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