Windows stores the TEB in FS (32bit) or GS (64bit) segment register. In a program using NtCurrentPeb()
the x86 instruction is mov rax, gs:60h
. The 0x60
value is offsetof(TEB, ProcessEnvironmentBlock)
.
To use this in a program I've to include both Windows.h
and Winternl.h
header file which has bunch of other #define
. As the question said I want to use the function without these header file and by directly accessing the segment register. I've also made a separate header file with the TEB and PEB structure. So how can I do that? I was thinking with __asm
keyword and a typedef NtCurrentTeb()
or something.