From 0d495e53e7bbc6ed5c4b524e439f20b804b1d860 Mon Sep 17 00:00:00 2001 From: Almira <42338880+saralmira@users.noreply.github.com> Date: Mon, 10 Nov 2025 10:47:43 +0800 Subject: [PATCH] Skip NOP codes when jumping back --- SyringeDebugger.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SyringeDebugger.cpp b/SyringeDebugger.cpp index 2651a68..da70b04 100644 --- a/SyringeDebugger.cpp +++ b/SyringeDebugger.cpp @@ -247,10 +247,12 @@ DWORD SyringeDebugger::HandleException(DEBUG_EVENT const& dbgEvent) p_code += overridden; } + const auto overridden_len = std::max(overridden, sizeof(jmp)); + // write the jump back auto const rel = RelativeOffset( base + (p_code - code.data() + 0x05), - static_cast(it.first) + 0x05); + static_cast(it.first) + /*0x05*/overridden_len); ApplyPatch(p_code, jmp_back); ApplyPatch(p_code + 0x01, rel); @@ -277,7 +279,7 @@ DWORD SyringeDebugger::HandleException(DEBUG_EVENT const& dbgEvent) auto const p_original_code = static_cast(it.first); auto const rel2 = RelativeOffset(p_original_code + 5, base); - code.assign(std::max(overridden, sizeof(jmp)), NOP); + code.assign(overridden_len, NOP); ApplyPatch(code.data(), jmp); ApplyPatch(code.data() + 0x01, rel2);