4 * Windows NT internal data structures and functions
6 * Note: This header exists only for compatibility with the native SDK.
7 * It's definitions are incomplete and potentially unsuitable.
8 * ReactOS modules should not make use of it!
12 * This file is part of the ReactOS PSDK package.
15 * Timo Kreuzer (timo.kreuzer@reactos.org)
17 * THIS SOFTWARE IS NOT COPYRIGHTED
19 * This source code is offered for use in the public domain. You may
20 * use, modify or distribute it freely.
22 * This code is distributed in the hope that it will be useful but
23 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
24 * DISCLAIMED. This includes but is not limited to warranties of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
31 #error "Do not use this header, use NDK!"
37 //#include <winapifamily.h>
44 typedef _Return_type_success_(return >= 0) LONG NTSTATUS
;
47 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
50 #ifndef NT_INFORMATION
51 #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
55 #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
59 #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
62 typedef CONST
char *PCSZ
;
64 typedef struct _STRING
70 typedef STRING ANSI_STRING
;
71 typedef PSTRING PANSI_STRING
;
72 typedef PSTRING PCANSI_STRING
; // yes, thats the definition from MS!
73 typedef STRING OEM_STRING
;
74 typedef PSTRING POEM_STRING
;
75 typedef const STRING
*PCOEM_STRING
;
77 typedef struct _UNICODE_STRING
82 } UNICODE_STRING
, *PUNICODE_STRING
;
83 typedef const UNICODE_STRING
*PCUNICODE_STRING
;
85 typedef struct _RTL_USER_PROCESS_PARAMETERS
89 UNICODE_STRING ImagePathName
;
90 UNICODE_STRING CommandLine
;
91 } RTL_USER_PROCESS_PARAMETERS
, *PRTL_USER_PROCESS_PARAMETERS
;
93 typedef struct _PEB_LDR_DATA
97 LIST_ENTRY InMemoryOrderModuleList
;
98 } PEB_LDR_DATA
, *PPEB_LDR_DATA
;
100 typedef struct _LDR_DATA_TABLE_ENTRY
103 LIST_ENTRY InMemoryOrderLinks
;
107 UNICODE_STRING FullDllName
;
115 } LDR_DATA_TABLE_ENTRY
, *PLDR_DATA_TABLE_ENTRY
;
119 (NTAPI
*PPS_POST_PROCESS_INIT_ROUTINE
)(
129 PRTL_USER_PROCESS_PARAMETERS ProcessParameters
;
131 PVOID AtlThunkSListPtr
;
136 ULONG AtlThunkSListPtr32
;
139 PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
;
140 BYTE Reserved11
[128];
148 PPEB ProcessEnvironmentBlock
;
149 PVOID Reserved2
[399];
150 BYTE Reserved3
[1952];
154 PVOID ReservedForOle
;
156 PVOID TlsExpansionSlots
;
159 typedef enum _FILE_INFORMATION_CLASS
161 FileDirectoryInformation
= 1
162 } FILE_INFORMATION_CLASS
;
164 #define INTERNAL_TS_ACTIVE_CONSOLE_ID (*((volatile ULONG*)0x7ffe02d8))
165 #define LOGONID_CURRENT ((ULONG)-1)
166 #define SERVERNAME_CURRENT ((HANDLE)NULL)
168 /* Flags for NtCreateFile and NtOpenFile */
169 #define FILE_DIRECTORY_FILE 0x00000001
170 #define FILE_WRITE_THROUGH 0x00000002
171 #define FILE_SEQUENTIAL_ONLY 0x00000004
172 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
173 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
174 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
175 #define FILE_NON_DIRECTORY_FILE 0x00000040
176 #define FILE_CREATE_TREE_CONNECTION 0x00000080
177 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
178 #define FILE_NO_EA_KNOWLEDGE 0x00000200
179 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400
180 #define FILE_RANDOM_ACCESS 0x00000800
181 #define FILE_DELETE_ON_CLOSE 0x00001000
182 #define FILE_OPEN_BY_FILE_ID 0x00002000
183 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
184 #define FILE_NO_COMPRESSION 0x00008000
185 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
186 #define FILE_OPEN_REQUIRING_OPLOCK 0x00010000
188 #define FILE_RESERVE_OPFILTER 0x00100000
189 #define FILE_OPEN_REPARSE_POINT 0x00200000
190 #define FILE_OPEN_NO_RECALL 0x00400000
191 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
193 /* Status for NtCreateFile or NtOpenFile */
194 #define FILE_SUPERSEDED 0x00000000
195 #define FILE_OPENED 0x00000001
196 #define FILE_CREATED 0x00000002
197 #define FILE_OVERWRITTEN 0x00000003
198 #define FILE_EXISTS 0x00000004
199 #define FILE_DOES_NOT_EXIST 0x00000005
201 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
202 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
203 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
204 #define FILE_VALID_SET_FLAGS 0x00000036
206 /* Disposition for NtCreateFile */
207 #define FILE_SUPERSEDE 0x00000000
208 #define FILE_OPEN 0x00000001
209 #define FILE_CREATE 0x00000002
210 #define FILE_OPEN_IF 0x00000003
211 #define FILE_OVERWRITE 0x00000004
212 #define FILE_OVERWRITE_IF 0x00000005
213 #define FILE_MAXIMUM_DISPOSITION 0x00000005
215 typedef struct _OBJECT_ATTRIBUTES
218 HANDLE RootDirectory
;
219 PUNICODE_STRING ObjectName
;
221 PVOID SecurityDescriptor
;
222 PVOID SecurityQualityOfService
;
223 } OBJECT_ATTRIBUTES
, *POBJECT_ATTRIBUTES
;
225 #define OBJ_INHERIT 0x00000002L
226 #define OBJ_PERMANENT 0x00000010L
227 #define OBJ_EXCLUSIVE 0x00000020L
228 #define OBJ_CASE_INSENSITIVE 0x00000040L
229 #define OBJ_OPENIF 0x00000080L
230 #define OBJ_OPENLINK 0x00000100L
231 #define OBJ_KERNEL_HANDLE 0x00000200L
232 #define OBJ_FORCE_ACCESS_CHECK 0x00000400L
233 #define OBJ_VALID_ATTRIBUTES 0x000007F2L
235 #ifndef InitializeObjectAttributes
236 #define InitializeObjectAttributes(p, n, a, r, s) \
238 (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
239 (p)->RootDirectory = r; \
240 (p)->Attributes = a; \
241 (p)->ObjectName = n; \
242 (p)->SecurityDescriptor = s; \
243 (p)->SecurityQualityOfService = NULL; \
247 typedef struct _IO_STATUS_BLOCK
{
253 ULONG_PTR Information
;
254 } IO_STATUS_BLOCK
, *PIO_STATUS_BLOCK
;
261 _Out_ PHANDLE FileHandle
,
262 _In_ ACCESS_MASK DesiredAccess
,
263 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
264 _Out_ PIO_STATUS_BLOCK IoStatusBlock
,
265 _In_opt_ PLARGE_INTEGER AllocationSize
,
266 _In_ ULONG FileAttributes
,
267 _In_ ULONG ShareAccess
,
268 _In_ ULONG CreateDisposition
,
269 _In_ ULONG CreateOptions
,
270 _In_reads_bytes_opt_(EaLength
) PVOID EaBuffer
,
271 _In_ ULONG EaLength
);
278 _Out_ PHANDLE FileHandle
,
279 _In_ ACCESS_MASK DesiredAccess
,
280 _In_ POBJECT_ATTRIBUTES ObjectAttributes
,
281 _Out_ PIO_STATUS_BLOCK IoStatusBlock
,
282 _In_ ULONG ShareAccess
,
283 _In_ ULONG OpenOptions
);
294 (NTAPI
*PIO_APC_ROUTINE
)(
295 _In_ PVOID ApcContext
,
296 _In_ PIO_STATUS_BLOCK IoStatusBlock
,
297 _In_ ULONG Reserved
);
303 NtDeviceIoControlFile(
304 _In_ HANDLE FileHandle
,
305 _In_opt_ HANDLE Event
,
306 _In_opt_ PIO_APC_ROUTINE ApcRoutine
,
307 _In_opt_ PVOID ApcContext
,
308 _Out_ PIO_STATUS_BLOCK IoStatusBlock
,
309 _In_ ULONG IoControlCode
,
310 _In_reads_bytes_opt_(InputBufferLength
) PVOID InputBuffer
,
311 _In_ ULONG InputBufferLength
,
312 _Out_writes_bytes_opt_(OutputBufferLength
) PVOID OutputBuffer
,
313 _In_ ULONG OutputBufferLength
);
319 NtWaitForSingleObject(
321 _In_ BOOLEAN Alertable
,
322 _In_opt_ PLARGE_INTEGER Timeout
);
329 _In_ HANDLE KeyHandle
,
330 _In_ PUNICODE_STRING NewName
);
336 NtNotifyChangeMultipleKeys(
337 _In_ HANDLE MasterKeyHandle
,
338 _In_opt_ ULONG Count
,
339 _In_reads_opt_(Count
) OBJECT_ATTRIBUTES SubordinateObjects
[],
340 _In_opt_ HANDLE Event
,
341 _In_opt_ PIO_APC_ROUTINE ApcRoutine
,
342 _In_opt_ PVOID ApcContext
,
343 _Out_ PIO_STATUS_BLOCK IoStatusBlock
,
344 _In_ ULONG CompletionFilter
,
345 _In_ BOOLEAN WatchTree
,
346 _Out_writes_bytes_opt_(BufferSize
) PVOID Buffer
,
347 _In_ ULONG BufferSize
,
348 _In_ BOOLEAN Asynchronous
);
350 typedef struct _KEY_VALUE_ENTRY
352 PUNICODE_STRING ValueName
;
356 } KEY_VALUE_ENTRY
, *PKEY_VALUE_ENTRY
;
362 NtQueryMultipleValueKey(
363 _In_ HANDLE KeyHandle
,
364 _Inout_updates_(EntryCount
) PKEY_VALUE_ENTRY ValueEntries
,
365 _In_ ULONG EntryCount
,
366 _Out_writes_bytes_(*BufferLength
) PVOID ValueBuffer
,
367 _Inout_ PULONG BufferLength
,
368 _Out_opt_ PULONG RequiredBufferLength
);
370 typedef enum _KEY_SET_INFORMATION_CLASS
372 KeyWriteTimeInformation
,
373 KeyWow64FlagsInformation
,
374 KeyControlFlagsInformation
,
375 KeySetVirtualizationInformation
,
376 KeySetDebugInformation
,
377 KeySetHandleTagsInformation
,
379 } KEY_SET_INFORMATION_CLASS
;
386 _In_ HANDLE KeyHandle
,
387 _In_ _Strict_type_match_
388 KEY_SET_INFORMATION_CLASS KeySetInformationClass
,
389 _In_reads_bytes_(KeySetInformationLength
) PVOID KeySetInformation
,
390 _In_ ULONG KeySetInformationLength
);
392 typedef enum _PROCESSINFOCLASS
394 ProcessBasicInformation
= 0,
395 ProcessDebugPort
= 7,
396 ProcessWow64Information
= 26,
397 ProcessImageFileName
= 27,
398 ProcessBreakOnTermination
= 29
401 typedef struct _PROCESS_BASIC_INFORMATION
406 ULONG_PTR UniqueProcessId
;
408 } PROCESS_BASIC_INFORMATION
, *PPROCESS_BASIC_INFORMATION
;
414 NtQueryInformationProcess(
415 _In_ HANDLE ProcessHandle
,
416 _In_ PROCESSINFOCLASS ProcessInformationClass
,
417 _Out_ PVOID ProcessInformation
,
418 _In_ ULONG ProcessInformationLength
,
419 _Out_opt_ PULONG ReturnLength
);
421 typedef enum _THREADINFOCLASS
423 ThreadIsIoPending
= 16
430 NtQueryInformationThread(
431 _In_ HANDLE ThreadHandle
,
432 _In_ THREADINFOCLASS ThreadInformationClass
,
433 _Out_ PVOID ThreadInformation
,
434 _In_ ULONG ThreadInformationLength
,
435 _Out_opt_ PULONG ReturnLength
);
437 typedef enum _OBJECT_INFORMATION_CLASS
439 ObjectBasicInformation
= 0,
440 ObjectTypeInformation
= 2
441 } OBJECT_INFORMATION_CLASS
;
443 typedef struct _PUBLIC_OBJECT_BASIC_INFORMATION
446 ACCESS_MASK GrantedAccess
;
450 } PUBLIC_OBJECT_BASIC_INFORMATION
, *PPUBLIC_OBJECT_BASIC_INFORMATION
;
452 typedef struct __PUBLIC_OBJECT_TYPE_INFORMATION
454 UNICODE_STRING TypeName
;
456 } PUBLIC_OBJECT_TYPE_INFORMATION
, *PPUBLIC_OBJECT_TYPE_INFORMATION
;
458 _IRQL_requires_max_(PASSIVE_LEVEL
)
464 _In_opt_ HANDLE Handle
,
465 _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass
,
466 _Out_writes_bytes_opt_(ObjectInformationLength
) PVOID ObjectInformation
,
467 _In_ ULONG ObjectInformationLength
,
468 _Out_opt_ PULONG ReturnLength
);
470 typedef enum _SYSTEM_INFORMATION_CLASS
472 SystemBasicInformation
= 0,
473 SystemPerformanceInformation
= 2,
474 SystemTimeOfDayInformation
= 3,
475 SystemProcessInformation
= 5,
476 SystemProcessorPerformanceInformation
= 8,
477 SystemInterruptInformation
= 23,
478 SystemExceptionInformation
= 33,
479 SystemRegistryQuotaInformation
= 37,
480 SystemLookasideInformation
= 45,
481 SystemPolicyInformation
= 134,
482 } SYSTEM_INFORMATION_CLASS
;
484 typedef struct _SYSTEM_BASIC_INFORMATION
488 CCHAR NumberOfProcessors
;
489 } SYSTEM_BASIC_INFORMATION
, *PSYSTEM_BASIC_INFORMATION
;
491 typedef struct _SYSTEM_PERFORMANCE_INFORMATION
494 } SYSTEM_PERFORMANCE_INFORMATION
, *PSYSTEM_PERFORMANCE_INFORMATION
;
496 typedef struct _SYSTEM_TIMEOFDAY_INFORMATION
499 } SYSTEM_TIMEOFDAY_INFORMATION
, *PSYSTEM_TIMEOFDAY_INFORMATION
;
501 typedef struct _SYSTEM_PROCESS_INFORMATION
503 ULONG NextEntryOffset
;
506 HANDLE UniqueProcessId
;
511 SIZE_T PeakPagefileUsage
;
512 SIZE_T PrivatePageCount
;
513 LARGE_INTEGER Reserved6
[6];
514 } SYSTEM_PROCESS_INFORMATION
, *PSYSTEM_PROCESS_INFORMATION
;
516 typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
518 LARGE_INTEGER IdleTime
;
519 LARGE_INTEGER KernelTime
;
520 LARGE_INTEGER UserTime
;
521 LARGE_INTEGER Reserved1
[2];
523 } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
;
525 typedef struct _SYSTEM_INTERRUPT_INFORMATION
528 } SYSTEM_INTERRUPT_INFORMATION
, *PSYSTEM_INTERRUPT_INFORMATION
;
530 typedef struct _SYSTEM_EXCEPTION_INFORMATION
533 } SYSTEM_EXCEPTION_INFORMATION
, *PSYSTEM_EXCEPTION_INFORMATION
;
535 typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION
537 ULONG RegistryQuotaAllowed
;
538 ULONG RegistryQuotaUsed
;
540 } SYSTEM_REGISTRY_QUOTA_INFORMATION
, *PSYSTEM_REGISTRY_QUOTA_INFORMATION
;
542 typedef struct _SYSTEM_LOOKASIDE_INFORMATION
545 } SYSTEM_LOOKASIDE_INFORMATION
, *PSYSTEM_LOOKASIDE_INFORMATION
;
547 typedef struct _SYSTEM_POLICY_INFORMATION
551 } SYSTEM_POLICY_INFORMATION
, *PSYSTEM_POLICY_INFORMATION
;
557 NtQuerySystemInformation(
558 _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass
,
559 _Out_ PVOID SystemInformation
,
560 _In_ ULONG InformationLength
,
561 _Out_opt_ PULONG ResultLength
);
563 typedef enum _WINSTATIONINFOCLASS
565 WinStationInformation
= 8
566 } WINSTATIONINFOCLASS
;
568 typedef struct _WINSTATIONINFORMATIONW
572 BYTE Reserved3
[1140];
573 } WINSTATIONINFORMATIONW
, * PWINSTATIONINFORMATIONW
;
577 (WINAPI
* PWINSTATIONQUERYINFORMATIONW
)(
590 _Out_ PLARGE_INTEGER SystemTime
);
592 #define RtlMoveMemory(Dest,Source,Length) memmove((Dest),(Source),(Length))
593 #define RtlFillMemory(Dest,Length,Fill) memset((Dest),(Fill),(Length))
594 #define RtlZeroMemory(Dest,Length) RtlFillMemory((Dest),(Length),0)
599 PSTRING DestinationString
,
605 PANSI_STRING DestinationString
,
610 RtlInitUnicodeString(
611 PUNICODE_STRING DestinationString
,
612 PCWSTR SourceString
);
617 PANSI_STRING AnsiString
);
622 POEM_STRING OemString
);
626 RtlFreeUnicodeString(
627 PUNICODE_STRING UnicodeString
);
631 RtlAnsiStringToUnicodeString(
632 PUNICODE_STRING DestinationString
,
633 PCANSI_STRING SourceString
,
634 BOOLEAN AllocateDestinationString
);
638 RtlUnicodeStringToAnsiString(
639 PANSI_STRING DestinationString
,
640 PCUNICODE_STRING SourceString
,
641 BOOLEAN AllocateDestinationString
);
645 RtlUnicodeStringToOemString(
646 POEM_STRING DestinationString
,
647 PCUNICODE_STRING SourceString
,
648 BOOLEAN AllocateDestinationString
);
652 RtlUnicodeToMultiByteSize(
653 _Out_ PULONG BytesInMultiByteString
,
654 _In_reads_bytes_(BytesInUnicodeString
) PWCH UnicodeString
,
655 _In_ ULONG BytesInUnicodeString
);
666 RtlIsNameLegalDOS8Dot3(
667 _In_ PUNICODE_STRING Name
,
668 _Inout_opt_ POEM_STRING OemName
,
669 _Inout_opt_ PBOOLEAN NameContainsSpaces
);
673 RtlLocalTimeToSystemTime(
674 IN PLARGE_INTEGER LocalTime
,
675 _Out_ PLARGE_INTEGER SystemTime
);
679 RtlTimeToSecondsSince1970(
681 PULONG ElapsedSeconds
);
683 _When_(Status
< 0, _Out_range_(>, 0))
684 _When_(Status
>= 0, _Out_range_(==, 0))
687 RtlNtStatusToDosError(
688 _In_ NTSTATUS Status
);
692 RtlConvertSidToUnicodeString(
693 PUNICODE_STRING UnicodeString
,
695 BOOLEAN AllocateDestinationString
);
707 #endif /* _WINTERNL_ */