Quote:
[Originally Posted by disavowed]according to the leak from Mainsoft, i'm right  |
Of course you're right, disavowed, but as usually things go in this strange world of human beings, everyone is right!
To make more light in this matter, let's do some reverse engineering...
Kernel debugger will help us a lot...
In all M$ operating systems the command
!teb is contained in an extension debugger DLL. Let's see...
NT4: F88 bytes are read for TEB structure. Disasm from NT4FRE\NTSDEXTS.DLL follows.
Code:
push [ebp+var_F54] ; var_F88-var_F54: +34
push offset aLasterrorval_0 ; " LastErrorValue: %u\n"
call dword_4EE92EB4
add esp, 8
push [ebp+var_394] ; var_F88-var_394: +BF4
push offset aLaststatusva_0 ; " LastStatusValue: %x\n"
call dword_4EE92EB4
add esp, 8
push [ebp+var_F50] ; var_F88-var_F50: +38
push offset aCountOwnedLock ; " Count Owned Locks:%u\n"
call dword_4EE92EB4
add esp, 8
push [ebp+var_60] ; var_F88-var_60: +F28
push offset aHarderrorsmode ; " HardErrorsMode: %u\n"
call dword_4EE92EB4
Win2K: FA4 bytes are read for TEB structure. Disasm from W2KFRE\NTSDEXTS.DLL follows.
Code:
push [ebp+var_F70] ; var_FA4-var_F70: +34
push offset aLasterrorval_0 ; " LastErrorValue: %u\n"
call dword_4EE95024
pop ecx
pop ecx
push [ebp+var_3B0] ; var_FA4-var_FB0: +BF4
push offset aLaststatusva_0 ; " LastStatusValue: %x\n"
call dword_4EE95024
pop ecx
pop ecx
push [ebp+var_F6C] ; var_FA4-var_F6C: +38
push offset aCountOwnedLock ; " Count Owned Locks:%u\n"
call dword_4EE95024
pop ecx
pop ecx
push [ebp+var_7C] ; var_FA4-var_7C: +F28
push offset aHarderrorsmode ; " HardErrorsMode: %u\n"
call dword_4EE95024
WinXP: since I'm playing on an XP box, there is no need to disasm; command dt may be used!
Code:
kd> dt _TEB
+0x000 NtTib : _NT_TIB
+0x01c EnvironmentPointer : Ptr32 Void
+0x020 ClientId : _CLIENT_ID
+0x028 ActiveRpcHandle : Ptr32 Void
+0x02c ThreadLocalStoragePointer : Ptr32 Void
+0x030 ProcessEnvironmentBlock : Ptr32 _PEB
+0x034 LastErrorValue : Uint4B
+0x038 CountOfOwnedCriticalSections : Uint4B
+0x03c CsrClientThread : Ptr32 Void
+0x040 Win32ThreadInfo : Ptr32 Void
+0x044 User32Reserved : [26] Uint4B
+0x0ac UserReserved : [5] Uint4B
+0x0c0 WOW32Reserved : Ptr32 Void
+0x0c4 CurrentLocale : Uint4B
+0x0c8 FpSoftwareStatusRegister : Uint4B
+0x0cc SystemReserved1 : [54] Ptr32 Void
+0x1a4 ExceptionCode : Int4B
+0x1a8 ActivationContextStack : _ACTIVATION_CONTEXT_STACK
+0x1bc SpareBytes1 : [24] UChar
+0x1d4 GdiTebBatch : _GDI_TEB_BATCH
+0x6b4 RealClientId : _CLIENT_ID
+0x6bc GdiCachedProcessHandle : Ptr32 Void
+0x6c0 GdiClientPID : Uint4B
+0x6c4 GdiClientTID : Uint4B
+0x6c8 GdiThreadLocalInfo : Ptr32 Void
+0x6cc Win32ClientInfo : [62] Uint4B
+0x7c4 glDispatchTable : [233] Ptr32 Void
+0xb68 glReserved1 : [29] Uint4B
+0xbdc glReserved2 : Ptr32 Void
+0xbe0 glSectionInfo : Ptr32 Void
+0xbe4 glSection : Ptr32 Void
+0xbe8 glTable : Ptr32 Void
+0xbec glCurrentRC : Ptr32 Void
+0xbf0 glContext : Ptr32 Void
+0xbf4 LastStatusValue : Uint4B
+0xbf8 StaticUnicodeString : _UNICODE_STRING
+0xc00 StaticUnicodeBuffer : [261] Uint2B
+0xe0c DeallocationStack : Ptr32 Void
+0xe10 TlsSlots : [64] Ptr32 Void
+0xf10 TlsLinks : _LIST_ENTRY
+0xf18 Vdm : Ptr32 Void
+0xf1c ReservedForNtRpc : Ptr32 Void
+0xf20 DbgSsReserved : [2] Ptr32 Void
+0xf28 HardErrorsAreDisabled : Uint4B
+0xf2c Instrumentation : [16] Ptr32 Void
+0xf6c WinSockData : Ptr32 Void
+0xf70 GdiBatchCount : Uint4B
+0xf74 InDbgPrint : UChar
+0xf75 FreeStackOnTermination : UChar
+0xf76 HasFiberData : UChar
+0xf77 IdealProcessor : UChar
+0xf78 Spare3 : Uint4B
+0xf7c ReservedForPerf : Ptr32 Void
+0xf80 ReservedForOle : Ptr32 Void
+0xf84 WaitingOnLoaderLock : Uint4B
+0xf88 Wx86Thread : _Wx86ThreadState
+0xf94 TlsExpansionSlots : Ptr32 Ptr32 Void
+0xf98 ImpersonationLocale : Uint4B
+0xf9c IsImpersonating : Uint4B
+0xfa0 NlsCache : Ptr32 Void
+0xfa4 pShimData : Ptr32 Void
+0xfa8 HeapVirtualAffinity : Uint4B
+0xfac CurrentTransactionHandle : Ptr32 Void
+0xfb0 ActiveFrame : Ptr32 _TEB_ACTIVE_FRAME
So we can see that the TEB structure is grown from F88 to FA4 to FB4 with the evolution (involution?) of M$ systems, but the offsets of the four fields are always the same
Code:
LastErrorValue: +34h
LastStatusValue: +BF4h
Count Owned Locks:+38h
HardErrorsMode: +F28h
Well, what about the structure NT_TEB_ADDON described by Thomas Kruse (Pegasus?) in Assembling Programming Journal Vol.1 No.1? He seems the only guy to be wrong! He correctly located only the first field, LastErrorValue, at bias +34, but the structure NT_TEB_ADDON is not existing, and the TEB is a lot bigger than 44h bytes, as we saw!
Regards, bilbo