Skip to content

Commit

Permalink
More regression fixes for post-only detours #3
Browse files Browse the repository at this point in the history
Don't try to pop values from any other stacks if there was nothing pushed in a pre-hook.
  • Loading branch information
peace-maker committed Jun 9, 2020
1 parent b492c66 commit 370ab37
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions DynamicHooks/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ bool CHook::AreCallbacksRegistered()

ReturnAction_t CHook::HookHandler(HookType_t eHookType)
{
if (eHookType == HOOKTYPE_POST)
if (eHookType == HOOKTYPE_POST && !m_LastPreReturnAction.empty())
{
ReturnAction_t lastPreReturnAction = ReturnAction_Ignored;
// Ignore hooks without a registered pre-hook handler.
if (!m_LastPreReturnAction.empty()) {
lastPreReturnAction = m_LastPreReturnAction.back();
m_LastPreReturnAction.pop();
}
ReturnAction_t lastPreReturnAction = m_LastPreReturnAction.back();
m_LastPreReturnAction.pop();
if (lastPreReturnAction == ReturnAction_Override)
m_pCallingConvention->RestoreReturnValue(m_pRegisters);
if (lastPreReturnAction < ReturnAction_Supercede)
Expand Down

0 comments on commit 370ab37

Please sign in to comment.