Skip to content

Commit 961615e

Browse files
committed
Fix dhooks regression
1 parent 24679be commit 961615e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

extensions/dhooks/DynamicHooks/hook.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,13 @@ void CHook::CreateBridge()
317317
PrintRegisters(jit);
318318

319319
// Jump to the trampoline
320+
jit.sub(rsp, 8);
321+
jit.push(rax);
320322
jit.mov(rax, reinterpret_cast<std::uint64_t>(&m_pTrampoline));
321323
jit.mov(rax, rax());
322-
jit.jump(rax);
324+
jit.mov(rsp(8), rax);
325+
jit.pop(rax);
326+
jit.retn();
323327

324328
// This code will be executed if a pre-hook returns ReturnAction_Supercede
325329
jit.rewrite<std::int32_t>(jumpOff - sizeof(std::int32_t), jit.get_outputpos() - jumpOff);
@@ -621,8 +625,12 @@ void CHook::CreateBridge()
621625
masm.j(equal, &label_supercede);
622626

623627
// Jump to the trampoline
628+
masm.subl(esp, 4);
629+
masm.push(eax);
624630
masm.movl(eax, Operand(ExternalAddress(&m_pTrampoline)));
625-
masm.jmp(eax);
631+
masm.movl(Operand(esp, 4), eax);
632+
masm.pop(eax);
633+
masm.ret();
626634

627635
// This code will be executed if a pre-hook returns ReturnAction_Supercede
628636
masm.bind(&label_supercede);

0 commit comments

Comments
 (0)