[RTL/NDK/DDK/XDK]
[reactos.git] / reactos / include / ddk / wdm.h
1 /*
2 * wdm.h
3 *
4 * Windows NT WDM Driver Developer Kit
5 *
6 * This file is part of the ReactOS DDK package.
7 *
8 * Contributors:
9 * Amine Khaldi (amine.khaldi@reactos.org)
10 * Timo Kreuzer (timo.kreuzer@reactos.org)
11 *
12 * THIS SOFTWARE IS NOT COPYRIGHTED
13 *
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
16 *
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAIMED. This includes but is not limited to warranties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 */
23 #pragma once
24
25 #ifndef _WDMDDK_
26 #define _WDMDDK_
27
28 #define WDM_MAJORVERSION 0x06
29 #define WDM_MINORVERSION 0x00
30
31 /* Included via ntddk.h? */
32 #ifndef _NTDDK_
33 #define _NTDDK_
34 #define _WDM_INCLUDED_
35 #define _DDK_DRIVER_
36 #define NO_INTERLOCKED_INTRINSICS
37 #endif /* _NTDDK_ */
38
39 /* Dependencies */
40 #define NT_INCLUDED
41 #include <excpt.h>
42 #include <ntdef.h>
43 #include <ntstatus.h>
44 #include <ntiologc.h>
45
46 #ifndef GUID_DEFINED
47 #include <guiddef.h>
48 #endif
49
50 #ifdef _MAC
51 #ifndef _INC_STRING
52 #include <string.h>
53 #endif /* _INC_STRING */
54 #else
55 #include <string.h>
56 #endif /* _MAC */
57
58 #ifndef _KTMTYPES_
59 typedef GUID UOW, *PUOW;
60 #endif
61
62 typedef GUID *PGUID;
63
64 #if (NTDDI_VERSION >= NTDDI_WINXP)
65 #include <dpfilter.h>
66 #endif
67
68 #include "intrin.h"
69
70 __internal_kernel_driver
71 __drv_Mode_impl(WDM_INCLUDED)
72
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76
77 #if !defined(_NTHALDLL_) && !defined(_BLDR_)
78 #define NTHALAPI DECLSPEC_IMPORT
79 #else
80 #define NTHALAPI
81 #endif
82
83 /* For ReactOS */
84 #if !defined(_NTOSKRNL_) && !defined(_BLDR_)
85 #define NTKERNELAPI DECLSPEC_IMPORT
86 #else
87 #define NTKERNELAPI
88 #endif
89
90 #if defined(_X86_) && !defined(_NTHAL_)
91 #define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT
92 #elif defined(_X86_)
93 #define _DECL_HAL_KE_IMPORT
94 #else
95 #define _DECL_HAL_KE_IMPORT NTKERNELAPI
96 #endif
97
98 #if defined(_WIN64)
99 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
100 #else
101 #define POINTER_ALIGNMENT
102 #endif
103
104 /* Helper macro to enable gcc's extension. */
105 #ifndef __GNU_EXTENSION
106 #ifdef __GNUC__
107 #define __GNU_EXTENSION __extension__
108 #else
109 #define __GNU_EXTENSION
110 #endif
111 #endif
112
113 #if defined(_MSC_VER)
114
115 /* Disable some warnings */
116 #pragma warning(disable:4115) /* Named type definition in parentheses */
117 #pragma warning(disable:4201) /* Nameless unions and structs */
118 #pragma warning(disable:4214) /* Bit fields of other types than int */
119 #pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */
120
121 /* Indicate if #pragma alloc_text() is supported */
122 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
123 #define ALLOC_PRAGMA 1
124 #endif
125
126 /* Indicate if #pragma data_seg() is supported */
127 #if defined(_M_IX86) || defined(_M_AMD64)
128 #define ALLOC_DATA_PRAGMA 1
129 #endif
130
131 #endif
132
133 #if defined(_WIN64)
134 #if !defined(USE_DMA_MACROS) && !defined(_NTHAL_)
135 #define USE_DMA_MACROS
136 #endif
137 #if !defined(NO_LEGACY_DRIVERS) && !defined(__REACTOS__)
138 #define NO_LEGACY_DRIVERS
139 #endif
140 #endif /* defined(_WIN64) */
141
142 /* Forward declarations */
143 struct _IRP;
144 struct _MDL;
145 struct _KAPC;
146 struct _KDPC;
147 struct _FILE_OBJECT;
148 struct _DMA_ADAPTER;
149 struct _DEVICE_OBJECT;
150 struct _DRIVER_OBJECT;
151 struct _IO_STATUS_BLOCK;
152 struct _DEVICE_DESCRIPTION;
153 struct _SCATTER_GATHER_LIST;
154 struct _DRIVE_LAYOUT_INFORMATION;
155 struct _COMPRESSED_DATA_INFO;
156 struct _IO_RESOURCE_DESCRIPTOR;
157
158 /* Structures not exposed to drivers */
159 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
160 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
161 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
162 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
163 typedef struct _EPROCESS *PEPROCESS;
164 typedef struct _ETHREAD *PETHREAD;
165 typedef struct _IO_TIMER *PIO_TIMER;
166 typedef struct _KINTERRUPT *PKINTERRUPT;
167 typedef struct _KPROCESS *PKPROCESS;
168 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
169 typedef struct _CONTEXT *PCONTEXT;
170
171 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_)
172 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
173 #elif defined(_WDM_INCLUDED_)
174 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
175 #else
176 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
177 #endif
178
179 #ifndef DEFINE_GUIDEX
180 #ifdef _MSC_VER
181 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
182 #else
183 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name
184 #endif
185 #endif /* DEFINE_GUIDEX */
186
187 #ifndef STATICGUIDOF
188 #define STATICGUIDOF(guid) STATIC_##guid
189 #endif
190
191 /* GUID Comparison */
192 #ifndef __IID_ALIGNED__
193 #define __IID_ALIGNED__
194 #ifdef __cplusplus
195 inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
196 {
197 return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
198 (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
199 }
200 #else
201 #define IsEqualGUIDAligned(guid1, guid2) \
202 ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \
203 (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) )
204 #endif /* __cplusplus */
205 #endif /* !__IID_ALIGNED__ */
206
207
208 /******************************************************************************
209 * INTERLOCKED Functions *
210 ******************************************************************************/
211 //
212 // Intrinsics (note: taken from our winnt.h)
213 // FIXME: 64-bit
214 //
215 #if defined(__GNUC__)
216
217 static __inline__ BOOLEAN
218 InterlockedBitTestAndSet(
219 _Inout_updates_bytes_((Bit+7)/8) _Interlocked_operand_ LONG volatile *Base,
220 _In_ LONG Bit)
221 {
222 #if defined(_M_IX86)
223 LONG OldBit;
224 __asm__ __volatile__("lock "
225 "btsl %2,%1\n\t"
226 "sbbl %0,%0\n\t"
227 :"=r" (OldBit),"+m" (*Base)
228 :"Ir" (Bit)
229 : "memory");
230 return OldBit;
231 #else
232 return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1;
233 #endif
234 }
235
236 static __inline__ BOOLEAN
237 InterlockedBitTestAndReset(
238 _Inout_updates_bytes_((Bit+7)/8) _Interlocked_operand_ LONG volatile *Base,
239 _In_ LONG Bit)
240 {
241 #if defined(_M_IX86)
242 LONG OldBit;
243 __asm__ __volatile__("lock "
244 "btrl %2,%1\n\t"
245 "sbbl %0,%0\n\t"
246 :"=r" (OldBit),"+m" (*Base)
247 :"Ir" (Bit)
248 : "memory");
249 return OldBit;
250 #else
251 return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1;
252 #endif
253 }
254
255 #endif /* defined(__GNUC__) */
256
257 #define BitScanForward _BitScanForward
258 #define BitScanReverse _BitScanReverse
259 #define BitTest _bittest
260 #define BitTestAndComplement _bittestandcomplement
261 #define BitTestAndSet _bittestandset
262 #define BitTestAndReset _bittestandreset
263 #define InterlockedBitTestAndSet _interlockedbittestandset
264 #define InterlockedBitTestAndReset _interlockedbittestandreset
265
266 #ifdef _M_AMD64
267 #define BitTest64 _bittest64
268 #define BitTestAndComplement64 _bittestandcomplement64
269 #define BitTestAndSet64 _bittestandset64
270 #define BitTestAndReset64 _bittestandreset64
271 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
272 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
273 #endif
274
275 #if !defined(__INTERLOCKED_DECLARED)
276 #define __INTERLOCKED_DECLARED
277
278 #if defined (_X86_)
279 #if defined(NO_INTERLOCKED_INTRINSICS)
280 NTKERNELAPI
281 LONG
282 FASTCALL
283 InterlockedIncrement(
284 _Inout_ _Interlocked_operand_ LONG volatile *Addend);
285
286 NTKERNELAPI
287 LONG
288 FASTCALL
289 InterlockedDecrement(
290 _Inout_ _Interlocked_operand_ LONG volatile *Addend);
291
292 NTKERNELAPI
293 LONG
294 FASTCALL
295 InterlockedCompareExchange(
296 _Inout_ _Interlocked_operand_ LONG volatile *Destination,
297 _In_ LONG Exchange,
298 _In_ LONG Comparand);
299
300 NTKERNELAPI
301 LONG
302 FASTCALL
303 InterlockedExchange(
304 _Inout_ _Interlocked_operand_ LONG volatile *Destination,
305 _In_ LONG Value);
306
307 NTKERNELAPI
308 LONG
309 FASTCALL
310 InterlockedExchangeAdd(
311 _Inout_ _Interlocked_operand_ LONG volatile *Addend,
312 _In_ LONG Value);
313
314 #else /* !defined(NO_INTERLOCKED_INTRINSICS) */
315
316 #define InterlockedExchange _InterlockedExchange
317 #define InterlockedIncrement _InterlockedIncrement
318 #define InterlockedDecrement _InterlockedDecrement
319 #define InterlockedExchangeAdd _InterlockedExchangeAdd
320 #define InterlockedCompareExchange _InterlockedCompareExchange
321 #define InterlockedOr _InterlockedOr
322 #define InterlockedAnd _InterlockedAnd
323 #define InterlockedXor _InterlockedXor
324
325 #endif /* !defined(NO_INTERLOCKED_INTRINSICS) */
326
327 #endif /* defined (_X86_) */
328
329 #if !defined (_WIN64)
330 /*
331 * PVOID
332 * InterlockedExchangePointer(
333 * IN OUT PVOID volatile *Target,
334 * IN PVOID Value)
335 */
336 #define InterlockedExchangePointer(Target, Value) \
337 ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value))
338
339 /*
340 * PVOID
341 * InterlockedCompareExchangePointer(
342 * IN OUT PVOID *Destination,
343 * IN PVOID Exchange,
344 * IN PVOID Comparand)
345 */
346 #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \
347 ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand))
348
349 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b)
350 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a)
351 #define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)a)
352
353 #endif // !defined (_WIN64)
354
355 #if defined (_M_AMD64)
356
357 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)a, (LONGLONG)b)
358 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)a)
359 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONGLONG *)a)
360 #define InterlockedAnd _InterlockedAnd
361 #define InterlockedOr _InterlockedOr
362 #define InterlockedXor _InterlockedXor
363 #define InterlockedIncrement _InterlockedIncrement
364 #define InterlockedDecrement _InterlockedDecrement
365 #define InterlockedAdd _InterlockedAdd
366 #define InterlockedExchange _InterlockedExchange
367 #define InterlockedExchangeAdd _InterlockedExchangeAdd
368 #define InterlockedCompareExchange _InterlockedCompareExchange
369 #define InterlockedAnd64 _InterlockedAnd64
370 #define InterlockedOr64 _InterlockedOr64
371 #define InterlockedXor64 _InterlockedXor64
372 #define InterlockedIncrement64 _InterlockedIncrement64
373 #define InterlockedDecrement64 _InterlockedDecrement64
374 #define InterlockedAdd64 _InterlockedAdd64
375 #define InterlockedExchange64 _InterlockedExchange64
376 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
377 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
378 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
379 #define InterlockedExchangePointer _InterlockedExchangePointer
380 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
381 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
382
383 #endif // _M_AMD64
384
385 #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
386 //#if !defined(_X86AMD64_) // FIXME: what's _X86AMD64_ used for?
387 FORCEINLINE
388 LONG64
389 InterlockedAdd64(
390 _Inout_ _Interlocked_operand_ LONG64 volatile *Addend,
391 _In_ LONG64 Value)
392 {
393 return InterlockedExchangeAdd64(Addend, Value) + Value;
394 }
395 //#endif
396 #endif
397
398 #endif /* !__INTERLOCKED_DECLARED */
399
400
401 /******************************************************************************
402 * Runtime Library Types *
403 ******************************************************************************/
404
405 #define RTL_REGISTRY_ABSOLUTE 0
406 #define RTL_REGISTRY_SERVICES 1
407 #define RTL_REGISTRY_CONTROL 2
408 #define RTL_REGISTRY_WINDOWS_NT 3
409 #define RTL_REGISTRY_DEVICEMAP 4
410 #define RTL_REGISTRY_USER 5
411 #define RTL_REGISTRY_MAXIMUM 6
412 #define RTL_REGISTRY_HANDLE 0x40000000
413 #define RTL_REGISTRY_OPTIONAL 0x80000000
414
415 /* RTL_QUERY_REGISTRY_TABLE.Flags */
416 #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001
417 #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002
418 #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004
419 #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008
420 #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010
421 #define RTL_QUERY_REGISTRY_DIRECT 0x00000020
422 #define RTL_QUERY_REGISTRY_DELETE 0x00000040
423
424 #define HASH_STRING_ALGORITHM_DEFAULT 0
425 #define HASH_STRING_ALGORITHM_X65599 1
426 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
427
428 typedef struct _RTL_BITMAP {
429 ULONG SizeOfBitMap;
430 PULONG Buffer;
431 } RTL_BITMAP, *PRTL_BITMAP;
432
433 typedef struct _RTL_BITMAP_RUN {
434 ULONG StartingIndex;
435 ULONG NumberOfBits;
436 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
437
438 _Function_class_(RTL_QUERY_REGISTRY_ROUTINE)
439 _IRQL_requires_max_(PASSIVE_LEVEL)
440 _IRQL_requires_same_
441 typedef NTSTATUS
442 (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
443 _In_z_ PWSTR ValueName,
444 _In_ ULONG ValueType,
445 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
446 _In_ ULONG ValueLength,
447 _In_opt_ PVOID Context,
448 _In_opt_ PVOID EntryContext);
449
450 typedef struct _RTL_QUERY_REGISTRY_TABLE {
451 PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
452 ULONG Flags;
453 PCWSTR Name;
454 PVOID EntryContext;
455 ULONG DefaultType;
456 PVOID DefaultData;
457 ULONG DefaultLength;
458 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
459
460 typedef struct _TIME_FIELDS {
461 CSHORT Year;
462 CSHORT Month;
463 CSHORT Day;
464 CSHORT Hour;
465 CSHORT Minute;
466 CSHORT Second;
467 CSHORT Milliseconds;
468 CSHORT Weekday;
469 } TIME_FIELDS, *PTIME_FIELDS;
470
471 /* Slist Header */
472 #ifndef _SLIST_HEADER_
473 #define _SLIST_HEADER_
474
475 #if defined(_WIN64)
476
477 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
478 struct _SLIST_ENTRY *Next;
479 } SLIST_ENTRY, *PSLIST_ENTRY;
480
481 typedef struct _SLIST_ENTRY32 {
482 ULONG Next;
483 } SLIST_ENTRY32, *PSLIST_ENTRY32;
484
485 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
486 _ANONYMOUS_STRUCT struct {
487 ULONGLONG Alignment;
488 ULONGLONG Region;
489 } DUMMYSTRUCTNAME;
490 struct {
491 ULONGLONG Depth:16;
492 ULONGLONG Sequence:9;
493 ULONGLONG NextEntry:39;
494 ULONGLONG HeaderType:1;
495 ULONGLONG Init:1;
496 ULONGLONG Reserved:59;
497 ULONGLONG Region:3;
498 } Header8;
499 struct {
500 ULONGLONG Depth:16;
501 ULONGLONG Sequence:48;
502 ULONGLONG HeaderType:1;
503 ULONGLONG Init:1;
504 ULONGLONG Reserved:2;
505 ULONGLONG NextEntry:60;
506 } Header16;
507 struct {
508 ULONGLONG Depth:16;
509 ULONGLONG Sequence:48;
510 ULONGLONG HeaderType:1;
511 ULONGLONG Reserved:3;
512 ULONGLONG NextEntry:60;
513 } HeaderX64;
514 } SLIST_HEADER, *PSLIST_HEADER;
515
516 typedef union _SLIST_HEADER32 {
517 ULONGLONG Alignment;
518 _ANONYMOUS_STRUCT struct {
519 SLIST_ENTRY32 Next;
520 USHORT Depth;
521 USHORT Sequence;
522 } DUMMYSTRUCTNAME;
523 } SLIST_HEADER32, *PSLIST_HEADER32;
524
525 #else
526
527 #define SLIST_ENTRY SINGLE_LIST_ENTRY
528 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
529 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
530
531 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32;
532
533 typedef union _SLIST_HEADER {
534 ULONGLONG Alignment;
535 _ANONYMOUS_STRUCT struct {
536 SLIST_ENTRY Next;
537 USHORT Depth;
538 USHORT Sequence;
539 } DUMMYSTRUCTNAME;
540 } SLIST_HEADER, *PSLIST_HEADER;
541
542 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
543
544 #endif /* defined(_WIN64) */
545
546 #endif /* _SLIST_HEADER_ */
547
548 /* MS definition is broken! */
549 extern BOOLEAN NTSYSAPI NlsMbCodePageTag;
550 extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag;
551 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
552 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
553
554 #define SHORT_LEAST_SIGNIFICANT_BIT 0
555 #define SHORT_MOST_SIGNIFICANT_BIT 1
556
557 #define LONG_LEAST_SIGNIFICANT_BIT 0
558 #define LONG_3RD_MOST_SIGNIFICANT_BIT 1
559 #define LONG_2ND_MOST_SIGNIFICANT_BIT 2
560 #define LONG_MOST_SIGNIFICANT_BIT 3
561
562 #define RTLVERLIB_DDI(x) Wdmlib##x
563
564 typedef BOOLEAN
565 (*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)(
566 _In_ ULONG Version);
567
568 typedef BOOLEAN
569 (*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)(
570 _In_ ULONG Version);
571
572 /******************************************************************************
573 * Kernel Types *
574 ******************************************************************************/
575
576 typedef UCHAR KIRQL, *PKIRQL;
577 typedef CCHAR KPROCESSOR_MODE;
578 typedef LONG KPRIORITY;
579
580 typedef enum _MODE {
581 KernelMode,
582 UserMode,
583 MaximumMode
584 } MODE;
585
586 #define CACHE_FULLY_ASSOCIATIVE 0xFF
587 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
588
589 #define EVENT_QUERY_STATE (0x0001)
590 #define EVENT_MODIFY_STATE (0x0002)
591 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
592
593 #define LTP_PC_SMT 0x1
594
595 #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS)
596 #define SINGLE_GROUP_LEGACY_API 1
597 #endif
598
599 #define SEMAPHORE_QUERY_STATE (0x0001)
600 #define SEMAPHORE_MODIFY_STATE (0x0002)
601 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
602
603 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
604 RelationProcessorCore,
605 RelationNumaNode,
606 RelationCache,
607 RelationProcessorPackage,
608 RelationGroup,
609 RelationAll = 0xffff
610 } LOGICAL_PROCESSOR_RELATIONSHIP;
611
612 typedef enum _PROCESSOR_CACHE_TYPE {
613 CacheUnified,
614 CacheInstruction,
615 CacheData,
616 CacheTrace
617 } PROCESSOR_CACHE_TYPE;
618
619 typedef struct _CACHE_DESCRIPTOR {
620 UCHAR Level;
621 UCHAR Associativity;
622 USHORT LineSize;
623 ULONG Size;
624 PROCESSOR_CACHE_TYPE Type;
625 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
626
627 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
628 ULONG_PTR ProcessorMask;
629 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
630 _ANONYMOUS_UNION union {
631 struct {
632 UCHAR Flags;
633 } ProcessorCore;
634 struct {
635 ULONG NodeNumber;
636 } NumaNode;
637 CACHE_DESCRIPTOR Cache;
638 ULONGLONG Reserved[2];
639 } DUMMYUNIONNAME;
640 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
641
642 typedef struct _PROCESSOR_RELATIONSHIP {
643 UCHAR Flags;
644 UCHAR Reserved[21];
645 USHORT GroupCount;
646 _Field_size_(GroupCount) GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
647 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
648
649 typedef struct _NUMA_NODE_RELATIONSHIP {
650 ULONG NodeNumber;
651 UCHAR Reserved[20];
652 GROUP_AFFINITY GroupMask;
653 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
654
655 typedef struct _CACHE_RELATIONSHIP {
656 UCHAR Level;
657 UCHAR Associativity;
658 USHORT LineSize;
659 ULONG CacheSize;
660 PROCESSOR_CACHE_TYPE Type;
661 UCHAR Reserved[20];
662 GROUP_AFFINITY GroupMask;
663 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
664
665 typedef struct _PROCESSOR_GROUP_INFO {
666 UCHAR MaximumProcessorCount;
667 UCHAR ActiveProcessorCount;
668 UCHAR Reserved[38];
669 KAFFINITY ActiveProcessorMask;
670 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
671
672 typedef struct _GROUP_RELATIONSHIP {
673 USHORT MaximumGroupCount;
674 USHORT ActiveGroupCount;
675 UCHAR Reserved[20];
676 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
677 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
678
679 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
680 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
681 ULONG Size;
682 _ANONYMOUS_UNION union {
683 PROCESSOR_RELATIONSHIP Processor;
684 NUMA_NODE_RELATIONSHIP NumaNode;
685 CACHE_RELATIONSHIP Cache;
686 GROUP_RELATIONSHIP Group;
687 } DUMMYUNIONNAME;
688 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;;
689
690 /* Processor features */
691 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
692 #define PF_FLOATING_POINT_EMULATED 1
693 #define PF_COMPARE_EXCHANGE_DOUBLE 2
694 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
695 #define PF_PPC_MOVEMEM_64BIT_OK 4
696 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
697 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
698 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
699 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
700 #define PF_PAE_ENABLED 9
701 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
702 #define PF_SSE_DAZ_MODE_AVAILABLE 11
703 #define PF_NX_ENABLED 12
704 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
705 #define PF_COMPARE_EXCHANGE128 14
706 #define PF_COMPARE64_EXCHANGE128 15
707 #define PF_CHANNELS_ENABLED 16
708 #define PF_XSAVE_ENABLED 17
709
710 #define MAXIMUM_WAIT_OBJECTS 64
711
712 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject)
713
714 #define ASSERT_DPC(Object) \
715 ASSERT(((Object)->Type == 0) || \
716 ((Object)->Type == DpcObject) || \
717 ((Object)->Type == ThreadedDpcObject))
718
719 #define ASSERT_GATE(object) \
720 NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
721 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
722
723 #define ASSERT_DEVICE_QUEUE(Object) \
724 NT_ASSERT((Object)->Type == DeviceQueueObject)
725
726 #define ASSERT_TIMER(E) \
727 NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \
728 ((E)->Header.Type == TimerSynchronizationObject))
729
730 #define ASSERT_MUTANT(E) \
731 NT_ASSERT((E)->Header.Type == MutantObject)
732
733 #define ASSERT_SEMAPHORE(E) \
734 NT_ASSERT((E)->Header.Type == SemaphoreObject)
735
736 #define ASSERT_EVENT(E) \
737 NT_ASSERT(((E)->Header.Type == NotificationEvent) || \
738 ((E)->Header.Type == SynchronizationEvent))
739
740 #define DPC_NORMAL 0
741 #define DPC_THREADED 1
742
743 #define GM_LOCK_BIT 0x1
744 #define GM_LOCK_BIT_V 0x0
745 #define GM_LOCK_WAITER_WOKEN 0x2
746 #define GM_LOCK_WAITER_INC 0x4
747
748 #define LOCK_QUEUE_WAIT_BIT 0
749 #define LOCK_QUEUE_OWNER_BIT 1
750
751 #define LOCK_QUEUE_WAIT 1
752 #define LOCK_QUEUE_OWNER 2
753 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4
754 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
755
756 #define PROCESSOR_FEATURE_MAX 64
757
758 #define DBG_STATUS_CONTROL_C 1
759 #define DBG_STATUS_SYSRQ 2
760 #define DBG_STATUS_BUGCHECK_FIRST 3
761 #define DBG_STATUS_BUGCHECK_SECOND 4
762 #define DBG_STATUS_FATAL 5
763 #define DBG_STATUS_DEBUG_CONTROL 6
764 #define DBG_STATUS_WORKER 7
765
766 #if defined(_WIN64)
767 #define MAXIMUM_PROC_PER_GROUP 64
768 #else
769 #define MAXIMUM_PROC_PER_GROUP 32
770 #endif
771 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP
772
773 /* Exception Records */
774 #define EXCEPTION_NONCONTINUABLE 1
775 #define EXCEPTION_MAXIMUM_PARAMETERS 15
776
777 #define EXCEPTION_DIVIDED_BY_ZERO 0
778 #define EXCEPTION_DEBUG 1
779 #define EXCEPTION_NMI 2
780 #define EXCEPTION_INT3 3
781 #define EXCEPTION_BOUND_CHECK 5
782 #define EXCEPTION_INVALID_OPCODE 6
783 #define EXCEPTION_NPX_NOT_AVAILABLE 7
784 #define EXCEPTION_DOUBLE_FAULT 8
785 #define EXCEPTION_NPX_OVERRUN 9
786 #define EXCEPTION_INVALID_TSS 0x0A
787 #define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B
788 #define EXCEPTION_STACK_FAULT 0x0C
789 #define EXCEPTION_GP_FAULT 0x0D
790 #define EXCEPTION_RESERVED_TRAP 0x0F
791 #define EXCEPTION_NPX_ERROR 0x010
792 #define EXCEPTION_ALIGNMENT_CHECK 0x011
793
794 typedef struct _EXCEPTION_RECORD {
795 NTSTATUS ExceptionCode;
796 ULONG ExceptionFlags;
797 struct _EXCEPTION_RECORD *ExceptionRecord;
798 PVOID ExceptionAddress;
799 ULONG NumberParameters;
800 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
801 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
802
803 typedef struct _EXCEPTION_RECORD32 {
804 NTSTATUS ExceptionCode;
805 ULONG ExceptionFlags;
806 ULONG ExceptionRecord;
807 ULONG ExceptionAddress;
808 ULONG NumberParameters;
809 ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
810 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
811
812 typedef struct _EXCEPTION_RECORD64 {
813 NTSTATUS ExceptionCode;
814 ULONG ExceptionFlags;
815 ULONG64 ExceptionRecord;
816 ULONG64 ExceptionAddress;
817 ULONG NumberParameters;
818 ULONG __unusedAlignment;
819 ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
820 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
821
822 typedef struct _EXCEPTION_POINTERS {
823 PEXCEPTION_RECORD ExceptionRecord;
824 PCONTEXT ContextRecord;
825 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
826
827 typedef enum _KBUGCHECK_CALLBACK_REASON {
828 KbCallbackInvalid,
829 KbCallbackReserved1,
830 KbCallbackSecondaryDumpData,
831 KbCallbackDumpIo,
832 KbCallbackAddPages
833 } KBUGCHECK_CALLBACK_REASON;
834
835 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
836
837 _Function_class_(KBUGCHECK_REASON_CALLBACK_ROUTINE)
838 _IRQL_requires_same_
839 typedef VOID
840 (NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)(
841 _In_ KBUGCHECK_CALLBACK_REASON Reason,
842 _In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
843 _Inout_ PVOID ReasonSpecificData,
844 _In_ ULONG ReasonSpecificDataLength);
845 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE;
846
847 typedef struct _KBUGCHECK_ADD_PAGES {
848 _Inout_ PVOID Context;
849 _Inout_ ULONG Flags;
850 _In_ ULONG BugCheckCode;
851 _Out_ ULONG_PTR Address;
852 _Out_ ULONG_PTR Count;
853 } KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES;
854
855 typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
856 _In_ PVOID InBuffer;
857 _In_ ULONG InBufferLength;
858 _In_ ULONG MaximumAllowed;
859 _Out_ GUID Guid;
860 _Out_ PVOID OutBuffer;
861 _Out_ ULONG OutBufferLength;
862 } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
863
864 typedef enum _KBUGCHECK_DUMP_IO_TYPE {
865 KbDumpIoInvalid,
866 KbDumpIoHeader,
867 KbDumpIoBody,
868 KbDumpIoSecondaryData,
869 KbDumpIoComplete
870 } KBUGCHECK_DUMP_IO_TYPE;
871
872 typedef struct _KBUGCHECK_DUMP_IO {
873 _In_ ULONG64 Offset;
874 _In_ PVOID Buffer;
875 _In_ ULONG BufferLength;
876 _In_ KBUGCHECK_DUMP_IO_TYPE Type;
877 } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
878
879 #define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL
880 #define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL
881 #define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL
882
883 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
884 LIST_ENTRY Entry;
885 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
886 PUCHAR Component;
887 ULONG_PTR Checksum;
888 KBUGCHECK_CALLBACK_REASON Reason;
889 UCHAR State;
890 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
891
892 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
893 BufferEmpty,
894 BufferInserted,
895 BufferStarted,
896 BufferFinished,
897 BufferIncomplete
898 } KBUGCHECK_BUFFER_DUMP_STATE;
899
900 _Function_class_(KBUGCHECK_CALLBACK_ROUTINE)
901 _IRQL_requires_same_
902 typedef VOID
903 (NTAPI KBUGCHECK_CALLBACK_ROUTINE)(
904 IN PVOID Buffer,
905 IN ULONG Length);
906 typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE;
907
908 typedef struct _KBUGCHECK_CALLBACK_RECORD {
909 LIST_ENTRY Entry;
910 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
911 _Field_size_bytes_opt_(Length) PVOID Buffer;
912 ULONG Length;
913 PUCHAR Component;
914 ULONG_PTR Checksum;
915 UCHAR State;
916 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
917
918 _Function_class_(NMI_CALLBACK)
919 _IRQL_requires_same_
920 typedef BOOLEAN
921 (NTAPI NMI_CALLBACK)(
922 _In_opt_ PVOID Context,
923 _In_ BOOLEAN Handled);
924 typedef NMI_CALLBACK *PNMI_CALLBACK;
925
926 typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE {
927 KeProcessorAddStartNotify = 0,
928 KeProcessorAddCompleteNotify,
929 KeProcessorAddFailureNotify
930 } KE_PROCESSOR_CHANGE_NOTIFY_STATE;
931
932 typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT {
933 KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
934 ULONG NtNumber;
935 NTSTATUS Status;
936 #if (NTDDI_VERSION >= NTDDI_WIN7)
937 PROCESSOR_NUMBER ProcNumber;
938 #endif
939 } KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
940
941 _IRQL_requires_same_
942 _Function_class_(PROCESSOR_CALLBACK_FUNCTION)
943 typedef VOID
944 (NTAPI PROCESSOR_CALLBACK_FUNCTION)(
945 _In_ PVOID CallbackContext,
946 _In_ PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext,
947 _Inout_ PNTSTATUS OperationStatus);
948 typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION;
949
950 #define KE_PROCESSOR_CHANGE_ADD_EXISTING 1
951
952 #define INVALID_PROCESSOR_INDEX 0xffffffff
953
954 typedef enum _KINTERRUPT_POLARITY {
955 InterruptPolarityUnknown,
956 InterruptActiveHigh,
957 InterruptActiveLow
958 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
959
960 typedef enum _KPROFILE_SOURCE {
961 ProfileTime,
962 ProfileAlignmentFixup,
963 ProfileTotalIssues,
964 ProfilePipelineDry,
965 ProfileLoadInstructions,
966 ProfilePipelineFrozen,
967 ProfileBranchInstructions,
968 ProfileTotalNonissues,
969 ProfileDcacheMisses,
970 ProfileIcacheMisses,
971 ProfileCacheMisses,
972 ProfileBranchMispredictions,
973 ProfileStoreInstructions,
974 ProfileFpInstructions,
975 ProfileIntegerInstructions,
976 Profile2Issue,
977 Profile3Issue,
978 Profile4Issue,
979 ProfileSpecialInstructions,
980 ProfileTotalCycles,
981 ProfileIcacheIssues,
982 ProfileDcacheAccesses,
983 ProfileMemoryBarrierCycles,
984 ProfileLoadLinkedIssues,
985 ProfileMaximum
986 } KPROFILE_SOURCE;
987
988 typedef enum _KWAIT_REASON {
989 Executive,
990 FreePage,
991 PageIn,
992 PoolAllocation,
993 DelayExecution,
994 Suspended,
995 UserRequest,
996 WrExecutive,
997 WrFreePage,
998 WrPageIn,
999 WrPoolAllocation,
1000 WrDelayExecution,
1001 WrSuspended,
1002 WrUserRequest,
1003 WrEventPair,
1004 WrQueue,
1005 WrLpcReceive,
1006 WrLpcReply,
1007 WrVirtualMemory,
1008 WrPageOut,
1009 WrRendezvous,
1010 WrKeyedEvent,
1011 WrTerminated,
1012 WrProcessInSwap,
1013 WrCpuRateControl,
1014 WrCalloutStack,
1015 WrKernel,
1016 WrResource,
1017 WrPushLock,
1018 WrMutex,
1019 WrQuantumEnd,
1020 WrDispatchInt,
1021 WrPreempted,
1022 WrYieldExecution,
1023 WrFastMutex,
1024 WrGuardedMutex,
1025 WrRundown,
1026 MaximumWaitReason
1027 } KWAIT_REASON;
1028
1029 typedef struct _KWAIT_BLOCK {
1030 LIST_ENTRY WaitListEntry;
1031 struct _KTHREAD *Thread;
1032 PVOID Object;
1033 struct _KWAIT_BLOCK *NextWaitBlock;
1034 USHORT WaitKey;
1035 UCHAR WaitType;
1036 #if (NTDDI_VERSION >= NTDDI_WIN7)
1037 volatile UCHAR BlockState;
1038 #else
1039 UCHAR SpareByte;
1040 #endif
1041 #if defined(_WIN64)
1042 LONG SpareLong;
1043 #endif
1044 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK;
1045
1046 typedef enum _KINTERRUPT_MODE {
1047 LevelSensitive,
1048 Latched
1049 } KINTERRUPT_MODE;
1050
1051 #define THREAD_WAIT_OBJECTS 3
1052
1053 _IRQL_requires_same_
1054 _Function_class_(KSTART_ROUTINE)
1055 typedef VOID
1056 (NTAPI KSTART_ROUTINE)(
1057 _In_ PVOID StartContext);
1058 typedef KSTART_ROUTINE *PKSTART_ROUTINE;
1059
1060 typedef VOID
1061 (NTAPI *PKINTERRUPT_ROUTINE)(
1062 VOID);
1063
1064 _Function_class_(KSERVICE_ROUTINE)
1065 _IRQL_requires_(HIGH_LEVEL)
1066 _IRQL_requires_same_
1067 typedef BOOLEAN
1068 (NTAPI KSERVICE_ROUTINE)(
1069 _In_ struct _KINTERRUPT *Interrupt,
1070 _In_ PVOID ServiceContext);
1071 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
1072
1073 _Function_class_(KMESSAGE_SERVICE_ROUTINE)
1074 _IRQL_requires_same_
1075 typedef BOOLEAN
1076 (NTAPI KMESSAGE_SERVICE_ROUTINE)(
1077 _In_ struct _KINTERRUPT *Interrupt,
1078 _In_ PVOID ServiceContext,
1079 _In_ ULONG MessageID);
1080 typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE;
1081
1082 typedef enum _KD_OPTION {
1083 KD_OPTION_SET_BLOCK_ENABLE,
1084 } KD_OPTION;
1085
1086 typedef VOID
1087 (NTAPI *PKNORMAL_ROUTINE)(
1088 IN PVOID NormalContext OPTIONAL,
1089 IN PVOID SystemArgument1 OPTIONAL,
1090 IN PVOID SystemArgument2 OPTIONAL);
1091
1092 typedef VOID
1093 (NTAPI *PKRUNDOWN_ROUTINE)(
1094 IN struct _KAPC *Apc);
1095
1096 typedef VOID
1097 (NTAPI *PKKERNEL_ROUTINE)(
1098 IN struct _KAPC *Apc,
1099 IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
1100 IN OUT PVOID *NormalContext OPTIONAL,
1101 IN OUT PVOID *SystemArgument1 OPTIONAL,
1102 IN OUT PVOID *SystemArgument2 OPTIONAL);
1103
1104 typedef struct _KAPC {
1105 UCHAR Type;
1106 UCHAR SpareByte0;
1107 UCHAR Size;
1108 UCHAR SpareByte1;
1109 ULONG SpareLong0;
1110 struct _KTHREAD *Thread;
1111 LIST_ENTRY ApcListEntry;
1112 PKKERNEL_ROUTINE KernelRoutine;
1113 PKRUNDOWN_ROUTINE RundownRoutine;
1114 PKNORMAL_ROUTINE NormalRoutine;
1115 PVOID NormalContext;
1116 PVOID SystemArgument1;
1117 PVOID SystemArgument2;
1118 CCHAR ApcStateIndex;
1119 KPROCESSOR_MODE ApcMode;
1120 BOOLEAN Inserted;
1121 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
1122
1123 #define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0)
1124 #define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1)
1125 #define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0)
1126 #define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1)
1127 #define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2)
1128 #define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex)
1129 #define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN))
1130
1131 typedef struct _KDEVICE_QUEUE_ENTRY {
1132 LIST_ENTRY DeviceListEntry;
1133 ULONG SortKey;
1134 BOOLEAN Inserted;
1135 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
1136 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
1137
1138 typedef PVOID PKIPI_CONTEXT;
1139
1140 typedef VOID
1141 (NTAPI *PKIPI_WORKER)(
1142 IN OUT PKIPI_CONTEXT PacketContext,
1143 IN PVOID Parameter1 OPTIONAL,
1144 IN PVOID Parameter2 OPTIONAL,
1145 IN PVOID Parameter3 OPTIONAL);
1146
1147 typedef struct _KIPI_COUNTS {
1148 ULONG Freeze;
1149 ULONG Packet;
1150 ULONG DPC;
1151 ULONG APC;
1152 ULONG FlushSingleTb;
1153 ULONG FlushMultipleTb;
1154 ULONG FlushEntireTb;
1155 ULONG GenericCall;
1156 ULONG ChangeColor;
1157 ULONG SweepDcache;
1158 ULONG SweepIcache;
1159 ULONG SweepIcacheRange;
1160 ULONG FlushIoBuffers;
1161 ULONG GratuitousDPC;
1162 } KIPI_COUNTS, *PKIPI_COUNTS;
1163
1164 _IRQL_requires_same_
1165 _Function_class_(KIPI_BROADCAST_WORKER)
1166 _IRQL_requires_(IPI_LEVEL)
1167 typedef ULONG_PTR
1168 (NTAPI KIPI_BROADCAST_WORKER)(
1169 _In_ ULONG_PTR Argument);
1170 typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER;
1171
1172 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
1173
1174 typedef struct _KSPIN_LOCK_QUEUE {
1175 struct _KSPIN_LOCK_QUEUE *volatile Next;
1176 PKSPIN_LOCK volatile Lock;
1177 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1178
1179 typedef struct _KLOCK_QUEUE_HANDLE {
1180 KSPIN_LOCK_QUEUE LockQueue;
1181 KIRQL OldIrql;
1182 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1183
1184 #if defined(_AMD64_)
1185
1186 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER;
1187
1188 #define LockQueueDispatcherLock 0
1189 #define LockQueueExpansionLock 1
1190 #define LockQueuePfnLock 2
1191 #define LockQueueSystemSpaceLock 3
1192 #define LockQueueVacbLock 4
1193 #define LockQueueMasterLock 5
1194 #define LockQueueNonPagedPoolLock 6
1195 #define LockQueueIoCancelLock 7
1196 #define LockQueueWorkQueueLock 8
1197 #define LockQueueIoVpbLock 9
1198 #define LockQueueIoDatabaseLock 10
1199 #define LockQueueIoCompletionLock 11
1200 #define LockQueueNtfsStructLock 12
1201 #define LockQueueAfdWorkQueueLock 13
1202 #define LockQueueBcbLock 14
1203 #define LockQueueMmNonPagedPoolLock 15
1204 #define LockQueueUnusedSpare16 16
1205 #define LockQueueTimerTableLock 17
1206 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS)
1207
1208 #else
1209
1210 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
1211 LockQueueDispatcherLock,
1212 LockQueueExpansionLock,
1213 LockQueuePfnLock,
1214 LockQueueSystemSpaceLock,
1215 LockQueueVacbLock,
1216 LockQueueMasterLock,
1217 LockQueueNonPagedPoolLock,
1218 LockQueueIoCancelLock,
1219 LockQueueWorkQueueLock,
1220 LockQueueIoVpbLock,
1221 LockQueueIoDatabaseLock,
1222 LockQueueIoCompletionLock,
1223 LockQueueNtfsStructLock,
1224 LockQueueAfdWorkQueueLock,
1225 LockQueueBcbLock,
1226 LockQueueMmNonPagedPoolLock,
1227 LockQueueUnusedSpare16,
1228 LockQueueTimerTableLock,
1229 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
1230 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
1231
1232 #endif /* defined(_AMD64_) */
1233
1234 _Function_class_(KDEFERRED_ROUTINE)
1235 _IRQL_requires_(DISPATCH_LEVEL)
1236 _IRQL_requires_same_
1237 typedef VOID
1238 (NTAPI KDEFERRED_ROUTINE)(
1239 _In_ struct _KDPC *Dpc,
1240 _In_opt_ PVOID DeferredContext,
1241 _In_opt_ PVOID SystemArgument1,
1242 _In_opt_ PVOID SystemArgument2);
1243 typedef KDEFERRED_ROUTINE *PKDEFERRED_ROUTINE;
1244
1245 typedef enum _KDPC_IMPORTANCE {
1246 LowImportance,
1247 MediumImportance,
1248 HighImportance,
1249 MediumHighImportance
1250 } KDPC_IMPORTANCE;
1251
1252 typedef struct _KDPC {
1253 UCHAR Type;
1254 UCHAR Importance;
1255 volatile USHORT Number;
1256 LIST_ENTRY DpcListEntry;
1257 PKDEFERRED_ROUTINE DeferredRoutine;
1258 PVOID DeferredContext;
1259 PVOID SystemArgument1;
1260 PVOID SystemArgument2;
1261 volatile PVOID DpcData;
1262 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
1263
1264 typedef struct _KDPC_WATCHDOG_INFORMATION {
1265 ULONG DpcTimeLimit;
1266 ULONG DpcTimeCount;
1267 ULONG DpcWatchdogLimit;
1268 ULONG DpcWatchdogCount;
1269 ULONG Reserved;
1270 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION;
1271
1272 typedef struct _KDEVICE_QUEUE {
1273 CSHORT Type;
1274 CSHORT Size;
1275 LIST_ENTRY DeviceListHead;
1276 KSPIN_LOCK Lock;
1277 # if defined(_AMD64_)
1278 _ANONYMOUS_UNION union {
1279 BOOLEAN Busy;
1280 _ANONYMOUS_STRUCT struct {
1281 LONG64 Reserved:8;
1282 LONG64 Hint:56;
1283 } DUMMYSTRUCTNAME;
1284 } DUMMYUNIONNAME;
1285 # else
1286 BOOLEAN Busy;
1287 # endif
1288 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
1289
1290 #define TIMER_EXPIRED_INDEX_BITS 6
1291 #define TIMER_PROCESSOR_INDEX_BITS 5
1292
1293 typedef struct _DISPATCHER_HEADER {
1294 _ANONYMOUS_UNION union {
1295 _ANONYMOUS_STRUCT struct {
1296 UCHAR Type;
1297 _ANONYMOUS_UNION union {
1298 _ANONYMOUS_UNION union {
1299 UCHAR TimerControlFlags;
1300 _ANONYMOUS_STRUCT struct {
1301 UCHAR Absolute:1;
1302 UCHAR Coalescable:1;
1303 UCHAR KeepShifting:1;
1304 UCHAR EncodedTolerableDelay:5;
1305 } DUMMYSTRUCTNAME;
1306 } DUMMYUNIONNAME;
1307 UCHAR Abandoned;
1308 #if (NTDDI_VERSION < NTDDI_WIN7)
1309 UCHAR NpxIrql;
1310 #endif
1311 BOOLEAN Signalling;
1312 } DUMMYUNIONNAME;
1313 _ANONYMOUS_UNION union {
1314 _ANONYMOUS_UNION union {
1315 UCHAR ThreadControlFlags;
1316 _ANONYMOUS_STRUCT struct {
1317 UCHAR CpuThrottled:1;
1318 UCHAR CycleProfiling:1;
1319 UCHAR CounterProfiling:1;
1320 UCHAR Reserved:5;
1321 } DUMMYSTRUCTNAME;
1322 } DUMMYUNIONNAME;
1323 UCHAR Size;
1324 UCHAR Hand;
1325 } DUMMYUNIONNAME2;
1326 _ANONYMOUS_UNION union {
1327 #if (NTDDI_VERSION >= NTDDI_WIN7)
1328 _ANONYMOUS_UNION union {
1329 UCHAR TimerMiscFlags;
1330 _ANONYMOUS_STRUCT struct {
1331 #if !defined(_X86_)
1332 UCHAR Index:TIMER_EXPIRED_INDEX_BITS;
1333 #else
1334 UCHAR Index:1;
1335 UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS;
1336 #endif
1337 UCHAR Inserted:1;
1338 volatile UCHAR Expired:1;
1339 } DUMMYSTRUCTNAME;
1340 } DUMMYUNIONNAME;
1341 #else
1342 /* Pre Win7 compatibility fix to latest WDK */
1343 UCHAR Inserted;
1344 #endif
1345 _ANONYMOUS_UNION union {
1346 BOOLEAN DebugActive;
1347 _ANONYMOUS_STRUCT struct {
1348 BOOLEAN ActiveDR7:1;
1349 BOOLEAN Instrumented:1;
1350 BOOLEAN Reserved2:4;
1351 BOOLEAN UmsScheduled:1;
1352 BOOLEAN UmsPrimary:1;
1353 } DUMMYSTRUCTNAME;
1354 } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */
1355 BOOLEAN DpcActive;
1356 } DUMMYUNIONNAME3;
1357 } DUMMYSTRUCTNAME;
1358 volatile LONG Lock;
1359 } DUMMYUNIONNAME;
1360 LONG SignalState;
1361 LIST_ENTRY WaitListHead;
1362 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
1363
1364 typedef struct _KEVENT {
1365 DISPATCHER_HEADER Header;
1366 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
1367
1368 typedef struct _KSEMAPHORE {
1369 DISPATCHER_HEADER Header;
1370 LONG Limit;
1371 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
1372
1373 #define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG))
1374
1375 typedef struct _KGATE {
1376 DISPATCHER_HEADER Header;
1377 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1378
1379 typedef struct _KGUARDED_MUTEX {
1380 volatile LONG Count;
1381 PKTHREAD Owner;
1382 ULONG Contention;
1383 KGATE Gate;
1384 _ANONYMOUS_UNION union {
1385 _ANONYMOUS_STRUCT struct {
1386 SHORT KernelApcDisable;
1387 SHORT SpecialApcDisable;
1388 } DUMMYSTRUCTNAME;
1389 ULONG CombinedApcDisable;
1390 } DUMMYUNIONNAME;
1391 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
1392
1393 typedef struct _KMUTANT {
1394 DISPATCHER_HEADER Header;
1395 LIST_ENTRY MutantListEntry;
1396 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1397 BOOLEAN Abandoned;
1398 UCHAR ApcDisable;
1399 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1400
1401 #define TIMER_TABLE_SIZE 512
1402 #define TIMER_TABLE_SHIFT 9
1403
1404 typedef struct _KTIMER {
1405 DISPATCHER_HEADER Header;
1406 ULARGE_INTEGER DueTime;
1407 LIST_ENTRY TimerListEntry;
1408 struct _KDPC *Dpc;
1409 #if (NTDDI_VERSION >= NTDDI_WIN7) && !defined(_X86_)
1410 ULONG Processor;
1411 #endif
1412 ULONG Period;
1413 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1414
1415 typedef enum _LOCK_OPERATION {
1416 IoReadAccess,
1417 IoWriteAccess,
1418 IoModifyAccess
1419 } LOCK_OPERATION;
1420
1421 #define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG))
1422
1423 _Function_class_(KSYNCHRONIZE_ROUTINE)
1424 _IRQL_requires_same_
1425 typedef BOOLEAN
1426 (NTAPI KSYNCHRONIZE_ROUTINE)(
1427 _In_ PVOID SynchronizeContext);
1428 typedef KSYNCHRONIZE_ROUTINE *PKSYNCHRONIZE_ROUTINE;
1429
1430 typedef enum _POOL_TYPE {
1431 NonPagedPool,
1432 PagedPool,
1433 NonPagedPoolMustSucceed,
1434 DontUseThisType,
1435 NonPagedPoolCacheAligned,
1436 PagedPoolCacheAligned,
1437 NonPagedPoolCacheAlignedMustS,
1438 MaxPoolType,
1439 NonPagedPoolSession = 32,
1440 PagedPoolSession,
1441 NonPagedPoolMustSucceedSession,
1442 DontUseThisTypeSession,
1443 NonPagedPoolCacheAlignedSession,
1444 PagedPoolCacheAlignedSession,
1445 NonPagedPoolCacheAlignedMustSSession
1446 } POOL_TYPE;
1447
1448 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
1449 StandardDesign,
1450 NEC98x86,
1451 EndAlternatives
1452 } ALTERNATIVE_ARCHITECTURE_TYPE;
1453
1454 #ifndef _X86_
1455
1456 #ifndef IsNEC_98
1457 #define IsNEC_98 (FALSE)
1458 #endif
1459
1460 #ifndef IsNotNEC_98
1461 #define IsNotNEC_98 (TRUE)
1462 #endif
1463
1464 #ifndef SetNEC_98
1465 #define SetNEC_98
1466 #endif
1467
1468 #ifndef SetNotNEC_98
1469 #define SetNotNEC_98
1470 #endif
1471
1472 #endif
1473
1474 typedef struct _KSYSTEM_TIME {
1475 ULONG LowPart;
1476 LONG High1Time;
1477 LONG High2Time;
1478 } KSYSTEM_TIME, *PKSYSTEM_TIME;
1479
1480 typedef struct DECLSPEC_ALIGN(16) _M128A {
1481 ULONGLONG Low;
1482 LONGLONG High;
1483 } M128A, *PM128A;
1484
1485 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
1486 USHORT ControlWord;
1487 USHORT StatusWord;
1488 UCHAR TagWord;
1489 UCHAR Reserved1;
1490 USHORT ErrorOpcode;
1491 ULONG ErrorOffset;
1492 USHORT ErrorSelector;
1493 USHORT Reserved2;
1494 ULONG DataOffset;
1495 USHORT DataSelector;
1496 USHORT Reserved3;
1497 ULONG MxCsr;
1498 ULONG MxCsr_Mask;
1499 M128A FloatRegisters[8];
1500 #if defined(_WIN64)
1501 M128A XmmRegisters[16];
1502 UCHAR Reserved4[96];
1503 #else
1504 M128A XmmRegisters[8];
1505 UCHAR Reserved4[192];
1506 ULONG StackControl[7];
1507 ULONG Cr0NpxState;
1508 #endif
1509 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1510
1511 typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER {
1512 ULONG64 Mask;
1513 ULONG64 Reserved[7];
1514 } XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER;
1515
1516 typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA {
1517 XSAVE_FORMAT LegacyState;
1518 XSAVE_AREA_HEADER Header;
1519 } XSAVE_AREA, *PXSAVE_AREA;
1520
1521 typedef struct _XSTATE_CONTEXT {
1522 ULONG64 Mask;
1523 ULONG Length;
1524 ULONG Reserved1;
1525 _Field_size_bytes_opt_(Length) PXSAVE_AREA Area;
1526 #if defined(_X86_)
1527 ULONG Reserved2;
1528 #endif
1529 PVOID Buffer;
1530 #if defined(_X86_)
1531 ULONG Reserved3;
1532 #endif
1533 } XSTATE_CONTEXT, *PXSTATE_CONTEXT;
1534
1535 typedef struct _XSTATE_SAVE {
1536 #if defined(_AMD64_)
1537 struct _XSTATE_SAVE* Prev;
1538 struct _KTHREAD* Thread;
1539 UCHAR Level;
1540 XSTATE_CONTEXT XStateContext;
1541 #elif defined(_IA64_)
1542 ULONG Dummy;
1543 #elif defined(_X86_)
1544 _ANONYMOUS_UNION union {
1545 _ANONYMOUS_STRUCT struct {
1546 LONG64 Reserved1;
1547 ULONG Reserved2;
1548 struct _XSTATE_SAVE* Prev;
1549 PXSAVE_AREA Reserved3;
1550 struct _KTHREAD* Thread;
1551 PVOID Reserved4;
1552 UCHAR Level;
1553 } DUMMYSTRUCTNAME;
1554 XSTATE_CONTEXT XStateContext;
1555 } DUMMYUNIONNAME;
1556 #endif
1557 } XSTATE_SAVE, *PXSTATE_SAVE;
1558
1559 #ifdef _X86_
1560
1561 #define MAXIMUM_SUPPORTED_EXTENSION 512
1562
1563 #if !defined(__midl) && !defined(MIDL_PASS)
1564 C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION);
1565 #endif
1566
1567 #endif /* _X86_ */
1568
1569 #define XSAVE_ALIGN 64
1570 #define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA)
1571
1572 #if !defined(__midl) && !defined(MIDL_PASS)
1573 C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0);
1574 C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0);
1575 C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64);
1576 #endif
1577
1578 typedef struct _CONTEXT_CHUNK {
1579 LONG Offset;
1580 ULONG Length;
1581 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
1582
1583 typedef struct _CONTEXT_EX {
1584 CONTEXT_CHUNK All;
1585 CONTEXT_CHUNK Legacy;
1586 CONTEXT_CHUNK XState;
1587 } CONTEXT_EX, *PCONTEXT_EX;
1588
1589 #define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN)
1590
1591 #if (NTDDI_VERSION >= NTDDI_VISTA)
1592 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
1593 #elif (NTDDI_VERSION >= NTDDI_WINXP)
1594 extern NTSYSAPI CCHAR KeNumberProcessors;
1595 #else
1596 extern PCCHAR KeNumberProcessors;
1597 #endif
1598
1599
1600 /******************************************************************************
1601 * Memory manager Types *
1602 ******************************************************************************/
1603
1604 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1605 typedef ULONG NODE_REQUIREMENT;
1606 #define MM_ANY_NODE_OK 0x80000000
1607 #endif
1608
1609 #define MM_DONT_ZERO_ALLOCATION 0x00000001
1610 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
1611 #define MM_ALLOCATE_FULLY_REQUIRED 0x00000004
1612 #define MM_ALLOCATE_NO_WAIT 0x00000008
1613 #define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010
1614 #define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020
1615
1616 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
1617 #define MDL_PAGES_LOCKED 0x0002
1618 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
1619 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
1620 #define MDL_PARTIAL 0x0010
1621 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
1622 #define MDL_IO_PAGE_READ 0x0040
1623 #define MDL_WRITE_OPERATION 0x0080
1624 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
1625 #define MDL_FREE_EXTRA_PTES 0x0200
1626 #define MDL_DESCRIBES_AWE 0x0400
1627 #define MDL_IO_SPACE 0x0800
1628 #define MDL_NETWORK_HEADER 0x1000
1629 #define MDL_MAPPING_CAN_FAIL 0x2000
1630 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
1631 #define MDL_INTERNAL 0x8000
1632
1633 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
1634 MDL_PAGES_LOCKED | \
1635 MDL_SOURCE_IS_NONPAGED_POOL | \
1636 MDL_PARTIAL_HAS_BEEN_MAPPED | \
1637 MDL_PARENT_MAPPED_SYSTEM_VA | \
1638 MDL_SYSTEM_VA | \
1639 MDL_IO_SPACE)
1640
1641 #define FLUSH_MULTIPLE_MAXIMUM 32
1642
1643 /* Section access rights */
1644 #define SECTION_QUERY 0x0001
1645 #define SECTION_MAP_WRITE 0x0002
1646 #define SECTION_MAP_READ 0x0004
1647 #define SECTION_MAP_EXECUTE 0x0008
1648 #define SECTION_EXTEND_SIZE 0x0010
1649 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
1650
1651 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| \
1652 SECTION_MAP_WRITE | \
1653 SECTION_MAP_READ | \
1654 SECTION_MAP_EXECUTE | \
1655 SECTION_EXTEND_SIZE)
1656
1657 #define SESSION_QUERY_ACCESS 0x0001
1658 #define SESSION_MODIFY_ACCESS 0x0002
1659
1660 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
1661 SESSION_QUERY_ACCESS | \
1662 SESSION_MODIFY_ACCESS)
1663
1664 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
1665
1666 #define PAGE_NOACCESS 0x01
1667 #define PAGE_READONLY 0x02
1668 #define PAGE_READWRITE 0x04
1669 #define PAGE_WRITECOPY 0x08
1670 #define PAGE_EXECUTE 0x10
1671 #define PAGE_EXECUTE_READ 0x20
1672 #define PAGE_EXECUTE_READWRITE 0x40
1673 #define PAGE_EXECUTE_WRITECOPY 0x80
1674 #define PAGE_GUARD 0x100
1675 #define PAGE_NOCACHE 0x200
1676 #define PAGE_WRITECOMBINE 0x400
1677
1678 #define MEM_COMMIT 0x1000
1679 #define MEM_RESERVE 0x2000
1680 #define MEM_DECOMMIT 0x4000
1681 #define MEM_RELEASE 0x8000
1682 #define MEM_FREE 0x10000
1683 #define MEM_PRIVATE 0x20000
1684 #define MEM_MAPPED 0x40000
1685 #define MEM_RESET 0x80000
1686 #define MEM_TOP_DOWN 0x100000
1687 #define MEM_LARGE_PAGES 0x20000000
1688 #define MEM_4MB_PAGES 0x80000000
1689
1690 #define SEC_RESERVE 0x4000000
1691 #define SEC_COMMIT 0x8000000
1692 #define SEC_LARGE_PAGES 0x80000000
1693
1694 /* Section map options */
1695 typedef enum _SECTION_INHERIT {
1696 ViewShare = 1,
1697 ViewUnmap = 2
1698 } SECTION_INHERIT;
1699
1700 typedef ULONG PFN_COUNT;
1701 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
1702 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
1703
1704 _Struct_size_bytes_(_Inexpressible_(sizeof(struct _MDL) +
1705 (ByteOffset + ByteCount + PAGE_SIZE-1) / PAGE_SIZE * sizeof(PFN_NUMBER)))
1706 typedef struct _MDL {
1707 struct _MDL *Next;
1708 CSHORT Size;
1709 CSHORT MdlFlags;
1710 struct _EPROCESS *Process;
1711 PVOID MappedSystemVa;
1712 PVOID StartVa;
1713 ULONG ByteCount;
1714 ULONG ByteOffset;
1715 } MDL, *PMDL;
1716 #if (_MSC_VER >= 1600)
1717 typedef _Readable_bytes_(_Inexpressible_(polymorphism)) MDL *PMDLX;
1718 #else
1719 typedef MDL *PMDLX;
1720 #endif
1721
1722 typedef enum _MEMORY_CACHING_TYPE_ORIG {
1723 MmFrameBufferCached = 2
1724 } MEMORY_CACHING_TYPE_ORIG;
1725
1726 typedef enum _MEMORY_CACHING_TYPE {
1727 MmNonCached = FALSE,
1728 MmCached = TRUE,
1729 MmWriteCombined = MmFrameBufferCached,
1730 MmHardwareCoherentCached,
1731 MmNonCachedUnordered,
1732 MmUSWCCached,
1733 MmMaximumCacheType
1734 } MEMORY_CACHING_TYPE;
1735
1736 typedef enum _MM_PAGE_PRIORITY {
1737 LowPagePriority,
1738 NormalPagePriority = 16,
1739 HighPagePriority = 32
1740 } MM_PAGE_PRIORITY;
1741
1742 typedef enum _MM_SYSTEM_SIZE {
1743 MmSmallSystem,
1744 MmMediumSystem,
1745 MmLargeSystem
1746 } MM_SYSTEMSIZE;
1747
1748 extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress;
1749 extern PVOID MmBadPointer;
1750
1751
1752 /******************************************************************************
1753 * Executive Types *
1754 ******************************************************************************/
1755 #define EX_RUNDOWN_ACTIVE 0x1
1756 #define EX_RUNDOWN_COUNT_SHIFT 0x1
1757 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT)
1758
1759 typedef struct _FAST_MUTEX {
1760 volatile LONG Count;
1761 PKTHREAD Owner;
1762 ULONG Contention;
1763 KEVENT Event;
1764 ULONG OldIrql;
1765 } FAST_MUTEX, *PFAST_MUTEX;
1766
1767 typedef enum _SUITE_TYPE {
1768 SmallBusiness,
1769 Enterprise,
1770 BackOffice,
1771 CommunicationServer,
1772 TerminalServer,
1773 SmallBusinessRestricted,
1774 EmbeddedNT,
1775 DataCenter,
1776 SingleUserTS,
1777 Personal,
1778 Blade,
1779 EmbeddedRestricted,
1780 SecurityAppliance,
1781 StorageServer,
1782 ComputeServer,
1783 WHServer,
1784 MaxSuiteType
1785 } SUITE_TYPE;
1786
1787 typedef enum _EX_POOL_PRIORITY {
1788 LowPoolPriority,
1789 LowPoolPrioritySpecialPoolOverrun = 8,
1790 LowPoolPrioritySpecialPoolUnderrun = 9,
1791 NormalPoolPriority = 16,
1792 NormalPoolPrioritySpecialPoolOverrun = 24,
1793 NormalPoolPrioritySpecialPoolUnderrun = 25,
1794 HighPoolPriority = 32,
1795 HighPoolPrioritySpecialPoolOverrun = 40,
1796 HighPoolPrioritySpecialPoolUnderrun = 41
1797 } EX_POOL_PRIORITY;
1798
1799 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
1800 #define LOOKASIDE_ALIGN
1801 #else
1802 #define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */
1803 #endif
1804
1805 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
1806
1807 _IRQL_requires_same_
1808 _Function_class_(ALLOCATE_FUNCTION)
1809 typedef PVOID
1810 (NTAPI *PALLOCATE_FUNCTION)(
1811 _In_ POOL_TYPE PoolType,
1812 _In_ SIZE_T NumberOfBytes,
1813 _In_ ULONG Tag);
1814
1815 _IRQL_requires_same_
1816 _Function_class_(ALLOCATE_FUNCTION_EX)
1817 typedef PVOID
1818 (NTAPI *PALLOCATE_FUNCTION_EX)(
1819 _In_ POOL_TYPE PoolType,
1820 _In_ SIZE_T NumberOfBytes,
1821 _In_ ULONG Tag,
1822 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
1823
1824 _IRQL_requires_same_
1825 _Function_class_(FREE_FUNCTION)
1826 typedef VOID
1827 (NTAPI *PFREE_FUNCTION)(
1828 _In_ PVOID Buffer);
1829
1830 _IRQL_requires_same_
1831 _Function_class_(FREE_FUNCTION_EX)
1832 typedef VOID
1833 (NTAPI *PFREE_FUNCTION_EX)(
1834 _In_ PVOID Buffer,
1835 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
1836
1837 _IRQL_requires_same_
1838 _Function_class_(CALLBACK_FUNCTION)
1839 typedef VOID
1840 (NTAPI CALLBACK_FUNCTION)(
1841 _In_opt_ PVOID CallbackContext,
1842 _In_opt_ PVOID Argument1,
1843 _In_opt_ PVOID Argument2);
1844 typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION;
1845
1846 #define GENERAL_LOOKASIDE_LAYOUT \
1847 _ANONYMOUS_UNION union { \
1848 SLIST_HEADER ListHead; \
1849 SINGLE_LIST_ENTRY SingleListHead; \
1850 } DUMMYUNIONNAME; \
1851 USHORT Depth; \
1852 USHORT MaximumDepth; \
1853 ULONG TotalAllocates; \
1854 _ANONYMOUS_UNION union { \
1855 ULONG AllocateMisses; \
1856 ULONG AllocateHits; \
1857 } DUMMYUNIONNAME2; \
1858 ULONG TotalFrees; \
1859 _ANONYMOUS_UNION union { \
1860 ULONG FreeMisses; \
1861 ULONG FreeHits; \
1862 } DUMMYUNIONNAME3; \
1863 POOL_TYPE Type; \
1864 ULONG Tag; \
1865 ULONG Size; \
1866 _ANONYMOUS_UNION union { \
1867 PALLOCATE_FUNCTION_EX AllocateEx; \
1868 PALLOCATE_FUNCTION Allocate; \
1869 } DUMMYUNIONNAME4; \
1870 _ANONYMOUS_UNION union { \
1871 PFREE_FUNCTION_EX FreeEx; \
1872 PFREE_FUNCTION Free; \
1873 } DUMMYUNIONNAME5; \
1874 LIST_ENTRY ListEntry; \
1875 ULONG LastTotalAllocates; \
1876 _ANONYMOUS_UNION union { \
1877 ULONG LastAllocateMisses; \
1878 ULONG LastAllocateHits; \
1879 } DUMMYUNIONNAME6; \
1880 ULONG Future[2];
1881
1882 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
1883 GENERAL_LOOKASIDE_LAYOUT
1884 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
1885
1886 typedef struct _GENERAL_LOOKASIDE_POOL {
1887 GENERAL_LOOKASIDE_LAYOUT
1888 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
1889
1890 #define LOOKASIDE_CHECK(f) \
1891 C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f))
1892
1893 LOOKASIDE_CHECK(TotalFrees);
1894 LOOKASIDE_CHECK(Tag);
1895 LOOKASIDE_CHECK(Future);
1896
1897 typedef struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST {
1898 GENERAL_LOOKASIDE L;
1899 #if !defined(_AMD64_) && !defined(_IA64_)
1900 FAST_MUTEX Lock__ObsoleteButDoNotDelete;
1901 #endif
1902 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
1903
1904 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
1905 GENERAL_LOOKASIDE L;
1906 #if !defined(_AMD64_) && !defined(_IA64_)
1907 KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
1908 #endif
1909 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
1910
1911 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next))
1912
1913 typedef struct _LOOKASIDE_LIST_EX {
1914 GENERAL_LOOKASIDE_POOL L;
1915 } LOOKASIDE_LIST_EX;
1916
1917 #if (NTDDI_VERSION >= NTDDI_VISTA)
1918
1919 #define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL
1920 #define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL
1921
1922 #define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256
1923 #define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024
1924
1925 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1926
1927 typedef struct _EX_RUNDOWN_REF {
1928 _ANONYMOUS_UNION union {
1929 volatile ULONG_PTR Count;
1930 volatile PVOID Ptr;
1931 } DUMMYUNIONNAME;
1932 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
1933
1934 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE;
1935
1936 typedef enum _WORK_QUEUE_TYPE {
1937 CriticalWorkQueue,
1938 DelayedWorkQueue,
1939 HyperCriticalWorkQueue,
1940 MaximumWorkQueue
1941 } WORK_QUEUE_TYPE;
1942
1943 _IRQL_requires_same_
1944 _Function_class_(WORKER_THREAD_ROUTINE)
1945 typedef VOID
1946 (NTAPI WORKER_THREAD_ROUTINE)(
1947 _In_ PVOID Parameter);
1948 typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE;
1949
1950 typedef struct _WORK_QUEUE_ITEM {
1951 LIST_ENTRY List;
1952 PWORKER_THREAD_ROUTINE WorkerRoutine;
1953 volatile PVOID Parameter;
1954 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
1955
1956 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
1957
1958 typedef struct _OWNER_ENTRY {
1959 ERESOURCE_THREAD OwnerThread;
1960 _ANONYMOUS_UNION union {
1961 _ANONYMOUS_STRUCT struct {
1962 ULONG IoPriorityBoosted:1;
1963 ULONG OwnerReferenced:1;
1964 ULONG OwnerCount:30;
1965 } DUMMYSTRUCTNAME;
1966 ULONG TableSize;
1967 } DUMMYUNIONNAME;
1968 } OWNER_ENTRY, *POWNER_ENTRY;
1969
1970 typedef struct _ERESOURCE {
1971 LIST_ENTRY SystemResourcesList;
1972 POWNER_ENTRY OwnerTable;
1973 SHORT ActiveCount;
1974 USHORT Flag;
1975 volatile PKSEMAPHORE SharedWaiters;
1976 volatile PKEVENT ExclusiveWaiters;
1977 OWNER_ENTRY OwnerEntry;
1978 ULONG ActiveEntries;
1979 ULONG ContentionCount;
1980 ULONG NumberOfSharedWaiters;
1981 ULONG NumberOfExclusiveWaiters;
1982 #if defined(_WIN64)
1983 PVOID Reserved2;
1984 #endif
1985 _ANONYMOUS_UNION union {
1986 PVOID Address;
1987 ULONG_PTR CreatorBackTraceIndex;
1988 } DUMMYUNIONNAME;
1989 KSPIN_LOCK SpinLock;
1990 } ERESOURCE, *PERESOURCE;
1991
1992 /* ERESOURCE.Flag */
1993 #define ResourceNeverExclusive 0x0010
1994 #define ResourceReleaseByOtherThread 0x0020
1995 #define ResourceOwnedExclusive 0x0080
1996
1997 #define RESOURCE_HASH_TABLE_SIZE 64
1998
1999 typedef struct _RESOURCE_HASH_ENTRY {
2000 LIST_ENTRY ListEntry;
2001 PVOID Address;
2002 ULONG ContentionCount;
2003 ULONG Number;
2004 } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY;
2005
2006 typedef struct _RESOURCE_PERFORMANCE_DATA {
2007 ULONG ActiveResourceCount;
2008 ULONG TotalResourceCount;
2009 ULONG ExclusiveAcquire;
2010 ULONG SharedFirstLevel;
2011 ULONG SharedSecondLevel;
2012 ULONG StarveFirstLevel;
2013 ULONG StarveSecondLevel;
2014 ULONG WaitForExclusive;
2015 ULONG OwnerTableExpands;
2016 ULONG MaximumTableExpand;
2017 LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE];
2018 } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA;
2019
2020 /* Global debug flag */
2021 #if DEVL
2022 extern ULONG NtGlobalFlag;
2023 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName))
2024 #else
2025 #define IF_NTOS_DEBUG(FlagName) if(FALSE)
2026 #endif
2027
2028 /******************************************************************************
2029 * Security Manager Types *
2030 ******************************************************************************/
2031
2032 /* Simple types */
2033 typedef PVOID PSECURITY_DESCRIPTOR;
2034 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2035 typedef ULONG ACCESS_MASK, *PACCESS_MASK;
2036 typedef PVOID PACCESS_TOKEN;
2037 typedef PVOID PSID;
2038
2039 #define DELETE 0x00010000L
2040 #define READ_CONTROL 0x00020000L
2041 #define WRITE_DAC 0x00040000L
2042 #define WRITE_OWNER 0x00080000L
2043 #define SYNCHRONIZE 0x00100000L
2044 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L
2045 #define STANDARD_RIGHTS_READ READ_CONTROL
2046 #define STANDARD_RIGHTS_WRITE READ_CONTROL
2047 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
2048 #define STANDARD_RIGHTS_ALL 0x001F0000L
2049 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL
2050 #define ACCESS_SYSTEM_SECURITY 0x01000000L
2051 #define MAXIMUM_ALLOWED 0x02000000L
2052 #define GENERIC_READ 0x80000000L
2053 #define GENERIC_WRITE 0x40000000L
2054 #define GENERIC_EXECUTE 0x20000000L
2055 #define GENERIC_ALL 0x10000000L
2056
2057 typedef struct _GENERIC_MAPPING {
2058 ACCESS_MASK GenericRead;
2059 ACCESS_MASK GenericWrite;
2060 ACCESS_MASK GenericExecute;
2061 ACCESS_MASK GenericAll;
2062 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2063
2064 #define ACL_REVISION 2
2065 #define ACL_REVISION_DS 4
2066
2067 #define ACL_REVISION1 1
2068 #define ACL_REVISION2 2
2069 #define ACL_REVISION3 3
2070 #define ACL_REVISION4 4
2071 #define MIN_ACL_REVISION ACL_REVISION2
2072 #define MAX_ACL_REVISION ACL_REVISION4
2073
2074 typedef struct _ACL {
2075 UCHAR AclRevision;
2076 UCHAR Sbz1;
2077 USHORT AclSize;
2078 USHORT AceCount;
2079 USHORT Sbz2;
2080 } ACL, *PACL;
2081
2082 /* Current security descriptor revision value */
2083 #define SECURITY_DESCRIPTOR_REVISION (1)
2084 #define SECURITY_DESCRIPTOR_REVISION1 (1)
2085
2086 /* Privilege attributes */
2087 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
2088 #define SE_PRIVILEGE_ENABLED (0x00000002L)
2089 #define SE_PRIVILEGE_REMOVED (0X00000004L)
2090 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
2091
2092 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
2093 SE_PRIVILEGE_ENABLED | \
2094 SE_PRIVILEGE_REMOVED | \
2095 SE_PRIVILEGE_USED_FOR_ACCESS)
2096
2097 #include <pshpack4.h>
2098 typedef struct _LUID_AND_ATTRIBUTES {
2099 LUID Luid;
2100 ULONG Attributes;
2101 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
2102 #include <poppack.h>
2103
2104 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
2105 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
2106
2107 /* Privilege sets */
2108 #define PRIVILEGE_SET_ALL_NECESSARY (1)
2109
2110 typedef struct _PRIVILEGE_SET {
2111 ULONG PrivilegeCount;
2112 ULONG Control;
2113 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2114 } PRIVILEGE_SET,*PPRIVILEGE_SET;
2115
2116 typedef enum _SECURITY_IMPERSONATION_LEVEL {
2117 SecurityAnonymous,
2118 SecurityIdentification,
2119 SecurityImpersonation,
2120 SecurityDelegation
2121 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
2122
2123 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
2124 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
2125 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
2126 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
2127
2128 #define SECURITY_DYNAMIC_TRACKING (TRUE)
2129 #define SECURITY_STATIC_TRACKING (FALSE)
2130
2131 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
2132
2133 typedef struct _SECURITY_QUALITY_OF_SERVICE {
2134 ULONG Length;
2135 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2136 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
2137 BOOLEAN EffectiveOnly;
2138 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
2139
2140 typedef struct _SE_IMPERSONATION_STATE {
2141 PACCESS_TOKEN Token;
2142 BOOLEAN CopyOnOpen;
2143 BOOLEAN EffectiveOnly;
2144 SECURITY_IMPERSONATION_LEVEL Level;
2145 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
2146
2147 #define OWNER_SECURITY_INFORMATION (0x00000001L)
2148 #define GROUP_SECURITY_INFORMATION (0x00000002L)
2149 #define DACL_SECURITY_INFORMATION (0x00000004L)
2150 #define SACL_SECURITY_INFORMATION (0x00000008L)
2151 #define LABEL_SECURITY_INFORMATION (0x00000010L)
2152
2153 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
2154 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
2155 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
2156 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
2157
2158 typedef enum _SECURITY_OPERATION_CODE {
2159 SetSecurityDescriptor,
2160 QuerySecurityDescriptor,
2161 DeleteSecurityDescriptor,
2162 AssignSecurityDescriptor
2163 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
2164
2165 #define INITIAL_PRIVILEGE_COUNT 3
2166
2167 typedef struct _INITIAL_PRIVILEGE_SET {
2168 ULONG PrivilegeCount;
2169 ULONG Control;
2170 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
2171 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
2172
2173 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
2174 #define SE_CREATE_TOKEN_PRIVILEGE 2
2175 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
2176 #define SE_LOCK_MEMORY_PRIVILEGE 4
2177 #define SE_INCREASE_QUOTA_PRIVILEGE 5
2178 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
2179 #define SE_TCB_PRIVILEGE 7
2180 #define SE_SECURITY_PRIVILEGE 8
2181 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
2182 #define SE_LOAD_DRIVER_PRIVILEGE 10
2183 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
2184 #define SE_SYSTEMTIME_PRIVILEGE 12
2185 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
2186 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
2187 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
2188 #define SE_CREATE_PERMANENT_PRIVILEGE 16
2189 #define SE_BACKUP_PRIVILEGE 17
2190 #define SE_RESTORE_PRIVILEGE 18
2191 #define SE_SHUTDOWN_PRIVILEGE 19
2192 #define SE_DEBUG_PRIVILEGE 20
2193 #define SE_AUDIT_PRIVILEGE 21
2194 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
2195 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
2196 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
2197 #define SE_UNDOCK_PRIVILEGE 25
2198 #define SE_SYNC_AGENT_PRIVILEGE 26
2199 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
2200 #define SE_MANAGE_VOLUME_PRIVILEGE 28
2201 #define SE_IMPERSONATE_PRIVILEGE 29
2202 #define SE_CREATE_GLOBAL_PRIVILEGE 30
2203 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
2204 #define SE_RELABEL_PRIVILEGE 32
2205 #define SE_INC_WORKING_SET_PRIVILEGE 33
2206 #define SE_TIME_ZONE_PRIVILEGE 34
2207 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35
2208 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
2209
2210 typedef struct _SECURITY_SUBJECT_CONTEXT {
2211 PACCESS_TOKEN ClientToken;
2212 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2213 PACCESS_TOKEN PrimaryToken;
2214 PVOID ProcessAuditId;
2215 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
2216
2217 typedef struct _ACCESS_STATE {
2218 LUID OperationID;
2219 BOOLEAN SecurityEvaluated;
2220 BOOLEAN GenerateAudit;
2221 BOOLEAN GenerateOnClose;
2222 BOOLEAN PrivilegesAllocated;
2223 ULONG Flags;
2224 ACCESS_MASK RemainingDesiredAccess;
2225 ACCESS_MASK PreviouslyGrantedAccess;
2226 ACCESS_MASK OriginalDesiredAccess;
2227 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
2228 PSECURITY_DESCRIPTOR SecurityDescriptor;
2229 PVOID AuxData;
2230 union {
2231 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
2232 PRIVILEGE_SET PrivilegeSet;
2233 } Privileges;
2234 BOOLEAN AuditPrivileges;
2235 UNICODE_STRING ObjectName;
2236 UNICODE_STRING ObjectTypeName;
2237 } ACCESS_STATE, *PACCESS_STATE;
2238
2239 typedef VOID
2240 (NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)(
2241 _In_ PVOID Vcb,
2242 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
2243
2244 #ifndef _NTLSA_IFS_
2245
2246 #ifndef _NTLSA_AUDIT_
2247 #define _NTLSA_AUDIT_
2248
2249 #define SE_MAX_AUDIT_PARAMETERS 32
2250 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
2251
2252 #define SE_ADT_OBJECT_ONLY 0x1
2253
2254 #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001
2255 #define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002
2256 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004
2257 #define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008
2258 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
2259
2260 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
2261 ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
2262 (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
2263
2264 typedef enum _SE_ADT_PARAMETER_TYPE {
2265 SeAdtParmTypeNone = 0,
2266 SeAdtParmTypeString,
2267 SeAdtParmTypeFileSpec,
2268 SeAdtParmTypeUlong,
2269 SeAdtParmTypeSid,
2270 SeAdtParmTypeLogonId,
2271 SeAdtParmTypeNoLogonId,
2272 SeAdtParmTypeAccessMask,
2273 SeAdtParmTypePrivs,
2274 SeAdtParmTypeObjectTypes,
2275 SeAdtParmTypeHexUlong,
2276 SeAdtParmTypePtr,
2277 SeAdtParmTypeTime,
2278 SeAdtParmTypeGuid,
2279 SeAdtParmTypeLuid,
2280 SeAdtParmTypeHexInt64,
2281 SeAdtParmTypeStringList,
2282 SeAdtParmTypeSidList,
2283 SeAdtParmTypeDuration,
2284 SeAdtParmTypeUserAccountControl,
2285 SeAdtParmTypeNoUac,
2286 SeAdtParmTypeMessage,
2287 SeAdtParmTypeDateTime,
2288 SeAdtParmTypeSockAddr,
2289 SeAdtParmTypeSD,
2290 SeAdtParmTypeLogonHours,
2291 SeAdtParmTypeLogonIdNoSid,
2292 SeAdtParmTypeUlongNoConv,
2293 SeAdtParmTypeSockAddrNoPort,
2294 SeAdtParmTypeAccessReason
2295 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
2296
2297 typedef struct _SE_ADT_OBJECT_TYPE {
2298 GUID ObjectType;
2299 USHORT Flags;
2300 USHORT Level;
2301 ACCESS_MASK AccessMask;
2302 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
2303
2304 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
2305 SE_ADT_PARAMETER_TYPE Type;
2306 ULONG Length;
2307 ULONG_PTR Data[2];
2308 PVOID Address;
2309 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
2310
2311 typedef struct _SE_ADT_ACCESS_REASON {
2312 ACCESS_MASK AccessMask;
2313 ULONG AccessReasons[32];
2314 ULONG ObjectTypeIndex;
2315 ULONG AccessGranted;
2316 PSECURITY_DESCRIPTOR SecurityDescriptor;
2317 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
2318
2319 typedef struct _SE_ADT_PARAMETER_ARRAY {
2320 ULONG CategoryId;
2321 ULONG AuditId;
2322 ULONG ParameterCount;
2323 ULONG Length;
2324 USHORT FlatSubCategoryId;
2325 USHORT Type;
2326 ULONG Flags;
2327 SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
2328 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
2329
2330 #endif /* !_NTLSA_AUDIT_ */
2331 #endif /* !_NTLSA_IFS_ */
2332 /******************************************************************************
2333 * Power Management Support Types *
2334 ******************************************************************************/
2335
2336 #ifndef _PO_DDK_
2337 #define _PO_DDK_
2338
2339 #define PO_CB_SYSTEM_POWER_POLICY 0
2340 #define PO_CB_AC_STATUS 1
2341 #define PO_CB_BUTTON_COLLISION 2
2342 #define PO_CB_SYSTEM_STATE_LOCK 3
2343 #define PO_CB_LID_SWITCH_STATE 4
2344 #define PO_CB_PROCESSOR_POWER_POLICY 5
2345
2346 /* Power States/Levels */
2347 typedef enum _SYSTEM_POWER_STATE {
2348 PowerSystemUnspecified = 0,
2349 PowerSystemWorking,
2350 PowerSystemSleeping1,
2351 PowerSystemSleeping2,
2352 PowerSystemSleeping3,
2353 PowerSystemHibernate,
2354 PowerSystemShutdown,
2355 PowerSystemMaximum
2356 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
2357
2358 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
2359
2360 typedef enum _POWER_INFORMATION_LEVEL {
2361 SystemPowerPolicyAc,
2362 SystemPowerPolicyDc,
2363 VerifySystemPolicyAc,
2364 VerifySystemPolicyDc,
2365 SystemPowerCapabilities,
2366 SystemBatteryState,
2367 SystemPowerStateHandler,
2368 ProcessorStateHandler,
2369 SystemPowerPolicyCurrent,
2370 AdministratorPowerPolicy,
2371 SystemReserveHiberFile,
2372 ProcessorInformation,
2373 SystemPowerInformation,
2374 ProcessorStateHandler2,
2375 LastWakeTime,
2376 LastSleepTime,
2377 SystemExecutionState,
2378 SystemPowerStateNotifyHandler,
2379 ProcessorPowerPolicyAc,
2380 ProcessorPowerPolicyDc,
2381 VerifyProcessorPowerPolicyAc,
2382 VerifyProcessorPowerPolicyDc,
2383 ProcessorPowerPolicyCurrent,
2384 SystemPowerStateLogging,
2385 SystemPowerLoggingEntry,
2386 SetPowerSettingValue,
2387 NotifyUserPowerSetting,
2388 PowerInformationLevelUnused0,
2389 PowerInformationLevelUnused1,
2390 SystemVideoState,
2391 TraceApplicationPowerMessage,
2392 TraceApplicationPowerMessageEnd,
2393 ProcessorPerfStates,
2394 ProcessorIdleStates,
2395 ProcessorCap,
2396 SystemWakeSource,
2397 SystemHiberFileInformation,
2398 TraceServicePowerMessage,
2399 ProcessorLoad,
2400 PowerShutdownNotification,
2401 MonitorCapabilities,
2402 SessionPowerInit,
2403 SessionDisplayState,
2404 PowerRequestCreate,
2405 PowerRequestAction,
2406 GetPowerRequestList,
2407 ProcessorInformationEx,
2408 NotifyUserModeLegacyPowerEvent,
2409 GroupPark,
2410 ProcessorIdleDomains,
2411 WakeTimerList,
2412 SystemHiberFileSize,
2413 PowerInformationLevelMaximum
2414 } POWER_INFORMATION_LEVEL;
2415
2416 typedef enum {
2417 PowerActionNone = 0,
2418 PowerActionReserved,
2419 PowerActionSleep,
2420 PowerActionHibernate,
2421 PowerActionShutdown,
2422 PowerActionShutdownReset,
2423 PowerActionShutdownOff,
2424 PowerActionWarmEject
2425 } POWER_ACTION, *PPOWER_ACTION;
2426
2427 typedef enum _DEVICE_POWER_STATE {
2428 PowerDeviceUnspecified = 0,
2429 PowerDeviceD0,
2430 PowerDeviceD1,
2431 PowerDeviceD2,
2432 PowerDeviceD3,
2433 PowerDeviceMaximum
2434 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
2435
2436 typedef enum _MONITOR_DISPLAY_STATE {
2437 PowerMonitorOff = 0,
2438 PowerMonitorOn,
2439 PowerMonitorDim
2440 } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
2441
2442 typedef union _POWER_STATE {
2443 SYSTEM_POWER_STATE SystemState;
2444 DEVICE_POWER_STATE DeviceState;
2445 } POWER_STATE, *PPOWER_STATE;
2446
2447 typedef enum _POWER_STATE_TYPE {
2448 SystemPowerState = 0,
2449 DevicePowerState
2450 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
2451
2452 #if (NTDDI_VERSION >= NTDDI_VISTA)
2453 typedef struct _SYSTEM_POWER_STATE_CONTEXT {
2454 _ANONYMOUS_UNION union {
2455 _ANONYMOUS_STRUCT struct {
2456 ULONG Reserved1:8;
2457 ULONG TargetSystemState:4;
2458 ULONG EffectiveSystemState:4;
2459 ULONG CurrentSystemState:4;
2460 ULONG IgnoreHibernationPath:1;
2461 ULONG PseudoTransition:1;
2462 ULONG Reserved2:10;
2463 } DUMMYSTRUCTNAME;
2464 ULONG ContextAsUlong;
2465 } DUMMYUNIONNAME;
2466 } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT;
2467 #endif
2468
2469 #if (NTDDI_VERSION >= NTDDI_WIN7)
2470 typedef struct _COUNTED_REASON_CONTEXT {
2471 ULONG Version;
2472 ULONG Flags;
2473 _ANONYMOUS_UNION union {
2474 _ANONYMOUS_STRUCT struct {
2475 UNICODE_STRING ResourceFileName;
2476 USHORT ResourceReasonId;
2477 ULONG StringCount;
2478 PUNICODE_STRING ReasonStrings;
2479 } DUMMYSTRUCTNAME;
2480 UNICODE_STRING SimpleString;
2481 } DUMMYUNIONNAME;
2482 } COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT;
2483 #endif
2484
2485 #define IOCTL_QUERY_DEVICE_POWER_STATE \
2486 CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
2487
2488 #define IOCTL_SET_DEVICE_WAKE \
2489 CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2490
2491 #define IOCTL_CANCEL_DEVICE_WAKE \
2492 CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2493
2494 #define ES_SYSTEM_REQUIRED 0x00000001
2495 #define ES_DISPLAY_REQUIRED 0x00000002
2496 #define ES_USER_PRESENT 0x00000004
2497 #define ES_CONTINUOUS 0x80000000
2498
2499 typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE;
2500
2501 typedef enum {
2502 LT_DONT_CARE,
2503 LT_LOWEST_LATENCY
2504 } LATENCY_TIME;
2505
2506 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
2507 #define DIAGNOSTIC_REASON_VERSION 0
2508 #define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001
2509 #define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002
2510 #define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000
2511 #define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003)
2512 #endif
2513
2514 #define POWER_REQUEST_CONTEXT_VERSION 0
2515 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
2516 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
2517
2518 #define PowerRequestMaximum 3
2519
2520 typedef enum _POWER_REQUEST_TYPE {
2521 PowerRequestDisplayRequired,
2522 PowerRequestSystemRequired,
2523 PowerRequestAwayModeRequired
2524 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
2525
2526 #if (NTDDI_VERSION >= NTDDI_WINXP)
2527
2528 #define PDCAP_D0_SUPPORTED 0x00000001
2529 #define PDCAP_D1_SUPPORTED 0x00000002
2530 #define PDCAP_D2_SUPPORTED 0x00000004
2531 #define PDCAP_D3_SUPPORTED 0x00000008
2532 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
2533 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
2534 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
2535 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
2536 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
2537
2538 typedef struct CM_Power_Data_s {
2539 ULONG PD_Size;
2540 DEVICE_POWER_STATE PD_MostRecentPowerState;
2541 ULONG PD_Capabilities;
2542 ULONG PD_D1Latency;
2543 ULONG PD_D2Latency;
2544 ULONG PD_D3Latency;
2545 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
2546 SYSTEM_POWER_STATE PD_DeepestSystemWake;
2547 } CM_POWER_DATA, *PCM_POWER_DATA;
2548
2549 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2550
2551 typedef enum _SYSTEM_POWER_CONDITION {
2552 PoAc,
2553 PoDc,
2554 PoHot,
2555 PoConditionMaximum
2556 } SYSTEM_POWER_CONDITION;
2557
2558 typedef struct _SET_POWER_SETTING_VALUE {
2559 ULONG Version;
2560 GUID Guid;
2561 SYSTEM_POWER_CONDITION PowerCondition;
2562 ULONG DataLength;
2563 UCHAR Data[ANYSIZE_ARRAY];
2564 } SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE;
2565
2566 #define POWER_SETTING_VALUE_VERSION (0x1)
2567
2568 typedef struct _NOTIFY_USER_POWER_SETTING {
2569 GUID Guid;
2570 } NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING;
2571
2572 typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
2573 LARGE_INTEGER ActivationTime;
2574 ULONG Flags;
2575 ULONG ButtonInstanceID;
2576 } APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE;
2577
2578 typedef enum _POWER_PLATFORM_ROLE {
2579 PlatformRoleUnspecified = 0,
2580 PlatformRoleDesktop,
2581 PlatformRoleMobile,
2582 PlatformRoleWorkstation,
2583 PlatformRoleEnterpriseServer,
2584 PlatformRoleSOHOServer,
2585 PlatformRoleAppliancePC,
2586 PlatformRolePerformanceServer,
2587 PlatformRoleMaximum
2588 } POWER_PLATFORM_ROLE;
2589
2590 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
2591 typedef struct {
2592 ULONG Granularity;
2593 ULONG Capacity;
2594 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
2595 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
2596
2597 #endif /* !_PO_DDK_ */
2598
2599 #define CORE_PARKING_POLICY_CHANGE_IDEAL 0
2600 #define CORE_PARKING_POLICY_CHANGE_SINGLE 1
2601 #define CORE_PARKING_POLICY_CHANGE_ROCKET 2
2602 #define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET
2603
2604 DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A);
2605 DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C);
2606 DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E);
2607 DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94);
2608 DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0);
2609 DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
2610 DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63);
2611 DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99);
2612 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E);
2613 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63);
2614 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64);
2615 DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee);
2616 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B);
2617 DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA);
2618 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb);
2619 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96);
2620 DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff);
2621 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8);
2622 DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67);
2623 DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47);
2624 DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23);
2625 DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42);
2626 DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E);
2627 DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63);
2628 DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67);
2629 DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20);
2630 DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70);
2631 DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA);
2632 DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0);
2633 DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64);
2634 DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E);
2635 DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1);
2636 DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0);
2637 DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87);
2638 DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab);
2639 DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D);
2640 DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2);
2641 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47);
2642 DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80);
2643 DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78);
2644 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB);
2645 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93);
2646 DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5);
2647 DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36);
2648 DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B);
2649 DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4);
2650 DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F);
2651 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46);
2652 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69);
2653 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f);
2654 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06);
2655 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A);
2656 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58);
2657 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4);
2658 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA);
2659 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82);
2660 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8);
2661 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65);
2662 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3);
2663 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00);
2664 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36);
2665 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC);
2666 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C);
2667 DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb);
2668 DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
2669 DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0);
2670 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d);
2671 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6);
2672 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18);
2673 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6);
2674 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa);
2675 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8);
2676 DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5);
2677 DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59);
2678 DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6);
2679 DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad);
2680 DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b);
2681 DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19);
2682 DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c);
2683 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1);
2684 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa);
2685 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6);
2686 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b);
2687 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28);
2688 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83);
2689 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32);
2690 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82);
2691 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82);
2692 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9);
2693 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20);
2694 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d);
2695 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29);
2696 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb);
2697 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1);
2698 DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f);
2699 DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b);
2700 DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f);
2701 DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F);
2702 DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51);
2703 DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19);
2704 DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48);
2705 DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3);
2706 DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1);
2707 DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1);
2708 DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E);
2709 DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA);
2710 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20);
2711 DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5);
2712 DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6);
2713
2714 #define PERFSTATE_POLICY_CHANGE_IDEAL 0
2715 #define PERFSTATE_POLICY_CHANGE_SINGLE 1
2716 #define PERFSTATE_POLICY_CHANGE_ROCKET 2
2717 #define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET
2718
2719 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0
2720 #define PROCESSOR_PERF_BOOST_POLICY_MAX 100
2721
2722 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0
2723 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1
2724
2725 _Function_class_(REQUEST_POWER_COMPLETE)
2726 _IRQL_requires_same_
2727 typedef VOID
2728 (NTAPI REQUEST_POWER_COMPLETE)(
2729 _In_ struct _DEVICE_OBJECT *DeviceObject,
2730 _In_ UCHAR MinorFunction,
2731 _In_ POWER_STATE PowerState,
2732 _In_opt_ PVOID Context,
2733 _In_ struct _IO_STATUS_BLOCK *IoStatus);
2734 typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE;
2735
2736 _Function_class_(POWER_SETTING_CALLBACK)
2737 _IRQL_requires_same_
2738 typedef NTSTATUS
2739 (NTAPI POWER_SETTING_CALLBACK)(
2740 _In_ LPCGUID SettingGuid,
2741 _In_reads_bytes_(ValueLength) PVOID Value,
2742 _In_ ULONG ValueLength,
2743 _Inout_opt_ PVOID Context);
2744 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
2745
2746 /******************************************************************************
2747 * Configuration Manager Types *
2748 ******************************************************************************/
2749
2750 /* Resource list definitions */
2751 typedef int CM_RESOURCE_TYPE;
2752
2753 #define CmResourceTypeNull 0
2754 #define CmResourceTypePort 1
2755 #define CmResourceTypeInterrupt 2
2756 #define CmResourceTypeMemory 3
2757 #define CmResourceTypeDma 4
2758 #define CmResourceTypeDeviceSpecific 5
2759 #define CmResourceTypeBusNumber 6
2760 #define CmResourceTypeNonArbitrated 128
2761 #define CmResourceTypeConfigData 128
2762 #define CmResourceTypeDevicePrivate 129
2763 #define CmResourceTypePcCardConfig 130
2764 #define CmResourceTypeMfCardConfig 131
2765
2766 /* KEY_VALUE_Xxx.Type */
2767 #define REG_NONE 0
2768 #define REG_SZ 1
2769 #define REG_EXPAND_SZ 2
2770 #define REG_BINARY 3
2771 #define REG_DWORD 4
2772 #define REG_DWORD_LITTLE_ENDIAN 4
2773 #define REG_DWORD_BIG_ENDIAN 5
2774 #define REG_LINK 6
2775 #define REG_MULTI_SZ 7
2776 #define REG_RESOURCE_LIST 8
2777 #define REG_FULL_RESOURCE_DESCRIPTOR 9
2778 #define REG_RESOURCE_REQUIREMENTS_LIST 10
2779 #define REG_QWORD 11
2780 #define REG_QWORD_LITTLE_ENDIAN 11
2781
2782 /* Registry Access Rights */
2783 #define KEY_QUERY_VALUE (0x0001)
2784 #define KEY_SET_VALUE (0x0002)
2785 #define KEY_CREATE_SUB_KEY (0x0004)
2786 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
2787 #define KEY_NOTIFY (0x0010)
2788 #define KEY_CREATE_LINK (0x0020)
2789 #define KEY_WOW64_32KEY (0x0200)
2790 #define KEY_WOW64_64KEY (0x0100)
2791 #define KEY_WOW64_RES (0x0300)
2792
2793 #define KEY_READ ((STANDARD_RIGHTS_READ |\
2794 KEY_QUERY_VALUE |\
2795 KEY_ENUMERATE_SUB_KEYS |\
2796 KEY_NOTIFY) \
2797 & \
2798 (~SYNCHRONIZE))
2799
2800 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
2801 KEY_SET_VALUE |\
2802 KEY_CREATE_SUB_KEY) \
2803 & \
2804 (~SYNCHRONIZE))
2805
2806 #define KEY_EXECUTE ((KEY_READ) \
2807 & \
2808 (~SYNCHRONIZE))
2809
2810 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
2811 KEY_QUERY_VALUE |\
2812 KEY_SET_VALUE |\
2813 KEY_CREATE_SUB_KEY |\
2814 KEY_ENUMERATE_SUB_KEYS |\
2815 KEY_NOTIFY |\
2816 KEY_CREATE_LINK) \
2817 & \
2818 (~SYNCHRONIZE))
2819
2820 /* Registry Open/Create Options */
2821 #define REG_OPTION_RESERVED (0x00000000L)
2822 #define REG_OPTION_NON_VOLATILE (0x00000000L)
2823 #define REG_OPTION_VOLATILE (0x00000001L)
2824 #define REG_OPTION_CREATE_LINK (0x00000002L)
2825 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
2826 #define REG_OPTION_OPEN_LINK (0x00000008L)
2827
2828 #define REG_LEGAL_OPTION \
2829 (REG_OPTION_RESERVED |\
2830 REG_OPTION_NON_VOLATILE |\
2831 REG_OPTION_VOLATILE |\
2832 REG_OPTION_CREATE_LINK |\
2833 REG_OPTION_BACKUP_RESTORE |\
2834 REG_OPTION_OPEN_LINK)
2835
2836 #define REG_OPEN_LEGAL_OPTION \
2837 (REG_OPTION_RESERVED |\
2838 REG_OPTION_BACKUP_RESTORE |\
2839 REG_OPTION_OPEN_LINK)
2840
2841 #define REG_STANDARD_FORMAT 1
2842 #define REG_LATEST_FORMAT 2
2843 #define REG_NO_COMPRESSION 4
2844
2845 /* Key creation/open disposition */
2846 #define REG_CREATED_NEW_KEY (0x00000001L)
2847 #define REG_OPENED_EXISTING_KEY (0x00000002L)
2848
2849 /* Key restore & hive load flags */
2850 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
2851 #define REG_REFRESH_HIVE (0x00000002L)
2852 #define REG_NO_LAZY_FLUSH (0x00000004L)
2853 #define REG_FORCE_RESTORE (0x00000008L)
2854 #define REG_APP_HIVE (0x00000010L)
2855 #define REG_PROCESS_PRIVATE (0x00000020L)
2856 #define REG_START_JOURNAL (0x00000040L)
2857 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
2858 #define REG_HIVE_NO_RM (0x00000100L)
2859 #define REG_HIVE_SINGLE_LOG (0x00000200L)
2860 #define REG_BOOT_HIVE (0x00000400L)
2861
2862 /* Unload Flags */
2863 #define REG_FORCE_UNLOAD 1
2864
2865 /* Notify Filter Values */
2866 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
2867 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
2868 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
2869 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
2870
2871 #define REG_LEGAL_CHANGE_FILTER \
2872 (REG_NOTIFY_CHANGE_NAME |\
2873 REG_NOTIFY_CHANGE_ATTRIBUTES |\
2874 REG_NOTIFY_CHANGE_LAST_SET |\
2875 REG_NOTIFY_CHANGE_SECURITY)
2876
2877 #include <pshpack4.h>
2878 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
2879 UCHAR Type;
2880 UCHAR ShareDisposition;
2881 USHORT Flags;
2882 union {
2883 struct {
2884 PHYSICAL_ADDRESS Start;
2885 ULONG Length;
2886 } Generic;
2887 struct {
2888 PHYSICAL_ADDRESS Start;
2889 ULONG Length;
2890 } Port;
2891 struct {
2892 #if defined(NT_PROCESSOR_GROUPS)
2893 USHORT Level;
2894 USHORT Group;
2895 #else
2896 ULONG Level;
2897 #endif
2898 ULONG Vector;
2899 KAFFINITY Affinity;
2900 } Interrupt;
2901 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
2902 struct {
2903 _ANONYMOUS_UNION union {
2904 struct {
2905 #if defined(NT_PROCESSOR_GROUPS)
2906 USHORT Group;
2907 #else
2908 USHORT Reserved;
2909 #endif
2910 USHORT MessageCount;
2911 ULONG Vector;
2912 KAFFINITY Affinity;
2913 } Raw;
2914 struct {
2915 #if defined(NT_PROCESSOR_GROUPS)
2916 USHORT Level;
2917 USHORT Group;
2918 #else
2919 ULONG Level;
2920 #endif
2921 ULONG Vector;
2922 KAFFINITY Affinity;
2923 } Translated;
2924 } DUMMYUNIONNAME;
2925 } MessageInterrupt;
2926 #endif
2927 struct {
2928 PHYSICAL_ADDRESS Start;
2929 ULONG Length;
2930 } Memory;
2931 struct {
2932 ULONG Channel;
2933 ULONG Port;
2934 ULONG Reserved1;
2935 } Dma;
2936 struct {
2937 ULONG Data[3];
2938 } DevicePrivate;
2939 struct {
2940 ULONG Start;
2941 ULONG Length;
2942 ULONG Reserved;
2943 } BusNumber;
2944 struct {
2945 ULONG DataSize;
2946 ULONG Reserved1;
2947 ULONG Reserved2;
2948 } DeviceSpecificData;
2949 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
2950 struct {
2951 PHYSICAL_ADDRESS Start;
2952 ULONG Length40;
2953 } Memory40;
2954 struct {
2955 PHYSICAL_ADDRESS Start;
2956 ULONG Length48;
2957 } Memory48;
2958 struct {
2959 PHYSICAL_ADDRESS Start;
2960 ULONG Length64;
2961 } Memory64;
2962 #endif
2963 } u;
2964 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
2965 #include <poppack.h>
2966
2967 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
2968 #define CmResourceTypeNull 0
2969 #define CmResourceTypePort 1
2970 #define CmResourceTypeInterrupt 2
2971 #define CmResourceTypeMemory 3
2972 #define CmResourceTypeDma 4
2973 #define CmResourceTypeDeviceSpecific 5
2974 #define CmResourceTypeBusNumber 6
2975 #define CmResourceTypeMemoryLarge 7
2976 #define CmResourceTypeNonArbitrated 128
2977 #define CmResourceTypeConfigData 128
2978 #define CmResourceTypeDevicePrivate 129
2979 #define CmResourceTypePcCardConfig 130
2980 #define CmResourceTypeMfCardConfig 131
2981
2982 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
2983 typedef enum _CM_SHARE_DISPOSITION {
2984 CmResourceShareUndetermined = 0,
2985 CmResourceShareDeviceExclusive,
2986 CmResourceShareDriverExclusive,
2987 CmResourceShareShared
2988 } CM_SHARE_DISPOSITION;
2989
2990 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
2991 #define CM_RESOURCE_PORT_MEMORY 0x0000
2992 #define CM_RESOURCE_PORT_IO 0x0001
2993 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
2994 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
2995 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
2996 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
2997 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
2998 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
2999 #define CM_RESOURCE_PORT_BAR 0x0100
3000
3001 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
3002 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
3003 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
3004 #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002
3005 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
3006
3007 #define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001
3008
3009 #define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2)
3010
3011 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
3012 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
3013 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
3014 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
3015 #define CM_RESOURCE_MEMORY_WRITEABILITY_MASK 0x0003
3016 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
3017 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
3018 #define CM_RESOURCE_MEMORY_24 0x0010
3019 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
3020 #define CM_RESOURCE_MEMORY_WINDOW_DECODE 0x0040
3021 #define CM_RESOURCE_MEMORY_BAR 0x0080
3022 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
3023
3024 #define CM_RESOURCE_MEMORY_LARGE 0x0E00
3025 #define CM_RESOURCE_MEMORY_LARGE_40 0x0200
3026 #define CM_RESOURCE_MEMORY_LARGE_48 0x0400
3027 #define CM_RESOURCE_MEMORY_LARGE_64 0x0800
3028
3029 #define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00
3030 #define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000
3031 #define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000
3032
3033 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
3034 #define CM_RESOURCE_DMA_8 0x0000
3035 #define CM_RESOURCE_DMA_16 0x0001
3036 #define CM_RESOURCE_DMA_32 0x0002
3037 #define CM_RESOURCE_DMA_8_AND_16 0x0004
3038 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
3039 #define CM_RESOURCE_DMA_TYPE_A 0x0010
3040 #define CM_RESOURCE_DMA_TYPE_B 0x0020
3041 #define CM_RESOURCE_DMA_TYPE_F 0x0040
3042
3043 typedef struct _DEVICE_FLAGS {
3044 ULONG Failed:1;
3045 ULONG ReadOnly:1;
3046 ULONG Removable:1;
3047 ULONG ConsoleIn:1;
3048 ULONG ConsoleOut:1;
3049 ULONG Input:1;
3050 ULONG Output:1;
3051 } DEVICE_FLAGS, *PDEVICE_FLAGS;
3052
3053 typedef enum _INTERFACE_TYPE {
3054 InterfaceTypeUndefined = -1,
3055 Internal,
3056 Isa,
3057 Eisa,
3058 MicroChannel,
3059 TurboChannel,
3060 PCIBus,
3061 VMEBus,
3062 NuBus,
3063 PCMCIABus,
3064 CBus,
3065 MPIBus,
3066 MPSABus,
3067 ProcessorInternal,
3068 InternalPowerBus,
3069 PNPISABus,
3070 PNPBus,
3071 Vmcs,
3072 MaximumInterfaceType
3073 } INTERFACE_TYPE, *PINTERFACE_TYPE;
3074
3075 typedef struct _CM_COMPONENT_INFORMATION {
3076 DEVICE_FLAGS Flags;
3077 ULONG Version;
3078 ULONG Key;
3079 KAFFINITY AffinityMask;
3080 } CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
3081
3082 typedef struct _CM_ROM_BLOCK {
3083 ULONG Address;
3084 ULONG Size;
3085 } CM_ROM_BLOCK, *PCM_ROM_BLOCK;
3086
3087 typedef struct _CM_PARTIAL_RESOURCE_LIST {
3088 USHORT Version;
3089 USHORT Revision;
3090 ULONG Count;
3091 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
3092 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
3093
3094 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
3095 INTERFACE_TYPE InterfaceType;
3096 ULONG BusNumber;
3097 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
3098 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
3099
3100 typedef struct _CM_RESOURCE_LIST {
3101 ULONG Count;
3102 CM_FULL_RESOURCE_DESCRIPTOR List[1];
3103 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
3104
3105 typedef struct _PNP_BUS_INFORMATION {
3106 GUID BusTypeGuid;
3107 INTERFACE_TYPE LegacyBusType;
3108 ULONG BusNumber;
3109 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
3110
3111 #include <pshpack1.h>
3112
3113 typedef struct _CM_INT13_DRIVE_PARAMETER {
3114 USHORT DriveSelect;
3115 ULONG MaxCylinders;
3116 USHORT SectorsPerTrack;
3117 USHORT MaxHeads;
3118 USHORT NumberDrives;
3119 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
3120
3121 typedef struct _CM_MCA_POS_DATA {
3122 USHORT AdapterId;
3123 UCHAR PosData1;
3124 UCHAR PosData2;
3125 UCHAR PosData3;
3126 UCHAR PosData4;
3127 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
3128
3129 typedef struct _CM_PNP_BIOS_DEVICE_NODE {
3130 USHORT Size;
3131 UCHAR Node;
3132 ULONG ProductId;
3133 UCHAR DeviceType[3];
3134 USHORT DeviceAttributes;
3135 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
3136
3137 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
3138 UCHAR Signature[4];
3139 UCHAR Revision;
3140 UCHAR Length;
3141 USHORT ControlField;
3142 UCHAR Checksum;
3143 ULONG EventFlagAddress;
3144 USHORT RealModeEntryOffset;
3145 USHORT RealModeEntrySegment;
3146 USHORT ProtectedModeEntryOffset;
3147 ULONG ProtectedModeCodeBaseAddress;
3148 ULONG OemDeviceId;
3149 USHORT RealModeDataBaseAddress;
3150 ULONG ProtectedModeDataBaseAddress;
3151 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
3152
3153 #include <poppack.h>
3154
3155 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
3156 ULONG BytesPerSector;
3157 ULONG NumberOfCylinders;
3158 ULONG SectorsPerTrack;
3159 ULONG NumberOfHeads;
3160 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
3161
3162 typedef struct _CM_KEYBOARD_DEVICE_DATA {
3163 USHORT Version;
3164 USHORT Revision;
3165 UCHAR Type;
3166 UCHAR Subtype;
3167 USHORT KeyboardFlags;
3168 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
3169
3170 typedef struct _CM_SCSI_DEVICE_DATA {
3171 USHORT Version;
3172 USHORT Revision;
3173 UCHAR HostIdentifier;
3174 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
3175
3176 typedef struct _CM_VIDEO_DEVICE_DATA {
3177 USHORT Version;
3178 USHORT Revision;
3179 ULONG VideoClock;
3180 } CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA;
3181
3182 typedef struct _CM_SONIC_DEVICE_DATA {
3183 USHORT Version;
3184 USHORT Revision;
3185 USHORT DataConfigurationRegister;
3186 UCHAR EthernetAddress[8];
3187 } CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA;
3188
3189 typedef struct _CM_SERIAL_DEVICE_DATA {
3190 USHORT Version;
3191 USHORT Revision;
3192 ULONG BaudClock;
3193 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
3194
3195 typedef struct _CM_MONITOR_DEVICE_DATA {
3196 USHORT Version;
3197 USHORT Revision;
3198 USHORT HorizontalScreenSize;
3199 USHORT VerticalScreenSize;
3200 USHORT HorizontalResolution;
3201 USHORT VerticalResolution;
3202 USHORT HorizontalDisplayTimeLow;
3203 USHORT HorizontalDisplayTime;
3204 USHORT HorizontalDisplayTimeHigh;
3205 USHORT HorizontalBackPorchLow;
3206 USHORT HorizontalBackPorch;
3207 USHORT HorizontalBackPorchHigh;
3208 USHORT HorizontalFrontPorchLow;
3209 USHORT HorizontalFrontPorch;
3210 USHORT HorizontalFrontPorchHigh;
3211 USHORT HorizontalSyncLow;
3212 USHORT HorizontalSync;
3213 USHORT HorizontalSyncHigh;
3214 USHORT VerticalBackPorchLow;
3215 USHORT VerticalBackPorch;
3216 USHORT VerticalBackPorchHigh;
3217 USHORT VerticalFrontPorchLow;
3218 USHORT VerticalFrontPorch;
3219 USHORT VerticalFrontPorchHigh;
3220 USHORT VerticalSyncLow;
3221 USHORT VerticalSync;
3222 USHORT VerticalSyncHigh;
3223 } CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA;
3224
3225 typedef struct _CM_FLOPPY_DEVICE_DATA {
3226 USHORT Version;
3227 USHORT Revision;
3228 CHAR Size[8];
3229 ULONG MaxDensity;
3230 ULONG MountDensity;
3231 UCHAR StepRateHeadUnloadTime;
3232 UCHAR HeadLoadTime;
3233 UCHAR MotorOffTime;
3234 UCHAR SectorLengthCode;
3235 UCHAR SectorPerTrack;
3236 UCHAR ReadWriteGapLength;
3237 UCHAR DataTransferLength;
3238 UCHAR FormatGapLength;
3239 UCHAR FormatFillCharacter;
3240 UCHAR HeadSettleTime;
3241 UCHAR MotorSettleTime;
3242 UCHAR MaximumTrackValue;
3243 UCHAR DataTransferRate;
3244 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
3245
3246 typedef enum _KEY_INFORMATION_CLASS {
3247 KeyBasicInformation,
3248 KeyNodeInformation,
3249 KeyFullInformation,
3250 KeyNameInformation,
3251 KeyCachedInformation,
3252 KeyFlagsInformation,
3253 KeyVirtualizationInformation,
3254 KeyHandleTagsInformation,
3255 MaxKeyInfoClass
3256 } KEY_INFORMATION_CLASS;
3257
3258 typedef struct _KEY_BASIC_INFORMATION {
3259 LARGE_INTEGER LastWriteTime;
3260 ULONG TitleIndex;
3261 ULONG NameLength;
3262 WCHAR Name[1];
3263 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
3264
3265 typedef struct _KEY_CONTROL_FLAGS_INFORMATION {
3266 ULONG ControlFlags;
3267 } KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION;
3268
3269 typedef struct _KEY_FULL_INFORMATION {
3270 LARGE_INTEGER LastWriteTime;
3271 ULONG TitleIndex;
3272 ULONG ClassOffset;
3273 ULONG ClassLength;
3274 ULONG SubKeys;
3275 ULONG MaxNameLen;
3276 ULONG MaxClassLen;
3277 ULONG Values;
3278 ULONG MaxValueNameLen;
3279 ULONG MaxValueDataLen;
3280 WCHAR Class[1];
3281 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
3282
3283 typedef struct _KEY_HANDLE_TAGS_INFORMATION {
3284 ULONG HandleTags;
3285 } KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION;
3286
3287 typedef struct _KEY_NODE_INFORMATION {
3288 LARGE_INTEGER LastWriteTime;
3289 ULONG TitleIndex;
3290 ULONG ClassOffset;
3291 ULONG ClassLength;
3292 ULONG NameLength;
3293 WCHAR Name[1];
3294 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
3295
3296 typedef enum _KEY_SET_INFORMATION_CLASS {
3297 KeyWriteTimeInformation,
3298 KeyWow64FlagsInformation,
3299 KeyControlFlagsInformation,
3300 KeySetVirtualizationInformation,
3301 KeySetDebugInformation,
3302 KeySetHandleTagsInformation,
3303 MaxKeySetInfoClass
3304 } KEY_SET_INFORMATION_CLASS;
3305
3306 typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION {
3307 ULONG VirtualTarget:1;
3308 ULONG VirtualStore:1;
3309 ULONG VirtualSource:1;
3310 ULONG Reserved:29;
3311 } KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION;
3312
3313 typedef struct _KEY_VALUE_BASIC_INFORMATION {
3314 ULONG TitleIndex;
3315 ULONG Type;
3316 ULONG NameLength;
3317 WCHAR Name[1];
3318 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
3319
3320 typedef struct _KEY_VALUE_FULL_INFORMATION {
3321 ULONG TitleIndex;
3322 ULONG Type;
3323 ULONG DataOffset;
3324 ULONG DataLength;
3325 ULONG NameLength;
3326 WCHAR Name[1];
3327 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
3328
3329 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
3330 ULONG TitleIndex;
3331 ULONG Type;
3332 ULONG DataLength;
3333 _Field_size_bytes_(DataLength) UCHAR Data[1];
3334 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
3335
3336 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
3337 ULONG Type;
3338 ULONG DataLength;
3339 _Field_size_bytes_(DataLength) UCHAR Data[1];
3340 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
3341
3342 typedef struct _KEY_VALUE_ENTRY {
3343 PUNICODE_STRING ValueName;
3344 ULONG DataLength;
3345 ULONG DataOffset;
3346 ULONG Type;
3347 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
3348
3349 typedef enum _KEY_VALUE_INFORMATION_CLASS {
3350 KeyValueBasicInformation,
3351 KeyValueFullInformation,
3352 KeyValuePartialInformation,
3353 KeyValueFullInformationAlign64,
3354 KeyValuePartialInformationAlign64
3355 } KEY_VALUE_INFORMATION_CLASS;
3356
3357 typedef struct _KEY_WOW64_FLAGS_INFORMATION {
3358 ULONG UserFlags;
3359 } KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION;
3360
3361 typedef struct _KEY_WRITE_TIME_INFORMATION {
3362 LARGE_INTEGER LastWriteTime;
3363 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
3364
3365 typedef enum _REG_NOTIFY_CLASS {
3366 RegNtDeleteKey,
3367 RegNtPreDeleteKey = RegNtDeleteKey,
3368 RegNtSetValueKey,
3369 RegNtPreSetValueKey = RegNtSetValueKey,
3370 RegNtDeleteValueKey,
3371 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
3372 RegNtSetInformationKey,
3373 RegNtPreSetInformationKey = RegNtSetInformationKey,
3374 RegNtRenameKey,
3375 RegNtPreRenameKey = RegNtRenameKey,
3376 RegNtEnumerateKey,
3377 RegNtPreEnumerateKey = RegNtEnumerateKey,
3378 RegNtEnumerateValueKey,
3379 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
3380 RegNtQueryKey,
3381 RegNtPreQueryKey = RegNtQueryKey,
3382 RegNtQueryValueKey,
3383 RegNtPreQueryValueKey = RegNtQueryValueKey,
3384 RegNtQueryMultipleValueKey,
3385 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
3386 RegNtPreCreateKey,
3387 RegNtPostCreateKey,
3388 RegNtPreOpenKey,
3389 RegNtPostOpenKey,
3390 RegNtKeyHandleClose,
3391 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
3392 RegNtPostDeleteKey,
3393 RegNtPostSetValueKey,
3394 RegNtPostDeleteValueKey,
3395 RegNtPostSetInformationKey,
3396 RegNtPostRenameKey,
3397 RegNtPostEnumerateKey,
3398 RegNtPostEnumerateValueKey,
3399 RegNtPostQueryKey,
3400 RegNtPostQueryValueKey,
3401 RegNtPostQueryMultipleValueKey,
3402 RegNtPostKeyHandleClose,
3403 RegNtPreCreateKeyEx,
3404 RegNtPostCreateKeyEx,
3405 RegNtPreOpenKeyEx,
3406 RegNtPostOpenKeyEx,
3407 RegNtPreFlushKey,
3408 RegNtPostFlushKey,
3409 RegNtPreLoadKey,
3410 RegNtPostLoadKey,
3411 RegNtPreUnLoadKey,
3412 RegNtPostUnLoadKey,
3413 RegNtPreQueryKeySecurity,
3414 RegNtPostQueryKeySecurity,
3415 RegNtPreSetKeySecurity,
3416 RegNtPostSetKeySecurity,
3417 RegNtCallbackObjectContextCleanup,
3418 RegNtPreRestoreKey,
3419 RegNtPostRestoreKey,
3420 RegNtPreSaveKey,
3421 RegNtPostSaveKey,
3422 RegNtPreReplaceKey,
3423 RegNtPostReplaceKey,
3424 MaxRegNtNotifyClass
3425 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
3426
3427 _IRQL_requires_same_
3428 _Function_class_(EX_CALLBACK_FUNCTION)
3429 typedef NTSTATUS
3430 (NTAPI EX_CALLBACK_FUNCTION)(
3431 _In_ PVOID CallbackContext,
3432 _In_opt_ PVOID Argument1,
3433 _In_opt_ PVOID Argument2);
3434 typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION;
3435
3436 typedef struct _REG_DELETE_KEY_INFORMATION {
3437 PVOID Object;
3438 PVOID CallContext;
3439 PVOID ObjectContext;
3440 PVOID Reserved;
3441 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
3442 #if (NTDDI_VERSION >= NTDDI_VISTA)
3443 , REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
3444 #endif
3445 ;
3446
3447 typedef struct _REG_SET_VALUE_KEY_INFORMATION {
3448 PVOID Object;
3449 PUNICODE_STRING ValueName;
3450 ULONG TitleIndex;
3451 ULONG Type;
3452 PVOID Data;
3453 ULONG DataSize;
3454 PVOID CallContext;
3455 PVOID ObjectContext;
3456 PVOID Reserved;
3457 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
3458
3459 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
3460 PVOID Object;
3461 PUNICODE_STRING ValueName;
3462 PVOID CallContext;
3463 PVOID ObjectContext;
3464 PVOID Reserved;
3465 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;