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