From f68e2dbd6c8768b5e4cf220941ce2be6501646b8 Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Sat, 27 Jul 2024 04:12:33 -0300 Subject: [PATCH] fix tls patch on windows based on TlsGetValue in kernel32.dll --- src/core/cpu_patches.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index 2a9cf5e29..4d11d625a 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -296,9 +296,8 @@ static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGe // Load the pointer to the table of TLS slots. c.putSeg(gs); - c.mov(dst, ptr[reinterpret_cast(teb_offset)]); // Load the pointer to our buffer. - c.mov(dst, qword[dst + tls_index * sizeof(LPVOID)]); + c.mov(dst, ptr[reinterpret_cast(teb_offset + tls_index * sizeof(LPVOID))]); #elif defined(__APPLE__) // The following logic is based on the Darwin implementation of _os_tsd_get_direct, used by // pthread_getspecific https://github.com/apple/darwin-xnu/blob/main/libsyscall/os/tsd.h#L89-L96