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