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