Skip to content

Commit

Permalink
refactor(hook): pad jump with nops
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed May 12, 2024
1 parent 982d0ac commit 5347bfb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/hooks.hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,15 @@ namespace lime
const auto spring_board = near ? false : rtn->m_impl->create_springboard();
const auto destination = spring_board ? rtn->m_impl->spring_board->start() : target;

const auto jump = impl::make_jmp(source, destination, near || spring_board);
auto jump = impl::make_jmp(source, destination, near || spring_board);
const auto prologue = rtn->m_impl->prologue.size();

if (jump.size() < prologue)
{
const auto remaining = prologue - jump.size();
std::vector<std::uint8_t> padding(remaining, 0x90);
std::ranges::move(padding, std::back_inserter(jump));
}

if (!rtn->m_impl->source_page->protect(rwx))
{
Expand Down

0 comments on commit 5347bfb

Please sign in to comment.