peb_teb.inc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {%MainUnit ndk.pas}
  2. {
  3. Native Development Kit for Native NT
  4. This file is part of the Free Pascal run time library.
  5. This units contains PEB and TEB structures used by NT
  6. Copyright (c) 2010 by Sven Barth
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. const
  14. GDI_HANDLE_BUFFER_SIZE_32 = 34;
  15. GDI_HANDLE_BUFFER_SIZE_64 = 60;
  16. {$ifdef cpu64}
  17. GDI_HANDLE_BUFFER_SIZE = GDI_HANDLE_BUFFER_SIZE_64;
  18. {$else}
  19. GDI_HANDLE_BUFFER_SIZE = GDI_HANDLE_BUFFER_SIZE_32;
  20. {$endif}
  21. { TODO : add bitness specific records }
  22. { TODO : add OS version specific records }
  23. { TODO : define remaining types }
  24. type
  25. { The PEB comes in three flavors: the platform dependant one, the 32 bit one
  26. and the 64 bit one. Only the first one should be used by natve processes.
  27. The others are needed if one e.g. wants to examine the PEB of a 32 bit
  28. process on a 64 bit system.
  29. }
  30. _PEB = packed record
  31. InheritedAddressSpace: NT_BOOLEAN;
  32. ReadImageFileExecOptions: NT_BOOLEAN;
  33. BeingDebugged: NT_BOOLEAN;
  34. (* #if (NTDDI_VERSION >= NTDDI_WS03)
  35. union
  36. {
  37. BOOLEAN BitField;
  38. struct
  39. {
  40. BOOLEAN ImageUsesLargePages:1;
  41. #if (NTDDI_VERSION >= NTDDI_LONGHORN)
  42. BOOLEAN IsProtectedProcess:1;
  43. BOOLEAN IsLegacyProcess:1;
  44. BOOLEAN IsImageDynamicallyRelocated:1;
  45. BOOLEAN SkipPatchingUser32Forwarders:1;
  46. BOOLEAN SpareBits:3;
  47. #else
  48. BOOLEAN SpareBits:7;
  49. #endif
  50. };
  51. };
  52. #else*)
  53. SpareBool: NT_BOOLEAN;
  54. // #endif
  55. Mutant: PHANDLE;
  56. ImageBaseAddress: PVOID;
  57. Ldr: Pointer;//PPEB_LDR_DATA;
  58. ProcessParameters: PRTL_USER_PROCESS_PARAMETERS;
  59. SubSystemData: PVOID;
  60. ProcessHeap: PVOID;
  61. FastPebLock: Pointer; //PRTL_CRITICAL_SECTION;
  62. (* #if (NTDDI_VERSION >= NTDDI_LONGHORN)
  63. PTR(PVOID) AltThunkSListPtr;
  64. PTR(PVOID) IFEOKey;
  65. union
  66. {
  67. ULONG CrossProcessFlags;
  68. struct
  69. {
  70. ULONG ProcessInJob:1;
  71. ULONG ProcessInitializing:1;
  72. ULONG ProcessUsingVEH:1;
  73. ULONG ProcessUsingVCH:1;
  74. ULONG ReservedBits0:28;
  75. };
  76. };
  77. union
  78. {
  79. PTR(PVOID) KernelCallbackTable;
  80. PTR(PVOID) UserSharedInfoPtr;
  81. };
  82. #elif (NTDDI_VERSION >= NTDDI_WS03)
  83. PTR(PVOID) AltThunkSListPtr;
  84. PTR(PVOID) SparePtr2;
  85. ULONG EnvironmentUpdateCount;
  86. PTR(PVOID) KernelCallbackTable;
  87. #else*)
  88. FastPebLockRoutine: Pointer; //PPEBLOCKROUTINE;
  89. FastPebUnlockRoutine: Pointer; //PPEBLOCKROUTINE;
  90. EnvironmentUpdateCount: ULONG;
  91. KernelCallbackTable: PVOID;
  92. // #endif
  93. SystemReserved: array[0..0] of ULONG;
  94. SpareUlong: ULONG; // AtlThunkSListPtr32
  95. FreeList: Pointer; //PPEB_FREE_BLOCK;
  96. TlsExpansionCounter: ULONG;
  97. TlsBitmap: PVOID;
  98. TlsBitmapBits: array[0..1] of ULONG;
  99. ReadOnlySharedMemoryBase: PVOID;
  100. (* #if (NTDDI_VERSION >= NTDDI_LONGHORN)
  101. PTR(PVOID) HotpatchInformation;
  102. #else*)
  103. ReadOnlySharedMemoryHeap: PVOID;
  104. // #endif
  105. ReadOnlyStaticServerData: PPVOID;
  106. AnsiCodePageData: PVOID;
  107. OemCodePageData: PVOID;
  108. UnicodeCaseTableData: PVOID;
  109. NumberOfProcessors: ULONG;
  110. NtGlobalFlag: ULONG;
  111. CriticalSectionTimeout: LARGE_INTEGER;
  112. HeapSegmentReserve: ULONG_PTR;
  113. HeapSegmentCommit: ULONG_PTR;
  114. HeapDeCommitTotalFreeThreshold: ULONG_PTR;
  115. HeapDeCommitFreeBlockThreshold: ULONG_PTR;
  116. NumberOfHeaps: ULONG;
  117. MaximumNumberOfHeaps: ULONG;
  118. ProcessHeaps: PPVOID;
  119. GdiSharedHandleTable: PVOID;
  120. ProcessStarterHelper: PVOID;
  121. GdiDCAttributeList: ULONG;
  122. LoaderLock: Pointer; //PRTL_CRITICAL_SECTION;
  123. OSMajorVersion: ULONG;
  124. OSMinorVersion: ULONG;
  125. OSBuildNumber: USHORT;
  126. OSCSDVersion: USHORT;
  127. OSPlatformId: ULONG;
  128. ImageSubsystem: ULONG;
  129. ImageSubsystemMajorVersion: ULONG;
  130. ImageSubsystemMinorVersion: ULONG;
  131. ImageProcessAffinityMask: ULONG_PTR;
  132. GdiHandleBuffer: array[0..GDI_HANDLE_BUFFER_SIZE-1] of ULONG;
  133. PostProcessInitRoutine: Pointer; //PPOST_PROCESS_INIT_ROUTINE;
  134. TlsExpansionBitmap: PVOID;
  135. TlsExpansionBitmapBits: array[0..31] of ULONG;
  136. SessionId: ULONG;
  137. { #if (NTDDI_VERSION >= NTDDI_WINXP)
  138. ULARGE_INTEGER AppCompatFlags;
  139. ULARGE_INTEGER AppCompatFlagsUser;
  140. PTR(PVOID) pShimData;
  141. PTR(PVOID) AppCompatInfo;
  142. STRUCT(UNICODE_STRING) CSDVersion;
  143. PTR(struct _ACTIVATION_CONTEXT_DATA*) ActivationContextData;
  144. PTR(struct _ASSEMBLY_STORAGE_MAP*) ProcessAssemblyStorageMap;
  145. PTR(struct _ACTIVATION_CONTEXT_DATA*) SystemDefaultActivationContextData;
  146. PTR(struct _ASSEMBLY_STORAGE_MAP*) SystemAssemblyStorageMap;
  147. PTR(ULONG_PTR) MinimumStackCommit;
  148. #endif
  149. #if (NTDDI_VERSION >= NTDDI_WS03)
  150. PTR(PVOID*) FlsCallback;
  151. STRUCT(LIST_ENTRY) FlsListHead;
  152. PTR(PVOID) FlsBitmap;
  153. ULONG FlsBitmapBits[4];
  154. ULONG FlsHighIndex;
  155. #endif
  156. #if (NTDDI_VERSION >= NTDDI_LONGHORN)
  157. PTR(PVOID) WerRegistrationData;
  158. PTR(PVOID) WerShipAssertPtr;
  159. #endif}
  160. end;
  161. PEB = _PEB;
  162. PPEB = ^PEB;