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);