Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions SyringeDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BYTE*>(it.first) + 0x05);
static_cast<BYTE*>(it.first) + /*0x05*/overridden_len);
ApplyPatch(p_code, jmp_back);
ApplyPatch(p_code + 0x01, rel);

Expand All @@ -277,7 +279,7 @@ DWORD SyringeDebugger::HandleException(DEBUG_EVENT const& dbgEvent)
auto const p_original_code = static_cast<BYTE*>(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);

Expand Down