Skip to content

Commit

Permalink
Fix dhooks regression (#2249)
Browse files Browse the repository at this point in the history
Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com>
  • Loading branch information
Kenzzer and Kenzzer authored Feb 4, 2025
1 parent b5e077c commit f6737a4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions extensions/dhooks/DynamicHooks/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,13 @@ void CHook::CreateBridge()
PrintRegisters(jit);

// Jump to the trampoline
jit.sub(rsp, 8);
jit.push(rax);
jit.mov(rax, reinterpret_cast<std::uint64_t>(&m_pTrampoline));
jit.mov(rax, rax());
jit.jump(rax);
jit.mov(rsp(8), rax);
jit.pop(rax);
jit.retn();

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

// Jump to the trampoline
masm.subl(esp, 4);
masm.push(eax);
masm.movl(eax, Operand(ExternalAddress(&m_pTrampoline)));
masm.jmp(eax);
masm.movl(Operand(esp, 4), eax);
masm.pop(eax);
masm.ret();

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

0 comments on commit f6737a4

Please sign in to comment.