namespace SKSE::stl { namespace detail { struct asm_patch : Xbyak::CodeGenerator { asm_patch(std::uintptr_t a_dst) { Xbyak::Label dst; mov(rax, a_dst); jmp(rax); } }; } void asm_jump(std::uintptr_t a_from, [[maybe_unused]] std::size_t a_size, std::uintptr_t a_to) { detail::asm_patch p{ a_to }; p.ready(); assert(p.getSize() <= a_size); REL::safe_write( a_from, std::span{ p.getCode(), p.getSize() }); } 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); asm_jump(a_from, a_size, a_to); } }