Skip to content

Commit

Permalink
refactor: use Relocation::write_func
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 committed Nov 15, 2024
1 parent 2da6699 commit c8ae644
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
namespace stl
{
namespace detail
{
struct asm_patch :
Xbyak::CodeGenerator
{
asm_patch(std::uintptr_t a_dst)
{
Xbyak::Label dst;

jmp(ptr[rip + dst]);

L(dst);
dq(a_dst);
}
};

static void asm_jump(std::uintptr_t a_from, [[maybe_unused]] std::size_t a_size, std::uintptr_t a_to)
{
asm_patch p{ a_to };
p.ready();
assert(p.getSize() <= a_size);
REL::safe_write(
a_from,
std::span{ p.getCode<const std::byte*>(), p.getSize() });
}
}

static void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to)
{
REL::safe_fill(a_from, REL::INT3, a_size);
detail::asm_jump(a_from, a_size, a_to);
}
}

namespace Config
{
namespace General
Expand All @@ -55,8 +19,8 @@ class ScrapHeap
public:
static void Install()
{
static REL::Relocation<std::uintptr_t> target{ REL::ID(2228361) };
stl::asm_replace(target.address(), 0x10, reinterpret_cast<std::uintptr_t>(QMaxMemory));
static REL::Relocation target{ REL::ID(2228361) };
target.write_func(0x10, QMaxMemory);

auto iScrapHeapMult = Config::General::iScrapHeapMult.GetValue();
switch (iScrapHeapMult)
Expand Down

0 comments on commit c8ae644

Please sign in to comment.