90d5d435c3b1aa5f8d290ccddf57584bfdddd9f4
[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
1919 /******************************************************************************
1920 * Configuration Manager Types *
1921 ******************************************************************************/
1922
1923 /* Resource list definitions */
1924 typedef int CM_RESOURCE_TYPE;
1925
1926 #define CmResourceTypeNull 0
1927 #define CmResourceTypePort 1
1928 #define CmResourceTypeInterrupt 2
1929 #define CmResourceTypeMemory 3
1930 #define CmResourceTypeDma 4
1931 #define CmResourceTypeDeviceSpecific 5
1932 #define CmResourceTypeBusNumber 6
1933 #define CmResourceTypeNonArbitrated 128
1934 #define CmResourceTypeConfigData 128
1935 #define CmResourceTypeDevicePrivate 129
1936 #define CmResourceTypePcCardConfig 130
1937 #define CmResourceTypeMfCardConfig 131
1938
1939 /* KEY_VALUE_Xxx.Type */
1940 #define REG_NONE 0
1941 #define REG_SZ 1
1942 #define REG_EXPAND_SZ 2
1943 #define REG_BINARY 3
1944 #define REG_DWORD 4
1945 #define REG_DWORD_LITTLE_ENDIAN 4
1946 #define REG_DWORD_BIG_ENDIAN 5
1947 #define REG_LINK 6
1948 #define REG_MULTI_SZ 7
1949 #define REG_RESOURCE_LIST 8
1950 #define REG_FULL_RESOURCE_DESCRIPTOR 9
1951 #define REG_RESOURCE_REQUIREMENTS_LIST 10
1952 #define REG_QWORD 11
1953 #define REG_QWORD_LITTLE_ENDIAN 11
1954
1955 /* Registry Access Rights */
1956 #define KEY_QUERY_VALUE (0x0001)
1957 #define KEY_SET_VALUE (0x0002)
1958 #define KEY_CREATE_SUB_KEY (0x0004)
1959 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
1960 #define KEY_NOTIFY (0x0010)
1961 #define KEY_CREATE_LINK (0x0020)
1962 #define KEY_WOW64_32KEY (0x0200)
1963 #define KEY_WOW64_64KEY (0x0100)
1964 #define KEY_WOW64_RES (0x0300)
1965
1966 #define KEY_READ ((STANDARD_RIGHTS_READ |\
1967 KEY_QUERY_VALUE |\
1968 KEY_ENUMERATE_SUB_KEYS |\
1969 KEY_NOTIFY) \
1970 & \
1971 (~SYNCHRONIZE))
1972
1973 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
1974 KEY_SET_VALUE |\
1975 KEY_CREATE_SUB_KEY) \
1976 & \
1977 (~SYNCHRONIZE))
1978
1979 #define KEY_EXECUTE ((KEY_READ) \
1980 & \
1981 (~SYNCHRONIZE))
1982
1983 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
1984 KEY_QUERY_VALUE |\
1985 KEY_SET_VALUE |\
1986 KEY_CREATE_SUB_KEY |\
1987 KEY_ENUMERATE_SUB_KEYS |\
1988 KEY_NOTIFY |\
1989 KEY_CREATE_LINK) \
1990 & \
1991 (~SYNCHRONIZE))
1992
1993 /* Registry Open/Create Options */
1994 #define REG_OPTION_RESERVED (0x00000000L)
1995 #define REG_OPTION_NON_VOLATILE (0x00000000L)
1996 #define REG_OPTION_VOLATILE (0x00000001L)
1997 #define REG_OPTION_CREATE_LINK (0x00000002L)
1998 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
1999 #define REG_OPTION_OPEN_LINK (0x00000008L)
2000
2001 #define REG_LEGAL_OPTION \
2002 (REG_OPTION_RESERVED |\
2003 REG_OPTION_NON_VOLATILE |\
2004 REG_OPTION_VOLATILE |\
2005 REG_OPTION_CREATE_LINK |\
2006 REG_OPTION_BACKUP_RESTORE |\
2007 REG_OPTION_OPEN_LINK)
2008
2009 /* Key creation/open disposition */
2010 #define REG_CREATED_NEW_KEY (0x00000001L)
2011 #define REG_OPENED_EXISTING_KEY (0x00000002L)
2012
2013 /* Key restore & hive load flags */
2014 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
2015 #define REG_REFRESH_HIVE (0x00000002L)
2016 #define REG_NO_LAZY_FLUSH (0x00000004L)
2017 #define REG_FORCE_RESTORE (0x00000008L)
2018 #define REG_APP_HIVE (0x00000010L)
2019 #define REG_PROCESS_PRIVATE (0x00000020L)
2020 #define REG_START_JOURNAL (0x00000040L)
2021 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
2022 #define REG_HIVE_NO_RM (0x00000100L)
2023 #define REG_HIVE_SINGLE_LOG (0x00000200L)
2024
2025 /* Unload Flags */
2026 #define REG_FORCE_UNLOAD 1
2027
2028 /* Notify Filter Values */
2029 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
2030 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
2031 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
2032 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
2033
2034 #define REG_LEGAL_CHANGE_FILTER \
2035 (REG_NOTIFY_CHANGE_NAME |\
2036 REG_NOTIFY_CHANGE_ATTRIBUTES |\
2037 REG_NOTIFY_CHANGE_LAST_SET |\
2038 REG_NOTIFY_CHANGE_SECURITY)
2039
2040 typedef struct _CM_FLOPPY_DEVICE_DATA {
2041 USHORT Version;
2042 USHORT Revision;
2043 CHAR Size[8];
2044 ULONG MaxDensity;
2045 ULONG MountDensity;
2046 UCHAR StepRateHeadUnloadTime;
2047 UCHAR HeadLoadTime;
2048 UCHAR MotorOffTime;
2049 UCHAR SectorLengthCode;
2050 UCHAR SectorPerTrack;
2051 UCHAR ReadWriteGapLength;
2052 UCHAR DataTransferLength;
2053 UCHAR FormatGapLength;
2054 UCHAR FormatFillCharacter;
2055 UCHAR HeadSettleTime;
2056 UCHAR MotorSettleTime;
2057 UCHAR MaximumTrackValue;
2058 UCHAR DataTransferRate;
2059 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
2060
2061 #include <pshpack4.h>
2062 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
2063 UCHAR Type;
2064 UCHAR ShareDisposition;
2065 USHORT Flags;
2066 union {
2067 struct {
2068 PHYSICAL_ADDRESS Start;
2069 ULONG Length;
2070 } Generic;
2071 struct {
2072 PHYSICAL_ADDRESS Start;
2073 ULONG Length;
2074 } Port;
2075 struct {
2076 #if defined(NT_PROCESSOR_GROUPS)
2077 USHORT Level;
2078 USHORT Group;
2079 #else
2080 ULONG Level;
2081 #endif
2082 ULONG Vector;
2083 KAFFINITY Affinity;
2084 } Interrupt;
2085 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
2086 struct {
2087 __GNU_EXTENSION union {
2088 struct {
2089 #if defined(NT_PROCESSOR_GROUPS)
2090 USHORT Group;
2091 #else
2092 USHORT Reserved;
2093 #endif
2094 USHORT MessageCount;
2095 ULONG Vector;
2096 KAFFINITY Affinity;
2097 } Raw;
2098 struct {
2099 #if defined(NT_PROCESSOR_GROUPS)
2100 USHORT Level;
2101 USHORT Group;
2102 #else
2103 ULONG Level;
2104 #endif
2105 ULONG Vector;
2106 KAFFINITY Affinity;
2107 } Translated;
2108 } DUMMYUNIONNAME;
2109 } MessageInterrupt;
2110 #endif
2111 struct {
2112 PHYSICAL_ADDRESS Start;
2113 ULONG Length;
2114 } Memory;
2115 struct {
2116 ULONG Channel;
2117 ULONG Port;
2118 ULONG Reserved1;
2119 } Dma;
2120 struct {
2121 ULONG Data[3];
2122 } DevicePrivate;
2123 struct {
2124 ULONG Start;
2125 ULONG Length;
2126 ULONG Reserved;
2127 } BusNumber;
2128 struct {
2129 ULONG DataSize;
2130 ULONG Reserved1;
2131 ULONG Reserved2;
2132 } DeviceSpecificData;
2133 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
2134 struct {
2135 PHYSICAL_ADDRESS Start;
2136 ULONG Length40;
2137 } Memory40;
2138 struct {
2139 PHYSICAL_ADDRESS Start;
2140 ULONG Length48;
2141 } Memory48;
2142 struct {
2143 PHYSICAL_ADDRESS Start;
2144 ULONG Length64;
2145 } Memory64;
2146 #endif
2147 } u;
2148 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
2149 #include <poppack.h>
2150
2151 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
2152 #define CmResourceTypeNull 0
2153 #define CmResourceTypePort 1
2154 #define CmResourceTypeInterrupt 2
2155 #define CmResourceTypeMemory 3
2156 #define CmResourceTypeDma 4
2157 #define CmResourceTypeDeviceSpecific 5
2158 #define CmResourceTypeBusNumber 6
2159 #define CmResourceTypeMemoryLarge 7
2160 #define CmResourceTypeNonArbitrated 128
2161 #define CmResourceTypeConfigData 128
2162 #define CmResourceTypeDevicePrivate 129
2163 #define CmResourceTypePcCardConfig 130
2164 #define CmResourceTypeMfCardConfig 131
2165
2166 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
2167 typedef enum _CM_SHARE_DISPOSITION {
2168 CmResourceShareUndetermined,
2169 CmResourceShareDeviceExclusive,
2170 CmResourceShareDriverExclusive,
2171 CmResourceShareShared
2172 } CM_SHARE_DISPOSITION;
2173
2174 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
2175 #define CM_RESOURCE_PORT_MEMORY 0x0000
2176 #define CM_RESOURCE_PORT_IO 0x0001
2177 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
2178 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
2179 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
2180 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
2181 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
2182 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
2183 #define CM_RESOURCE_PORT_BAR 0x0100
2184
2185 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
2186 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
2187 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
2188 #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002
2189 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
2190
2191 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
2192 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
2193 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
2194 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
2195 #define CM_RESOURCE_MEMORY_WRITEABILITY_MASK 0x0003
2196 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
2197 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
2198 #define CM_RESOURCE_MEMORY_24 0x0010
2199 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
2200 #define CM_RESOURCE_MEMORY_WINDOW_DECODE 0x0040
2201 #define CM_RESOURCE_MEMORY_BAR 0x0080
2202 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
2203
2204 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
2205 #define CM_RESOURCE_DMA_8 0x0000
2206 #define CM_RESOURCE_DMA_16 0x0001
2207 #define CM_RESOURCE_DMA_32 0x0002
2208 #define CM_RESOURCE_DMA_8_AND_16 0x0004
2209 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
2210 #define CM_RESOURCE_DMA_TYPE_A 0x0010
2211 #define CM_RESOURCE_DMA_TYPE_B 0x0020
2212 #define CM_RESOURCE_DMA_TYPE_F 0x0040
2213
2214 typedef struct _CM_PARTIAL_RESOURCE_LIST {
2215 USHORT Version;
2216 USHORT Revision;
2217 ULONG Count;
2218 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
2219 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
2220
2221 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
2222 INTERFACE_TYPE InterfaceType;
2223 ULONG BusNumber;
2224 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
2225 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
2226
2227 typedef struct _CM_RESOURCE_LIST {
2228 ULONG Count;
2229 CM_FULL_RESOURCE_DESCRIPTOR List[1];
2230 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
2231
2232 #include <pshpack1.h>
2233 typedef struct _CM_INT13_DRIVE_PARAMETER {
2234 USHORT DriveSelect;
2235 ULONG MaxCylinders;
2236 USHORT SectorsPerTrack;
2237 USHORT MaxHeads;
2238 USHORT NumberDrives;
2239 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
2240
2241 typedef struct _CM_PNP_BIOS_DEVICE_NODE {
2242 USHORT Size;
2243 UCHAR Node;
2244 ULONG ProductId;
2245 UCHAR DeviceType[3];
2246 USHORT DeviceAttributes;
2247 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
2248
2249 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
2250 UCHAR Signature[4];
2251 UCHAR Revision;
2252 UCHAR Length;
2253 USHORT ControlField;
2254 UCHAR Checksum;
2255 ULONG EventFlagAddress;
2256 USHORT RealModeEntryOffset;
2257 USHORT RealModeEntrySegment;
2258 USHORT ProtectedModeEntryOffset;
2259 ULONG ProtectedModeCodeBaseAddress;
2260 ULONG OemDeviceId;
2261 USHORT RealModeDataBaseAddress;
2262 ULONG ProtectedModeDataBaseAddress;
2263 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
2264 #include <poppack.h>
2265
2266 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
2267 ULONG BytesPerSector;
2268 ULONG NumberOfCylinders;
2269 ULONG SectorsPerTrack;
2270 ULONG NumberOfHeads;
2271 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
2272
2273 typedef struct _CM_KEYBOARD_DEVICE_DATA {
2274 USHORT Version;
2275 USHORT Revision;
2276 UCHAR Type;
2277 UCHAR Subtype;
2278 USHORT KeyboardFlags;
2279 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
2280
2281 typedef struct _CM_MCA_POS_DATA {
2282 USHORT AdapterId;
2283 UCHAR PosData1;
2284 UCHAR PosData2;
2285 UCHAR PosData3;
2286 UCHAR PosData4;
2287 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
2288
2289 #if (NTDDI_VERSION >= NTDDI_WINXP)
2290 typedef struct CM_Power_Data_s {
2291 ULONG PD_Size;
2292 DEVICE_POWER_STATE PD_MostRecentPowerState;
2293 ULONG PD_Capabilities;
2294 ULONG PD_D1Latency;
2295 ULONG PD_D2Latency;
2296 ULONG PD_D3Latency;
2297 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
2298 SYSTEM_POWER_STATE PD_DeepestSystemWake;
2299 } CM_POWER_DATA, *PCM_POWER_DATA;
2300
2301 #define PDCAP_D0_SUPPORTED 0x00000001
2302 #define PDCAP_D1_SUPPORTED 0x00000002
2303 #define PDCAP_D2_SUPPORTED 0x00000004
2304 #define PDCAP_D3_SUPPORTED 0x00000008
2305 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
2306 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
2307 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
2308 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
2309 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
2310
2311 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2312
2313 typedef struct _CM_SCSI_DEVICE_DATA {
2314 USHORT Version;
2315 USHORT Revision;
2316 UCHAR HostIdentifier;
2317 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
2318
2319 typedef struct _CM_SERIAL_DEVICE_DATA {
2320 USHORT Version;
2321 USHORT Revision;
2322 ULONG BaudClock;
2323 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
2324
2325 typedef enum _KEY_INFORMATION_CLASS {
2326 KeyBasicInformation,
2327 KeyNodeInformation,
2328 KeyFullInformation,
2329 KeyNameInformation,
2330 KeyCachedInformation,
2331 KeyFlagsInformation
2332 } KEY_INFORMATION_CLASS;
2333
2334 typedef struct _KEY_BASIC_INFORMATION {
2335 LARGE_INTEGER LastWriteTime;
2336 ULONG TitleIndex;
2337 ULONG NameLength;
2338 WCHAR Name[1];
2339 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
2340
2341 typedef struct _KEY_FULL_INFORMATION {
2342 LARGE_INTEGER LastWriteTime;
2343 ULONG TitleIndex;
2344 ULONG ClassOffset;
2345 ULONG ClassLength;
2346 ULONG SubKeys;
2347 ULONG MaxNameLen;
2348 ULONG MaxClassLen;
2349 ULONG Values;
2350 ULONG MaxValueNameLen;
2351 ULONG MaxValueDataLen;
2352 WCHAR Class[1];
2353 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
2354
2355 typedef struct _KEY_NODE_INFORMATION {
2356 LARGE_INTEGER LastWriteTime;
2357 ULONG TitleIndex;
2358 ULONG ClassOffset;
2359 ULONG ClassLength;
2360 ULONG NameLength;
2361 WCHAR Name[1];
2362 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
2363
2364 typedef struct _KEY_VALUE_BASIC_INFORMATION {
2365 ULONG TitleIndex;
2366 ULONG Type;
2367 ULONG NameLength;
2368 WCHAR Name[1];
2369 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
2370
2371 typedef struct _KEY_VALUE_FULL_INFORMATION {
2372 ULONG TitleIndex;
2373 ULONG Type;
2374 ULONG DataOffset;
2375 ULONG DataLength;
2376 ULONG NameLength;
2377 WCHAR Name[1];
2378 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
2379
2380 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
2381 ULONG TitleIndex;
2382 ULONG Type;
2383 ULONG DataLength;
2384 UCHAR Data[1];
2385 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
2386
2387 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
2388 ULONG Type;
2389 ULONG DataLength;
2390 UCHAR Data[1];
2391 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
2392
2393 typedef struct _KEY_VALUE_ENTRY {
2394 PUNICODE_STRING ValueName;
2395 ULONG DataLength;
2396 ULONG DataOffset;
2397 ULONG Type;
2398 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
2399
2400 typedef enum _KEY_VALUE_INFORMATION_CLASS {
2401 KeyValueBasicInformation,
2402 KeyValueFullInformation,
2403 KeyValuePartialInformation,
2404 KeyValueFullInformationAlign64,
2405 KeyValuePartialInformationAlign64
2406 } KEY_VALUE_INFORMATION_CLASS;
2407
2408 typedef struct _KEY_WRITE_TIME_INFORMATION {
2409 LARGE_INTEGER LastWriteTime;
2410 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
2411
2412 typedef enum _KEY_SET_INFORMATION_CLASS {
2413 KeyWriteTimeInformation,
2414 KeyWow64FlagsInformation,
2415 KeyControlFlagsInformation,
2416 KeySetVirtualizationInformation,
2417 KeySetDebugInformation,
2418 KeySetHandleTagsInformation,
2419 MaxKeySetInfoClass
2420 } KEY_SET_INFORMATION_CLASS;
2421
2422 typedef enum _REG_NOTIFY_CLASS {
2423 RegNtDeleteKey,
2424 RegNtPreDeleteKey = RegNtDeleteKey,
2425 RegNtSetValueKey,
2426 RegNtPreSetValueKey = RegNtSetValueKey,
2427 RegNtDeleteValueKey,
2428 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
2429 RegNtSetInformationKey,
2430 RegNtPreSetInformationKey = RegNtSetInformationKey,
2431 RegNtRenameKey,
2432 RegNtPreRenameKey = RegNtRenameKey,
2433 RegNtEnumerateKey,
2434 RegNtPreEnumerateKey = RegNtEnumerateKey,
2435 RegNtEnumerateValueKey,
2436 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
2437 RegNtQueryKey,
2438 RegNtPreQueryKey = RegNtQueryKey,
2439 RegNtQueryValueKey,
2440 RegNtPreQueryValueKey = RegNtQueryValueKey,
2441 RegNtQueryMultipleValueKey,
2442 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
2443 RegNtPreCreateKey,
2444 RegNtPostCreateKey,
2445 RegNtPreOpenKey,
2446 RegNtPostOpenKey,
2447 RegNtKeyHandleClose,
2448 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
2449 RegNtPostDeleteKey,
2450 RegNtPostSetValueKey,
2451 RegNtPostDeleteValueKey,
2452 RegNtPostSetInformationKey,
2453 RegNtPostRenameKey,
2454 RegNtPostEnumerateKey,
2455 RegNtPostEnumerateValueKey,
2456 RegNtPostQueryKey,
2457 RegNtPostQueryValueKey,
2458 RegNtPostQueryMultipleValueKey,
2459 RegNtPostKeyHandleClose,
2460 RegNtPreCreateKeyEx,
2461 RegNtPostCreateKeyEx,
2462 RegNtPreOpenKeyEx,
2463 RegNtPostOpenKeyEx,
2464 RegNtPreFlushKey,
2465 RegNtPostFlushKey,
2466 RegNtPreLoadKey,
2467 RegNtPostLoadKey,
2468 RegNtPreUnLoadKey,
2469 RegNtPostUnLoadKey,
2470 RegNtPreQueryKeySecurity,
2471 RegNtPostQueryKeySecurity,
2472 RegNtPreSetKeySecurity,
2473 RegNtPostSetKeySecurity,
2474 RegNtCallbackObjectContextCleanup,
2475 RegNtPreRestoreKey,
2476 RegNtPostRestoreKey,
2477 RegNtPreSaveKey,
2478 RegNtPostSaveKey,
2479 RegNtPreReplaceKey,
2480 RegNtPostReplaceKey,
2481 MaxRegNtNotifyClass
2482 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
2483
2484 typedef NTSTATUS
2485 (NTAPI *PEX_CALLBACK_FUNCTION)(
2486 IN PVOID CallbackContext,
2487 IN PVOID Argument1,
2488 IN PVOID Argument2
2489 );
2490
2491 typedef struct _REG_DELETE_KEY_INFORMATION {
2492 PVOID Object;
2493 PVOID CallContext;
2494 PVOID ObjectContext;
2495 PVOID Reserved;
2496 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
2497 #if (NTDDI_VERSION >= NTDDI_VISTA)
2498 , REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
2499 #endif
2500 ;
2501
2502 typedef struct _REG_SET_VALUE_KEY_INFORMATION {
2503 PVOID Object;
2504 PUNICODE_STRING ValueName;
2505 ULONG TitleIndex;
2506 ULONG Type;
2507 PVOID Data;
2508 ULONG DataSize;
2509 PVOID CallContext;
2510 PVOID ObjectContext;
2511 PVOID Reserved;
2512 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
2513
2514 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
2515 PVOID Object;
2516 PUNICODE_STRING ValueName;
2517 PVOID CallContext;
2518 PVOID ObjectContext;
2519 PVOID Reserved;
2520 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
2521
2522 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
2523 PVOID Object;
2524 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
2525 PVOID KeySetInformation;
2526 ULONG KeySetInformationLength;
2527 PVOID CallContext;
2528 PVOID ObjectContext;
2529 PVOID Reserved;
2530 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
2531
2532 typedef struct _REG_ENUMERATE_KEY_INFORMATION {
2533 PVOID Object;
2534 ULONG Index;
2535 KEY_INFORMATION_CLASS KeyInformationClass;
2536 PVOID KeyInformation;
2537 ULONG Length;
2538 PULONG ResultLength;
2539 PVOID CallContext;
2540 PVOID ObjectContext;
2541 PVOID Reserved;
2542 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
2543
2544 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
2545 PVOID Object;
2546 ULONG Index;
2547 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
2548 PVOID KeyValueInformation;
2549 ULONG Length;
2550 PULONG ResultLength;
2551 PVOID CallContext;
2552 PVOID ObjectContext;
2553 PVOID Reserved;
2554 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
2555
2556 typedef struct _REG_QUERY_KEY_INFORMATION {
2557 PVOID Object;
2558 KEY_INFORMATION_CLASS KeyInformationClass;
2559 PVOID KeyInformation;
2560 ULONG Length;
2561 PULONG ResultLength;
2562 PVOID CallContext;
2563 PVOID ObjectContext;
2564 PVOID Reserved;
2565 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
2566
2567 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
2568 PVOID Object;
2569 PUNICODE_STRING ValueName;
2570 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
2571 PVOID KeyValueInformation;
2572 ULONG Length;
2573 PULONG ResultLength;
2574 PVOID CallContext;
2575 PVOID ObjectContext;
2576 PVOID Reserved;
2577 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
2578
2579 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
2580 PVOID Object;
2581 PKEY_VALUE_ENTRY ValueEntries;
2582 ULONG EntryCount;
2583 PVOID ValueBuffer;
2584 PULONG BufferLength;
2585 PULONG RequiredBufferLength;
2586 PVOID CallContext;
2587 PVOID ObjectContext;
2588 PVOID Reserved;
2589 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
2590
2591 typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
2592 PUNICODE_STRING CompleteName;
2593 } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;;
2594
2595 typedef struct _REG_POST_CREATE_KEY_INFORMATION {
2596 PUNICODE_STRING CompleteName;
2597 PVOID Object;
2598 NTSTATUS Status;
2599 } REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
2600
2601 typedef struct _REG_POST_OPERATION_INFORMATION {
2602 PVOID Object;
2603 NTSTATUS Status;
2604 PVOID PreInformation;
2605 NTSTATUS ReturnStatus;
2606 PVOID CallContext;
2607 PVOID ObjectContext;
2608 PVOID Reserved;
2609 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
2610
2611 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
2612 PVOID Object;
2613 PVOID CallContext;
2614 PVOID ObjectContext;
2615 PVOID Reserved;
2616 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
2617
2618 /******************************************************************************
2619 * I/O Manager Types *
2620 ******************************************************************************/
2621
2622 /* PCI_COMMON_CONFIG.Command */
2623 #define PCI_ENABLE_IO_SPACE 0x0001
2624 #define PCI_ENABLE_MEMORY_SPACE 0x0002
2625 #define PCI_ENABLE_BUS_MASTER 0x0004
2626 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
2627 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
2628 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
2629 #define PCI_ENABLE_PARITY 0x0040
2630 #define PCI_ENABLE_WAIT_CYCLE 0x0080
2631 #define PCI_ENABLE_SERR 0x0100
2632 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
2633 #define PCI_DISABLE_LEVEL_INTERRUPT 0x0400
2634
2635 /* PCI_COMMON_CONFIG.Status */
2636 #define PCI_STATUS_INTERRUPT_PENDING 0x0008
2637 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
2638 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
2639 #define PCI_STATUS_UDF_SUPPORTED 0x0040
2640 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
2641 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
2642 #define PCI_STATUS_DEVSEL 0x0600
2643 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
2644 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
2645 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
2646 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
2647 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
2648
2649 /* PCI_COMMON_CONFIG.HeaderType */
2650 #define PCI_MULTIFUNCTION 0x80
2651 #define PCI_DEVICE_TYPE 0x00
2652 #define PCI_BRIDGE_TYPE 0x01
2653 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
2654
2655 #define PCI_CONFIGURATION_TYPE(PciData) \
2656 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
2657
2658 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
2659 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
2660
2661 /* PCI device classes */
2662 #define PCI_CLASS_PRE_20 0x00
2663 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
2664 #define PCI_CLASS_NETWORK_CTLR 0x02
2665 #define PCI_CLASS_DISPLAY_CTLR 0x03
2666 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
2667 #define PCI_CLASS_MEMORY_CTLR 0x05
2668 #define PCI_CLASS_BRIDGE_DEV 0x06
2669 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
2670 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
2671 #define PCI_CLASS_INPUT_DEV 0x09
2672 #define PCI_CLASS_DOCKING_STATION 0x0a
2673 #define PCI_CLASS_PROCESSOR 0x0b
2674 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
2675 #define PCI_CLASS_WIRELESS_CTLR 0x0d
2676 #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
2677 #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
2678 #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
2679 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
2680
2681 /* PCI device subclasses for class 0 */
2682 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
2683 #define PCI_SUBCLASS_PRE_20_VGA 0x01
2684
2685 /* PCI device subclasses for class 1 (mass storage controllers)*/
2686 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
2687 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
2688 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
2689 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
2690 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
2691 #define PCI_SUBCLASS_MSC_OTHER 0x80
2692
2693 /* PCI device subclasses for class 2 (network controllers)*/
2694 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
2695 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
2696 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
2697 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
2698 #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
2699 #define PCI_SUBCLASS_NET_OTHER 0x80
2700
2701 /* PCI device subclasses for class 3 (display controllers)*/
2702 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
2703 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
2704 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
2705 #define PCI_SUBCLASS_VID_OTHER 0x80
2706
2707 /* PCI device subclasses for class 4 (multimedia device)*/
2708 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
2709 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
2710 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
2711 #define PCI_SUBCLASS_MM_OTHER 0x80
2712
2713 /* PCI device subclasses for class 5 (memory controller)*/
2714 #define PCI_SUBCLASS_MEM_RAM 0x00
2715 #define PCI_SUBCLASS_MEM_FLASH 0x01
2716 #define PCI_SUBCLASS_MEM_OTHER 0x80
2717
2718 /* PCI device subclasses for class 6 (bridge device)*/
2719 #define PCI_SUBCLASS_BR_HOST 0x00
2720 #define PCI_SUBCLASS_BR_ISA 0x01
2721 #define PCI_SUBCLASS_BR_EISA 0x02
2722 #define PCI_SUBCLASS_BR_MCA 0x03
2723 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
2724 #define PCI_SUBCLASS_BR_PCMCIA 0x05
2725 #define PCI_SUBCLASS_BR_NUBUS 0x06
2726 #define PCI_SUBCLASS_BR_CARDBUS 0x07
2727 #define PCI_SUBCLASS_BR_RACEWAY 0x08
2728 #define PCI_SUBCLASS_BR_OTHER 0x80
2729
2730 /* PCI device subclasses for class C (serial bus controller)*/
2731 #define PCI_SUBCLASS_SB_IEEE1394 0x00
2732 #define PCI_SUBCLASS_SB_ACCESS 0x01
2733 #define PCI_SUBCLASS_SB_SSA 0x02
2734 #define PCI_SUBCLASS_SB_USB 0x03
2735 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
2736 #define PCI_SUBCLASS_SB_SMBUS 0x05
2737
2738 #define PCI_MAX_DEVICES 32
2739 #define PCI_MAX_FUNCTION 8
2740 #define PCI_MAX_BRIDGE_NUMBER 0xFF
2741 #define PCI_INVALID_VENDORID 0xFFFF
2742 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
2743
2744 #define PCI_ADDRESS_IO_SPACE 0x00000001
2745 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
2746 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
2747 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
2748 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
2749 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
2750
2751 #define PCI_TYPE_32BIT 0
2752 #define PCI_TYPE_20BIT 2
2753 #define PCI_TYPE_64BIT 4
2754
2755 #define POOL_COLD_ALLOCATION 256
2756 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
2757 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
2758
2759 #define PCI_TYPE0_ADDRESSES 6
2760 #define PCI_TYPE1_ADDRESSES 2
2761 #define PCI_TYPE2_ADDRESSES 5
2762
2763 #define IO_TYPE_ADAPTER 1
2764 #define IO_TYPE_CONTROLLER 2
2765 #define IO_TYPE_DEVICE 3
2766 #define IO_TYPE_DRIVER 4
2767 #define IO_TYPE_FILE 5
2768 #define IO_TYPE_IRP 6
2769 #define IO_TYPE_MASTER_ADAPTER 7
2770 #define IO_TYPE_OPEN_PACKET 8
2771 #define IO_TYPE_TIMER 9
2772 #define IO_TYPE_VPB 10
2773 #define IO_TYPE_ERROR_LOG 11
2774 #define IO_TYPE_ERROR_MESSAGE 12
2775 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
2776
2777 #define IO_TYPE_CSQ_IRP_CONTEXT 1
2778 #define IO_TYPE_CSQ 2
2779 #define IO_TYPE_CSQ_EX 3
2780
2781 /* IO_RESOURCE_DESCRIPTOR.Option */
2782 #define IO_RESOURCE_PREFERRED 0x01
2783 #define IO_RESOURCE_DEFAULT 0x02
2784 #define IO_RESOURCE_ALTERNATIVE 0x08
2785
2786 /* DEVICE_OBJECT.Flags */
2787 #define DO_VERIFY_VOLUME 0x00000002
2788 #define DO_BUFFERED_IO 0x00000004
2789 #define DO_EXCLUSIVE 0x00000008
2790 #define DO_DIRECT_IO 0x00000010
2791 #define DO_MAP_IO_BUFFER 0x00000020
2792 #define DO_DEVICE_INITIALIZING 0x00000080
2793 #define DO_SHUTDOWN_REGISTERED 0x00000800
2794 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
2795 #define DO_POWER_PAGABLE 0x00002000
2796 #define DO_POWER_INRUSH 0x00004000
2797
2798 /* DEVICE_OBJECT.Characteristics */
2799 #define FILE_REMOVABLE_MEDIA 0x00000001
2800 #define FILE_READ_ONLY_DEVICE 0x00000002
2801 #define FILE_FLOPPY_DISKETTE 0x00000004
2802 #define FILE_WRITE_ONCE_MEDIA 0x00000008
2803 #define FILE_REMOTE_DEVICE 0x00000010
2804 #define FILE_DEVICE_IS_MOUNTED 0x00000020
2805 #define FILE_VIRTUAL_VOLUME 0x00000040
2806 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
2807 #define FILE_DEVICE_SECURE_OPEN 0x00000100
2808 #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800
2809 #define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000
2810 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
2811
2812 /* DEVICE_OBJECT.AlignmentRequirement */
2813 #define FILE_BYTE_ALIGNMENT 0x00000000
2814 #define FILE_WORD_ALIGNMENT 0x00000001
2815 #define FILE_LONG_ALIGNMENT 0x00000003
2816 #define FILE_QUAD_ALIGNMENT 0x00000007
2817 #define FILE_OCTA_ALIGNMENT 0x0000000f
2818 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
2819 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
2820 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
2821 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
2822 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
2823
2824 /* DEVICE_OBJECT.DeviceType */
2825 #define DEVICE_TYPE ULONG
2826
2827 #define FILE_DEVICE_BEEP 0x00000001
2828 #define FILE_DEVICE_CD_ROM 0x00000002
2829 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2830 #define FILE_DEVICE_CONTROLLER 0x00000004
2831 #define FILE_DEVICE_DATALINK 0x00000005
2832 #define FILE_DEVICE_DFS 0x00000006
2833 #define FILE_DEVICE_DISK 0x00000007
2834 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2835 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
2836 #define FILE_DEVICE_INPORT_PORT 0x0000000a
2837 #define FILE_DEVICE_KEYBOARD 0x0000000b
2838 #define FILE_DEVICE_MAILSLOT 0x0000000c
2839 #define FILE_DEVICE_MIDI_IN 0x0000000d
2840 #define FILE_DEVICE_MIDI_OUT 0x0000000e
2841 #define FILE_DEVICE_MOUSE 0x0000000f
2842 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
2843 #define FILE_DEVICE_NAMED_PIPE 0x00000011
2844 #define FILE_DEVICE_NETWORK 0x00000012
2845 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
2846 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2847 #define FILE_DEVICE_NULL 0x00000015
2848 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
2849 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
2850 #define FILE_DEVICE_PRINTER 0x00000018
2851 #define FILE_DEVICE_SCANNER 0x00000019
2852 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
2853 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
2854 #define FILE_DEVICE_SCREEN 0x0000001c
2855 #define FILE_DEVICE_SOUND 0x0000001d
2856 #define FILE_DEVICE_STREAMS 0x0000001e
2857 #define FILE_DEVICE_TAPE 0x0000001f
2858 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2859 #define FILE_DEVICE_TRANSPORT 0x00000021
2860 #define FILE_DEVICE_UNKNOWN 0x00000022
2861 #define FILE_DEVICE_VIDEO 0x00000023
2862 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2863 #define FILE_DEVICE_WAVE_IN 0x00000025
2864 #define FILE_DEVICE_WAVE_OUT 0x00000026
2865 #define FILE_DEVICE_8042_PORT 0x00000027
2866 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2867 #define FILE_DEVICE_BATTERY 0x00000029
2868 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
2869 #define FILE_DEVICE_MODEM 0x0000002b
2870 #define FILE_DEVICE_VDM 0x0000002c
2871 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
2872 #define FILE_DEVICE_SMB 0x0000002e
2873 #define FILE_DEVICE_KS 0x0000002f
2874 #define FILE_DEVICE_CHANGER 0x00000030
2875 #define FILE_DEVICE_SMARTCARD 0x00000031
2876 #define FILE_DEVICE_ACPI 0x00000032
2877 #define FILE_DEVICE_DVD 0x00000033
2878 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
2879 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
2880 #define FILE_DEVICE_DFS_VOLUME 0x00000036
2881 #define FILE_DEVICE_SERENUM 0x00000037
2882 #define FILE_DEVICE_TERMSRV 0x00000038
2883 #define FILE_DEVICE_KSEC 0x00000039
2884 #define FILE_DEVICE_FIPS 0x0000003A
2885 #define FILE_DEVICE_INFINIBAND 0x0000003B
2886 #define FILE_DEVICE_VMBUS 0x0000003E
2887 #define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F
2888 #define FILE_DEVICE_WPD 0x00000040
2889 #define FILE_DEVICE_BLUETOOTH 0x00000041
2890 #define FILE_DEVICE_MT_COMPOSITE 0x00000042
2891 #define FILE_DEVICE_MT_TRANSPORT 0x00000043
2892 #define FILE_DEVICE_BIOMETRIC 0x00000044
2893 #define FILE_DEVICE_PMI 0x00000045
2894
2895 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
2896
2897 typedef struct _OBJECT_HANDLE_INFORMATION {
2898 ULONG HandleAttributes;
2899 ACCESS_MASK GrantedAccess;
2900 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
2901
2902 typedef struct _CLIENT_ID {
2903 HANDLE UniqueProcess;
2904 HANDLE UniqueThread;
2905 } CLIENT_ID, *PCLIENT_ID;
2906
2907 typedef VOID
2908 (DDKAPI *PKSTART_ROUTINE)(
2909 IN PVOID StartContext);
2910
2911 typedef struct _VPB {
2912 CSHORT Type;
2913 CSHORT Size;
2914 USHORT Flags;
2915 USHORT VolumeLabelLength;
2916 struct _DEVICE_OBJECT *DeviceObject;
2917 struct _DEVICE_OBJECT *RealDevice;
2918 ULONG SerialNumber;
2919 ULONG ReferenceCount;
2920 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
2921 } VPB, *PVPB;
2922
2923 typedef enum _IO_ALLOCATION_ACTION {
2924 KeepObject = 1,
2925 DeallocateObject,
2926 DeallocateObjectKeepRegisters
2927 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
2928
2929 typedef IO_ALLOCATION_ACTION
2930 (DDKAPI *PDRIVER_CONTROL)(
2931 IN struct _DEVICE_OBJECT *DeviceObject,
2932 IN struct _IRP *Irp,
2933 IN PVOID MapRegisterBase,
2934 IN PVOID Context);
2935
2936 typedef struct _WAIT_CONTEXT_BLOCK {
2937 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
2938 PDRIVER_CONTROL DeviceRoutine;
2939 PVOID DeviceContext;
2940 ULONG NumberOfMapRegisters;
2941 PVOID DeviceObject;
2942 PVOID CurrentIrp;
2943 PKDPC BufferChainingDpc;
2944 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
2945
2946 typedef struct _DEVICE_OBJECT {
2947 CSHORT Type;
2948 USHORT Size;
2949 LONG ReferenceCount;
2950 struct _DRIVER_OBJECT *DriverObject;
2951 struct _DEVICE_OBJECT *NextDevice;
2952 struct _DEVICE_OBJECT *AttachedDevice;
2953 struct _IRP *CurrentIrp;
2954 PIO_TIMER Timer;
2955 ULONG Flags;
2956 ULONG Characteristics;
2957 volatile PVPB Vpb;
2958 PVOID DeviceExtension;
2959 DEVICE_TYPE DeviceType;
2960 CCHAR StackSize;
2961 union {
2962 LIST_ENTRY ListEntry;
2963 WAIT_CONTEXT_BLOCK Wcb;
2964 } Queue;
2965 ULONG AlignmentRequirement;
2966 KDEVICE_QUEUE DeviceQueue;
2967 KDPC Dpc;
2968 ULONG ActiveThreadCount;
2969 PSECURITY_DESCRIPTOR SecurityDescriptor;
2970 KEVENT DeviceLock;
2971 USHORT SectorSize;
2972 USHORT Spare1;
2973 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
2974 PVOID Reserved;
2975 } DEVICE_OBJECT, *PDEVICE_OBJECT;
2976
2977 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
2978
2979 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
2980 BOOLEAN Removed;
2981 BOOLEAN Reserved[3];
2982 volatile LONG IoCount;
2983 KEVENT RemoveEvent;
2984 } IO_REMOVE_LOCK_COMMON_BLOCK;
2985
2986 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
2987 LONG Signature;
2988 LONG HighWatermark;
2989 LONGLONG MaxLockedTicks;
2990 LONG AllocateTag;
2991 LIST_ENTRY LockList;
2992 KSPIN_LOCK Spin;
2993 volatile LONG LowMemoryCount;
2994 ULONG Reserved1[4];
2995 PVOID Reserved2;
2996 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
2997 } IO_REMOVE_LOCK_DBG_BLOCK;
2998
2999 typedef struct _IO_REMOVE_LOCK {
3000 IO_REMOVE_LOCK_COMMON_BLOCK Common;
3001 #if DBG
3002 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
3003 #endif
3004 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
3005
3006 typedef struct _IO_WORKITEM *PIO_WORKITEM;
3007
3008 typedef VOID
3009 (DDKAPI IO_WORKITEM_ROUTINE)(
3010 IN PDEVICE_OBJECT DeviceObject,
3011 IN PVOID Context);
3012 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
3013
3014 typedef struct _SHARE_ACCESS {
3015 ULONG OpenCount;
3016 ULONG Readers;
3017 ULONG Writers;
3018 ULONG Deleters;
3019 ULONG SharedRead;
3020 ULONG SharedWrite;
3021 ULONG SharedDelete;
3022 } SHARE_ACCESS, *PSHARE_ACCESS;
3023
3024 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
3025 inheritance, even from a struct renders the type non-POD. So we use
3026 this hack */
3027 #define PCI_COMMON_HEADER_LAYOUT \
3028 USHORT VendorID; \
3029 USHORT DeviceID; \
3030 USHORT Command; \
3031 USHORT Status; \
3032 UCHAR RevisionID; \
3033 UCHAR ProgIf; \
3034 UCHAR SubClass; \
3035 UCHAR BaseClass; \
3036 UCHAR CacheLineSize; \
3037 UCHAR LatencyTimer; \
3038 UCHAR HeaderType; \
3039 UCHAR BIST; \
3040 union { \
3041 struct _PCI_HEADER_TYPE_0 { \
3042 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \
3043 ULONG CIS; \
3044 USHORT SubVendorID; \
3045 USHORT SubSystemID; \
3046 ULONG ROMBaseAddress; \
3047 UCHAR CapabilitiesPtr; \
3048 UCHAR Reserved1[3]; \
3049 ULONG Reserved2; \
3050 UCHAR InterruptLine; \
3051 UCHAR InterruptPin; \
3052 UCHAR MinimumGrant; \
3053 UCHAR MaximumLatency; \
3054 } type0; \
3055 struct _PCI_HEADER_TYPE_1 { \
3056 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \
3057 UCHAR PrimaryBus; \
3058 UCHAR SecondaryBus; \
3059 UCHAR SubordinateBus; \
3060 UCHAR SecondaryLatency; \
3061 UCHAR IOBase; \
3062 UCHAR IOLimit; \
3063 USHORT SecondaryStatus; \
3064 USHORT MemoryBase; \
3065 USHORT MemoryLimit; \
3066 USHORT PrefetchBase; \
3067 USHORT PrefetchLimit; \
3068 ULONG PrefetchBaseUpper32; \
3069 ULONG PrefetchLimitUpper32; \
3070 USHORT IOBaseUpper16; \
3071 USHORT IOLimitUpper16; \
3072 UCHAR CapabilitiesPtr; \
3073 UCHAR Reserved1[3]; \
3074 ULONG ROMBaseAddress; \
3075 UCHAR InterruptLine; \
3076 UCHAR InterruptPin; \
3077 USHORT BridgeControl; \
3078 } type1; \
3079 struct _PCI_HEADER_TYPE_2 { \
3080 ULONG SocketRegistersBaseAddress; \
3081 UCHAR CapabilitiesPtr; \
3082 UCHAR Reserved; \
3083 USHORT SecondaryStatus; \
3084 UCHAR PrimaryBus; \
3085 UCHAR SecondaryBus; \
3086 UCHAR SubordinateBus; \
3087 UCHAR SecondaryLatency; \
3088 struct { \
3089 ULONG Base; \
3090 ULONG Limit; \
3091 } Range[PCI_TYPE2_ADDRESSES-1]; \
3092 UCHAR InterruptLine; \
3093 UCHAR InterruptPin; \
3094 USHORT BridgeControl; \
3095 } type2; \
3096 } u;
3097
3098 typedef struct _PCI_COMMON_HEADER {
3099 PCI_COMMON_HEADER_LAYOUT
3100 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
3101
3102 #ifdef __cplusplus
3103 typedef struct _PCI_COMMON_CONFIG {
3104 PCI_COMMON_HEADER_LAYOUT
3105 UCHAR DeviceSpecific[192];
3106 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3107 #else
3108 typedef struct _PCI_COMMON_CONFIG {
3109 PCI_COMMON_HEADER DUMMYSTRUCTNAME;
3110 UCHAR DeviceSpecific[192];
3111 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3112 #endif
3113
3114 typedef enum _CREATE_FILE_TYPE {
3115 CreateFileTypeNone,
3116 CreateFileTypeNamedPipe,
3117 CreateFileTypeMailslot
3118 } CREATE_FILE_TYPE;
3119
3120 #define IO_FORCE_ACCESS_CHECK 0x001
3121 #define IO_NO_PARAMETER_CHECKING 0x100
3122
3123 #define IO_REPARSE 0x0
3124 #define IO_REMOUNT 0x1
3125
3126 typedef struct _IO_STATUS_BLOCK {
3127 _ANONYMOUS_UNION union {
3128 NTSTATUS Status;
3129 PVOID Pointer;
3130 } DUMMYUNIONNAME;
3131 ULONG_PTR Information;
3132 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
3133
3134 typedef struct _PCI_SLOT_NUMBER {
3135 union {
3136 struct {
3137 ULONG DeviceNumber : 5;
3138 ULONG FunctionNumber : 3;
3139 ULONG Reserved : 24;
3140 } bits;
3141 ULONG AsULONG;
3142 } u;
3143 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
3144
3145 typedef VOID
3146 (DDKAPI *PIO_APC_ROUTINE)(
3147 IN PVOID ApcContext,
3148 IN PIO_STATUS_BLOCK IoStatusBlock,
3149 IN ULONG Reserved);
3150
3151 typedef VOID
3152 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
3153 PVOID Wnode,
3154 PVOID Context);
3155
3156 #define EVENT_INCREMENT 1
3157 #define IO_NO_INCREMENT 0
3158 #define IO_CD_ROM_INCREMENT 1
3159 #define IO_DISK_INCREMENT 1
3160 #define IO_KEYBOARD_INCREMENT 6
3161 #define IO_MAILSLOT_INCREMENT 2
3162 #define IO_MOUSE_INCREMENT 6
3163 #define IO_NAMED_PIPE_INCREMENT 2
3164 #define IO_NETWORK_INCREMENT 2
3165 #define IO_PARALLEL_INCREMENT 1
3166 #define IO_SERIAL_INCREMENT 2
3167 #define IO_SOUND_INCREMENT 8
3168 #define IO_VIDEO_INCREMENT 1
3169 #define SEMAPHORE_INCREMENT 1
3170
3171 #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
3172
3173 typedef struct _BOOTDISK_INFORMATION {
3174 LONGLONG BootPartitionOffset;
3175 LONGLONG SystemPartitionOffset;
3176 ULONG BootDeviceSignature;
3177 ULONG SystemDeviceSignature;
3178 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
3179
3180 typedef struct _BOOTDISK_INFORMATION_EX {
3181 LONGLONG BootPartitionOffset;
3182 LONGLONG SystemPartitionOffset;
3183 ULONG BootDeviceSignature;
3184 ULONG SystemDeviceSignature;
3185 GUID BootDeviceGuid;
3186 GUID SystemDeviceGuid;
3187 BOOLEAN BootDeviceIsGpt;
3188 BOOLEAN SystemDeviceIsGpt;
3189 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
3190
3191 typedef struct _EISA_MEMORY_TYPE {
3192 UCHAR ReadWrite : 1;
3193 UCHAR Cached : 1;
3194 UCHAR Reserved0 : 1;
3195 UCHAR Type : 2;
3196 UCHAR Shared : 1;
3197 UCHAR Reserved1 : 1;
3198 UCHAR MoreEntries : 1;
3199 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
3200
3201 #include <pshpack1.h>
3202 typedef struct _EISA_MEMORY_CONFIGURATION {
3203 EISA_MEMORY_TYPE ConfigurationByte;
3204 UCHAR DataSize;
3205 USHORT AddressLowWord;
3206 UCHAR AddressHighByte;
3207 USHORT MemorySize;
3208 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
3209 #include <poppack.h>
3210
3211 typedef struct _EISA_IRQ_DESCRIPTOR {
3212 UCHAR Interrupt : 4;
3213 UCHAR Reserved : 1;
3214 UCHAR LevelTriggered : 1;
3215 UCHAR Shared : 1;
3216 UCHAR MoreEntries : 1;
3217 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
3218
3219 typedef struct _EISA_IRQ_CONFIGURATION {
3220 EISA_IRQ_DESCRIPTOR ConfigurationByte;
3221 UCHAR Reserved;
3222 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
3223
3224 typedef struct _DMA_CONFIGURATION_BYTE0 {
3225 UCHAR Channel : 3;
3226 UCHAR Reserved : 3;
3227 UCHAR Shared : 1;
3228 UCHAR MoreEntries : 1;
3229 } DMA_CONFIGURATION_BYTE0;
3230
3231 typedef struct _DMA_CONFIGURATION_BYTE1 {
3232 UCHAR Reserved0 : 2;
3233 UCHAR TransferSize : 2;
3234 UCHAR Timing : 2;
3235 UCHAR Reserved1 : 2;
3236 } DMA_CONFIGURATION_BYTE1;
3237
3238 typedef struct _EISA_DMA_CONFIGURATION {
3239 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
3240 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
3241 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
3242
3243 #include <pshpack1.h>
3244 typedef struct _EISA_PORT_DESCRIPTOR {
3245 UCHAR NumberPorts : 5;
3246 UCHAR Reserved : 1;
3247 UCHAR Shared : 1;
3248 UCHAR MoreEntries : 1;
3249 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
3250
3251 typedef struct _EISA_PORT_CONFIGURATION {
3252 EISA_PORT_DESCRIPTOR Configuration;
3253 USHORT PortAddress;
3254 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
3255 #include <poppack.h>
3256
3257 typedef struct _CM_EISA_FUNCTION_INFORMATION {
3258 ULONG CompressedId;
3259 UCHAR IdSlotFlags1;
3260 UCHAR IdSlotFlags2;
3261 UCHAR MinorRevision;
3262 UCHAR MajorRevision;
3263 UCHAR Selections[26];
3264 UCHAR FunctionFlags;
3265 UCHAR TypeString[80];
3266 EISA_MEMORY_CONFIGURATION EisaMemory[9];
3267 EISA_IRQ_CONFIGURATION EisaIrq[7];
3268 EISA_DMA_CONFIGURATION EisaDma[4];
3269 EISA_PORT_CONFIGURATION EisaPort[20];
3270 UCHAR InitializationData[60];
3271 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
3272
3273 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
3274
3275 #define EISA_FUNCTION_ENABLED 0x80
3276 #define EISA_FREE_FORM_DATA 0x40
3277 #define EISA_HAS_PORT_INIT_ENTRY 0x20
3278 #define EISA_HAS_PORT_RANGE 0x10
3279 #define EISA_HAS_DMA_ENTRY 0x08
3280 #define EISA_HAS_IRQ_ENTRY 0x04
3281 #define EISA_HAS_MEMORY_ENTRY 0x02
3282 #define EISA_HAS_TYPE_ENTRY 0x01
3283 #define EISA_HAS_INFORMATION \
3284 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
3285 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
3286
3287 typedef struct _CM_EISA_SLOT_INFORMATION {
3288 UCHAR ReturnCode;
3289 UCHAR ReturnFlags;
3290 UCHAR MajorRevision;
3291 UCHAR MinorRevision;
3292 USHORT Checksum;
3293 UCHAR NumberFunctions;
3294 UCHAR FunctionInformation;
3295 ULONG CompressedId;
3296 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
3297
3298 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
3299
3300 #define EISA_INVALID_SLOT 0x80
3301 #define EISA_INVALID_FUNCTION 0x81
3302 #define EISA_INVALID_CONFIGURATION 0x82
3303 #define EISA_EMPTY_SLOT 0x83
3304 #define EISA_INVALID_BIOS_CALL 0x86
3305
3306 /*
3307 ** Plug and Play structures
3308 */
3309
3310 typedef VOID
3311 (DDKAPI *PINTERFACE_REFERENCE)(
3312 PVOID Context);
3313
3314 typedef VOID
3315 (DDKAPI *PINTERFACE_DEREFERENCE)(
3316 PVOID Context);
3317
3318 typedef BOOLEAN
3319 (DDKAPI *PTRANSLATE_BUS_ADDRESS)(
3320 IN PVOID Context,
3321 IN PHYSICAL_ADDRESS BusAddress,
3322 IN ULONG Length,
3323 IN OUT PULONG AddressSpace,
3324 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3325
3326 typedef struct _DMA_ADAPTER*
3327 (DDKAPI *PGET_DMA_ADAPTER)(
3328 IN PVOID Context,
3329 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
3330 OUT PULONG NumberOfMapRegisters);
3331
3332 typedef ULONG
3333 (DDKAPI *PGET_SET_DEVICE_DATA)(
3334 IN PVOID Context,
3335 IN ULONG DataType,
3336 IN PVOID Buffer,
3337 IN ULONG Offset,
3338 IN ULONG Length);
3339
3340 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
3341 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
3342 #define PCI_USE_REVISION 0x00000002
3343 #define PCI_USE_VENDEV_IDS 0x00000004
3344 #define PCI_USE_CLASS_SUBCLASS 0x00000008
3345 #define PCI_USE_PROGIF 0x00000010
3346 #define PCI_USE_LOCAL_BUS 0x00000020
3347 #define PCI_USE_LOCAL_DEVICE 0x00000040
3348
3349 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
3350 ULONG Size;
3351 ULONG Flags;
3352 USHORT VendorID;
3353 USHORT DeviceID;
3354 UCHAR RevisionID;
3355 USHORT SubVendorID;
3356 USHORT SubSystemID;
3357 UCHAR BaseClass;
3358 UCHAR SubClass;
3359 UCHAR ProgIf;
3360 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
3361
3362 typedef BOOLEAN
3363 (DDKAPI *PPCI_IS_DEVICE_PRESENT)(
3364 IN USHORT VendorID,
3365 IN USHORT DeviceID,
3366 IN UCHAR RevisionID,
3367 IN USHORT SubVendorID,
3368 IN USHORT SubSystemID,
3369 IN ULONG Flags);
3370
3371 typedef BOOLEAN
3372 (DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
3373 IN PVOID Context,
3374 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
3375
3376 typedef struct _BUS_INTERFACE_STANDARD {
3377 USHORT Size;
3378 USHORT Version;
3379 PVOID Context;
3380 PINTERFACE_REFERENCE InterfaceReference;
3381 PINTERFACE_DEREFERENCE InterfaceDereference;
3382 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
3383 PGET_DMA_ADAPTER GetDmaAdapter;
3384 PGET_SET_DEVICE_DATA SetBusData;
3385 PGET_SET_DEVICE_DATA GetBusData;
3386 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
3387
3388 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
3389 USHORT Size;
3390 USHORT Version;
3391 PVOID Context;
3392 PINTERFACE_REFERENCE InterfaceReference;
3393 PINTERFACE_DEREFERENCE InterfaceDereference;
3394 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
3395 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
3396 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
3397
3398 typedef struct _DEVICE_CAPABILITIES {
3399 USHORT Size;
3400 USHORT Version;
3401 ULONG DeviceD1 : 1;
3402 ULONG DeviceD2 : 1;
3403 ULONG LockSupported : 1;
3404 ULONG EjectSupported : 1;
3405 ULONG Removable : 1;
3406 ULONG DockDevice : 1;
3407 ULONG UniqueID : 1;
3408 ULONG SilentInstall : 1;
3409 ULONG RawDeviceOK : 1;
3410 ULONG SurpriseRemovalOK : 1;
3411 ULONG WakeFromD0 : 1;
3412 ULONG WakeFromD1 : 1;
3413 ULONG WakeFromD2 : 1;
3414 ULONG WakeFromD3 : 1;
3415 ULONG HardwareDisabled : 1;
3416 ULONG NonDynamic : 1;
3417 ULONG WarmEjectSupported : 1;
3418 ULONG NoDisplayInUI : 1;
3419 ULONG Reserved : 14;
3420 ULONG Address;
3421 ULONG UINumber;
3422 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
3423 SYSTEM_POWER_STATE SystemWake;
3424 DEVICE_POWER_STATE DeviceWake;
3425 ULONG D1Latency;
3426 ULONG D2Latency;
3427 ULONG D3Latency;
3428 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
3429
3430 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
3431 USHORT Version;
3432 USHORT Size;
3433 GUID Event;
3434 GUID InterfaceClassGuid;
3435 PUNICODE_STRING SymbolicLinkName;
3436 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
3437
3438 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
3439 USHORT Version;
3440 USHORT Size;
3441 GUID Event;
3442 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
3443
3444 #undef INTERFACE
3445
3446 typedef struct _INTERFACE {
3447 USHORT Size;
3448 USHORT Version;
3449 PVOID Context;
3450 PINTERFACE_REFERENCE InterfaceReference;
3451 PINTERFACE_DEREFERENCE InterfaceDereference;
3452 } INTERFACE, *PINTERFACE;
3453
3454 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
3455 USHORT Version;
3456 USHORT Size;
3457 GUID Event;
3458 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
3459
3460 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
3461
3462 /* PNP_DEVICE_STATE */
3463
3464 #define PNP_DEVICE_DISABLED 0x00000001
3465 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
3466 #define PNP_DEVICE_FAILED 0x00000004
3467 #define PNP_DEVICE_REMOVED 0x00000008
3468 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
3469 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
3470
3471 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
3472 USHORT Version;
3473 USHORT Size;
3474 GUID Event;
3475 struct _FILE_OBJECT *FileObject;
3476 LONG NameBufferOffset;
3477 UCHAR CustomDataBuffer[1];
3478 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
3479
3480 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
3481 USHORT Version;
3482 USHORT Size;
3483 GUID Event;
3484 struct _FILE_OBJECT *FileObject;
3485 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
3486
3487 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
3488 DeviceUsageTypeUndefined,
3489 DeviceUsageTypePaging,
3490 DeviceUsageTypeHibernation,
3491 DeviceUsageTypeDumpFile
3492 } DEVICE_USAGE_NOTIFICATION_TYPE;
3493
3494 typedef struct _POWER_SEQUENCE {
3495 ULONG SequenceD1;
3496 ULONG SequenceD2;
3497 ULONG SequenceD3;
3498 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
3499
3500 typedef enum {
3501 DevicePropertyDeviceDescription = 0x0,
3502 DevicePropertyHardwareID = 0x1,
3503 DevicePropertyCompatibleIDs = 0x2,
3504 DevicePropertyBootConfiguration = 0x3,
3505 DevicePropertyBootConfigurationTranslated = 0x4,
3506 DevicePropertyClassName = 0x5,
3507 DevicePropertyClassGuid = 0x6,
3508 DevicePropertyDriverKeyName = 0x7,
3509 DevicePropertyManufacturer = 0x8,
3510 DevicePropertyFriendlyName = 0x9,
3511 DevicePropertyLocationInformation = 0xa,
3512 DevicePropertyPhysicalDeviceObjectName = 0xb,
3513 DevicePropertyBusTypeGuid = 0xc,
3514 DevicePropertyLegacyBusType = 0xd,
3515 DevicePropertyBusNumber = 0xe,
3516 DevicePropertyEnumeratorName = 0xf,
3517 DevicePropertyAddress = 0x10,
3518 DevicePropertyUINumber = 0x11,
3519 DevicePropertyInstallState = 0x12,
3520 DevicePropertyRemovalPolicy = 0x13,
3521 DevicePropertyResourceRequirements = 0x14,
3522 DevicePropertyAllocatedResources = 0x15,
3523 DevicePropertyContainerID = 0x16
3524 } DEVICE_REGISTRY_PROPERTY;
3525
3526 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
3527 EventCategoryReserved,
3528 EventCategoryHardwareProfileChange,
3529 EventCategoryDeviceInterfaceChange,
3530 EventCategoryTargetDeviceChange
3531 } IO_NOTIFICATION_EVENT_CATEGORY;
3532
3533 typedef enum _IO_PRIORITY_HINT {
3534 IoPriorityVeryLow = 0,
3535 IoPriorityLow,
3536 IoPriorityNormal,
3537 IoPriorityHigh,
3538 IoPriorityCritical,
3539 MaxIoPriorityTypes
3540 } IO_PRIORITY_HINT;
3541
3542 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
3543
3544 typedef NTSTATUS
3545 (DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
3546 IN PVOID NotificationStructure,
3547 IN PVOID Context);
3548
3549 typedef VOID
3550 (DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
3551 IN PVOID Context);
3552
3553 typedef enum _FILE_INFORMATION_CLASS {
3554 FileDirectoryInformation = 1,
3555 FileFullDirectoryInformation,
3556 FileBothDirectoryInformation,
3557 FileBasicInformation,
3558 FileStandardInformation,
3559 FileInternalInformation,
3560 FileEaInformation,
3561 FileAccessInformation,
3562 FileNameInformation,
3563 FileRenameInformation,
3564 FileLinkInformation,
3565 FileNamesInformation,
3566 FileDispositionInformation,
3567 FilePositionInformation,
3568 FileFullEaInformation,
3569 FileModeInformation,
3570 FileAlignmentInformation,
3571 FileAllInformation,
3572 FileAllocationInformation,
3573 FileEndOfFileInformation,
3574 FileAlternateNameInformation,
3575 FileStreamInformation,
3576 FilePipeInformation,
3577 FilePipeLocalInformation,
3578 FilePipeRemoteInformation,
3579 FileMailslotQueryInformation,
3580 FileMailslotSetInformation,
3581 FileCompressionInformation,
3582 FileObjectIdInformation,
3583 FileCompletionInformation,
3584 FileMoveClusterInformation,
3585 FileQuotaInformation,
3586 FileReparsePointInformation,
3587 FileNetworkOpenInformation,
3588 FileAttributeTagInformation,
3589 FileTrackingInformation,
3590 FileIdBothDirectoryInformation,
3591 FileIdFullDirectoryInformation,
3592 FileValidDataLengthInformation,
3593 FileShortNameInformation,
3594 FileIoCompletionNotificationInformation,
3595 FileIoStatusBlockRangeInformation,
3596 FileIoPriorityHintInformation,
3597 FileSfioReserveInformation,
3598 FileSfioVolumeInformation,
3599 FileHardLinkInformation,
3600 FileProcessIdsUsingFileInformation,
3601 FileNormalizedNameInformation,
3602 FileNetworkPhysicalNameInformation,
3603 FileIdGlobalTxDirectoryInformation,
3604 FileIsRemoteDeviceInformation,
3605 FileAttributeCacheInformation,
3606 FileNumaNodeInformation,
3607 FileStandardLinkInformation,
3608 FileRemoteProtocolInformation,
3609 FileMaximumInformation
3610 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
3611
3612 typedef struct _FILE_POSITION_INFORMATION {
3613 LARGE_INTEGER CurrentByteOffset;
3614 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
3615
3616 #include <pshpack8.h>
3617 typedef struct _FILE_BASIC_INFORMATION {
3618 LARGE_INTEGER CreationTime;
3619 LARGE_INTEGER LastAccessTime;
3620 LARGE_INTEGER LastWriteTime;
3621 LARGE_INTEGER ChangeTime;
3622 ULONG FileAttributes;
3623 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
3624 #include <poppack.h>
3625
3626 typedef struct _FILE_STANDARD_INFORMATION {
3627 LARGE_INTEGER AllocationSize;
3628 LARGE_INTEGER EndOfFile;
3629 ULONG NumberOfLinks;
3630 BOOLEAN DeletePending;
3631 BOOLEAN Directory;
3632 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
3633
3634 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
3635 LARGE_INTEGER CreationTime;
3636 LARGE_INTEGER LastAccessTime;
3637 LARGE_INTEGER LastWriteTime;
3638 LARGE_INTEGER ChangeTime;
3639 LARGE_INTEGER AllocationSize;
3640 LARGE_INTEGER EndOfFile;
3641 ULONG FileAttributes;
3642 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
3643
3644 typedef enum _FSINFOCLASS {
3645 FileFsVolumeInformation = 1,
3646 FileFsLabelInformation,
3647 FileFsSizeInformation,
3648 FileFsDeviceInformation,
3649 FileFsAttributeInformation,
3650 FileFsControlInformation,
3651 FileFsFullSizeInformation,
3652 FileFsObjectIdInformation,
3653 FileFsDriverPathInformation,
3654 FileFsVolumeFlagsInformation,
3655 FileFsMaximumInformation
3656 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
3657
3658 typedef struct _FILE_FS_DEVICE_INFORMATION {
3659 DEVICE_TYPE DeviceType;
3660 ULONG Characteristics;
3661 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
3662
3663 typedef struct _FILE_FULL_EA_INFORMATION {
3664 ULONG NextEntryOffset;
3665 UCHAR Flags;
3666 UCHAR EaNameLength;
3667 USHORT EaValueLength;
3668 CHAR EaName[1];
3669 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
3670
3671 #define FM_LOCK_BIT (0x1)
3672 #define FM_LOCK_BIT_V (0x0)
3673 #define FM_LOCK_WAITER_WOKEN (0x2)
3674 #define FM_LOCK_WAITER_INC (0x4)
3675
3676 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
3677
3678 typedef struct _OWNER_ENTRY {
3679 ERESOURCE_THREAD OwnerThread;
3680 _ANONYMOUS_UNION union {
3681 LONG OwnerCount;
3682 ULONG TableSize;
3683 } DUMMYUNIONNAME;
3684 } OWNER_ENTRY, *POWNER_ENTRY;
3685
3686 typedef struct _ERESOURCE
3687 {
3688 LIST_ENTRY SystemResourcesList;
3689 POWNER_ENTRY OwnerTable;
3690 SHORT ActiveCount;
3691 USHORT Flag;
3692 volatile PKSEMAPHORE SharedWaiters;
3693 volatile PKEVENT ExclusiveWaiters;
3694 OWNER_ENTRY OwnerEntry;
3695 ULONG ActiveEntries;
3696 ULONG ContentionCount;
3697 ULONG NumberOfSharedWaiters;
3698 ULONG NumberOfExclusiveWaiters;
3699 __GNU_EXTENSION union
3700 {
3701 PVOID Address;
3702 ULONG_PTR CreatorBackTraceIndex;
3703 };
3704 KSPIN_LOCK SpinLock;
3705 } ERESOURCE, *PERESOURCE;
3706
3707 /* ERESOURCE.Flag */
3708 #define ResourceNeverExclusive 0x0010
3709 #define ResourceReleaseByOtherThread 0x0020
3710 #define ResourceOwnedExclusive 0x0080
3711
3712 #define RESOURCE_HASH_TABLE_SIZE 64
3713
3714 typedef BOOLEAN
3715 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
3716 IN struct _FILE_OBJECT *FileObject,
3717 IN PLARGE_INTEGER FileOffset,
3718 IN ULONG Length,
3719 IN BOOLEAN Wait,
3720 IN ULONG LockKey,
3721 IN BOOLEAN CheckForReadOperation,
3722 OUT PIO_STATUS_BLOCK IoStatus,
3723 IN struct _DEVICE_OBJECT *DeviceObject);
3724
3725 typedef BOOLEAN
3726 (DDKAPI *PFAST_IO_READ)(
3727 IN struct _FILE_OBJECT *FileObject,
3728 IN PLARGE_INTEGER FileOffset,
3729 IN ULONG Length,
3730 IN BOOLEAN Wait,
3731 IN ULONG LockKey,
3732 OUT PVOID Buffer,
3733 OUT PIO_STATUS_BLOCK IoStatus,
3734 IN struct _DEVICE_OBJECT *DeviceObject);
3735
3736 typedef BOOLEAN
3737 (DDKAPI *PFAST_IO_WRITE)(
3738 IN struct _FILE_OBJECT *FileObject,
3739 IN PLARGE_INTEGER FileOffset,
3740 IN ULONG Length,
3741 IN BOOLEAN Wait,
3742 IN ULONG LockKey,
3743 IN PVOID Buffer,
3744 OUT PIO_STATUS_BLOCK IoStatus,
3745 IN struct _DEVICE_OBJECT *DeviceObject);
3746
3747 typedef BOOLEAN
3748 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
3749 IN struct _FILE_OBJECT *FileObject,
3750 IN BOOLEAN Wait,
3751 OUT PFILE_BASIC_INFORMATION Buffer,
3752 OUT PIO_STATUS_BLOCK IoStatus,
3753 IN struct _DEVICE_OBJECT *DeviceObject);
3754
3755 typedef BOOLEAN
3756 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
3757 IN struct _FILE_OBJECT *FileObject,
3758 IN BOOLEAN Wait,
3759 OUT PFILE_STANDARD_INFORMATION Buffer,
3760 OUT PIO_STATUS_BLOCK IoStatus,
3761 IN struct _DEVICE_OBJECT *DeviceObject);
3762
3763 typedef BOOLEAN
3764 (DDKAPI *PFAST_IO_LOCK)(
3765 IN struct _FILE_OBJECT *FileObject,
3766 IN PLARGE_INTEGER FileOffset,
3767 IN PLARGE_INTEGER Length,
3768 PEPROCESS ProcessId,
3769 ULONG Key,
3770 BOOLEAN FailImmediately,
3771 BOOLEAN ExclusiveLock,
3772 OUT PIO_STATUS_BLOCK IoStatus,
3773 IN struct _DEVICE_OBJECT *DeviceObject);
3774
3775 typedef BOOLEAN
3776 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
3777 IN struct _FILE_OBJECT *FileObject,
3778 IN PLARGE_INTEGER FileOffset,
3779 IN PLARGE_INTEGER Length,
3780 PEPROCESS ProcessId,
3781 ULONG Key,
3782 OUT PIO_STATUS_BLOCK IoStatus,
3783 IN struct _DEVICE_OBJECT *DeviceObject);
3784
3785 typedef BOOLEAN
3786 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
3787 IN struct _FILE_OBJECT *FileObject,
3788 PEPROCESS ProcessId,
3789 OUT PIO_STATUS_BLOCK IoStatus,
3790 IN struct _DEVICE_OBJECT *DeviceObject);
3791
3792 typedef BOOLEAN
3793 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
3794 IN struct _FILE_OBJECT *FileObject,
3795 PVOID ProcessId,
3796 ULONG Key,
3797 OUT PIO_STATUS_BLOCK IoStatus,
3798 IN struct _DEVICE_OBJECT *DeviceObject);
3799
3800 typedef BOOLEAN
3801 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
3802 IN struct _FILE_OBJECT *FileObject,
3803 IN BOOLEAN Wait,
3804 IN PVOID InputBuffer OPTIONAL,
3805 IN ULONG InputBufferLength,
3806 OUT PVOID OutputBuffer OPTIONAL,
3807 IN ULONG OutputBufferLength,
3808 IN ULONG IoControlCode,
3809 OUT PIO_STATUS_BLOCK IoStatus,
3810 IN struct _DEVICE_OBJECT *DeviceObject);
3811
3812 typedef VOID
3813 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
3814 IN struct _FILE_OBJECT *FileObject);
3815
3816 typedef VOID
3817 (DDKAPI *PFAST_IO_RELEASE_FILE)(
3818 IN struct _FILE_OBJECT *FileObject);
3819
3820 typedef VOID
3821 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
3822 IN struct _DEVICE_OBJECT *SourceDevice,
3823 IN struct _DEVICE_OBJECT *TargetDevice);
3824
3825 typedef BOOLEAN
3826 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
3827 IN struct _FILE_OBJECT *FileObject,
3828 IN BOOLEAN Wait,
3829 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
3830 OUT struct _IO_STATUS_BLOCK *IoStatus,
3831 IN struct _DEVICE_OBJECT *DeviceObject);
3832
3833 typedef NTSTATUS
3834 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
3835 IN struct _FILE_OBJECT *FileObject,
3836 IN PLARGE_INTEGER EndingOffset,
3837 OUT struct _ERESOURCE **ResourceToRelease,
3838 IN struct _DEVICE_OBJECT *DeviceObject);
3839
3840 typedef BOOLEAN
3841 (DDKAPI *PFAST_IO_MDL_READ)(
3842 IN struct _FILE_OBJECT *FileObject,
3843 IN PLARGE_INTEGER FileOffset,
3844 IN ULONG Length,
3845 IN ULONG LockKey,
3846 OUT PMDL *MdlChain,
3847 OUT PIO_STATUS_BLOCK IoStatus,
3848 IN struct _DEVICE_OBJECT *DeviceObject);
3849
3850 typedef BOOLEAN
3851 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
3852 IN struct _FILE_OBJECT *FileObject,
3853 IN PMDL MdlChain,
3854 IN struct _DEVICE_OBJECT *DeviceObject);
3855
3856 typedef BOOLEAN
3857 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
3858 IN struct _FILE_OBJECT *FileObject,
3859 IN PLARGE_INTEGER FileOffset,
3860 IN ULONG Length,
3861 IN ULONG LockKey,
3862 OUT PMDL *MdlChain,
3863 OUT PIO_STATUS_BLOCK IoStatus,
3864 IN struct _DEVICE_OBJECT *DeviceObject);
3865
3866 typedef BOOLEAN
3867 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
3868 IN struct _FILE_OBJECT *FileObject,
3869 IN PLARGE_INTEGER FileOffset,
3870 IN PMDL MdlChain,
3871 IN struct _DEVICE_OBJECT *DeviceObject);
3872
3873 typedef BOOLEAN
3874 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
3875 IN struct _FILE_OBJECT *FileObject,
3876 IN PLARGE_INTEGER FileOffset,
3877 IN ULONG Length,
3878 IN ULONG LockKey,
3879 OUT PVOID Buffer,
3880 OUT PMDL *MdlChain,
3881 OUT PIO_STATUS_BLOCK IoStatus,
3882 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
3883 IN ULONG CompressedDataInfoLength,
3884 IN struct _DEVICE_OBJECT *DeviceObject);
3885
3886 typedef BOOLEAN
3887 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
3888 IN struct _FILE_OBJECT *FileObject,
3889 IN PLARGE_INTEGER FileOffset,
3890 IN ULONG Length,
3891 IN ULONG LockKey,
3892 IN PVOID Buffer,
3893 OUT PMDL *MdlChain,
3894 OUT PIO_STATUS_BLOCK IoStatus,
3895 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
3896 IN ULONG CompressedDataInfoLength,
3897 IN struct _DEVICE_OBJECT *DeviceObject);
3898
3899 typedef BOOLEAN
3900 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
3901 IN struct _FILE_OBJECT *FileObject,
3902 IN PMDL MdlChain,
3903 IN struct _DEVICE_OBJECT *DeviceObject);
3904
3905 typedef BOOLEAN
3906 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
3907 IN struct _FILE_OBJECT *FileObject,
3908 IN PLARGE_INTEGER FileOffset,
3909 IN PMDL MdlChain,
3910 IN struct _DEVICE_OBJECT *DeviceObject);
3911
3912 typedef BOOLEAN
3913 (DDKAPI *PFAST_IO_QUERY_OPEN)(
3914 IN struct _IRP *Irp,
3915 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
3916 IN struct _DEVICE_OBJECT *DeviceObject);
3917
3918 typedef NTSTATUS
3919 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
3920 IN struct _FILE_OBJECT *FileObject,
3921 IN struct _ERESOURCE *ResourceToRelease,
3922 IN struct _DEVICE_OBJECT *DeviceObject);
3923
3924 typedef NTSTATUS
3925 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
3926 IN struct _FILE_OBJECT *FileObject,
3927 IN struct _DEVICE_OBJECT *DeviceObject);
3928
3929 typedef NTSTATUS
3930 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
3931 IN struct _FILE_OBJECT *FileObject,
3932 IN struct _DEVICE_OBJECT *DeviceObject);
3933
3934 typedef struct _FAST_IO_DISPATCH {
3935 ULONG SizeOfFastIoDispatch;
3936 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
3937 PFAST_IO_READ FastIoRead;
3938 PFAST_IO_WRITE FastIoWrite;
3939 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
3940 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
3941 PFAST_IO_LOCK FastIoLock;
3942 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
3943 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
3944 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
3945 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
3946 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
3947 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
3948 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
3949 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
3950 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
3951 PFAST_IO_MDL_READ MdlRead;
3952 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
3953 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
3954 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
3955 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
3956 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
3957 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
3958 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
3959 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
3960 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
3961 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
3962 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
3963 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
3964
3965 typedef struct _SECTION_OBJECT_POINTERS {
3966 PVOID DataSectionObject;
3967 PVOID SharedCacheMap;
3968 PVOID ImageSectionObject;
3969 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
3970
3971 typedef struct _IO_COMPLETION_CONTEXT {
3972 PVOID Port;
3973 PVOID Key;
3974 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
3975
3976 /* FILE_OBJECT.Flags */
3977 #define FO_FILE_OPEN 0x00000001
3978 #define FO_SYNCHRONOUS_IO 0x00000002
3979 #define FO_ALERTABLE_IO 0x00000004
3980 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
3981 #define FO_WRITE_THROUGH 0x00000010
3982 #define FO_SEQUENTIAL_ONLY 0x00000020
3983 #define FO_CACHE_SUPPORTED 0x00000040
3984 #define FO_NAMED_PIPE 0x00000080
3985 #define FO_STREAM_FILE 0x00000100
3986 #define FO_MAILSLOT 0x00000200
3987 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
3988 #define FO_QUEUE_IRP_TO_THREAD 0x00000400
3989 #define FO_DIRECT_DEVICE_OPEN 0x00000800
3990 #define FO_FILE_MODIFIED 0x00001000
3991 #define FO_FILE_SIZE_CHANGED 0x00002000
3992 #define FO_CLEANUP_COMPLETE 0x00004000
3993 #define FO_TEMPORARY_FILE 0x00008000
3994 #define FO_DELETE_ON_CLOSE 0x00010000
3995 #define FO_OPENED_CASE_SENSITIVE 0x00020000
3996 #define FO_HANDLE_CREATED 0x00040000
3997 #define FO_FILE_FAST_IO_READ 0x00080000
3998 #define FO_RANDOM_ACCESS 0x00100000
3999 #define FO_FILE_OPEN_CANCELLED 0x00200000
4000 #define FO_VOLUME_OPEN 0x00400000
4001 #define FO_REMOTE_ORIGIN 0x01000000
4002 #define FO_DISALLOW_EXCLUSIVE 0x02000000
4003 #define FO_SKIP_COMPLETION_PORT 0x02000000
4004 #define FO_SKIP_SET_EVENT 0x04000000
4005 #define FO_SKIP_SET_FAST_IO 0x08000000
4006
4007 /* VPB.Flags */
4008 #define VPB_MOUNTED 0x0001
4009 #define VPB_LOCKED 0x0002
4010 #define VPB_PERSISTENT 0x0004
4011 #define VPB_REMOVE_PENDING 0x0008
4012 #define VPB_RAW_MOUNT 0x0010
4013 #define VPB_DIRECT_WRITES_ALLOWED 0x0020
4014
4015 /* IRP.Flags */
4016
4017 #define SL_FORCE_ACCESS_CHECK 0x01
4018 #define SL_OPEN_PAGING_FILE 0x02
4019 #define SL_OPEN_TARGET_DIRECTORY 0x04
4020 #define SL_CASE_SENSITIVE 0x80
4021
4022 #define SL_KEY_SPECIFIED 0x01
4023 #define SL_OVERRIDE_VERIFY_VOLUME 0x02
4024 #define SL_WRITE_THROUGH 0x04
4025 #define SL_FT_SEQUENTIAL_WRITE 0x08
4026
4027 #define SL_FAIL_IMMEDIATELY 0x01
4028 #define SL_EXCLUSIVE_LOCK 0x02
4029
4030 #define SL_RESTART_SCAN 0x01
4031 #define SL_RETURN_SINGLE_ENTRY 0x02
4032 #define SL_INDEX_SPECIFIED 0x04
4033
4034 #define SL_WATCH_TREE 0x01
4035
4036 #define SL_ALLOW_RAW_MOUNT 0x01
4037
4038 #define CTL_CODE(DeviceType, Function, Method, Access) \
4039 (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
4040
4041 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
4042
4043 #define IRP_NOCACHE 0x00000001
4044 #define IRP_PAGING_IO 0x00000002
4045 #define IRP_MOUNT_COMPLETION 0x00000002
4046 #define IRP_SYNCHRONOUS_API 0x00000004
4047 #define IRP_ASSOCIATED_IRP 0x00000008
4048 #define IRP_BUFFERED_IO 0x00000010
4049 #define IRP_DEALLOCATE_BUFFER 0x00000020
4050 #define IRP_INPUT_OPERATION 0x00000040
4051 #define IRP_SYNCHRONOUS_PAGING_IO 0x00000040
4052 #define IRP_CREATE_OPERATION 0x00000080
4053 #define IRP_READ_OPERATION 0x00000100
4054 #define IRP_WRITE_OPERATION 0x00000200
4055 #define IRP_CLOSE_OPERATION 0x00000400
4056 #define IRP_DEFER_IO_COMPLETION 0x00000800
4057 #define IRP_OB_QUERY_NAME 0x00001000
4058 #define IRP_HOLD_DEVICE_QUEUE 0x00002000
4059
4060 #define IRP_QUOTA_CHARGED 0x01
4061 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
4062 #define IRP_ALLOCATED_FIXED_SIZE 0x04
4063 #define IRP_LOOKASIDE_ALLOCATION 0x08
4064
4065 /*
4066 ** IRP function codes
4067 */
4068
4069 #define IRP_MJ_CREATE 0x00
4070 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
4071 #define IRP_MJ_CLOSE 0x02
4072 #define IRP_MJ_READ 0x03
4073 #define IRP_MJ_WRITE 0x04
4074 #define IRP_MJ_QUERY_INFORMATION 0x05
4075 #define IRP_MJ_SET_INFORMATION 0x06
4076 #define IRP_MJ_QUERY_EA 0x07
4077 #define IRP_MJ_SET_EA 0x08
4078 #define IRP_MJ_FLUSH_BUFFERS 0x09
4079 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
4080 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
4081 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
4082 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
4083 #define IRP_MJ_DEVICE_CONTROL 0x0e
4084 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
4085 #define IRP_MJ_SCSI 0x0f
4086 #define IRP_MJ_SHUTDOWN 0x10
4087 #define IRP_MJ_LOCK_CONTROL 0x11
4088 #define IRP_MJ_CLEANUP 0x12
4089 #define IRP_MJ_CREATE_MAILSLOT 0x13
4090 #define IRP_MJ_QUERY_SECURITY 0x14
4091 #define IRP_MJ_SET_SECURITY 0x15
4092 #define IRP_MJ_POWER 0x16
4093 #define IRP_MJ_SYSTEM_CONTROL 0x17
4094 #define IRP_MJ_DEVICE_CHANGE 0x18
4095 #define IRP_MJ_QUERY_QUOTA 0x19
4096 #define IRP_MJ_SET_QUOTA 0x1a
4097 #define IRP_MJ_PNP 0x1b
4098 #define IRP_MJ_PNP_POWER 0x1b
4099 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
4100
4101 #define IRP_MN_SCSI_CLASS 0x01
4102
4103 #define IRP_MN_START_DEVICE 0x00
4104 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
4105 #define IRP_MN_REMOVE_DEVICE 0x02
4106 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
4107 #define IRP_MN_STOP_DEVICE 0x04
4108 #define IRP_MN_QUERY_STOP_DEVICE 0x05
4109 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
4110
4111 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
4112 #define IRP_MN_QUERY_INTERFACE 0x08
4113 #define IRP_MN_QUERY_CAPABILITIES 0x09
4114 #define IRP_MN_QUERY_RESOURCES 0x0A
4115 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
4116 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
4117 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
4118
4119 #define IRP_MN_READ_CONFIG 0x0F
4120 #define IRP_MN_WRITE_CONFIG 0x10
4121 #define IRP_MN_EJECT 0x11
4122 #define IRP_MN_SET_LOCK 0x12
4123 #define IRP_MN_QUERY_ID 0x13
4124 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
4125 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
4126 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
4127 #define IRP_MN_SURPRISE_REMOVAL 0x17
4128
4129 #define IRP_MN_WAIT_WAKE 0x00
4130 #define IRP_MN_POWER_SEQUENCE 0x01
4131 #define IRP_MN_SET_POWER 0x02
4132 #define IRP_MN_QUERY_POWER 0x03
4133
4134 #define IRP_MN_QUERY_ALL_DATA 0x00
4135 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
4136 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
4137 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
4138 #define IRP_MN_ENABLE_EVENTS 0x04
4139 #define IRP_MN_DISABLE_EVENTS 0x05
4140 #define IRP_MN_ENABLE_COLLECTION 0x06
4141 #define IRP_MN_DISABLE_COLLECTION 0x07
4142 #define IRP_MN_REGINFO 0x08
4143 #define IRP_MN_EXECUTE_METHOD 0x09
4144
4145 #define IRP_MN_REGINFO_EX 0x0b
4146
4147 typedef struct _FILE_OBJECT
4148 {
4149 CSHORT Type;
4150 CSHORT Size;
4151 PDEVICE_OBJECT DeviceObject;
4152 PVPB Vpb;
4153 PVOID FsContext;
4154 PVOID FsContext2;
4155 PSECTION_OBJECT_POINTERS SectionObjectPointer;
4156 PVOID PrivateCacheMap;
4157 NTSTATUS FinalStatus;
4158 struct _FILE_OBJECT *RelatedFileObject;
4159 BOOLEAN LockOperation;
4160 BOOLEAN DeletePending;
4161 BOOLEAN ReadAccess;
4162 BOOLEAN WriteAccess;
4163 BOOLEAN DeleteAccess;
4164 BOOLEAN SharedRead;
4165 BOOLEAN SharedWrite;
4166 BOOLEAN SharedDelete;
4167 ULONG Flags;
4168 UNICODE_STRING FileName;
4169 LARGE_INTEGER CurrentByteOffset;
4170 volatile ULONG Waiters;
4171 volatile ULONG Busy;
4172 PVOID LastLock;
4173 KEVENT Lock;
4174 KEVENT Event;
4175 volatile PIO_COMPLETION_CONTEXT CompletionContext;
4176 KSPIN_LOCK IrpListLock;
4177 LIST_ENTRY IrpList;
4178 volatile PVOID FileObjectExtension;
4179 } FILE_OBJECT, *PFILE_OBJECT;
4180
4181 typedef struct _IO_ERROR_LOG_PACKET {
4182 UCHAR MajorFunctionCode;
4183 UCHAR RetryCount;
4184 USHORT DumpDataSize;
4185 USHORT NumberOfStrings;
4186 USHORT StringOffset;
4187 USHORT EventCategory;
4188 NTSTATUS ErrorCode;
4189 ULONG UniqueErrorValue;
4190 NTSTATUS FinalStatus;
4191 ULONG SequenceNumber;
4192 ULONG IoControlCode;
4193 LARGE_INTEGER DeviceOffset;
4194 ULONG DumpData[1];
4195 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
4196
4197 typedef struct _IO_ERROR_LOG_MESSAGE {
4198 USHORT Type;
4199 USHORT Size;
4200 USHORT DriverNameLength;
4201 LARGE_INTEGER TimeStamp;
4202 ULONG DriverNameOffset;
4203 IO_ERROR_LOG_PACKET EntryData;
4204 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
4205
4206 #define ERROR_LOG_LIMIT_SIZE 240
4207 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
4208 sizeof(IO_ERROR_LOG_PACKET) + \
4209 (sizeof(WCHAR) * 40))
4210 #define ERROR_LOG_MESSAGE_LIMIT_SIZE \
4211 (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
4212 #define IO_ERROR_LOG_MESSAGE_LENGTH \
4213 ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \
4214 ERROR_LOG_MESSAGE_LIMIT_SIZE : \
4215 PORT_MAXIMUM_MESSAGE_LENGTH)
4216 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
4217 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
4218
4219 typedef enum _DMA_WIDTH {
4220 Width8Bits,
4221 Width16Bits,
4222 Width32Bits,
4223 MaximumDmaWidth
4224 } DMA_WIDTH, *PDMA_WIDTH;
4225
4226 typedef enum _DMA_SPEED {
4227 Compatible,
4228 TypeA,
4229 TypeB,
4230 TypeC,
4231 TypeF,
4232 MaximumDmaSpeed
4233 } DMA_SPEED, *PDMA_SPEED;
4234
4235 /* DEVICE_DESCRIPTION.Version */
4236
4237 #define DEVICE_DESCRIPTION_VERSION 0x0000
4238 #define DEVICE_DESCRIPTION_VERSION1 0x0001
4239 #define DEVICE_DESCRIPTION_VERSION2 0x0002
4240
4241 typedef struct _DEVICE_DESCRIPTION {
4242 ULONG Version;
4243 BOOLEAN Master;
4244 BOOLEAN ScatterGather;
4245 BOOLEAN DemandMode;
4246 BOOLEAN AutoInitialize;
4247 BOOLEAN Dma32BitAddresses;
4248 BOOLEAN IgnoreCount;
4249 BOOLEAN Reserved1;
4250 BOOLEAN Dma64BitAddresses;
4251 ULONG BusNumber;
4252 ULONG DmaChannel;
4253 INTERFACE_TYPE InterfaceType;
4254 DMA_WIDTH DmaWidth;
4255 DMA_SPEED DmaSpeed;
4256 ULONG MaximumLength;
4257 ULONG DmaPort;
4258 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
4259
4260 typedef enum _DEVICE_RELATION_TYPE {
4261 BusRelations,
4262 EjectionRelations,
4263 PowerRelations,
4264 RemovalRelations,
4265 TargetDeviceRelation,
4266 SingleBusRelations,
4267 TransportRelations
4268 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
4269
4270 typedef struct _DEVICE_RELATIONS {
4271 ULONG Count;
4272 PDEVICE_OBJECT Objects[1];
4273 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
4274
4275 typedef struct _DEVOBJ_EXTENSION
4276 {
4277 CSHORT Type;
4278 USHORT Size;
4279 PDEVICE_OBJECT DeviceObject;
4280 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
4281
4282 typedef struct _SCATTER_GATHER_ELEMENT {
4283 PHYSICAL_ADDRESS Address;
4284 ULONG Length;
4285 ULONG_PTR Reserved;
4286 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
4287
4288 #if defined(_MSC_EXTENSIONS)
4289
4290 #if _MSC_VER >= 1200
4291 #pragma warning(push)
4292 #endif
4293 #pragma warning(disable:4200)
4294 typedef struct _SCATTER_GATHER_LIST {
4295 ULONG NumberOfElements;
4296 ULONG_PTR Reserved;
4297 SCATTER_GATHER_ELEMENT Elements[1];
4298 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
4299
4300 #if _MSC_VER >= 1200
4301 #pragma warning(pop)
4302 #else
4303 #pragma warning(default:4200)
4304 #endif
4305
4306 #else
4307
4308 struct _SCATTER_GATHER_LIST;
4309 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
4310
4311 #endif
4312
4313 typedef NTSTATUS
4314 (DDKAPI DRIVER_ADD_DEVICE)(
4315 IN struct _DRIVER_OBJECT *DriverObject,
4316 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
4317 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
4318
4319 typedef struct _DRIVER_EXTENSION {
4320 struct _DRIVER_OBJECT *DriverObject;
4321 PDRIVER_ADD_DEVICE AddDevice;
4322 ULONG Count;
4323 UNICODE_STRING ServiceKeyName;
4324 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
4325
4326 #define DRVO_UNLOAD_INVOKED 0x00000001
4327 #define DRVO_LEGACY_DRIVER 0x00000002
4328 #define DRVO_BUILTIN_DRIVER 0x00000004
4329
4330 typedef NTSTATUS
4331 (DDKAPI DRIVER_INITIALIZE)(
4332 IN struct _DRIVER_OBJECT *DriverObject,
4333 IN PUNICODE_STRING RegistryPath);
4334 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
4335
4336 typedef VOID
4337 (DDKAPI DRIVER_STARTIO)(
4338 IN struct _DEVICE_OBJECT *DeviceObject,
4339 IN struct _IRP *Irp);
4340 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
4341
4342 typedef VOID
4343 (DDKAPI DRIVER_UNLOAD)(
4344 IN struct _DRIVER_OBJECT *DriverObject);
4345 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
4346
4347 typedef NTSTATUS
4348 (DDKAPI DRIVER_DISPATCH)(
4349 IN struct _DEVICE_OBJECT *DeviceObject,
4350 IN struct _IRP *Irp);
4351 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
4352
4353 typedef struct _DRIVER_OBJECT {
4354 CSHORT Type;
4355 CSHORT Size;
4356 PDEVICE_OBJECT DeviceObject;
4357 ULONG Flags;
4358 PVOID DriverStart;
4359 ULONG DriverSize;
4360 PVOID DriverSection;
4361 PDRIVER_EXTENSION DriverExtension;
4362 UNICODE_STRING DriverName;
4363 PUNICODE_STRING HardwareDatabase;
4364 struct _FAST_IO_DISPATCH *FastIoDispatch;
4365 PDRIVER_INITIALIZE DriverInit;
4366 PDRIVER_STARTIO DriverStartIo;
4367 PDRIVER_UNLOAD DriverUnload;
4368 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
4369 } DRIVER_OBJECT;
4370 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
4371
4372 typedef struct _DMA_ADAPTER {
4373 USHORT Version;
4374 USHORT Size;
4375 struct _DMA_OPERATIONS* DmaOperations;
4376 } DMA_ADAPTER, *PDMA_ADAPTER;
4377
4378 typedef VOID
4379 (DDKAPI *PPUT_DMA_ADAPTER)(
4380 IN PDMA_ADAPTER DmaAdapter);
4381
4382 typedef PVOID
4383 (DDKAPI *PALLOCATE_COMMON_BUFFER)(
4384 IN PDMA_ADAPTER DmaAdapter,
4385 IN ULONG Length,
4386 OUT PPHYSICAL_ADDRESS LogicalAddress,
4387 IN BOOLEAN CacheEnabled);
4388
4389 typedef VOID
4390 (DDKAPI *PFREE_COMMON_BUFFER)(
4391 IN PDMA_ADAPTER DmaAdapter,
4392 IN ULONG Length,
4393 IN PHYSICAL_ADDRESS LogicalAddress,
4394 IN PVOID VirtualAddress,
4395 IN BOOLEAN CacheEnabled);
4396
4397 typedef NTSTATUS
4398 (DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
4399 IN PDMA_ADAPTER DmaAdapter,
4400 IN PDEVICE_OBJECT DeviceObject,
4401 IN ULONG NumberOfMapRegisters,
4402 IN PDRIVER_CONTROL ExecutionRoutine,
4403 IN PVOID Context);
4404
4405 typedef BOOLEAN
4406 (DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
4407 IN PDMA_ADAPTER DmaAdapter,
4408 IN PMDL Mdl,
4409 IN PVOID MapRegisterBase,
4410 IN PVOID CurrentVa,
4411 IN ULONG Length,
4412 IN BOOLEAN WriteToDevice);
4413
4414 typedef VOID
4415 (DDKAPI *PFREE_ADAPTER_CHANNEL)(
4416 IN PDMA_ADAPTER DmaAdapter);
4417
4418 typedef VOID
4419 (DDKAPI *PFREE_MAP_REGISTERS)(
4420 IN PDMA_ADAPTER DmaAdapter,
4421 PVOID MapRegisterBase,
4422 ULONG NumberOfMapRegisters);
4423
4424 typedef PHYSICAL_ADDRESS
4425 (DDKAPI *PMAP_TRANSFER)(
4426 IN PDMA_ADAPTER DmaAdapter,
4427 IN PMDL Mdl,
4428 IN PVOID MapRegisterBase,
4429 IN PVOID CurrentVa,
4430 IN OUT PULONG Length,
4431 IN BOOLEAN WriteToDevice);
4432
4433 typedef ULONG
4434 (DDKAPI *PGET_DMA_ALIGNMENT)(
4435 IN PDMA_ADAPTER DmaAdapter);
4436
4437 typedef ULONG
4438 (DDKAPI *PREAD_DMA_COUNTER)(
4439 IN PDMA_ADAPTER DmaAdapter);
4440
4441 typedef VOID
4442 (DDKAPI *PDRIVER_LIST_CONTROL)(
4443 IN struct _DEVICE_OBJECT *DeviceObject,
4444 IN struct _IRP *Irp,
4445 IN struct _SCATTER_GATHER_LIST *ScatterGather,
4446 IN PVOID Context);
4447
4448 typedef NTSTATUS
4449 (DDKAPI *PGET_SCATTER_GATHER_LIST)(
4450 IN PDMA_ADAPTER DmaAdapter,
4451 IN PDEVICE_OBJECT DeviceObject,
4452 IN PMDL Mdl,
4453 IN PVOID CurrentVa,
4454 IN ULONG Length,
4455 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
4456 IN PVOID Context,
4457 IN BOOLEAN WriteToDevice);
4458
4459 typedef VOID
4460 (DDKAPI *PPUT_SCATTER_GATHER_LIST)(
4461 IN PDMA_ADAPTER DmaAdapter,
4462 IN PSCATTER_GATHER_LIST ScatterGather,
4463 IN BOOLEAN WriteToDevice);
4464
4465 typedef NTSTATUS
4466 (DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
4467 IN PDMA_ADAPTER DmaAdapter,
4468 IN PMDL Mdl OPTIONAL,
4469 IN PVOID CurrentVa,
4470 IN ULONG Length,
4471 OUT PULONG ScatterGatherListSize,
4472 OUT PULONG pNumberOfMapRegisters OPTIONAL);
4473
4474 typedef NTSTATUS
4475 (DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
4476 IN PDMA_ADAPTER DmaAdapter,
4477 IN PDEVICE_OBJECT DeviceObject,
4478 IN PMDL Mdl,
4479 IN PVOID CurrentVa,
4480 IN ULONG Length,
4481 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
4482 IN PVOID Context,
4483 IN BOOLEAN WriteToDevice,
4484 IN PVOID ScatterGatherBuffer,
4485 IN ULONG ScatterGatherLength);
4486
4487 typedef NTSTATUS
4488 (DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
4489 IN PDMA_ADAPTER DmaAdapter,
4490 IN PSCATTER_GATHER_LIST ScatterGather,
4491 IN PMDL OriginalMdl,
4492 OUT PMDL *TargetMdl);
4493
4494 typedef struct _DMA_OPERATIONS {
4495 ULONG Size;
4496 PPUT_DMA_ADAPTER PutDmaAdapter;
4497 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
4498 PFREE_COMMON_BUFFER FreeCommonBuffer;
4499 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
4500 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
4501 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
4502 PFREE_MAP_REGISTERS FreeMapRegisters;
4503 PMAP_TRANSFER MapTransfer;
4504 PGET_DMA_ALIGNMENT GetDmaAlignment;
4505 PREAD_DMA_COUNTER ReadDmaCounter;
4506 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
4507 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
4508 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
4509 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
4510 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
4511 } DMA_OPERATIONS, *PDMA_OPERATIONS;
4512
4513 typedef struct _IO_RESOURCE_DESCRIPTOR {
4514 UCHAR Option;
4515 UCHAR Type;
4516 UCHAR ShareDisposition;
4517 UCHAR Spare1;
4518 USHORT Flags;
4519 USHORT Spare2;
4520 union {
4521 struct {
4522 ULONG Length;
4523 ULONG Alignment;
4524 PHYSICAL_ADDRESS MinimumAddress;
4525 PHYSICAL_ADDRESS MaximumAddress;
4526 } Port;
4527 struct {
4528 ULONG Length;
4529 ULONG Alignment;
4530 PHYSICAL_ADDRESS MinimumAddress;
4531 PHYSICAL_ADDRESS MaximumAddress;
4532 } Memory;
4533 struct {
4534 ULONG MinimumVector;
4535 ULONG MaximumVector;
4536 } Interrupt;
4537 struct {
4538 ULONG MinimumChannel;
4539 ULONG MaximumChannel;
4540 } Dma;
4541 struct {
4542 ULONG Length;
4543 ULONG Alignment;
4544 PHYSICAL_ADDRESS MinimumAddress;
4545 PHYSICAL_ADDRESS MaximumAddress;
4546 } Generic;
4547 struct {
4548 ULONG Data[3];
4549 } DevicePrivate;
4550 struct {
4551 ULONG Length;
4552 ULONG MinBusNumber;
4553 ULONG MaxBusNumber;
4554 ULONG Reserved;
4555 } BusNumber;
4556 struct {
4557 ULONG Priority;
4558 ULONG Reserved1;
4559 ULONG Reserved2;
4560 } ConfigData;
4561 } u;
4562 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
4563
4564 typedef struct _IO_RESOURCE_LIST {
4565 USHORT Version;
4566 USHORT Revision;
4567 ULONG Count;
4568 IO_RESOURCE_DESCRIPTOR Descriptors[1];
4569 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
4570
4571 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
4572 ULONG ListSize;
4573 INTERFACE_TYPE InterfaceType;
4574 ULONG BusNumber;
4575 ULONG SlotNumber;
4576 ULONG Reserved[3];
4577 ULONG AlternativeLists;
4578 IO_RESOURCE_LIST List[1];
4579 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
4580
4581 typedef VOID
4582 (DDKAPI DRIVER_CANCEL)(
4583 IN struct _DEVICE_OBJECT *DeviceObject,
4584 IN struct _IRP *Irp);
4585 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
4586
4587 typedef struct _IRP {
4588 CSHORT Type;
4589 USHORT Size;
4590 struct _MDL *MdlAddress;
4591 ULONG Flags;
4592 union {
4593 struct _IRP *MasterIrp;
4594 volatile LONG IrpCount;
4595 PVOID SystemBuffer;
4596 } AssociatedIrp;
4597 LIST_ENTRY ThreadListEntry;
4598 IO_STATUS_BLOCK IoStatus;
4599 KPROCESSOR_MODE RequestorMode;
4600 BOOLEAN PendingReturned;
4601 CHAR StackCount;
4602 CHAR CurrentLocation;
4603 BOOLEAN Cancel;
4604 KIRQL CancelIrql;
4605 CCHAR ApcEnvironment;
4606 UCHAR AllocationFlags;
4607 PIO_STATUS_BLOCK UserIosb;
4608 PKEVENT UserEvent;
4609 union {
4610 struct {
4611 _ANONYMOUS_UNION union {
4612 PIO_APC_ROUTINE UserApcRoutine;
4613 PVOID IssuingProcess;
4614 } DUMMYUNIONNAME;
4615 PVOID UserApcContext;
4616 } AsynchronousParameters;
4617 LARGE_INTEGER AllocationSize;
4618 } Overlay;
4619 volatile PDRIVER_CANCEL CancelRoutine;
4620 PVOID UserBuffer;
4621 union {
4622 struct {
4623 _ANONYMOUS_UNION union {
4624 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
4625 _ANONYMOUS_STRUCT struct {
4626 PVOID DriverContext[4];
4627 } DUMMYSTRUCTNAME;
4628 } DUMMYUNIONNAME;
4629 PETHREAD Thread;
4630 PCHAR AuxiliaryBuffer;
4631 _ANONYMOUS_STRUCT struct {