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