Hi All, I am trying to get GCC to produce:
Code: Select all
movq %%gs:0x45, xxxx
Any help is appreciated.
Code: Select all
#define GetKernelGSPointerData(KernelPointerType, Member, ReturnType, ReturnVariableName) \
ReturnType ReturnVariableName; \
{ int ofs = offset(KernelPointerType, Member); asm volatile ("movq %%gs:%1, %0" : "=q"(ReturnVariableName) : "m"(ofs) ); }
Code: Select all
#define offset(type, member) ((WORD)(QWORD)&((type *)0)->member);
Code: Select all
GetKernelGSPointerData(tCPU, Sleeping, QWORD, Test);
Code: Select all
30c2cb: c7 04 24 00 00 00 00 mov DWORD PTR [rsp],0x0
30c2d2: 65 48 8b 34 24 mov rsi,QWORD PTR gs:[rsp]
Code: Select all
mov rsi, QWORD PTR gs:0