Skip to content

Commit

Permalink
Fix regression crash with post-only detours #3
Browse files Browse the repository at this point in the history
If there were no pre-detour handlers registered for a detour, there was no return Action of the pre hook available in a post hook, so don't try to access it.
  • Loading branch information
peace-maker committed Jun 4, 2020
1 parent 9d24417 commit 568ada2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions DynamicHooks/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
{
if (eHookType == HOOKTYPE_POST)
{
ReturnAction_t lastPreReturnAction = m_LastPreReturnAction.back();
m_LastPreReturnAction.pop();
ReturnAction_t lastPreReturnAction = ReturnAction_Ignored;
// Ignore hooks without a registered pre-hook handler.
if (!m_LastPreReturnAction.empty()) {
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 568ada2

Please sign in to comment.