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