Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
11 KiB

  1. /*++
  2. Copyright (c) 1999-2002 Microsoft Corporation
  3. Module Name:
  4. nt4p.h
  5. Abstract:
  6. NT 4.0 specific headers. The structures and defines in this header were
  7. stolen from the relevant places in the NT4 header files so certian
  8. NtXXXX calls will continue to work when called from NT > version 4.
  9. Author:
  10. Matthew D Hendel (math) 10-Sept-1999
  11. Revision History:
  12. --*/
  13. #pragma once
  14. //
  15. // From ntdef.h
  16. //
  17. #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
  18. typedef LONG NTSTATUS;
  19. typedef struct _NT4_UNICODE_STRING {
  20. USHORT Length;
  21. USHORT MaximumLength;
  22. #ifdef MIDL_PASS
  23. [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
  24. #else // MIDL_PASS
  25. PWSTR Buffer;
  26. #endif // MIDL_PASS
  27. } NT4_UNICODE_STRING;
  28. typedef NT4_UNICODE_STRING *PNT4_UNICODE_STRING;
  29. #define UNICODE_NULL ((WCHAR)0) // winnt
  30. //
  31. // Valid values for the Attributes field
  32. //
  33. #define NT4_OBJ_INHERIT 0x00000002L
  34. #define NT4_OBJ_PERMANENT 0x00000010L
  35. #define NT4_OBJ_EXCLUSIVE 0x00000020L
  36. #define NT4_OBJ_CASE_INSENSITIVE 0x00000040L
  37. #define NT4_OBJ_OPENIF 0x00000080L
  38. #define NT4_OBJ_OPENLINK 0x00000100L
  39. #define NT4_OBJ_VALID_ATTRIBUTES 0x000001F2L
  40. //
  41. // Object Attributes structure
  42. //
  43. typedef struct _NT4_OBJECT_ATTRIBUTES {
  44. ULONG Length;
  45. HANDLE RootDirectory;
  46. PNT4_UNICODE_STRING ObjectName;
  47. ULONG Attributes;
  48. PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
  49. PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
  50. } NT4_OBJECT_ATTRIBUTES;
  51. typedef NT4_OBJECT_ATTRIBUTES *PNT4_OBJECT_ATTRIBUTES;
  52. //++
  53. //
  54. // VOID
  55. // InitializeObjectAttributes(
  56. // OUT PNT4_OBJECT_ATTRIBUTES p,
  57. // IN PNT4_UNICODE_STRING n,
  58. // IN ULONG a,
  59. // IN HANDLE r,
  60. // IN PSECURITY_DESCRIPTOR s
  61. // )
  62. //
  63. //--
  64. #define Nt4InitializeObjectAttributes( p, n, a, r, s ) { \
  65. (p)->Length = sizeof( NT4_OBJECT_ATTRIBUTES ); \
  66. (p)->RootDirectory = r; \
  67. (p)->Attributes = a; \
  68. (p)->ObjectName = n; \
  69. (p)->SecurityDescriptor = s; \
  70. (p)->SecurityQualityOfService = NULL; \
  71. }
  72. //
  73. // From ntpsapi.h
  74. //
  75. typedef struct _NT4_CLIENT_ID {
  76. HANDLE UniqueProcess;
  77. HANDLE UniqueThread;
  78. } NT4_CLIENT_ID;
  79. typedef NT4_CLIENT_ID *PNT4_CLIENT_ID;
  80. //
  81. // From ntkeapi.h
  82. //
  83. typedef LONG NT4_KPRIORITY;
  84. typedef ULONG NT4_KAFFINITY;
  85. //
  86. // From ntpsapi.h
  87. //
  88. //
  89. // System Information Classes.
  90. //
  91. typedef enum _NT4_SYSTEM_INFORMATION_CLASS {
  92. Nt4SystemBasicInformation,
  93. Nt4SystemProcessorInformation, // obsolete...delete
  94. Nt4SystemPerformanceInformation,
  95. Nt4SystemTimeOfDayInformation,
  96. Nt4SystemPathInformation,
  97. Nt4SystemProcessInformation,
  98. Nt4SystemCallCountInformation,
  99. Nt4SystemDeviceInformation,
  100. Nt4SystemProcessorPerformanceInformation,
  101. Nt4SystemFlagsInformation,
  102. Nt4SystemCallTimeInformation,
  103. Nt4SystemModuleInformation,
  104. Nt4SystemLocksInformation,
  105. Nt4SystemStackTraceInformation,
  106. Nt4SystemPagedPoolInformation,
  107. Nt4SystemNonPagedPoolInformation,
  108. Nt4SystemHandleInformation,
  109. Nt4SystemObjectInformation,
  110. Nt4SystemPageFileInformation,
  111. Nt4SystemVdmInstemulInformation,
  112. Nt4SystemVdmBopInformation,
  113. Nt4SystemFileCacheInformation,
  114. Nt4SystemPoolTagInformation,
  115. Nt4SystemInterruptInformation,
  116. Nt4SystemDpcBehaviorInformation,
  117. Nt4SystemFullMemoryInformation,
  118. Nt4SystemLoadGdiDriverInformation,
  119. Nt4SystemUnloadGdiDriverInformation,
  120. Nt4SystemTimeAdjustmentInformation,
  121. Nt4SystemSummaryMemoryInformation,
  122. Nt4SystemNextEventIdInformation,
  123. Nt4SystemEventIdsInformation,
  124. Nt4SystemCrashDumpInformation,
  125. Nt4SystemExceptionInformation,
  126. Nt4SystemCrashDumpStateInformation,
  127. Nt4SystemKernelDebuggerInformation,
  128. Nt4SystemContextSwitchInformation,
  129. Nt4SystemRegistryQuotaInformation,
  130. Nt4SystemExtendServiceTableInformation,
  131. Nt4SystemPrioritySeperation,
  132. Nt4SystemPlugPlayBusInformation,
  133. Nt4SystemDockInformation,
  134. NT4SystemPowerInformation,
  135. Nt4SystemProcessorSpeedInformation,
  136. Nt4SystemCurrentTimeZoneInformation,
  137. Nt4SystemLookasideInformation
  138. } NT4_SYSTEM_INFORMATION_CLASS;
  139. typedef struct _NT4_SYSTEM_PROCESS_INFORMATION {
  140. ULONG NextEntryOffset;
  141. ULONG NumberOfThreads;
  142. LARGE_INTEGER SpareLi1;
  143. LARGE_INTEGER SpareLi2;
  144. LARGE_INTEGER SpareLi3;
  145. LARGE_INTEGER CreateTime;
  146. LARGE_INTEGER UserTime;
  147. LARGE_INTEGER KernelTime;
  148. NT4_UNICODE_STRING ImageName;
  149. NT4_KPRIORITY BasePriority;
  150. HANDLE UniqueProcessId;
  151. HANDLE InheritedFromUniqueProcessId;
  152. ULONG HandleCount;
  153. ULONG SpareUl2;
  154. ULONG SpareUl3;
  155. ULONG PeakVirtualSize;
  156. ULONG VirtualSize;
  157. ULONG PageFaultCount;
  158. ULONG PeakWorkingSetSize;
  159. ULONG WorkingSetSize;
  160. ULONG QuotaPeakPagedPoolUsage;
  161. ULONG QuotaPagedPoolUsage;
  162. ULONG QuotaPeakNonPagedPoolUsage;
  163. ULONG QuotaNonPagedPoolUsage;
  164. ULONG PagefileUsage;
  165. ULONG PeakPagefileUsage;
  166. ULONG PrivatePageCount;
  167. } NT4_SYSTEM_PROCESS_INFORMATION, *PNT4_SYSTEM_PROCESS_INFORMATION;
  168. typedef struct _NT4_SYSTEM_THREAD_INFORMATION {
  169. LARGE_INTEGER KernelTime;
  170. LARGE_INTEGER UserTime;
  171. LARGE_INTEGER CreateTime;
  172. ULONG WaitTime;
  173. PVOID StartAddress;
  174. NT4_CLIENT_ID ClientId;
  175. NT4_KPRIORITY Priority;
  176. LONG BasePriority;
  177. ULONG ContextSwitches;
  178. ULONG ThreadState;
  179. ULONG WaitReason;
  180. } NT4_SYSTEM_THREAD_INFORMATION, *PNT4_SYSTEM_THREAD_INFORMATION;
  181. typedef enum _NT4_PROCESSINFOCLASS {
  182. Nt4ProcessBasicInformation,
  183. Nt4ProcessQuotaLimits,
  184. Nt4ProcessIoCounters,
  185. Nt4ProcessVmCounters,
  186. Nt4ProcessTimes,
  187. Nt4ProcessBasePriority,
  188. Nt4ProcessRaisePriority,
  189. Nt4ProcessDebugPort,
  190. Nt4ProcessExceptionPort,
  191. Nt4ProcessAccessToken,
  192. Nt4ProcessLdtInformation,
  193. Nt4ProcessLdtSize,
  194. Nt4ProcessDefaultHardErrorMode,
  195. Nt4ProcessIoPortHandlers, // Note: this is kernel mode only
  196. Nt4ProcessPooledUsageAndLimits,
  197. Nt4ProcessWorkingSetWatch,
  198. Nt4ProcessUserModeIOPL,
  199. Nt4ProcessEnableAlignmentFaultFixup,
  200. Nt4ProcessPriorityClass,
  201. Nt4ProcessWx86Information,
  202. Nt4ProcessHandleCount,
  203. Nt4ProcessAffinityMask,
  204. Nt4ProcessPriorityBoost,
  205. MaxNt4ProcessInfoClass
  206. } NT4_PROCESSINFOCLASS;
  207. //
  208. // From ntpsapi.h
  209. //
  210. //
  211. // Process Environment Block
  212. //
  213. typedef struct _NT4_PEB_LDR_DATA {
  214. ULONG Length;
  215. BOOLEAN Initialized;
  216. HANDLE SsHandle;
  217. LIST_ENTRY InLoadOrderModuleList;
  218. LIST_ENTRY InMemoryOrderModuleList;
  219. LIST_ENTRY InInitializationOrderModuleList;
  220. } NT4_PEB_LDR_DATA, *PNT4_PEB_LDR_DATA;
  221. #define NT4_GDI_HANDLE_BUFFER_SIZE 34
  222. typedef struct _NT4_PEB_FREE_BLOCK {
  223. struct _PEB_FREE_BLOCK *Next;
  224. ULONG Size;
  225. } NT4_PEB_FREE_BLOCK, *PNT4_PEB_FREE_BLOCK;
  226. #if 0
  227. typedef struct _NT4_CLIENT_ID {
  228. HANDLE UniqueProcess;
  229. HANDLE UniqueThread;
  230. } NT4_CLIENT_ID;
  231. typedef NT4_CLIENT_ID *PNT4_CLIENT_ID;
  232. #endif
  233. typedef struct _NT4_PEB {
  234. BOOLEAN InheritedAddressSpace; // These four fields cannot change unless the
  235. BOOLEAN ReadImageFileExecOptions; //
  236. BOOLEAN BeingDebugged; //
  237. BOOLEAN SpareBool; //
  238. HANDLE Mutant; // INITIAL_PEB structure is also updated.
  239. PVOID ImageBaseAddress;
  240. PNT4_PEB_LDR_DATA Ldr;
  241. struct _RTL_USER_PROCESS_PARAMETERS *ProcessParameters;
  242. PVOID SubSystemData;
  243. PVOID ProcessHeap;
  244. PVOID FastPebLock;
  245. PVOID FastPebLockRoutine;
  246. PVOID FastPebUnlockRoutine;
  247. ULONG EnvironmentUpdateCount;
  248. PVOID KernelCallbackTable;
  249. HANDLE EventLogSection;
  250. PVOID EventLog;
  251. PNT4_PEB_FREE_BLOCK FreeList;
  252. ULONG TlsExpansionCounter;
  253. PVOID TlsBitmap;
  254. ULONG TlsBitmapBits[2]; // relates to TLS_MINIMUM_AVAILABLE
  255. PVOID ReadOnlySharedMemoryBase;
  256. PVOID ReadOnlySharedMemoryHeap;
  257. PVOID *ReadOnlyStaticServerData;
  258. PVOID AnsiCodePageData;
  259. PVOID OemCodePageData;
  260. PVOID UnicodeCaseTableData;
  261. //
  262. // Useful information for LdrpInitialize
  263. ULONG NumberOfProcessors;
  264. ULONG NtGlobalFlag;
  265. //
  266. // Passed up from MmCreatePeb from Session Manager registry key
  267. //
  268. LARGE_INTEGER CriticalSectionTimeout;
  269. ULONG HeapSegmentReserve;
  270. ULONG HeapSegmentCommit;
  271. ULONG HeapDeCommitTotalFreeThreshold;
  272. ULONG HeapDeCommitFreeBlockThreshold;
  273. //
  274. // Where heap manager keeps track of all heaps created for a process
  275. // Fields initialized by MmCreatePeb. ProcessHeaps is initialized
  276. // to point to the first free byte after the PEB and MaximumNumberOfHeaps
  277. // is computed from the page size used to hold the PEB, less the fixed
  278. // size of this data structure.
  279. //
  280. ULONG NumberOfHeaps;
  281. ULONG MaximumNumberOfHeaps;
  282. PVOID *ProcessHeaps;
  283. //
  284. //
  285. PVOID GdiSharedHandleTable;
  286. PVOID ProcessStarterHelper;
  287. PVOID GdiDCAttributeList;
  288. PVOID LoaderLock;
  289. //
  290. // Following fields filled in by MmCreatePeb from system values and/or
  291. // image header.
  292. //
  293. ULONG OSMajorVersion;
  294. ULONG OSMinorVersion;
  295. ULONG OSBuildNumber;
  296. ULONG OSPlatformId;
  297. ULONG ImageSubsystem;
  298. ULONG ImageSubsystemMajorVersion;
  299. ULONG ImageSubsystemMinorVersion;
  300. ULONG ImageProcessAffinityMask;
  301. ULONG GdiHandleBuffer[NT4_GDI_HANDLE_BUFFER_SIZE];
  302. } NT4_PEB, *PNT4_PEB;
  303. //
  304. // From ntldr.h
  305. //
  306. typedef struct _NT4_LDR_DATA_TABLE_ENTRY {
  307. LIST_ENTRY InLoadOrderLinks;
  308. LIST_ENTRY InMemoryOrderLinks;
  309. LIST_ENTRY InInitializationOrderLinks;
  310. PVOID DllBase;
  311. PVOID EntryPoint;
  312. ULONG SizeOfImage;
  313. NT4_UNICODE_STRING FullDllName;
  314. NT4_UNICODE_STRING BaseDllName;
  315. ULONG Flags;
  316. USHORT LoadCount;
  317. USHORT TlsIndex;
  318. union {
  319. LIST_ENTRY HashLinks;
  320. struct {
  321. PVOID SectionPointer;
  322. ULONG CheckSum;
  323. };
  324. };
  325. ULONG TimeDateStamp;
  326. } NT4_LDR_DATA_TABLE_ENTRY, *PNT4_LDR_DATA_TABLE_ENTRY;
  327. //
  328. // From ntpsapi.h.
  329. //
  330. typedef struct _NT4_PROCESS_BASIC_INFORMATION {
  331. NTSTATUS ExitStatus;
  332. PNT4_PEB PebBaseAddress;
  333. NT4_KAFFINITY AffinityMask;
  334. NT4_KPRIORITY BasePriority;
  335. ULONG UniqueProcessId;
  336. ULONG InheritedFromUniqueProcessId;
  337. } NT4_PROCESS_BASIC_INFORMATION;
  338. typedef NT4_PROCESS_BASIC_INFORMATION *PNT4_PROCESS_BASIC_INFORMATION;
  339. #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
  340. typedef DWORD ACCESS_MASK;