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