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