From 5347bfb6b8945d03f32e678c0b98122601833b3f Mon Sep 17 00:00:00 2001 From: Curve Date: Mon, 13 May 2024 01:07:26 +0200 Subject: [PATCH] refactor(hook): pad jump with nops --- src/hooks.hook.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hooks.hook.cpp b/src/hooks.hook.cpp index 38c03cc..fd54fd7 100644 --- a/src/hooks.hook.cpp +++ b/src/hooks.hook.cpp @@ -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 padding(remaining, 0x90); + std::ranges::move(padding, std::back_inserter(jump)); + } if (!rtn->m_impl->source_page->protect(rwx)) {