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