Fix not clearing return address cache after use

The esp pointer wasn't removed from the map after the function was called and the original return address was retrieved.
If the same function was called again with the same esp this would fail due to there already being an (old) return address associated with the esp.
This commit is contained in:
Peace-Maker 2018-01-22 00:11:28 +01:00
parent b6382f1c27
commit 5d21350e9e

View File

@ -189,10 +189,19 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
void* __cdecl CHook::GetReturnAddress(void* pESP)
{
ReturnAddressMap::Result r = m_RetAddr.find(pESP);
assert(r.found());
if (!r.found())
{
puts("ESP not present.");
return NULL;
}
return r->value;
void *pRetAddr = r->value;
// Clear the stack address from the cache now that we ran the post hook code.
m_RetAddr.remove(r);
return pRetAddr;
}
void __cdecl CHook::SetReturnAddress(void* pRetAddr, void* pESP)