GCC Inline KernelGS Offset
Posted: Tue Jul 14, 2015 8:17 pm
Edit: Found it out, thanks!
Hi All, I am trying to get GCC to produce:The 0x45 above will change as my structure changes, but I am having trouble telling asm how to fix the value.
Any help is appreciated.Example calling code:It currently Produces:Which is fine, but I would like a
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