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