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