在 2022/6/30 00:24, Ozkan Sezer 写道:

Lazy solution for me would be something like the following:
Does it look correct?

#if defined(__MINGW32__) && defined(__x86_64__)
#undef NtCurrentTeb
#define NtCurrentTeb MI_NtCurrentTeb
struct _TEB * MI_NtCurrentTeb(void) {
   void *ret;
   __asm__ __volatile__ ("movq %%gs:0x30,%0" : "=r" (ret));
   return ret;
}

The `__volatile__` specifier is not necessary there, because the read operation has no side effect. Moreover, this function is suitable for the `const` attribute:

   struct _TEB * MI_NtCurrentTeb(void) __attribute__((__const__));



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to