GetCurrentProcess/Thread(Id)的反汇编

kernel32!GetCurrentProcessId:
7c8099b0 64a118000000    mov     eax,dword ptr fs:[00000018h]
7c8099b6 8b4020          mov     eax,dword ptr [eax+20h]
7c8099b9 c3              ret

kernel32!GetCurrentProcess:
7c80de85 83c8ff          or      eax,0FFFFFFFFh
7c80de88 c3              ret

kernel32!GetCurrentThreadId:
7c8097b8 64a118000000    mov     eax,dword ptr fs:[00000018h]
7c8097be 8b4024          mov     eax,dword ptr [eax+24h]
7c8097c1 c3              ret

kernel32!GetCurrentThread:
7c80997b 6afe            push    0FFFFFFFEh
7c80997d 58              pop     eax
7c80997e c3              ret

在RING3下,FS指向当前线程的TEB结构.
nt!_TEB
   +0x000 NtTib            : _NT_TIB
      +0x000 ExceptionList    : Ptr32
      +0x004 StackBase        : Ptr32
      +0x008 StackLimit       : Ptr32
      +0x00c SubSystemTib     : Ptr32
      +0x010 FiberData        : Ptr32
      +0x010 Version          : Uint4B
      +0x014 ArbitraryUserPointer : Ptr32
      +0x018 Self             : Ptr32
   +0x01c EnvironmentPointer : Ptr32
   +0x020 ClientId         : _CLIENT_ID
      +0x000 UniqueProcess    : Ptr32    <---当前进程的ID
      +0x004 UniqueThread     : Ptr32    <---当前线程的ID
   +0x028 ActiveRpcHandle  : Ptr32
   +0x02c ThreadLocalStoragePointer : Ptr32
   +0x030 ProcessEnvironmentBlock : Ptr32
   +0x034 LastErrorValue   : Uint4B
   +0x038 CountOfOwnedCriticalSections : Uint4B
   +0x03c CsrClientThread  : Ptr32
   +0x040 Win32ThreadInfo  : Ptr32
   +0x044 User32Reserved   : Uint4B
   +0x0ac UserReserved     : Uint4B
   +0x0c0 WOW32Reserved    : Ptr32
   +0x0c4 CurrentLocale    : Uint4B
   +0x0c8 FpSoftwareStatusRegister : Uint4B
   +0x0cc SystemReserved1  : Ptr32
   +0x1a4 ExceptionCode    : Int4B
   +0x1a8 ActivationContextStack : _ACTIVATION_CONTEXT_STACK
      +0x000 Flags            : Uint4B
      +0x004 NextCookieSequenceNumber : Uint4B
      +0x008 ActiveFrame      : Ptr32
      +0x00c FrameListCache   : _LIST_ENTRY
         +0x000 Flink            : Ptr32
         +0x004 Blink            : Ptr32
   +0x1bc SpareBytes1      : UChar
   +0x1d4 GdiTebBatch      : _GDI_TEB_BATCH
      +0x000 Offset           : Uint4B
      +0x004 HDC              : Uint4B
      +0x008 Buffer           : Uint4B
   +0x6b4 RealClientId     : _CLIENT_ID
      +0x000 UniqueProcess    : Ptr32
      +0x004 UniqueThread     : Ptr32
   +0x6bc GdiCachedProcessHandle : Ptr32
   +0x6c0 GdiClientPID     : Uint4B
   +0x6c4 GdiClientTID     : Uint4B
   +0x6c8 GdiThreadLocalInfo : Ptr32
   +0x6cc Win32ClientInfo  : Uint4B
   +0x7c4 glDispatchTable  : Ptr32
   +0xb68 glReserved1      : Uint4B
   +0xbdc glReserved2      : Ptr32
   +0xbe0 glSectionInfo    : Ptr32
   +0xbe4 glSection        : Ptr32
   +0xbe8 glTable          : Ptr32
   +0xbec glCurrentRC      : Ptr32
   +0xbf0 glContext        : Ptr32
   +0xbf4 LastStatusValue  : Uint4B
   +0xbf8 StaticUnicodeString : _UNICODE_STRING
      +0x000 Length           : Uint2B
      +0x002 MaximumLength    : Uint2B
      +0x004 Buffer           : Ptr32
   +0xc00 StaticUnicodeBuffer : Uint2B
   +0xe0c DeallocationStack : Ptr32
   +0xe10 TlsSlots         : Ptr32
   +0xf10 TlsLinks         : _LIST_ENTRY
      +0x000 Flink            : Ptr32
      +0x004 Blink            : Ptr32
   +0xf18 Vdm              : Ptr32
   +0xf1c ReservedForNtRpc : Ptr32
   +0xf20 DbgSsReserved    : Ptr32
   +0xf28 HardErrorsAreDisabled : Uint4B
   +0xf2c Instrumentation  : Ptr32
   +0xf6c WinSockData      : Ptr32
   +0xf70 GdiBatchCount    : Uint4B
   +0xf74 InDbgPrint       : UChar
   +0xf75 FreeStackOnTermination : UChar
   +0xf76 HasFiberData     : UChar
   +0xf77 IdealProcessor   : UChar
   +0xf78 Spare3           : Uint4B
   +0xf7c ReservedForPerf  : Ptr32
   +0xf80 ReservedForOle   : Ptr32
   +0xf84 WaitingOnLoaderLock : Uint4B
   +0xf88 Wx86Thread       : _Wx86ThreadState
      +0x000 CallBx86Eip      : Ptr32
      +0x004 DeallocationCpu  : Ptr32
      +0x008 UseKnownWx86Dll  : UChar
      +0x009 OleStubInvoked   : Char
   +0xf94 TlsExpansionSlots : Ptr32
   +0xf98 ImpersonationLocale : Uint4B
   +0xf9c IsImpersonating  : Uint4B
   +0xfa0 NlsCache         : Ptr32
   +0xfa4 pShimData        : Ptr32
   +0xfa8 HeapVirtualAffinity : Uint4B
   +0xfac CurrentTransactionHandle : Ptr32
   +0xfb0 ActiveFrame      : Ptr32
   +0xfb4 SafeThunkCall    : UChar
   +0xfb5 BooleanSpare     : UChar

你可能感兴趣的:(thread,c,list,汇编,String,buffer)