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