Reputation: 145
I used this instruction in Visual C++ inline assembly
lea eax, FS:[0]
Why did eax
get a zero?
And how do I get the linear address of FS:[0]
?
Upvotes: 3
Views: 893
Reputation: 39621
Assuming FS points to the Windows Thread Information Block (TIB), also known as the Thread Environment Block (TEB), you get the linear address of the TIB by reading the 32-bit value at fs:[0x18]
. The best way to do this in Visual C++ is to use the __readfsdword
intrinsic:
TEB *teb = (TEB *) __readfsdword(0x18);
Upvotes: 6
Reputation: 37212
The LEA
instruction ("Load Effective Address") is badly named (e.g. should probably be called LEO
/"Load Effective Offset") because it only calculates the offset within a segment.
Upvotes: 3