sync with trunk r46493
[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
42 #ifndef GUID_DEFINED
43 #include <guiddef.h>
44 #endif /* GUID_DEFINED */
45
46 #if (NTDDI_VERSION >= NTDDI_WINXP)
47 #include <dpfilter.h>
48 #endif
49
50 #include "intrin.h"
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 #if !defined(_NTHALDLL_) && !defined(_BLDR_)
57 #define NTHALAPI DECLSPEC_IMPORT
58 #else
59 #define NTHALAPI
60 #endif
61
62 /* For ReactOS */
63 #if !defined(_NTOSKRNL_) && !defined(_BLDR_)
64 #define NTKERNELAPI DECLSPEC_IMPORT
65 #else
66 #define NTKERNELAPI
67 #endif
68
69 #if defined(_X86_) && !defined(_NTHAL_)
70 #define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT
71 #elif defined(_X86_)
72 #define _DECL_HAL_KE_IMPORT
73 #else
74 #define _DECL_HAL_KE_IMPORT NTKERNELAPI
75 #endif
76
77 #if defined(_WIN64)
78 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
79 #else
80 #define POINTER_ALIGNMENT
81 #endif
82
83 /* Helper macro to enable gcc's extension. */
84 #ifndef __GNU_EXTENSION
85 #ifdef __GNUC__
86 #define __GNU_EXTENSION __extension__
87 #else
88 #define __GNU_EXTENSION
89 #endif
90 #endif
91
92 #if defined(_MSC_VER)
93
94 /* Indicate if #pragma alloc_text() is supported */
95 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
96 #define ALLOC_PRAGMA 1
97 #endif
98
99 /* Indicate if #pragma data_seg() is supported */
100 #if defined(_M_IX86) || defined(_M_AMD64)
101 #define ALLOC_DATA_PRAGMA 1
102 #endif
103
104 #endif
105
106 /* Forward declarations */
107 struct _IRP;
108 struct _MDL;
109 struct _KAPC;
110 struct _KDPC;
111 struct _FILE_OBJECT;
112 struct _DMA_ADAPTER;
113 struct _DEVICE_OBJECT;
114 struct _DRIVER_OBJECT;
115 struct _IO_STATUS_BLOCK;
116 struct _DEVICE_DESCRIPTION;
117 struct _SCATTER_GATHER_LIST;
118 struct _DRIVE_LAYOUT_INFORMATION;
119 struct _COMPRESSED_DATA_INFO;
120 struct _IO_RESOURCE_DESCRIPTOR;
121
122 /* Structures not exposed to drivers */
123 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
124 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
125 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
126 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
127 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
128 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
129 typedef struct _ETHREAD *PETHREAD;
130 typedef struct _EPROCESS *PEPROCESS;
131 typedef struct _IO_TIMER *PIO_TIMER;
132 typedef struct _KINTERRUPT *PKINTERRUPT;
133 typedef struct _KPROCESS *PKPROCESS;
134 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
135 typedef struct _CONTEXT *PCONTEXT;
136
137
138 /******************************************************************************
139 * INTERLOCKED Functions *
140 ******************************************************************************/
141 //
142 // Intrinsics (note: taken from our winnt.h)
143 // FIXME: 64-bit
144 //
145 #if defined(__GNUC__)
146
147 static __inline__ BOOLEAN
148 InterlockedBitTestAndSet(IN LONG volatile *Base,
149 IN LONG Bit)
150 {
151 #if defined(_M_IX86)
152 LONG OldBit;
153 __asm__ __volatile__("lock "
154 "btsl %2,%1\n\t"
155 "sbbl %0,%0\n\t"
156 :"=r" (OldBit),"+m" (*Base)
157 :"Ir" (Bit)
158 : "memory");
159 return OldBit;
160 #else
161 return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1;
162 #endif
163 }
164
165 static __inline__ BOOLEAN
166 InterlockedBitTestAndReset(IN LONG volatile *Base,
167 IN LONG Bit)
168 {
169 #if defined(_M_IX86)
170 LONG OldBit;
171 __asm__ __volatile__("lock "
172 "btrl %2,%1\n\t"
173 "sbbl %0,%0\n\t"
174 :"=r" (OldBit),"+m" (*Base)
175 :"Ir" (Bit)
176 : "memory");
177 return OldBit;
178 #else
179 return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1;
180 #endif
181 }
182
183 #endif
184
185 #define BitScanForward _BitScanForward
186 #define BitScanReverse _BitScanReverse
187 #define BitTest _bittest
188 #define BitTestAndComplement _bittestandcomplement
189 #define BitTestAndSet _bittestandset
190 #define BitTestAndReset _bittestandreset
191 #define InterlockedBitTestAndSet _interlockedbittestandset
192 #define InterlockedBitTestAndReset _interlockedbittestandreset
193
194 #ifdef _M_AMD64
195 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
196 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
197 #endif
198
199 #if !defined(__INTERLOCKED_DECLARED)
200 #define __INTERLOCKED_DECLARED
201
202 #if defined (_X86_)
203 #if defined(NO_INTERLOCKED_INTRINSICS)
204 NTKERNELAPI
205 LONG
206 FASTCALL
207 InterlockedIncrement(
208 IN OUT LONG volatile *Addend);
209
210 NTKERNELAPI
211 LONG
212 FASTCALL
213 InterlockedDecrement(
214 IN OUT LONG volatile *Addend);
215
216 NTKERNELAPI
217 LONG
218 FASTCALL
219 InterlockedCompareExchange(
220 IN OUT LONG volatile *Destination,
221 IN LONG Exchange,
222 IN LONG Comparand);
223
224 NTKERNELAPI
225 LONG
226 FASTCALL
227 InterlockedExchange(
228 IN OUT LONG volatile *Destination,
229 IN LONG Value);
230
231 NTKERNELAPI
232 LONG
233 FASTCALL
234 InterlockedExchangeAdd(
235 IN OUT LONG volatile *Addend,
236 IN LONG Value);
237
238 #else // !defined(NO_INTERLOCKED_INTRINSICS)
239
240 #define InterlockedExchange _InterlockedExchange
241 #define InterlockedIncrement _InterlockedIncrement
242 #define InterlockedDecrement _InterlockedDecrement
243 #define InterlockedExchangeAdd _InterlockedExchangeAdd
244 #define InterlockedCompareExchange _InterlockedCompareExchange
245 #define InterlockedOr _InterlockedOr
246 #define InterlockedAnd _InterlockedAnd
247 #define InterlockedXor _InterlockedXor
248
249 #endif // !defined(NO_INTERLOCKED_INTRINSICS)
250
251 #endif // defined (_X86_)
252
253 #if !defined (_WIN64)
254 /*
255 * PVOID
256 * InterlockedExchangePointer(
257 * IN OUT PVOID volatile *Target,
258 * IN PVOID Value)
259 */
260 #define InterlockedExchangePointer(Target, Value) \
261 ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value))
262
263 /*
264 * PVOID
265 * InterlockedCompareExchangePointer(
266 * IN OUT PVOID *Destination,
267 * IN PVOID Exchange,
268 * IN PVOID Comparand)
269 */
270 #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \
271 ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand))
272
273 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b)
274 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a)
275 #define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)a)
276
277 #endif // !defined (_WIN64)
278
279 #if defined (_M_AMD64)
280
281 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)a, (LONGLONG)b)
282 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)a)
283 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONGLONG *)a)
284 #define InterlockedAnd _InterlockedAnd
285 #define InterlockedOr _InterlockedOr
286 #define InterlockedXor _InterlockedXor
287 #define InterlockedIncrement _InterlockedIncrement
288 #define InterlockedDecrement _InterlockedDecrement
289 #define InterlockedAdd _InterlockedAdd
290 #define InterlockedExchange _InterlockedExchange
291 #define InterlockedExchangeAdd _InterlockedExchangeAdd
292 #define InterlockedCompareExchange _InterlockedCompareExchange
293 #define InterlockedAnd64 _InterlockedAnd64
294 #define InterlockedOr64 _InterlockedOr64
295 #define InterlockedXor64 _InterlockedXor64
296 #define InterlockedIncrement64 _InterlockedIncrement64
297 #define InterlockedDecrement64 _InterlockedDecrement64
298 #define InterlockedAdd64 _InterlockedAdd64
299 #define InterlockedExchange64 _InterlockedExchange64
300 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
301 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
302 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
303 #define InterlockedExchangePointer _InterlockedExchangePointer
304 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
305 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
306
307 #endif // _M_AMD64
308
309 #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
310 //#if !defined(_X86AMD64_) // FIXME: what's _X86AMD64_ used for?
311 FORCEINLINE
312 LONG64
313 InterlockedAdd64(
314 IN OUT LONG64 volatile *Addend,
315 IN LONG64 Value)
316 {
317 return InterlockedExchangeAdd64(Addend, Value) + Value;
318 }
319 //#endif
320 #endif
321
322 #endif /* !__INTERLOCKED_DECLARED */
323
324
325 /******************************************************************************
326 * Runtime Library Types *
327 ******************************************************************************/
328
329 #define RTL_REGISTRY_ABSOLUTE 0
330 #define RTL_REGISTRY_SERVICES 1
331 #define RTL_REGISTRY_CONTROL 2
332 #define RTL_REGISTRY_WINDOWS_NT 3
333 #define RTL_REGISTRY_DEVICEMAP 4
334 #define RTL_REGISTRY_USER 5
335 #define RTL_REGISTRY_MAXIMUM 6
336 #define RTL_REGISTRY_HANDLE 0x40000000
337 #define RTL_REGISTRY_OPTIONAL 0x80000000
338
339 /* RTL_QUERY_REGISTRY_TABLE.Flags */
340 #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001
341 #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002
342 #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004
343 #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008
344 #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010
345 #define RTL_QUERY_REGISTRY_DIRECT 0x00000020
346 #define RTL_QUERY_REGISTRY_DELETE 0x00000040
347
348 #define HASH_STRING_ALGORITHM_DEFAULT 0
349 #define HASH_STRING_ALGORITHM_X65599 1
350 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
351
352 typedef struct _RTL_BITMAP {
353 ULONG SizeOfBitMap;
354 PULONG Buffer;
355 } RTL_BITMAP, *PRTL_BITMAP;
356
357 typedef struct _RTL_BITMAP_RUN {
358 ULONG StartingIndex;
359 ULONG NumberOfBits;
360 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
361
362 typedef NTSTATUS
363 (DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
364 IN PWSTR ValueName,
365 IN ULONG ValueType,
366 IN PVOID ValueData,
367 IN ULONG ValueLength,
368 IN PVOID Context,
369 IN PVOID EntryContext);
370
371 typedef struct _RTL_QUERY_REGISTRY_TABLE {
372 PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
373 ULONG Flags;
374 PCWSTR Name;
375 PVOID EntryContext;
376 ULONG DefaultType;
377 PVOID DefaultData;
378 ULONG DefaultLength;
379 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
380
381 typedef struct _TIME_FIELDS {
382 CSHORT Year;
383 CSHORT Month;
384 CSHORT Day;
385 CSHORT Hour;
386 CSHORT Minute;
387 CSHORT Second;
388 CSHORT Milliseconds;
389 CSHORT Weekday;
390 } TIME_FIELDS, *PTIME_FIELDS;
391
392 /* Slist Header */
393 #ifndef _SLIST_HEADER_
394 #define _SLIST_HEADER_
395
396 #if defined(_WIN64)
397 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
398 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
399 PSLIST_ENTRY Next;
400 } SLIST_ENTRY;
401 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
402 struct {
403 ULONGLONG Alignment;
404 ULONGLONG Region;
405 } DUMMYSTRUCTNAME;
406 struct {
407 ULONGLONG Depth:16;
408 ULONGLONG Sequence:9;
409 ULONGLONG NextEntry:39;
410 ULONGLONG HeaderType:1;
411 ULONGLONG Init:1;
412 ULONGLONG Reserved:59;
413 ULONGLONG Region:3;
414 } Header8;
415 struct {
416 ULONGLONG Depth:16;
417 ULONGLONG Sequence:48;
418 ULONGLONG HeaderType:1;
419 ULONGLONG Init:1;
420 ULONGLONG Reserved:2;
421 ULONGLONG NextEntry:60;
422 } Header16;
423 } SLIST_HEADER, *PSLIST_HEADER;
424 #else
425 #define SLIST_ENTRY SINGLE_LIST_ENTRY
426 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
427 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
428 typedef union _SLIST_HEADER {
429 ULONGLONG Alignment;
430 struct {
431 SLIST_ENTRY Next;
432 USHORT Depth;
433 USHORT Sequence;
434 } DUMMYSTRUCTNAME;
435 } SLIST_HEADER, *PSLIST_HEADER;
436 #endif
437
438 #endif /* _SLIST_HEADER_ */
439
440
441 /* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
442 #if defined(_NTSYSTEM_) || defined(__GNUC__)
443 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
444 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
445 #else
446 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
447 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
448 #endif /* _NT_SYSTEM */
449 extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
450 extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
451
452
453 /******************************************************************************
454 * Kernel Types *
455 ******************************************************************************/
456
457 typedef UCHAR KIRQL, *PKIRQL;
458 typedef CCHAR KPROCESSOR_MODE;
459 typedef LONG KPRIORITY;
460
461 typedef ULONG EXECUTION_STATE;
462
463 typedef enum _MODE {
464 KernelMode,
465 UserMode,
466 MaximumMode
467 } MODE;
468
469 /* Processor features */
470 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
471 #define PF_FLOATING_POINT_EMULATED 1
472 #define PF_COMPARE_EXCHANGE_DOUBLE 2
473 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
474 #define PF_PPC_MOVEMEM_64BIT_OK 4
475 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
476 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
477 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
478 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
479 #define PF_PAE_ENABLED 9
480 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
481 #define PF_SSE_DAZ_MODE_AVAILABLE 11
482 #define PF_NX_ENABLED 12
483 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
484 #define PF_COMPARE_EXCHANGE128 14
485 #define PF_COMPARE64_EXCHANGE128 15
486 #define PF_CHANNELS_ENABLED 16
487 #define PF_XSAVE_ENABLED 17
488
489 #define MAXIMUM_SUPPORTED_EXTENSION 512
490 #define MAXIMUM_WAIT_OBJECTS 64
491
492 #define ASSERT_APC(Object) \
493 ASSERT((Object)->Type == ApcObject)
494
495 #define ASSERT_DPC(Object) \
496 ASSERT(((Object)->Type == 0) || \
497 ((Object)->Type == DpcObject) || \
498 ((Object)->Type == ThreadedDpcObject))
499
500 #define ASSERT_GATE(object) \
501 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
502 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
503
504 #define ASSERT_DEVICE_QUEUE(Object) \
505 ASSERT((Object)->Type == DeviceQueueObject)
506
507 #define ASSERT_TIMER(E) \
508 ASSERT(((E)->Header.Type == TimerNotificationObject) || \
509 ((E)->Header.Type == TimerSynchronizationObject))
510
511 #define ASSERT_MUTANT(E) \
512 ASSERT((E)->Header.Type == MutantObject)
513
514 #define ASSERT_SEMAPHORE(E) \
515 ASSERT((E)->Header.Type == SemaphoreObject)
516
517 #define ASSERT_EVENT(E) \
518 ASSERT(((E)->Header.Type == NotificationEvent) || \
519 ((E)->Header.Type == SynchronizationEvent))
520
521 #define DPC_NORMAL 0
522 #define DPC_THREADED 1
523
524 #define GM_LOCK_BIT 0x1
525 #define GM_LOCK_BIT_V 0x0
526 #define GM_LOCK_WAITER_WOKEN 0x2
527 #define GM_LOCK_WAITER_INC 0x4
528
529 #define LOCK_QUEUE_WAIT 1
530 #define LOCK_QUEUE_OWNER 2
531 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4
532 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
533
534 #define PROCESSOR_FEATURE_MAX 64
535
536 #define DBG_STATUS_CONTROL_C 1
537 #define DBG_STATUS_SYSRQ 2
538 #define DBG_STATUS_BUGCHECK_FIRST 3
539 #define DBG_STATUS_BUGCHECK_SECOND 4
540 #define DBG_STATUS_FATAL 5
541 #define DBG_STATUS_DEBUG_CONTROL 6
542 #define DBG_STATUS_WORKER 7
543
544 #if defined(_WIN64)
545 #define MAXIMUM_PROC_PER_GROUP 64
546 #else
547 #define MAXIMUM_PROC_PER_GROUP 32
548 #endif
549 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP
550
551 /* Exception Records */
552 #define EXCEPTION_NONCONTINUABLE 1
553 #define EXCEPTION_MAXIMUM_PARAMETERS 15
554
555 typedef struct _EXCEPTION_RECORD {
556 NTSTATUS ExceptionCode;
557 ULONG ExceptionFlags;
558 struct _EXCEPTION_RECORD *ExceptionRecord;
559 PVOID ExceptionAddress;
560 ULONG NumberParameters;
561 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
562 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
563
564 typedef struct _EXCEPTION_RECORD32 {
565 NTSTATUS ExceptionCode;
566 ULONG ExceptionFlags;
567 ULONG ExceptionRecord;
568 ULONG ExceptionAddress;
569 ULONG NumberParameters;
570 ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
571 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
572
573 typedef struct _EXCEPTION_RECORD64 {
574 NTSTATUS ExceptionCode;
575 ULONG ExceptionFlags;
576 ULONG64 ExceptionRecord;
577 ULONG64 ExceptionAddress;
578 ULONG NumberParameters;
579 ULONG __unusedAlignment;
580 ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
581 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
582
583 typedef struct _EXCEPTION_POINTERS {
584 PEXCEPTION_RECORD ExceptionRecord;
585 PCONTEXT ContextRecord;
586 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
587
588
589 typedef enum _KBUGCHECK_CALLBACK_REASON {
590 KbCallbackInvalid,
591 KbCallbackReserved1,
592 KbCallbackSecondaryDumpData,
593 KbCallbackDumpIo,
594 KbCallbackAddPages
595 } KBUGCHECK_CALLBACK_REASON;
596
597 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
598
599 typedef VOID
600 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
601 IN KBUGCHECK_CALLBACK_REASON Reason,
602 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
603 IN OUT PVOID ReasonSpecificData,
604 IN ULONG ReasonSpecificDataLength);
605
606 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
607 LIST_ENTRY Entry;
608 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
609 PUCHAR Component;
610 ULONG_PTR Checksum;
611 KBUGCHECK_CALLBACK_REASON Reason;
612 UCHAR State;
613 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
614
615 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
616 BufferEmpty,
617 BufferInserted,
618 BufferStarted,
619 BufferFinished,
620 BufferIncomplete
621 } KBUGCHECK_BUFFER_DUMP_STATE;
622
623 typedef VOID
624 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
625 IN PVOID Buffer,
626 IN ULONG Length);
627
628 typedef struct _KBUGCHECK_CALLBACK_RECORD {
629 LIST_ENTRY Entry;
630 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
631 PVOID Buffer;
632 ULONG Length;
633 PUCHAR Component;
634 ULONG_PTR Checksum;
635 UCHAR State;
636 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
637
638 typedef BOOLEAN
639 (DDKAPI *PNMI_CALLBACK)(
640 IN PVOID Context,
641 IN BOOLEAN Handled);
642
643 typedef enum _TRACE_INFORMATION_CLASS {
644 TraceIdClass,
645 TraceHandleClass,
646 TraceEnableFlagsClass,
647 TraceEnableLevelClass,
648 GlobalLoggerHandleClass,
649 EventLoggerHandleClass,
650 AllLoggerHandlesClass,
651 TraceHandleByNameClass,
652 LoggerEventsLostClass,
653 TraceSessionSettingsClass,
654 LoggerEventsLoggedClass,
655 MaxTraceInformationClass
656 } TRACE_INFORMATION_CLASS;
657
658 typedef enum _KINTERRUPT_POLARITY {
659 InterruptPolarityUnknown,
660 InterruptActiveHigh,
661 InterruptActiveLow
662 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
663
664 typedef enum _KPROFILE_SOURCE {
665 ProfileTime,
666 ProfileAlignmentFixup,
667 ProfileTotalIssues,
668 ProfilePipelineDry,
669 ProfileLoadInstructions,
670 ProfilePipelineFrozen,
671 ProfileBranchInstructions,
672 ProfileTotalNonissues,
673 ProfileDcacheMisses,
674 ProfileIcacheMisses,
675 ProfileCacheMisses,
676 ProfileBranchMispredictions,
677 ProfileStoreInstructions,
678 ProfileFpInstructions,
679 ProfileIntegerInstructions,
680 Profile2Issue,
681 Profile3Issue,
682 Profile4Issue,
683 ProfileSpecialInstructions,
684 ProfileTotalCycles,
685 ProfileIcacheIssues,
686 ProfileDcacheAccesses,
687 ProfileMemoryBarrierCycles,
688 ProfileLoadLinkedIssues,
689 ProfileMaximum
690 } KPROFILE_SOURCE;
691
692 typedef enum _KWAIT_REASON {
693 Executive,
694 FreePage,
695 PageIn,
696 PoolAllocation,
697 DelayExecution,
698 Suspended,
699 UserRequest,
700 WrExecutive,
701 WrFreePage,
702 WrPageIn,
703 WrPoolAllocation,
704 WrDelayExecution,
705 WrSuspended,
706 WrUserRequest,
707 WrEventPair,
708 WrQueue,
709 WrLpcReceive,
710 WrLpcReply,
711 WrVirtualMemory,
712 WrPageOut,
713 WrRendezvous,
714 WrKeyedEvent,
715 WrTerminated,
716 WrProcessInSwap,
717 WrCpuRateControl,
718 WrCalloutStack,
719 WrKernel,
720 WrResource,
721 WrPushLock,
722 WrMutex,
723 WrQuantumEnd,
724 WrDispatchInt,
725 WrPreempted,
726 WrYieldExecution,
727 WrFastMutex,
728 WrGuardedMutex,
729 WrRundown,
730 MaximumWaitReason
731 } KWAIT_REASON;
732
733 typedef struct _KWAIT_BLOCK {
734 LIST_ENTRY WaitListEntry;
735 struct _KTHREAD *Thread;
736 PVOID Object;
737 struct _KWAIT_BLOCK *NextWaitBlock;
738 USHORT WaitKey;
739 UCHAR WaitType;
740 volatile UCHAR BlockState;
741 #if defined(_WIN64)
742 LONG SpareLong;
743 #endif
744 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK;
745
746 typedef enum _KINTERRUPT_MODE {
747 LevelSensitive,
748 Latched
749 } KINTERRUPT_MODE;
750
751 #define THREAD_WAIT_OBJECTS 3
752
753 typedef VOID
754 (DDKAPI *PKINTERRUPT_ROUTINE)(
755 VOID);
756
757 typedef enum _KD_OPTION {
758 KD_OPTION_SET_BLOCK_ENABLE,
759 } KD_OPTION;
760
761 typedef enum _INTERFACE_TYPE {
762 InterfaceTypeUndefined = -1,
763 Internal,
764 Isa,
765 Eisa,
766 MicroChannel,
767 TurboChannel,
768 PCIBus,
769 VMEBus,
770 NuBus,
771 PCMCIABus,
772 CBus,
773 MPIBus,
774 MPSABus,
775 ProcessorInternal,
776 InternalPowerBus,
777 PNPISABus,
778 PNPBus,
779 Vmcs,
780 MaximumInterfaceType
781 } INTERFACE_TYPE, *PINTERFACE_TYPE;
782
783 typedef VOID
784 (DDKAPI *PKNORMAL_ROUTINE)(
785 IN PVOID NormalContext,
786 IN PVOID SystemArgument1,
787 IN PVOID SystemArgument2);
788
789 typedef VOID
790 (DDKAPI *PKRUNDOWN_ROUTINE)(
791 IN struct _KAPC *Apc);
792
793 typedef VOID
794 (DDKAPI *PKKERNEL_ROUTINE)(
795 IN struct _KAPC *Apc,
796 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
797 IN OUT PVOID *NormalContext,
798 IN OUT PVOID *SystemArgument1,
799 IN OUT PVOID *SystemArgument2);
800
801 typedef struct _KAPC
802 {
803 UCHAR Type;
804 UCHAR SpareByte0;
805 UCHAR Size;
806 UCHAR SpareByte1;
807 ULONG SpareLong0;
808 struct _KTHREAD *Thread;
809 LIST_ENTRY ApcListEntry;
810 PKKERNEL_ROUTINE KernelRoutine;
811 PKRUNDOWN_ROUTINE RundownRoutine;
812 PKNORMAL_ROUTINE NormalRoutine;
813 PVOID NormalContext;
814 PVOID SystemArgument1;
815 PVOID SystemArgument2;
816 CCHAR ApcStateIndex;
817 KPROCESSOR_MODE ApcMode;
818 BOOLEAN Inserted;
819 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
820
821 typedef struct _KDEVICE_QUEUE_ENTRY {
822 LIST_ENTRY DeviceListEntry;
823 ULONG SortKey;
824 BOOLEAN Inserted;
825 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
826 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
827
828 typedef PVOID PKIPI_CONTEXT;
829
830 typedef
831 VOID
832 (NTAPI *PKIPI_WORKER)(
833 IN PKIPI_CONTEXT PacketContext,
834 IN PVOID Parameter1,
835 IN PVOID Parameter2,
836 IN PVOID Parameter3);
837
838 typedef
839 ULONG_PTR
840 (NTAPI *PKIPI_BROADCAST_WORKER)(
841 IN ULONG_PTR Argument);
842
843 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
844
845 typedef struct _KSPIN_LOCK_QUEUE {
846 struct _KSPIN_LOCK_QUEUE *volatile Next;
847 PKSPIN_LOCK volatile Lock;
848 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
849
850 typedef struct _KLOCK_QUEUE_HANDLE {
851 KSPIN_LOCK_QUEUE LockQueue;
852 KIRQL OldIrql;
853 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
854
855 #if defined(_AMD64_)
856
857 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER;
858
859 #define LockQueueDispatcherLock 0
860 #define LockQueueExpansionLock 1
861 #define LockQueuePfnLock 2
862 #define LockQueueSystemSpaceLock 3
863 #define LockQueueVacbLock 4
864 #define LockQueueMasterLock 5
865 #define LockQueueNonPagedPoolLock 6
866 #define LockQueueIoCancelLock 7
867 #define LockQueueWorkQueueLock 8
868 #define LockQueueIoVpbLock 9
869 #define LockQueueIoDatabaseLock 10
870 #define LockQueueIoCompletionLock 11
871 #define LockQueueNtfsStructLock 12
872 #define LockQueueAfdWorkQueueLock 13
873 #define LockQueueBcbLock 14
874 #define LockQueueMmNonPagedPoolLock 15
875 #define LockQueueUnusedSpare16 16
876 #define LockQueueTimerTableLock 17
877 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS)
878
879 #else
880
881 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
882 LockQueueDispatcherLock,
883 LockQueueExpansionLock,
884 LockQueuePfnLock,
885 LockQueueSystemSpaceLock,
886 LockQueueVacbLock,
887 LockQueueMasterLock,
888 LockQueueNonPagedPoolLock,
889 LockQueueIoCancelLock,
890 LockQueueWorkQueueLock,
891 LockQueueIoVpbLock,
892 LockQueueIoDatabaseLock,
893 LockQueueIoCompletionLock,
894 LockQueueNtfsStructLock,
895 LockQueueAfdWorkQueueLock,
896 LockQueueBcbLock,
897 LockQueueMmNonPagedPoolLock,
898 LockQueueUnusedSpare16,
899 LockQueueTimerTableLock,
900 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
901 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
902
903 #endif
904
905 typedef VOID
906 (DDKAPI *PKDEFERRED_ROUTINE)(
907 IN struct _KDPC *Dpc,
908 IN PVOID DeferredContext,
909 IN PVOID SystemArgument1,
910 IN PVOID SystemArgument2);
911
912 typedef enum _KDPC_IMPORTANCE {
913 LowImportance,
914 MediumImportance,
915 HighImportance,
916 MediumHighImportance
917 } KDPC_IMPORTANCE;
918
919 typedef struct _KDPC
920 {
921 UCHAR Type;
922 UCHAR Importance;
923 volatile USHORT Number;
924 LIST_ENTRY DpcListEntry;
925 PKDEFERRED_ROUTINE DeferredRoutine;
926 PVOID DeferredContext;
927 PVOID SystemArgument1;
928 PVOID SystemArgument2;
929 volatile PVOID DpcData;
930 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
931
932 typedef struct _KDPC_WATCHDOG_INFORMATION {
933 ULONG DpcTimeLimit;
934 ULONG DpcTimeCount;
935 ULONG DpcWatchdogLimit;
936 ULONG DpcWatchdogCount;
937 ULONG Reserved;
938 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION;
939
940 typedef struct _KDEVICE_QUEUE {
941 CSHORT Type;
942 CSHORT Size;
943 LIST_ENTRY DeviceListHead;
944 KSPIN_LOCK Lock;
945 #if defined(_AMD64_)
946 union {
947 BOOLEAN Busy;
948 struct {
949 LONG64 Reserved : 8;
950 LONG64 Hint : 56;
951 };
952 };
953 #else
954 BOOLEAN Busy;
955 #endif
956
957 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
958
959 #define TIMER_EXPIRED_INDEX_BITS 6
960 #define TIMER_PROCESSOR_INDEX_BITS 5
961 typedef struct _DISPATCHER_HEADER {
962 _ANONYMOUS_UNION union {
963 _ANONYMOUS_STRUCT struct {
964 UCHAR Type;
965 _ANONYMOUS_UNION union {
966 _ANONYMOUS_UNION union {
967 UCHAR TimerControlFlags;
968 _ANONYMOUS_STRUCT struct {
969 UCHAR Absolute:1;
970 UCHAR Coalescable:1;
971 UCHAR KeepShifting:1;
972 UCHAR EncodedTolerableDelay:5;
973 } DUMMYSTRUCTNAME;
974 } DUMMYUNIONNAME;
975 UCHAR Abandoned;
976 #if (NTDDI_VERSION < NTDDI_WIN7)
977 UCHAR NpxIrql;
978 #endif
979 BOOLEAN Signalling;
980 } DUMMYUNIONNAME;
981 _ANONYMOUS_UNION union {
982 _ANONYMOUS_UNION union {
983 UCHAR ThreadControlFlags;
984 _ANONYMOUS_STRUCT struct {
985 UCHAR CpuThrottled:1;
986 UCHAR CycleProfiling:1;
987 UCHAR CounterProfiling:1;
988 UCHAR Reserved:5;
989 } DUMMYSTRUCTNAME;
990 } DUMMYUNIONNAME;
991 UCHAR Size;
992 UCHAR Hand;
993 } DUMMYUNIONNAME2;
994 _ANONYMOUS_UNION union {
995 #if (NTDDI_VERSION >= NTDDI_WIN7)
996 _ANONYMOUS_UNION union {
997 UCHAR TimerMiscFlags;
998 _ANONYMOUS_STRUCT struct {
999 #if !defined(_X86_)
1000 UCHAR Index:TIMER_EXPIRED_INDEX_BITS;
1001 #else
1002 UCHAR Index:1;
1003 UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS;
1004 #endif
1005 UCHAR Inserted:1;
1006 volatile UCHAR Expired:1;
1007 } DUMMYSTRUCTNAME;
1008 } DUMMYUNIONNAME;
1009 #else
1010 /* Pre Win7 compatibility fix to latest WDK */
1011 UCHAR Inserted;
1012 #endif
1013 _ANONYMOUS_UNION union {
1014 BOOLEAN DebugActive;
1015 _ANONYMOUS_STRUCT struct {
1016 BOOLEAN ActiveDR7:1;
1017 BOOLEAN Instrumented:1;
1018 BOOLEAN Reserved2:4;
1019 BOOLEAN UmsScheduled:1;
1020 BOOLEAN UmsPrimary:1;
1021 } DUMMYSTRUCTNAME;
1022 } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */
1023 BOOLEAN DpcActive;
1024 } DUMMYUNIONNAME3;
1025 } DUMMYSTRUCTNAME;
1026 volatile LONG Lock;
1027 } DUMMYUNIONNAME;
1028 LONG SignalState;
1029 LIST_ENTRY WaitListHead;
1030 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
1031
1032 typedef struct _KEVENT {
1033 DISPATCHER_HEADER Header;
1034 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
1035
1036 typedef struct _KSEMAPHORE {
1037 DISPATCHER_HEADER Header;
1038 LONG Limit;
1039 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
1040
1041 typedef struct _KGATE
1042 {
1043 DISPATCHER_HEADER Header;
1044 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1045
1046 typedef struct _KGUARDED_MUTEX
1047 {
1048 volatile LONG Count;
1049 PKTHREAD Owner;
1050 ULONG Contention;
1051 KGATE Gate;
1052 __GNU_EXTENSION union
1053 {
1054 __GNU_EXTENSION struct
1055 {
1056 SHORT KernelApcDisable;
1057 SHORT SpecialApcDisable;
1058 };
1059 ULONG CombinedApcDisable;
1060 };
1061 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
1062
1063 typedef struct _KMUTANT {
1064 DISPATCHER_HEADER Header;
1065 LIST_ENTRY MutantListEntry;
1066 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1067 BOOLEAN Abandoned;
1068 UCHAR ApcDisable;
1069 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1070
1071 #define TIMER_TABLE_SIZE 512
1072 #define TIMER_TABLE_SHIFT 9
1073
1074 typedef struct _KTIMER {
1075 DISPATCHER_HEADER Header;
1076 ULARGE_INTEGER DueTime;
1077 LIST_ENTRY TimerListEntry;
1078 struct _KDPC *Dpc;
1079 #if !defined(_X86_)
1080 ULONG Processor;
1081 #endif
1082 ULONG Period;
1083 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1084
1085 typedef BOOLEAN
1086 (DDKAPI *PKSYNCHRONIZE_ROUTINE)(
1087 IN PVOID SynchronizeContext);
1088
1089 typedef enum _POOL_TYPE {
1090 NonPagedPool,
1091 PagedPool,
1092 NonPagedPoolMustSucceed,
1093 DontUseThisType,
1094 NonPagedPoolCacheAligned,
1095 PagedPoolCacheAligned,
1096 NonPagedPoolCacheAlignedMustS,
1097 MaxPoolType,
1098 NonPagedPoolSession = 32,
1099 PagedPoolSession,
1100 NonPagedPoolMustSucceedSession,
1101 DontUseThisTypeSession,
1102 NonPagedPoolCacheAlignedSession,
1103 PagedPoolCacheAlignedSession,
1104 NonPagedPoolCacheAlignedMustSSession
1105 } POOL_TYPE;
1106
1107 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
1108 {
1109 StandardDesign,
1110 NEC98x86,
1111 EndAlternatives
1112 } ALTERNATIVE_ARCHITECTURE_TYPE;
1113
1114 typedef struct _KSYSTEM_TIME
1115 {
1116 ULONG LowPart;
1117 LONG High1Time;
1118 LONG High2Time;
1119 } KSYSTEM_TIME, *PKSYSTEM_TIME;
1120
1121 typedef struct _PNP_BUS_INFORMATION {
1122 GUID BusTypeGuid;
1123 INTERFACE_TYPE LegacyBusType;
1124 ULONG BusNumber;
1125 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
1126
1127 typedef struct DECLSPEC_ALIGN(16) _M128A {
1128 ULONGLONG Low;
1129 LONGLONG High;
1130 } M128A, *PM128A;
1131
1132 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
1133 USHORT ControlWord;
1134 USHORT StatusWord;
1135 UCHAR TagWord;
1136 UCHAR Reserved1;
1137 USHORT ErrorOpcode;
1138 ULONG ErrorOffset;
1139 USHORT ErrorSelector;
1140 USHORT Reserved2;
1141 ULONG DataOffset;
1142 USHORT DataSelector;
1143 USHORT Reserved3;
1144 ULONG MxCsr;
1145 ULONG MxCsr_Mask;
1146 M128A FloatRegisters[8];
1147 #if defined(_WIN64)
1148 M128A XmmRegisters[16];
1149 UCHAR Reserved4[96];
1150 #else
1151 M128A XmmRegisters[8];
1152 UCHAR Reserved4[192];
1153 ULONG StackControl[7];
1154 ULONG Cr0NpxState;
1155 #endif
1156 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1157
1158
1159
1160 /******************************************************************************
1161 * Memory manager Types *
1162 ******************************************************************************/
1163
1164 #define MM_DONT_ZERO_ALLOCATION 0x00000001
1165 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
1166 #define MM_ALLOCATE_FULLY_REQUIRED 0x00000004
1167 #define MM_ALLOCATE_NO_WAIT 0x00000008
1168 #define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010
1169 #define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020
1170
1171 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
1172 #define MDL_PAGES_LOCKED 0x0002
1173 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
1174 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
1175 #define MDL_PARTIAL 0x0010
1176 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
1177 #define MDL_IO_PAGE_READ 0x0040
1178 #define MDL_WRITE_OPERATION 0x0080
1179 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
1180 #define MDL_FREE_EXTRA_PTES 0x0200
1181 #define MDL_DESCRIBES_AWE 0x0400
1182 #define MDL_IO_SPACE 0x0800
1183 #define MDL_NETWORK_HEADER 0x1000
1184 #define MDL_MAPPING_CAN_FAIL 0x2000
1185 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
1186 #define MDL_INTERNAL 0x8000
1187
1188 #define MDL_MAPPING_FLAGS ( \
1189 MDL_MAPPED_TO_SYSTEM_VA | \
1190 MDL_PAGES_LOCKED | \
1191 MDL_SOURCE_IS_NONPAGED_POOL | \
1192 MDL_PARTIAL_HAS_BEEN_MAPPED | \
1193 MDL_PARENT_MAPPED_SYSTEM_VA | \
1194 MDL_SYSTEM_VA | \
1195 MDL_IO_SPACE)
1196
1197 #define FLUSH_MULTIPLE_MAXIMUM 32
1198
1199 /* Section access rights */
1200 #define SECTION_QUERY 0x0001
1201 #define SECTION_MAP_WRITE 0x0002
1202 #define SECTION_MAP_READ 0x0004
1203 #define SECTION_MAP_EXECUTE 0x0008
1204 #define SECTION_EXTEND_SIZE 0x0010
1205 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
1206
1207 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
1208 SECTION_MAP_WRITE | \
1209 SECTION_MAP_READ | \
1210 SECTION_MAP_EXECUTE | \
1211 SECTION_EXTEND_SIZE)
1212
1213 #define SESSION_QUERY_ACCESS 0x0001
1214 #define SESSION_MODIFY_ACCESS 0x0002
1215
1216 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
1217 SESSION_QUERY_ACCESS | \
1218 SESSION_MODIFY_ACCESS)
1219
1220 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
1221
1222 #define PAGE_NOACCESS 0x01
1223 #define PAGE_READONLY 0x02
1224 #define PAGE_READWRITE 0x04
1225 #define PAGE_WRITECOPY 0x08
1226 #define PAGE_EXECUTE 0x10
1227 #define PAGE_EXECUTE_READ 0x20
1228 #define PAGE_EXECUTE_READWRITE 0x40
1229 #define PAGE_EXECUTE_WRITECOPY 0x80
1230 #define PAGE_GUARD 0x100
1231 #define PAGE_NOCACHE 0x200
1232 #define PAGE_WRITECOMBINE 0x400
1233
1234 #define MEM_COMMIT 0x1000
1235 #define MEM_RESERVE 0x2000
1236 #define MEM_DECOMMIT 0x4000
1237 #define MEM_RELEASE 0x8000
1238 #define MEM_FREE 0x10000
1239 #define MEM_PRIVATE 0x20000
1240 #define MEM_MAPPED 0x40000
1241 #define MEM_RESET 0x80000
1242 #define MEM_TOP_DOWN 0x100000
1243 #define MEM_LARGE_PAGES 0x20000000
1244 #define MEM_4MB_PAGES 0x80000000
1245
1246 #define SEC_RESERVE 0x4000000
1247 #define SEC_COMMIT 0x8000000
1248 #define SEC_LARGE_PAGES 0x80000000
1249
1250 /* Section map options */
1251 typedef enum _SECTION_INHERIT {
1252 ViewShare = 1,
1253 ViewUnmap = 2
1254 } SECTION_INHERIT;
1255
1256 typedef ULONG PFN_COUNT;
1257 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
1258 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
1259
1260 typedef struct _MDL {
1261 struct _MDL *Next;
1262 CSHORT Size;
1263 CSHORT MdlFlags;
1264 struct _EPROCESS *Process;
1265 PVOID MappedSystemVa;
1266 PVOID StartVa;
1267 ULONG ByteCount;
1268 ULONG ByteOffset;
1269 } MDL, *PMDL;
1270 typedef MDL *PMDLX;
1271
1272 typedef enum _MEMORY_CACHING_TYPE_ORIG {
1273 MmFrameBufferCached = 2
1274 } MEMORY_CACHING_TYPE_ORIG;
1275
1276 typedef enum _MEMORY_CACHING_TYPE {
1277 MmNonCached = FALSE,
1278 MmCached = TRUE,
1279 MmWriteCombined = MmFrameBufferCached,
1280 MmHardwareCoherentCached,
1281 MmNonCachedUnordered,
1282 MmUSWCCached,
1283 MmMaximumCacheType
1284 } MEMORY_CACHING_TYPE;
1285
1286 typedef enum _MM_PAGE_PRIORITY {
1287 LowPagePriority,
1288 NormalPagePriority = 16,
1289 HighPagePriority = 32
1290 } MM_PAGE_PRIORITY;
1291
1292 typedef enum _LOCK_OPERATION {
1293 IoReadAccess,
1294 IoWriteAccess,
1295 IoModifyAccess
1296 } LOCK_OPERATION;
1297
1298 typedef enum _MM_SYSTEM_SIZE {
1299 MmSmallSystem,
1300 MmMediumSystem,
1301 MmLargeSystem
1302 } MM_SYSTEMSIZE;
1303
1304
1305 /******************************************************************************
1306 * Executive Types *
1307 ******************************************************************************/
1308
1309 #define EX_RUNDOWN_ACTIVE 0x1
1310 #define EX_RUNDOWN_COUNT_SHIFT 0x1
1311 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT)
1312
1313 #ifdef _WIN64
1314 #define PORT_MAXIMUM_MESSAGE_LENGTH 512
1315 #else
1316 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
1317 #endif
1318
1319 typedef struct _FAST_MUTEX {
1320 volatile LONG Count;
1321 PKTHREAD Owner;
1322 ULONG Contention;
1323 KEVENT Event;
1324 ULONG OldIrql;
1325 } FAST_MUTEX, *PFAST_MUTEX;
1326
1327 typedef enum _SUITE_TYPE {
1328 SmallBusiness,
1329 Enterprise,
1330 BackOffice,
1331 CommunicationServer,
1332 TerminalServer,
1333 SmallBusinessRestricted,
1334 EmbeddedNT,
1335 DataCenter,
1336 SingleUserTS,
1337 Personal,
1338 Blade,
1339 EmbeddedRestricted,
1340 SecurityAppliance,
1341 StorageServer,
1342 ComputeServer,
1343 WHServer,
1344 MaxSuiteType
1345 } SUITE_TYPE;
1346
1347 typedef enum _EX_POOL_PRIORITY {
1348 LowPoolPriority,
1349 LowPoolPrioritySpecialPoolOverrun = 8,
1350 LowPoolPrioritySpecialPoolUnderrun = 9,
1351 NormalPoolPriority = 16,
1352 NormalPoolPrioritySpecialPoolOverrun = 24,
1353 NormalPoolPrioritySpecialPoolUnderrun = 25,
1354 HighPoolPriority = 32,
1355 HighPoolPrioritySpecialPoolOverrun = 40,
1356 HighPoolPrioritySpecialPoolUnderrun = 41
1357 } EX_POOL_PRIORITY;
1358
1359 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
1360 #define LOOKASIDE_ALIGN
1361 #else
1362 #define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */
1363 #endif
1364
1365 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
1366
1367 typedef PVOID
1368 (DDKAPI *PALLOCATE_FUNCTION)(
1369 IN POOL_TYPE PoolType,
1370 IN SIZE_T NumberOfBytes,
1371 IN ULONG Tag);
1372
1373 typedef PVOID
1374 (DDKAPI *PALLOCATE_FUNCTION_EX)(
1375 IN POOL_TYPE PoolType,
1376 IN SIZE_T NumberOfBytes,
1377 IN ULONG Tag,
1378 IN OUT PLOOKASIDE_LIST_EX Lookaside);
1379
1380 typedef VOID
1381 (DDKAPI *PFREE_FUNCTION)(
1382 IN PVOID Buffer);
1383
1384 typedef VOID
1385 (DDKAPI *PFREE_FUNCTION_EX)(
1386 IN PVOID Buffer,
1387 IN OUT PLOOKASIDE_LIST_EX Lookaside);
1388
1389 typedef VOID
1390 (DDKAPI *PCALLBACK_FUNCTION)(
1391 IN PVOID CallbackContext,
1392 IN PVOID Argument1,
1393 IN PVOID Argument2);
1394
1395 #define GENERAL_LOOKASIDE_LAYOUT \
1396 union { \
1397 SLIST_HEADER ListHead; \
1398 SINGLE_LIST_ENTRY SingleListHead; \
1399 } DUMMYUNIONNAME; \
1400 USHORT Depth; \
1401 USHORT MaximumDepth; \
1402 ULONG TotalAllocates; \
1403 union { \
1404 ULONG AllocateMisses; \
1405 ULONG AllocateHits; \
1406 } DUMMYUNIONNAME2; \
1407 \
1408 ULONG TotalFrees; \
1409 union { \
1410 ULONG FreeMisses; \
1411 ULONG FreeHits; \
1412 } DUMMYUNIONNAME3; \
1413 \
1414 POOL_TYPE Type; \
1415 ULONG Tag; \
1416 ULONG Size; \
1417 union { \
1418 PALLOCATE_FUNCTION_EX AllocateEx; \
1419 PALLOCATE_FUNCTION Allocate; \
1420 } DUMMYUNIONNAME4; \
1421 \
1422 union { \
1423 PFREE_FUNCTION_EX FreeEx; \
1424 PFREE_FUNCTION Free; \
1425 } DUMMYUNIONNAME5; \
1426 \
1427 LIST_ENTRY ListEntry; \
1428 ULONG LastTotalAllocates; \
1429 union { \
1430 ULONG LastAllocateMisses; \
1431 ULONG LastAllocateHits; \
1432 } DUMMYUNIONNAME6; \
1433 ULONG Future[2];
1434
1435 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
1436 GENERAL_LOOKASIDE_LAYOUT
1437 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
1438
1439 typedef struct _GENERAL_LOOKASIDE_POOL {
1440 GENERAL_LOOKASIDE_LAYOUT
1441 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
1442
1443 typedef struct _PAGED_LOOKASIDE_LIST {
1444 GENERAL_LOOKASIDE L;
1445 #if !defined(_AMD64_) && !defined(_IA64_)
1446 FAST_MUTEX Lock__ObsoleteButDoNotDelete;
1447 #endif
1448 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
1449
1450 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
1451 GENERAL_LOOKASIDE L;
1452 #if !defined(_AMD64_) && !defined(_IA64_)
1453 KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
1454 #endif
1455 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
1456
1457 typedef struct _LOOKASIDE_LIST_EX {
1458 GENERAL_LOOKASIDE_POOL L;
1459 } LOOKASIDE_LIST_EX;
1460
1461 typedef struct _EX_RUNDOWN_REF {
1462 __GNU_EXTENSION union {
1463 volatile ULONG_PTR Count;
1464 volatile PVOID Ptr;
1465 };
1466 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
1467
1468 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE;
1469
1470 typedef VOID
1471 (DDKAPI *PWORKER_THREAD_ROUTINE)(
1472 IN PVOID Parameter);
1473
1474 typedef struct _WORK_QUEUE_ITEM {
1475 LIST_ENTRY List;
1476 PWORKER_THREAD_ROUTINE WorkerRoutine;
1477 volatile PVOID Parameter;
1478 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
1479
1480
1481 /******************************************************************************
1482 * Security Manager Types *
1483 ******************************************************************************/
1484
1485 /* Simple types */
1486 typedef PVOID PSECURITY_DESCRIPTOR;
1487 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
1488 typedef ULONG ACCESS_MASK, *PACCESS_MASK;
1489 typedef PVOID PACCESS_TOKEN;
1490 typedef PVOID PSID;
1491
1492 #define DELETE 0x00010000L
1493 #define READ_CONTROL 0x00020000L
1494 #define WRITE_DAC 0x00040000L
1495 #define WRITE_OWNER 0x00080000L
1496 #define SYNCHRONIZE 0x00100000L
1497 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L
1498 #define STANDARD_RIGHTS_READ READ_CONTROL
1499 #define STANDARD_RIGHTS_WRITE READ_CONTROL
1500 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
1501 #define STANDARD_RIGHTS_ALL 0x001F0000L
1502 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL
1503 #define ACCESS_SYSTEM_SECURITY 0x01000000L
1504 #define MAXIMUM_ALLOWED 0x02000000L
1505 #define GENERIC_READ 0x80000000L
1506 #define GENERIC_WRITE 0x40000000L
1507 #define GENERIC_EXECUTE 0x20000000L
1508 #define GENERIC_ALL 0x10000000L
1509
1510 typedef struct _GENERIC_MAPPING {
1511 ACCESS_MASK GenericRead;
1512 ACCESS_MASK GenericWrite;
1513 ACCESS_MASK GenericExecute;
1514 ACCESS_MASK GenericAll;
1515 } GENERIC_MAPPING, *PGENERIC_MAPPING;
1516
1517 #define ACL_REVISION 2
1518 #define ACL_REVISION_DS 4
1519
1520 #define ACL_REVISION1 1
1521 #define ACL_REVISION2 2
1522 #define ACL_REVISION3 3
1523 #define ACL_REVISION4 4
1524 #define MIN_ACL_REVISION ACL_REVISION2
1525 #define MAX_ACL_REVISION ACL_REVISION4
1526
1527 typedef struct _ACL {
1528 UCHAR AclRevision;
1529 UCHAR Sbz1;
1530 USHORT AclSize;
1531 USHORT AceCount;
1532 USHORT Sbz2;
1533 } ACL, *PACL;
1534
1535 /* Current security descriptor revision value */
1536 #define SECURITY_DESCRIPTOR_REVISION (1)
1537 #define SECURITY_DESCRIPTOR_REVISION1 (1)
1538
1539 /* Privilege attributes */
1540 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
1541 #define SE_PRIVILEGE_ENABLED (0x00000002L)
1542 #define SE_PRIVILEGE_REMOVED (0X00000004L)
1543 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
1544
1545 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
1546 SE_PRIVILEGE_ENABLED | \
1547 SE_PRIVILEGE_REMOVED | \
1548 SE_PRIVILEGE_USED_FOR_ACCESS)
1549
1550 #include <pshpack4.h>
1551 typedef struct _LUID_AND_ATTRIBUTES {
1552 LUID Luid;
1553 ULONG Attributes;
1554 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
1555 #include <poppack.h>
1556
1557 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
1558 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
1559
1560 /* Privilege sets */
1561 #define PRIVILEGE_SET_ALL_NECESSARY (1)
1562
1563 typedef struct _PRIVILEGE_SET {
1564 ULONG PrivilegeCount;
1565 ULONG Control;
1566 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
1567 } PRIVILEGE_SET,*PPRIVILEGE_SET;
1568
1569 typedef enum _SECURITY_IMPERSONATION_LEVEL {
1570 SecurityAnonymous,
1571 SecurityIdentification,
1572 SecurityImpersonation,
1573 SecurityDelegation
1574 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
1575
1576 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
1577 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
1578 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
1579 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
1580
1581 #define SECURITY_DYNAMIC_TRACKING (TRUE)
1582 #define SECURITY_STATIC_TRACKING (FALSE)
1583
1584 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
1585
1586 typedef struct _SECURITY_QUALITY_OF_SERVICE {
1587 ULONG Length;
1588 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
1589 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
1590 BOOLEAN EffectiveOnly;
1591 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
1592
1593 typedef struct _SE_IMPERSONATION_STATE {
1594 PACCESS_TOKEN Token;
1595 BOOLEAN CopyOnOpen;
1596 BOOLEAN EffectiveOnly;
1597 SECURITY_IMPERSONATION_LEVEL Level;
1598 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
1599
1600 #define OWNER_SECURITY_INFORMATION (0x00000001L)
1601 #define GROUP_SECURITY_INFORMATION (0x00000002L)
1602 #define DACL_SECURITY_INFORMATION (0x00000004L)
1603 #define SACL_SECURITY_INFORMATION (0x00000008L)
1604 #define LABEL_SECURITY_INFORMATION (0x00000010L)
1605
1606 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
1607 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
1608 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
1609 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
1610
1611 typedef enum _SECURITY_OPERATION_CODE {
1612 SetSecurityDescriptor,
1613 QuerySecurityDescriptor,
1614 DeleteSecurityDescriptor,
1615 AssignSecurityDescriptor
1616 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
1617
1618 #define INITIAL_PRIVILEGE_COUNT 3
1619
1620 typedef struct _INITIAL_PRIVILEGE_SET {
1621 ULONG PrivilegeCount;
1622 ULONG Control;
1623 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
1624 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
1625
1626 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
1627 #define SE_CREATE_TOKEN_PRIVILEGE 2
1628 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
1629 #define SE_LOCK_MEMORY_PRIVILEGE 4
1630 #define SE_INCREASE_QUOTA_PRIVILEGE 5
1631 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
1632 #define SE_TCB_PRIVILEGE 7
1633 #define SE_SECURITY_PRIVILEGE 8
1634 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
1635 #define SE_LOAD_DRIVER_PRIVILEGE 10
1636 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
1637 #define SE_SYSTEMTIME_PRIVILEGE 12
1638 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
1639 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
1640 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
1641 #define SE_CREATE_PERMANENT_PRIVILEGE 16
1642 #define SE_BACKUP_PRIVILEGE 17
1643 #define SE_RESTORE_PRIVILEGE 18
1644 #define SE_SHUTDOWN_PRIVILEGE 19
1645 #define SE_DEBUG_PRIVILEGE 20
1646 #define SE_AUDIT_PRIVILEGE 21
1647 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
1648 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
1649 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
1650 #define SE_UNDOCK_PRIVILEGE 25
1651 #define SE_SYNC_AGENT_PRIVILEGE 26
1652 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
1653 #define SE_MANAGE_VOLUME_PRIVILEGE 28
1654 #define SE_IMPERSONATE_PRIVILEGE 29
1655 #define SE_CREATE_GLOBAL_PRIVILEGE 30
1656 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
1657 #define SE_RELABEL_PRIVILEGE 32
1658 #define SE_INC_WORKING_SET_PRIVILEGE 33
1659 #define SE_TIME_ZONE_PRIVILEGE 34
1660 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35
1661 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
1662
1663 typedef struct _SECURITY_SUBJECT_CONTEXT {
1664 PACCESS_TOKEN ClientToken;
1665 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
1666 PACCESS_TOKEN PrimaryToken;
1667 PVOID ProcessAuditId;
1668 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
1669
1670 typedef struct _ACCESS_STATE {
1671 LUID OperationID;
1672 BOOLEAN SecurityEvaluated;
1673 BOOLEAN GenerateAudit;
1674 BOOLEAN GenerateOnClose;
1675 BOOLEAN PrivilegesAllocated;
1676 ULONG Flags;
1677 ACCESS_MASK RemainingDesiredAccess;
1678 ACCESS_MASK PreviouslyGrantedAccess;
1679 ACCESS_MASK OriginalDesiredAccess;
1680 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
1681 PSECURITY_DESCRIPTOR SecurityDescriptor;
1682 PVOID AuxData;
1683 union {
1684 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
1685 PRIVILEGE_SET PrivilegeSet;
1686 } Privileges;
1687
1688 BOOLEAN AuditPrivileges;
1689 UNICODE_STRING ObjectName;
1690 UNICODE_STRING ObjectTypeName;
1691 } ACCESS_STATE, *PACCESS_STATE;
1692
1693
1694 #ifndef _NTLSA_IFS_
1695
1696 #ifndef _NTLSA_AUDIT_
1697 #define _NTLSA_AUDIT_
1698
1699 #define SE_MAX_AUDIT_PARAMETERS 32
1700 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
1701
1702 #define SE_ADT_OBJECT_ONLY 0x1
1703
1704 #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001
1705 #define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002
1706 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004
1707 #define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008
1708 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
1709
1710 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
1711 ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
1712 (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
1713
1714 typedef enum _SE_ADT_PARAMETER_TYPE {
1715 SeAdtParmTypeNone = 0,
1716 SeAdtParmTypeString,
1717 SeAdtParmTypeFileSpec,
1718 SeAdtParmTypeUlong,
1719 SeAdtParmTypeSid,
1720 SeAdtParmTypeLogonId,
1721 SeAdtParmTypeNoLogonId,
1722 SeAdtParmTypeAccessMask,
1723 SeAdtParmTypePrivs,
1724 SeAdtParmTypeObjectTypes,
1725 SeAdtParmTypeHexUlong,
1726 SeAdtParmTypePtr,
1727 SeAdtParmTypeTime,
1728 SeAdtParmTypeGuid,
1729 SeAdtParmTypeLuid,
1730 SeAdtParmTypeHexInt64,
1731 SeAdtParmTypeStringList,
1732 SeAdtParmTypeSidList,
1733 SeAdtParmTypeDuration,
1734 SeAdtParmTypeUserAccountControl,
1735 SeAdtParmTypeNoUac,
1736 SeAdtParmTypeMessage,
1737 SeAdtParmTypeDateTime,
1738 SeAdtParmTypeSockAddr,
1739 SeAdtParmTypeSD,
1740 SeAdtParmTypeLogonHours,
1741 SeAdtParmTypeLogonIdNoSid,
1742 SeAdtParmTypeUlongNoConv,
1743 SeAdtParmTypeSockAddrNoPort,
1744 SeAdtParmTypeAccessReason
1745 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
1746
1747 typedef struct _SE_ADT_OBJECT_TYPE {
1748 GUID ObjectType;
1749 USHORT Flags;
1750 USHORT Level;
1751 ACCESS_MASK AccessMask;
1752 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
1753
1754 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
1755 SE_ADT_PARAMETER_TYPE Type;
1756 ULONG Length;
1757 ULONG_PTR Data[2];
1758 PVOID Address;
1759 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
1760
1761 typedef struct _SE_ADT_ACCESS_REASON {
1762 ACCESS_MASK AccessMask;
1763 ULONG AccessReasons[32];
1764 ULONG ObjectTypeIndex;
1765 ULONG AccessGranted;
1766 PSECURITY_DESCRIPTOR SecurityDescriptor;
1767 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
1768
1769 typedef struct _SE_ADT_PARAMETER_ARRAY {
1770 ULONG CategoryId;
1771 ULONG AuditId;
1772 ULONG ParameterCount;
1773 ULONG Length;
1774 USHORT FlatSubCategoryId;
1775 USHORT Type;
1776 ULONG Flags;
1777 SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
1778 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
1779
1780 #endif /* !_NTLSA_AUDIT_ */
1781 #endif /* !_NTLSA_IFS_ */
1782
1783
1784 /******************************************************************************
1785 * Power Management Support Types *
1786 ******************************************************************************/
1787
1788 #ifndef _PO_DDK_
1789 #define _PO_DDK_
1790
1791 /* Power States/Levels */
1792 typedef enum _SYSTEM_POWER_STATE {
1793 PowerSystemUnspecified,
1794 PowerSystemWorking,
1795 PowerSystemSleeping1,
1796 PowerSystemSleeping2,
1797 PowerSystemSleeping3,
1798 PowerSystemHibernate,
1799 PowerSystemShutdown,
1800 PowerSystemMaximum
1801 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
1802
1803 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
1804
1805 typedef enum _POWER_INFORMATION_LEVEL {
1806 SystemPowerPolicyAc,
1807 SystemPowerPolicyDc,
1808 VerifySystemPolicyAc,
1809 VerifySystemPolicyDc,
1810 SystemPowerCapabilities,
1811 SystemBatteryState,
1812 SystemPowerStateHandler,
1813 ProcessorStateHandler,
1814 SystemPowerPolicyCurrent,
1815 AdministratorPowerPolicy,
1816 SystemReserveHiberFile,
1817 ProcessorInformation,
1818 SystemPowerInformation,
1819 ProcessorStateHandler2,
1820 LastWakeTime,
1821 LastSleepTime,
1822 SystemExecutionState,
1823 SystemPowerStateNotifyHandler,
1824 ProcessorPowerPolicyAc,
1825 ProcessorPowerPolicyDc,
1826 VerifyProcessorPowerPolicyAc,
1827 VerifyProcessorPowerPolicyDc,
1828 ProcessorPowerPolicyCurrent,
1829 SystemPowerStateLogging,
1830 SystemPowerLoggingEntry,
1831 SetPowerSettingValue,
1832 NotifyUserPowerSetting,
1833 PowerInformationLevelUnused0,
1834 PowerInformationLevelUnused1,
1835 SystemVideoState,
1836 TraceApplicationPowerMessage,
1837 TraceApplicationPowerMessageEnd,
1838 ProcessorPerfStates,
1839 ProcessorIdleStates,
1840 ProcessorCap,
1841 SystemWakeSource,
1842 SystemHiberFileInformation,
1843 TraceServicePowerMessage,
1844 ProcessorLoad,
1845 PowerShutdownNotification,
1846 MonitorCapabilities,
1847 SessionPowerInit,
1848 SessionDisplayState,
1849 PowerRequestCreate,
1850 PowerRequestAction,
1851 GetPowerRequestList,
1852 ProcessorInformationEx,
1853 NotifyUserModeLegacyPowerEvent,
1854 GroupPark,
1855 ProcessorIdleDomains,
1856 WakeTimerList,
1857 SystemHiberFileSize,
1858 PowerInformationLevelMaximum
1859 } POWER_INFORMATION_LEVEL;
1860
1861 typedef enum {
1862 PowerActionNone,
1863 PowerActionReserved,
1864 PowerActionSleep,
1865 PowerActionHibernate,
1866 PowerActionShutdown,
1867 PowerActionShutdownReset,
1868 PowerActionShutdownOff,
1869 PowerActionWarmEject
1870 } POWER_ACTION, *PPOWER_ACTION;
1871
1872 typedef enum _DEVICE_POWER_STATE {
1873 PowerDeviceUnspecified,
1874 PowerDeviceD0,
1875 PowerDeviceD1,
1876 PowerDeviceD2,
1877 PowerDeviceD3,
1878 PowerDeviceMaximum
1879 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
1880
1881 typedef union _POWER_STATE {
1882 SYSTEM_POWER_STATE SystemState;
1883 DEVICE_POWER_STATE DeviceState;
1884 } POWER_STATE, *PPOWER_STATE;
1885
1886 typedef enum _POWER_STATE_TYPE {
1887 SystemPowerState = 0,
1888 DevicePowerState
1889 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
1890
1891 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
1892 typedef struct {
1893 ULONG Granularity;
1894 ULONG Capacity;
1895 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
1896 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
1897
1898 #endif /* !_PO_DDK_ */
1899
1900 typedef VOID
1901 (DDKAPI *PREQUEST_POWER_COMPLETE)(
1902 IN struct _DEVICE_OBJECT *DeviceObject,
1903 IN UCHAR MinorFunction,
1904 IN POWER_STATE PowerState,
1905 IN PVOID Context,
1906 IN struct _IO_STATUS_BLOCK *IoStatus);
1907
1908 typedef
1909 NTSTATUS
1910 (DDKAPI POWER_SETTING_CALLBACK)(
1911 IN LPCGUID SettingGuid,
1912 IN PVOID Value,
1913 IN ULONG ValueLength,
1914 IN OUT PVOID Context OPTIONAL);
1915
1916 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
1917
1918 #define PO_CB_SYSTEM_POWER_POLICY 0
1919 #define PO_CB_AC_STATUS 1
1920 #define PO_CB_BUTTON_COLLISION 2
1921 #define PO_CB_SYSTEM_STATE_LOCK 3
1922 #define PO_CB_LID_SWITCH_STATE 4
1923 #define PO_CB_PROCESSOR_POWER_POLICY 5
1924
1925 /******************************************************************************
1926 * Configuration Manager Types *
1927 ******************************************************************************/
1928
1929 /* Resource list definitions */
1930 typedef int CM_RESOURCE_TYPE;
1931
1932 #define CmResourceTypeNull 0
1933 #define CmResourceTypePort 1
1934 #define CmResourceTypeInterrupt 2
1935 #define CmResourceTypeMemory 3
1936 #define CmResourceTypeDma 4
1937 #define CmResourceTypeDeviceSpecific 5
1938 #define CmResourceTypeBusNumber 6
1939 #define CmResourceTypeNonArbitrated 128
1940 #define CmResourceTypeConfigData 128
1941 #define CmResourceTypeDevicePrivate 129
1942 #define CmResourceTypePcCardConfig 130
1943 #define CmResourceTypeMfCardConfig 131
1944
1945 /* KEY_VALUE_Xxx.Type */
1946 #define REG_NONE 0
1947 #define REG_SZ 1
1948 #define REG_EXPAND_SZ 2
1949 #define REG_BINARY 3
1950 #define REG_DWORD 4
1951 #define REG_DWORD_LITTLE_ENDIAN 4
1952 #define REG_DWORD_BIG_ENDIAN 5
1953 #define REG_LINK 6
1954 #define REG_MULTI_SZ 7
1955 #define REG_RESOURCE_LIST 8
1956 #define REG_FULL_RESOURCE_DESCRIPTOR 9
1957 #define REG_RESOURCE_REQUIREMENTS_LIST 10
1958 #define REG_QWORD 11
1959 #define REG_QWORD_LITTLE_ENDIAN 11
1960
1961 /* Registry Access Rights */
1962 #define KEY_QUERY_VALUE (0x0001)
1963 #define KEY_SET_VALUE (0x0002)
1964 #define KEY_CREATE_SUB_KEY (0x0004)
1965 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
1966 #define KEY_NOTIFY (0x0010)
1967 #define KEY_CREATE_LINK (0x0020)
1968 #define KEY_WOW64_32KEY (0x0200)
1969 #define KEY_WOW64_64KEY (0x0100)
1970 #define KEY_WOW64_RES (0x0300)
1971
1972 #define KEY_READ ((STANDARD_RIGHTS_READ |\
1973 KEY_QUERY_VALUE |\
1974 KEY_ENUMERATE_SUB_KEYS |\
1975 KEY_NOTIFY) \
1976 & \
1977 (~SYNCHRONIZE))
1978
1979 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
1980 KEY_SET_VALUE |\
1981 KEY_CREATE_SUB_KEY) \
1982 & \
1983 (~SYNCHRONIZE))
1984
1985 #define KEY_EXECUTE ((KEY_READ) \
1986 & \
1987 (~SYNCHRONIZE))
1988
1989 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
1990 KEY_QUERY_VALUE |\
1991 KEY_SET_VALUE |\
1992 KEY_CREATE_SUB_KEY |\
1993 KEY_ENUMERATE_SUB_KEYS |\
1994 KEY_NOTIFY |\
1995 KEY_CREATE_LINK) \
1996 & \
1997 (~SYNCHRONIZE))
1998
1999 /* Registry Open/Create Options */
2000 #define REG_OPTION_RESERVED (0x00000000L)
2001 #define REG_OPTION_NON_VOLATILE (0x00000000L)
2002 #define REG_OPTION_VOLATILE (0x00000001L)
2003 #define REG_OPTION_CREATE_LINK (0x00000002L)
2004 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
2005 #define REG_OPTION_OPEN_LINK (0x00000008L)
2006
2007 #define REG_LEGAL_OPTION \
2008 (REG_OPTION_RESERVED |\
2009 REG_OPTION_NON_VOLATILE |\
2010 REG_OPTION_VOLATILE |\
2011 REG_OPTION_CREATE_LINK |\
2012 REG_OPTION_BACKUP_RESTORE |\
2013 REG_OPTION_OPEN_LINK)
2014
2015 /* Key creation/open disposition */
2016 #define REG_CREATED_NEW_KEY (0x00000001L)
2017 #define REG_OPENED_EXISTING_KEY (0x00000002L)
2018
2019 /* Key restore & hive load flags */
2020 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
2021 #define REG_REFRESH_HIVE (0x00000002L)
2022 #define REG_NO_LAZY_FLUSH (0x00000004L)
2023 #define REG_FORCE_RESTORE (0x00000008L)
2024 #define REG_APP_HIVE (0x00000010L)
2025 #define REG_PROCESS_PRIVATE (0x00000020L)
2026 #define REG_START_JOURNAL (0x00000040L)
2027 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
2028 #define REG_HIVE_NO_RM (0x00000100L)
2029 #define REG_HIVE_SINGLE_LOG (0x00000200L)
2030
2031 /* Unload Flags */
2032 #define REG_FORCE_UNLOAD 1
2033
2034 /* Notify Filter Values */
2035 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
2036 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
2037 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
2038 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
2039
2040 #define REG_LEGAL_CHANGE_FILTER \
2041 (REG_NOTIFY_CHANGE_NAME |\
2042 REG_NOTIFY_CHANGE_ATTRIBUTES |\
2043 REG_NOTIFY_CHANGE_LAST_SET |\
2044 REG_NOTIFY_CHANGE_SECURITY)
2045
2046 typedef struct _CM_FLOPPY_DEVICE_DATA {
2047 USHORT Version;
2048 USHORT Revision;
2049 CHAR Size[8];
2050 ULONG MaxDensity;
2051 ULONG MountDensity;
2052 UCHAR StepRateHeadUnloadTime;
2053 UCHAR HeadLoadTime;
2054 UCHAR MotorOffTime;
2055 UCHAR SectorLengthCode;
2056 UCHAR SectorPerTrack;
2057 UCHAR ReadWriteGapLength;
2058 UCHAR DataTransferLength;
2059 UCHAR FormatGapLength;
2060 UCHAR FormatFillCharacter;
2061 UCHAR HeadSettleTime;
2062 UCHAR MotorSettleTime;
2063 UCHAR MaximumTrackValue;
2064 UCHAR DataTransferRate;
2065 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
2066
2067 #include <pshpack4.h>
2068 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
2069 UCHAR Type;
2070 UCHAR ShareDisposition;
2071 USHORT Flags;
2072 union {
2073 struct {
2074 PHYSICAL_ADDRESS Start;
2075 ULONG Length;
2076 } Generic;
2077 struct {
2078 PHYSICAL_ADDRESS Start;
2079 ULONG Length;
2080 } Port;
2081 struct {
2082 #if defined(NT_PROCESSOR_GROUPS)
2083 USHORT Level;
2084 USHORT Group;
2085 #else
2086 ULONG Level;
2087 #endif
2088 ULONG Vector;
2089 KAFFINITY Affinity;
2090 } Interrupt;
2091 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
2092 struct {
2093 __GNU_EXTENSION union {
2094 struct {
2095 #if defined(NT_PROCESSOR_GROUPS)
2096 USHORT Group;
2097 #else
2098 USHORT Reserved;
2099 #endif
2100 USHORT MessageCount;
2101 ULONG Vector;
2102 KAFFINITY Affinity;
2103 } Raw;
2104 struct {
2105 #if defined(NT_PROCESSOR_GROUPS)
2106 USHORT Level;
2107 USHORT Group;
2108 #else
2109 ULONG Level;
2110 #endif
2111 ULONG Vector;
2112 KAFFINITY Affinity;
2113 } Translated;
2114 } DUMMYUNIONNAME;
2115 } MessageInterrupt;
2116 #endif
2117 struct {
2118 PHYSICAL_ADDRESS Start;
2119 ULONG Length;
2120 } Memory;
2121 struct {
2122 ULONG Channel;
2123 ULONG Port;
2124 ULONG Reserved1;
2125 } Dma;
2126 struct {
2127 ULONG Data[3];
2128 } DevicePrivate;
2129 struct {
2130 ULONG Start;
2131 ULONG Length;
2132 ULONG Reserved;
2133 } BusNumber;
2134 struct {
2135 ULONG DataSize;
2136 ULONG Reserved1;
2137 ULONG Reserved2;
2138 } DeviceSpecificData;
2139 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
2140 struct {
2141 PHYSICAL_ADDRESS Start;
2142 ULONG Length40;
2143 } Memory40;
2144 struct {
2145 PHYSICAL_ADDRESS Start;
2146 ULONG Length48;
2147 } Memory48;
2148 struct {
2149 PHYSICAL_ADDRESS Start;
2150 ULONG Length64;
2151 } Memory64;
2152 #endif
2153 } u;
2154 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
2155 #include <poppack.h>
2156
2157 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
2158 #define CmResourceTypeNull 0
2159 #define CmResourceTypePort 1
2160 #define CmResourceTypeInterrupt 2
2161 #define CmResourceTypeMemory 3
2162 #define CmResourceTypeDma 4
2163 #define CmResourceTypeDeviceSpecific 5
2164 #define CmResourceTypeBusNumber 6
2165 #define CmResourceTypeMemoryLarge 7
2166 #define CmResourceTypeNonArbitrated 128
2167 #define CmResourceTypeConfigData 128
2168 #define CmResourceTypeDevicePrivate 129
2169 #define CmResourceTypePcCardConfig 130
2170 #define CmResourceTypeMfCardConfig 131
2171
2172 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
2173 typedef enum _CM_SHARE_DISPOSITION {
2174 CmResourceShareUndetermined,
2175 CmResourceShareDeviceExclusive,
2176 CmResourceShareDriverExclusive,
2177 CmResourceShareShared
2178 } CM_SHARE_DISPOSITION;
2179
2180 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
2181 #define CM_RESOURCE_PORT_MEMORY 0x0000
2182 #define CM_RESOURCE_PORT_IO 0x0001
2183 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
2184 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
2185 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
2186 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
2187 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
2188 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
2189 #define CM_RESOURCE_PORT_BAR 0x0100
2190
2191 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
2192 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
2193 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
2194 #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002
2195 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
2196
2197 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
2198 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
2199 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
2200 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
2201 #define CM_RESOURCE_MEMORY_WRITEABILITY_MASK 0x0003
2202 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
2203 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
2204 #define CM_RESOURCE_MEMORY_24 0x0010
2205 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
2206 #define CM_RESOURCE_MEMORY_WINDOW_DECODE 0x0040
2207 #define CM_RESOURCE_MEMORY_BAR 0x0080
2208 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
2209
2210 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
2211 #define CM_RESOURCE_DMA_8 0x0000
2212 #define CM_RESOURCE_DMA_16 0x0001
2213 #define CM_RESOURCE_DMA_32 0x0002
2214 #define CM_RESOURCE_DMA_8_AND_16 0x0004
2215 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
2216 #define CM_RESOURCE_DMA_TYPE_A 0x0010
2217 #define CM_RESOURCE_DMA_TYPE_B 0x0020
2218 #define CM_RESOURCE_DMA_TYPE_F 0x0040
2219
2220 typedef struct _CM_PARTIAL_RESOURCE_LIST {
2221 USHORT Version;
2222 USHORT Revision;
2223 ULONG Count;
2224 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
2225 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
2226
2227 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
2228 INTERFACE_TYPE InterfaceType;
2229 ULONG BusNumber;
2230 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
2231 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
2232
2233 typedef struct _CM_RESOURCE_LIST {
2234 ULONG Count;
2235 CM_FULL_RESOURCE_DESCRIPTOR List[1];
2236 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
2237
2238 #include <pshpack1.h>
2239 typedef struct _CM_INT13_DRIVE_PARAMETER {
2240 USHORT DriveSelect;
2241 ULONG MaxCylinders;
2242 USHORT SectorsPerTrack;
2243 USHORT MaxHeads;
2244 USHORT NumberDrives;
2245 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
2246
2247 typedef struct _CM_PNP_BIOS_DEVICE_NODE {
2248 USHORT Size;
2249 UCHAR Node;
2250 ULONG ProductId;
2251 UCHAR DeviceType[3];
2252 USHORT DeviceAttributes;
2253 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
2254
2255 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
2256 UCHAR Signature[4];
2257 UCHAR Revision;
2258 UCHAR Length;
2259 USHORT ControlField;
2260 UCHAR Checksum;
2261 ULONG EventFlagAddress;
2262 USHORT RealModeEntryOffset;
2263 USHORT RealModeEntrySegment;
2264 USHORT ProtectedModeEntryOffset;
2265 ULONG ProtectedModeCodeBaseAddress;
2266 ULONG OemDeviceId;
2267 USHORT RealModeDataBaseAddress;
2268 ULONG ProtectedModeDataBaseAddress;
2269 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
2270 #include <poppack.h>
2271
2272 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
2273 ULONG BytesPerSector;
2274 ULONG NumberOfCylinders;
2275 ULONG SectorsPerTrack;
2276 ULONG NumberOfHeads;
2277 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
2278
2279 typedef struct _CM_KEYBOARD_DEVICE_DATA {
2280 USHORT Version;
2281 USHORT Revision;
2282 UCHAR Type;
2283 UCHAR Subtype;
2284 USHORT KeyboardFlags;
2285 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
2286
2287 typedef struct _CM_MCA_POS_DATA {
2288 USHORT AdapterId;
2289 UCHAR PosData1;
2290 UCHAR PosData2;
2291 UCHAR PosData3;
2292 UCHAR PosData4;
2293 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
2294
2295 #if (NTDDI_VERSION >= NTDDI_WINXP)
2296 typedef struct CM_Power_Data_s {
2297 ULONG PD_Size;
2298 DEVICE_POWER_STATE PD_MostRecentPowerState;
2299 ULONG PD_Capabilities;
2300 ULONG PD_D1Latency;
2301 ULONG PD_D2Latency;
2302 ULONG PD_D3Latency;
2303 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
2304 SYSTEM_POWER_STATE PD_DeepestSystemWake;
2305 } CM_POWER_DATA, *PCM_POWER_DATA;
2306
2307 #define PDCAP_D0_SUPPORTED 0x00000001
2308 #define PDCAP_D1_SUPPORTED 0x00000002
2309 #define PDCAP_D2_SUPPORTED 0x00000004
2310 #define PDCAP_D3_SUPPORTED 0x00000008
2311 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
2312 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
2313 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
2314 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
2315 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
2316
2317 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2318
2319 typedef struct _CM_SCSI_DEVICE_DATA {
2320 USHORT Version;
2321 USHORT Revision;
2322 UCHAR HostIdentifier;
2323 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
2324
2325 typedef struct _CM_SERIAL_DEVICE_DATA {
2326 USHORT Version;
2327 USHORT Revision;
2328 ULONG BaudClock;
2329 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
2330
2331 typedef enum _KEY_INFORMATION_CLASS {
2332 KeyBasicInformation,
2333 KeyNodeInformation,
2334 KeyFullInformation,
2335 KeyNameInformation,
2336 KeyCachedInformation,
2337 KeyFlagsInformation
2338 } KEY_INFORMATION_CLASS;
2339
2340 typedef struct _KEY_BASIC_INFORMATION {
2341 LARGE_INTEGER LastWriteTime;
2342 ULONG TitleIndex;
2343 ULONG NameLength;
2344 WCHAR Name[1];
2345 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
2346
2347 typedef struct _KEY_FULL_INFORMATION {
2348 LARGE_INTEGER LastWriteTime;
2349 ULONG TitleIndex;
2350 ULONG ClassOffset;
2351 ULONG ClassLength;
2352 ULONG SubKeys;
2353 ULONG MaxNameLen;
2354 ULONG MaxClassLen;
2355 ULONG Values;
2356 ULONG MaxValueNameLen;
2357 ULONG MaxValueDataLen;
2358 WCHAR Class[1];
2359 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
2360
2361 typedef struct _KEY_NODE_INFORMATION {
2362 LARGE_INTEGER LastWriteTime;
2363 ULONG TitleIndex;
2364 ULONG ClassOffset;
2365 ULONG ClassLength;
2366 ULONG NameLength;
2367 WCHAR Name[1];
2368 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
2369
2370 typedef struct _KEY_VALUE_BASIC_INFORMATION {
2371 ULONG TitleIndex;
2372 ULONG Type;
2373 ULONG NameLength;
2374 WCHAR Name[1];
2375 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
2376
2377 typedef struct _KEY_VALUE_FULL_INFORMATION {
2378 ULONG TitleIndex;
2379 ULONG Type;
2380 ULONG DataOffset;
2381 ULONG DataLength;
2382 ULONG NameLength;
2383 WCHAR Name[1];
2384 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
2385
2386 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
2387 ULONG TitleIndex;
2388 ULONG Type;
2389 ULONG DataLength;
2390 UCHAR Data[1];
2391 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
2392
2393 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
2394 ULONG Type;
2395 ULONG DataLength;
2396 UCHAR Data[1];
2397 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
2398
2399 typedef struct _KEY_VALUE_ENTRY {
2400 PUNICODE_STRING ValueName;
2401 ULONG DataLength;
2402 ULONG DataOffset;
2403 ULONG Type;
2404 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
2405
2406 typedef enum _KEY_VALUE_INFORMATION_CLASS {
2407 KeyValueBasicInformation,
2408 KeyValueFullInformation,
2409 KeyValuePartialInformation,
2410 KeyValueFullInformationAlign64,
2411 KeyValuePartialInformationAlign64
2412 } KEY_VALUE_INFORMATION_CLASS;
2413
2414 typedef struct _KEY_WRITE_TIME_INFORMATION {
2415 LARGE_INTEGER LastWriteTime;
2416 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
2417
2418 typedef enum _KEY_SET_INFORMATION_CLASS {
2419 KeyWriteTimeInformation,
2420 KeyWow64FlagsInformation,
2421 KeyControlFlagsInformation,
2422 KeySetVirtualizationInformation,
2423 KeySetDebugInformation,
2424 KeySetHandleTagsInformation,
2425 MaxKeySetInfoClass
2426 } KEY_SET_INFORMATION_CLASS;
2427
2428 typedef enum _REG_NOTIFY_CLASS {
2429 RegNtDeleteKey,
2430 RegNtPreDeleteKey = RegNtDeleteKey,
2431 RegNtSetValueKey,
2432 RegNtPreSetValueKey = RegNtSetValueKey,
2433 RegNtDeleteValueKey,
2434 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
2435 RegNtSetInformationKey,
2436 RegNtPreSetInformationKey = RegNtSetInformationKey,
2437 RegNtRenameKey,
2438 RegNtPreRenameKey = RegNtRenameKey,
2439 RegNtEnumerateKey,
2440 RegNtPreEnumerateKey = RegNtEnumerateKey,
2441 RegNtEnumerateValueKey,
2442 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
2443 RegNtQueryKey,
2444 RegNtPreQueryKey = RegNtQueryKey,
2445 RegNtQueryValueKey,
2446 RegNtPreQueryValueKey = RegNtQueryValueKey,
2447 RegNtQueryMultipleValueKey,
2448 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
2449 RegNtPreCreateKey,
2450 RegNtPostCreateKey,
2451 RegNtPreOpenKey,
2452 RegNtPostOpenKey,
2453 RegNtKeyHandleClose,
2454 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
2455 RegNtPostDeleteKey,
2456 RegNtPostSetValueKey,
2457 RegNtPostDeleteValueKey,
2458 RegNtPostSetInformationKey,
2459 RegNtPostRenameKey,
2460 RegNtPostEnumerateKey,
2461 RegNtPostEnumerateValueKey,
2462 RegNtPostQueryKey,
2463 RegNtPostQueryValueKey,
2464 RegNtPostQueryMultipleValueKey,
2465 RegNtPostKeyHandleClose,
2466 RegNtPreCreateKeyEx,
2467 RegNtPostCreateKeyEx,
2468 RegNtPreOpenKeyEx,
2469 RegNtPostOpenKeyEx,
2470 RegNtPreFlushKey,
2471 RegNtPostFlushKey,
2472 RegNtPreLoadKey,
2473 RegNtPostLoadKey,
2474 RegNtPreUnLoadKey,
2475 RegNtPostUnLoadKey,
2476 RegNtPreQueryKeySecurity,
2477 RegNtPostQueryKeySecurity,
2478 RegNtPreSetKeySecurity,
2479 RegNtPostSetKeySecurity,
2480 RegNtCallbackObjectContextCleanup,
2481 RegNtPreRestoreKey,
2482 RegNtPostRestoreKey,
2483 RegNtPreSaveKey,
2484 RegNtPostSaveKey,
2485 RegNtPreReplaceKey,
2486 RegNtPostReplaceKey,
2487 MaxRegNtNotifyClass
2488 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
2489
2490 typedef NTSTATUS
2491 (NTAPI *PEX_CALLBACK_FUNCTION)(
2492 IN PVOID CallbackContext,
2493 IN PVOID Argument1,
2494 IN PVOID Argument2
2495 );
2496
2497 typedef struct _REG_DELETE_KEY_INFORMATION {
2498 PVOID Object;
2499 PVOID CallContext;
2500 PVOID ObjectContext;
2501 PVOID Reserved;
2502 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
2503 #if (NTDDI_VERSION >= NTDDI_VISTA)
2504 , REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
2505 #endif
2506 ;
2507
2508 typedef struct _REG_SET_VALUE_KEY_INFORMATION {
2509 PVOID Object;
2510 PUNICODE_STRING ValueName;
2511 ULONG TitleIndex;
2512 ULONG Type;
2513 PVOID Data;
2514 ULONG DataSize;
2515 PVOID CallContext;
2516 PVOID ObjectContext;
2517 PVOID Reserved;
2518 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
2519
2520 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
2521 PVOID Object;
2522 PUNICODE_STRING ValueName;
2523 PVOID CallContext;
2524 PVOID ObjectContext;
2525 PVOID Reserved;
2526 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
2527
2528 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
2529 PVOID Object;
2530 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
2531 PVOID KeySetInformation;
2532 ULONG KeySetInformationLength;
2533 PVOID CallContext;
2534 PVOID ObjectContext;
2535 PVOID Reserved;
2536 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
2537
2538 typedef struct _REG_ENUMERATE_KEY_INFORMATION {
2539 PVOID Object;
2540 ULONG Index;
2541 KEY_INFORMATION_CLASS KeyInformationClass;
2542 PVOID KeyInformation;
2543 ULONG Length;
2544 PULONG ResultLength;
2545 PVOID CallContext;
2546 PVOID ObjectContext;
2547 PVOID Reserved;
2548 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
2549
2550 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
2551 PVOID Object;
2552 ULONG Index;
2553 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
2554 PVOID KeyValueInformation;
2555 ULONG Length;
2556 PULONG ResultLength;
2557 PVOID CallContext;
2558 PVOID ObjectContext;
2559 PVOID Reserved;
2560 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
2561
2562 typedef struct _REG_QUERY_KEY_INFORMATION {
2563 PVOID Object;
2564 KEY_INFORMATION_CLASS KeyInformationClass;
2565 PVOID KeyInformation;
2566 ULONG Length;
2567 PULONG ResultLength;
2568 PVOID CallContext;
2569 PVOID ObjectContext;
2570 PVOID Reserved;
2571 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
2572
2573 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
2574 PVOID Object;
2575 PUNICODE_STRING ValueName;
2576 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
2577 PVOID KeyValueInformation;
2578 ULONG Length;
2579 PULONG ResultLength;
2580 PVOID CallContext;
2581 PVOID ObjectContext;
2582 PVOID Reserved;
2583 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
2584
2585 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
2586 PVOID Object;
2587 PKEY_VALUE_ENTRY ValueEntries;
2588 ULONG EntryCount;
2589 PVOID ValueBuffer;
2590 PULONG BufferLength;
2591 PULONG RequiredBufferLength;
2592 PVOID CallContext;
2593 PVOID ObjectContext;
2594 PVOID Reserved;
2595 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
2596
2597 typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
2598 PUNICODE_STRING CompleteName;
2599 } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;;
2600
2601 typedef struct _REG_POST_CREATE_KEY_INFORMATION {
2602 PUNICODE_STRING CompleteName;
2603 PVOID Object;
2604 NTSTATUS Status;
2605 } REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
2606
2607 typedef struct _REG_POST_OPERATION_INFORMATION {
2608 PVOID Object;
2609 NTSTATUS Status;
2610 PVOID PreInformation;
2611 NTSTATUS ReturnStatus;
2612 PVOID CallContext;
2613 PVOID ObjectContext;
2614 PVOID Reserved;
2615 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
2616
2617 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
2618 PVOID Object;
2619 PVOID CallContext;
2620 PVOID ObjectContext;
2621 PVOID Reserved;
2622 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
2623
2624 /******************************************************************************
2625 * I/O Manager Types *
2626 ******************************************************************************/
2627
2628 /* PCI_COMMON_CONFIG.Command */
2629 #define PCI_ENABLE_IO_SPACE 0x0001
2630 #define PCI_ENABLE_MEMORY_SPACE 0x0002
2631 #define PCI_ENABLE_BUS_MASTER 0x0004
2632 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
2633 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
2634 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
2635 #define PCI_ENABLE_PARITY 0x0040
2636 #define PCI_ENABLE_WAIT_CYCLE 0x0080
2637 #define PCI_ENABLE_SERR 0x0100
2638 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
2639 #define PCI_DISABLE_LEVEL_INTERRUPT 0x0400
2640
2641 /* PCI_COMMON_CONFIG.Status */
2642 #define PCI_STATUS_INTERRUPT_PENDING 0x0008
2643 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
2644 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
2645 #define PCI_STATUS_UDF_SUPPORTED 0x0040
2646 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
2647 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
2648 #define PCI_STATUS_DEVSEL 0x0600
2649 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
2650 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
2651 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
2652 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
2653 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
2654
2655 /* PCI_COMMON_CONFIG.HeaderType */
2656 #define PCI_MULTIFUNCTION 0x80
2657 #define PCI_DEVICE_TYPE 0x00
2658 #define PCI_BRIDGE_TYPE 0x01
2659 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
2660
2661 #define PCI_CONFIGURATION_TYPE(PciData) \
2662 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
2663
2664 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
2665 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
2666
2667 /* PCI device classes */
2668 #define PCI_CLASS_PRE_20 0x00
2669 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
2670 #define PCI_CLASS_NETWORK_CTLR 0x02
2671 #define PCI_CLASS_DISPLAY_CTLR 0x03
2672 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
2673 #define PCI_CLASS_MEMORY_CTLR 0x05
2674 #define PCI_CLASS_BRIDGE_DEV 0x06
2675 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
2676 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
2677 #define PCI_CLASS_INPUT_DEV 0x09
2678 #define PCI_CLASS_DOCKING_STATION 0x0a
2679 #define PCI_CLASS_PROCESSOR 0x0b
2680 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
2681 #define PCI_CLASS_WIRELESS_CTLR 0x0d
2682 #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
2683 #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
2684 #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
2685 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
2686
2687 /* PCI device subclasses for class 0 */
2688 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
2689 #define PCI_SUBCLASS_PRE_20_VGA 0x01
2690
2691 /* PCI device subclasses for class 1 (mass storage controllers)*/
2692 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
2693 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
2694 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
2695 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
2696 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
2697 #define PCI_SUBCLASS_MSC_OTHER 0x80
2698
2699 /* PCI device subclasses for class 2 (network controllers)*/
2700 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
2701 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
2702 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
2703 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
2704 #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
2705 #define PCI_SUBCLASS_NET_OTHER 0x80
2706
2707 /* PCI device subclasses for class 3 (display controllers)*/
2708 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
2709 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
2710 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
2711 #define PCI_SUBCLASS_VID_OTHER 0x80
2712
2713 /* PCI device subclasses for class 4 (multimedia device)*/
2714 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
2715 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
2716 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
2717 #define PCI_SUBCLASS_MM_OTHER 0x80
2718
2719 /* PCI device subclasses for class 5 (memory controller)*/
2720 #define PCI_SUBCLASS_MEM_RAM 0x00
2721 #define PCI_SUBCLASS_MEM_FLASH 0x01
2722 #define PCI_SUBCLASS_MEM_OTHER 0x80
2723
2724 /* PCI device subclasses for class 6 (bridge device)*/
2725 #define PCI_SUBCLASS_BR_HOST 0x00
2726 #define PCI_SUBCLASS_BR_ISA 0x01
2727 #define PCI_SUBCLASS_BR_EISA 0x02
2728 #define PCI_SUBCLASS_BR_MCA 0x03
2729 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
2730 #define PCI_SUBCLASS_BR_PCMCIA 0x05
2731 #define PCI_SUBCLASS_BR_NUBUS 0x06
2732 #define PCI_SUBCLASS_BR_CARDBUS 0x07
2733 #define PCI_SUBCLASS_BR_RACEWAY 0x08
2734 #define PCI_SUBCLASS_BR_OTHER 0x80
2735
2736 /* PCI device subclasses for class C (serial bus controller)*/
2737 #define PCI_SUBCLASS_SB_IEEE1394 0x00
2738 #define PCI_SUBCLASS_SB_ACCESS 0x01
2739 #define PCI_SUBCLASS_SB_SSA 0x02
2740 #define PCI_SUBCLASS_SB_USB 0x03
2741 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
2742 #define PCI_SUBCLASS_SB_SMBUS 0x05
2743
2744 #define PCI_MAX_DEVICES 32
2745 #define PCI_MAX_FUNCTION 8
2746 #define PCI_MAX_BRIDGE_NUMBER 0xFF
2747 #define PCI_INVALID_VENDORID 0xFFFF
2748 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
2749
2750 #define PCI_ADDRESS_IO_SPACE 0x00000001
2751 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
2752 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
2753 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
2754 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
2755 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
2756
2757 #define PCI_TYPE_32BIT 0
2758 #define PCI_TYPE_20BIT 2
2759 #define PCI_TYPE_64BIT 4
2760
2761 #define POOL_COLD_ALLOCATION 256
2762 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
2763 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
2764
2765 #define PCI_TYPE0_ADDRESSES 6
2766 #define PCI_TYPE1_ADDRESSES 2
2767 #define PCI_TYPE2_ADDRESSES 5
2768
2769 #define IO_TYPE_ADAPTER 1
2770 #define IO_TYPE_CONTROLLER 2
2771 #define IO_TYPE_DEVICE 3
2772 #define IO_TYPE_DRIVER 4
2773 #define IO_TYPE_FILE 5
2774 #define IO_TYPE_IRP 6
2775 #define IO_TYPE_MASTER_ADAPTER 7
2776 #define IO_TYPE_OPEN_PACKET 8
2777 #define IO_TYPE_TIMER 9
2778 #define IO_TYPE_VPB 10
2779 #define IO_TYPE_ERROR_LOG 11
2780 #define IO_TYPE_ERROR_MESSAGE 12
2781 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
2782
2783 #define IO_TYPE_CSQ_IRP_CONTEXT 1
2784 #define IO_TYPE_CSQ 2
2785 #define IO_TYPE_CSQ_EX 3
2786
2787 /* IO_RESOURCE_DESCRIPTOR.Option */
2788 #define IO_RESOURCE_PREFERRED 0x01
2789 #define IO_RESOURCE_DEFAULT 0x02
2790 #define IO_RESOURCE_ALTERNATIVE 0x08
2791
2792 /* DEVICE_OBJECT.Flags */
2793 #define DO_VERIFY_VOLUME 0x00000002
2794 #define DO_BUFFERED_IO 0x00000004
2795 #define DO_EXCLUSIVE 0x00000008
2796 #define DO_DIRECT_IO 0x00000010
2797 #define DO_MAP_IO_BUFFER 0x00000020
2798 #define DO_DEVICE_INITIALIZING 0x00000080
2799 #define DO_SHUTDOWN_REGISTERED 0x00000800
2800 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
2801 #define DO_POWER_PAGABLE 0x00002000
2802 #define DO_POWER_INRUSH 0x00004000
2803
2804 /* DEVICE_OBJECT.Characteristics */
2805 #define FILE_REMOVABLE_MEDIA 0x00000001
2806 #define FILE_READ_ONLY_DEVICE 0x00000002
2807 #define FILE_FLOPPY_DISKETTE 0x00000004
2808 #define FILE_WRITE_ONCE_MEDIA 0x00000008
2809 #define FILE_REMOTE_DEVICE 0x00000010
2810 #define FILE_DEVICE_IS_MOUNTED 0x00000020
2811 #define FILE_VIRTUAL_VOLUME 0x00000040
2812 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
2813 #define FILE_DEVICE_SECURE_OPEN 0x00000100
2814 #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800
2815 #define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000
2816 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
2817
2818 /* DEVICE_OBJECT.AlignmentRequirement */
2819 #define FILE_BYTE_ALIGNMENT 0x00000000
2820 #define FILE_WORD_ALIGNMENT 0x00000001
2821 #define FILE_LONG_ALIGNMENT 0x00000003
2822 #define FILE_QUAD_ALIGNMENT 0x00000007
2823 #define FILE_OCTA_ALIGNMENT 0x0000000f
2824 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
2825 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
2826 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
2827 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
2828 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
2829
2830 /* DEVICE_OBJECT.DeviceType */
2831 #define DEVICE_TYPE ULONG
2832
2833 #define FILE_DEVICE_BEEP 0x00000001
2834 #define FILE_DEVICE_CD_ROM 0x00000002
2835 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2836 #define FILE_DEVICE_CONTROLLER 0x00000004
2837 #define FILE_DEVICE_DATALINK 0x00000005
2838 #define FILE_DEVICE_DFS 0x00000006
2839 #define FILE_DEVICE_DISK 0x00000007
2840 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2841 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
2842 #define FILE_DEVICE_INPORT_PORT 0x0000000a
2843 #define FILE_DEVICE_KEYBOARD 0x0000000b
2844 #define FILE_DEVICE_MAILSLOT 0x0000000c
2845 #define FILE_DEVICE_MIDI_IN 0x0000000d
2846 #define FILE_DEVICE_MIDI_OUT 0x0000000e
2847 #define FILE_DEVICE_MOUSE 0x0000000f
2848 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
2849 #define FILE_DEVICE_NAMED_PIPE 0x00000011
2850 #define FILE_DEVICE_NETWORK 0x00000012
2851 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
2852 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2853 #define FILE_DEVICE_NULL 0x00000015
2854 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
2855 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
2856 #define FILE_DEVICE_PRINTER 0x00000018
2857 #define FILE_DEVICE_SCANNER 0x00000019
2858 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
2859 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
2860 #define FILE_DEVICE_SCREEN 0x0000001c
2861 #define FILE_DEVICE_SOUND 0x0000001d
2862 #define FILE_DEVICE_STREAMS 0x0000001e
2863 #define FILE_DEVICE_TAPE 0x0000001f
2864 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2865 #define FILE_DEVICE_TRANSPORT 0x00000021
2866 #define FILE_DEVICE_UNKNOWN 0x00000022
2867 #define FILE_DEVICE_VIDEO 0x00000023
2868 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2869 #define FILE_DEVICE_WAVE_IN 0x00000025
2870 #define FILE_DEVICE_WAVE_OUT 0x00000026
2871 #define FILE_DEVICE_8042_PORT 0x00000027
2872 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2873 #define FILE_DEVICE_BATTERY 0x00000029
2874 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
2875 #define FILE_DEVICE_MODEM 0x0000002b
2876 #define FILE_DEVICE_VDM 0x0000002c
2877 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
2878 #define FILE_DEVICE_SMB 0x0000002e
2879 #define FILE_DEVICE_KS 0x0000002f
2880 #define FILE_DEVICE_CHANGER 0x00000030
2881 #define FILE_DEVICE_SMARTCARD 0x00000031
2882 #define FILE_DEVICE_ACPI 0x00000032
2883 #define FILE_DEVICE_DVD 0x00000033
2884 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
2885 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
2886 #define FILE_DEVICE_DFS_VOLUME 0x00000036
2887 #define FILE_DEVICE_SERENUM 0x00000037
2888 #define FILE_DEVICE_TERMSRV 0x00000038
2889 #define FILE_DEVICE_KSEC 0x00000039
2890 #define FILE_DEVICE_FIPS 0x0000003A
2891 #define FILE_DEVICE_INFINIBAND 0x0000003B
2892 #define FILE_DEVICE_VMBUS 0x0000003E
2893 #define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F
2894 #define FILE_DEVICE_WPD 0x00000040
2895 #define FILE_DEVICE_BLUETOOTH 0x00000041
2896 #define FILE_DEVICE_MT_COMPOSITE 0x00000042
2897 #define FILE_DEVICE_MT_TRANSPORT 0x00000043
2898 #define FILE_DEVICE_BIOMETRIC 0x00000044
2899 #define FILE_DEVICE_PMI 0x00000045
2900
2901 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
2902
2903 typedef struct _OBJECT_HANDLE_INFORMATION {
2904 ULONG HandleAttributes;
2905 ACCESS_MASK GrantedAccess;
2906 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
2907
2908 typedef struct _CLIENT_ID {
2909 HANDLE UniqueProcess;
2910 HANDLE UniqueThread;
2911 } CLIENT_ID, *PCLIENT_ID;
2912
2913 typedef VOID
2914 (DDKAPI *PKSTART_ROUTINE)(
2915 IN PVOID StartContext);
2916
2917 typedef struct _VPB {
2918 CSHORT Type;
2919 CSHORT Size;
2920 USHORT Flags;
2921 USHORT VolumeLabelLength;
2922 struct _DEVICE_OBJECT *DeviceObject;
2923 struct _DEVICE_OBJECT *RealDevice;
2924 ULONG SerialNumber;
2925 ULONG ReferenceCount;
2926 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
2927 } VPB, *PVPB;
2928
2929 typedef enum _IO_ALLOCATION_ACTION {
2930 KeepObject = 1,
2931 DeallocateObject,
2932 DeallocateObjectKeepRegisters
2933 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
2934
2935 typedef IO_ALLOCATION_ACTION
2936 (DDKAPI *PDRIVER_CONTROL)(
2937 IN struct _DEVICE_OBJECT *DeviceObject,
2938 IN struct _IRP *Irp,
2939 IN PVOID MapRegisterBase,
2940 IN PVOID Context);
2941
2942 typedef struct _WAIT_CONTEXT_BLOCK {
2943 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
2944 PDRIVER_CONTROL DeviceRoutine;
2945 PVOID DeviceContext;
2946 ULONG NumberOfMapRegisters;
2947 PVOID DeviceObject;
2948 PVOID CurrentIrp;
2949 PKDPC BufferChainingDpc;
2950 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
2951
2952 typedef struct _DEVICE_OBJECT {
2953 CSHORT Type;
2954 USHORT Size;
2955 LONG ReferenceCount;
2956 struct _DRIVER_OBJECT *DriverObject;
2957 struct _DEVICE_OBJECT *NextDevice;
2958 struct _DEVICE_OBJECT *AttachedDevice;
2959 struct _IRP *CurrentIrp;
2960 PIO_TIMER Timer;
2961 ULONG Flags;
2962 ULONG Characteristics;
2963 volatile PVPB Vpb;
2964 PVOID DeviceExtension;
2965 DEVICE_TYPE DeviceType;
2966 CCHAR StackSize;
2967 union {
2968 LIST_ENTRY ListEntry;
2969 WAIT_CONTEXT_BLOCK Wcb;
2970 } Queue;
2971 ULONG AlignmentRequirement;
2972 KDEVICE_QUEUE DeviceQueue;
2973 KDPC Dpc;
2974 ULONG ActiveThreadCount;
2975 PSECURITY_DESCRIPTOR SecurityDescriptor;
2976 KEVENT DeviceLock;
2977 USHORT SectorSize;
2978 USHORT Spare1;
2979 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
2980 PVOID Reserved;
2981 } DEVICE_OBJECT, *PDEVICE_OBJECT;
2982
2983 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
2984
2985 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
2986 BOOLEAN Removed;
2987 BOOLEAN Reserved[3];
2988 volatile LONG IoCount;
2989 KEVENT RemoveEvent;
2990 } IO_REMOVE_LOCK_COMMON_BLOCK;
2991
2992 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
2993 LONG Signature;
2994 LONG HighWatermark;
2995 LONGLONG MaxLockedTicks;
2996 LONG AllocateTag;
2997 LIST_ENTRY LockList;
2998 KSPIN_LOCK Spin;
2999 volatile LONG LowMemoryCount;
3000 ULONG Reserved1[4];
3001 PVOID Reserved2;
3002 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
3003 } IO_REMOVE_LOCK_DBG_BLOCK;
3004
3005 typedef struct _IO_REMOVE_LOCK {
3006 IO_REMOVE_LOCK_COMMON_BLOCK Common;
3007 #if DBG
3008 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
3009 #endif
3010 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
3011
3012 typedef struct _IO_WORKITEM *PIO_WORKITEM;
3013
3014 typedef VOID
3015 (DDKAPI IO_WORKITEM_ROUTINE)(
3016 IN PDEVICE_OBJECT DeviceObject,
3017 IN PVOID Context);
3018 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
3019
3020 typedef struct _SHARE_ACCESS {
3021 ULONG OpenCount;
3022 ULONG Readers;
3023 ULONG Writers;
3024 ULONG Deleters;
3025 ULONG SharedRead;
3026 ULONG SharedWrite;
3027 ULONG SharedDelete;
3028 } SHARE_ACCESS, *PSHARE_ACCESS;
3029
3030 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
3031 inheritance, even from a struct renders the type non-POD. So we use
3032 this hack */
3033 #define PCI_COMMON_HEADER_LAYOUT \
3034 USHORT VendorID; \
3035 USHORT DeviceID; \
3036 USHORT Command; \
3037 USHORT Status; \
3038 UCHAR RevisionID; \
3039 UCHAR ProgIf; \
3040 UCHAR SubClass; \
3041 UCHAR BaseClass; \
3042 UCHAR CacheLineSize; \
3043 UCHAR LatencyTimer; \
3044 UCHAR HeaderType; \
3045 UCHAR BIST; \
3046 union { \
3047 struct _PCI_HEADER_TYPE_0 { \
3048 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \
3049 ULONG CIS; \
3050 USHORT SubVendorID; \
3051 USHORT SubSystemID; \
3052 ULONG ROMBaseAddress; \
3053 UCHAR CapabilitiesPtr; \
3054 UCHAR Reserved1[3]; \
3055 ULONG Reserved2; \
3056 UCHAR InterruptLine; \
3057 UCHAR InterruptPin; \
3058 UCHAR MinimumGrant; \
3059 UCHAR MaximumLatency; \
3060 } type0; \
3061 struct _PCI_HEADER_TYPE_1 { \
3062 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \
3063 UCHAR PrimaryBus; \
3064 UCHAR SecondaryBus; \
3065 UCHAR SubordinateBus; \
3066 UCHAR SecondaryLatency; \
3067 UCHAR IOBase; \
3068 UCHAR IOLimit; \
3069 USHORT SecondaryStatus; \
3070 USHORT MemoryBase; \
3071 USHORT MemoryLimit; \
3072 USHORT PrefetchBase; \
3073 USHORT PrefetchLimit; \
3074 ULONG PrefetchBaseUpper32; \
3075 ULONG PrefetchLimitUpper32; \
3076 USHORT IOBaseUpper16; \
3077 USHORT IOLimitUpper16; \
3078 UCHAR CapabilitiesPtr; \
3079 UCHAR Reserved1[3]; \
3080 ULONG ROMBaseAddress; \
3081 UCHAR InterruptLine; \
3082 UCHAR InterruptPin; \
3083 USHORT BridgeControl; \
3084 } type1; \
3085 struct _PCI_HEADER_TYPE_2 { \
3086 ULONG SocketRegistersBaseAddress; \
3087 UCHAR CapabilitiesPtr; \
3088 UCHAR Reserved; \
3089 USHORT SecondaryStatus; \
3090 UCHAR PrimaryBus; \
3091 UCHAR SecondaryBus; \
3092 UCHAR SubordinateBus; \
3093 UCHAR SecondaryLatency; \
3094 struct { \
3095 ULONG Base; \
3096 ULONG Limit; \
3097 } Range[PCI_TYPE2_ADDRESSES-1]; \
3098 UCHAR InterruptLine; \
3099 UCHAR InterruptPin; \
3100 USHORT BridgeControl; \
3101 } type2; \
3102 } u;
3103
3104 typedef struct _PCI_COMMON_HEADER {
3105 PCI_COMMON_HEADER_LAYOUT
3106 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
3107
3108 #ifdef __cplusplus
3109 typedef struct _PCI_COMMON_CONFIG {
3110 PCI_COMMON_HEADER_LAYOUT
3111 UCHAR DeviceSpecific[192];
3112 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3113 #else
3114 typedef struct _PCI_COMMON_CONFIG {
3115 PCI_COMMON_HEADER DUMMYSTRUCTNAME;
3116 UCHAR DeviceSpecific[192];
3117 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3118 #endif
3119
3120 typedef enum _CREATE_FILE_TYPE {
3121 CreateFileTypeNone,
3122 CreateFileTypeNamedPipe,
3123 CreateFileTypeMailslot
3124 } CREATE_FILE_TYPE;
3125
3126 #define IO_FORCE_ACCESS_CHECK 0x001
3127 #define IO_NO_PARAMETER_CHECKING 0x100
3128
3129 #define IO_REPARSE 0x0
3130 #define IO_REMOUNT 0x1
3131
3132 typedef struct _IO_STATUS_BLOCK {
3133 _ANONYMOUS_UNION union {
3134 NTSTATUS Status;
3135 PVOID Pointer;
3136 } DUMMYUNIONNAME;
3137 ULONG_PTR Information;
3138 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
3139
3140 typedef struct _PCI_SLOT_NUMBER {
3141 union {
3142 struct {
3143 ULONG DeviceNumber : 5;
3144 ULONG FunctionNumber : 3;
3145 ULONG Reserved : 24;
3146 } bits;
3147 ULONG AsULONG;
3148 } u;
3149 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
3150
3151 typedef VOID
3152 (DDKAPI *PIO_APC_ROUTINE)(
3153 IN PVOID ApcContext,
3154 IN PIO_STATUS_BLOCK IoStatusBlock,
3155 IN ULONG Reserved);
3156
3157 typedef VOID
3158 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
3159 PVOID Wnode,
3160 PVOID Context);
3161
3162 #define WMIREG_ACTION_REGISTER 1
3163 #define WMIREG_ACTION_DEREGISTER 2
3164 #define WMIREG_ACTION_REREGISTER 3
3165 #define WMIREG_ACTION_UPDATE_GUIDS 4
3166 #define WMIREG_ACTION_BLOCK_IRPS 5
3167
3168 #define EVENT_INCREMENT 1
3169 #define IO_NO_INCREMENT 0
3170 #define IO_CD_ROM_INCREMENT 1
3171 #define IO_DISK_INCREMENT 1
3172 #define IO_KEYBOARD_INCREMENT 6
3173 #define IO_MAILSLOT_INCREMENT 2
3174 #define IO_MOUSE_INCREMENT 6
3175 #define IO_NAMED_PIPE_INCREMENT 2
3176 #define IO_NETWORK_INCREMENT 2
3177 #define IO_PARALLEL_INCREMENT 1
3178 #define IO_SERIAL_INCREMENT 2
3179 #define IO_SOUND_INCREMENT 8
3180 #define IO_VIDEO_INCREMENT 1
3181 #define SEMAPHORE_INCREMENT 1
3182
3183 #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
3184
3185 typedef struct _BOOTDISK_INFORMATION {
3186 LONGLONG BootPartitionOffset;
3187 LONGLONG SystemPartitionOffset;
3188 ULONG BootDeviceSignature;
3189 ULONG SystemDeviceSignature;
3190 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
3191
3192 typedef struct _BOOTDISK_INFORMATION_EX {
3193 LONGLONG BootPartitionOffset;
3194 LONGLONG SystemPartitionOffset;
3195 ULONG BootDeviceSignature;
3196 ULONG SystemDeviceSignature;
3197 GUID BootDeviceGuid;
3198 GUID SystemDeviceGuid;
3199 BOOLEAN BootDeviceIsGpt;
3200 BOOLEAN SystemDeviceIsGpt;
3201 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
3202
3203 typedef struct _EISA_MEMORY_TYPE {
3204 UCHAR ReadWrite : 1;
3205 UCHAR Cached : 1;
3206 UCHAR Reserved0 : 1;
3207 UCHAR Type : 2;
3208 UCHAR Shared : 1;
3209 UCHAR Reserved1 : 1;
3210 UCHAR MoreEntries : 1;
3211 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
3212
3213 #include <pshpack1.h>
3214 typedef struct _EISA_MEMORY_CONFIGURATION {
3215 EISA_MEMORY_TYPE ConfigurationByte;
3216 UCHAR DataSize;
3217 USHORT AddressLowWord;
3218 UCHAR AddressHighByte;
3219 USHORT MemorySize;
3220 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
3221 #include <poppack.h>
3222
3223 typedef struct _EISA_IRQ_DESCRIPTOR {
3224 UCHAR Interrupt : 4;
3225 UCHAR Reserved : 1;
3226 UCHAR LevelTriggered : 1;
3227 UCHAR Shared : 1;
3228 UCHAR MoreEntries : 1;
3229 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
3230
3231 typedef struct _EISA_IRQ_CONFIGURATION {
3232 EISA_IRQ_DESCRIPTOR ConfigurationByte;
3233 UCHAR Reserved;
3234 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
3235
3236 typedef struct _DMA_CONFIGURATION_BYTE0 {
3237 UCHAR Channel : 3;
3238 UCHAR Reserved : 3;
3239 UCHAR Shared : 1;
3240 UCHAR MoreEntries : 1;
3241 } DMA_CONFIGURATION_BYTE0;
3242
3243 typedef struct _DMA_CONFIGURATION_BYTE1 {
3244 UCHAR Reserved0 : 2;
3245 UCHAR TransferSize : 2;
3246 UCHAR Timing : 2;
3247 UCHAR Reserved1 : 2;
3248 } DMA_CONFIGURATION_BYTE1;
3249
3250 typedef struct _EISA_DMA_CONFIGURATION {
3251 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
3252 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
3253 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
3254
3255 #include <pshpack1.h>
3256 typedef struct _EISA_PORT_DESCRIPTOR {
3257 UCHAR NumberPorts : 5;
3258 UCHAR Reserved : 1;
3259 UCHAR Shared : 1;
3260 UCHAR MoreEntries : 1;
3261 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
3262
3263 typedef struct _EISA_PORT_CONFIGURATION {
3264 EISA_PORT_DESCRIPTOR Configuration;
3265 USHORT PortAddress;
3266 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
3267 #include <poppack.h>
3268
3269 typedef struct _CM_EISA_FUNCTION_INFORMATION {
3270 ULONG CompressedId;
3271 UCHAR IdSlotFlags1;
3272 UCHAR IdSlotFlags2;
3273 UCHAR MinorRevision;
3274 UCHAR MajorRevision;
3275 UCHAR Selections[26];
3276 UCHAR FunctionFlags;
3277 UCHAR TypeString[80];
3278 EISA_MEMORY_CONFIGURATION EisaMemory[9];
3279 EISA_IRQ_CONFIGURATION EisaIrq[7];
3280 EISA_DMA_CONFIGURATION EisaDma[4];
3281 EISA_PORT_CONFIGURATION EisaPort[20];
3282 UCHAR InitializationData[60];
3283 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
3284
3285 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
3286
3287 #define EISA_FUNCTION_ENABLED 0x80
3288 #define EISA_FREE_FORM_DATA 0x40
3289 #define EISA_HAS_PORT_INIT_ENTRY 0x20
3290 #define EISA_HAS_PORT_RANGE 0x10
3291 #define EISA_HAS_DMA_ENTRY 0x08
3292 #define EISA_HAS_IRQ_ENTRY 0x04
3293 #define EISA_HAS_MEMORY_ENTRY 0x02
3294 #define EISA_HAS_TYPE_ENTRY 0x01
3295 #define EISA_HAS_INFORMATION \
3296 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
3297 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
3298
3299 typedef struct _CM_EISA_SLOT_INFORMATION {
3300 UCHAR ReturnCode;
3301 UCHAR ReturnFlags;
3302 UCHAR MajorRevision;
3303 UCHAR MinorRevision;
3304 USHORT Checksum;
3305 UCHAR NumberFunctions;
3306 UCHAR FunctionInformation;
3307 ULONG CompressedId;
3308 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
3309
3310 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
3311
3312 #define EISA_INVALID_SLOT 0x80
3313 #define EISA_INVALID_FUNCTION 0x81
3314 #define EISA_INVALID_CONFIGURATION 0x82
3315 #define EISA_EMPTY_SLOT 0x83
3316 #define EISA_INVALID_BIOS_CALL 0x86
3317
3318 /*
3319 ** Plug and Play structures
3320 */
3321
3322 typedef VOID
3323 (DDKAPI *PINTERFACE_REFERENCE)(
3324 PVOID Context);
3325
3326 typedef VOID
3327 (DDKAPI *PINTERFACE_DEREFERENCE)(
3328 PVOID Context);
3329
3330 typedef BOOLEAN
3331 (DDKAPI *PTRANSLATE_BUS_ADDRESS)(
3332 IN PVOID Context,
3333 IN PHYSICAL_ADDRESS BusAddress,
3334 IN ULONG Length,
3335 IN OUT PULONG AddressSpace,
3336 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3337
3338 typedef struct _DMA_ADAPTER*
3339 (DDKAPI *PGET_DMA_ADAPTER)(
3340 IN PVOID Context,
3341 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
3342 OUT PULONG NumberOfMapRegisters);
3343
3344 typedef ULONG
3345 (DDKAPI *PGET_SET_DEVICE_DATA)(
3346 IN PVOID Context,
3347 IN ULONG DataType,
3348 IN PVOID Buffer,
3349 IN ULONG Offset,
3350 IN ULONG Length);
3351
3352 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
3353 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
3354 #define PCI_USE_REVISION 0x00000002
3355 #define PCI_USE_VENDEV_IDS 0x00000004
3356 #define PCI_USE_CLASS_SUBCLASS 0x00000008
3357 #define PCI_USE_PROGIF 0x00000010
3358 #define PCI_USE_LOCAL_BUS 0x00000020
3359 #define PCI_USE_LOCAL_DEVICE 0x00000040
3360
3361 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
3362 ULONG Size;
3363 ULONG Flags;
3364 USHORT VendorID;
3365 USHORT DeviceID;
3366 UCHAR RevisionID;
3367 USHORT SubVendorID;
3368 USHORT SubSystemID;
3369 UCHAR BaseClass;
3370 UCHAR SubClass;
3371 UCHAR ProgIf;
3372 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
3373
3374 typedef BOOLEAN
3375 (DDKAPI *PPCI_IS_DEVICE_PRESENT)(
3376 IN USHORT VendorID,
3377 IN USHORT DeviceID,
3378 IN UCHAR RevisionID,
3379 IN USHORT SubVendorID,
3380 IN USHORT SubSystemID,
3381 IN ULONG Flags);
3382
3383 typedef BOOLEAN
3384 (DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
3385 IN PVOID Context,
3386 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
3387
3388 typedef struct _BUS_INTERFACE_STANDARD {
3389 USHORT Size;
3390 USHORT Version;
3391 PVOID Context;
3392 PINTERFACE_REFERENCE InterfaceReference;
3393 PINTERFACE_DEREFERENCE InterfaceDereference;
3394 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
3395 PGET_DMA_ADAPTER GetDmaAdapter;
3396 PGET_SET_DEVICE_DATA SetBusData;
3397 PGET_SET_DEVICE_DATA GetBusData;
3398 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
3399
3400 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
3401 USHORT Size;
3402 USHORT Version;
3403 PVOID Context;
3404 PINTERFACE_REFERENCE InterfaceReference;
3405 PINTERFACE_DEREFERENCE InterfaceDereference;
3406 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
3407 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
3408 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
3409
3410 typedef
3411 BOOLEAN
3412 (*PGPE_SERVICE_ROUTINE2)(
3413 PVOID ObjectContext,
3414 PVOID ServiceContext
3415 );
3416
3417 typedef
3418 NTSTATUS
3419 (*PGPE_CONNECT_VECTOR2)(
3420 PVOID Context,
3421 ULONG GpeNumber,
3422 KINTERRUPT_MODE Mode,
3423 BOOLEAN Shareable,
3424 PGPE_SERVICE_ROUTINE2 ServiceRoutine,
3425 PVOID ServiceContext,
3426 PVOID *ObjectContext
3427 );
3428
3429 typedef
3430 NTSTATUS
3431 (*PGPE_DISCONNECT_VECTOR2)(
3432 PVOID Context,
3433 PVOID ObjectContext
3434 );
3435
3436 typedef
3437 NTSTATUS
3438 (*PGPE_ENABLE_EVENT2)(
3439 PVOID Context,
3440 PVOID ObjectContext
3441 );
3442
3443 typedef
3444 NTSTATUS
3445 (*PGPE_DISABLE_EVENT2)(
3446 PVOID Context,
3447 PVOID ObjectContext
3448 );
3449
3450 typedef
3451 NTSTATUS
3452 (*PGPE_CLEAR_STATUS2)(
3453 PVOID Context,
3454 PVOID ObjectContext
3455 );
3456
3457 typedef
3458 VOID
3459 (*PDEVICE_NOTIFY_CALLBACK2)(
3460 PVOID NotificationContext,
3461 ULONG NotifyCode
3462 );
3463
3464 typedef
3465 NTSTATUS
3466 (*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
3467 PVOID Context,
3468 PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
3469 PVOID NotificationContext
3470 );
3471
3472 typedef
3473 VOID
3474 (*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
3475 PVOID Context
3476 );
3477
3478 typedef struct
3479 {
3480 USHORT Size;
3481 USHORT Version;
3482 PVOID Context;
3483 PINTERFACE_REFERENCE InterfaceReference;
3484 PINTERFACE_DEREFERENCE InterfaceDereference;
3485 PGPE_CONNECT_VECTOR2 GpeConnectVector;
3486 PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
3487 PGPE_ENABLE_EVENT2 GpeEnableEvent;
3488 PGPE_DISABLE_EVENT2 GpeDisableEvent;
3489 PGPE_CLEAR_STATUS2 GpeClearStatus;
3490 PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
3491 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
3492 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
3493
3494 typedef
3495 BOOLEAN
3496 (*PGPE_SERVICE_ROUTINE)(
3497 PDEVICE_OBJECT ObjectContext,
3498 PVOID ServiceContext
3499 );
3500
3501 typedef
3502 NTSTATUS
3503 (*PGPE_CONNECT_VECTOR)(
3504 PDEVICE_OBJECT Context,
3505 ULONG GpeNumber,
3506 KINTERRUPT_MODE Mode,
3507 BOOLEAN Shareable,
3508 PGPE_SERVICE_ROUTINE ServiceRoutine,
3509 PVOID ServiceContext,
3510 PVOID *ObjectContext
3511 );
3512
3513 typedef
3514 NTSTATUS
3515 (*PGPE_DISCONNECT_VECTOR)(
3516 PDEVICE_OBJECT Context,
3517 PVOID ObjectContext
3518 );
3519
3520 typedef
3521 NTSTATUS
3522 (*PGPE_ENABLE_EVENT)(
3523 PDEVICE_OBJECT Context,
3524 PVOID ObjectContext
3525 );
3526
3527 typedef
3528 NTSTATUS
3529 (*PGPE_DISABLE_EVENT)(
3530 PDEVICE_OBJECT Context,
3531 PVOID ObjectContext
3532 );
3533
3534 typedef
3535 NTSTATUS
3536 (*PGPE_CLEAR_STATUS)(
3537 PDEVICE_OBJECT Context,
3538 PVOID ObjectContext
3539 );
3540
3541 typedef
3542 VOID
3543 (*PDEVICE_NOTIFY_CALLBACK)(
3544 PVOID NotificationContext,
3545 ULONG NotifyCode
3546 );
3547
3548 typedef
3549 NTSTATUS
3550 (*PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
3551 PDEVICE_OBJECT Context,
3552 PDEVICE_NOTIFY_CALLBACK NotificationHandler,
3553 PVOID NotificationContext
3554 );
3555
3556 typedef
3557 VOID
3558 (*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
3559 PDEVICE_OBJECT Context,
3560 PDEVICE_NOTIFY_CALLBACK NotificationHandler
3561 );
3562
3563 typedef struct
3564 {
3565 USHORT Size;
3566 USHORT Version;
3567 PVOID Context;
3568 PINTERFACE_REFERENCE InterfaceReference;
3569 PINTERFACE_DEREFERENCE InterfaceDereference;
3570 PGPE_CONNECT_VECTOR GpeConnectVector;
3571 PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
3572 PGPE_ENABLE_EVENT GpeEnableEvent;
3573 PGPE_DISABLE_EVENT GpeDisableEvent;
3574 PGPE_CLEAR_STATUS GpeClearStatus;
3575 PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
3576 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
3577 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
3578
3579 typedef struct _DEVICE_CAPABILITIES {
3580 USHORT Size;
3581 USHORT Version;
3582 ULONG DeviceD1 : 1;
3583 ULONG DeviceD2 : 1;
3584 ULONG LockSupported : 1;
3585 ULONG EjectSupported : 1;
3586 ULONG Removable : 1;
3587 ULONG DockDevice : 1;
3588 ULONG UniqueID : 1;
3589 ULONG SilentInstall : 1;
3590 ULONG RawDeviceOK : 1;
3591 ULONG SurpriseRemovalOK : 1;
3592 ULONG WakeFromD0 : 1;
3593 ULONG WakeFromD1 : 1;
3594 ULONG WakeFromD2 : 1;
3595 ULONG WakeFromD3 : 1;
3596 ULONG HardwareDisabled : 1;
3597 ULONG NonDynamic : 1;
3598 ULONG WarmEjectSupported : 1;
3599 ULONG NoDisplayInUI : 1;
3600 ULONG Reserved : 14;
3601 ULONG Address;
3602 ULONG UINumber;
3603 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
3604 SYSTEM_POWER_STATE SystemWake;
3605 DEVICE_POWER_STATE DeviceWake;
3606 ULONG D1Latency;
3607 ULONG D2Latency;
3608 ULONG D3Latency;
3609 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
3610
3611 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
3612 USHORT Version;
3613 USHORT Size;
3614 GUID Event;
3615 GUID InterfaceClassGuid;
3616 PUNICODE_STRING SymbolicLinkName;
3617 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
3618
3619 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
3620 USHORT Version;
3621 USHORT Size;
3622 GUID Event;
3623 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
3624
3625 #undef INTERFACE
3626
3627 typedef struct _INTERFACE {
3628 USHORT Size;
3629 USHORT Version;
3630 PVOID Context;
3631 PINTERFACE_REFERENCE InterfaceReference;
3632 PINTERFACE_DEREFERENCE InterfaceDereference;
3633 } INTERFACE, *PINTERFACE;
3634
3635 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
3636 USHORT Version;
3637 USHORT Size;
3638 GUID Event;
3639 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
3640
3641 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
3642
3643 /* PNP_DEVICE_STATE */
3644
3645 #define PNP_DEVICE_DISABLED 0x00000001
3646 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
3647 #define PNP_DEVICE_FAILED 0x00000004
3648 #define PNP_DEVICE_REMOVED 0x00000008
3649 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
3650 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
3651
3652 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
3653 USHORT Version;
3654 USHORT Size;
3655 GUID Event;
3656 struct _FILE_OBJECT *FileObject;
3657 LONG NameBufferOffset;
3658 UCHAR CustomDataBuffer[1];
3659 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
3660
3661 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
3662 USHORT Version;
3663 USHORT Size;
3664 GUID Event;
3665 struct _FILE_OBJECT *FileObject;
3666 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
3667
3668 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
3669 DeviceUsageTypeUndefined,
3670 DeviceUsageTypePaging,
3671 DeviceUsageTypeHibernation,
3672 DeviceUsageTypeDumpFile
3673 } DEVICE_USAGE_NOTIFICATION_TYPE;
3674
3675 typedef struct _POWER_SEQUENCE {
3676 ULONG SequenceD1;
3677 ULONG SequenceD2;
3678 ULONG SequenceD3;
3679 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
3680
3681 typedef enum {
3682 DevicePropertyDeviceDescription = 0x0,
3683 DevicePropertyHardwareID = 0x1,
3684 DevicePropertyCompatibleIDs = 0x2,
3685 DevicePropertyBootConfiguration = 0x3,
3686 DevicePropertyBootConfigurationTranslated = 0x4,
3687 DevicePropertyClassName = 0x5,
3688 DevicePropertyClassGuid = 0x6,
3689 DevicePropertyDriverKeyName = 0x7,
3690 DevicePropertyManufacturer = 0x8,
3691 DevicePropertyFriendlyName = 0x9,
3692 DevicePropertyLocationInformation = 0xa,
3693 DevicePropertyPhysicalDeviceObjectName = 0xb,
3694 DevicePropertyBusTypeGuid = 0xc,
3695 DevicePropertyLegacyBusType = 0xd,
3696 DevicePropertyBusNumber = 0xe,
3697 DevicePropertyEnumeratorName = 0xf,
3698 DevicePropertyAddress = 0x10,
3699 DevicePropertyUINumber = 0x11,
3700 DevicePropertyInstallState = 0x12,
3701 DevicePropertyRemovalPolicy = 0x13,
3702 DevicePropertyResourceRequirements = 0x14,
3703 DevicePropertyAllocatedResources = 0x15,
3704 DevicePropertyContainerID = 0x16
3705 } DEVICE_REGISTRY_PROPERTY;
3706
3707 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
3708 EventCategoryReserved,
3709 EventCategoryHardwareProfileChange,
3710 EventCategoryDeviceInterfaceChange,
3711 EventCategoryTargetDeviceChange
3712 } IO_NOTIFICATION_EVENT_CATEGORY;
3713
3714 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
3715
3716 typedef NTSTATUS
3717 (DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
3718 IN PVOID NotificationStructure,
3719 IN PVOID Context);
3720
3721 typedef VOID
3722 (DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
3723 IN PVOID Context);
3724
3725 typedef enum _FILE_INFORMATION_CLASS {
3726 FileDirectoryInformation = 1,
3727 FileFullDirectoryInformation,
3728 FileBothDirectoryInformation,
3729 FileBasicInformation,
3730 FileStandardInformation,
3731 FileInternalInformation,
3732 FileEaInformation,
3733 FileAccessInformation,
3734 FileNameInformation,
3735 FileRenameInformation,
3736 FileLinkInformation,
3737 FileNamesInformation,
3738 FileDispositionInformation,
3739 FilePositionInformation,
3740 FileFullEaInformation,
3741 FileModeInformation,
3742 FileAlignmentInformation,
3743 FileAllInformation,
3744 FileAllocationInformation,
3745 FileEndOfFileInformation,
3746 FileAlternateNameInformation,
3747 FileStreamInformation,
3748 FilePipeInformation,
3749 FilePipeLocalInformation,
3750 FilePipeRemoteInformation,
3751 FileMailslotQueryInformation,
3752 FileMailslotSetInformation,
3753 FileCompressionInformation,
3754 FileObjectIdInformation,
3755 FileCompletionInformation,
3756 FileMoveClusterInformation,
3757 FileQuotaInformation,
3758 FileReparsePointInformation,
3759 FileNetworkOpenInformation,
3760 FileAttributeTagInformation,
3761 FileTrackingInformation,
3762 FileIdBothDirectoryInformation,
3763 FileIdFullDirectoryInformation,
3764 FileValidDataLengthInformation,
3765 FileShortNameInformation,
3766 FileIoCompletionNotificationInformation,
3767 FileIoStatusBlockRangeInformation,
3768 FileIoPriorityHintInformation,
3769 FileSfioReserveInformation,
3770 FileSfioVolumeInformation,
3771 FileHardLinkInformation,
3772 FileProcessIdsUsingFileInformation,
3773 FileNormalizedNameInformation,
3774 FileNetworkPhysicalNameInformation,
3775 FileIdGlobalTxDirectoryInformation,
3776 FileIsRemoteDeviceInformation,
3777 FileAttributeCacheInformation,
3778 FileNumaNodeInformation,
3779 FileStandardLinkInformation,
3780 FileRemoteProtocolInformation,
3781 FileMaximumInformation
3782 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
3783
3784 typedef struct _FILE_POSITION_INFORMATION {
3785 LARGE_INTEGER CurrentByteOffset;
3786 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
3787
3788 #include <pshpack8.h>
3789 typedef struct _FILE_BASIC_INFORMATION {
3790 LARGE_INTEGER CreationTime;
3791 LARGE_INTEGER LastAccessTime;
3792 LARGE_INTEGER LastWriteTime;
3793 LARGE_INTEGER ChangeTime;
3794 ULONG FileAttributes;
3795 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
3796 #include <poppack.h>
3797
3798 typedef struct _FILE_STANDARD_INFORMATION {
3799 LARGE_INTEGER AllocationSize;
3800 LARGE_INTEGER EndOfFile;
3801 ULONG NumberOfLinks;
3802 BOOLEAN DeletePending;
3803 BOOLEAN Directory;
3804 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
3805
3806 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
3807 LARGE_INTEGER CreationTime;
3808 LARGE_INTEGER LastAccessTime;
3809 LARGE_INTEGER LastWriteTime;
3810 LARGE_INTEGER ChangeTime;
3811 LARGE_INTEGER AllocationSize;
3812 LARGE_INTEGER EndOfFile;
3813 ULONG FileAttributes;
3814 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
3815
3816 typedef enum _FSINFOCLASS {
3817 FileFsVolumeInformation = 1,
3818 FileFsLabelInformation,
3819 FileFsSizeInformation,
3820 FileFsDeviceInformation,
3821 FileFsAttributeInformation,
3822 FileFsControlInformation,
3823 FileFsFullSizeInformation,
3824 FileFsObjectIdInformation,
3825 FileFsDriverPathInformation,
3826 FileFsVolumeFlagsInformation,
3827 FileFsMaximumInformation
3828 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
3829
3830 typedef struct _FILE_FS_DEVICE_INFORMATION {
3831 DEVICE_TYPE DeviceType;
3832 ULONG Characteristics;
3833 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
3834
3835 typedef struct _FILE_FULL_EA_INFORMATION {
3836 ULONG NextEntryOffset;
3837 UCHAR Flags;
3838 UCHAR EaNameLength;
3839 USHORT EaValueLength;
3840 CHAR EaName[1];
3841 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
3842
3843 #define FM_LOCK_BIT (0x1)
3844 #define FM_LOCK_BIT_V (0x0)
3845 #define FM_LOCK_WAITER_WOKEN (0x2)
3846 #define FM_LOCK_WAITER_INC (0x4)
3847
3848 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
3849
3850 typedef struct _OWNER_ENTRY {
3851 ERESOURCE_THREAD OwnerThread;
3852 _ANONYMOUS_UNION union {
3853 LONG OwnerCount;
3854 ULONG TableSize;
3855 } DUMMYUNIONNAME;
3856 } OWNER_ENTRY, *POWNER_ENTRY;
3857
3858 typedef struct _ERESOURCE
3859 {
3860 LIST_ENTRY SystemResourcesList;
3861 POWNER_ENTRY OwnerTable;
3862 SHORT ActiveCount;
3863 USHORT Flag;
3864 volatile PKSEMAPHORE SharedWaiters;
3865 volatile PKEVENT ExclusiveWaiters;
3866 OWNER_ENTRY OwnerEntry;
3867 ULONG ActiveEntries;
3868 ULONG ContentionCount;
3869 ULONG NumberOfSharedWaiters;
3870 ULONG NumberOfExclusiveWaiters;
3871 __GNU_EXTENSION union
3872 {
3873 PVOID Address;
3874 ULONG_PTR CreatorBackTraceIndex;
3875 };
3876 KSPIN_LOCK SpinLock;
3877 } ERESOURCE, *PERESOURCE;
3878
3879 /* ERESOURCE.Flag */
3880 #define ResourceNeverExclusive 0x0010
3881 #define ResourceReleaseByOtherThread 0x0020
3882 #define ResourceOwnedExclusive 0x0080
3883
3884 #define RESOURCE_HASH_TABLE_SIZE 64
3885
3886 typedef BOOLEAN
3887 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
3888 IN struct _FILE_OBJECT *FileObject,
3889 IN PLARGE_INTEGER FileOffset,
3890 IN ULONG Length,
3891 IN BOOLEAN Wait,
3892 IN ULONG LockKey,