PageRenderTime 55ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/python/helpers/pydev/pydevd_attach_to_process/winappdbg/win32/peb_teb.py

http://github.com/JetBrains/intellij-community
Python | 3435 lines | 1692 code | 72 blank | 1671 comment | 47 complexity | 6d56e5b1c3a1d599fb5dd8695c77f236 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, MPL-2.0-no-copyleft-exception, MIT, EPL-1.0, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Copyright (c) 2009-2014, Mario Vilas
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are met:
  8. #
  9. # * Redistributions of source code must retain the above copyright notice,
  10. # this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above copyright
  12. # notice,this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. # * Neither the name of the copyright holder nor the names of its
  15. # contributors may be used to endorse or promote products derived from
  16. # this software without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  22. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. # POSSIBILITY OF SUCH DAMAGE.
  29. """
  30. PEB and TEB structures, constants and data types.
  31. """
  32. __revision__ = "$Id$"
  33. from winappdbg.win32.defines import *
  34. from winappdbg.win32.version import os
  35. #==============================================================================
  36. # This is used later on to calculate the list of exported symbols.
  37. _all = None
  38. _all = set(vars().keys())
  39. #==============================================================================
  40. #--- PEB and TEB structures, constants and data types -------------------------
  41. # From http://www.nirsoft.net/kernel_struct/vista/CLIENT_ID.html
  42. #
  43. # typedef struct _CLIENT_ID
  44. # {
  45. # PVOID UniqueProcess;
  46. # PVOID UniqueThread;
  47. # } CLIENT_ID, *PCLIENT_ID;
  48. class CLIENT_ID(Structure):
  49. _fields_ = [
  50. ("UniqueProcess", PVOID),
  51. ("UniqueThread", PVOID),
  52. ]
  53. # From MSDN:
  54. #
  55. # typedef struct _LDR_DATA_TABLE_ENTRY {
  56. # BYTE Reserved1[2];
  57. # LIST_ENTRY InMemoryOrderLinks;
  58. # PVOID Reserved2[2];
  59. # PVOID DllBase;
  60. # PVOID EntryPoint;
  61. # PVOID Reserved3;
  62. # UNICODE_STRING FullDllName;
  63. # BYTE Reserved4[8];
  64. # PVOID Reserved5[3];
  65. # union {
  66. # ULONG CheckSum;
  67. # PVOID Reserved6;
  68. # };
  69. # ULONG TimeDateStamp;
  70. # } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
  71. ##class LDR_DATA_TABLE_ENTRY(Structure):
  72. ## _fields_ = [
  73. ## ("Reserved1", BYTE * 2),
  74. ## ("InMemoryOrderLinks", LIST_ENTRY),
  75. ## ("Reserved2", PVOID * 2),
  76. ## ("DllBase", PVOID),
  77. ## ("EntryPoint", PVOID),
  78. ## ("Reserved3", PVOID),
  79. ## ("FullDllName", UNICODE_STRING),
  80. ## ("Reserved4", BYTE * 8),
  81. ## ("Reserved5", PVOID * 3),
  82. ## ("CheckSum", ULONG),
  83. ## ("TimeDateStamp", ULONG),
  84. ##]
  85. # From MSDN:
  86. #
  87. # typedef struct _PEB_LDR_DATA {
  88. # BYTE Reserved1[8];
  89. # PVOID Reserved2[3];
  90. # LIST_ENTRY InMemoryOrderModuleList;
  91. # } PEB_LDR_DATA,
  92. # *PPEB_LDR_DATA;
  93. ##class PEB_LDR_DATA(Structure):
  94. ## _fields_ = [
  95. ## ("Reserved1", BYTE),
  96. ## ("Reserved2", PVOID),
  97. ## ("InMemoryOrderModuleList", LIST_ENTRY),
  98. ##]
  99. # From http://undocumented.ntinternals.net/UserMode/Structures/RTL_USER_PROCESS_PARAMETERS.html
  100. # typedef struct _RTL_USER_PROCESS_PARAMETERS {
  101. # ULONG MaximumLength;
  102. # ULONG Length;
  103. # ULONG Flags;
  104. # ULONG DebugFlags;
  105. # PVOID ConsoleHandle;
  106. # ULONG ConsoleFlags;
  107. # HANDLE StdInputHandle;
  108. # HANDLE StdOutputHandle;
  109. # HANDLE StdErrorHandle;
  110. # UNICODE_STRING CurrentDirectoryPath;
  111. # HANDLE CurrentDirectoryHandle;
  112. # UNICODE_STRING DllPath;
  113. # UNICODE_STRING ImagePathName;
  114. # UNICODE_STRING CommandLine;
  115. # PVOID Environment;
  116. # ULONG StartingPositionLeft;
  117. # ULONG StartingPositionTop;
  118. # ULONG Width;
  119. # ULONG Height;
  120. # ULONG CharWidth;
  121. # ULONG CharHeight;
  122. # ULONG ConsoleTextAttributes;
  123. # ULONG WindowFlags;
  124. # ULONG ShowWindowFlags;
  125. # UNICODE_STRING WindowTitle;
  126. # UNICODE_STRING DesktopName;
  127. # UNICODE_STRING ShellInfo;
  128. # UNICODE_STRING RuntimeData;
  129. # RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
  130. # } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
  131. # kd> dt _RTL_USER_PROCESS_PARAMETERS
  132. # ntdll!_RTL_USER_PROCESS_PARAMETERS
  133. # +0x000 MaximumLength : Uint4B
  134. # +0x004 Length : Uint4B
  135. # +0x008 Flags : Uint4B
  136. # +0x00c DebugFlags : Uint4B
  137. # +0x010 ConsoleHandle : Ptr32 Void
  138. # +0x014 ConsoleFlags : Uint4B
  139. # +0x018 StandardInput : Ptr32 Void
  140. # +0x01c StandardOutput : Ptr32 Void
  141. # +0x020 StandardError : Ptr32 Void
  142. # +0x024 CurrentDirectory : _CURDIR
  143. # +0x030 DllPath : _UNICODE_STRING
  144. # +0x038 ImagePathName : _UNICODE_STRING
  145. # +0x040 CommandLine : _UNICODE_STRING
  146. # +0x048 Environment : Ptr32 Void
  147. # +0x04c StartingX : Uint4B
  148. # +0x050 StartingY : Uint4B
  149. # +0x054 CountX : Uint4B
  150. # +0x058 CountY : Uint4B
  151. # +0x05c CountCharsX : Uint4B
  152. # +0x060 CountCharsY : Uint4B
  153. # +0x064 FillAttribute : Uint4B
  154. # +0x068 WindowFlags : Uint4B
  155. # +0x06c ShowWindowFlags : Uint4B
  156. # +0x070 WindowTitle : _UNICODE_STRING
  157. # +0x078 DesktopInfo : _UNICODE_STRING
  158. # +0x080 ShellInfo : _UNICODE_STRING
  159. # +0x088 RuntimeData : _UNICODE_STRING
  160. # +0x090 CurrentDirectores : [32] _RTL_DRIVE_LETTER_CURDIR
  161. # +0x290 EnvironmentSize : Uint4B
  162. ##class RTL_USER_PROCESS_PARAMETERS(Structure):
  163. ## _fields_ = [
  164. ## ("MaximumLength", ULONG),
  165. ## ("Length", ULONG),
  166. ## ("Flags", ULONG),
  167. ## ("DebugFlags", ULONG),
  168. ## ("ConsoleHandle", PVOID),
  169. ## ("ConsoleFlags", ULONG),
  170. ## ("StandardInput", HANDLE),
  171. ## ("StandardOutput", HANDLE),
  172. ## ("StandardError", HANDLE),
  173. ## ("CurrentDirectory", CURDIR),
  174. ## ("DllPath", UNICODE_STRING),
  175. ## ("ImagePathName", UNICODE_STRING),
  176. ## ("CommandLine", UNICODE_STRING),
  177. ## ("Environment", PVOID),
  178. ## ("StartingX", ULONG),
  179. ## ("StartingY", ULONG),
  180. ## ("CountX", ULONG),
  181. ## ("CountY", ULONG),
  182. ## ("CountCharsX", ULONG),
  183. ## ("CountCharsY", ULONG),
  184. ## ("FillAttribute", ULONG),
  185. ## ("WindowFlags", ULONG),
  186. ## ("ShowWindowFlags", ULONG),
  187. ## ("WindowTitle", UNICODE_STRING),
  188. ## ("DesktopInfo", UNICODE_STRING),
  189. ## ("ShellInfo", UNICODE_STRING),
  190. ## ("RuntimeData", UNICODE_STRING),
  191. ## ("CurrentDirectores", RTL_DRIVE_LETTER_CURDIR * 32), # typo here?
  192. ##
  193. ## # Windows 2008 and Vista
  194. ## ("EnvironmentSize", ULONG),
  195. ##]
  196. ## @property
  197. ## def CurrentDirectories(self):
  198. ## return self.CurrentDirectores
  199. # From MSDN:
  200. #
  201. # typedef struct _RTL_USER_PROCESS_PARAMETERS {
  202. # BYTE Reserved1[16];
  203. # PVOID Reserved2[10];
  204. # UNICODE_STRING ImagePathName;
  205. # UNICODE_STRING CommandLine;
  206. # } RTL_USER_PROCESS_PARAMETERS,
  207. # *PRTL_USER_PROCESS_PARAMETERS;
  208. class RTL_USER_PROCESS_PARAMETERS(Structure):
  209. _fields_ = [
  210. ("Reserved1", BYTE * 16),
  211. ("Reserved2", PVOID * 10),
  212. ("ImagePathName", UNICODE_STRING),
  213. ("CommandLine", UNICODE_STRING),
  214. ("Environment", PVOID), # undocumented!
  215. #
  216. # XXX TODO
  217. # This structure should be defined with all undocumented fields for
  218. # each version of Windows, just like it's being done for PEB and TEB.
  219. #
  220. ]
  221. PPS_POST_PROCESS_INIT_ROUTINE = PVOID
  222. #from MSDN:
  223. #
  224. # typedef struct _PEB {
  225. # BYTE Reserved1[2];
  226. # BYTE BeingDebugged;
  227. # BYTE Reserved2[21];
  228. # PPEB_LDR_DATA LoaderData;
  229. # PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
  230. # BYTE Reserved3[520];
  231. # PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;
  232. # BYTE Reserved4[136];
  233. # ULONG SessionId;
  234. # } PEB;
  235. ##class PEB(Structure):
  236. ## _fields_ = [
  237. ## ("Reserved1", BYTE * 2),
  238. ## ("BeingDebugged", BYTE),
  239. ## ("Reserved2", BYTE * 21),
  240. ## ("LoaderData", PVOID, # PPEB_LDR_DATA
  241. ## ("ProcessParameters", PVOID, # PRTL_USER_PROCESS_PARAMETERS
  242. ## ("Reserved3", BYTE * 520),
  243. ## ("PostProcessInitRoutine", PPS_POST_PROCESS_INIT_ROUTINE),
  244. ## ("Reserved4", BYTE),
  245. ## ("SessionId", ULONG),
  246. ##]
  247. # from MSDN:
  248. #
  249. # typedef struct _TEB {
  250. # BYTE Reserved1[1952];
  251. # PVOID Reserved2[412];
  252. # PVOID TlsSlots[64];
  253. # BYTE Reserved3[8];
  254. # PVOID Reserved4[26];
  255. # PVOID ReservedForOle;
  256. # PVOID Reserved5[4];
  257. # PVOID TlsExpansionSlots;
  258. # } TEB,
  259. # *PTEB;
  260. ##class TEB(Structure):
  261. ## _fields_ = [
  262. ## ("Reserved1", PVOID * 1952),
  263. ## ("Reserved2", PVOID * 412),
  264. ## ("TlsSlots", PVOID * 64),
  265. ## ("Reserved3", BYTE * 8),
  266. ## ("Reserved4", PVOID * 26),
  267. ## ("ReservedForOle", PVOID),
  268. ## ("Reserved5", PVOID * 4),
  269. ## ("TlsExpansionSlots", PVOID),
  270. ##]
  271. # from http://undocumented.ntinternals.net/UserMode/Structures/LDR_MODULE.html
  272. #
  273. # typedef struct _LDR_MODULE {
  274. # LIST_ENTRY InLoadOrderModuleList;
  275. # LIST_ENTRY InMemoryOrderModuleList;
  276. # LIST_ENTRY InInitializationOrderModuleList;
  277. # PVOID BaseAddress;
  278. # PVOID EntryPoint;
  279. # ULONG SizeOfImage;
  280. # UNICODE_STRING FullDllName;
  281. # UNICODE_STRING BaseDllName;
  282. # ULONG Flags;
  283. # SHORT LoadCount;
  284. # SHORT TlsIndex;
  285. # LIST_ENTRY HashTableEntry;
  286. # ULONG TimeDateStamp;
  287. # } LDR_MODULE, *PLDR_MODULE;
  288. class LDR_MODULE(Structure):
  289. _fields_ = [
  290. ("InLoadOrderModuleList", LIST_ENTRY),
  291. ("InMemoryOrderModuleList", LIST_ENTRY),
  292. ("InInitializationOrderModuleList", LIST_ENTRY),
  293. ("BaseAddress", PVOID),
  294. ("EntryPoint", PVOID),
  295. ("SizeOfImage", ULONG),
  296. ("FullDllName", UNICODE_STRING),
  297. ("BaseDllName", UNICODE_STRING),
  298. ("Flags", ULONG),
  299. ("LoadCount", SHORT),
  300. ("TlsIndex", SHORT),
  301. ("HashTableEntry", LIST_ENTRY),
  302. ("TimeDateStamp", ULONG),
  303. ]
  304. # from http://undocumented.ntinternals.net/UserMode/Structures/PEB_LDR_DATA.html
  305. #
  306. # typedef struct _PEB_LDR_DATA {
  307. # ULONG Length;
  308. # BOOLEAN Initialized;
  309. # PVOID SsHandle;
  310. # LIST_ENTRY InLoadOrderModuleList;
  311. # LIST_ENTRY InMemoryOrderModuleList;
  312. # LIST_ENTRY InInitializationOrderModuleList;
  313. # } PEB_LDR_DATA, *PPEB_LDR_DATA;
  314. class PEB_LDR_DATA(Structure):
  315. _fields_ = [
  316. ("Length", ULONG),
  317. ("Initialized", BOOLEAN),
  318. ("SsHandle", PVOID),
  319. ("InLoadOrderModuleList", LIST_ENTRY),
  320. ("InMemoryOrderModuleList", LIST_ENTRY),
  321. ("InInitializationOrderModuleList", LIST_ENTRY),
  322. ]
  323. # From http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/NT%20Objects/Process/PEB_FREE_BLOCK.html
  324. #
  325. # typedef struct _PEB_FREE_BLOCK {
  326. # PEB_FREE_BLOCK *Next;
  327. # ULONG Size;
  328. # } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
  329. class PEB_FREE_BLOCK(Structure):
  330. pass
  331. ##PPEB_FREE_BLOCK = POINTER(PEB_FREE_BLOCK)
  332. PPEB_FREE_BLOCK = PVOID
  333. PEB_FREE_BLOCK._fields_ = [
  334. ("Next", PPEB_FREE_BLOCK),
  335. ("Size", ULONG),
  336. ]
  337. # From http://undocumented.ntinternals.net/UserMode/Structures/RTL_DRIVE_LETTER_CURDIR.html
  338. #
  339. # typedef struct _RTL_DRIVE_LETTER_CURDIR {
  340. # USHORT Flags;
  341. # USHORT Length;
  342. # ULONG TimeStamp;
  343. # UNICODE_STRING DosPath;
  344. # } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
  345. class RTL_DRIVE_LETTER_CURDIR(Structure):
  346. _fields_ = [
  347. ("Flags", USHORT),
  348. ("Length", USHORT),
  349. ("TimeStamp", ULONG),
  350. ("DosPath", UNICODE_STRING),
  351. ]
  352. # From http://www.nirsoft.net/kernel_struct/vista/CURDIR.html
  353. #
  354. # typedef struct _CURDIR
  355. # {
  356. # UNICODE_STRING DosPath;
  357. # PVOID Handle;
  358. # } CURDIR, *PCURDIR;
  359. class CURDIR(Structure):
  360. _fields_ = [
  361. ("DosPath", UNICODE_STRING),
  362. ("Handle", PVOID),
  363. ]
  364. # From http://www.nirsoft.net/kernel_struct/vista/RTL_CRITICAL_SECTION_DEBUG.html
  365. #
  366. # typedef struct _RTL_CRITICAL_SECTION_DEBUG
  367. # {
  368. # WORD Type;
  369. # WORD CreatorBackTraceIndex;
  370. # PRTL_CRITICAL_SECTION CriticalSection;
  371. # LIST_ENTRY ProcessLocksList;
  372. # ULONG EntryCount;
  373. # ULONG ContentionCount;
  374. # ULONG Flags;
  375. # WORD CreatorBackTraceIndexHigh;
  376. # WORD SpareUSHORT;
  377. # } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG;
  378. #
  379. # From http://www.nirsoft.net/kernel_struct/vista/RTL_CRITICAL_SECTION.html
  380. #
  381. # typedef struct _RTL_CRITICAL_SECTION
  382. # {
  383. # PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
  384. # LONG LockCount;
  385. # LONG RecursionCount;
  386. # PVOID OwningThread;
  387. # PVOID LockSemaphore;
  388. # ULONG SpinCount;
  389. # } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
  390. #
  391. class RTL_CRITICAL_SECTION(Structure):
  392. _fields_ = [
  393. ("DebugInfo", PVOID), # PRTL_CRITICAL_SECTION_DEBUG
  394. ("LockCount", LONG),
  395. ("RecursionCount", LONG),
  396. ("OwningThread", PVOID),
  397. ("LockSemaphore", PVOID),
  398. ("SpinCount", ULONG),
  399. ]
  400. class RTL_CRITICAL_SECTION_DEBUG(Structure):
  401. _fields_ = [
  402. ("Type", WORD),
  403. ("CreatorBackTraceIndex", WORD),
  404. ("CriticalSection", PVOID), # PRTL_CRITICAL_SECTION
  405. ("ProcessLocksList", LIST_ENTRY),
  406. ("EntryCount", ULONG),
  407. ("ContentionCount", ULONG),
  408. ("Flags", ULONG),
  409. ("CreatorBackTraceIndexHigh", WORD),
  410. ("SpareUSHORT", WORD),
  411. ]
  412. PRTL_CRITICAL_SECTION = POINTER(RTL_CRITICAL_SECTION)
  413. PRTL_CRITICAL_SECTION_DEBUG = POINTER(RTL_CRITICAL_SECTION_DEBUG)
  414. PPEB_LDR_DATA = POINTER(PEB_LDR_DATA)
  415. PRTL_USER_PROCESS_PARAMETERS = POINTER(RTL_USER_PROCESS_PARAMETERS)
  416. PPEBLOCKROUTINE = PVOID
  417. # BitField
  418. ImageUsesLargePages = 1 << 0
  419. IsProtectedProcess = 1 << 1
  420. IsLegacyProcess = 1 << 2
  421. IsImageDynamicallyRelocated = 1 << 3
  422. SkipPatchingUser32Forwarders = 1 << 4
  423. # CrossProcessFlags
  424. ProcessInJob = 1 << 0
  425. ProcessInitializing = 1 << 1
  426. ProcessUsingVEH = 1 << 2
  427. ProcessUsingVCH = 1 << 3
  428. ProcessUsingFTH = 1 << 4
  429. # TracingFlags
  430. HeapTracingEnabled = 1 << 0
  431. CritSecTracingEnabled = 1 << 1
  432. # NtGlobalFlags
  433. FLG_VALID_BITS = 0x003FFFFF # not a flag
  434. FLG_STOP_ON_EXCEPTION = 0x00000001
  435. FLG_SHOW_LDR_SNAPS = 0x00000002
  436. FLG_DEBUG_INITIAL_COMMAND = 0x00000004
  437. FLG_STOP_ON_HUNG_GUI = 0x00000008
  438. FLG_HEAP_ENABLE_TAIL_CHECK = 0x00000010
  439. FLG_HEAP_ENABLE_FREE_CHECK = 0x00000020
  440. FLG_HEAP_VALIDATE_PARAMETERS = 0x00000040
  441. FLG_HEAP_VALIDATE_ALL = 0x00000080
  442. FLG_POOL_ENABLE_TAIL_CHECK = 0x00000100
  443. FLG_POOL_ENABLE_FREE_CHECK = 0x00000200
  444. FLG_POOL_ENABLE_TAGGING = 0x00000400
  445. FLG_HEAP_ENABLE_TAGGING = 0x00000800
  446. FLG_USER_STACK_TRACE_DB = 0x00001000
  447. FLG_KERNEL_STACK_TRACE_DB = 0x00002000
  448. FLG_MAINTAIN_OBJECT_TYPELIST = 0x00004000
  449. FLG_HEAP_ENABLE_TAG_BY_DLL = 0x00008000
  450. FLG_IGNORE_DEBUG_PRIV = 0x00010000
  451. FLG_ENABLE_CSRDEBUG = 0x00020000
  452. FLG_ENABLE_KDEBUG_SYMBOL_LOAD = 0x00040000
  453. FLG_DISABLE_PAGE_KERNEL_STACKS = 0x00080000
  454. FLG_HEAP_ENABLE_CALL_TRACING = 0x00100000
  455. FLG_HEAP_DISABLE_COALESCING = 0x00200000
  456. FLG_ENABLE_CLOSE_EXCEPTION = 0x00400000
  457. FLG_ENABLE_EXCEPTION_LOGGING = 0x00800000
  458. FLG_ENABLE_HANDLE_TYPE_TAGGING = 0x01000000
  459. FLG_HEAP_PAGE_ALLOCS = 0x02000000
  460. FLG_DEBUG_WINLOGON = 0x04000000
  461. FLG_ENABLE_DBGPRINT_BUFFERING = 0x08000000
  462. FLG_EARLY_CRITICAL_SECTION_EVT = 0x10000000
  463. FLG_DISABLE_DLL_VERIFICATION = 0x80000000
  464. class _PEB_NT(Structure):
  465. _pack_ = 4
  466. _fields_ = [
  467. ("InheritedAddressSpace", BOOLEAN),
  468. ("ReadImageFileExecOptions", UCHAR),
  469. ("BeingDebugged", BOOLEAN),
  470. ("BitField", UCHAR),
  471. ("Mutant", HANDLE),
  472. ("ImageBaseAddress", PVOID),
  473. ("Ldr", PVOID), # PPEB_LDR_DATA
  474. ("ProcessParameters", PVOID), # PRTL_USER_PROCESS_PARAMETERS
  475. ("SubSystemData", PVOID),
  476. ("ProcessHeap", PVOID),
  477. ("FastPebLock", PVOID),
  478. ("FastPebLockRoutine", PVOID), # PPEBLOCKROUTINE
  479. ("FastPebUnlockRoutine", PVOID), # PPEBLOCKROUTINE
  480. ("EnvironmentUpdateCount", ULONG),
  481. ("KernelCallbackTable", PVOID), # Ptr32 Ptr32 Void
  482. ("EventLogSection", PVOID),
  483. ("EventLog", PVOID),
  484. ("FreeList", PVOID), # PPEB_FREE_BLOCK
  485. ("TlsExpansionCounter", ULONG),
  486. ("TlsBitmap", PVOID),
  487. ("TlsBitmapBits", ULONG * 2),
  488. ("ReadOnlySharedMemoryBase", PVOID),
  489. ("ReadOnlySharedMemoryHeap", PVOID),
  490. ("ReadOnlyStaticServerData", PVOID), # Ptr32 Ptr32 Void
  491. ("AnsiCodePageData", PVOID),
  492. ("OemCodePageData", PVOID),
  493. ("UnicodeCaseTableData", PVOID),
  494. ("NumberOfProcessors", ULONG),
  495. ("NtGlobalFlag", ULONG),
  496. ("Spare2", BYTE * 4),
  497. ("CriticalSectionTimeout", LONGLONG), # LARGE_INTEGER
  498. ("HeapSegmentReserve", ULONG),
  499. ("HeapSegmentCommit", ULONG),
  500. ("HeapDeCommitTotalFreeThreshold", ULONG),
  501. ("HeapDeCommitFreeBlockThreshold", ULONG),
  502. ("NumberOfHeaps", ULONG),
  503. ("MaximumNumberOfHeaps", ULONG),
  504. ("ProcessHeaps", PVOID), # Ptr32 Ptr32 Void
  505. ("GdiSharedHandleTable", PVOID),
  506. ("ProcessStarterHelper", PVOID),
  507. ("GdiDCAttributeList", PVOID),
  508. ("LoaderLock", PVOID), # PRTL_CRITICAL_SECTION
  509. ("OSMajorVersion", ULONG),
  510. ("OSMinorVersion", ULONG),
  511. ("OSBuildNumber", ULONG),
  512. ("OSPlatformId", ULONG),
  513. ("ImageSubSystem", ULONG),
  514. ("ImageSubSystemMajorVersion", ULONG),
  515. ("ImageSubSystemMinorVersion", ULONG),
  516. ("ImageProcessAffinityMask", ULONG),
  517. ("GdiHandleBuffer", ULONG * 34),
  518. ("PostProcessInitRoutine", PPS_POST_PROCESS_INIT_ROUTINE),
  519. ("TlsExpansionBitmap", ULONG),
  520. ("TlsExpansionBitmapBits", BYTE * 128),
  521. ("SessionId", ULONG),
  522. ]
  523. # not really, but "dt _PEB" in w2k isn't working for me :(
  524. _PEB_2000 = _PEB_NT
  525. # +0x000 InheritedAddressSpace : UChar
  526. # +0x001 ReadImageFileExecOptions : UChar
  527. # +0x002 BeingDebugged : UChar
  528. # +0x003 SpareBool : UChar
  529. # +0x004 Mutant : Ptr32 Void
  530. # +0x008 ImageBaseAddress : Ptr32 Void
  531. # +0x00c Ldr : Ptr32 _PEB_LDR_DATA
  532. # +0x010 ProcessParameters : Ptr32 _RTL_USER_PROCESS_PARAMETERS
  533. # +0x014 SubSystemData : Ptr32 Void
  534. # +0x018 ProcessHeap : Ptr32 Void
  535. # +0x01c FastPebLock : Ptr32 _RTL_CRITICAL_SECTION
  536. # +0x020 FastPebLockRoutine : Ptr32 Void
  537. # +0x024 FastPebUnlockRoutine : Ptr32 Void
  538. # +0x028 EnvironmentUpdateCount : Uint4B
  539. # +0x02c KernelCallbackTable : Ptr32 Void
  540. # +0x030 SystemReserved : [1] Uint4B
  541. # +0x034 AtlThunkSListPtr32 : Uint4B
  542. # +0x038 FreeList : Ptr32 _PEB_FREE_BLOCK
  543. # +0x03c TlsExpansionCounter : Uint4B
  544. # +0x040 TlsBitmap : Ptr32 Void
  545. # +0x044 TlsBitmapBits : [2] Uint4B
  546. # +0x04c ReadOnlySharedMemoryBase : Ptr32 Void
  547. # +0x050 ReadOnlySharedMemoryHeap : Ptr32 Void
  548. # +0x054 ReadOnlyStaticServerData : Ptr32 Ptr32 Void
  549. # +0x058 AnsiCodePageData : Ptr32 Void
  550. # +0x05c OemCodePageData : Ptr32 Void
  551. # +0x060 UnicodeCaseTableData : Ptr32 Void
  552. # +0x064 NumberOfProcessors : Uint4B
  553. # +0x068 NtGlobalFlag : Uint4B
  554. # +0x070 CriticalSectionTimeout : _LARGE_INTEGER
  555. # +0x078 HeapSegmentReserve : Uint4B
  556. # +0x07c HeapSegmentCommit : Uint4B
  557. # +0x080 HeapDeCommitTotalFreeThreshold : Uint4B
  558. # +0x084 HeapDeCommitFreeBlockThreshold : Uint4B
  559. # +0x088 NumberOfHeaps : Uint4B
  560. # +0x08c MaximumNumberOfHeaps : Uint4B
  561. # +0x090 ProcessHeaps : Ptr32 Ptr32 Void
  562. # +0x094 GdiSharedHandleTable : Ptr32 Void
  563. # +0x098 ProcessStarterHelper : Ptr32 Void
  564. # +0x09c GdiDCAttributeList : Uint4B
  565. # +0x0a0 LoaderLock : Ptr32 Void
  566. # +0x0a4 OSMajorVersion : Uint4B
  567. # +0x0a8 OSMinorVersion : Uint4B
  568. # +0x0ac OSBuildNumber : Uint2B
  569. # +0x0ae OSCSDVersion : Uint2B
  570. # +0x0b0 OSPlatformId : Uint4B
  571. # +0x0b4 ImageSubsystem : Uint4B
  572. # +0x0b8 ImageSubsystemMajorVersion : Uint4B
  573. # +0x0bc ImageSubsystemMinorVersion : Uint4B
  574. # +0x0c0 ImageProcessAffinityMask : Uint4B
  575. # +0x0c4 GdiHandleBuffer : [34] Uint4B
  576. # +0x14c PostProcessInitRoutine : Ptr32 void
  577. # +0x150 TlsExpansionBitmap : Ptr32 Void
  578. # +0x154 TlsExpansionBitmapBits : [32] Uint4B
  579. # +0x1d4 SessionId : Uint4B
  580. # +0x1d8 AppCompatFlags : _ULARGE_INTEGER
  581. # +0x1e0 AppCompatFlagsUser : _ULARGE_INTEGER
  582. # +0x1e8 pShimData : Ptr32 Void
  583. # +0x1ec AppCompatInfo : Ptr32 Void
  584. # +0x1f0 CSDVersion : _UNICODE_STRING
  585. # +0x1f8 ActivationContextData : Ptr32 Void
  586. # +0x1fc ProcessAssemblyStorageMap : Ptr32 Void
  587. # +0x200 SystemDefaultActivationContextData : Ptr32 Void
  588. # +0x204 SystemAssemblyStorageMap : Ptr32 Void
  589. # +0x208 MinimumStackCommit : Uint4B
  590. class _PEB_XP(Structure):
  591. _pack_ = 8
  592. _fields_ = [
  593. ("InheritedAddressSpace", BOOLEAN),
  594. ("ReadImageFileExecOptions", UCHAR),
  595. ("BeingDebugged", BOOLEAN),
  596. ("SpareBool", UCHAR),
  597. ("Mutant", HANDLE),
  598. ("ImageBaseAddress", PVOID),
  599. ("Ldr", PVOID), # PPEB_LDR_DATA
  600. ("ProcessParameters", PVOID), # PRTL_USER_PROCESS_PARAMETERS
  601. ("SubSystemData", PVOID),
  602. ("ProcessHeap", PVOID),
  603. ("FastPebLock", PVOID),
  604. ("FastPebLockRoutine", PVOID),
  605. ("FastPebUnlockRoutine", PVOID),
  606. ("EnvironmentUpdateCount", DWORD),
  607. ("KernelCallbackTable", PVOID),
  608. ("SystemReserved", DWORD),
  609. ("AtlThunkSListPtr32", DWORD),
  610. ("FreeList", PVOID), # PPEB_FREE_BLOCK
  611. ("TlsExpansionCounter", DWORD),
  612. ("TlsBitmap", PVOID),
  613. ("TlsBitmapBits", DWORD * 2),
  614. ("ReadOnlySharedMemoryBase", PVOID),
  615. ("ReadOnlySharedMemoryHeap", PVOID),
  616. ("ReadOnlyStaticServerData", PVOID), # Ptr32 Ptr32 Void
  617. ("AnsiCodePageData", PVOID),
  618. ("OemCodePageData", PVOID),
  619. ("UnicodeCaseTableData", PVOID),
  620. ("NumberOfProcessors", DWORD),
  621. ("NtGlobalFlag", DWORD),
  622. ("CriticalSectionTimeout", LONGLONG), # LARGE_INTEGER
  623. ("HeapSegmentReserve", DWORD),
  624. ("HeapSegmentCommit", DWORD),
  625. ("HeapDeCommitTotalFreeThreshold", DWORD),
  626. ("HeapDeCommitFreeBlockThreshold", DWORD),
  627. ("NumberOfHeaps", DWORD),
  628. ("MaximumNumberOfHeaps", DWORD),
  629. ("ProcessHeaps", PVOID), # Ptr32 Ptr32 Void
  630. ("GdiSharedHandleTable", PVOID),
  631. ("ProcessStarterHelper", PVOID),
  632. ("GdiDCAttributeList", DWORD),
  633. ("LoaderLock", PVOID), # PRTL_CRITICAL_SECTION
  634. ("OSMajorVersion", DWORD),
  635. ("OSMinorVersion", DWORD),
  636. ("OSBuildNumber", WORD),
  637. ("OSCSDVersion", WORD),
  638. ("OSPlatformId", DWORD),
  639. ("ImageSubsystem", DWORD),
  640. ("ImageSubsystemMajorVersion", DWORD),
  641. ("ImageSubsystemMinorVersion", DWORD),
  642. ("ImageProcessAffinityMask", DWORD),
  643. ("GdiHandleBuffer", DWORD * 34),
  644. ("PostProcessInitRoutine", PPS_POST_PROCESS_INIT_ROUTINE),
  645. ("TlsExpansionBitmap", PVOID),
  646. ("TlsExpansionBitmapBits", DWORD * 32),
  647. ("SessionId", DWORD),
  648. ("AppCompatFlags", ULONGLONG), # ULARGE_INTEGER
  649. ("AppCompatFlagsUser", ULONGLONG), # ULARGE_INTEGER
  650. ("pShimData", PVOID),
  651. ("AppCompatInfo", PVOID),
  652. ("CSDVersion", UNICODE_STRING),
  653. ("ActivationContextData", PVOID), # ACTIVATION_CONTEXT_DATA
  654. ("ProcessAssemblyStorageMap", PVOID), # ASSEMBLY_STORAGE_MAP
  655. ("SystemDefaultActivationContextData", PVOID), # ACTIVATION_CONTEXT_DATA
  656. ("SystemAssemblyStorageMap", PVOID), # ASSEMBLY_STORAGE_MAP
  657. ("MinimumStackCommit", DWORD),
  658. ]
  659. # +0x000 InheritedAddressSpace : UChar
  660. # +0x001 ReadImageFileExecOptions : UChar
  661. # +0x002 BeingDebugged : UChar
  662. # +0x003 BitField : UChar
  663. # +0x003 ImageUsesLargePages : Pos 0, 1 Bit
  664. # +0x003 SpareBits : Pos 1, 7 Bits
  665. # +0x008 Mutant : Ptr64 Void
  666. # +0x010 ImageBaseAddress : Ptr64 Void
  667. # +0x018 Ldr : Ptr64 _PEB_LDR_DATA
  668. # +0x020 ProcessParameters : Ptr64 _RTL_USER_PROCESS_PARAMETERS
  669. # +0x028 SubSystemData : Ptr64 Void
  670. # +0x030 ProcessHeap : Ptr64 Void
  671. # +0x038 FastPebLock : Ptr64 _RTL_CRITICAL_SECTION
  672. # +0x040 AtlThunkSListPtr : Ptr64 Void
  673. # +0x048 SparePtr2 : Ptr64 Void
  674. # +0x050 EnvironmentUpdateCount : Uint4B
  675. # +0x058 KernelCallbackTable : Ptr64 Void
  676. # +0x060 SystemReserved : [1] Uint4B
  677. # +0x064 SpareUlong : Uint4B
  678. # +0x068 FreeList : Ptr64 _PEB_FREE_BLOCK
  679. # +0x070 TlsExpansionCounter : Uint4B
  680. # +0x078 TlsBitmap : Ptr64 Void
  681. # +0x080 TlsBitmapBits : [2] Uint4B
  682. # +0x088 ReadOnlySharedMemoryBase : Ptr64 Void
  683. # +0x090 ReadOnlySharedMemoryHeap : Ptr64 Void
  684. # +0x098 ReadOnlyStaticServerData : Ptr64 Ptr64 Void
  685. # +0x0a0 AnsiCodePageData : Ptr64 Void
  686. # +0x0a8 OemCodePageData : Ptr64 Void
  687. # +0x0b0 UnicodeCaseTableData : Ptr64 Void
  688. # +0x0b8 NumberOfProcessors : Uint4B
  689. # +0x0bc NtGlobalFlag : Uint4B
  690. # +0x0c0 CriticalSectionTimeout : _LARGE_INTEGER
  691. # +0x0c8 HeapSegmentReserve : Uint8B
  692. # +0x0d0 HeapSegmentCommit : Uint8B
  693. # +0x0d8 HeapDeCommitTotalFreeThreshold : Uint8B
  694. # +0x0e0 HeapDeCommitFreeBlockThreshold : Uint8B
  695. # +0x0e8 NumberOfHeaps : Uint4B
  696. # +0x0ec MaximumNumberOfHeaps : Uint4B
  697. # +0x0f0 ProcessHeaps : Ptr64 Ptr64 Void
  698. # +0x0f8 GdiSharedHandleTable : Ptr64 Void
  699. # +0x100 ProcessStarterHelper : Ptr64 Void
  700. # +0x108 GdiDCAttributeList : Uint4B
  701. # +0x110 LoaderLock : Ptr64 _RTL_CRITICAL_SECTION
  702. # +0x118 OSMajorVersion : Uint4B
  703. # +0x11c OSMinorVersion : Uint4B
  704. # +0x120 OSBuildNumber : Uint2B
  705. # +0x122 OSCSDVersion : Uint2B
  706. # +0x124 OSPlatformId : Uint4B
  707. # +0x128 ImageSubsystem : Uint4B
  708. # +0x12c ImageSubsystemMajorVersion : Uint4B
  709. # +0x130 ImageSubsystemMinorVersion : Uint4B
  710. # +0x138 ImageProcessAffinityMask : Uint8B
  711. # +0x140 GdiHandleBuffer : [60] Uint4B
  712. # +0x230 PostProcessInitRoutine : Ptr64 void
  713. # +0x238 TlsExpansionBitmap : Ptr64 Void
  714. # +0x240 TlsExpansionBitmapBits : [32] Uint4B
  715. # +0x2c0 SessionId : Uint4B
  716. # +0x2c8 AppCompatFlags : _ULARGE_INTEGER
  717. # +0x2d0 AppCompatFlagsUser : _ULARGE_INTEGER
  718. # +0x2d8 pShimData : Ptr64 Void
  719. # +0x2e0 AppCompatInfo : Ptr64 Void
  720. # +0x2e8 CSDVersion : _UNICODE_STRING
  721. # +0x2f8 ActivationContextData : Ptr64 _ACTIVATION_CONTEXT_DATA
  722. # +0x300 ProcessAssemblyStorageMap : Ptr64 _ASSEMBLY_STORAGE_MAP
  723. # +0x308 SystemDefaultActivationContextData : Ptr64 _ACTIVATION_CONTEXT_DATA
  724. # +0x310 SystemAssemblyStorageMap : Ptr64 _ASSEMBLY_STORAGE_MAP
  725. # +0x318 MinimumStackCommit : Uint8B
  726. # +0x320 FlsCallback : Ptr64 Ptr64 Void
  727. # +0x328 FlsListHead : _LIST_ENTRY
  728. # +0x338 FlsBitmap : Ptr64 Void
  729. # +0x340 FlsBitmapBits : [4] Uint4B
  730. # +0x350 FlsHighIndex : Uint4B
  731. class _PEB_XP_64(Structure):
  732. _pack_ = 8
  733. _fields_ = [
  734. ("InheritedAddressSpace", BOOLEAN),
  735. ("ReadImageFileExecOptions", UCHAR),
  736. ("BeingDebugged", BOOLEAN),
  737. ("BitField", UCHAR),
  738. ("Mutant", HANDLE),
  739. ("ImageBaseAddress", PVOID),
  740. ("Ldr", PVOID), # PPEB_LDR_DATA
  741. ("ProcessParameters", PVOID), # PRTL_USER_PROCESS_PARAMETERS
  742. ("SubSystemData", PVOID),
  743. ("ProcessHeap", PVOID),
  744. ("FastPebLock", PVOID), # PRTL_CRITICAL_SECTION
  745. ("AtlThunkSListPtr", PVOID),
  746. ("SparePtr2", PVOID),
  747. ("EnvironmentUpdateCount", DWORD),
  748. ("KernelCallbackTable", PVOID),
  749. ("SystemReserved", DWORD),
  750. ("SpareUlong", DWORD),
  751. ("FreeList", PVOID), # PPEB_FREE_BLOCK
  752. ("TlsExpansionCounter", DWORD),
  753. ("TlsBitmap", PVOID),
  754. ("TlsBitmapBits", DWORD * 2),
  755. ("ReadOnlySharedMemoryBase", PVOID),
  756. ("ReadOnlySharedMemoryHeap", PVOID),
  757. ("ReadOnlyStaticServerData", PVOID), # Ptr64 Ptr64 Void
  758. ("AnsiCodePageData", PVOID),
  759. ("OemCodePageData", PVOID),
  760. ("UnicodeCaseTableData", PVOID),
  761. ("NumberOfProcessors", DWORD),
  762. ("NtGlobalFlag", DWORD),
  763. ("CriticalSectionTimeout", LONGLONG), # LARGE_INTEGER
  764. ("HeapSegmentReserve", QWORD),
  765. ("HeapSegmentCommit", QWORD),
  766. ("HeapDeCommitTotalFreeThreshold", QWORD),
  767. ("HeapDeCommitFreeBlockThreshold", QWORD),
  768. ("NumberOfHeaps", DWORD),
  769. ("MaximumNumberOfHeaps", DWORD),
  770. ("ProcessHeaps", PVOID), # Ptr64 Ptr64 Void
  771. ("GdiSharedHandleTable", PVOID),
  772. ("ProcessStarterHelper", PVOID),
  773. ("GdiDCAttributeList", DWORD),
  774. ("LoaderLock", PVOID), # PRTL_CRITICAL_SECTION
  775. ("OSMajorVersion", DWORD),
  776. ("OSMinorVersion", DWORD),
  777. ("OSBuildNumber", WORD),
  778. ("OSCSDVersion", WORD),
  779. ("OSPlatformId", DWORD),
  780. ("ImageSubsystem", DWORD),
  781. ("ImageSubsystemMajorVersion", DWORD),
  782. ("ImageSubsystemMinorVersion", DWORD),
  783. ("ImageProcessAffinityMask", QWORD),
  784. ("GdiHandleBuffer", DWORD * 60),
  785. ("PostProcessInitRoutine", PPS_POST_PROCESS_INIT_ROUTINE),
  786. ("TlsExpansionBitmap", PVOID),
  787. ("TlsExpansionBitmapBits", DWORD * 32),
  788. ("SessionId", DWORD),
  789. ("AppCompatFlags", ULONGLONG), # ULARGE_INTEGER
  790. ("AppCompatFlagsUser", ULONGLONG), # ULARGE_INTEGER
  791. ("pShimData", PVOID),
  792. ("AppCompatInfo", PVOID),
  793. ("CSDVersion", UNICODE_STRING),
  794. ("ActivationContextData", PVOID), # ACTIVATION_CONTEXT_DATA
  795. ("ProcessAssemblyStorageMap", PVOID), # ASSEMBLY_STORAGE_MAP
  796. ("SystemDefaultActivationContextData", PVOID), # ACTIVATION_CONTEXT_DATA
  797. ("SystemAssemblyStorageMap", PVOID), # ASSEMBLY_STORAGE_MAP
  798. ("MinimumStackCommit", QWORD),
  799. ("FlsCallback", PVOID), # Ptr64 Ptr64 Void
  800. ("FlsListHead", LIST_ENTRY),
  801. ("FlsBitmap", PVOID),
  802. ("FlsBitmapBits", DWORD * 4),
  803. ("FlsHighIndex", DWORD),
  804. ]
  805. # +0x000 InheritedAddressSpace : UChar
  806. # +0x001 ReadImageFileExecOptions : UChar
  807. # +0x002 BeingDebugged : UChar
  808. # +0x003 BitField : UChar
  809. # +0x003 ImageUsesLargePages : Pos 0, 1 Bit
  810. # +0x003 SpareBits : Pos 1, 7 Bits
  811. # +0x004 Mutant : Ptr32 Void
  812. # +0x008 ImageBaseAddress : Ptr32 Void
  813. # +0x00c Ldr : Ptr32 _PEB_LDR_DATA
  814. # +0x010 ProcessParameters : Ptr32 _RTL_USER_PROCESS_PARAMETERS
  815. # +0x014 SubSystemData : Ptr32 Void
  816. # +0x018 ProcessHeap : Ptr32 Void
  817. # +0x01c FastPebLock : Ptr32 _RTL_CRITICAL_SECTION
  818. # +0x020 AtlThunkSListPtr : Ptr32 Void
  819. # +0x024 SparePtr2 : Ptr32 Void
  820. # +0x028 EnvironmentUpdateCount : Uint4B
  821. # +0x02c KernelCallbackTable : Ptr32 Void
  822. # +0x030 SystemReserved : [1] Uint4B
  823. # +0x034 SpareUlong : Uint4B
  824. # +0x038 FreeList : Ptr32 _PEB_FREE_BLOCK
  825. # +0x03c TlsExpansionCounter : Uint4B
  826. # +0x040 TlsBitmap : Ptr32 Void
  827. # +0x044 TlsBitmapBits : [2] Uint4B
  828. # +0x04c ReadOnlySharedMemoryBase : Ptr32 Void
  829. # +0x050 ReadOnlySharedMemoryHeap : Ptr32 Void
  830. # +0x054 ReadOnlyStaticServerData : Ptr32 Ptr32 Void
  831. # +0x058 AnsiCodePageData : Ptr32 Void
  832. # +0x05c OemCodePageData : Ptr32 Void
  833. # +0x060 UnicodeCaseTableData : Ptr32 Void
  834. # +0x064 NumberOfProcessors : Uint4B
  835. # +0x068 NtGlobalFlag : Uint4B
  836. # +0x070 CriticalSectionTimeout : _LARGE_INTEGER
  837. # +0x078 HeapSegmentReserve : Uint4B
  838. # +0x07c HeapSegmentCommit : Uint4B
  839. # +0x080 HeapDeCommitTotalFreeThreshold : Uint4B
  840. # +0x084 HeapDeCommitFreeBlockThreshold : Uint4B
  841. # +0x088 NumberOfHeaps : Uint4B
  842. # +0x08c MaximumNumberOfHeaps : Uint4B
  843. # +0x090 ProcessHeaps : Ptr32 Ptr32 Void
  844. # +0x094 GdiSharedHandleTable : Ptr32 Void
  845. # +0x098 ProcessStarterHelper : Ptr32 Void
  846. # +0x09c GdiDCAttributeList : Uint4B
  847. # +0x0a0 LoaderLock : Ptr32 _RTL_CRITICAL_SECTION
  848. # +0x0a4 OSMajorVersion : Uint4B
  849. # +0x0a8 OSMinorVersion : Uint4B
  850. # +0x0ac OSBuildNumber : Uint2B
  851. # +0x0ae OSCSDVersion : Uint2B
  852. # +0x0b0 OSPlatformId : Uint4B
  853. # +0x0b4 ImageSubsystem : Uint4B
  854. # +0x0b8 ImageSubsystemMajorVersion : Uint4B
  855. # +0x0bc ImageSubsystemMinorVersion : Uint4B
  856. # +0x0c0 ImageProcessAffinityMask : Uint4B
  857. # +0x0c4 GdiHandleBuffer : [34] Uint4B
  858. # +0x14c PostProcessInitRoutine : Ptr32 void
  859. # +0x150 TlsExpansionBitmap : Ptr32 Void
  860. # +0x154 TlsExpansionBitmapBits : [32] Uint4B
  861. # +0x1d4 SessionId : Uint4B
  862. # +0x1d8 AppCompatFlags : _ULARGE_INTEGER
  863. # +0x1e0 AppCompatFlagsUser : _ULARGE_INTEGER
  864. # +0x1e8 pShimData : Ptr32 Void
  865. # +0x1ec AppCompatInfo : Ptr32 Void
  866. # +0x1f0 CSDVersion : _UNICODE_STRING
  867. # +0x1f8 ActivationContextData : Ptr32 _ACTIVATION_CONTEXT_DATA
  868. # +0x1fc ProcessAssemblyStorageMap : Ptr32 _ASSEMBLY_STORAGE_MAP
  869. # +0x200 SystemDefaultActivationContextData : Ptr32 _ACTIVATION_CONTEXT_DATA
  870. # +0x204 SystemAssemblyStorageMap : Ptr32 _ASSEMBLY_STORAGE_MAP
  871. # +0x208 MinimumStackCommit : Uint4B
  872. # +0x20c FlsCallback : Ptr32 Ptr32 Void
  873. # +0x210 FlsListHead : _LIST_ENTRY
  874. # +0x218 FlsBitmap : Ptr32 Void
  875. # +0x21c FlsBitmapBits : [4] Uint4B
  876. # +0x22c FlsHighIndex : Uint4B
  877. class _PEB_2003(Structure):
  878. _pack_ = 8
  879. _fields_ = [
  880. ("InheritedAddressSpace", BOOLEAN),
  881. ("ReadImageFileExecOptions", UCHAR),
  882. ("BeingDebugged", BOOLEAN),
  883. ("BitField", UCHAR),
  884. ("Mutant", HANDLE),
  885. ("ImageBaseAddress", PVOID),
  886. ("Ldr", PVOID), # PPEB_LDR_DATA
  887. ("ProcessParameters", PVOID), # PRTL_USER_PROCESS_PARAMETERS
  888. ("SubSystemData", PVOID),
  889. ("ProcessHeap", PVOID),
  890. ("FastPebLock", PVOID), # PRTL_CRITICAL_SECTION
  891. ("AtlThunkSListPtr", PVOID),
  892. ("SparePtr2", PVOID),
  893. ("EnvironmentUpdateCount", DWORD),
  894. ("KernelCallbackTable", PVOID),
  895. ("SystemReserved", DWORD),
  896. ("SpareUlong", DWORD),
  897. ("FreeList", PVOID), # PPEB_FREE_BLOCK
  898. ("TlsExpansionCounter", DWORD),
  899. ("TlsBitmap", PVOID),
  900. ("TlsBitmapBits", DWORD * 2),
  901. ("ReadOnlySharedMemoryBase", PVOID),
  902. ("ReadOnlySharedMemoryHeap", PVOID),
  903. ("ReadOnlyStaticServerData", PVOID), # Ptr32 Ptr32 Void
  904. ("AnsiCodePageData", PVOID),
  905. ("OemCodePageData", PVOID),
  906. ("UnicodeCaseTableData", PVOID),
  907. ("NumberOfProcessors", DWORD),
  908. ("NtGlobalFlag", DWORD),
  909. ("CriticalSectionTimeout", LONGLONG), # LARGE_INTEGER
  910. ("HeapSegmentReserve", DWORD),
  911. ("HeapSegmentCommit", DWORD),
  912. ("HeapDeCommitTotalFreeThreshold", DWORD),
  913. ("HeapDeCommitFreeBlockThreshold", DWORD),
  914. ("NumberOfHeaps", DWORD),
  915. ("MaximumNumberOfHeaps", DWORD),
  916. ("ProcessHeaps", PVOID), # Ptr32 Ptr32 Void
  917. ("GdiSharedHandleTable", PVOID),
  918. ("ProcessStarterHelper", PVOID),
  919. ("GdiDCAttributeList", DWORD),
  920. ("LoaderLock", PVOID), # PRTL_CRITICAL_SECTION
  921. ("OSMajorVersion", DWORD),
  922. ("OSMinorVersion", DWORD),
  923. ("OSBuildNumber", WORD),
  924. ("OSCSDVersion", WORD),
  925. ("OSPlatformId", DWORD),
  926. ("ImageSubsystem", DWORD),
  927. ("ImageSubsystemMajorVersion", DWORD),
  928. ("ImageSubsystemMinorVersion", DWORD),
  929. ("ImageProcessAffinityMask", DWORD),
  930. ("GdiHandleBuffer", DWORD * 34),
  931. ("PostProcessInitRoutine", PPS_POST_PROCESS_INIT_ROUTINE),
  932. ("TlsExpansionBitmap", PVOID),
  933. ("TlsExpansionBitmapBits", DWORD * 32),
  934. ("SessionId", DWORD),
  935. ("AppCompatFlags", ULONGLONG), # ULARGE_INTEGER
  936. ("AppCompatFlagsUser", ULONGLONG), # ULARGE_INTEGER
  937. ("pShimData", PVOID),
  938. ("AppCompatInfo", PVOID),
  939. ("CSDVersion", UNICODE_STRING),
  940. ("ActivationContextData", PVOID), # ACTIVATION_CONTEXT_DATA
  941. ("ProcessAssemblyStorageMap", PVOID), # ASSEMBLY_STORAGE_MAP
  942. ("SystemDefaultActivationContextData", PVOID), # ACTIVATION_CONTEXT_DATA
  943. ("SystemAssemblyStorageMap", PVOID), # ASSEMBLY_STORAGE_MAP
  944. ("MinimumStackCommit", QWORD),
  945. ("FlsCallback", PVOID), # Ptr32 Ptr32 Void
  946. ("FlsListHead", LIST_ENTRY),
  947. ("FlsBitmap", PVOID),
  948. ("FlsBitmapBits", DWORD * 4),
  949. ("FlsHighIndex", DWORD),
  950. ]
  951. _PEB_2003_64 = _PEB_XP_64
  952. _PEB_2003_R2 = _PEB_2003
  953. _PEB_2003_R2_64 = _PEB_2003_64
  954. # +0x000 InheritedAddressSpace : UChar
  955. # +0x001 ReadImageFileExecOptions : UChar
  956. # +0x002 BeingDebugged : UChar
  957. # +0x003 BitField : UChar
  958. # +0x003 ImageUsesLargePages : Pos 0, 1 Bit
  959. # +0x003 IsProtectedProcess : Pos 1, 1 Bit
  960. # +0x003 IsLegacyProcess : Pos 2, 1 Bit
  961. # +0x003 IsImageDynamicallyRelocated : Pos 3, 1 Bit
  962. # +0x003 SkipPatchingUser32Forwarders : Pos 4, 1 Bit
  963. # +0x003 SpareBits : Pos 5, 3 Bits
  964. # +0x004 Mutant : Ptr32 Void
  965. # +0x008 ImageBaseAddress : Ptr32 Void
  966. # +0x00c Ldr : Ptr32 _PEB_LDR_DATA
  967. # +0x010 ProcessParameters : Ptr32 _RTL_USER_PROCESS_PARAMETERS
  968. # +0x014 SubSystemData : Ptr32 Void
  969. # +0x018 ProcessHeap : Ptr32 Void
  970. # +0x01c FastPebLock : Ptr32 _RTL_CRITICAL_SECTION
  971. # +0x020 AtlThunkSListPtr : Ptr32 Void
  972. # +0x024 IFEOKey : Ptr32 Void
  973. # +0x028 CrossProcessFlags : Uint4B
  974. # +0x028 ProcessInJob : Pos 0, 1 Bit
  975. # +0x028 ProcessInitializing : Pos 1, 1 Bit
  976. # +0x028 ProcessUsingVEH : Pos 2, 1 Bit
  977. # +0x028 ProcessUsingVCH : Pos 3, 1 Bit
  978. # +0x028 ReservedBits0 : Pos 4, 28 Bits
  979. # +0x02c KernelCallbackTable : Ptr32 Void
  980. # +0x02c UserSharedInfoPtr : Ptr32 Void
  981. # +0x030 SystemReserved : [1] Uint4B
  982. # +0x034 SpareUlong : Uint4B
  983. # +0x038 SparePebPtr0 : Uint4B
  984. # +0x03c TlsExpansionCounter : Uint4B
  985. # +0x040 TlsBitmap : Ptr32 Void
  986. # +0x044 TlsBitmapBits : [2] Uint4B
  987. # +0x04c ReadOnlySharedMemoryBase : Ptr32 Void
  988. # +0x050 HotpatchInformation : Ptr32 Void
  989. # +0x054 ReadOnlyStaticServerData : Ptr32 Ptr32 Void
  990. # +0x058 AnsiCodePageData : Ptr32 Void
  991. # +0x05c OemCodePageData : Ptr32 Void
  992. # +0x060 UnicodeCaseTableData : Ptr32 Void
  993. # +0x064 NumberOfProcessors : Uint4B
  994. # +0x068 NtGlobalFlag : Uint4B
  995. # +0x070 CriticalSectionTimeout : _LARGE_INTEGER
  996. # +0x078 HeapSegmentReserve : Uint4B
  997. # +0x07c HeapSegmentCommit : Uint4B
  998. # +0x080 HeapDeCommitTotalFreeThreshold : Uint4B
  999. # +0x084 HeapDeCommitFreeBlockThreshold : Uint4B
  1000. # +0x088 NumberOfHeaps : Uint4B
  1001. # +0x08c MaximumNumberOfHeaps : Uint4B
  1002. # +0x090 ProcessHeaps : Ptr32 Ptr32 Void
  1003. # +0x094 GdiSharedHandleTable : Ptr32 Void
  1004. # +0x098 ProcessStarterHelper : Ptr32 Void
  1005. # +0x09c GdiDCAttributeList : Uint4B
  1006. # +0x0a0 LoaderLock : Ptr32 _RTL_CRITICAL_SECTION
  1007. # +0x0a4 OSMajorVersion : Uint4B
  1008. # +0x0a8 OSMinorVersion : Uint4B
  1009. # +0x0ac OSBuildNumber : Uint2B
  1010. # +0x0ae OSCSDVersion : Uint2B
  1011. # +0x0b0 OSPlatformId : Uint4B
  1012. # +0x0b4 ImageSubsystem : Uint4B
  1013. # +0x0b8 ImageSubsystemMajorVersion : Uint4B
  1014. # +0x0bc ImageSubsystemMinorVersion : Uint4B
  1015. # +0x0c0 ActiveProcessAffinityMask : Uint4B
  1016. # +0x0c4 GdiHandleBuffer : [34] Uint4B
  1017. # +0x14c PostProcessInitRoutine : Ptr32 void
  1018. # +0x150 TlsExpansionBitmap : Ptr32 Void
  1019. # +0x154 TlsExpansionBitmapBits : [32] Uint4B
  1020. # +0x1d4 SessionId : Uint4B
  1021. # +0x1d8 AppCompatFlags : _ULARGE_INTEGER
  1022. # +0x1e0 AppCompatFlagsUser : _ULARGE_INTEGER
  1023. # +0x1e8 pShimData : Ptr32 Void
  1024. # +0x1ec AppCompatInfo : Ptr32 Void
  1025. # +0x1f0 CSDVersion : _UNICODE_STRING
  1026. # +0x1f8 ActivationContextData : Ptr32 _ACTIVATION_CONTEXT_DATA
  1027. # +0x1fc ProcessAssemblyStorageMap : Ptr32 _ASSEMBLY_STORAGE_MAP
  1028. # +0x200 SystemDefaultActivationContextData : Ptr32 _ACTIVATION_CONTEXT_DATA
  1029. # +0x204 SystemAssemblyStorageMap : Ptr32 _ASSEMBLY_STORAGE_MAP
  1030. # +0x208 MinimumStackCommit : Uint4B
  1031. # +0x20c FlsCallback : Ptr32 _FLS_CALLBACK_INFO
  1032. # +0x210 FlsListHead : _LIST_ENTRY
  1033. # +0x218 FlsBitmap : Ptr32 Void
  1034. # +0x21c FlsBitmapBits : [4] Uint4B
  1035. # +0x22c FlsHighIndex : Uint4B
  1036. # +0x230 WerRegistrationData : Ptr32 Void
  1037. # +0x234 WerShipAssertPtr : Ptr32 Void
  1038. class _PEB_2008(Structure):
  1039. _pack_ = 8
  1040. _fields_ = [
  1041. ("InheritedAddressSpace", BOOLEAN),
  1042. ("ReadImageFileExecOptions", UCHAR),
  1043. ("BeingDebugged", BOOLEAN),
  1044. ("BitField", UCHAR),
  1045. ("Mutant", HANDLE),
  1046. ("ImageBaseAddress", PVOID),
  1047. ("Ldr", PVOID), # PPEB_LDR_DATA
  1048. ("ProcessParameters", PVOID), # PRTL_USER_PROCESS_PARAMETERS
  1049. ("SubSystemData", PVOID),
  1050. ("ProcessHeap", PVOID),
  1051. ("FastPebLock", PVOID), # PRTL_CRITICAL_SECTION
  1052. ("AtlThunkSListPtr", PVOID),
  1053. ("IFEOKey", PVOID),
  1054. ("CrossProcessFlags", DWORD),
  1055. ("KernelCallbackTable", PVOID),
  1056. ("SystemReserved", DWORD),
  1057. ("SpareUlong", DWORD),
  1058. ("SparePebPtr0", PVOID),
  1059. ("TlsExpansionCounter", DWORD),
  1060. ("TlsBitmap", PVOID),
  1061. ("TlsBitmapBits", DWORD * 2),
  1062. ("ReadOnlySharedMemoryBase", PVOID),
  1063. ("HotpatchInformation", PVOID),
  1064. ("ReadOnlyStaticServerData", PVOID), # Ptr32 Ptr32 Void
  1065. ("AnsiCodePageData", PVOID),
  1066. ("OemCodePageData", PVOID),
  1067. ("UnicodeCaseTableData", PVOID),
  1068. ("NumberOfProcessors", DWORD),
  1069. ("NtGlobalFlag", DWORD),
  1070. ("CriticalSectionTimeout", LONGLONG), # LARGE_INTEGER
  1071. ("HeapSegmentReserve", DWORD),
  1072. ("HeapSegmentCommit", DWORD),
  1073. ("HeapDeCommitTotalFreeThreshold", DWORD),
  1074. ("HeapDeCommitFreeBlockThreshold", DWORD),
  1075. ("NumberOfHeaps", DWORD),
  1076. ("MaximumNumberOfHeaps", DWORD),
  1077. ("ProcessHeaps", PVOID), # Ptr32 Ptr32 Void
  1078. ("GdiSharedHandleTable", PVOID),
  1079. ("ProcessStarterHelper", PVOID),
  1080. ("GdiDCAttributeList", DWORD),
  1081. ("LoaderLock", PVOID), # PRTL_CRITICAL_SECTION

Large files files are truncated, but you can click here to view the full file