diff --git a/src/client/component/tls.cpp b/src/client/component/tls.cpp index d27e58a0..bd411223 100644 --- a/src/client/component/tls.cpp +++ b/src/client/component/tls.cpp @@ -23,8 +23,7 @@ namespace tls void get_tls_stub(utils::hook::assembler& a) { - std::uint8_t bytes[] = {0x65, 0x48, 0x8B, 0x04, 0x25, 0x58, 0x00, 0x00, 0x00}; // mov rax, gs:58h - a.embed(bytes, sizeof(bytes)); + a.mov(rax, seg_ptr(gs, 0x58)); a.add(rax, get_tls_index() * 8); a.ret(); } diff --git a/src/common/utils/hook.cpp b/src/common/utils/hook.cpp index 56322023..9af1ee7c 100644 --- a/src/common/utils/hook.cpp +++ b/src/common/utils/hook.cpp @@ -3,6 +3,13 @@ #include +Mem seg_ptr(const SReg& segment, const uint64_t off) +{ + auto mem = ptr_abs(off); + mem.setSegment(segment); + return mem; +} + namespace utils::hook { namespace diff --git a/src/common/utils/hook.hpp b/src/common/utils/hook.hpp index cabd4b97..3a1480ad 100644 --- a/src/common/utils/hook.hpp +++ b/src/common/utils/hook.hpp @@ -7,6 +7,8 @@ using namespace asmjit::x86; +Mem seg_ptr(const SReg& segment, const uint64_t off); + namespace utils::hook { namespace detail