Save this pointer on windows after calling original function

ecx might get cleared before the original function returns leading to garbage in the post handler.
This commit is contained in:
Peace-Maker
2016-12-13 17:47:59 -07:00
parent b18e3284e1
commit 8221a6522b
4 changed files with 23 additions and 0 deletions
+4
View File
@@ -157,6 +157,8 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
{
if (m_LastPreReturnAction == ReturnAction_Override)
m_pCallingConvention->RestoreReturnValue(m_pRegisters);
if (m_LastPreReturnAction < ReturnAction_Supercede)
m_pCallingConvention->RestorePostCallRegisters(m_pRegisters);
}
ReturnAction_t returnAction = ReturnAction_Ignored;
@@ -177,6 +179,8 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
m_LastPreReturnAction = returnAction;
if (returnAction == ReturnAction_Override)
m_pCallingConvention->SaveReturnValue(m_pRegisters);
if (returnAction < ReturnAction_Supercede)
m_pCallingConvention->SavePostCallRegisters(m_pRegisters);
}
return returnAction;