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