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