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