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