-
Notifications
You must be signed in to change notification settings - Fork 14
2.0 Hook: Memory Editing
DK edited this page Mar 3, 2024
·
3 revisions
DKUtil::Hook
offers some memory writing methods like other library does.
// write raw data with size
void WriteData(std::uintptr_t a_dst, const void* a_data, const std::size_t a_size) noexcept;
// write immediate value (trivial, integral or standard layout(pod) types)
void WriteImm(std::uintptr_t a_dst, const dku_h_pod_t auto& a_data) noexcept;
// write packed memory structure
void WritePatch(std::uintptr_t a_dst, const Patch* a_patch) noexcept;
void WritePatch(std::uintptr_t a_dst, const Xbyak::CodeGenerator* a_patch) noexcept;
Before committing any action that requires a trampoline (e.g. detour hooks, cave hooks, asm patches with exceeding sizes), DKUtil::Hook
requires a manual dku::Hook::Trampoline::AllocTrampoline(size)
call to initiate a page allocation for trampoline to use. This should be called only once, with sufficient size.
For SKSE, SFSE, and F4SE plugin projects, DKUtil::Hook
will use commonlib's trampoline instead of its internal trampoline.