From 02e0545d754b372b524926f3fbd4bb7de03008b6 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Tue, 23 Jan 2018 13:39:37 +0100 Subject: [PATCH] Fix saving arguments in custom registers in combination with arguments on the stack If a function was optimized to only pass one parameter in a register, but still pass other parameters on the stack, save the registers at the correct offset in the buffer. --- dynhooks_sourcepawn.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dynhooks_sourcepawn.cpp b/dynhooks_sourcepawn.cpp index ae0a980..6c73a07 100644 --- a/dynhooks_sourcepawn.cpp +++ b/dynhooks_sourcepawn.cpp @@ -599,8 +599,9 @@ HookParamsStruct *CDynamicHooksSourcePawn::GetParamStruct() continue; int size = argTypes[i].size; + void *paramAddr = (void *)((intptr_t)params->orgParams + offset); void *regAddr = callingConvention->GetArgumentPtr(i + firstArg, m_pDetour->m_pRegisters); - memcpy(params->orgParams + offset, regAddr, size); + memcpy(paramAddr, regAddr, size); offset += size; }