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