Process Hacker
ntexapi.h
Go to the documentation of this file.
1 #ifndef _NTEXAPI_H
2 #define _NTEXAPI_H
3 
4 #include <ntkeapi.h>
5 
6 #if (PHNT_MODE != PHNT_MODE_KERNEL)
7 
8 // Thread execution
9 
10 NTSYSCALLAPI
11 NTSTATUS
12 NTAPI
13 NtDelayExecution(
14  _In_ BOOLEAN Alertable,
15  _In_ PLARGE_INTEGER DelayInterval
16  );
17 
18 // Environment values
19 
20 NTSYSCALLAPI
21 NTSTATUS
22 NTAPI
23 NtQuerySystemEnvironmentValue(
24  _In_ PUNICODE_STRING VariableName,
25  _Out_writes_bytes_(ValueLength) PWSTR VariableValue,
26  _In_ USHORT ValueLength,
27  _Out_opt_ PUSHORT ReturnLength
28  );
29 
30 NTSYSCALLAPI
31 NTSTATUS
32 NTAPI
33 NtSetSystemEnvironmentValue(
34  _In_ PUNICODE_STRING VariableName,
35  _In_ PUNICODE_STRING VariableValue
36  );
37 
38 #if (PHNT_VERSION >= PHNT_WIN8)
39 
40 NTSYSCALLAPI
41 NTSTATUS
42 NTAPI
43 NtQuerySystemEnvironmentValueEx(
44  _In_ PUNICODE_STRING VariableName,
45  _In_ LPGUID VendorGuid,
46  _Out_writes_bytes_opt_(*ValueLength) PVOID Value,
47  _Inout_ PULONG ValueLength,
48  _Out_opt_ PULONG Attributes
49  );
50 
51 NTSYSCALLAPI
52 NTSTATUS
53 NTAPI
54 NtSetSystemEnvironmentValueEx(
55  _In_ PUNICODE_STRING VariableName,
56  _In_ LPGUID VendorGuid,
57  _In_reads_bytes_opt_(ValueLength) PVOID Value,
58  _In_ ULONG ValueLength,
59  _In_ ULONG Attributes
60  );
61 
62 NTSYSCALLAPI
63 NTSTATUS
64 NTAPI
65 NtEnumerateSystemEnvironmentValuesEx(
66  _In_ ULONG InformationClass,
67  _Out_ PVOID Buffer,
68  _Inout_ PULONG BufferLength
69  );
70 
71 #endif
72 
73 // EFI
74 
75 // private
76 typedef struct _BOOT_ENTRY
77 {
78  ULONG Version;
79  ULONG Length;
80  ULONG Id;
81  ULONG Attributes;
82  ULONG FriendlyNameOffset;
83  ULONG BootFilePathOffset;
84  ULONG OsOptionsLength;
85  UCHAR OsOptions[1];
86 } BOOT_ENTRY, *PBOOT_ENTRY;
87 
88 // private
89 typedef struct _BOOT_ENTRY_LIST
90 {
91  ULONG NextEntryOffset;
92  BOOT_ENTRY BootEntry;
93 } BOOT_ENTRY_LIST, *PBOOT_ENTRY_LIST;
94 
95 // private
96 typedef struct _BOOT_OPTIONS
97 {
98  ULONG Version;
99  ULONG Length;
100  ULONG Timeout;
101  ULONG CurrentBootEntryId;
102  ULONG NextBootEntryId;
103  WCHAR HeadlessRedirection[1];
104 } BOOT_OPTIONS, *PBOOT_OPTIONS;
105 
106 // private
107 typedef struct _FILE_PATH
108 {
109  ULONG Version;
110  ULONG Length;
111  ULONG Type;
112  UCHAR FilePath[1];
113 } FILE_PATH, *PFILE_PATH;
114 
115 // private
116 typedef struct _EFI_DRIVER_ENTRY
117 {
118  ULONG Version;
119  ULONG Length;
120  ULONG Id;
121  ULONG FriendlyNameOffset;
122  ULONG DriverFilePathOffset;
123 } EFI_DRIVER_ENTRY, *PEFI_DRIVER_ENTRY;
124 
125 // private
126 typedef struct _EFI_DRIVER_ENTRY_LIST
127 {
128  ULONG NextEntryOffset;
129  EFI_DRIVER_ENTRY DriverEntry;
130 } EFI_DRIVER_ENTRY_LIST, *PEFI_DRIVER_ENTRY_LIST;
131 
132 #if (PHNT_VERSION >= PHNT_VISTA)
133 
134 NTSYSCALLAPI
135 NTSTATUS
136 NTAPI
137 NtAddBootEntry(
138  _In_ PBOOT_ENTRY BootEntry,
139  _Out_opt_ PULONG Id
140  );
141 
142 NTSYSCALLAPI
143 NTSTATUS
144 NTAPI
145 NtDeleteBootEntry(
146  _In_ ULONG Id
147  );
148 
149 NTSYSCALLAPI
150 NTSTATUS
151 NTAPI
152 NtModifyBootEntry(
153  _In_ PBOOT_ENTRY BootEntry
154  );
155 
156 NTSYSCALLAPI
157 NTSTATUS
158 NTAPI
159 NtEnumerateBootEntries(
160  _Out_writes_bytes_opt_(*BufferLength) PVOID Buffer,
161  _Inout_ PULONG BufferLength
162  );
163 
164 NTSYSCALLAPI
165 NTSTATUS
166 NTAPI
167 NtQueryBootEntryOrder(
168  _Out_writes_opt_(*Count) PULONG Ids,
169  _Inout_ PULONG Count
170  );
171 
172 NTSYSCALLAPI
173 NTSTATUS
174 NTAPI
175 NtSetBootEntryOrder(
176  _In_reads_(Count) PULONG Ids,
177  _In_ ULONG Count
178  );
179 
180 NTSYSCALLAPI
181 NTSTATUS
182 NTAPI
183 NtQueryBootOptions(
184  _Out_writes_bytes_opt_(*BootOptionsLength) PBOOT_OPTIONS BootOptions,
185  _Inout_ PULONG BootOptionsLength
186  );
187 
188 NTSYSCALLAPI
189 NTSTATUS
190 NTAPI
191 NtSetBootOptions(
192  _In_ PBOOT_OPTIONS BootOptions,
193  _In_ ULONG FieldsToChange
194  );
195 
196 NTSYSCALLAPI
197 NTSTATUS
198 NTAPI
199 NtTranslateFilePath(
200  _In_ PFILE_PATH InputFilePath,
201  _In_ ULONG OutputType,
202  _Out_writes_bytes_opt_(*OutputFilePathLength) PFILE_PATH OutputFilePath,
203  _Inout_opt_ PULONG OutputFilePathLength
204  );
205 
206 NTSYSCALLAPI
207 NTSTATUS
208 NTAPI
209 NtAddDriverEntry(
210  _In_ PEFI_DRIVER_ENTRY DriverEntry,
211  _Out_opt_ PULONG Id
212  );
213 
214 NTSYSCALLAPI
215 NTSTATUS
216 NTAPI
217 NtDeleteDriverEntry(
218  _In_ ULONG Id
219  );
220 
221 NTSYSCALLAPI
222 NTSTATUS
223 NTAPI
224 NtModifyDriverEntry(
225  _In_ PEFI_DRIVER_ENTRY DriverEntry
226  );
227 
228 NTSYSCALLAPI
229 NTSTATUS
230 NTAPI
231 NtEnumerateDriverEntries(
232  _Out_writes_bytes_opt_(*BufferLength) PVOID Buffer,
233  _Inout_ PULONG BufferLength
234  );
235 
236 NTSYSCALLAPI
237 NTSTATUS
238 NTAPI
239 NtQueryDriverEntryOrder(
240  _Out_writes_opt_(*Count) PULONG Ids,
241  _Inout_ PULONG Count
242  );
243 
244 NTSYSCALLAPI
245 NTSTATUS
246 NTAPI
247 NtSetDriverEntryOrder(
248  _In_reads_(Count) PULONG Ids,
249  _In_ ULONG Count
250  );
251 
252 #endif
253 
254 // Event
255 
256 #ifndef EVENT_QUERY_STATE
257 #define EVENT_QUERY_STATE 0x0001
258 #endif
259 
260 typedef enum _EVENT_INFORMATION_CLASS
261 {
262  EventBasicInformation
263 } EVENT_INFORMATION_CLASS;
264 
265 typedef struct _EVENT_BASIC_INFORMATION
266 {
267  EVENT_TYPE EventType;
268  LONG EventState;
269 } EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION;
270 
271 NTSYSCALLAPI
272 NTSTATUS
273 NTAPI
274 NtCreateEvent(
275  _Out_ PHANDLE EventHandle,
276  _In_ ACCESS_MASK DesiredAccess,
277  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
278  _In_ EVENT_TYPE EventType,
279  _In_ BOOLEAN InitialState
280  );
281 
282 NTSYSCALLAPI
283 NTSTATUS
284 NTAPI
285 NtOpenEvent(
286  _Out_ PHANDLE EventHandle,
287  _In_ ACCESS_MASK DesiredAccess,
288  _In_ POBJECT_ATTRIBUTES ObjectAttributes
289  );
290 
291 NTSYSCALLAPI
292 NTSTATUS
293 NTAPI
294 NtSetEvent(
295  _In_ HANDLE EventHandle,
296  _Out_opt_ PLONG PreviousState
297  );
298 
299 NTSYSCALLAPI
300 NTSTATUS
301 NTAPI
302 NtSetEventBoostPriority(
303  _In_ HANDLE EventHandle
304  );
305 
306 NTSYSCALLAPI
307 NTSTATUS
308 NTAPI
309 NtClearEvent(
310  _In_ HANDLE EventHandle
311  );
312 
313 NTSYSCALLAPI
314 NTSTATUS
315 NTAPI
316 NtResetEvent(
317  _In_ HANDLE EventHandle,
318  _Out_opt_ PLONG PreviousState
319  );
320 
321 NTSYSCALLAPI
322 NTSTATUS
323 NTAPI
324 NtPulseEvent(
325  _In_ HANDLE EventHandle,
326  _Out_opt_ PLONG PreviousState
327  );
328 
329 NTSYSCALLAPI
330 NTSTATUS
331 NTAPI
332 NtQueryEvent(
333  _In_ HANDLE EventHandle,
334  _In_ EVENT_INFORMATION_CLASS EventInformationClass,
335  _Out_writes_bytes_(EventInformationLength) PVOID EventInformation,
336  _In_ ULONG EventInformationLength,
337  _Out_opt_ PULONG ReturnLength
338  );
339 
340 // Event Pair
341 
342 #define EVENT_PAIR_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE)
343 
344 NTSYSCALLAPI
345 NTSTATUS
346 NTAPI
347 NtCreateEventPair(
348  _Out_ PHANDLE EventPairHandle,
349  _In_ ACCESS_MASK DesiredAccess,
350  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes
351  );
352 
353 NTSYSCALLAPI
354 NTSTATUS
355 NTAPI
356 NtOpenEventPair(
357  _Out_ PHANDLE EventPairHandle,
358  _In_ ACCESS_MASK DesiredAccess,
359  _In_ POBJECT_ATTRIBUTES ObjectAttributes
360  );
361 
362 NTSYSCALLAPI
363 NTSTATUS
364 NTAPI
365 NtSetLowEventPair(
366  _In_ HANDLE EventPairHandle
367  );
368 
369 NTSYSCALLAPI
370 NTSTATUS
371 NTAPI
372 NtSetHighEventPair(
373  _In_ HANDLE EventPairHandle
374  );
375 
376 NTSYSCALLAPI
377 NTSTATUS
378 NTAPI
379 NtWaitLowEventPair(
380  _In_ HANDLE EventPairHandle
381  );
382 
383 NTSYSCALLAPI
384 NTSTATUS
385 NTAPI
386 NtWaitHighEventPair(
387  _In_ HANDLE EventPairHandle
388  );
389 
390 NTSYSCALLAPI
391 NTSTATUS
392 NTAPI
393 NtSetLowWaitHighEventPair(
394  _In_ HANDLE EventPairHandle
395  );
396 
397 NTSYSCALLAPI
398 NTSTATUS
399 NTAPI
400 NtSetHighWaitLowEventPair(
401  _In_ HANDLE EventPairHandle
402  );
403 
404 // Mutant
405 
406 typedef enum _MUTANT_INFORMATION_CLASS
407 {
408  MutantBasicInformation,
409  MutantOwnerInformation
410 } MUTANT_INFORMATION_CLASS;
411 
412 typedef struct _MUTANT_BASIC_INFORMATION
413 {
414  LONG CurrentCount;
415  BOOLEAN OwnedByCaller;
416  BOOLEAN AbandonedState;
417 } MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION;
418 
419 typedef struct _MUTANT_OWNER_INFORMATION
420 {
421  CLIENT_ID ClientId;
422 } MUTANT_OWNER_INFORMATION, *PMUTANT_OWNER_INFORMATION;
423 
424 NTSYSCALLAPI
425 NTSTATUS
426 NTAPI
427 NtCreateMutant(
428  _Out_ PHANDLE MutantHandle,
429  _In_ ACCESS_MASK DesiredAccess,
430  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
431  _In_ BOOLEAN InitialOwner
432  );
433 
434 NTSYSCALLAPI
435 NTSTATUS
436 NTAPI
437 NtOpenMutant(
438  _Out_ PHANDLE MutantHandle,
439  _In_ ACCESS_MASK DesiredAccess,
440  _In_ POBJECT_ATTRIBUTES ObjectAttributes
441  );
442 
443 NTSYSCALLAPI
444 NTSTATUS
445 NTAPI
446 NtReleaseMutant(
447  _In_ HANDLE MutantHandle,
448  _Out_opt_ PLONG PreviousCount
449  );
450 
451 NTSYSCALLAPI
452 NTSTATUS
453 NTAPI
454 NtQueryMutant(
455  _In_ HANDLE MutantHandle,
456  _In_ MUTANT_INFORMATION_CLASS MutantInformationClass,
457  _Out_writes_bytes_(MutantInformationLength) PVOID MutantInformation,
458  _In_ ULONG MutantInformationLength,
459  _Out_opt_ PULONG ReturnLength
460  );
461 
462 // Semaphore
463 
464 #ifndef SEMAPHORE_QUERY_STATE
465 #define SEMAPHORE_QUERY_STATE 0x0001
466 #endif
467 
468 typedef enum _SEMAPHORE_INFORMATION_CLASS
469 {
470  SemaphoreBasicInformation
471 } SEMAPHORE_INFORMATION_CLASS;
472 
473 typedef struct _SEMAPHORE_BASIC_INFORMATION
474 {
475  LONG CurrentCount;
476  LONG MaximumCount;
477 } SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION;
478 
479 NTSYSCALLAPI
480 NTSTATUS
481 NTAPI
482 NtCreateSemaphore(
483  _Out_ PHANDLE SemaphoreHandle,
484  _In_ ACCESS_MASK DesiredAccess,
485  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
486  _In_ LONG InitialCount,
487  _In_ LONG MaximumCount
488  );
489 
490 NTSYSCALLAPI
491 NTSTATUS
492 NTAPI
493 NtOpenSemaphore(
494  _Out_ PHANDLE SemaphoreHandle,
495  _In_ ACCESS_MASK DesiredAccess,
496  _In_ POBJECT_ATTRIBUTES ObjectAttributes
497  );
498 
499 NTSYSCALLAPI
500 NTSTATUS
501 NTAPI
502 NtReleaseSemaphore(
503  _In_ HANDLE SemaphoreHandle,
504  _In_ LONG ReleaseCount,
505  _Out_opt_ PLONG PreviousCount
506  );
507 
508 NTSYSCALLAPI
509 NTSTATUS
510 NTAPI
511 NtQuerySemaphore(
512  _In_ HANDLE SemaphoreHandle,
513  _In_ SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
514  _Out_writes_bytes_(SemaphoreInformationLength) PVOID SemaphoreInformation,
515  _In_ ULONG SemaphoreInformationLength,
516  _Out_opt_ PULONG ReturnLength
517  );
518 
519 // Timer
520 
521 typedef enum _TIMER_INFORMATION_CLASS
522 {
523  TimerBasicInformation
524 } TIMER_INFORMATION_CLASS;
525 
526 typedef struct _TIMER_BASIC_INFORMATION
527 {
528  LARGE_INTEGER RemainingTime;
529  BOOLEAN TimerState;
530 } TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION;
531 
532 typedef VOID (NTAPI *PTIMER_APC_ROUTINE)(
533  _In_ PVOID TimerContext,
534  _In_ ULONG TimerLowValue,
535  _In_ LONG TimerHighValue
536  );
537 
538 typedef enum _TIMER_SET_INFORMATION_CLASS
539 {
540  TimerSetCoalescableTimer,
541  MaxTimerInfoClass
542 } TIMER_SET_INFORMATION_CLASS;
543 
544 #if (PHNT_VERSION >= PHNT_WIN7)
545 struct _COUNTED_REASON_CONTEXT;
546 
547 typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO
548 {
549  _In_ LARGE_INTEGER DueTime;
550  _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine;
551  _In_opt_ PVOID TimerContext;
552  _In_opt_ struct _COUNTED_REASON_CONTEXT *WakeContext;
553  _In_opt_ ULONG Period;
554  _In_ ULONG TolerableDelay;
555  _Out_opt_ PBOOLEAN PreviousState;
556 } TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO;
557 #endif
558 
559 NTSYSCALLAPI
560 NTSTATUS
561 NTAPI
562 NtCreateTimer(
563  _Out_ PHANDLE TimerHandle,
564  _In_ ACCESS_MASK DesiredAccess,
565  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
566  _In_ TIMER_TYPE TimerType
567  );
568 
569 NTSYSCALLAPI
570 NTSTATUS
571 NTAPI
572 NtOpenTimer(
573  _Out_ PHANDLE TimerHandle,
574  _In_ ACCESS_MASK DesiredAccess,
575  _In_ POBJECT_ATTRIBUTES ObjectAttributes
576  );
577 
578 NTSYSCALLAPI
579 NTSTATUS
580 NTAPI
581 NtSetTimer(
582  _In_ HANDLE TimerHandle,
583  _In_ PLARGE_INTEGER DueTime,
584  _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine,
585  _In_opt_ PVOID TimerContext,
586  _In_ BOOLEAN ResumeTimer,
587  _In_opt_ LONG Period,
588  _Out_opt_ PBOOLEAN PreviousState
589  );
590 
591 #if (PHNT_VERSION >= PHNT_WIN7)
592 NTSYSCALLAPI
593 NTSTATUS
594 NTAPI
595 NtSetTimerEx(
596  _In_ HANDLE TimerHandle,
597  _In_ TIMER_SET_INFORMATION_CLASS TimerSetInformationClass,
598  _Inout_updates_bytes_opt_(TimerSetInformationLength) PVOID TimerSetInformation,
599  _In_ ULONG TimerSetInformationLength
600  );
601 #endif
602 
603 NTSYSCALLAPI
604 NTSTATUS
605 NTAPI
606 NtCancelTimer(
607  _In_ HANDLE TimerHandle,
608  _Out_opt_ PBOOLEAN CurrentState
609  );
610 
611 NTSYSCALLAPI
612 NTSTATUS
613 NTAPI
614 NtQueryTimer(
615  _In_ HANDLE TimerHandle,
616  _In_ TIMER_INFORMATION_CLASS TimerInformationClass,
617  _Out_writes_bytes_(TimerInformationLength) PVOID TimerInformation,
618  _In_ ULONG TimerInformationLength,
619  _Out_opt_ PULONG ReturnLength
620  );
621 
622 #if (PHNT_VERSION >= PHNT_WIN8)
623 
624 NTSYSCALLAPI
625 NTSTATUS
626 NTAPI
627 NtCreateIRTimer(
628  _Out_ PHANDLE TimerHandle,
629  _In_ ACCESS_MASK DesiredAccess
630  );
631 
632 NTSYSCALLAPI
633 NTSTATUS
634 NTAPI
635 NtSetIRTimer(
636  _In_ HANDLE TimerHandle,
637  _In_opt_ PLARGE_INTEGER DueTime
638  );
639 
640 #endif
641 
642 typedef struct _T2_SET_PARAMETERS_V0
643 {
644  ULONG Version;
645  ULONG Reserved;
646  LONGLONG NoWakeTolerance;
647 } T2_SET_PARAMETERS, *PT2_SET_PARAMETERS;
648 
649 typedef PVOID PT2_CANCEL_PARAMETERS;
650 
651 #if (PHNT_VERSION >= PHNT_THRESHOLD)
652 
653 NTSYSCALLAPI
654 NTSTATUS
655 NTAPI
656 NtCreateTimer2(
657  _Out_ PHANDLE TimerHandle,
658  _In_opt_ PVOID Reserved1,
659  _In_opt_ PVOID Reserved2,
660  _In_ ULONG Attributes,
661  _In_ ACCESS_MASK DesiredAccess
662  );
663 
664 NTSYSCALLAPI
665 NTSTATUS
666 NTAPI
667 NtSetTimer2(
668  _In_ HANDLE TimerHandle,
669  _In_ PLARGE_INTEGER DueTime,
670  _In_opt_ PLARGE_INTEGER Period,
671  _In_ PT2_SET_PARAMETERS Parameters
672  );
673 
674 NTSYSCALLAPI
675 NTSTATUS
676 NTAPI
677 NtCancelTimer2(
678  _In_ HANDLE TimerHandle,
679  _In_ PT2_CANCEL_PARAMETERS Parameters
680  );
681 
682 #endif
683 
684 // Profile
685 
686 #define PROFILE_CONTROL 0x0001
687 #define PROFILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | PROFILE_CONTROL)
688 
689 NTSYSCALLAPI
690 NTSTATUS
691 NTAPI
692 NtCreateProfile(
693  _Out_ PHANDLE ProfileHandle,
694  _In_opt_ HANDLE Process,
695  _In_ PVOID ProfileBase,
696  _In_ SIZE_T ProfileSize,
697  _In_ ULONG BucketSize,
698  _In_reads_bytes_(BufferSize) PULONG Buffer,
699  _In_ ULONG BufferSize,
700  _In_ KPROFILE_SOURCE ProfileSource,
701  _In_ KAFFINITY Affinity
702  );
703 
704 #if (PHNT_VERSION >= PHNT_WIN7)
705 NTSYSCALLAPI
706 NTSTATUS
707 NTAPI
708 NtCreateProfileEx(
709  _Out_ PHANDLE ProfileHandle,
710  _In_opt_ HANDLE Process,
711  _In_ PVOID ProfileBase,
712  _In_ SIZE_T ProfileSize,
713  _In_ ULONG BucketSize,
714  _In_reads_bytes_(BufferSize) PULONG Buffer,
715  _In_ ULONG BufferSize,
716  _In_ KPROFILE_SOURCE ProfileSource,
717  _In_ USHORT GroupCount,
718  _In_reads_(GroupCount) PGROUP_AFFINITY GroupAffinity
719  );
720 #endif
721 
722 NTSYSCALLAPI
723 NTSTATUS
724 NTAPI
725 NtStartProfile(
726  _In_ HANDLE ProfileHandle
727  );
728 
729 NTSYSCALLAPI
730 NTSTATUS
731 NTAPI
732 NtStopProfile(
733  _In_ HANDLE ProfileHandle
734  );
735 
736 NTSYSCALLAPI
737 NTSTATUS
738 NTAPI
739 NtQueryIntervalProfile(
740  _In_ KPROFILE_SOURCE ProfileSource,
741  _Out_ PULONG Interval
742  );
743 
744 NTSYSCALLAPI
745 NTSTATUS
746 NTAPI
747 NtSetIntervalProfile(
748  _In_ ULONG Interval,
749  _In_ KPROFILE_SOURCE Source
750  );
751 
752 // Keyed Event
753 
754 #define KEYEDEVENT_WAIT 0x0001
755 #define KEYEDEVENT_WAKE 0x0002
756 #define KEYEDEVENT_ALL_ACCESS \
757  (STANDARD_RIGHTS_REQUIRED | KEYEDEVENT_WAIT | KEYEDEVENT_WAKE)
758 
759 NTSYSCALLAPI
760 NTSTATUS
761 NTAPI
762 NtCreateKeyedEvent(
763  _Out_ PHANDLE KeyedEventHandle,
764  _In_ ACCESS_MASK DesiredAccess,
765  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
766  _In_ ULONG Flags
767  );
768 
769 NTSYSCALLAPI
770 NTSTATUS
771 NTAPI
772 NtOpenKeyedEvent(
773  _Out_ PHANDLE KeyedEventHandle,
774  _In_ ACCESS_MASK DesiredAccess,
775  _In_ POBJECT_ATTRIBUTES ObjectAttributes
776  );
777 
778 NTSYSCALLAPI
779 NTSTATUS
780 NTAPI
781 NtReleaseKeyedEvent(
782  _In_ HANDLE KeyedEventHandle,
783  _In_ PVOID KeyValue,
784  _In_ BOOLEAN Alertable,
785  _In_opt_ PLARGE_INTEGER Timeout
786  );
787 
788 NTSYSCALLAPI
789 NTSTATUS
790 NTAPI
791 NtWaitForKeyedEvent(
792  _In_ HANDLE KeyedEventHandle,
793  _In_ PVOID KeyValue,
794  _In_ BOOLEAN Alertable,
795  _In_opt_ PLARGE_INTEGER Timeout
796  );
797 
798 // UMS
799 
800 #if (PHNT_VERSION >= PHNT_WIN7)
801 NTSYSCALLAPI
802 NTSTATUS
803 NTAPI
804 NtUmsThreadYield(
805  _In_ PVOID SchedulerParam
806  );
807 #endif
808 
809 // WNF
810 
811 // begin_private
812 
813 typedef struct _WNF_STATE_NAME
814 {
815  ULONG Data[2];
816 } WNF_STATE_NAME, *PWNF_STATE_NAME;
817 
818 typedef const WNF_STATE_NAME *PCWNF_STATE_NAME;
819 
820 typedef enum _WNF_STATE_NAME_LIFETIME
821 {
822  WnfWellKnownStateName,
823  WnfPermanentStateName,
824  WnfPersistentStateName,
825  WnfTemporaryStateName
826 } WNF_STATE_NAME_LIFETIME;
827 
828 typedef enum _WNF_STATE_NAME_INFORMATION
829 {
830  WnfInfoStateNameExist,
831  WnfInfoSubscribersPresent,
832  WnfInfoIsQuiescent
833 } WNF_STATE_NAME_INFORMATION;
834 
835 typedef enum _WNF_DATA_SCOPE
836 {
837  WnfDataScopeSystem,
838  WnfDataScopeSession,
839  WnfDataScopeUser,
840  WnfDataScopeProcess
841 } WNF_DATA_SCOPE;
842 
843 typedef struct _WNF_TYPE_ID
844 {
845  GUID TypeId;
846 } WNF_TYPE_ID, *PWNF_TYPE_ID;
847 
848 typedef const WNF_TYPE_ID *PCWNF_TYPE_ID;
849 
850 // rev
851 typedef ULONG WNF_CHANGE_STAMP, *PWNF_CHANGE_STAMP;
852 
853 typedef struct _WNF_DELIVERY_DESCRIPTOR
854 {
855  ULONGLONG SubscriptionId;
856  WNF_STATE_NAME StateName;
857  WNF_CHANGE_STAMP ChangeStamp;
858  ULONG StateDataSize;
859  ULONG EventMask;
860  WNF_TYPE_ID TypeId;
861  ULONG StateDataOffset;
862 } WNF_DELIVERY_DESCRIPTOR, *PWNF_DELIVERY_DESCRIPTOR;
863 
864 // end_private
865 
866 #if (PHNT_VERSION >= PHNT_WIN8)
867 
868 NTSYSCALLAPI
869 NTSTATUS
870 NTAPI
871 NtCreateWnfStateName(
872  _Out_ PWNF_STATE_NAME StateName,
873  _In_ WNF_STATE_NAME_LIFETIME NameLifetime,
874  _In_ WNF_DATA_SCOPE DataScope,
875  _In_ BOOLEAN PersistData,
876  _In_opt_ PCWNF_TYPE_ID TypeId,
877  _In_ ULONG MaximumStateSize,
878  _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
879  );
880 
881 NTSYSCALLAPI
882 NTSTATUS
883 NTAPI
884 NtDeleteWnfStateName(
885  _In_ PCWNF_STATE_NAME StateName
886  );
887 
888 NTSYSCALLAPI
889 NTSTATUS
890 NTAPI
891 NtUpdateWnfStateData(
892  _In_ PCWNF_STATE_NAME StateName,
893  _In_reads_bytes_opt_(Length) const VOID* Buffer,
894  _In_opt_ ULONG Length,
895  _In_opt_ PCWNF_TYPE_ID TypeId,
896  _In_opt_ const PVOID ExplicitScope,
897  _In_ WNF_CHANGE_STAMP MatchingChangeStamp,
898  _In_ LOGICAL CheckStamp
899  );
900 
901 NTSYSCALLAPI
902 NTSTATUS
903 NTAPI
904 NtDeleteWnfStateData(
905  _In_ PCWNF_STATE_NAME StateName,
906  _In_opt_ const PVOID ExplicitScope
907  );
908 
909 NTSYSCALLAPI
910 NTSTATUS
911 NTAPI
912 NtQueryWnfStateData(
913  _In_ PCWNF_STATE_NAME StateName,
914  _In_opt_ PCWNF_TYPE_ID TypeId,
915  _In_opt_ const VOID* ExplicitScope,
916  _Out_ PWNF_CHANGE_STAMP ChangeStamp,
917  _Out_writes_bytes_to_opt_(*BufferSize, *BufferSize) PVOID Buffer,
918  _Inout_ PULONG BufferSize
919  );
920 
921 NTSYSCALLAPI
922 NTSTATUS
923 NTAPI
924 NtQueryWnfStateNameInformation(
925  _In_ PCWNF_STATE_NAME StateName,
926  _In_ WNF_STATE_NAME_INFORMATION NameInfoClass,
927  _In_opt_ const PVOID ExplicitScope,
928  _Out_writes_bytes_(InfoBufferSize) PVOID InfoBuffer,
929  _In_ ULONG InfoBufferSize
930  );
931 
932 NTSYSCALLAPI
933 NTSTATUS
934 NTAPI
935 NtSubscribeWnfStateChange(
936  _In_ PCWNF_STATE_NAME StateName,
937  _In_opt_ WNF_CHANGE_STAMP ChangeStamp,
938  _In_ ULONG EventMask,
939  _Out_opt_ PULONG64 SubscriptionId
940  );
941 
942 NTSYSCALLAPI
943 NTSTATUS
944 NTAPI
945 NtUnsubscribeWnfStateChange(
946  _In_ PCWNF_STATE_NAME StateName
947  );
948 
949 #if (PHNT_VERSION >= PHNT_THRESHOLD)
950 
951 NTSYSCALLAPI
952 NTSTATUS
953 NTAPI
954 NtGetCompleteWnfStateSubscription(
955  _In_opt_ PWNF_STATE_NAME OldDescriptorStateName,
956  _In_opt_ ULONG64 *OldSubscriptionId,
957  _In_opt_ ULONG OldDescriptorEventMask,
958  _In_opt_ ULONG OldDescriptorStatus,
959  _Out_writes_bytes_(DescriptorSize) PWNF_DELIVERY_DESCRIPTOR NewDeliveryDescriptor,
960  _In_ ULONG DescriptorSize
961  );
962 
963 NTSYSCALLAPI
964 NTSTATUS
965 NTAPI
966 NtSetWnfProcessNotificationEvent(
967  _In_ HANDLE NotificationEvent
968  );
969 
970 #endif
971 
972 #endif
973 
974 // Worker factory
975 
976 // begin_rev
977 
978 #define WORKER_FACTORY_RELEASE_WORKER 0x0001
979 #define WORKER_FACTORY_WAIT 0x0002
980 #define WORKER_FACTORY_SET_INFORMATION 0x0004
981 #define WORKER_FACTORY_QUERY_INFORMATION 0x0008
982 #define WORKER_FACTORY_READY_WORKER 0x0010
983 #define WORKER_FACTORY_SHUTDOWN 0x0020
984 
985 #define WORKER_FACTORY_ALL_ACCESS ( \
986  STANDARD_RIGHTS_REQUIRED | \
987  WORKER_FACTORY_RELEASE_WORKER | \
988  WORKER_FACTORY_WAIT | \
989  WORKER_FACTORY_SET_INFORMATION | \
990  WORKER_FACTORY_QUERY_INFORMATION | \
991  WORKER_FACTORY_READY_WORKER | \
992  WORKER_FACTORY_SHUTDOWN \
993  )
994 
995 // end_rev
996 
997 // begin_private
998 
999 typedef enum _WORKERFACTORYINFOCLASS
1000 {
1001  WorkerFactoryTimeout,
1002  WorkerFactoryRetryTimeout,
1003  WorkerFactoryIdleTimeout,
1004  WorkerFactoryBindingCount,
1005  WorkerFactoryThreadMinimum,
1006  WorkerFactoryThreadMaximum,
1007  WorkerFactoryPaused,
1008  WorkerFactoryBasicInformation,
1009  WorkerFactoryAdjustThreadGoal,
1010  WorkerFactoryCallbackType,
1011  WorkerFactoryStackInformation, // 10
1012  WorkerFactoryThreadBasePriority,
1013  WorkerFactoryTimeoutWaiters, // since THRESHOLD
1014  WorkerFactoryFlags,
1015  WorkerFactoryThreadSoftMaximum,
1016  MaxWorkerFactoryInfoClass
1017 } WORKERFACTORYINFOCLASS, *PWORKERFACTORYINFOCLASS;
1018 
1019 typedef struct _WORKER_FACTORY_BASIC_INFORMATION
1020 {
1021  LARGE_INTEGER Timeout;
1022  LARGE_INTEGER RetryTimeout;
1023  LARGE_INTEGER IdleTimeout;
1024  BOOLEAN Paused;
1025  BOOLEAN TimerSet;
1026  BOOLEAN QueuedToExWorker;
1027  BOOLEAN MayCreate;
1028  BOOLEAN CreateInProgress;
1029  BOOLEAN InsertedIntoQueue;
1030  BOOLEAN Shutdown;
1031  ULONG BindingCount;
1032  ULONG ThreadMinimum;
1033  ULONG ThreadMaximum;
1034  ULONG PendingWorkerCount;
1035  ULONG WaitingWorkerCount;
1036  ULONG TotalWorkerCount;
1037  ULONG ReleaseCount;
1038  LONGLONG InfiniteWaitGoal;
1039  PVOID StartRoutine;
1040  PVOID StartParameter;
1041  HANDLE ProcessId;
1042  SIZE_T StackReserve;
1043  SIZE_T StackCommit;
1044  NTSTATUS LastThreadCreationStatus;
1045 } WORKER_FACTORY_BASIC_INFORMATION, *PWORKER_FACTORY_BASIC_INFORMATION;
1046 
1047 // end_private
1048 
1049 #if (PHNT_VERSION >= PHNT_VISTA)
1050 
1051 NTSYSCALLAPI
1052 NTSTATUS
1053 NTAPI
1054 NtCreateWorkerFactory(
1055  _Out_ PHANDLE WorkerFactoryHandleReturn,
1056  _In_ ACCESS_MASK DesiredAccess,
1057  _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
1058  _In_ HANDLE CompletionPortHandle,
1059  _In_ HANDLE WorkerProcessHandle,
1060  _In_ PVOID StartRoutine,
1061  _In_opt_ PVOID StartParameter,
1062  _In_opt_ ULONG MaxThreadCount,
1063  _In_opt_ SIZE_T StackReserve,
1064  _In_opt_ SIZE_T StackCommit
1065  );
1066 
1067 NTSYSCALLAPI
1068 NTSTATUS
1069 NTAPI
1070 NtQueryInformationWorkerFactory(
1071  _In_ HANDLE WorkerFactoryHandle,
1072  _In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass,
1073  _Out_writes_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation,
1074  _In_ ULONG WorkerFactoryInformationLength,
1075  _Out_opt_ PULONG ReturnLength
1076  );
1077 
1078 NTSYSCALLAPI
1079 NTSTATUS
1080 NTAPI
1081 NtSetInformationWorkerFactory(
1082  _In_ HANDLE WorkerFactoryHandle,
1083  _In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass,
1084  _In_reads_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation,
1085  _In_ ULONG WorkerFactoryInformationLength
1086  );
1087 
1088 NTSYSCALLAPI
1089 NTSTATUS
1090 NTAPI
1091 NtShutdownWorkerFactory(
1092  _In_ HANDLE WorkerFactoryHandle,
1093  _Inout_ volatile LONG *PendingWorkerCount
1094  );
1095 
1096 NTSYSCALLAPI
1097 NTSTATUS
1098 NTAPI
1099 NtReleaseWorkerFactoryWorker(
1100  _In_ HANDLE WorkerFactoryHandle
1101  );
1102 
1103 NTSYSCALLAPI
1104 NTSTATUS
1105 NTAPI
1106 NtWorkerFactoryWorkerReady(
1107  _In_ HANDLE WorkerFactoryHandle
1108  );
1109 
1111 
1112 NTSYSCALLAPI
1113 NTSTATUS
1114 NTAPI
1115 NtWaitForWorkViaWorkerFactory(
1116  _In_ HANDLE WorkerFactoryHandle,
1117  _Out_ struct _FILE_IO_COMPLETION_INFORMATION *MiniPacket
1118  );
1119 
1120 #endif
1121 
1122 // Time
1123 
1124 NTSYSCALLAPI
1125 NTSTATUS
1126 NTAPI
1127 NtQuerySystemTime(
1128  _Out_ PLARGE_INTEGER SystemTime
1129  );
1130 
1131 NTSYSCALLAPI
1132 NTSTATUS
1133 NTAPI
1134 NtSetSystemTime(
1135  _In_opt_ PLARGE_INTEGER SystemTime,
1136  _Out_opt_ PLARGE_INTEGER PreviousTime
1137  );
1138 
1139 NTSYSCALLAPI
1140 NTSTATUS
1141 NTAPI
1142 NtQueryTimerResolution(
1143  _Out_ PULONG MaximumTime,
1144  _Out_ PULONG MinimumTime,
1145  _Out_ PULONG CurrentTime
1146  );
1147 
1148 NTSYSCALLAPI
1149 NTSTATUS
1150 NTAPI
1151 NtSetTimerResolution(
1152  _In_ ULONG DesiredTime,
1153  _In_ BOOLEAN SetResolution,
1154  _Out_ PULONG ActualTime
1155  );
1156 
1157 // Performance Counter
1158 
1159 NTSYSCALLAPI
1160 NTSTATUS
1161 NTAPI
1162 NtQueryPerformanceCounter(
1163  _Out_ PLARGE_INTEGER PerformanceCounter,
1164  _Out_opt_ PLARGE_INTEGER PerformanceFrequency
1165  );
1166 
1167 // LUIDs
1168 
1169 NTSYSCALLAPI
1170 NTSTATUS
1171 NTAPI
1172 NtAllocateLocallyUniqueId(
1173  _Out_ PLUID Luid
1174  );
1175 
1176 // UUIDs
1177 
1178 NTSYSCALLAPI
1179 NTSTATUS
1180 NTAPI
1181 NtSetUuidSeed(
1182  _In_ PCHAR Seed
1183  );
1184 
1185 NTSYSCALLAPI
1186 NTSTATUS
1187 NTAPI
1188 NtAllocateUuids(
1189  _Out_ PULARGE_INTEGER Time,
1190  _Out_ PULONG Range,
1191  _Out_ PULONG Sequence,
1192  _Out_ PCHAR Seed
1193  );
1194 
1195 // System Information
1196 
1197 #endif // (PHNT_MODE != PHNT_MODE_KERNEL)
1198 
1199 // rev
1200 // private
1201 // source:http://www.microsoft.com/whdc/system/Sysinternals/MoreThan64proc.mspx
1203 {
1204  SystemBasicInformation, // q: SYSTEM_BASIC_INFORMATION
1205  SystemProcessorInformation, // q: SYSTEM_PROCESSOR_INFORMATION
1206  SystemPerformanceInformation, // q: SYSTEM_PERFORMANCE_INFORMATION
1207  SystemTimeOfDayInformation, // q: SYSTEM_TIMEOFDAY_INFORMATION
1208  SystemPathInformation, // not implemented
1209  SystemProcessInformation, // q: SYSTEM_PROCESS_INFORMATION
1210  SystemCallCountInformation, // q: SYSTEM_CALL_COUNT_INFORMATION
1211  SystemDeviceInformation, // q: SYSTEM_DEVICE_INFORMATION
1212  SystemProcessorPerformanceInformation, // q: SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
1213  SystemFlagsInformation, // q: SYSTEM_FLAGS_INFORMATION
1214  SystemCallTimeInformation, // 10, not implemented
1215  SystemModuleInformation, // q: RTL_PROCESS_MODULES
1218  SystemPagedPoolInformation, // not implemented
1219  SystemNonPagedPoolInformation, // not implemented
1220  SystemHandleInformation, // q: SYSTEM_HANDLE_INFORMATION
1221  SystemObjectInformation, // q: SYSTEM_OBJECTTYPE_INFORMATION mixed with SYSTEM_OBJECT_INFORMATION
1222  SystemPageFileInformation, // q: SYSTEM_PAGEFILE_INFORMATION
1224  SystemVdmBopInformation, // 20, not implemented
1225  SystemFileCacheInformation, // q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (info for WorkingSetTypeSystemCache)
1226  SystemPoolTagInformation, // q: SYSTEM_POOLTAG_INFORMATION
1227  SystemInterruptInformation, // q: SYSTEM_INTERRUPT_INFORMATION
1228  SystemDpcBehaviorInformation, // q: SYSTEM_DPC_BEHAVIOR_INFORMATION; s: SYSTEM_DPC_BEHAVIOR_INFORMATION (requires SeLoadDriverPrivilege)
1229  SystemFullMemoryInformation, // not implemented
1230  SystemLoadGdiDriverInformation, // s (kernel-mode only)
1231  SystemUnloadGdiDriverInformation, // s (kernel-mode only)
1232  SystemTimeAdjustmentInformation, // q: SYSTEM_QUERY_TIME_ADJUST_INFORMATION; s: SYSTEM_SET_TIME_ADJUST_INFORMATION (requires SeSystemtimePrivilege)
1234  SystemMirrorMemoryInformation, // 30, s (requires license value "Kernel-MemoryMirroringSupported") (requires SeShutdownPrivilege)
1236  SystemObsolete0, // not implemented
1237  SystemExceptionInformation, // q: SYSTEM_EXCEPTION_INFORMATION
1238  SystemCrashDumpStateInformation, // s (requires SeDebugPrivilege)
1239  SystemKernelDebuggerInformation, // q: SYSTEM_KERNEL_DEBUGGER_INFORMATION
1240  SystemContextSwitchInformation, // q: SYSTEM_CONTEXT_SWITCH_INFORMATION
1241  SystemRegistryQuotaInformation, // q: SYSTEM_REGISTRY_QUOTA_INFORMATION; s (requires SeIncreaseQuotaPrivilege)
1242  SystemExtendServiceTableInformation, // s (requires SeLoadDriverPrivilege) // loads win32k only
1243  SystemPrioritySeperation, // s (requires SeTcbPrivilege)
1244  SystemVerifierAddDriverInformation, // 40, s (requires SeDebugPrivilege)
1245  SystemVerifierRemoveDriverInformation, // s (requires SeDebugPrivilege)
1246  SystemProcessorIdleInformation, // q: SYSTEM_PROCESSOR_IDLE_INFORMATION
1247  SystemLegacyDriverInformation, // q: SYSTEM_LEGACY_DRIVER_INFORMATION
1249  SystemLookasideInformation, // q: SYSTEM_LOOKASIDE_INFORMATION
1250  SystemTimeSlipNotification, // s (requires SeSystemtimePrivilege)
1251  SystemSessionCreate, // not implemented
1252  SystemSessionDetach, // not implemented
1253  SystemSessionInformation, // not implemented
1255  SystemVerifierInformation, // q: SYSTEM_VERIFIER_INFORMATION; s (requires SeDebugPrivilege)
1256  SystemVerifierThunkExtend, // s (kernel-mode only)
1257  SystemSessionProcessInformation, // q: SYSTEM_SESSION_PROCESS_INFORMATION
1258  SystemLoadGdiDriverInSystemSpace, // s (kernel-mode only) (same as SystemLoadGdiDriverInformation)
1260  SystemPrefetcherInformation, // q: PREFETCHER_INFORMATION; s: PREFETCHER_INFORMATION // PfSnQueryPrefetcherInformation
1261  SystemExtendedProcessInformation, // q: SYSTEM_PROCESS_INFORMATION
1265  SystemProcessorPowerInformation, // q: SYSTEM_PROCESSOR_POWER_INFORMATION
1268  SystemExtendedHandleInformation, // q: SYSTEM_HANDLE_INFORMATION_EX
1270  SystemBigPoolInformation, // q: SYSTEM_BIGPOOL_INFORMATION
1271  SystemSessionPoolTagInformation, // q: SYSTEM_SESSION_POOLTAG_INFORMATION
1272  SystemSessionMappedViewInformation, // q: SYSTEM_SESSION_MAPPED_VIEW_INFORMATION
1275  SystemWatchdogTimerHandler, // s (kernel-mode only)
1276  SystemWatchdogTimerInformation, // q (kernel-mode only); s (kernel-mode only)
1277  SystemLogicalProcessorInformation, // q: SYSTEM_LOGICAL_PROCESSOR_INFORMATION
1281  SystemModuleInformationEx, // q: RTL_PROCESS_MODULE_INFORMATION_EX
1283  SystemSuperfetchInformation, // q: SUPERFETCH_INFORMATION; s: SUPERFETCH_INFORMATION // PfQuerySuperfetchInformation
1284  SystemMemoryListInformation, // 80, q: SYSTEM_MEMORY_LIST_INFORMATION; s: SYSTEM_MEMORY_LIST_COMMAND (requires SeProfileSingleProcessPrivilege)
1285  SystemFileCacheInformationEx, // q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (same as SystemFileCacheInformation)
1286  SystemThreadPriorityClientIdInformation, // s: SYSTEM_THREAD_CID_PRIORITY_INFORMATION (requires SeIncreaseBasePriorityPrivilege)
1287  SystemProcessorIdleCycleTimeInformation, // q: SYSTEM_PROCESSOR_IDLE_CYCLE_TIME_INFORMATION[]
1288  SystemVerifierCancellationInformation, // not implemented // name:wow64:whNT32QuerySystemVerifierCancellationInformation
1290  SystemRefTraceInformation, // q; s // ObQueryRefTraceInformation
1291  SystemSpecialPoolInformation, // q; s (requires SeDebugPrivilege) // MmSpecialPoolTag, then MmSpecialPoolCatchOverruns != 0
1292  SystemProcessIdInformation, // q: SYSTEM_PROCESS_ID_INFORMATION
1293  SystemErrorPortInformation, // s (requires SeTcbPrivilege)
1294  SystemBootEnvironmentInformation, // 90, q: SYSTEM_BOOT_ENVIRONMENT_INFORMATION
1295  SystemHypervisorInformation, // q; s (kernel-mode only)
1297  SystemTimeZoneInformation, // s (requires SeTimeZonePrivilege)
1298  SystemImageFileExecutionOptionsInformation, // s: SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION (requires SeTcbPrivilege)
1299  SystemCoverageInformation, // q; s // name:wow64:whNT32QuerySystemCoverageInformation; ExpCovQueryInformation
1301  SystemVerifierFaultsInformation, // s (requires SeDebugPrivilege)
1302  SystemSystemPartitionInformation, // q: SYSTEM_SYSTEM_PARTITION_INFORMATION
1303  SystemSystemDiskInformation, // q: SYSTEM_SYSTEM_DISK_INFORMATION
1304  SystemProcessorPerformanceDistribution, // 100, q: SYSTEM_PROCESSOR_PERFORMANCE_DISTRIBUTION
1306  SystemDynamicTimeZoneInformation, // q; s (requires SeTimeZonePrivilege)
1307  SystemCodeIntegrityInformation, // q // SeCodeIntegrityQueryInformation
1309  SystemProcessorBrandString, // q // HaliQuerySystemInformation -> HalpGetProcessorBrandString, info class 23
1310  SystemVirtualAddressInformation, // q: SYSTEM_VA_LIST_INFORMATION[]; s: SYSTEM_VA_LIST_INFORMATION[] (requires SeIncreaseQuotaPrivilege) // MmQuerySystemVaInformation
1311  SystemLogicalProcessorAndGroupInformation, // q: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX // since WIN7 // KeQueryLogicalProcessorRelationship
1312  SystemProcessorCycleTimeInformation, // q: SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION[]
1313  SystemStoreInformation, // q; s // SmQueryStoreInformation
1314  SystemRegistryAppendString, // 110, s: SYSTEM_REGISTRY_APPEND_STRING_PARAMETERS
1315  SystemAitSamplingValue, // s: ULONG (requires SeProfileSingleProcessPrivilege)
1316  SystemVhdBootInformation, // q: SYSTEM_VHD_BOOT_INFORMATION
1317  SystemCpuQuotaInformation, // q; s // PsQueryCpuQuotaInformation
1318  SystemNativeBasicInformation, // not implemented
1319  SystemSpare1, // not implemented
1320  SystemLowPriorityIoInformation, // q: SYSTEM_LOW_PRIORITY_IO_INFORMATION
1321  SystemTpmBootEntropyInformation, // q: TPM_BOOT_ENTROPY_NT_RESULT // ExQueryTpmBootEntropyInformation
1322  SystemVerifierCountersInformation, // q: SYSTEM_VERIFIER_COUNTERS_INFORMATION
1323  SystemPagedPoolInformationEx, // q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (info for WorkingSetTypePagedPool)
1324  SystemSystemPtesInformationEx, // 120, q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (info for WorkingSetTypeSystemPtes)
1326  SystemAcpiAuditInformation, // q: SYSTEM_ACPI_AUDIT_INFORMATION // HaliQuerySystemInformation -> HalpAuditQueryResults, info class 26
1327  SystemBasicPerformanceInformation, // q: SYSTEM_BASIC_PERFORMANCE_INFORMATION // name:wow64:whNtQuerySystemInformation_SystemBasicPerformanceInformation
1328  SystemQueryPerformanceCounterInformation, // q: SYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION // since WIN7 SP1
1345  SystemProcessorPerformanceInformationEx, // q: SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION_EX // since WINBLUE
1348  SystemPageFileInformationEx, // q: SYSTEM_PAGEFILE_INFORMATION_EX
1352  SystemFullProcessInformation, // q: SYSTEM_PROCESS_INFORMATION with SYSTEM_PROCESS_INFORMATION_EXTENSION (requires admin)
1353  SystemKernelDebuggerInformationEx, // q: SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX
1358  SystemProcessorFeaturesInformation, // q: SYSTEM_PROCESSOR_FEATURES_INFORMATION
1361  SystemManufacturingInformation, // q: SYSTEM_MANUFACTURING_INFORMATION // since THRESHOLD
1362  SystemEnergyEstimationConfigInformation, // q: SYSTEM_ENERGY_ESTIMATION_CONFIG_INFORMATION
1363  SystemHypervisorDetailInformation, // q: SYSTEM_HYPERVISOR_DETAIL_INFORMATION
1364  SystemProcessorCycleStatsInformation, // q: SYSTEM_PROCESSOR_CYCLE_STATS_INFORMATION // 160
1366  SystemTrustedPlatformModuleInformation, // q: SYSTEM_TPM_INFORMATION
1371  SystemSingleModuleInformation, // q: SYSTEM_SINGLE_MODULE_INFORMATION
1378  SystemRootSiloInformation, // q: SYSTEM_ROOT_SILO_INFORMATION
1381 
1383 {
1384  ULONG Reserved;
1386  ULONG PageSize;
1396 
1398 {
1402  USHORT Reserved;
1405 
1407 {
1408  LARGE_INTEGER IdleProcessTime;
1409  LARGE_INTEGER IoReadTransferCount;
1410  LARGE_INTEGER IoWriteTransferCount;
1411  LARGE_INTEGER IoOtherTransferCount;
1483 
1485 {
1486  LARGE_INTEGER BootTime;
1487  LARGE_INTEGER CurrentTime;
1488  LARGE_INTEGER TimeZoneBias;
1489  ULONG TimeZoneId;
1490  ULONG Reserved;
1491  ULONGLONG BootTimeBias;
1492  ULONGLONG SleepTimeBias;
1494 
1496 {
1497  LARGE_INTEGER KernelTime;
1498  LARGE_INTEGER UserTime;
1499  LARGE_INTEGER CreateTime;
1500  ULONG WaitTime;
1507  KWAIT_REASON WaitReason;
1509 
1510 typedef struct _TEB *PTEB;
1511 
1512 // private
1514 {
1516  PVOID StackBase;
1517  PVOID StackLimit;
1519  PTEB TebBase; // since VISTA
1520  ULONG_PTR Reserved2;
1521  ULONG_PTR Reserved3;
1522  ULONG_PTR Reserved4;
1524 
1526 {
1529  LARGE_INTEGER WorkingSetPrivateSize; // since VISTA
1530  ULONG HardFaultCount; // since WIN7
1531  ULONG NumberOfThreadsHighWatermark; // since WIN7
1532  ULONGLONG CycleTime; // since WIN7
1533  LARGE_INTEGER CreateTime;
1534  LARGE_INTEGER UserTime;
1535  LARGE_INTEGER KernelTime;
1541  ULONG SessionId;
1542  ULONG_PTR UniqueProcessKey; // since VISTA (requires SystemExtendedProcessInformation)
1544  SIZE_T VirtualSize;
1555  LARGE_INTEGER ReadOperationCount;
1556  LARGE_INTEGER WriteOperationCount;
1557  LARGE_INTEGER OtherOperationCount;
1558  LARGE_INTEGER ReadTransferCount;
1559  LARGE_INTEGER WriteTransferCount;
1560  LARGE_INTEGER OtherTransferCount;
1563 
1565 {
1566  ULONG Length;
1569 
1571 {
1579 
1581 {
1582  LARGE_INTEGER IdleTime;
1583  LARGE_INTEGER KernelTime;
1584  LARGE_INTEGER UserTime;
1585  LARGE_INTEGER DpcTime;
1586  LARGE_INTEGER InterruptTime;
1589 
1591 {
1592  ULONG Flags; // NtGlobalFlag
1594 
1596 {
1601  USHORT HandleValue;
1602  PVOID Object;
1605 
1607 {
1611 
1613 {
1617  ULONG TypeIndex;
1619  GENERIC_MAPPING GenericMapping;
1621  ULONG PoolType;
1626 
1628 {
1630  PVOID Object;
1633  USHORT Flags;
1642 
1644 {
1646  ULONG TotalSize;
1647  ULONG TotalInUse;
1648  ULONG PeakUsage;
1651 
1652 #define MM_WORKING_SET_MAX_HARD_ENABLE 0x1
1653 #define MM_WORKING_SET_MAX_HARD_DISABLE 0x2
1654 #define MM_WORKING_SET_MIN_HARD_ENABLE 0x4
1655 #define MM_WORKING_SET_MIN_HARD_DISABLE 0x8
1656 
1658 {
1659  SIZE_T CurrentSize;
1660  SIZE_T PeakSize;
1667  ULONG Flags;
1669 
1670 // Can be used instead of SYSTEM_FILECACHE_INFORMATION
1672 {
1673  SIZE_T CurrentSize;
1674  SIZE_T PeakSize;
1677 
1678 typedef struct _SYSTEM_POOLTAG
1679 {
1680  union
1681  {
1682  UCHAR Tag[4];
1683  ULONG TagUlong;
1684  };
1686  ULONG PagedFrees;
1687  SIZE_T PagedUsed;
1692 
1694 {
1695  ULONG Count;
1698 
1700 {
1702  ULONG DpcCount;
1703  ULONG DpcRate;
1708 
1710 {
1711  ULONG Spare;
1717 
1719 {
1722  BOOLEAN Enable;
1724 
1726 {
1728  BOOLEAN Enable;
1730 
1732 {
1738 
1740 {
1744 
1746 {
1748  ULONG FindAny;
1749  ULONG FindLast;
1750  ULONG FindIdeal;
1751  ULONG IdleAny;
1753  ULONG IdleLast;
1754  ULONG IdleIdeal;
1755  ULONG PreemptAny;
1760 
1762 {
1767 
1769 {
1770  ULONGLONG IdleTime;
1771  ULONGLONG C1Time;
1772  ULONGLONG C2Time;
1773  ULONGLONG C3Time;
1777  ULONG Padding;
1779 
1781 {
1782  ULONG VetoType;
1785 
1787 {
1792  ULONG TotalFrees;
1793  ULONG FreeMisses;
1794  ULONG Type;
1795  ULONG Tag;
1796  ULONG Size;
1798 
1800 {
1802  ULONG Level;
1804 
1805  ULONG RaiseIrqls;
1809 
1814 
1815  ULONG Trims;
1818  ULONG Loads;
1819 
1820  ULONG Unloads;
1824 
1827 
1833 
1835 {
1836  ULONG SessionId;
1837  ULONG SizeOfBuf;
1838  PVOID Buffer;
1840 
1842 {
1855  ULONG ErrorCount;
1856  ULONG RetryCount;
1863 
1865 {
1866  PVOID Object;
1867  ULONG_PTR UniqueProcessId;
1868  ULONG_PTR HandleValue;
1873  ULONG Reserved;
1875 
1877 {
1878  ULONG_PTR NumberOfHandles;
1879  ULONG_PTR Reserved;
1882 
1884 {
1885  union
1886  {
1888  ULONG_PTR NonPaged : 1;
1889  };
1890  SIZE_T SizeInBytes;
1891  union
1892  {
1893  UCHAR Tag[4];
1894  ULONG TagUlong;
1895  };
1897 
1899 {
1900  ULONG Count;
1903 
1904 typedef struct _SYSTEM_POOL_ENTRY
1905 {
1906  BOOLEAN Allocated;
1907  BOOLEAN Spare0;
1909  ULONG Size;
1910  union
1911  {
1912  UCHAR Tag[4];
1913  ULONG TagUlong;
1915  };
1917 
1919 {
1920  SIZE_T TotalSize;
1921  PVOID FirstEntry;
1924  BOOLEAN Spare0;
1928 
1930 {
1932  ULONG SessionId;
1933  ULONG Count;
1936 
1938 {
1940  ULONG SessionId;
1945 
1946 // private
1948 {
1949  ULONG_PTR ZeroPageCount;
1950  ULONG_PTR FreePageCount;
1953  ULONG_PTR BadPageCount;
1954  ULONG_PTR PageCountByPriority[8];
1958 
1959 // private
1961 {
1970 
1971 // private
1973 {
1977 
1978 // private
1980 {
1981  ULONGLONG CycleTime;
1983 
1984 // private
1986 {
1987  BOOLEAN TraceEnable;
1992 
1993 // private
1995 {
1996  HANDLE ProcessId;
1999 
2000 #if (PHNT_MODE == PHNT_MODE_KERNEL)
2001 typedef enum _FIRMWARE_TYPE
2002 {
2008 #endif
2009 
2010 // private
2012 {
2016 
2017 // private
2019 {
2023 
2024 // private
2026 {
2029 
2030 // private
2032 {
2035 
2036 // private
2038 {
2039  LARGE_INTEGER Hits; // ULONG in WIN8
2042 
2043 // private
2045 {
2047  ULONG StateCount;
2050 
2051 // private
2053 {
2055  ULONG Offsets[1];
2057 
2058 // private
2059 typedef enum _SYSTEM_VA_TYPE
2060 {
2069 
2070 // private
2072 {
2073  SIZE_T VirtualSize;
2074  SIZE_T VirtualPeak;
2078 
2079 // private
2081 {
2082  HANDLE KeyHandle;
2085  PUCHAR Buffer;
2087  ULONG Type;
2093 
2094 // msdn
2096 {
2097  BOOLEAN OsDiskIsVhd;
2099  WCHAR OsVhdParentVolume[ANYSIZE_ARRAY];
2101 
2102 // private
2104 {
2116 
2117 // symbols
2119 {
2126 
2127 // Contents of KeLoaderBlock->Extension->TpmBootEntropyResult (TPM_BOOT_ENTROPY_LDR_RESULT).
2128 // EntropyData is truncated to 40 bytes.
2129 
2130 // private
2132 {
2133  ULONGLONG Policy;
2135  NTSTATUS ResultStatus;
2136  ULONGLONG Time;
2138  UCHAR EntropyData[40];
2140 
2141 // private
2143 {
2145  ULONG RaiseIrqls;
2151  SIZE_T LockedBytes;
2162 
2163 // private
2165 {
2166  ULONG RsdpCount;
2167  ULONG SameRsdt : 1;
2168  ULONG SlicPresent : 1;
2169  ULONG SlicDifferent : 1;
2171 
2172 // private
2174 {
2177  SIZE_T CommitLimit;
2180 
2181 // begin_msdn
2182 
2184 {
2185  union
2186  {
2187  struct
2188  {
2189  ULONG KernelTransition : 1;
2190  ULONG Reserved : 31;
2191  };
2192  ULONG ul;
2193  };
2195 
2197 {
2198  ULONG Version;
2202 
2203 // end_msdn
2204 
2205 // private
2207 {
2208  LARGE_INTEGER IdleTime;
2209  LARGE_INTEGER KernelTime;
2210  LARGE_INTEGER UserTime;
2211  LARGE_INTEGER DpcTime;
2212  LARGE_INTEGER InterruptTime;
2214  ULONG Spare0;
2215  LARGE_INTEGER AvailableTime;
2216  LARGE_INTEGER Spare1;
2217  LARGE_INTEGER Spare2;
2219 
2220 // private
2222 {
2227 
2228 // private
2230 {
2231  ULONGLONG BytesRead;
2232  ULONGLONG BytesWritten;
2237 
2238 // private
2240 {
2241  ULONGLONG Cycles[2][4];
2242  ULONGLONG DiskEnergy;
2244  ULONGLONG MBBTailEnergy;
2245  ULONGLONG NetworkTxRxBytes;
2246  ULONGLONG MBBTxRxBytes;
2247  union
2248  {
2249  struct
2250  {
2251  ULONG Foreground : 1;
2252  };
2254  };
2255  ULONG PixelArea;
2257  ULONGLONG PixelTime;
2259  ULONGLONG ForegroundTime;
2261 
2262 // private
2264 {
2266  ULONGLONG ContextSwitches;
2267  union
2268  {
2269  ULONG Flags;
2270  struct
2271  {
2272  ULONG HasStrongId : 1;
2273  ULONG Spare : 31;
2274  };
2275  };
2277  ULONG PackageFullNameOffset; // since THRESHOLD
2279  ULONG AppIdOffset; // since THRESHOLD
2281 
2282 // private
2284 {
2289 
2290 // private
2292 {
2294  ULONGLONG Reserved[3];
2296 
2297 // private
2299 {
2300  ULONG Options;
2303 
2304 // private
2306 {
2307  BOOLEAN Enabled;
2309 
2310 // private
2311 typedef struct _HV_DETAILS
2312 {
2313  ULONG Data[4];
2315 
2316 // private
2318 {
2327 
2328 // private
2330 {
2331  ULONGLONG Cycles[2][4];
2333 
2334 // private
2336 {
2337  ULONG Flags;
2339 
2340 // private
2342 {
2346 
2347 // private
2349 {
2351  HANDLE SiloIdList[1];
2353 
2354 #if (PHNT_MODE != PHNT_MODE_KERNEL)
2355 
2356 NTSYSCALLAPI
2357 NTSTATUS
2358 NTAPI
2359 NtQuerySystemInformation(
2360  _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
2361  _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
2362  _In_ ULONG SystemInformationLength,
2363  _Out_opt_ PULONG ReturnLength
2364  );
2365 
2366 #if (PHNT_VERSION >= PHNT_WIN7)
2367 NTSYSCALLAPI
2368 NTSTATUS
2369 NTAPI
2370 NtQuerySystemInformationEx(
2371  _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
2372  _In_reads_bytes_(InputBufferLength) PVOID InputBuffer,
2373  _In_ ULONG InputBufferLength,
2374  _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
2375  _In_ ULONG SystemInformationLength,
2376  _Out_opt_ PULONG ReturnLength
2377  );
2378 #endif
2379 
2380 NTSYSCALLAPI
2381 NTSTATUS
2382 NTAPI
2383 NtSetSystemInformation(
2384  _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
2385  _In_reads_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
2386  _In_ ULONG SystemInformationLength
2387  );
2388 
2389 // SysDbg APIs
2390 
2391 // private
2392 typedef enum _SYSDBG_COMMAND
2393 {
2394  SysDbgQueryModuleInformation,
2395  SysDbgQueryTraceInformation,
2396  SysDbgSetTracepoint,
2397  SysDbgSetSpecialCall,
2398  SysDbgClearSpecialCalls,
2399  SysDbgQuerySpecialCalls,
2400  SysDbgBreakPoint,
2401  SysDbgQueryVersion,
2402  SysDbgReadVirtual,
2403  SysDbgWriteVirtual,
2404  SysDbgReadPhysical,
2405  SysDbgWritePhysical,
2406  SysDbgReadControlSpace,
2407  SysDbgWriteControlSpace,
2408  SysDbgReadIoSpace,
2409  SysDbgWriteIoSpace,
2410  SysDbgReadMsr,
2411  SysDbgWriteMsr,
2412  SysDbgReadBusData,
2413  SysDbgWriteBusData,
2414  SysDbgCheckLowMemory,
2415  SysDbgEnableKernelDebugger,
2416  SysDbgDisableKernelDebugger,
2417  SysDbgGetAutoKdEnable,
2418  SysDbgSetAutoKdEnable,
2419  SysDbgGetPrintBufferSize,
2420  SysDbgSetPrintBufferSize,
2421  SysDbgGetKdUmExceptionEnable,
2422  SysDbgSetKdUmExceptionEnable,
2423  SysDbgGetTriageDump,
2424  SysDbgGetKdBlockEnable,
2425  SysDbgSetKdBlockEnable,
2426  SysDbgRegisterForUmBreakInfo,
2427  SysDbgGetUmBreakPid,
2428  SysDbgClearUmBreakPid,
2429  SysDbgGetUmAttachPid,
2430  SysDbgClearUmAttachPid
2431 } SYSDBG_COMMAND, *PSYSDBG_COMMAND;
2432 
2433 typedef struct _SYSDBG_VIRTUAL
2434 {
2435  PVOID Address;
2436  PVOID Buffer;
2437  ULONG Request;
2438 } SYSDBG_VIRTUAL, *PSYSDBG_VIRTUAL;
2439 
2440 typedef struct _SYSDBG_PHYSICAL
2441 {
2442  PHYSICAL_ADDRESS Address;
2443  PVOID Buffer;
2444  ULONG Request;
2445 } SYSDBG_PHYSICAL, *PSYSDBG_PHYSICAL;
2446 
2447 typedef struct _SYSDBG_CONTROL_SPACE
2448 {
2449  ULONG64 Address;
2450  PVOID Buffer;
2451  ULONG Request;
2452  ULONG Processor;
2453 } SYSDBG_CONTROL_SPACE, *PSYSDBG_CONTROL_SPACE;
2454 
2455 enum _INTERFACE_TYPE;
2456 
2457 typedef struct _SYSDBG_IO_SPACE
2458 {
2459  ULONG64 Address;
2460  PVOID Buffer;
2461  ULONG Request;
2462  enum _INTERFACE_TYPE InterfaceType;
2463  ULONG BusNumber;
2464  ULONG AddressSpace;
2465 } SYSDBG_IO_SPACE, *PSYSDBG_IO_SPACE;
2466 
2467 typedef struct _SYSDBG_MSR
2468 {
2469  ULONG Msr;
2470  ULONG64 Data;
2471 } SYSDBG_MSR, *PSYSDBG_MSR;
2472 
2473 enum _BUS_DATA_TYPE;
2474 
2475 typedef struct _SYSDBG_BUS_DATA
2476 {
2477  ULONG Address;
2478  PVOID Buffer;
2479  ULONG Request;
2480  enum _BUS_DATA_TYPE BusDataType;
2481  ULONG BusNumber;
2482  ULONG SlotNumber;
2483 } SYSDBG_BUS_DATA, *PSYSDBG_BUS_DATA;
2484 
2485 // private
2486 typedef struct _SYSDBG_TRIAGE_DUMP
2487 {
2488  ULONG Flags;
2489  ULONG BugCheckCode;
2490  ULONG_PTR BugCheckParam1;
2491  ULONG_PTR BugCheckParam2;
2492  ULONG_PTR BugCheckParam3;
2493  ULONG_PTR BugCheckParam4;
2494  ULONG ProcessHandles;
2495  ULONG ThreadHandles;
2496  PHANDLE Handles;
2497 } SYSDBG_TRIAGE_DUMP, *PSYSDBG_TRIAGE_DUMP;
2498 
2499 NTSYSCALLAPI
2500 NTSTATUS
2501 NTAPI
2502 NtSystemDebugControl(
2503  _In_ SYSDBG_COMMAND Command,
2504  _Inout_updates_bytes_opt_(InputBufferLength) PVOID InputBuffer,
2505  _In_ ULONG InputBufferLength,
2506  _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer,
2507  _In_ ULONG OutputBufferLength,
2508  _Out_opt_ PULONG ReturnLength
2509  );
2510 
2511 // Hard errors
2512 
2513 typedef enum _HARDERROR_RESPONSE_OPTION
2514 {
2515  OptionAbortRetryIgnore,
2516  OptionOk,
2517  OptionOkCancel,
2518  OptionRetryCancel,
2519  OptionYesNo,
2520  OptionYesNoCancel,
2521  OptionShutdownSystem,
2522  OptionOkNoWait,
2523  OptionCancelTryContinue
2524 } HARDERROR_RESPONSE_OPTION;
2525 
2526 typedef enum _HARDERROR_RESPONSE
2527 {
2528  ResponseReturnToCaller,
2529  ResponseNotHandled,
2530  ResponseAbort,
2531  ResponseCancel,
2532  ResponseIgnore,
2533  ResponseNo,
2534  ResponseOk,
2535  ResponseRetry,
2536  ResponseYes,
2537  ResponseTryAgain,
2538  ResponseContinue
2539 } HARDERROR_RESPONSE;
2540 
2541 // HARDERROR_MSG not included
2542 
2543 NTSYSCALLAPI
2544 NTSTATUS
2545 NTAPI
2546 NtRaiseHardError(
2547  _In_ NTSTATUS ErrorStatus,
2548  _In_ ULONG NumberOfParameters,
2549  _In_ ULONG UnicodeStringParameterMask,
2550  _In_reads_(NumberOfParameters) PULONG_PTR Parameters,
2551  _In_ ULONG ValidResponseOptions,
2552  _Out_ PULONG Response
2553  );
2554 
2555 // Kernel-user shared data
2556 
2557 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
2558 {
2559  StandardDesign,
2560  NEC98x86,
2561  EndAlternatives
2562 } ALTERNATIVE_ARCHITECTURE_TYPE;
2563 
2564 #define PROCESSOR_FEATURE_MAX 64
2565 
2566 #define MAX_WOW64_SHARED_ENTRIES 16
2567 
2568 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
2569 #define NX_SUPPORT_POLICY_ALWAYSON 1
2570 #define NX_SUPPORT_POLICY_OPTIN 2
2571 #define NX_SUPPORT_POLICY_OPTOUT 3
2572 
2573 #include <pshpack4.h>
2574 typedef struct _KUSER_SHARED_DATA
2575 {
2576  ULONG TickCountLowDeprecated;
2577  ULONG TickCountMultiplier;
2578 
2579  volatile KSYSTEM_TIME InterruptTime;
2580  volatile KSYSTEM_TIME SystemTime;
2581  volatile KSYSTEM_TIME TimeZoneBias;
2582 
2583  USHORT ImageNumberLow;
2584  USHORT ImageNumberHigh;
2585 
2586  WCHAR NtSystemRoot[260];
2587 
2588  ULONG MaxStackTraceDepth;
2589 
2590  ULONG CryptoExponent;
2591 
2592  ULONG TimeZoneId;
2593  ULONG LargePageMinimum;
2594  ULONG AitSamplingValue;
2595  ULONG AppCompatFlag;
2596  ULONGLONG RNGSeedVersion;
2597  ULONG GlobalValidationRunlevel;
2598  LONG TimeZoneBiasStamp;
2599  ULONG Reserved2;
2600 
2601  ULONG NtProductType;
2602  BOOLEAN ProductTypeIsValid;
2603  UCHAR Reserved0[1];
2604  USHORT NativeProcessorArchitecture;
2605 
2606  ULONG NtMajorVersion;
2607  ULONG NtMinorVersion;
2608 
2609  BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
2610 
2611  ULONG Reserved1;
2612  ULONG Reserved3;
2613 
2614  volatile ULONG TimeSlip;
2615 
2616  ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
2617  ULONG AltArchitecturePad[1];
2618 
2619  LARGE_INTEGER SystemExpirationDate;
2620 
2621  ULONG SuiteMask;
2622 
2623  BOOLEAN KdDebuggerEnabled;
2624  union
2625  {
2626  UCHAR MitigationPolicies;
2627  struct
2628  {
2629  UCHAR NXSupportPolicy : 2;
2630  UCHAR SEHValidationPolicy : 2;
2631  UCHAR CurDirDevicesSkippedForDlls : 2;
2632  UCHAR Reserved : 2;
2633  };
2634  };
2635  UCHAR Reserved6[2];
2636 
2637  volatile ULONG ActiveConsoleId;
2638 
2639  volatile ULONG DismountCount;
2640 
2641  ULONG ComPlusPackage;
2642 
2643  ULONG LastSystemRITEventTickCount;
2644 
2645  ULONG NumberOfPhysicalPages;
2646 
2647  BOOLEAN SafeBootMode;
2648  UCHAR Reserved12[3];
2649 
2650  union
2651  {
2652  ULONG SharedDataFlags;
2653  struct
2654  {
2655  ULONG DbgErrorPortPresent : 1;
2656  ULONG DbgElevationEnabled : 1;
2657  ULONG DbgVirtEnabled : 1;
2658  ULONG DbgInstallerDetectEnabled : 1;
2659  ULONG DbgLkgEnabled : 1;
2660  ULONG DbgDynProcessorEnabled : 1;
2661  ULONG DbgConsoleBrokerEnabled : 1;
2662  ULONG DbgSecureBootEnabled : 1;
2663  ULONG SpareBits : 24;
2664  };
2665  };
2666  ULONG DataFlagsPad[1];
2667 
2668  ULONGLONG TestRetInstruction;
2669  ULONGLONG QpcFrequency;
2670  ULONGLONG SystemCallPad[3];
2671 
2672  union
2673  {
2674  volatile KSYSTEM_TIME TickCount;
2675  volatile ULONG64 TickCountQuad;
2676  ULONG ReservedTickCountOverlay[3];
2677  };
2678  ULONG TickCountPad[1];
2679 
2680  ULONG Cookie;
2681  ULONG CookiePad[1];
2682 
2683  LONGLONG ConsoleSessionForegroundProcessId;
2684  ULONGLONG TimeUpdateSequence;
2685  ULONGLONG BaselineSystemTimeQpc;
2686  ULONGLONG BaselineInterruptTimeQpc;
2687  ULONGLONG QpcSystemTimeIncrement;
2688  ULONGLONG QpcInterruptTimeIncrement;
2689  ULONG QpcSystemTimeIncrement32;
2690  ULONG QpcInterruptTimeIncrement32;
2691  UCHAR QpcSystemTimeIncrementShift;
2692  UCHAR QpcInterruptTimeIncrementShift;
2693  UCHAR Reserved8[14];
2694 
2695  USHORT UserModeGlobalLogger[16];
2696  ULONG ImageFileExecutionOptions;
2697 
2698  ULONG LangGenerationCount;
2699  ULONGLONG Reserved4;
2700  volatile ULONG64 InterruptTimeBias;
2701  volatile ULONG64 QpcBias;
2702 
2703  volatile ULONG ActiveProcessorCount;
2704  volatile UCHAR ActiveGroupCount;
2705  UCHAR Reserved9;
2706  union
2707  {
2708  USHORT QpcData;
2709  struct
2710  {
2711  UCHAR QpcBypassEnabled : 1;
2712  UCHAR QpcShift : 1;
2713  };
2714  };
2715 
2716  LARGE_INTEGER TimeZoneBiasEffectiveStart;
2717  LARGE_INTEGER TimeZoneBiasEffectiveEnd;
2718  XSTATE_CONFIGURATION XState;
2719 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
2720 #include <poppack.h>
2721 
2722 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TickCountMultiplier) == 0x4);
2723 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, InterruptTime) == 0x8);
2724 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemTime) == 0x14);
2725 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneBias) == 0x20);
2726 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ImageNumberLow) == 0x2c);
2727 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ImageNumberHigh) == 0x2e);
2728 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, NtSystemRoot) == 0x30);
2729 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, MaxStackTraceDepth) == 0x238);
2730 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, CryptoExponent) == 0x23c);
2731 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneId) == 0x240);
2732 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, LargePageMinimum) == 0x244);
2733 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, NtProductType) == 0x264);
2734 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ProductTypeIsValid) == 0x268);
2735 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, NtMajorVersion) == 0x26c);
2736 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, NtMinorVersion) == 0x270);
2737 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ProcessorFeatures) == 0x274);
2738 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, Reserved1) == 0x2b4);
2739 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, Reserved3) == 0x2b8);
2740 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TimeSlip) == 0x2bc);
2741 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, AlternativeArchitecture) == 0x2c0);
2742 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemExpirationDate) == 0x2c8);
2743 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SuiteMask) == 0x2d0);
2744 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, KdDebuggerEnabled) == 0x2d4);
2745 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ActiveConsoleId) == 0x2d8);
2746 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, DismountCount) == 0x2dc);
2747 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ComPlusPackage) == 0x2e0);
2748 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, LastSystemRITEventTickCount) == 0x2e4);
2749 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, NumberOfPhysicalPages) == 0x2e8);
2750 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SafeBootMode) == 0x2ec);
2751 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TestRetInstruction) == 0x2f8);
2752 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCallPad) == 0x308);
2753 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TickCount) == 0x320);
2754 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TickCountQuad) == 0x320);
2755 C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, XState) == 0x3d8);
2756 
2757 #define USER_SHARED_DATA ((KUSER_SHARED_DATA * const)0x7ffe0000)
2758 
2759 #if (PHNT_VERSION >= PHNT_WS03)
2760 
2761 FORCEINLINE ULONGLONG NtGetTickCount64()
2762 {
2763  ULARGE_INTEGER tickCount;
2764 
2765 #ifdef _WIN64
2766 
2767  tickCount.QuadPart = USER_SHARED_DATA->TickCountQuad;
2768 
2769 #else
2770 
2771  while (TRUE)
2772  {
2773  tickCount.HighPart = (ULONG)USER_SHARED_DATA->TickCount.High1Time;
2774  tickCount.LowPart = USER_SHARED_DATA->TickCount.LowPart;
2775 
2776  if (tickCount.HighPart == (ULONG)USER_SHARED_DATA->TickCount.High2Time)
2777  break;
2778 
2779  YieldProcessor();
2780  }
2781 
2782 #endif
2783 
2784  return (UInt32x32To64(tickCount.LowPart, USER_SHARED_DATA->TickCountMultiplier) >> 24) +
2785  (UInt32x32To64(tickCount.HighPart, USER_SHARED_DATA->TickCountMultiplier) << 8);
2786 }
2787 
2788 FORCEINLINE ULONG NtGetTickCount()
2789 {
2790 #ifdef _WIN64
2791 
2792  return (ULONG)((USER_SHARED_DATA->TickCountQuad * USER_SHARED_DATA->TickCountMultiplier) >> 24);
2793 
2794 #else
2795 
2796  ULARGE_INTEGER tickCount;
2797 
2798  while (TRUE)
2799  {
2800  tickCount.HighPart = (ULONG)USER_SHARED_DATA->TickCount.High1Time;
2801  tickCount.LowPart = USER_SHARED_DATA->TickCount.LowPart;
2802 
2803  if (tickCount.HighPart == (ULONG)USER_SHARED_DATA->TickCount.High2Time)
2804  break;
2805 
2806  YieldProcessor();
2807  }
2808 
2809  return (ULONG)((UInt32x32To64(tickCount.LowPart, USER_SHARED_DATA->TickCountMultiplier) >> 24) +
2810  UInt32x32To64((tickCount.HighPart << 8) & 0xffffffff, USER_SHARED_DATA->TickCountMultiplier));
2811 
2812 #endif
2813 }
2814 
2815 #endif
2816 
2817 // Locale
2818 
2819 NTSYSCALLAPI
2820 NTSTATUS
2821 NTAPI
2822 NtQueryDefaultLocale(
2823  _In_ BOOLEAN UserProfile,
2824  _Out_ PLCID DefaultLocaleId
2825  );
2826 
2827 NTSYSCALLAPI
2828 NTSTATUS
2829 NTAPI
2830 NtSetDefaultLocale(
2831  _In_ BOOLEAN UserProfile,
2832  _In_ LCID DefaultLocaleId
2833  );
2834 
2835 NTSYSCALLAPI
2836 NTSTATUS
2837 NTAPI
2838 NtQueryInstallUILanguage(
2839  _Out_ LANGID *InstallUILanguageId
2840  );
2841 
2842 #if (PHNT_VERSION >= PHNT_VISTA)
2843 // private
2844 NTSYSCALLAPI
2845 NTSTATUS
2846 NTAPI
2847 NtFlushInstallUILanguage(
2848  _In_ LANGID InstallUILanguage,
2849  _In_ ULONG SetComittedFlag
2850  );
2851 #endif
2852 
2853 NTSYSCALLAPI
2854 NTSTATUS
2855 NTAPI
2856 NtQueryDefaultUILanguage(
2857  _Out_ LANGID *DefaultUILanguageId
2858  );
2859 
2860 NTSYSCALLAPI
2861 NTSTATUS
2862 NTAPI
2863 NtSetDefaultUILanguage(
2864  _In_ LANGID DefaultUILanguageId
2865  );
2866 
2867 #if (PHNT_VERSION >= PHNT_VISTA)
2868 // private
2869 NTSYSCALLAPI
2870 NTSTATUS
2871 NTAPI
2872 NtIsUILanguageComitted(
2873  VOID
2874  );
2875 #endif
2876 
2877 // NLS
2878 
2879 // begin_private
2880 
2881 #if (PHNT_VERSION >= PHNT_VISTA)
2882 
2883 #if (PHNT_VERSION >= PHNT_WIN7)
2884 NTSYSCALLAPI
2885 NTSTATUS
2886 NTAPI
2887 NtInitializeNlsFiles(
2888  _Out_ PVOID *BaseAddress,
2889  _Out_ PLCID DefaultLocaleId,
2890  _Out_ PLARGE_INTEGER DefaultCasingTableSize
2891  );
2892 #else
2893 NTSYSCALLAPI
2894 NTSTATUS
2895 NTAPI
2896 NtInitializeNlsFiles(
2897  _Out_ PVOID *BaseAddress,
2898  _Out_ PLCID DefaultLocaleId,
2899  _Out_ PLARGE_INTEGER DefaultCasingTableSize,
2900  _Out_opt_ PULONG CurrentNLSVersion
2901  );
2902 #endif
2903 
2904 NTSYSCALLAPI
2905 NTSTATUS
2906 NTAPI
2907 NtGetNlsSectionPtr(
2908  _In_ ULONG SectionType,
2909  _In_ ULONG SectionData,
2910  _In_ PVOID ContextData,
2911  _Out_ PVOID *SectionPointer,
2912  _Out_ PULONG SectionSize
2913  );
2914 
2915 #if (PHNT_VERSION < PHNT_WIN7)
2916 
2917 NTSYSCALLAPI
2918 NTSTATUS
2919 NTAPI
2920 NtAcquireCMFViewOwnership(
2921  _Out_ PULONGLONG TimeStamp,
2922  _Out_ PBOOLEAN tokenTaken,
2923  _In_ BOOLEAN replaceExisting
2924  );
2925 
2926 NTSYSCALLAPI
2927 NTSTATUS
2928 NTAPI
2929 NtReleaseCMFViewOwnership(
2930  VOID
2931  );
2932 
2933 #endif
2934 
2935 NTSYSCALLAPI
2936 NTSTATUS
2937 NTAPI
2938 NtMapCMFModule(
2939  _In_ ULONG What,
2940  _In_ ULONG Index,
2941  _Out_opt_ PULONG CacheIndexOut,
2942  _Out_opt_ PULONG CacheFlagsOut,
2943  _Out_opt_ PULONG ViewSizeOut,
2944  _Out_opt_ PVOID *BaseAddress
2945  );
2946 
2947 NTSYSCALLAPI
2948 NTSTATUS
2949 NTAPI
2950 NtGetMUIRegistryInfo(
2951  _In_ ULONG Flags,
2952  _Inout_ PULONG DataSize,
2953  _Out_ PVOID Data
2954  );
2955 
2956 #endif
2957 
2958 // end_private
2959 
2960 // Global atoms
2961 
2962 NTSYSCALLAPI
2963 NTSTATUS
2964 NTAPI
2965 NtAddAtom(
2966  _In_reads_bytes_opt_(Length) PWSTR AtomName,
2967  _In_ ULONG Length,
2968  _Out_opt_ PRTL_ATOM Atom
2969  );
2970 
2971 NTSYSCALLAPI
2972 NTSTATUS
2973 NTAPI
2974 NtFindAtom(
2975  _In_reads_bytes_opt_(Length) PWSTR AtomName,
2976  _In_ ULONG Length,
2977  _Out_opt_ PRTL_ATOM Atom
2978  );
2979 
2980 NTSYSCALLAPI
2981 NTSTATUS
2982 NTAPI
2983 NtDeleteAtom(
2984  _In_ RTL_ATOM Atom
2985  );
2986 
2987 typedef enum _ATOM_INFORMATION_CLASS
2988 {
2989  AtomBasicInformation,
2990  AtomTableInformation
2991 } ATOM_INFORMATION_CLASS;
2992 
2993 typedef struct _ATOM_BASIC_INFORMATION
2994 {
2995  USHORT UsageCount;
2996  USHORT Flags;
2997  USHORT NameLength;
2998  WCHAR Name[1];
2999 } ATOM_BASIC_INFORMATION, *PATOM_BASIC_INFORMATION;
3000 
3001 typedef struct _ATOM_TABLE_INFORMATION
3002 {
3003  ULONG NumberOfAtoms;
3004  RTL_ATOM Atoms[1];
3005 } ATOM_TABLE_INFORMATION, *PATOM_TABLE_INFORMATION;
3006 
3007 NTSYSCALLAPI
3008 NTSTATUS
3009 NTAPI
3010 NtQueryInformationAtom(
3011  _In_ RTL_ATOM Atom,
3012  _In_ ATOM_INFORMATION_CLASS AtomInformationClass,
3013  _Out_writes_bytes_(AtomInformationLength) PVOID AtomInformation,
3014  _In_ ULONG AtomInformationLength,
3015  _Out_opt_ PULONG ReturnLength
3016  );
3017 
3018 // Global flags
3019 
3020 #define FLG_STOP_ON_EXCEPTION 0x00000001 // uk
3021 #define FLG_SHOW_LDR_SNAPS 0x00000002 // uk
3022 #define FLG_DEBUG_INITIAL_COMMAND 0x00000004 // k
3023 #define FLG_STOP_ON_HUNG_GUI 0x00000008 // k
3024 
3025 #define FLG_HEAP_ENABLE_TAIL_CHECK 0x00000010 // u
3026 #define FLG_HEAP_ENABLE_FREE_CHECK 0x00000020 // u
3027 #define FLG_HEAP_VALIDATE_PARAMETERS 0x00000040 // u
3028 #define FLG_HEAP_VALIDATE_ALL 0x00000080 // u
3029 
3030 #define FLG_APPLICATION_VERIFIER 0x00000100 // u
3031 #define FLG_POOL_ENABLE_TAGGING 0x00000400 // k
3032 #define FLG_HEAP_ENABLE_TAGGING 0x00000800 // u
3033 
3034 #define FLG_USER_STACK_TRACE_DB 0x00001000 // u,32
3035 #define FLG_KERNEL_STACK_TRACE_DB 0x00002000 // k,32
3036 #define FLG_MAINTAIN_OBJECT_TYPELIST 0x00004000 // k
3037 #define FLG_HEAP_ENABLE_TAG_BY_DLL 0x00008000 // u
3038 
3039 #define FLG_DISABLE_STACK_EXTENSION 0x00010000 // u
3040 #define FLG_ENABLE_CSRDEBUG 0x00020000 // k
3041 #define FLG_ENABLE_KDEBUG_SYMBOL_LOAD 0x00040000 // k
3042 #define FLG_DISABLE_PAGE_KERNEL_STACKS 0x00080000 // k
3043 
3044 #define FLG_ENABLE_SYSTEM_CRIT_BREAKS 0x00100000 // u
3045 #define FLG_HEAP_DISABLE_COALESCING 0x00200000 // u
3046 #define FLG_ENABLE_CLOSE_EXCEPTIONS 0x00400000 // k
3047 #define FLG_ENABLE_EXCEPTION_LOGGING 0x00800000 // k
3048 
3049 #define FLG_ENABLE_HANDLE_TYPE_TAGGING 0x01000000 // k
3050 #define FLG_HEAP_PAGE_ALLOCS 0x02000000 // u
3051 #define FLG_DEBUG_INITIAL_COMMAND_EX 0x04000000 // k
3052 #define FLG_DISABLE_DBGPRINT 0x08000000 // k
3053 
3054 #define FLG_CRITSEC_EVENT_CREATION 0x10000000 // u
3055 #define FLG_LDR_TOP_DOWN 0x20000000 // u,64
3056 #define FLG_ENABLE_HANDLE_EXCEPTIONS 0x40000000 // k
3057 #define FLG_DISABLE_PROTDLLS 0x80000000 // u
3058 
3059 #define FLG_VALID_BITS 0xfffffdff
3060 
3061 #define FLG_USERMODE_VALID_BITS (FLG_STOP_ON_EXCEPTION | \
3062  FLG_SHOW_LDR_SNAPS | \
3063  FLG_HEAP_ENABLE_TAIL_CHECK | \
3064  FLG_HEAP_ENABLE_FREE_CHECK | \
3065  FLG_HEAP_VALIDATE_PARAMETERS | \
3066  FLG_HEAP_VALIDATE_ALL | \
3067  FLG_APPLICATION_VERIFIER | \
3068  FLG_HEAP_ENABLE_TAGGING | \
3069  FLG_USER_STACK_TRACE_DB | \
3070  FLG_HEAP_ENABLE_TAG_BY_DLL | \
3071  FLG_DISABLE_STACK_EXTENSION | \
3072  FLG_ENABLE_SYSTEM_CRIT_BREAKS | \
3073  FLG_HEAP_DISABLE_COALESCING | \
3074  FLG_DISABLE_PROTDLLS | \
3075  FLG_HEAP_PAGE_ALLOCS | \
3076  FLG_CRITSEC_EVENT_CREATION | \
3077  FLG_LDR_TOP_DOWN)
3078 
3079 #define FLG_BOOTONLY_VALID_BITS (FLG_KERNEL_STACK_TRACE_DB | \
3080  FLG_MAINTAIN_OBJECT_TYPELIST | \
3081  FLG_ENABLE_CSRDEBUG | \
3082  FLG_DEBUG_INITIAL_COMMAND | \
3083  FLG_DEBUG_INITIAL_COMMAND_EX | \
3084  FLG_DISABLE_PAGE_KERNEL_STACKS)
3085 
3086 #define FLG_KERNELMODE_VALID_BITS (FLG_STOP_ON_EXCEPTION | \
3087  FLG_SHOW_LDR_SNAPS | \
3088  FLG_STOP_ON_HUNG_GUI | \
3089  FLG_POOL_ENABLE_TAGGING | \
3090  FLG_ENABLE_KDEBUG_SYMBOL_LOAD | \
3091  FLG_ENABLE_CLOSE_EXCEPTIONS | \
3092  FLG_ENABLE_EXCEPTION_LOGGING | \
3093  FLG_ENABLE_HANDLE_TYPE_TAGGING | \
3094  FLG_DISABLE_DBGPRINT | \
3095  FLG_ENABLE_HANDLE_EXCEPTIONS)
3096 
3097 // Licensing
3098 
3099 NTSYSCALLAPI
3100 NTSTATUS
3101 NTAPI
3102 NtQueryLicenseValue(
3103  _In_ PUNICODE_STRING ValueName,
3104  _Out_opt_ PULONG Type,
3105  _Out_writes_bytes_to_opt_(DataSize, *ResultDataSize) PVOID Data,
3106  _In_ ULONG DataSize,
3107  _Out_ PULONG ResultDataSize
3108  );
3109 
3110 // Misc.
3111 
3112 NTSYSCALLAPI
3113 NTSTATUS
3114 NTAPI
3115 NtSetDefaultHardErrorPort(
3116  _In_ HANDLE DefaultHardErrorPort
3117  );
3118 
3119 typedef enum _SHUTDOWN_ACTION
3120 {
3121  ShutdownNoReboot,
3122  ShutdownReboot,
3123  ShutdownPowerOff
3124 } SHUTDOWN_ACTION;
3125 
3126 NTSYSCALLAPI
3127 NTSTATUS
3128 NTAPI
3129 NtShutdownSystem(
3130  _In_ SHUTDOWN_ACTION Action
3131  );
3132 
3133 NTSYSCALLAPI
3134 NTSTATUS
3135 NTAPI
3136 NtDisplayString(
3137  _In_ PUNICODE_STRING String
3138  );
3139 
3140 #if (PHNT_VERSION >= PHNT_WIN7)
3141 NTSYSCALLAPI
3142 NTSTATUS
3143 NTAPI
3144 NtDrawText(
3145  _In_ PUNICODE_STRING String
3146  );
3147 #endif
3148 
3149 #endif // (PHNT_MODE != PHNT_MODE_KERNEL)
3150 
3151 #endif