2
0

sysndk.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // These datatypes are used in system.pas and ndk.pas
  2. const
  3. {$ifdef kmode}
  4. ntdll = 'ntoskrnl.exe';
  5. {$else}
  6. ntdll = 'ntdll.dll';
  7. {$endif}
  8. type
  9. //
  10. // some basic types
  11. //
  12. HANDLE = THandle;
  13. PVOID = Pointer;
  14. LONG = LongInt;
  15. ULONG = LongWord;
  16. NTSTATUS = LongInt;
  17. UNICODE_STRING = packed record
  18. Length: Word; // used characters in buffer
  19. MaximumLength: Word; // maximum characters in buffer
  20. Buffer: PWideChar;
  21. end;
  22. PUNICODE_STRING = ^UNICODE_STRING;
  23. // alias to differ from TUnicodeString
  24. TNtUnicodeString = UNICODE_STRING;
  25. PNtUnicodeString = ^TNtUnicodeString;
  26. // using Int64 is an alternative (QWord might have unintended side effects)
  27. LARGE_INTEGER = packed record
  28. case Boolean of
  29. True:(LowPart: LongWord;
  30. HighPart: LongInt);
  31. False:(QuadPart: Int64);
  32. end;
  33. PLARGE_INTEGER = ^LARGE_INTEGER;
  34. TLargeInteger = LARGE_INTEGER;
  35. PLargeInteger = ^TLargeInteger;
  36. //
  37. // Object Attributes structure
  38. //
  39. POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;
  40. _OBJECT_ATTRIBUTES = record
  41. Length: ULONG;
  42. RootDirectory: HANDLE;
  43. ObjectName: PUNICODE_STRING;
  44. Attributes: ULONG;
  45. SecurityDescriptor: PVOID; // Points to type SECURITY_DESCRIPTOR
  46. SecurityQualityOfService: PVOID; // Points to type SECURITY_QUALITY_OF_SERVICE
  47. end;
  48. OBJECT_ATTRIBUTES = _OBJECT_ATTRIBUTES;
  49. TObjectAttributes = OBJECT_ATTRIBUTES;
  50. PObjectAttributes = POBJECT_ATTRIBUTES;
  51. TRtlDriveLetterCurDir = packed record
  52. Flags: Word;
  53. Length: Word;
  54. TimeStamp: LongWord;
  55. DosPath: TNtUnicodeString;
  56. end;
  57. TCurDir = packed record
  58. DosPath: TNtUnicodeString;
  59. Handle: THandle;
  60. end;
  61. TRtlUserProcessParameters = packed record
  62. MaximumLength: LongWord;
  63. Length: LongWord;
  64. Flags: LongWord;
  65. DebugFlags: LongWord;
  66. ConsoleHandle: THandle;
  67. ConsoleFlags: LongWord;
  68. StandardInput: THandle;
  69. StandardOutput: THandle;
  70. StandardError: THandle;
  71. CurrentDirectory: TCurDir;
  72. DllPath: TNtUnicodeString;
  73. ImagePathName: TNtUnicodeString;
  74. CommandLine: TNtUnicodeString;
  75. Environment: ^Word; // PWSTR
  76. StartingX: LongWord;
  77. StartingY: LongWord;
  78. CountX: LongWord;
  79. CountY: LongWord;
  80. CountCharsX: LongWord;
  81. CountCharsY: LongWord;
  82. FillAttribute: LongWord;
  83. WindowFlags: LongWord;
  84. ShowWindowFlags: LongWord;
  85. WindowTitle: TNtUnicodeString;
  86. DesktopInfo: TNtUnicodeString;
  87. ShellInfo: TNtUnicodeString;
  88. RuntimeData: TNtUnicodeString;
  89. CurrentDirectories: array[0..31] of TRtlDriveLetterCurDir;
  90. end;
  91. PRtlUserProcessParameters = ^TRtlUserProcessParameters;
  92. TSimplePEB = packed record
  93. InheritedAddressSpace: Byte;
  94. ReadImageFileExecOptions: Byte;
  95. BeingDebugged: Byte;
  96. //#if (NTDDI_VERSION >= NTDDI_WS03)
  97. // struct
  98. {
  99. UCHAR ImageUsesLargePages:1;
  100. #if (NTDDI_VERSION >= NTDDI_LONGHORN)
  101. UCHAR IsProtectedProcess:1;
  102. UCHAR IsLegacyProcess:1;
  103. UCHAR SpareBits:5;
  104. #else
  105. UCHAR SpareBits:7;
  106. #endif
  107. }//;
  108. //#else
  109. SpareBool: Byte;
  110. //#endif
  111. Mutant: THandle;
  112. ImageBaseAddress: Pointer;
  113. Ldr: Pointer; // PPEB_LDR_DATA
  114. ProcessParameters: PRtlUserProcessParameters;
  115. SubSystemData: Pointer;
  116. ProcessHeap: Pointer;
  117. //#if (NTDDI_VERSION >= NTDDI_LONGHORN)
  118. (* struct _RTL_CRITICAL_SECTION *FastPebLock;
  119. PVOID AltThunkSListPtr;
  120. PVOID IFEOKey;
  121. ULONG Spare;
  122. union
  123. {
  124. PVOID* KernelCallbackTable;
  125. PVOID UserSharedInfoPtr;
  126. };
  127. ULONG SystemReserved[1];
  128. ULONG SpareUlong;*)
  129. //#else
  130. FastPebLock: Pointer;
  131. FastPebLockRoutine: Pointer; // PPEBLOCKROUTINE
  132. FastPebUnlockRoutine: Pointer; // PPEBLOCKROUTINE
  133. EnvironmentUpdateCount: LongWord;
  134. KernelCallbackTable: Pointer; // PVOID*
  135. EventLogSection: Pointer;
  136. EventLog: Pointer;
  137. //#endif
  138. FreeList: Pointer; // PPEB_FREE_BLOCK
  139. TlsExpansionCounter: LongWord;
  140. TlsBitmap: Pointer;
  141. TlsBitmapBits: array[0..1] of LongWord; //TlsBitmapBits[0x2]
  142. ReadOnlySharedMemoryBase: Pointer;
  143. ReadOnlySharedMemoryHeap: Pointer;
  144. ReadOnlyStaticServerData: Pointer; //PVOID*
  145. AnsiCodePageData: Pointer;
  146. OemCodePageData: Pointer;
  147. UnicodeCaseTableData: Pointer;
  148. NumberOfProcessors: LongWord;
  149. NtGlobalFlag: LongWord;
  150. CriticalSectionTimeout: Int64; // LARGE_INTEGER
  151. HeapSegmentReserve: LongWord;
  152. HeapSegmentCommit: LongWord;
  153. HeapDeCommitTotalFreeThreshold: LongWord;
  154. HeapDeCommitFreeBlockThreshold: LongWord;
  155. NumberOfHeaps: LongWord;
  156. MaximumNumberOfHeaps: LongWord;
  157. ProcessHeaps: Pointer; // PVOID*
  158. GdiSharedHandleTable: Pointer;
  159. ProcessStarterHelper: Pointer;
  160. GdiDCAttributeList: LongWord;
  161. //#if (NTDDI_VERSION >= NTDDI_LONGHORN)
  162. // struct _RTL_CRITICAL_SECTION *LoaderLock;
  163. //#else
  164. LoaderLock: Pointer;
  165. //#endif
  166. OSMajorVersion: LongWord;
  167. OSMinorVersion: LongWord;
  168. OSBuildNumber: Word; // USHORT
  169. OSCSDVersion: Word; // USHORT
  170. OSPlatformId: LongWord;
  171. ImageSubSystem: LongWord;
  172. ImageSubSystemMajorVersion: LongWord;
  173. ImageSubSystemMinorVersion: LongWord;
  174. ImageProcessAffinityMask: LongWord;
  175. GdiHandleBuffer: array[0..$21] of LongWord; // GdiHandleBuffer[0x22]
  176. PostProcessInitRoutine: Pointer; //PPOST_PROCESS_INIT_ROUTINE
  177. TlsExpansionBitmap: Pointer; //struct _RTL_BITMAP *TlsExpansionBitmap
  178. TlsExpansionBitmapBits: array[0..$19] of Word; //TlsExpansionBitmapBits[0x20]
  179. SessionId: LongWord;
  180. {#if (NTDDI_VERSION >= NTDDI_WINXP)
  181. ULARGE_INTEGER AppCompatFlags;
  182. ULARGE_INTEGER AppCompatFlagsUser;
  183. PVOID pShimData;
  184. PVOID AppCompatInfo;
  185. UNICODE_STRING CSDVersion;
  186. struct _ACTIVATION_CONTEXT_DATA *ActivationContextData;
  187. struct _ASSEMBLY_STORAGE_MAP *ProcessAssemblyStorageMap;
  188. struct _ACTIVATION_CONTEXT_DATA *SystemDefaultActivationContextData;
  189. struct _ASSEMBLY_STORAGE_MAP *SystemAssemblyStorageMap;
  190. ULONG MinimumStackCommit;
  191. #endif
  192. #if (NTDDI_VERSION >= NTDDI_WS03)
  193. PVOID *FlsCallback;
  194. LIST_ENTRY FlsListHead;
  195. struct _RTL_BITMAP *FlsBitmap;
  196. ULONG FlsBitmapBits[4];
  197. ULONG FlsHighIndex;
  198. #endif
  199. #if (NTDDI_VERSION >= NTDDI_LONGHORN)
  200. PVOID WerRegistrationData;
  201. PVOID WerShipAssertPtr;
  202. #endif}
  203. end;
  204. PPEB = ^TSimplePEB;
  205. function NtDisplayString(aString: PNtUnicodeString): NTSTATUS; stdcall; external ntdll;