8f5f16f553f6730ab6939a1426473f268f1951f6
[reactos.git] / reactos / w32api / include / ddk / winddk.h
1 /*
2 * winddk.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __WINDDK_H
24 #define __WINDDK_H
25
26 #if __GNUC__ >= 3
27 #pragma GCC system_header
28 #endif
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*
35 ** Definitions specific to this Device Driver Kit
36 */
37 #define DDKAPI __stdcall
38 #define DDKFASTAPI __fastcall
39 #define FASTCALL __fastcall
40 #define DDKCDECLAPI __cdecl
41
42 /* FIXME: REMOVE THIS UNCOMPATIBLE CRUFT!!! */
43 #if defined(_NTOSKRNL_)
44 #ifndef NTOSAPI
45 #define NTOSAPI DECL_EXPORT
46 #endif
47 #define DECLARE_INTERNAL_OBJECT(x) typedef struct _##x; typedef struct _##x *P##x;
48 #define DECLARE_INTERNAL_OBJECT2(x,y) typedef struct _##x; typedef struct _##x *P##y;
49 #else
50 #ifndef NTOSAPI
51 #define NTOSAPI DECL_IMPORT
52 #endif
53 #define DECLARE_INTERNAL_OBJECT(x) struct _##x; typedef struct _##x *P##x;
54 #define DECLARE_INTERNAL_OBJECT2(x,y) struct _##x; typedef struct _##x *P##y;
55 #endif
56
57 #if defined(_NTHAL_)
58 #ifndef NTHALAPI
59 #define NTHALAPI DECL_EXPORT
60 #endif
61 #else
62 #ifndef NTHALAPI
63 #define NTHALAPI DECL_IMPORT
64 #endif
65 #endif
66
67 /* Pseudo modifiers for parameters */
68 #define IN
69 #define OUT
70 #define OPTIONAL
71 #define UNALLIGNED
72
73 #define CONST const
74 #define VOLATILE volatile
75
76 #define RESTRICTED_POINTER
77 #define POINTER_ALIGNMENT
78 #define DECLSPEC_ADDRSAFE
79
80 #ifdef NONAMELESSUNION
81 # define _DDK_DUMMYUNION_MEMBER(name) DUMMYUNIONNAME.name
82 # define _DDK_DUMMYUNION_N_MEMBER(n, name) DUMMYUNIONNAME##n.name
83 #else
84 # define _DDK_DUMMYUNION_MEMBER(name) name
85 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
86 #endif
87
88 #if !defined(_NTSYSTEM_)
89 #define NTSYSAPI DECLSPEC_IMPORT
90 #define NTSYSCALLAPI DECLSPEC_IMPORT
91 #else
92 #define NTSYSAPI
93 #if defined(_NTDLLBUILD_)
94 #define NTSYSCALLAPI
95 #else
96 #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
97 #endif
98 #endif
99
100 /*
101 * Alignment Macros
102 */
103 #define ALIGN_DOWN(s, t) \
104 ((ULONG)(s) & ~(sizeof(t) - 1))
105
106 #define ALIGN_UP(s, t) \
107 (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
108
109 #define ALIGN_DOWN_POINTER(p, t) \
110 ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
111
112 #define ALIGN_UP_POINTER(p, t) \
113 (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
114
115 /*
116 ** Forward declarations
117 */
118
119 struct _IRP;
120 struct _MDL;
121 struct _KAPC;
122 struct _KDPC;
123 struct _KPCR;
124 struct _KPRCB;
125 struct _KTSS;
126 struct _FILE_OBJECT;
127 struct _DMA_ADAPTER;
128 struct _DEVICE_OBJECT;
129 struct _DRIVER_OBJECT;
130 struct _SECTION_OBJECT;
131 struct _IO_STATUS_BLOCK;
132 struct _DEVICE_DESCRIPTION;
133 struct _SCATTER_GATHER_LIST;
134 struct _DRIVE_LAYOUT_INFORMATION;
135 struct _DRIVE_LAYOUT_INFORMATION_EX;
136
137 typedef PVOID PSECURITY_DESCRIPTOR;
138 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
139 typedef PVOID PSID;
140
141 DECLARE_INTERNAL_OBJECT(ADAPTER_OBJECT)
142 DECLARE_INTERNAL_OBJECT(DMA_ADAPTER)
143 DECLARE_INTERNAL_OBJECT(IO_STATUS_BLOCK)
144 DECLARE_INTERNAL_OBJECT(SECTION_OBJECT)
145
146 #if 1
147 /* FIXME: Unknown definitions */
148 struct _SET_PARTITION_INFORMATION_EX;
149 typedef ULONG WAIT_TYPE;
150 #define WaitAll 0
151 #define WaitAny 1
152 typedef HANDLE TRACEHANDLE;
153 typedef PVOID PWMILIB_CONTEXT;
154 typedef PVOID PSYSCTL_IRP_DISPOSITION;
155 typedef ULONG LOGICAL;
156 #endif
157
158 /*
159 ** Routines specific to this DDK
160 */
161 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
162
163 /*
164 ** Simple structures
165 */
166
167 typedef LONG KPRIORITY;
168 typedef UCHAR KIRQL, *PKIRQL;
169 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
170 typedef UCHAR KPROCESSOR_MODE;
171
172 typedef enum _MODE {
173 KernelMode,
174 UserMode,
175 MaximumMode
176 } MODE;
177
178 typedef struct _QUAD
179 {
180 union
181 {
182 LONGLONG UseThisFieldToCopy;
183 float DoNotUseThisField;
184 };
185 } QUAD, *PQUAD;
186
187 /* Structures not exposed to drivers */
188 typedef struct _IO_TIMER *PIO_TIMER;
189 typedef struct _KPROCESS *PKPROCESS;
190 typedef struct _EPROCESS *PEPROCESS;
191 typedef struct _ETHREAD *PETHREAD;
192 typedef struct _KINTERRUPT *PKINTERRUPT;
193 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
194 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
195 typedef struct _COMPRESSED_DATA_INFO *PCOMPRESSED_DATA_INFO;
196 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
197 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
198 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
199 typedef struct _BUS_HANDLER *PBUS_HANDLER;
200 typedef struct _PEB *PPEB;
201 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
202
203 /* Constants */
204 #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 )
205 #define ZwCurrentProcess() NtCurrentProcess()
206 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
207 #define ZwCurrentThread() NtCurrentThread()
208
209 #define DPFLTR_ERROR_LEVEL 0
210 #define DPFLTR_WARNING_LEVEL 1
211 #define DPFLTR_TRACE_LEVEL 2
212 #define DPFLTR_INFO_LEVEL 3
213 #define DPFLTR_MASK 0x80000000
214
215 #define MAXIMUM_PROCESSORS 32
216
217 #define MAXIMUM_WAIT_OBJECTS 64
218
219 #define EX_RUNDOWN_ACTIVE 0x1
220 #define EX_RUNDOWN_COUNT_SHIFT 0x1
221 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT)
222
223 #define METHOD_BUFFERED 0
224 #define METHOD_IN_DIRECT 1
225 #define METHOD_OUT_DIRECT 2
226 #define METHOD_NEITHER 3
227
228 #define LOW_PRIORITY 0
229 #define LOW_REALTIME_PRIORITY 16
230 #define HIGH_PRIORITY 31
231 #define MAXIMUM_PRIORITY 32
232
233 #define FILE_SUPERSEDED 0x00000000
234 #define FILE_OPENED 0x00000001
235 #define FILE_CREATED 0x00000002
236 #define FILE_OVERWRITTEN 0x00000003
237 #define FILE_EXISTS 0x00000004
238 #define FILE_DOES_NOT_EXIST 0x00000005
239
240 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
241 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
242
243 /* also in winnt.h */
244 #define FILE_LIST_DIRECTORY 0x00000001
245 #define FILE_READ_DATA 0x00000001
246 #define FILE_ADD_FILE 0x00000002
247 #define FILE_WRITE_DATA 0x00000002
248 #define FILE_ADD_SUBDIRECTORY 0x00000004
249 #define FILE_APPEND_DATA 0x00000004
250 #define FILE_CREATE_PIPE_INSTANCE 0x00000004
251 #define FILE_READ_EA 0x00000008
252 #define FILE_WRITE_EA 0x00000010
253 #define FILE_EXECUTE 0x00000020
254 #define FILE_TRAVERSE 0x00000020
255 #define FILE_DELETE_CHILD 0x00000040
256 #define FILE_READ_ATTRIBUTES 0x00000080
257 #define FILE_WRITE_ATTRIBUTES 0x00000100
258
259 #define FILE_SHARE_READ 0x00000001
260 #define FILE_SHARE_WRITE 0x00000002
261 #define FILE_SHARE_DELETE 0x00000004
262 #define FILE_SHARE_VALID_FLAGS 0x00000007
263
264 #define FILE_ATTRIBUTE_READONLY 0x00000001
265 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
266 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
267 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
268 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
269 #define FILE_ATTRIBUTE_DEVICE 0x00000040
270 #define FILE_ATTRIBUTE_NORMAL 0x00000080
271 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
272 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
273 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
274 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
275 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
276 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
277 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
278
279 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
280 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
281
282 #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
283 #define FILE_STRUCTURED_STORAGE 0x00000441
284
285 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
286 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
287 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
288 #define FILE_VALID_SET_FLAGS 0x00000036
289
290 #define FILE_SUPERSEDE 0x00000000
291 #define FILE_OPEN 0x00000001
292 #define FILE_CREATE 0x00000002
293 #define FILE_OPEN_IF 0x00000003
294 #define FILE_OVERWRITE 0x00000004
295 #define FILE_OVERWRITE_IF 0x00000005
296 #define FILE_MAXIMUM_DISPOSITION 0x00000005
297
298 #define FILE_DIRECTORY_FILE 0x00000001
299 #define FILE_WRITE_THROUGH 0x00000002
300 #define FILE_SEQUENTIAL_ONLY 0x00000004
301 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
302 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
303 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
304 #define FILE_NON_DIRECTORY_FILE 0x00000040
305 #define FILE_CREATE_TREE_CONNECTION 0x00000080
306 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
307 #define FILE_NO_EA_KNOWLEDGE 0x00000200
308 #define FILE_OPEN_FOR_RECOVERY 0x00000400
309 #define FILE_RANDOM_ACCESS 0x00000800
310 #define FILE_DELETE_ON_CLOSE 0x00001000
311 #define FILE_OPEN_BY_FILE_ID 0x00002000
312 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
313 #define FILE_NO_COMPRESSION 0x00008000
314 #define FILE_RESERVE_OPFILTER 0x00100000
315 #define FILE_OPEN_REPARSE_POINT 0x00200000
316 #define FILE_OPEN_NO_RECALL 0x00400000
317 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
318
319 #define FILE_ANY_ACCESS 0x00000000
320 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS
321 #define FILE_READ_ACCESS 0x00000001
322 #define FILE_WRITE_ACCESS 0x00000002
323
324 #define FILE_ALL_ACCESS \
325 (STANDARD_RIGHTS_REQUIRED | \
326 SYNCHRONIZE | \
327 0x1FF)
328
329 #define FILE_GENERIC_EXECUTE \
330 (STANDARD_RIGHTS_EXECUTE | \
331 FILE_READ_ATTRIBUTES | \
332 FILE_EXECUTE | \
333 SYNCHRONIZE)
334
335 #define FILE_GENERIC_READ \
336 (STANDARD_RIGHTS_READ | \
337 FILE_READ_DATA | \
338 FILE_READ_ATTRIBUTES | \
339 FILE_READ_EA | \
340 SYNCHRONIZE)
341
342 #define FILE_GENERIC_WRITE \
343 (STANDARD_RIGHTS_WRITE | \
344 FILE_WRITE_DATA | \
345 FILE_WRITE_ATTRIBUTES | \
346 FILE_WRITE_EA | \
347 FILE_APPEND_DATA | \
348 SYNCHRONIZE)
349 /* end winnt.h */
350
351 #define OBJECT_TYPE_CREATE (0x0001)
352 #define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
353
354 #define DIRECTORY_QUERY (0x0001)
355 #define DIRECTORY_TRAVERSE (0x0002)
356 #define DIRECTORY_CREATE_OBJECT (0x0004)
357 #define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
358 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
359
360 #define EVENT_QUERY_STATE (0x0001)
361 #define EVENT_MODIFY_STATE (0x0002)
362 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
363
364 #define SEMAPHORE_QUERY_STATE (0x0001)
365 #define SEMAPHORE_MODIFY_STATE (0x0002)
366 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
367
368 #define THREAD_ALERT (0x0004)
369
370 #define FM_LOCK_BIT (0x1)
371 #define FM_LOCK_BIT_V (0x0)
372 #define FM_LOCK_WAITER_WOKEN (0x2)
373 #define FM_LOCK_WAITER_INC (0x4)
374
375 /* Exported object types */
376 extern NTOSAPI POBJECT_TYPE ExDesktopObjectType;
377 extern NTOSAPI POBJECT_TYPE ExEventObjectType;
378 extern NTOSAPI POBJECT_TYPE ExSemaphoreObjectType;
379 extern NTOSAPI POBJECT_TYPE ExWindowStationObjectType;
380 extern NTOSAPI ULONG IoDeviceHandlerObjectSize;
381 extern NTOSAPI POBJECT_TYPE IoDeviceHandlerObjectType;
382 extern NTOSAPI POBJECT_TYPE IoDeviceObjectType;
383 extern NTOSAPI POBJECT_TYPE IoDriverObjectType;
384 extern NTOSAPI POBJECT_TYPE IoFileObjectType;
385 extern NTOSAPI POBJECT_TYPE PsThreadType;
386 extern NTOSAPI POBJECT_TYPE LpcPortObjectType;
387 extern NTOSAPI POBJECT_TYPE MmSectionObjectType;
388 extern NTOSAPI POBJECT_TYPE SeTokenObjectType;
389
390 extern NTOSAPI CCHAR KeNumberProcessors;
391
392 #define PROCESSOR_FEATURE_MAX 64
393 #define MAX_WOW64_SHARED_ENTRIES 16
394
395 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
396 {
397 StandardDesign,
398 NEC98x86,
399 EndAlternatives
400 } ALTERNATIVE_ARCHITECTURE_TYPE;
401
402 typedef struct _KSYSTEM_TIME
403 {
404 ULONG LowPart;
405 LONG High1Time;
406 LONG High2Time;
407 } KSYSTEM_TIME, *PKSYSTEM_TIME;
408
409 typedef struct _KUSER_SHARED_DATA
410 {
411 ULONG TickCountLowDeprecated;
412 ULONG TickCountMultiplier;
413 volatile KSYSTEM_TIME InterruptTime;
414 volatile KSYSTEM_TIME SystemTime;
415 volatile KSYSTEM_TIME TimeZoneBias;
416 USHORT ImageNumberLow;
417 USHORT ImageNumberHigh;
418 WCHAR NtSystemRoot[260];
419 ULONG MaxStackTraceDepth;
420 ULONG CryptoExponent;
421 ULONG TimeZoneId;
422 ULONG LargePageMinimum;
423 ULONG Reserved2[7];
424 NT_PRODUCT_TYPE NtProductType;
425 BOOLEAN ProductTypeIsValid;
426 ULONG NtMajorVersion;
427 ULONG NtMinorVersion;
428 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
429 ULONG Reserved1;
430 ULONG Reserved3;
431 volatile ULONG TimeSlip;
432 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
433 LARGE_INTEGER SystemExpirationDate;
434 ULONG SuiteMask;
435 BOOLEAN KdDebuggerEnabled;
436 volatile ULONG ActiveConsoleId;
437 volatile ULONG DismountCount;
438 ULONG ComPlusPackage;
439 ULONG LastSystemRITEventTickCount;
440 ULONG NumberOfPhysicalPages;
441 BOOLEAN SafeBootMode;
442 ULONG TraceLogging;
443 ULONG Fill0;
444 ULONGLONG TestRetInstruction;
445 ULONG SystemCall;
446 ULONG SystemCallReturn;
447 ULONGLONG SystemCallPad[3];
448 union {
449 volatile KSYSTEM_TIME TickCount;
450 volatile ULONG64 TickCountQuad;
451 };
452 ULONG Cookie;
453 LONGLONG ConsoleSessionForegroundProcessId;
454 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
455 ULONG UserModeGlobalLogging;
456 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
457
458 /*
459 ** IRP function codes
460 */
461
462 #define IRP_MJ_CREATE 0x00
463 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
464 #define IRP_MJ_CLOSE 0x02
465 #define IRP_MJ_READ 0x03
466 #define IRP_MJ_WRITE 0x04
467 #define IRP_MJ_QUERY_INFORMATION 0x05
468 #define IRP_MJ_SET_INFORMATION 0x06
469 #define IRP_MJ_QUERY_EA 0x07
470 #define IRP_MJ_SET_EA 0x08
471 #define IRP_MJ_FLUSH_BUFFERS 0x09
472 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
473 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
474 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
475 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
476 #define IRP_MJ_DEVICE_CONTROL 0x0e
477 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
478 #define IRP_MJ_SCSI 0x0f
479 #define IRP_MJ_SHUTDOWN 0x10
480 #define IRP_MJ_LOCK_CONTROL 0x11
481 #define IRP_MJ_CLEANUP 0x12
482 #define IRP_MJ_CREATE_MAILSLOT 0x13
483 #define IRP_MJ_QUERY_SECURITY 0x14
484 #define IRP_MJ_SET_SECURITY 0x15
485 #define IRP_MJ_POWER 0x16
486 #define IRP_MJ_SYSTEM_CONTROL 0x17
487 #define IRP_MJ_DEVICE_CHANGE 0x18
488 #define IRP_MJ_QUERY_QUOTA 0x19
489 #define IRP_MJ_SET_QUOTA 0x1a
490 #define IRP_MJ_PNP 0x1b
491 #define IRP_MJ_PNP_POWER 0x1b
492 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
493
494 #define IRP_MN_QUERY_DIRECTORY 0x01
495 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
496
497 #define IRP_MN_USER_FS_REQUEST 0x00
498 #define IRP_MN_MOUNT_VOLUME 0x01
499 #define IRP_MN_VERIFY_VOLUME 0x02
500 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
501 #define IRP_MN_TRACK_LINK 0x04
502 #define IRP_MN_KERNEL_CALL 0x04
503
504 #define IRP_MN_LOCK 0x01
505 #define IRP_MN_UNLOCK_SINGLE 0x02
506 #define IRP_MN_UNLOCK_ALL 0x03
507 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
508
509 #define IRP_MN_NORMAL 0x00
510 #define IRP_MN_DPC 0x01
511 #define IRP_MN_MDL 0x02
512 #define IRP_MN_COMPLETE 0x04
513 #define IRP_MN_COMPRESSED 0x08
514
515 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
516 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
517 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
518
519 #define IRP_MN_SCSI_CLASS 0x01
520
521 #define IRP_MN_START_DEVICE 0x00
522 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
523 #define IRP_MN_REMOVE_DEVICE 0x02
524 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
525 #define IRP_MN_STOP_DEVICE 0x04
526 #define IRP_MN_QUERY_STOP_DEVICE 0x05
527 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
528
529 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
530 #define IRP_MN_QUERY_INTERFACE 0x08
531 #define IRP_MN_QUERY_CAPABILITIES 0x09
532 #define IRP_MN_QUERY_RESOURCES 0x0A
533 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
534 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
535 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
536
537 #define IRP_MN_READ_CONFIG 0x0F
538 #define IRP_MN_WRITE_CONFIG 0x10
539 #define IRP_MN_EJECT 0x11
540 #define IRP_MN_SET_LOCK 0x12
541 #define IRP_MN_QUERY_ID 0x13
542 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
543 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
544 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
545 #define IRP_MN_SURPRISE_REMOVAL 0x17
546 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
547
548 #define IRP_MN_WAIT_WAKE 0x00
549 #define IRP_MN_POWER_SEQUENCE 0x01
550 #define IRP_MN_SET_POWER 0x02
551 #define IRP_MN_QUERY_POWER 0x03
552
553 #define IRP_MN_QUERY_ALL_DATA 0x00
554 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
555 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
556 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
557 #define IRP_MN_ENABLE_EVENTS 0x04
558 #define IRP_MN_DISABLE_EVENTS 0x05
559 #define IRP_MN_ENABLE_COLLECTION 0x06
560 #define IRP_MN_DISABLE_COLLECTION 0x07
561 #define IRP_MN_REGINFO 0x08
562 #define IRP_MN_EXECUTE_METHOD 0x09
563
564 #define IRP_MN_REGINFO_EX 0x0b
565
566 typedef enum _IO_ALLOCATION_ACTION {
567 KeepObject = 1,
568 DeallocateObject,
569 DeallocateObjectKeepRegisters
570 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
571
572 typedef IO_ALLOCATION_ACTION
573 (DDKAPI *PDRIVER_CONTROL)(
574 IN struct _DEVICE_OBJECT *DeviceObject,
575 IN struct _IRP *Irp,
576 IN PVOID MapRegisterBase,
577 IN PVOID Context);
578
579 typedef EXCEPTION_DISPOSITION
580 (DDKAPI *PEXCEPTION_ROUTINE)(
581 IN struct _EXCEPTION_RECORD *ExceptionRecord,
582 IN PVOID EstablisherFrame,
583 IN OUT struct _CONTEXT *ContextRecord,
584 IN OUT PVOID DispatcherContext);
585
586 typedef VOID
587 (DDKAPI *PDRIVER_LIST_CONTROL)(
588 IN struct _DEVICE_OBJECT *DeviceObject,
589 IN struct _IRP *Irp,
590 IN struct _SCATTER_GATHER_LIST *ScatterGather,
591 IN PVOID Context);
592
593 typedef NTSTATUS
594 (DDKAPI *PDRIVER_ADD_DEVICE)(
595 IN struct _DRIVER_OBJECT *DriverObject,
596 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
597
598 typedef NTSTATUS
599 (DDKAPI *PIO_COMPLETION_ROUTINE)(
600 IN struct _DEVICE_OBJECT *DeviceObject,
601 IN struct _IRP *Irp,
602 IN PVOID Context);
603
604 typedef VOID
605 (DDKAPI *PDRIVER_CANCEL)(
606 IN struct _DEVICE_OBJECT *DeviceObject,
607 IN struct _IRP *Irp);
608
609 typedef VOID
610 (DDKAPI *PKDEFERRED_ROUTINE)(
611 IN struct _KDPC *Dpc,
612 IN PVOID DeferredContext,
613 IN PVOID SystemArgument1,
614 IN PVOID SystemArgument2);
615
616 typedef NTSTATUS
617 (DDKAPI *PDRIVER_DISPATCH)(
618 IN struct _DEVICE_OBJECT *DeviceObject,
619 IN struct _IRP *Irp);
620
621 typedef VOID
622 (DDKAPI *PIO_DPC_ROUTINE)(
623 IN struct _KDPC *Dpc,
624 IN struct _DEVICE_OBJECT *DeviceObject,
625 IN struct _IRP *Irp,
626 IN PVOID Context);
627
628 typedef NTSTATUS
629 (DDKAPI *PMM_DLL_INITIALIZE)(
630 IN PUNICODE_STRING RegistryPath);
631
632 typedef NTSTATUS
633 (DDKAPI *PMM_DLL_UNLOAD)(
634 VOID);
635
636 typedef NTSTATUS
637 (DDKAPI *PDRIVER_ENTRY)(
638 IN struct _DRIVER_OBJECT *DriverObject,
639 IN PUNICODE_STRING RegistryPath);
640
641 typedef NTSTATUS
642 (DDKAPI *PDRIVER_INITIALIZE)(
643 IN struct _DRIVER_OBJECT *DriverObject,
644 IN PUNICODE_STRING RegistryPath);
645
646 typedef BOOLEAN
647 (DDKAPI *PKSERVICE_ROUTINE)(
648 IN struct _KINTERRUPT *Interrupt,
649 IN PVOID ServiceContext);
650
651 typedef VOID
652 (DDKAPI *PIO_TIMER_ROUTINE)(
653 IN struct _DEVICE_OBJECT *DeviceObject,
654 IN PVOID Context);
655
656 typedef VOID
657 (DDKAPI *PDRIVER_REINITIALIZE)(
658 IN struct _DRIVER_OBJECT *DriverObject,
659 IN PVOID Context,
660 IN ULONG Count);
661
662 typedef VOID
663 (DDKAPI *PDRIVER_STARTIO)(
664 IN struct _DEVICE_OBJECT *DeviceObject,
665 IN struct _IRP *Irp);
666
667 typedef BOOLEAN
668 (DDKAPI *PKSYNCHRONIZE_ROUTINE)(
669 IN PVOID SynchronizeContext);
670
671 typedef VOID
672 (DDKAPI *PDRIVER_UNLOAD)(
673 IN struct _DRIVER_OBJECT *DriverObject);
674
675
676
677 /*
678 ** Plug and Play structures
679 */
680
681 typedef VOID
682 (DDKAPI *PINTERFACE_REFERENCE)(
683 PVOID Context);
684
685 typedef VOID
686 (DDKAPI *PINTERFACE_DEREFERENCE)(
687 PVOID Context);
688
689 typedef BOOLEAN
690 (DDKAPI *PTRANSLATE_BUS_ADDRESS)(
691 IN PVOID Context,
692 IN PHYSICAL_ADDRESS BusAddress,
693 IN ULONG Length,
694 IN OUT PULONG AddressSpace,
695 OUT PPHYSICAL_ADDRESS TranslatedAddress);
696
697 typedef struct _DMA_ADAPTER*
698 (DDKAPI *PGET_DMA_ADAPTER)(
699 IN PVOID Context,
700 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
701 OUT PULONG NumberOfMapRegisters);
702
703 typedef ULONG
704 (DDKAPI *PGET_SET_DEVICE_DATA)(
705 IN PVOID Context,
706 IN ULONG DataType,
707 IN PVOID Buffer,
708 IN ULONG Offset,
709 IN ULONG Length);
710
711 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
712 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
713 #define PCI_USE_REVISION 0x00000002
714 #define PCI_USE_VENDEV_IDS 0x00000004
715 #define PCI_USE_CLASS_SUBCLASS 0x00000008
716 #define PCI_USE_PROGIF 0x00000010
717 #define PCI_USE_LOCAL_BUS 0x00000020
718 #define PCI_USE_LOCAL_DEVICE 0x00000040
719
720 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
721 ULONG Size;
722 ULONG Flags;
723 USHORT VendorID;
724 USHORT DeviceID;
725 UCHAR RevisionID;
726 USHORT SubVendorID;
727 USHORT SubSystemID;
728 UCHAR BaseClass;
729 UCHAR SubClass;
730 UCHAR ProgIf;
731 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
732
733 typedef BOOLEAN
734 (DDKAPI *PPCI_IS_DEVICE_PRESENT)(
735 IN USHORT VendorID,
736 IN USHORT DeviceID,
737 IN UCHAR RevisionID,
738 IN USHORT SubVendorID,
739 IN USHORT SubSystemID,
740 IN ULONG Flags);
741
742 typedef BOOLEAN
743 (DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
744 IN PVOID Context,
745 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
746
747 typedef union _POWER_STATE {
748 SYSTEM_POWER_STATE SystemState;
749 DEVICE_POWER_STATE DeviceState;
750 } POWER_STATE, *PPOWER_STATE;
751
752 typedef enum _POWER_STATE_TYPE {
753 SystemPowerState,
754 DevicePowerState
755 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
756
757 typedef struct _BUS_INTERFACE_STANDARD {
758 USHORT Size;
759 USHORT Version;
760 PVOID Context;
761 PINTERFACE_REFERENCE InterfaceReference;
762 PINTERFACE_DEREFERENCE InterfaceDereference;
763 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
764 PGET_DMA_ADAPTER GetDmaAdapter;
765 PGET_SET_DEVICE_DATA SetBusData;
766 PGET_SET_DEVICE_DATA GetBusData;
767 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
768
769 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
770 USHORT Size;
771 USHORT Version;
772 PVOID Context;
773 PINTERFACE_REFERENCE InterfaceReference;
774 PINTERFACE_DEREFERENCE InterfaceDereference;
775 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
776 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
777 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
778
779 typedef struct _DEVICE_CAPABILITIES {
780 USHORT Size;
781 USHORT Version;
782 ULONG DeviceD1 : 1;
783 ULONG DeviceD2 : 1;
784 ULONG LockSupported : 1;
785 ULONG EjectSupported : 1;
786 ULONG Removable : 1;
787 ULONG DockDevice : 1;
788 ULONG UniqueID : 1;
789 ULONG SilentInstall : 1;
790 ULONG RawDeviceOK : 1;
791 ULONG SurpriseRemovalOK : 1;
792 ULONG WakeFromD0 : 1;
793 ULONG WakeFromD1 : 1;
794 ULONG WakeFromD2 : 1;
795 ULONG WakeFromD3 : 1;
796 ULONG HardwareDisabled : 1;
797 ULONG NonDynamic : 1;
798 ULONG WarmEjectSupported : 1;
799 ULONG NoDisplayInUI : 1;
800 ULONG Reserved : 14;
801 ULONG Address;
802 ULONG UINumber;
803 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
804 SYSTEM_POWER_STATE SystemWake;
805 DEVICE_POWER_STATE DeviceWake;
806 ULONG D1Latency;
807 ULONG D2Latency;
808 ULONG D3Latency;
809 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
810
811 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
812 USHORT Version;
813 USHORT Size;
814 GUID Event;
815 GUID InterfaceClassGuid;
816 PUNICODE_STRING SymbolicLinkName;
817 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
818
819 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
820 USHORT Version;
821 USHORT Size;
822 GUID Event;
823 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
824
825 #undef INTERFACE
826
827 typedef struct _INTERFACE {
828 USHORT Size;
829 USHORT Version;
830 PVOID Context;
831 PINTERFACE_REFERENCE InterfaceReference;
832 PINTERFACE_DEREFERENCE InterfaceDereference;
833 } INTERFACE, *PINTERFACE;
834
835 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
836 USHORT Version;
837 USHORT Size;
838 GUID Event;
839 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
840
841 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
842
843 /* PNP_DEVICE_STATE */
844
845 #define PNP_DEVICE_DISABLED 0x00000001
846 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
847 #define PNP_DEVICE_FAILED 0x00000004
848 #define PNP_DEVICE_REMOVED 0x00000008
849 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
850 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
851
852 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
853 USHORT Version;
854 USHORT Size;
855 GUID Event;
856 struct _FILE_OBJECT *FileObject;
857 LONG NameBufferOffset;
858 UCHAR CustomDataBuffer[1];
859 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
860
861 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
862 USHORT Version;
863 USHORT Size;
864 GUID Event;
865 struct _FILE_OBJECT *FileObject;
866 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
867
868 typedef enum _BUS_QUERY_ID_TYPE {
869 BusQueryDeviceID,
870 BusQueryHardwareIDs,
871 BusQueryCompatibleIDs,
872 BusQueryInstanceID,
873 BusQueryDeviceSerialNumber
874 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
875
876 typedef enum _DEVICE_TEXT_TYPE {
877 DeviceTextDescription,
878 DeviceTextLocationInformation
879 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
880
881 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
882 DeviceUsageTypeUndefined,
883 DeviceUsageTypePaging,
884 DeviceUsageTypeHibernation,
885 DeviceUsageTypeDumpFile
886 } DEVICE_USAGE_NOTIFICATION_TYPE;
887
888 typedef struct _POWER_SEQUENCE {
889 ULONG SequenceD1;
890 ULONG SequenceD2;
891 ULONG SequenceD3;
892 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
893
894 typedef enum {
895 DevicePropertyDeviceDescription,
896 DevicePropertyHardwareID,
897 DevicePropertyCompatibleIDs,
898 DevicePropertyBootConfiguration,
899 DevicePropertyBootConfigurationTranslated,
900 DevicePropertyClassName,
901 DevicePropertyClassGuid,
902 DevicePropertyDriverKeyName,
903 DevicePropertyManufacturer,
904 DevicePropertyFriendlyName,
905 DevicePropertyLocationInformation,
906 DevicePropertyPhysicalDeviceObjectName,
907 DevicePropertyBusTypeGuid,
908 DevicePropertyLegacyBusType,
909 DevicePropertyBusNumber,
910 DevicePropertyEnumeratorName,
911 DevicePropertyAddress,
912 DevicePropertyUINumber,
913 DevicePropertyInstallState,
914 DevicePropertyRemovalPolicy
915 } DEVICE_REGISTRY_PROPERTY;
916
917 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
918 EventCategoryReserved,
919 EventCategoryHardwareProfileChange,
920 EventCategoryDeviceInterfaceChange,
921 EventCategoryTargetDeviceChange
922 } IO_NOTIFICATION_EVENT_CATEGORY;
923
924 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
925
926 typedef NTSTATUS
927 (DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
928 IN PVOID NotificationStructure,
929 IN PVOID Context);
930
931 typedef VOID
932 (DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
933 IN PVOID Context);
934
935
936 /*
937 ** System structures
938 */
939
940 #define SYMBOLIC_LINK_QUERY 0x0001
941 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
942
943 /* also in winnt,h */
944 #define DUPLICATE_CLOSE_SOURCE 0x00000001
945 #define DUPLICATE_SAME_ACCESS 0x00000002
946 #define DUPLICATE_SAME_ATTRIBUTES 0x00000004
947 /* end winnt.h */
948
949 typedef struct _OBJECT_NAME_INFORMATION {
950 UNICODE_STRING Name;
951 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
952
953 typedef VOID
954 (DDKAPI *PIO_APC_ROUTINE)(
955 IN PVOID ApcContext,
956 IN PIO_STATUS_BLOCK IoStatusBlock,
957 IN ULONG Reserved);
958
959 typedef struct _IO_STATUS_BLOCK {
960 _ANONYMOUS_UNION union {
961 NTSTATUS Status;
962 PVOID Pointer;
963 } DUMMYUNIONNAME;
964 ULONG_PTR Information;
965 } IO_STATUS_BLOCK;
966
967 typedef VOID
968 (DDKAPI *PKNORMAL_ROUTINE)(
969 IN PVOID NormalContext,
970 IN PVOID SystemArgument1,
971 IN PVOID SystemArgument2);
972
973 typedef VOID
974 (DDKAPI *PKKERNEL_ROUTINE)(
975 IN struct _KAPC *Apc,
976 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
977 IN OUT PVOID *NormalContext,
978 IN OUT PVOID *SystemArgument1,
979 IN OUT PVOID *SystemArgument2);
980
981 typedef VOID
982 (DDKAPI *PKRUNDOWN_ROUTINE)(
983 IN struct _KAPC *Apc);
984
985 typedef BOOLEAN
986 (DDKAPI *PKTRANSFER_ROUTINE)(
987 VOID);
988
989 typedef struct _KAPC
990 {
991 UCHAR Type;
992 UCHAR SpareByte0;
993 UCHAR Size;
994 UCHAR SpareByte1;
995 ULONG SpareLong0;
996 struct _KTHREAD *Thread;
997 LIST_ENTRY ApcListEntry;
998 PKKERNEL_ROUTINE KernelRoutine;
999 PKRUNDOWN_ROUTINE RundownRoutine;
1000 PKNORMAL_ROUTINE NormalRoutine;
1001 PVOID NormalContext;
1002 PVOID SystemArgument1;
1003 PVOID SystemArgument2;
1004 CCHAR ApcStateIndex;
1005 KPROCESSOR_MODE ApcMode;
1006 BOOLEAN Inserted;
1007 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
1008
1009 typedef struct _KDEVICE_QUEUE {
1010 CSHORT Type;
1011 CSHORT Size;
1012 LIST_ENTRY DeviceListHead;
1013 KSPIN_LOCK Lock;
1014 BOOLEAN Busy;
1015 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
1016
1017 typedef struct _KDEVICE_QUEUE_ENTRY {
1018 LIST_ENTRY DeviceListEntry;
1019 ULONG SortKey;
1020 BOOLEAN Inserted;
1021 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
1022 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
1023
1024 #define LOCK_QUEUE_WAIT 1
1025 #define LOCK_QUEUE_OWNER 2
1026
1027 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
1028 LockQueueDispatcherLock,
1029 LockQueueContextSwapLock,
1030 LockQueuePfnLock,
1031 LockQueueSystemSpaceLock,
1032 LockQueueVacbLock,
1033 LockQueueMasterLock,
1034 LockQueueNonPagedPoolLock,
1035 LockQueueIoCancelLock,
1036 LockQueueWorkQueueLock,
1037 LockQueueIoVpbLock,
1038 LockQueueIoDatabaseLock,
1039 LockQueueIoCompletionLock,
1040 LockQueueNtfsStructLock,
1041 LockQueueAfdWorkQueueLock,
1042 LockQueueBcbLock,
1043 LockQueueMaximumLock
1044 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
1045
1046 typedef struct _KSPIN_LOCK_QUEUE {
1047 struct _KSPIN_LOCK_QUEUE *VOLATILE Next;
1048 PKSPIN_LOCK VOLATILE Lock;
1049 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1050
1051 typedef struct _KLOCK_QUEUE_HANDLE {
1052 KSPIN_LOCK_QUEUE LockQueue;
1053 KIRQL OldIrql;
1054 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1055
1056 typedef struct _KDPC {
1057 CSHORT Type;
1058 UCHAR Number;
1059 UCHAR Importance;
1060 LIST_ENTRY DpcListEntry;
1061 PKDEFERRED_ROUTINE DeferredRoutine;
1062 PVOID DeferredContext;
1063 PVOID SystemArgument1;
1064 PVOID SystemArgument2;
1065 PVOID DpcData;
1066 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
1067
1068 typedef struct _WAIT_CONTEXT_BLOCK {
1069 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
1070 PDRIVER_CONTROL DeviceRoutine;
1071 PVOID DeviceContext;
1072 ULONG NumberOfMapRegisters;
1073 PVOID DeviceObject;
1074 PVOID CurrentIrp;
1075 PKDPC BufferChainingDpc;
1076 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
1077
1078 typedef struct _DISPATCHER_HEADER
1079 {
1080 union
1081 {
1082 struct
1083 {
1084 UCHAR Type;
1085 union
1086 {
1087 UCHAR Absolute;
1088 UCHAR NpxIrql;
1089 };
1090 union
1091 {
1092 UCHAR Size;
1093 UCHAR Hand;
1094 };
1095 union
1096 {
1097 UCHAR Inserted;
1098 BOOLEAN DebugActive;
1099 };
1100 };
1101 volatile LONG Lock;
1102 };
1103 LONG SignalState;
1104 LIST_ENTRY WaitListHead;
1105 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
1106
1107 typedef struct _KEVENT {
1108 DISPATCHER_HEADER Header;
1109 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
1110
1111 typedef struct _KSEMAPHORE {
1112 DISPATCHER_HEADER Header;
1113 LONG Limit;
1114 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
1115
1116 typedef struct _FAST_MUTEX
1117 {
1118 LONG Count;
1119 PKTHREAD Owner;
1120 ULONG Contention;
1121 KEVENT Gate;
1122 ULONG OldIrql;
1123 } FAST_MUTEX, *PFAST_MUTEX;
1124
1125 typedef struct _EX_RUNDOWN_REF
1126 {
1127 union
1128 {
1129 ULONG_PTR Count;
1130 PVOID Ptr;
1131 };
1132 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
1133
1134 typedef struct _KGATE
1135 {
1136 DISPATCHER_HEADER Header;
1137 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1138
1139 typedef struct _KGUARDED_MUTEX
1140 {
1141 LONG Count;
1142 struct _KTHREAD* Owner;
1143 ULONG Contention;
1144 KGATE Gate;
1145 union {
1146 struct {
1147 SHORT KernelApcDisable;
1148 SHORT SpecialApcDisable;
1149 };
1150 ULONG CombinedApcDisable;
1151 };
1152 } KGUARDED_MUTEX, *PKGUARDED_MUTEX, *RESTRICTED_POINTER PRKGUARDED_MUTEX;
1153
1154 typedef struct _KTIMER {
1155 DISPATCHER_HEADER Header;
1156 ULARGE_INTEGER DueTime;
1157 LIST_ENTRY TimerListEntry;
1158 struct _KDPC *Dpc;
1159 LONG Period;
1160 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1161
1162 typedef struct _KMUTANT {
1163 DISPATCHER_HEADER Header;
1164 LIST_ENTRY MutantListEntry;
1165 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1166 BOOLEAN Abandoned;
1167 UCHAR ApcDisable;
1168 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1169
1170 typedef enum _TIMER_TYPE {
1171 NotificationTimer,
1172 SynchronizationTimer
1173 } TIMER_TYPE;
1174
1175 #define EVENT_INCREMENT 1
1176 #define IO_NO_INCREMENT 0
1177 #define IO_CD_ROM_INCREMENT 1
1178 #define IO_DISK_INCREMENT 1
1179 #define IO_KEYBOARD_INCREMENT 6
1180 #define IO_MAILSLOT_INCREMENT 2
1181 #define IO_MOUSE_INCREMENT 6
1182 #define IO_NAMED_PIPE_INCREMENT 2
1183 #define IO_NETWORK_INCREMENT 2
1184 #define IO_PARALLEL_INCREMENT 1
1185 #define IO_SERIAL_INCREMENT 2
1186 #define IO_SOUND_INCREMENT 8
1187 #define IO_VIDEO_INCREMENT 1
1188 #define SEMAPHORE_INCREMENT 1
1189
1190 typedef struct _IRP {
1191 CSHORT Type;
1192 USHORT Size;
1193 struct _MDL *MdlAddress;
1194 ULONG Flags;
1195 union {
1196 struct _IRP *MasterIrp;
1197 LONG IrpCount;
1198 PVOID SystemBuffer;
1199 } AssociatedIrp;
1200 LIST_ENTRY ThreadListEntry;
1201 IO_STATUS_BLOCK IoStatus;
1202 KPROCESSOR_MODE RequestorMode;
1203 BOOLEAN PendingReturned;
1204 CHAR StackCount;
1205 CHAR CurrentLocation;
1206 BOOLEAN Cancel;
1207 KIRQL CancelIrql;
1208 CCHAR ApcEnvironment;
1209 UCHAR AllocationFlags;
1210 PIO_STATUS_BLOCK UserIosb;
1211 PKEVENT UserEvent;
1212 union {
1213 struct {
1214 PIO_APC_ROUTINE UserApcRoutine;
1215 PVOID UserApcContext;
1216 } AsynchronousParameters;
1217 LARGE_INTEGER AllocationSize;
1218 } Overlay;
1219 PDRIVER_CANCEL CancelRoutine;
1220 PVOID UserBuffer;
1221 union {
1222 struct {
1223 _ANONYMOUS_UNION union {
1224 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
1225 _ANONYMOUS_STRUCT struct {
1226 PVOID DriverContext[4];
1227 } DUMMYSTRUCTNAME;
1228 } DUMMYUNIONNAME;
1229 PETHREAD Thread;
1230 PCHAR AuxiliaryBuffer;
1231 _ANONYMOUS_STRUCT struct {
1232 LIST_ENTRY ListEntry;
1233 _ANONYMOUS_UNION union {
1234 struct _IO_STACK_LOCATION *CurrentStackLocation;
1235 ULONG PacketType;
1236 } DUMMYUNIONNAME;
1237 } DUMMYSTRUCTNAME;
1238 struct _FILE_OBJECT *OriginalFileObject;
1239 } Overlay;
1240 KAPC Apc;
1241 PVOID CompletionKey;
1242 } Tail;
1243 } IRP;
1244 typedef struct _IRP *PIRP;
1245
1246 /* IRP.Flags */
1247
1248 #define SL_FORCE_ACCESS_CHECK 0x01
1249 #define SL_OPEN_PAGING_FILE 0x02
1250 #define SL_OPEN_TARGET_DIRECTORY 0x04
1251 #define SL_CASE_SENSITIVE 0x80
1252
1253 #define SL_KEY_SPECIFIED 0x01
1254 #define SL_OVERRIDE_VERIFY_VOLUME 0x02
1255 #define SL_WRITE_THROUGH 0x04
1256 #define SL_FT_SEQUENTIAL_WRITE 0x08
1257
1258 #define SL_FAIL_IMMEDIATELY 0x01
1259 #define SL_EXCLUSIVE_LOCK 0x02
1260
1261 #define SL_RESTART_SCAN 0x01
1262 #define SL_RETURN_SINGLE_ENTRY 0x02
1263 #define SL_INDEX_SPECIFIED 0x04
1264
1265 #define SL_WATCH_TREE 0x01
1266
1267 #define SL_ALLOW_RAW_MOUNT 0x01
1268
1269 #define CTL_CODE(DeviceType, Function, Method, Access)( \
1270 ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1271
1272 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
1273
1274 enum
1275 {
1276 IRP_NOCACHE = 0x1,
1277 IRP_PAGING_IO = 0x2,
1278 IRP_MOUNT_COMPLETION = 0x2,
1279 IRP_SYNCHRONOUS_API = 0x4,
1280 IRP_ASSOCIATED_IRP = 0x8,
1281 IRP_BUFFERED_IO = 0x10,
1282 IRP_DEALLOCATE_BUFFER = 0x20,
1283 IRP_INPUT_OPERATION = 0x40,
1284 IRP_SYNCHRONOUS_PAGING_IO = 0x40,
1285 IRP_CREATE_OPERATION = 0x80,
1286 IRP_READ_OPERATION = 0x100,
1287 IRP_WRITE_OPERATION = 0x200,
1288 IRP_CLOSE_OPERATION = 0x400,
1289 IRP_DEFER_IO_COMPLETION = 0x800,
1290 IRP_OB_QUERY_NAME = 0x1000,
1291 IRP_HOLD_DEVICE_QUEUE = 0x2000,
1292 IRP_RETRY_IO_COMPLETION = 0x4000
1293 };
1294
1295 #define IRP_QUOTA_CHARGED 0x01
1296 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
1297 #define IRP_ALLOCATED_FIXED_SIZE 0x04
1298 #define IRP_LOOKASIDE_ALLOCATION 0x08
1299
1300 typedef struct _BOOTDISK_INFORMATION {
1301 LONGLONG BootPartitionOffset;
1302 LONGLONG SystemPartitionOffset;
1303 ULONG BootDeviceSignature;
1304 ULONG SystemDeviceSignature;
1305 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
1306
1307 typedef struct _BOOTDISK_INFORMATION_EX {
1308 LONGLONG BootPartitionOffset;
1309 LONGLONG SystemPartitionOffset;
1310 ULONG BootDeviceSignature;
1311 ULONG SystemDeviceSignature;
1312 GUID BootDeviceGuid;
1313 GUID SystemDeviceGuid;
1314 BOOLEAN BootDeviceIsGpt;
1315 BOOLEAN SystemDeviceIsGpt;
1316 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
1317
1318 typedef struct _EISA_MEMORY_TYPE {
1319 UCHAR ReadWrite : 1;
1320 UCHAR Cached : 1;
1321 UCHAR Reserved0 : 1;
1322 UCHAR Type : 2;
1323 UCHAR Shared : 1;
1324 UCHAR Reserved1 : 1;
1325 UCHAR MoreEntries : 1;
1326 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
1327
1328 #include <pshpack1.h>
1329 typedef struct _EISA_MEMORY_CONFIGURATION {
1330 EISA_MEMORY_TYPE ConfigurationByte;
1331 UCHAR DataSize;
1332 USHORT AddressLowWord;
1333 UCHAR AddressHighByte;
1334 USHORT MemorySize;
1335 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
1336 #include <poppack.h>
1337
1338 typedef struct _EISA_IRQ_DESCRIPTOR {
1339 UCHAR Interrupt : 4;
1340 UCHAR Reserved : 1;
1341 UCHAR LevelTriggered : 1;
1342 UCHAR Shared : 1;
1343 UCHAR MoreEntries : 1;
1344 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
1345
1346 typedef struct _EISA_IRQ_CONFIGURATION {
1347 EISA_IRQ_DESCRIPTOR ConfigurationByte;
1348 UCHAR Reserved;
1349 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
1350
1351 typedef struct _DMA_CONFIGURATION_BYTE0 {
1352 UCHAR Channel : 3;
1353 UCHAR Reserved : 3;
1354 UCHAR Shared : 1;
1355 UCHAR MoreEntries : 1;
1356 } DMA_CONFIGURATION_BYTE0;
1357
1358 typedef struct _DMA_CONFIGURATION_BYTE1 {
1359 UCHAR Reserved0 : 2;
1360 UCHAR TransferSize : 2;
1361 UCHAR Timing : 2;
1362 UCHAR Reserved1 : 2;
1363 } DMA_CONFIGURATION_BYTE1;
1364
1365 typedef struct _EISA_DMA_CONFIGURATION {
1366 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
1367 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
1368 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
1369
1370 #include <pshpack1.h>
1371 typedef struct _EISA_PORT_DESCRIPTOR {
1372 UCHAR NumberPorts : 5;
1373 UCHAR Reserved : 1;
1374 UCHAR Shared : 1;
1375 UCHAR MoreEntries : 1;
1376 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
1377
1378 typedef struct _EISA_PORT_CONFIGURATION {
1379 EISA_PORT_DESCRIPTOR Configuration;
1380 USHORT PortAddress;
1381 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
1382 #include <poppack.h>
1383
1384 typedef struct _CM_EISA_FUNCTION_INFORMATION {
1385 ULONG CompressedId;
1386 UCHAR IdSlotFlags1;
1387 UCHAR IdSlotFlags2;
1388 UCHAR MinorRevision;
1389 UCHAR MajorRevision;
1390 UCHAR Selections[26];
1391 UCHAR FunctionFlags;
1392 UCHAR TypeString[80];
1393 EISA_MEMORY_CONFIGURATION EisaMemory[9];
1394 EISA_IRQ_CONFIGURATION EisaIrq[7];
1395 EISA_DMA_CONFIGURATION EisaDma[4];
1396 EISA_PORT_CONFIGURATION EisaPort[20];
1397 UCHAR InitializationData[60];
1398 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
1399
1400 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
1401
1402 #define EISA_FUNCTION_ENABLED 0x80
1403 #define EISA_FREE_FORM_DATA 0x40
1404 #define EISA_HAS_PORT_INIT_ENTRY 0x20
1405 #define EISA_HAS_PORT_RANGE 0x10
1406 #define EISA_HAS_DMA_ENTRY 0x08
1407 #define EISA_HAS_IRQ_ENTRY 0x04
1408 #define EISA_HAS_MEMORY_ENTRY 0x02
1409 #define EISA_HAS_TYPE_ENTRY 0x01
1410 #define EISA_HAS_INFORMATION \
1411 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
1412 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
1413
1414 typedef struct _CM_EISA_SLOT_INFORMATION {
1415 UCHAR ReturnCode;
1416 UCHAR ReturnFlags;
1417 UCHAR MajorRevision;
1418 UCHAR MinorRevision;
1419 USHORT Checksum;
1420 UCHAR NumberFunctions;
1421 UCHAR FunctionInformation;
1422 ULONG CompressedId;
1423 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
1424
1425 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
1426
1427 #define EISA_INVALID_SLOT 0x80
1428 #define EISA_INVALID_FUNCTION 0x81
1429 #define EISA_INVALID_CONFIGURATION 0x82
1430 #define EISA_EMPTY_SLOT 0x83
1431 #define EISA_INVALID_BIOS_CALL 0x86
1432
1433 typedef struct _CM_FLOPPY_DEVICE_DATA {
1434 USHORT Version;
1435 USHORT Revision;
1436 CHAR Size[8];
1437 ULONG MaxDensity;
1438 ULONG MountDensity;
1439 UCHAR StepRateHeadUnloadTime;
1440 UCHAR HeadLoadTime;
1441 UCHAR MotorOffTime;
1442 UCHAR SectorLengthCode;
1443 UCHAR SectorPerTrack;
1444 UCHAR ReadWriteGapLength;
1445 UCHAR DataTransferLength;
1446 UCHAR FormatGapLength;
1447 UCHAR FormatFillCharacter;
1448 UCHAR HeadSettleTime;
1449 UCHAR MotorSettleTime;
1450 UCHAR MaximumTrackValue;
1451 UCHAR DataTransferRate;
1452 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
1453
1454 typedef enum _INTERFACE_TYPE {
1455 InterfaceTypeUndefined = -1,
1456 Internal,
1457 Isa,
1458 Eisa,
1459 MicroChannel,
1460 TurboChannel,
1461 PCIBus,
1462 VMEBus,
1463 NuBus,
1464 PCMCIABus,
1465 CBus,
1466 MPIBus,
1467 MPSABus,
1468 ProcessorInternal,
1469 InternalPowerBus,
1470 PNPISABus,
1471 PNPBus,
1472 MaximumInterfaceType
1473 } INTERFACE_TYPE, *PINTERFACE_TYPE;
1474
1475 typedef struct _PNP_BUS_INFORMATION {
1476 GUID BusTypeGuid;
1477 INTERFACE_TYPE LegacyBusType;
1478 ULONG BusNumber;
1479 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
1480
1481 #include <pshpack1.h>
1482 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
1483 UCHAR Type;
1484 UCHAR ShareDisposition;
1485 USHORT Flags;
1486 union {
1487 struct {
1488 PHYSICAL_ADDRESS Start;
1489 ULONG Length;
1490 } Generic;
1491 struct {
1492 PHYSICAL_ADDRESS Start;
1493 ULONG Length;
1494 } Port;
1495 struct {
1496 ULONG Level;
1497 ULONG Vector;
1498 ULONG Affinity;
1499 } Interrupt;
1500 struct {
1501 PHYSICAL_ADDRESS Start;
1502 ULONG Length;
1503 } Memory;
1504 struct {
1505 ULONG Channel;
1506 ULONG Port;
1507 ULONG Reserved1;
1508 } Dma;
1509 struct {
1510 ULONG Data[3];
1511 } DevicePrivate;
1512 struct {
1513 ULONG Start;
1514 ULONG Length;
1515 ULONG Reserved;
1516 } BusNumber;
1517 struct {
1518 ULONG DataSize;
1519 ULONG Reserved1;
1520 ULONG Reserved2;
1521 } DeviceSpecificData;
1522 } u;
1523 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
1524
1525 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
1526
1527 #define CmResourceTypeNull 0
1528 #define CmResourceTypePort 1
1529 #define CmResourceTypeInterrupt 2
1530 #define CmResourceTypeMemory 3
1531 #define CmResourceTypeDma 4
1532 #define CmResourceTypeDeviceSpecific 5
1533 #define CmResourceTypeBusNumber 6
1534 #define CmResourceTypeMaximum 7
1535 #define CmResourceTypeNonArbitrated 128
1536 #define CmResourceTypeConfigData 128
1537 #define CmResourceTypeDevicePrivate 129
1538 #define CmResourceTypePcCardConfig 130
1539 #define CmResourceTypeMfCardConfig 131
1540
1541 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
1542
1543 typedef enum _CM_SHARE_DISPOSITION {
1544 CmResourceShareUndetermined,
1545 CmResourceShareDeviceExclusive,
1546 CmResourceShareDriverExclusive,
1547 CmResourceShareShared
1548 } CM_SHARE_DISPOSITION;
1549
1550 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
1551
1552 #define CM_RESOURCE_PORT_MEMORY 0x0000
1553 #define CM_RESOURCE_PORT_IO 0x0001
1554 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
1555 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
1556 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
1557 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
1558 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
1559 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
1560
1561 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
1562
1563 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
1564 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
1565
1566 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
1567
1568 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
1569 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
1570 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
1571 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
1572 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
1573 #define CM_RESOURCE_MEMORY_24 0x0010
1574 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
1575
1576 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
1577
1578 #define CM_RESOURCE_DMA_8 0x0000
1579 #define CM_RESOURCE_DMA_16 0x0001
1580 #define CM_RESOURCE_DMA_32 0x0002
1581 #define CM_RESOURCE_DMA_8_AND_16 0x0004
1582 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
1583 #define CM_RESOURCE_DMA_TYPE_A 0x0010
1584 #define CM_RESOURCE_DMA_TYPE_B 0x0020
1585 #define CM_RESOURCE_DMA_TYPE_F 0x0040
1586
1587 typedef struct _CM_PARTIAL_RESOURCE_LIST {
1588 USHORT Version;
1589 USHORT Revision;
1590 ULONG Count;
1591 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
1592 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
1593
1594 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
1595 INTERFACE_TYPE InterfaceType;
1596 ULONG BusNumber;
1597 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
1598 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
1599
1600 typedef struct _CM_RESOURCE_LIST {
1601 ULONG Count;
1602 CM_FULL_RESOURCE_DESCRIPTOR List[1];
1603 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
1604
1605 typedef struct _CM_INT13_DRIVE_PARAMETER {
1606 USHORT DriveSelect;
1607 ULONG MaxCylinders;
1608 USHORT SectorsPerTrack;
1609 USHORT MaxHeads;
1610 USHORT NumberDrives;
1611 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
1612 #include <poppack.h>
1613
1614 typedef struct _CM_KEYBOARD_DEVICE_DATA {
1615 USHORT Version;
1616 USHORT Revision;
1617 UCHAR Type;
1618 UCHAR Subtype;
1619 USHORT KeyboardFlags;
1620 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
1621
1622 #define KEYBOARD_INSERT_ON 0x08
1623 #define KEYBOARD_CAPS_LOCK_ON 0x04
1624 #define KEYBOARD_NUM_LOCK_ON 0x02
1625 #define KEYBOARD_SCROLL_LOCK_ON 0x01
1626 #define KEYBOARD_ALT_KEY_DOWN 0x80
1627 #define KEYBOARD_CTRL_KEY_DOWN 0x40
1628 #define KEYBOARD_LEFT_SHIFT_DOWN 0x20
1629 #define KEYBOARD_RIGHT_SHIFT_DOWN 0x10
1630
1631 typedef struct _CM_MCA_POS_DATA {
1632 USHORT AdapterId;
1633 UCHAR PosData1;
1634 UCHAR PosData2;
1635 UCHAR PosData3;
1636 UCHAR PosData4;
1637 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
1638
1639 typedef struct CM_Power_Data_s {
1640 ULONG PD_Size;
1641 DEVICE_POWER_STATE PD_MostRecentPowerState;
1642 ULONG PD_Capabilities;
1643 ULONG PD_D1Latency;
1644 ULONG PD_D2Latency;
1645 ULONG PD_D3Latency;
1646 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
1647 } CM_POWER_DATA, *PCM_POWER_DATA;
1648
1649 #define PDCAP_D0_SUPPORTED 0x00000001
1650 #define PDCAP_D1_SUPPORTED 0x00000002
1651 #define PDCAP_D2_SUPPORTED 0x00000004
1652 #define PDCAP_D3_SUPPORTED 0x00000008
1653 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
1654 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
1655 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
1656 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
1657 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
1658
1659 typedef struct _CM_SCSI_DEVICE_DATA {
1660 USHORT Version;
1661 USHORT Revision;
1662 UCHAR HostIdentifier;
1663 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
1664
1665 typedef struct _CM_SERIAL_DEVICE_DATA {
1666 USHORT Version;
1667 USHORT Revision;
1668 ULONG BaudClock;
1669 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
1670
1671 typedef struct _VM_COUNTERS
1672 {
1673 SIZE_T PeakVirtualSize;
1674 SIZE_T VirtualSize;
1675 ULONG PageFaultCount;
1676 SIZE_T PeakWorkingSetSize;
1677 SIZE_T WorkingSetSize;
1678 SIZE_T QuotaPeakPagedPoolUsage;
1679 SIZE_T QuotaPagedPoolUsage;
1680 SIZE_T QuotaPeakNonPagedPoolUsage;
1681 SIZE_T QuotaNonPagedPoolUsage;
1682 SIZE_T PagefileUsage;
1683 SIZE_T PeakPagefileUsage;
1684 } VM_COUNTERS, *PVM_COUNTERS;
1685
1686 typedef struct _VM_COUNTERS_EX
1687 {
1688 SIZE_T PeakVirtualSize;
1689 SIZE_T VirtualSize;
1690 ULONG PageFaultCount;
1691 SIZE_T PeakWorkingSetSize;
1692 SIZE_T WorkingSetSize;
1693 SIZE_T QuotaPeakPagedPoolUsage;
1694 SIZE_T QuotaPagedPoolUsage;
1695 SIZE_T QuotaPeakNonPagedPoolUsage;
1696 SIZE_T QuotaNonPagedPoolUsage;
1697 SIZE_T PagefileUsage;
1698 SIZE_T PeakPagefileUsage;
1699 SIZE_T PrivateUsage;
1700 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
1701
1702 typedef struct _POOLED_USAGE_AND_LIMITS
1703 {
1704 SIZE_T PeakPagedPoolUsage;
1705 SIZE_T PagedPoolUsage;
1706 SIZE_T PagedPoolLimit;
1707 SIZE_T PeakNonPagedPoolUsage;
1708 SIZE_T NonPagedPoolUsage;
1709 SIZE_T NonPagedPoolLimit;
1710 SIZE_T PeakPagefileUsage;
1711 SIZE_T PagefileUsage;
1712 SIZE_T PagefileLimit;
1713 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
1714
1715 /* IO_RESOURCE_DESCRIPTOR.Option */
1716
1717 #define IO_RESOURCE_PREFERRED 0x01
1718 #define IO_RESOURCE_DEFAULT 0x02
1719 #define IO_RESOURCE_ALTERNATIVE 0x08
1720
1721 typedef struct _IO_RESOURCE_DESCRIPTOR {
1722 UCHAR Option;
1723 UCHAR Type;
1724 UCHAR ShareDisposition;
1725 UCHAR Spare1;
1726 USHORT Flags;
1727 USHORT Spare2;
1728 union {
1729 struct {
1730 ULONG Length;
1731 ULONG Alignment;
1732 PHYSICAL_ADDRESS MinimumAddress;
1733 PHYSICAL_ADDRESS MaximumAddress;
1734 } Port;
1735 struct {
1736 ULONG Length;
1737 ULONG Alignment;
1738 PHYSICAL_ADDRESS MinimumAddress;
1739 PHYSICAL_ADDRESS MaximumAddress;
1740 } Memory;
1741 struct {
1742 ULONG MinimumVector;
1743 ULONG MaximumVector;
1744 } Interrupt;
1745 struct {
1746 ULONG MinimumChannel;
1747 ULONG MaximumChannel;
1748 } Dma;
1749 struct {
1750 ULONG Length;
1751 ULONG Alignment;
1752 PHYSICAL_ADDRESS MinimumAddress;
1753 PHYSICAL_ADDRESS MaximumAddress;
1754 } Generic;
1755 struct {
1756 ULONG Data[3];
1757 } DevicePrivate;
1758 struct {
1759 ULONG Length;
1760 ULONG MinBusNumber;
1761 ULONG MaxBusNumber;
1762 ULONG Reserved;
1763 } BusNumber;
1764 struct {
1765 ULONG Priority;
1766 ULONG Reserved1;
1767 ULONG Reserved2;
1768 } ConfigData;
1769 } u;
1770 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
1771
1772 typedef struct _IO_RESOURCE_LIST {
1773 USHORT Version;
1774 USHORT Revision;
1775 ULONG Count;
1776 IO_RESOURCE_DESCRIPTOR Descriptors[1];
1777 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
1778
1779 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
1780 ULONG ListSize;
1781 INTERFACE_TYPE InterfaceType;
1782 ULONG BusNumber;
1783 ULONG SlotNumber;
1784 ULONG Reserved[3];
1785 ULONG AlternativeLists;
1786 IO_RESOURCE_LIST List[1];
1787 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
1788
1789 typedef struct _IO_ERROR_LOG_PACKET {
1790 UCHAR MajorFunctionCode;
1791 UCHAR RetryCount;
1792 USHORT DumpDataSize;
1793 USHORT NumberOfStrings;
1794 USHORT StringOffset;
1795 USHORT EventCategory;
1796 NTSTATUS ErrorCode;
1797 ULONG UniqueErrorValue;
1798 NTSTATUS FinalStatus;
1799 ULONG SequenceNumber;
1800 ULONG IoControlCode;
1801 LARGE_INTEGER DeviceOffset;
1802 ULONG DumpData[1];
1803 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
1804
1805 typedef struct _IO_ERROR_LOG_MESSAGE {
1806 USHORT Type;
1807 USHORT Size;
1808 USHORT DriverNameLength;
1809 LARGE_INTEGER TimeStamp;
1810 ULONG DriverNameOffset;
1811 IO_ERROR_LOG_PACKET EntryData;
1812 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
1813
1814 #define ERROR_LOG_LIMIT_SIZE 240
1815 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
1816 sizeof(IO_ERROR_LOG_PACKET) + \
1817 (sizeof(WCHAR) * 40))
1818
1819 typedef struct _CONTROLLER_OBJECT {
1820 CSHORT Type;
1821 CSHORT Size;
1822 PVOID ControllerExtension;
1823 KDEVICE_QUEUE DeviceWaitQueue;
1824 ULONG Spare1;
1825 LARGE_INTEGER Spare2;
1826 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
1827
1828 typedef enum _DMA_WIDTH {
1829 Width8Bits,
1830 Width16Bits,
1831 Width32Bits,
1832 MaximumDmaWidth
1833 } DMA_WIDTH, *PDMA_WIDTH;
1834
1835 typedef enum _DMA_SPEED {
1836 Compatible,
1837 TypeA,
1838 TypeB,
1839 TypeC,
1840 TypeF,
1841 MaximumDmaSpeed
1842 } DMA_SPEED, *PDMA_SPEED;
1843
1844 /* DEVICE_DESCRIPTION.Version */
1845
1846 #define DEVICE_DESCRIPTION_VERSION 0x0000
1847 #define DEVICE_DESCRIPTION_VERSION1 0x0001
1848 #define DEVICE_DESCRIPTION_VERSION2 0x0002
1849
1850 typedef struct _DEVICE_DESCRIPTION {
1851 ULONG Version;
1852 BOOLEAN Master;
1853 BOOLEAN ScatterGather;
1854 BOOLEAN DemandMode;
1855 BOOLEAN AutoInitialize;
1856 BOOLEAN Dma32BitAddresses;
1857 BOOLEAN IgnoreCount;
1858 BOOLEAN Reserved1;
1859 BOOLEAN Dma64BitAddresses;
1860 ULONG BusNumber;
1861 ULONG DmaChannel;
1862 INTERFACE_TYPE InterfaceType;
1863 DMA_WIDTH DmaWidth;
1864 DMA_SPEED DmaSpeed;
1865 ULONG MaximumLength;
1866 ULONG DmaPort;
1867 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
1868
1869 /* VPB.Flags */
1870 #define VPB_MOUNTED 0x0001
1871 #define VPB_LOCKED 0x0002
1872 #define VPB_PERSISTENT 0x0004
1873 #define VPB_REMOVE_PENDING 0x0008
1874 #define VPB_RAW_MOUNT 0x0010
1875
1876 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
1877
1878 typedef struct _VPB {
1879 CSHORT Type;
1880 CSHORT Size;
1881 USHORT Flags;
1882 USHORT VolumeLabelLength;
1883 struct _DEVICE_OBJECT *DeviceObject;
1884 struct _DEVICE_OBJECT *RealDevice;
1885 ULONG SerialNumber;
1886 ULONG ReferenceCount;
1887 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
1888 } VPB, *PVPB;
1889
1890 /* DEVICE_OBJECT.Flags */
1891
1892 #define DO_VERIFY_VOLUME 0x00000002
1893 #define DO_BUFFERED_IO 0x00000004
1894 #define DO_EXCLUSIVE 0x00000008
1895 #define DO_DIRECT_IO 0x00000010
1896 #define DO_MAP_IO_BUFFER 0x00000020
1897 #define DO_DEVICE_HAS_NAME 0x00000040
1898 #define DO_DEVICE_INITIALIZING 0x00000080
1899 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
1900 #define DO_LONG_TERM_REQUESTS 0x00000200
1901 #define DO_NEVER_LAST_DEVICE 0x00000400
1902 #define DO_SHUTDOWN_REGISTERED 0x00000800
1903 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
1904 #define DO_POWER_PAGABLE 0x00002000
1905 #define DO_POWER_INRUSH 0x00004000
1906 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
1907
1908 /* DEVICE_OBJECT.Characteristics */
1909
1910 #define FILE_REMOVABLE_MEDIA 0x00000001
1911 #define FILE_READ_ONLY_DEVICE 0x00000002
1912 #define FILE_FLOPPY_DISKETTE 0x00000004
1913 #define FILE_WRITE_ONCE_MEDIA 0x00000008
1914 #define FILE_REMOTE_DEVICE 0x00000010
1915 #define FILE_DEVICE_IS_MOUNTED 0x00000020
1916 #define FILE_VIRTUAL_VOLUME 0x00000040
1917 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
1918 #define FILE_DEVICE_SECURE_OPEN 0x00000100
1919
1920 /* DEVICE_OBJECT.AlignmentRequirement */
1921
1922 #define FILE_BYTE_ALIGNMENT 0x00000000
1923 #define FILE_WORD_ALIGNMENT 0x00000001
1924 #define FILE_LONG_ALIGNMENT 0x00000003
1925 #define FILE_QUAD_ALIGNMENT 0x00000007
1926 #define FILE_OCTA_ALIGNMENT 0x0000000f
1927 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
1928 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
1929 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
1930 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
1931 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
1932
1933 /* DEVICE_OBJECT.DeviceType */
1934
1935 #define DEVICE_TYPE ULONG
1936
1937 #define FILE_DEVICE_BEEP 0x00000001
1938 #define FILE_DEVICE_CD_ROM 0x00000002
1939 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1940 #define FILE_DEVICE_CONTROLLER 0x00000004
1941 #define FILE_DEVICE_DATALINK 0x00000005
1942 #define FILE_DEVICE_DFS 0x00000006
1943 #define FILE_DEVICE_DISK 0x00000007
1944 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1945 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1946 #define FILE_DEVICE_INPORT_PORT 0x0000000a
1947 #define FILE_DEVICE_KEYBOARD 0x0000000b
1948 #define FILE_DEVICE_MAILSLOT 0x0000000c
1949 #define FILE_DEVICE_MIDI_IN 0x0000000d
1950 #define FILE_DEVICE_MIDI_OUT 0x0000000e
1951 #define FILE_DEVICE_MOUSE 0x0000000f
1952 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
1953 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1954 #define FILE_DEVICE_NETWORK 0x00000012
1955 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
1956 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1957 #define FILE_DEVICE_NULL 0x00000015
1958 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1959 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
1960 #define FILE_DEVICE_PRINTER 0x00000018
1961 #define FILE_DEVICE_SCANNER 0x00000019
1962 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
1963 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1964 #define FILE_DEVICE_SCREEN 0x0000001c
1965 #define FILE_DEVICE_SOUND 0x0000001d
1966 #define FILE_DEVICE_STREAMS 0x0000001e
1967 #define FILE_DEVICE_TAPE 0x0000001f
1968 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1969 #define FILE_DEVICE_TRANSPORT 0x00000021
1970 #define FILE_DEVICE_UNKNOWN 0x00000022
1971 #define FILE_DEVICE_VIDEO 0x00000023
1972 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1973 #define FILE_DEVICE_WAVE_IN 0x00000025
1974 #define FILE_DEVICE_WAVE_OUT 0x00000026
1975 #define FILE_DEVICE_8042_PORT 0x00000027
1976 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1977 #define FILE_DEVICE_BATTERY 0x00000029
1978 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
1979 #define FILE_DEVICE_MODEM 0x0000002b
1980 #define FILE_DEVICE_VDM 0x0000002c
1981 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
1982 #define FILE_DEVICE_SMB 0x0000002e
1983 #define FILE_DEVICE_KS 0x0000002f
1984 #define FILE_DEVICE_CHANGER 0x00000030
1985 #define FILE_DEVICE_SMARTCARD 0x00000031
1986 #define FILE_DEVICE_ACPI 0x00000032
1987 #define FILE_DEVICE_DVD 0x00000033
1988 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
1989 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
1990 #define FILE_DEVICE_DFS_VOLUME 0x00000036
1991 #define FILE_DEVICE_SERENUM 0x00000037
1992 #define FILE_DEVICE_TERMSRV 0x00000038
1993 #define FILE_DEVICE_KSEC 0x00000039
1994 #define FILE_DEVICE_FIPS 0x0000003a
1995
1996 typedef struct _DEVICE_OBJECT {
1997 CSHORT Type;
1998 USHORT Size;
1999 LONG ReferenceCount;
2000 struct _DRIVER_OBJECT *DriverObject;
2001 struct _DEVICE_OBJECT *NextDevice;
2002 struct _DEVICE_OBJECT *AttachedDevice;
2003 struct _IRP *CurrentIrp;
2004 PIO_TIMER Timer;
2005 ULONG Flags;
2006 ULONG Characteristics;
2007 PVPB Vpb;
2008 PVOID DeviceExtension;
2009 DEVICE_TYPE DeviceType;
2010 CCHAR StackSize;
2011 union {
2012 LIST_ENTRY ListEntry;
2013 WAIT_CONTEXT_BLOCK Wcb;
2014 } Queue;
2015 ULONG AlignmentRequirement;
2016 KDEVICE_QUEUE DeviceQueue;
2017 KDPC Dpc;
2018 ULONG ActiveThreadCount;
2019 PSECURITY_DESCRIPTOR SecurityDescriptor;
2020 KEVENT DeviceLock;
2021 USHORT SectorSize;
2022 USHORT Spare1;
2023 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
2024 PVOID Reserved;
2025 } DEVICE_OBJECT, *PDEVICE_OBJECT;
2026
2027 typedef enum _DEVICE_RELATION_TYPE {
2028 BusRelations,
2029 EjectionRelations,
2030 PowerRelations,
2031 RemovalRelations,
2032 TargetDeviceRelation,
2033 SingleBusRelations
2034 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
2035
2036 typedef struct _DEVICE_RELATIONS {
2037 ULONG Count;
2038 PDEVICE_OBJECT Objects[1];
2039 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
2040
2041 typedef struct _SCATTER_GATHER_ELEMENT {
2042 PHYSICAL_ADDRESS Address;
2043 ULONG Length;
2044 ULONG_PTR Reserved;
2045 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
2046
2047 typedef struct _SCATTER_GATHER_LIST {
2048 ULONG NumberOfElements;
2049 ULONG_PTR Reserved;
2050 SCATTER_GATHER_ELEMENT Elements[0];
2051 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2052
2053 typedef struct _MDL {
2054 struct _MDL *Next;
2055 CSHORT Size;
2056 CSHORT MdlFlags;
2057 struct _EPROCESS *Process;
2058 PVOID MappedSystemVa;
2059 PVOID StartVa;
2060 ULONG ByteCount;
2061 ULONG ByteOffset;
2062 } MDL, *PMDL;
2063
2064 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
2065 #define MDL_PAGES_LOCKED 0x0002
2066 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
2067 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
2068 #define MDL_PARTIAL 0x0010
2069 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
2070 #define MDL_IO_PAGE_READ 0x0040
2071 #define MDL_WRITE_OPERATION 0x0080
2072 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
2073 #define MDL_FREE_EXTRA_PTES 0x0200
2074 #define MDL_IO_SPACE 0x0800
2075 #define MDL_NETWORK_HEADER 0x1000
2076 #define MDL_MAPPING_CAN_FAIL 0x2000
2077 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
2078
2079 #define MDL_MAPPING_FLAGS ( \
2080 MDL_MAPPED_TO_SYSTEM_VA | \
2081 MDL_PAGES_LOCKED | \
2082 MDL_SOURCE_IS_NONPAGED_POOL | \
2083 MDL_PARTIAL_HAS_BEEN_MAPPED | \
2084 MDL_PARENT_MAPPED_SYSTEM_VA | \
2085 MDL_SYSTEM_VA | \
2086 MDL_IO_SPACE)
2087
2088 typedef VOID
2089 (DDKAPI *PPUT_DMA_ADAPTER)(
2090 IN PDMA_ADAPTER DmaAdapter);
2091
2092 typedef PVOID
2093 (DDKAPI *PALLOCATE_COMMON_BUFFER)(
2094 IN PDMA_ADAPTER DmaAdapter,
2095 IN ULONG Length,
2096 OUT PPHYSICAL_ADDRESS LogicalAddress,
2097 IN BOOLEAN CacheEnabled);
2098
2099 typedef VOID
2100 (DDKAPI *PFREE_COMMON_BUFFER)(
2101 IN PDMA_ADAPTER DmaAdapter,
2102 IN ULONG Length,
2103 IN PHYSICAL_ADDRESS LogicalAddress,
2104 IN PVOID VirtualAddress,
2105 IN BOOLEAN CacheEnabled);
2106
2107 typedef NTSTATUS
2108 (DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
2109 IN PDMA_ADAPTER DmaAdapter,
2110 IN PDEVICE_OBJECT DeviceObject,
2111 IN ULONG NumberOfMapRegisters,
2112 IN PDRIVER_CONTROL ExecutionRoutine,
2113 IN PVOID Context);
2114
2115 typedef BOOLEAN
2116 (DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
2117 IN PDMA_ADAPTER DmaAdapter,
2118 IN PMDL Mdl,
2119 IN PVOID MapRegisterBase,
2120 IN PVOID CurrentVa,
2121 IN ULONG Length,
2122 IN BOOLEAN WriteToDevice);
2123
2124 typedef VOID
2125 (DDKAPI *PFREE_ADAPTER_CHANNEL)(
2126 IN PDMA_ADAPTER DmaAdapter);
2127
2128 typedef VOID
2129 (DDKAPI *PFREE_MAP_REGISTERS)(
2130 IN PDMA_ADAPTER DmaAdapter,
2131 PVOID MapRegisterBase,
2132 ULONG NumberOfMapRegisters);
2133
2134 typedef PHYSICAL_ADDRESS
2135 (DDKAPI *PMAP_TRANSFER)(
2136 IN PDMA_ADAPTER DmaAdapter,
2137 IN PMDL Mdl,
2138 IN PVOID MapRegisterBase,
2139 IN PVOID CurrentVa,
2140 IN OUT PULONG Length,
2141 IN BOOLEAN WriteToDevice);
2142
2143 typedef ULONG
2144 (DDKAPI *PGET_DMA_ALIGNMENT)(
2145 IN PDMA_ADAPTER DmaAdapter);
2146
2147 typedef ULONG
2148 (DDKAPI *PREAD_DMA_COUNTER)(
2149 IN PDMA_ADAPTER DmaAdapter);
2150
2151 typedef NTSTATUS
2152 (DDKAPI *PGET_SCATTER_GATHER_LIST)(
2153 IN PDMA_ADAPTER DmaAdapter,
2154 IN PDEVICE_OBJECT DeviceObject,
2155 IN PMDL Mdl,
2156 IN PVOID CurrentVa,
2157 IN ULONG Length,
2158 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2159 IN PVOID Context,
2160 IN BOOLEAN WriteToDevice);
2161
2162 typedef VOID
2163 (DDKAPI *PPUT_SCATTER_GATHER_LIST)(
2164 IN PDMA_ADAPTER DmaAdapter,
2165 IN PSCATTER_GATHER_LIST ScatterGather,
2166 IN BOOLEAN WriteToDevice);
2167
2168 typedef NTSTATUS
2169 (DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2170 IN PDMA_ADAPTER DmaAdapter,
2171 IN PMDL Mdl OPTIONAL,
2172 IN PVOID CurrentVa,
2173 IN ULONG Length,
2174 OUT PULONG ScatterGatherListSize,
2175 OUT PULONG pNumberOfMapRegisters OPTIONAL);
2176
2177 typedef NTSTATUS
2178 (DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
2179 IN PDMA_ADAPTER DmaAdapter,
2180 IN PDEVICE_OBJECT DeviceObject,
2181 IN PMDL Mdl,
2182 IN PVOID CurrentVa,
2183 IN ULONG Length,
2184 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2185 IN PVOID Context,
2186 IN BOOLEAN WriteToDevice,
2187 IN PVOID ScatterGatherBuffer,
2188 IN ULONG ScatterGatherLength);
2189
2190 typedef NTSTATUS
2191 (DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2192 IN PDMA_ADAPTER DmaAdapter,
2193 IN PSCATTER_GATHER_LIST ScatterGather,
2194 IN PMDL OriginalMdl,
2195 OUT PMDL *TargetMdl);
2196
2197 typedef struct _DMA_OPERATIONS {
2198 ULONG Size;
2199 PPUT_DMA_ADAPTER PutDmaAdapter;
2200 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2201 PFREE_COMMON_BUFFER FreeCommonBuffer;
2202 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2203 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2204 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2205 PFREE_MAP_REGISTERS FreeMapRegisters;
2206 PMAP_TRANSFER MapTransfer;
2207 PGET_DMA_ALIGNMENT GetDmaAlignment;
2208 PREAD_DMA_COUNTER ReadDmaCounter;
2209 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2210 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2211 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2212 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2213 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2214 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2215
2216 typedef struct _DMA_ADAPTER {
2217 USHORT Version;
2218 USHORT Size;
2219 PDMA_OPERATIONS DmaOperations;
2220 } DMA_ADAPTER;
2221
2222
2223 typedef enum _ARBITER_REQUEST_SOURCE {
2224 ArbiterRequestUndefined = -1,
2225 ArbiterRequestLegacyReported,
2226 ArbiterRequestHalReported,
2227 ArbiterRequestLegacyAssigned,
2228 ArbiterRequestPnpDetected,
2229 ArbiterRequestPnpEnumerated
2230 } ARBITER_REQUEST_SOURCE;
2231
2232 typedef enum _ARBITER_RESULT {
2233 ArbiterResultUndefined = -1,
2234 ArbiterResultSuccess,
2235 ArbiterResultExternalConflict,
2236 ArbiterResultNullRequest
2237 } ARBITER_RESULT;
2238
2239 typedef enum _ARBITER_ACTION {
2240 ArbiterActionTestAllocation,
2241 ArbiterActionRetestAllocation,
2242 ArbiterActionCommitAllocation,
2243 ArbiterActionRollbackAllocation,
2244 ArbiterActionQueryAllocatedResources,
2245 ArbiterActionWriteReservedResources,
2246 ArbiterActionQueryConflict,
2247 ArbiterActionQueryArbitrate,
2248 ArbiterActionAddReserved,
2249 ArbiterActionBootAllocation
2250 } ARBITER_ACTION, *PARBITER_ACTION;
2251
2252 typedef struct _ARBITER_CONFLICT_INFO {
2253 PDEVICE_OBJECT OwningObject;
2254 ULONGLONG Start;
2255 ULONGLONG End;
2256 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
2257
2258 typedef struct _ARBITER_PARAMETERS {
2259 union {
2260 struct {
2261 IN OUT PLIST_ENTRY ArbitrationList;
2262 IN ULONG AllocateFromCount;
2263 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2264 } TestAllocation;
2265
2266 struct {
2267 IN OUT PLIST_ENTRY ArbitrationList;
2268 IN ULONG AllocateFromCount;
2269 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2270 } RetestAllocation;
2271
2272 struct {
2273 IN OUT PLIST_ENTRY ArbitrationList;
2274 } BootAllocation;
2275
2276 struct {
2277 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
2278 } QueryAllocatedResources;
2279
2280 struct {
2281 IN PDEVICE_OBJECT PhysicalDeviceObject;
2282 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
2283 OUT PULONG ConflictCount;
2284 OUT PARBITER_CONFLICT_INFO *Conflicts;
2285 } QueryConflict;
2286
2287 struct {
2288 IN PLIST_ENTRY ArbitrationList;
2289 } QueryArbitrate;
2290
2291 struct {
2292 IN PDEVICE_OBJECT ReserveDevice;
2293 } AddReserved;
2294 } Parameters;
2295 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
2296
2297 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
2298
2299 typedef struct _ARBITER_LIST_ENTRY {
2300 LIST_ENTRY ListEntry;
2301 ULONG AlternativeCount;
2302 PIO_RESOURCE_DESCRIPTOR Alternatives;
2303 PDEVICE_OBJECT PhysicalDeviceObject;
2304 ARBITER_REQUEST_SOURCE RequestSource;
2305 ULONG Flags;
2306 LONG_PTR WorkSpace;
2307 INTERFACE_TYPE InterfaceType;
2308 ULONG SlotNumber;
2309 ULONG BusNumber;
2310 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
2311 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
2312 ARBITER_RESULT Result;
2313 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
2314
2315 typedef NTSTATUS
2316 (DDKAPI *PARBITER_HANDLER)(
2317 IN PVOID Context,
2318 IN ARBITER_ACTION Action,
2319 IN OUT PARBITER_PARAMETERS Parameters);
2320
2321 #define ARBITER_PARTIAL 0x00000001
2322
2323 typedef struct _ARBITER_INTERFACE {
2324 USHORT Size;
2325 USHORT Version;
2326 PVOID Context;
2327 PINTERFACE_REFERENCE InterfaceReference;
2328 PINTERFACE_DEREFERENCE InterfaceDereference;
2329 PARBITER_HANDLER ArbiterHandler;
2330 ULONG Flags;
2331 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
2332
2333 typedef enum _HAL_QUERY_INFORMATION_CLASS {
2334 HalInstalledBusInformation,
2335 HalProfileSourceInformation,
2336 HalInformationClassUnused1,
2337 HalPowerInformation,
2338 HalProcessorSpeedInformation,
2339 HalCallbackInformation,
2340 HalMapRegisterInformation,
2341 HalMcaLogInformation,
2342 HalFrameBufferCachingInformation,
2343 HalDisplayBiosInformation,
2344 HalProcessorFeatureInformation,
2345 HalNumaTopologyInterface,
2346 HalErrorInformation,
2347 HalCmcLogInformation,
2348 HalCpeLogInformation,
2349 HalQueryMcaInterface,
2350 HalQueryAMLIIllegalIOPortAddresses,
2351 HalQueryMaxHotPlugMemoryAddress,
2352 HalPartitionIpiInterface,
2353 HalPlatformInformation,
2354 HalQueryProfileSourceList
2355 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
2356
2357 typedef enum _HAL_SET_INFORMATION_CLASS {
2358 HalProfileSourceInterval,
2359 HalProfileSourceInterruptHandler,
2360 HalMcaRegisterDriver,
2361 HalKernelErrorHandler,
2362 HalCmcRegisterDriver,
2363 HalCpeRegisterDriver,
2364 HalMcaLog,
2365 HalCmcLog,
2366 HalCpeLog,
2367 HalGenerateCmcInterrupt
2368 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
2369
2370 /* Function Type Defintions for Dispatch Functions */
2371
2372 typedef VOID
2373 (DDKAPI *PDEVICE_CONTROL_COMPLETION)(
2374 IN struct _DEVICE_CONTROL_CONTEXT *ControlContext);
2375
2376 typedef struct _DEVICE_CONTROL_CONTEXT {
2377 NTSTATUS Status;
2378 PDEVICE_HANDLER_OBJECT DeviceHandler;
2379 PDEVICE_OBJECT DeviceObject;
2380 ULONG ControlCode;
2381 PVOID Buffer;
2382 PULONG BufferLength;
2383 PVOID Context;
2384 } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
2385
2386 typedef struct _PM_DISPATCH_TABLE {
2387 ULONG Signature;
2388 ULONG Version;
2389 PVOID Function[1];
2390 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
2391
2392 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
2393 TranslateChildToParent,
2394 TranslateParentToChild
2395 } RESOURCE_TRANSLATION_DIRECTION;
2396
2397 typedef NTSTATUS
2398 (DDKAPI *PTRANSLATE_RESOURCE_HANDLER)(
2399 IN PVOID Context,
2400 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
2401 IN RESOURCE_TRANSLATION_DIRECTION Direction,
2402 IN ULONG AlternativesCount,
2403 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
2404 IN PDEVICE_OBJECT PhysicalDeviceObject,
2405 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
2406
2407 typedef NTSTATUS
2408 (DDKAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
2409 IN PVOID Context,
2410 IN PIO_RESOURCE_DESCRIPTOR Source,
2411 IN PDEVICE_OBJECT PhysicalDeviceObject,
2412 OUT PULONG TargetCount,
2413 OUT PIO_RESOURCE_DESCRIPTOR *Target);
2414
2415 typedef struct _TRANSLATOR_INTERFACE {
2416 USHORT Size;
2417 USHORT Version;
2418 PVOID Context;
2419 PINTERFACE_REFERENCE InterfaceReference;
2420 PINTERFACE_DEREFERENCE InterfaceDereference;
2421 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
2422 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
2423 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
2424
2425 typedef NTSTATUS
2426 (DDKAPI *pHalDeviceControl)(
2427 IN PDEVICE_HANDLER_OBJECT DeviceHandler,
2428 IN PDEVICE_OBJECT DeviceObject,
2429 IN ULONG ControlCode,
2430 IN OUT PVOID Buffer OPTIONAL,
2431 IN OUT PULONG BufferLength OPTIONAL,
2432 IN PVOID Context,
2433 IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
2434
2435 typedef VOID
2436 (DDKFASTAPI *pHalExamineMBR)(
2437 IN PDEVICE_OBJECT DeviceObject,
2438 IN ULONG SectorSize,
2439 IN ULONG MBRTypeIdentifier,
2440 OUT PVOID *Buffer);
2441
2442 typedef VOID
2443 (DDKFASTAPI *pHalIoAssignDriveLetters)(
2444 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2445 IN PSTRING NtDeviceName,
2446 OUT PUCHAR NtSystemPath,
2447 OUT PSTRING NtSystemPathString);
2448
2449 typedef NTSTATUS
2450 (DDKFASTAPI *pHalIoReadPartitionTable)(
2451 IN PDEVICE_OBJECT DeviceObject,
2452 IN ULONG SectorSize,
2453 IN BOOLEAN ReturnRecognizedPartitions,
2454 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2455
2456 typedef NTSTATUS
2457 (DDKFASTAPI *pHalIoSetPartitionInformation)(
2458 IN PDEVICE_OBJECT DeviceObject,
2459 IN ULONG SectorSize,
2460 IN ULONG PartitionNumber,
2461 IN ULONG PartitionType);
2462
2463 typedef NTSTATUS
2464 (DDKFASTAPI *pHalIoWritePartitionTable)(
2465 IN PDEVICE_OBJECT DeviceObject,
2466 IN ULONG SectorSize,
2467 IN ULONG SectorsPerTrack,
2468 IN ULONG NumberOfHeads,
2469 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2470
2471 typedef PBUS_HANDLER
2472 (DDKFASTAPI *pHalHandlerForBus)(
2473 IN INTERFACE_TYPE InterfaceType,
2474 IN ULONG BusNumber);
2475
2476 typedef VOID
2477 (DDKFASTAPI *pHalReferenceBusHandler)(
2478 IN PBUS_HANDLER BusHandler);
2479
2480 typedef NTSTATUS
2481 (DDKAPI *pHalQuerySystemInformation)(
2482 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
2483 IN ULONG BufferSize,
2484 IN OUT PVOID Buffer,
2485 OUT PULONG ReturnedLength);
2486
2487 typedef NTSTATUS
2488 (DDKAPI *pHalSetSystemInformation)(
2489 IN HAL_SET_INFORMATION_CLASS InformationClass,
2490 IN ULONG BufferSize,
2491 IN PVOID Buffer);
2492
2493 typedef NTSTATUS
2494 (DDKAPI *pHalQueryBusSlots)(
2495 IN PBUS_HANDLER BusHandler,
2496 IN ULONG BufferSize,
2497 OUT PULONG SlotNumbers,
2498 OUT PULONG ReturnedLength);
2499
2500 typedef NTSTATUS
2501 (DDKAPI *pHalInitPnpDriver)(
2502 VOID);
2503
2504 typedef NTSTATUS
2505 (DDKAPI *pHalInitPowerManagement)(
2506 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
2507 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
2508
2509 typedef struct _DMA_ADAPTER*
2510 (DDKAPI *pHalGetDmaAdapter)(
2511 IN PVOID Context,
2512 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
2513 OUT PULONG NumberOfMapRegisters);
2514
2515 typedef NTSTATUS
2516 (DDKAPI *pHalGetInterruptTranslator)(
2517 IN INTERFACE_TYPE ParentInterfaceType,
2518 IN ULONG ParentBusNumber,
2519 IN INTERFACE_TYPE BridgeInterfaceType,
2520 IN USHORT Size,
2521 IN USHORT Version,
2522 OUT PTRANSLATOR_INTERFACE Translator,
2523 OUT PULONG BridgeBusNumber);
2524
2525 typedef NTSTATUS
2526 (DDKAPI *pHalStartMirroring)(
2527 VOID);
2528
2529 typedef NTSTATUS
2530 (DDKAPI *pHalEndMirroring)(
2531 IN ULONG PassNumber);
2532
2533 typedef NTSTATUS
2534 (DDKAPI *pHalMirrorPhysicalMemory)(
2535 IN PHYSICAL_ADDRESS PhysicalAddress,
2536 IN LARGE_INTEGER NumberOfBytes);
2537
2538 typedef NTSTATUS
2539 (DDKAPI *pHalMirrorVerify)(
2540 IN PHYSICAL_ADDRESS PhysicalAddress,
2541 IN LARGE_INTEGER NumberOfBytes);
2542
2543 typedef VOID
2544 (DDKAPI *pHalEndOfBoot)(
2545 VOID);
2546
2547 typedef BOOLEAN
2548 (DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
2549 ULONG Columns, ULONG Rows);
2550
2551 typedef struct {
2552 ULONG Version;
2553 pHalQuerySystemInformation HalQuerySystemInformation;
2554 pHalSetSystemInformation HalSetSystemInformation;
2555 pHalQueryBusSlots HalQueryBusSlots;
2556 ULONG Spare1;
2557 pHalExamineMBR HalExamineMBR;
2558 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
2559 pHalIoReadPartitionTable HalIoReadPartitionTable;
2560 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
2561 pHalIoWritePartitionTable HalIoWritePartitionTable;
2562 pHalHandlerForBus HalReferenceHandlerForBus;
2563 pHalReferenceBusHandler HalReferenceBusHandler;
2564 pHalReferenceBusHandler HalDereferenceBusHandler;
2565 pHalInitPnpDriver HalInitPnpDriver;
2566 pHalInitPowerManagement HalInitPowerManagement;
2567 pHalGetDmaAdapter HalGetDmaAdapter;
2568 pHalGetInterruptTranslator HalGetInterruptTranslator;
2569 pHalStartMirroring HalStartMirroring;
2570 pHalEndMirroring HalEndMirroring;
2571 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
2572 pHalEndOfBoot HalEndOfBoot;
2573 pHalMirrorVerify HalMirrorVerify;
2574 } HAL_DISPATCH, *PHAL_DISPATCH;
2575
2576 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTHAL_)
2577 extern DECL_IMPORT PHAL_DISPATCH HalDispatchTable;
2578 #define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable)
2579 #else
2580 extern DECL_EXPORT HAL_DISPATCH HalDispatchTable;
2581 #define HALDISPATCH (&HalDispatchTable)
2582 #endif
2583
2584 #define HAL_DISPATCH_VERSION 3
2585 #define HalDispatchTableVersion HALDISPATCH->Version
2586 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
2587 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
2588 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
2589 #define HalDeviceControl HALDISPATCH->HalDeviceControl
2590 #define HalIoAssignDriveLetters HALDISPATCH->HalIoAssignDriveLetters
2591 #define HalIoReadPartitionTable HALDISPATCH->HalIoReadPartitionTable
2592 #define HalIoSetPartitionInformation HALDISPATCH->HalIoSetPartitionInformation
2593 #define HalIoWritePartitionTable HALDISPATCH->HalIoWritePartitionTable
2594 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
2595 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
2596 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
2597 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
2598 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
2599 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
2600 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
2601 #define HalStartMirroring HALDISPATCH->HalStartMirroring
2602 #define HalEndMirroring HALDISPATCH->HalEndMirroring
2603 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
2604 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
2605 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
2606
2607 typedef enum _FILE_INFORMATION_CLASS {
2608 FileDirectoryInformation = 1,
2609 FileFullDirectoryInformation,
2610 FileBothDirectoryInformation,
2611 FileBasicInformation,
2612 FileStandardInformation,
2613 FileInternalInformation,
2614 FileEaInformation,
2615 FileAccessInformation,
2616 FileNameInformation,
2617 FileRenameInformation,
2618 FileLinkInformation,
2619 FileNamesInformation,
2620 FileDispositionInformation,
2621 FilePositionInformation,
2622 FileFullEaInformation,
2623 FileModeInformation,
2624 FileAlignmentInformation,
2625 FileAllInformation,
2626 FileAllocationInformation,
2627 FileEndOfFileInformation,
2628 FileAlternateNameInformation,
2629 FileStreamInformation,
2630 FilePipeInformation,
2631 FilePipeLocalInformation,
2632 FilePipeRemoteInformation,
2633 FileMailslotQueryInformation,
2634 FileMailslotSetInformation,
2635 FileCompressionInformation,
2636 FileObjectIdInformation,
2637 FileCompletionInformation,
2638 FileMoveClusterInformation,
2639 FileQuotaInformation,
2640 FileReparsePointInformation,
2641 FileNetworkOpenInformation,
2642 FileAttributeTagInformation,
2643 FileTrackingInformation,
2644 FileIdBothDirectoryInformation,
2645 FileIdFullDirectoryInformation,
2646 FileValidDataLengthInformation,
2647 FileShortNameInformation,
2648 FileMaximumInformation
2649 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
2650
2651 typedef struct _FILE_POSITION_INFORMATION {
2652 LARGE_INTEGER CurrentByteOffset;
2653 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
2654
2655 typedef struct _FILE_ALIGNMENT_INFORMATION {
2656 ULONG AlignmentRequirement;
2657 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
2658
2659 typedef struct _FILE_NAME_INFORMATION {
2660 ULONG FileNameLength;
2661 WCHAR FileName[1];
2662 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
2663
2664 #include <pshpack8.h>
2665 typedef struct _FILE_BASIC_INFORMATION {
2666 LARGE_INTEGER CreationTime;
2667 LARGE_INTEGER LastAccessTime;
2668 LARGE_INTEGER LastWriteTime;
2669 LARGE_INTEGER ChangeTime;
2670 ULONG FileAttributes;
2671 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
2672 #include <poppack.h>
2673
2674 typedef struct _FILE_STANDARD_INFORMATION {
2675 LARGE_INTEGER AllocationSize;
2676 LARGE_INTEGER EndOfFile;
2677 ULONG NumberOfLinks;
2678 BOOLEAN DeletePending;
2679 BOOLEAN Directory;
2680 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
2681
2682 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
2683 LARGE_INTEGER CreationTime;
2684 LARGE_INTEGER LastAccessTime;
2685 LARGE_INTEGER LastWriteTime;
2686 LARGE_INTEGER ChangeTime;
2687 LARGE_INTEGER AllocationSize;
2688 LARGE_INTEGER EndOfFile;
2689 ULONG FileAttributes;
2690 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
2691
2692 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
2693 ULONG FileAttributes;
2694 ULONG ReparseTag;
2695 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
2696
2697 typedef struct _FILE_DISPOSITION_INFORMATION {
2698 BOOLEAN DeleteFile;
2699 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
2700
2701 typedef struct _FILE_END_OF_FILE_INFORMATION {
2702 LARGE_INTEGER EndOfFile;
2703 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
2704
2705 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
2706 LARGE_INTEGER ValidDataLength;
2707 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
2708
2709 typedef enum _FSINFOCLASS {
2710 FileFsVolumeInformation = 1,
2711 FileFsLabelInformation,
2712 FileFsSizeInformation,
2713 FileFsDeviceInformation,
2714 FileFsAttributeInformation,
2715 FileFsControlInformation,
2716 FileFsFullSizeInformation,
2717 FileFsObjectIdInformation,
2718 FileFsDriverPathInformation,
2719 FileFsMaximumInformation
2720 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
2721
2722 typedef struct _FILE_FS_DEVICE_INFORMATION {
2723 DEVICE_TYPE DeviceType;
2724 ULONG Characteristics;
2725 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
2726
2727 typedef struct _FILE_FULL_EA_INFORMATION {
2728 ULONG NextEntryOffset;
2729 UCHAR Flags;
2730 UCHAR EaNameLength;
2731 USHORT EaValueLength;
2732 CHAR EaName[1];
2733 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
2734
2735 typedef ULONG_PTR ERESOURCE_THREAD;
2736 typedef ERESOURCE_THREAD *PERESOURCE_THREAD;
2737
2738 typedef struct _OWNER_ENTRY {
2739 ERESOURCE_THREAD OwnerThread;
2740 _ANONYMOUS_UNION union {
2741 LONG OwnerCount;
2742 ULONG TableSize;
2743 } DUMMYUNIONNAME;
2744 } OWNER_ENTRY, *POWNER_ENTRY;
2745
2746 /* ERESOURCE.Flag */
2747
2748 #define ResourceNeverExclusive 0x0010
2749 #define ResourceReleaseByOtherThread 0x0020
2750 #define ResourceOwnedExclusive 0x0080
2751
2752 #define RESOURCE_HASH_TABLE_SIZE 64
2753
2754 typedef struct _ERESOURCE {
2755 LIST_ENTRY SystemResourcesList;
2756 POWNER_ENTRY OwnerTable;
2757 SHORT ActiveCount;
2758 USHORT Flag;
2759 PKSEMAPHORE SharedWaiters;
2760 PKEVENT ExclusiveWaiters;
2761 OWNER_ENTRY OwnerThreads[2];
2762 ULONG ContentionCount;
2763 USHORT NumberOfSharedWaiters;
2764 USHORT NumberOfExclusiveWaiters;
2765 _ANONYMOUS_UNION union {
2766 PVOID Address;
2767 ULONG_PTR CreatorBackTraceIndex;
2768 } DUMMYUNIONNAME;
2769 KSPIN_LOCK SpinLock;
2770 } ERESOURCE, *PERESOURCE;
2771
2772 typedef struct _DEVOBJ_EXTENSION
2773 {
2774 CSHORT Type;
2775 USHORT Size;
2776 PDEVICE_OBJECT DeviceObject;
2777 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
2778
2779 typedef struct _DRIVER_EXTENSION {
2780 struct _DRIVER_OBJECT *DriverObject;
2781 PDRIVER_ADD_DEVICE AddDevice;
2782 ULONG Count;
2783 UNICODE_STRING ServiceKeyName;
2784 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2785
2786 typedef BOOLEAN
2787 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
2788 IN struct _FILE_OBJECT *FileObject,
2789 IN PLARGE_INTEGER FileOffset,
2790 IN ULONG Length,
2791 IN BOOLEAN Wait,
2792 IN ULONG LockKey,
2793 IN BOOLEAN CheckForReadOperation,
2794 OUT PIO_STATUS_BLOCK IoStatus,
2795 IN struct _DEVICE_OBJECT *DeviceObject);
2796
2797 typedef BOOLEAN
2798 (DDKAPI *PFAST_IO_READ)(
2799 IN struct _FILE_OBJECT *FileObject,
2800 IN PLARGE_INTEGER FileOffset,
2801 IN ULONG Length,
2802 IN BOOLEAN Wait,
2803 IN ULONG LockKey,
2804 OUT PVOID Buffer,
2805 OUT PIO_STATUS_BLOCK IoStatus,
2806 IN struct _DEVICE_OBJECT *DeviceObject);
2807
2808 typedef BOOLEAN
2809 (DDKAPI *PFAST_IO_WRITE)(
2810 IN struct _FILE_OBJECT *FileObject,
2811 IN PLARGE_INTEGER FileOffset,
2812 IN ULONG Length,
2813 IN BOOLEAN Wait,
2814 IN ULONG LockKey,
2815 IN PVOID Buffer,
2816 OUT PIO_STATUS_BLOCK IoStatus,
2817 IN struct _DEVICE_OBJECT *DeviceObject);
2818
2819 typedef BOOLEAN
2820 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
2821 IN struct _FILE_OBJECT *FileObject,
2822 IN BOOLEAN Wait,
2823 OUT PFILE_BASIC_INFORMATION Buffer,
2824 OUT PIO_STATUS_BLOCK IoStatus,
2825 IN struct _DEVICE_OBJECT *DeviceObject);
2826
2827 typedef BOOLEAN
2828 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
2829 IN struct _FILE_OBJECT *FileObject,
2830 IN BOOLEAN Wait,
2831 OUT PFILE_STANDARD_INFORMATION Buffer,
2832 OUT PIO_STATUS_BLOCK IoStatus,
2833 IN struct _DEVICE_OBJECT *DeviceObject);
2834
2835 typedef BOOLEAN
2836 (DDKAPI *PFAST_IO_LOCK)(
2837 IN struct _FILE_OBJECT *FileObject,
2838 IN PLARGE_INTEGER FileOffset,
2839 IN PLARGE_INTEGER Length,
2840 PEPROCESS ProcessId,
2841 ULONG Key,
2842 BOOLEAN FailImmediately,
2843 BOOLEAN ExclusiveLock,
2844 OUT PIO_STATUS_BLOCK IoStatus,
2845 IN struct _DEVICE_OBJECT *DeviceObject);
2846
2847 typedef BOOLEAN
2848 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
2849 IN struct _FILE_OBJECT *FileObject,
2850 IN PLARGE_INTEGER FileOffset,
2851 IN PLARGE_INTEGER Length,
2852 PEPROCESS ProcessId,
2853 ULONG Key,
2854 OUT PIO_STATUS_BLOCK IoStatus,
2855 IN struct _DEVICE_OBJECT *DeviceObject);
2856
2857 typedef BOOLEAN
2858 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
2859 IN struct _FILE_OBJECT *FileObject,
2860 PEPROCESS ProcessId,
2861 OUT PIO_STATUS_BLOCK IoStatus,
2862 IN struct _DEVICE_OBJECT *DeviceObject);
2863
2864 typedef BOOLEAN
2865 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
2866 IN struct _FILE_OBJECT *FileObject,
2867 PEPROCESS ProcessId,
2868 ULONG Key,
2869 OUT PIO_STATUS_BLOCK IoStatus,
2870 IN struct _DEVICE_OBJECT *DeviceObject);
2871
2872 typedef BOOLEAN
2873 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
2874 IN struct _FILE_OBJECT *FileObject,
2875 IN BOOLEAN Wait,
2876 IN PVOID InputBuffer OPTIONAL,
2877 IN ULONG InputBufferLength,
2878 OUT PVOID OutputBuffer OPTIONAL,
2879 IN ULONG OutputBufferLength,
2880 IN ULONG IoControlCode,
2881 OUT PIO_STATUS_BLOCK IoStatus,
2882 IN struct _DEVICE_OBJECT *DeviceObject);
2883
2884 typedef VOID
2885 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
2886 IN struct _FILE_OBJECT *FileObject);
2887
2888 typedef VOID
2889 (DDKAPI *PFAST_IO_RELEASE_FILE)(
2890 IN struct _FILE_OBJECT *FileObject);
2891
2892 typedef VOID
2893 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
2894 IN struct _DEVICE_OBJECT *SourceDevice,
2895 IN struct _DEVICE_OBJECT *TargetDevice);
2896
2897 typedef BOOLEAN
2898 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
2899 IN struct _FILE_OBJECT *FileObject,
2900 IN BOOLEAN Wait,
2901 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
2902 OUT struct _IO_STATUS_BLOCK *IoStatus,
2903 IN struct _DEVICE_OBJECT *DeviceObject);
2904
2905 typedef NTSTATUS
2906 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
2907 IN struct _FILE_OBJECT *FileObject,
2908 IN PLARGE_INTEGER EndingOffset,
2909 OUT struct _ERESOURCE **ResourceToRelease,
2910 IN struct _DEVICE_OBJECT *DeviceObject);
2911
2912 typedef BOOLEAN
2913 (DDKAPI *PFAST_IO_MDL_READ)(
2914 IN struct _FILE_OBJECT *FileObject,
2915 IN PLARGE_INTEGER FileOffset,
2916 IN ULONG Length,
2917 IN ULONG LockKey,
2918 OUT PMDL *MdlChain,
2919 OUT PIO_STATUS_BLOCK IoStatus,
2920 IN struct _DEVICE_OBJECT *DeviceObject);
2921
2922 typedef BOOLEAN
2923 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
2924 IN struct _FILE_OBJECT *FileObject,
2925 IN PMDL MdlChain,
2926 IN struct _DEVICE_OBJECT *DeviceObject);
2927
2928 typedef BOOLEAN
2929 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
2930 IN struct _FILE_OBJECT *FileObject,
2931 IN PLARGE_INTEGER FileOffset,
2932 IN ULONG Length,
2933 IN ULONG LockKey,
2934 OUT PMDL *MdlChain,
2935 OUT PIO_STATUS_BLOCK IoStatus,
2936 IN struct _DEVICE_OBJECT *DeviceObject);
2937
2938 typedef BOOLEAN
2939 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
2940 IN struct _FILE_OBJECT *FileObject,
2941 IN PLARGE_INTEGER FileOffset,
2942 IN PMDL MdlChain,
2943 IN struct _DEVICE_OBJECT *DeviceObject);
2944
2945 typedef BOOLEAN
2946 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
2947 IN struct _FILE_OBJECT *FileObject,
2948 IN PLARGE_INTEGER FileOffset,
2949 IN ULONG Length,
2950 IN ULONG LockKey,
2951 OUT PVOID Buffer,
2952 OUT PMDL *MdlChain,
2953 OUT PIO_STATUS_BLOCK IoStatus,
2954 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
2955 IN ULONG CompressedDataInfoLength,
2956 IN struct _DEVICE_OBJECT *DeviceObject);
2957
2958 typedef BOOLEAN
2959 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
2960 IN struct _FILE_OBJECT *FileObject,
2961 IN PLARGE_INTEGER FileOffset,
2962 IN ULONG Length,
2963 IN ULONG LockKey,
2964 IN PVOID Buffer,
2965 OUT PMDL *MdlChain,
2966 OUT PIO_STATUS_BLOCK IoStatus,
2967 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
2968 IN ULONG CompressedDataInfoLength,
2969 IN struct _DEVICE_OBJECT *DeviceObject);
2970
2971 typedef BOOLEAN
2972 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
2973 IN struct _FILE_OBJECT *FileObject,
2974 IN PMDL MdlChain,
2975 IN struct _DEVICE_OBJECT *DeviceObject);
2976
2977 typedef BOOLEAN
2978 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
2979 IN struct _FILE_OBJECT *FileObject,
2980 IN PLARGE_INTEGER FileOffset,
2981 IN PMDL MdlChain,
2982 IN struct _DEVICE_OBJECT *DeviceObject);
2983
2984 typedef BOOLEAN
2985 (DDKAPI *PFAST_IO_QUERY_OPEN)(
2986 IN struct _IRP *Irp,
2987 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
2988 IN struct _DEVICE_OBJECT *DeviceObject);
2989
2990 typedef NTSTATUS
2991 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
2992 IN struct _FILE_OBJECT *FileObject,
2993 IN struct _ERESOURCE *ResourceToRelease,
2994 IN struct _DEVICE_OBJECT *DeviceObject);
2995
2996 typedef NTSTATUS
2997 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
2998 IN struct _FILE_OBJECT *FileObject,
2999 IN struct _DEVICE_OBJECT *DeviceObject);
3000
3001 typedef NTSTATUS
3002 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
3003 IN struct _FILE_OBJECT *FileObject,
3004 IN struct _DEVICE_OBJECT *DeviceObject);
3005
3006 typedef struct _FAST_IO_DISPATCH {
3007 ULONG SizeOfFastIoDispatch;
3008 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
3009 PFAST_IO_READ FastIoRead;
3010 PFAST_IO_WRITE FastIoWrite;
3011 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
3012 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
3013 PFAST_IO_LOCK FastIoLock;
3014 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
3015 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
3016 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
3017 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
3018 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
3019 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
3020 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
3021 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
3022 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
3023 PFAST_IO_MDL_READ MdlRead;
3024 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
3025 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
3026 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
3027 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
3028 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
3029 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
3030 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
3031 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
3032 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
3033 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
3034 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
3035 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
3036
3037 #define DRVO_UNLOAD_INVOKED 0x00000001
3038 #define DRVO_LEGACY_DRIVER 0x00000002
3039 #define DRVO_BUILTIN_DRIVER 0x00000004
3040 #define DRVO_REINIT_REGISTERED 0x00000008
3041 #define DRVO_INITIALIZED 0x00000010
3042 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
3043 #define DRVO_LEGACY_RESOURCES 0x00000040
3044
3045 typedef struct _DRIVER_OBJECT {
3046 CSHORT Type;
3047 CSHORT Size;
3048 PDEVICE_OBJECT DeviceObject;
3049 ULONG Flags;
3050 PVOID DriverStart;
3051 ULONG DriverSize;
3052 PVOID DriverSection;
3053 PDRIVER_EXTENSION DriverExtension;
3054 UNICODE_STRING DriverName;
3055 PUNICODE_STRING HardwareDatabase;
3056 PFAST_IO_DISPATCH FastIoDispatch;
3057 PDRIVER_INITIALIZE DriverInit;
3058 PDRIVER_STARTIO DriverStartIo;
3059 PDRIVER_UNLOAD DriverUnload;
3060 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
3061 } DRIVER_OBJECT;
3062 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
3063
3064 typedef struct _SECTION_OBJECT_POINTERS {
3065 PVOID DataSectionObject;
3066 PVOID SharedCacheMap;
3067 PVOID ImageSectionObject;
3068 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
3069
3070 typedef struct _IO_COMPLETION_CONTEXT {
3071 PVOID Port;
3072 PVOID Key;
3073 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
3074
3075 /* FILE_OBJECT.Flags */
3076
3077 #define FO_FILE_OPEN 0x00000001
3078 #define FO_SYNCHRONOUS_IO 0x00000002
3079 #define FO_ALERTABLE_IO 0x00000004
3080 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
3081 #define FO_WRITE_THROUGH 0x00000010
3082 #define FO_SEQUENTIAL_ONLY 0x00000020
3083 #define FO_CACHE_SUPPORTED 0x00000040
3084 #define FO_NAMED_PIPE 0x00000080
3085 #define FO_STREAM_FILE 0x00000100
3086 #define FO_MAILSLOT 0x00000200
3087 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
3088 #define FO_DIRECT_DEVICE_OPEN 0x00000800
3089 #define FO_FILE_MODIFIED 0x00001000
3090 #define FO_FILE_SIZE_CHANGED 0x00002000
3091 #define FO_CLEANUP_COMPLETE 0x00004000
3092 #define FO_TEMPORARY_FILE 0x00008000
3093 #define FO_DELETE_ON_CLOSE 0x00010000
3094 #define FO_OPENED_CASE_SENSITIVE 0x00020000
3095 #define FO_HANDLE_CREATED 0x00040000
3096 #define FO_FILE_FAST_IO_READ 0x00080000
3097 #define FO_RANDOM_ACCESS 0x00100000
3098 #define FO_FILE_OPEN_CANCELLED 0x00200000
3099 #define FO_VOLUME_OPEN 0x00400000
3100 #define FO_FILE_OBJECT_HAS_EXTENSION 0x00800000
3101 #define FO_REMOTE_ORIGIN 0x01000000
3102
3103 typedef struct _FILE_OBJECT {
3104 CSHORT Type;
3105 CSHORT Size;
3106 PDEVICE_OBJECT DeviceObject;
3107 PVPB Vpb;
3108 PVOID FsContext;
3109 PVOID FsContext2;
3110 PSECTION_OBJECT_POINTERS SectionObjectPointer;
3111 PVOID PrivateCacheMap;
3112 NTSTATUS FinalStatus;
3113 struct _FILE_OBJECT *RelatedFileObject;
3114 BOOLEAN LockOperation;
3115 BOOLEAN DeletePending;
3116 BOOLEAN ReadAccess;
3117 BOOLEAN WriteAccess;
3118 BOOLEAN DeleteAccess;
3119 BOOLEAN SharedRead;
3120 BOOLEAN SharedWrite;
3121 BOOLEAN SharedDelete;
3122 ULONG Flags;
3123 UNICODE_STRING FileName;
3124 LARGE_INTEGER CurrentByteOffset;
3125 ULONG Waiters;
3126 ULONG Busy;
3127 PVOID LastLock;
3128 KEVENT Lock;
3129 KEVENT Event;
3130 PIO_COMPLETION_CONTEXT CompletionContext;
3131 } FILE_OBJECT;
3132 typedef struct _FILE_OBJECT *PFILE_OBJECT;
3133
3134 typedef enum _SECURITY_OPERATION_CODE {
3135 SetSecurityDescriptor,
3136 QuerySecurityDescriptor,
3137 DeleteSecurityDescriptor,
3138 AssignSecurityDescriptor
3139 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
3140
3141 #define INITIAL_PRIVILEGE_COUNT 3
3142
3143 typedef struct _INITIAL_PRIVILEGE_SET {
3144 ULONG PrivilegeCount;
3145 ULONG Control;
3146 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
3147 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
3148
3149 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
3150 #define SE_CREATE_TOKEN_PRIVILEGE 2
3151 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
3152 #define SE_LOCK_MEMORY_PRIVILEGE 4
3153 #define SE_INCREASE_QUOTA_PRIVILEGE 5
3154 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
3155 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
3156 #define SE_TCB_PRIVILEGE 7
3157 #define SE_SECURITY_PRIVILEGE 8
3158 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
3159 #define SE_LOAD_DRIVER_PRIVILEGE 10
3160 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
3161 #define SE_SYSTEMTIME_PRIVILEGE 12
3162 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
3163 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
3164 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
3165 #define SE_CREATE_PERMANENT_PRIVILEGE 16
3166 #define SE_BACKUP_PRIVILEGE 17
3167 #define SE_RESTORE_PRIVILEGE 18
3168 #define SE_SHUTDOWN_PRIVILEGE 19
3169 #define SE_DEBUG_PRIVILEGE 20
3170 #define SE_AUDIT_PRIVILEGE 21
3171 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
3172 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
3173 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
3174 #define SE_UNDOCK_PRIVILEGE 25
3175 #define SE_SYNC_AGENT_PRIVILEGE 26
3176 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
3177 #define SE_MANAGE_VOLUME_PRIVILEGE 28
3178 #define SE_IMPERSONATE_PRIVILEGE 29
3179 #define SE_CREATE_GLOBAL_PRIVILEGE 30
3180 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_GLOBAL_PRIVILEGE
3181
3182 typedef struct _SECURITY_SUBJECT_CONTEXT {
3183 PACCESS_TOKEN ClientToken;
3184 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3185 PACCESS_TOKEN PrimaryToken;
3186 PVOID ProcessAuditId;
3187 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
3188
3189 #include <pshpack4.h>
3190 typedef struct _ACCESS_STATE {
3191 LUID OperationID;
3192 BOOLEAN SecurityEvaluated;
3193 BOOLEAN GenerateAudit;
3194 BOOLEAN GenerateOnClose;
3195 BOOLEAN PrivilegesAllocated;
3196 ULONG Flags;
3197 ACCESS_MASK RemainingDesiredAccess;
3198 ACCESS_MASK PreviouslyGrantedAccess;
3199 ACCESS_MASK OriginalDesiredAccess;
3200 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
3201 PSECURITY_DESCRIPTOR SecurityDescriptor;
3202 PVOID AuxData;
3203 union {
3204 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
3205 PRIVILEGE_SET PrivilegeSet;
3206 } Privileges;
3207
3208 BOOLEAN AuditPrivileges;
3209 UNICODE_STRING ObjectName;
3210 UNICODE_STRING ObjectTypeName;
3211 } ACCESS_STATE, *PACCESS_STATE;
3212 #include <poppack.h>
3213
3214 typedef struct _IO_SECURITY_CONTEXT {
3215 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
3216 PACCESS_STATE AccessState;
3217 ACCESS_MASK DesiredAccess;
3218 ULONG FullCreateOptions;
3219 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
3220
3221 #define IO_TYPE_ADAPTER 1
3222 #define IO_TYPE_CONTROLLER 2
3223 #define IO_TYPE_DEVICE 3
3224 #define IO_TYPE_DRIVER 4
3225 #define IO_TYPE_FILE 5
3226 #define IO_TYPE_IRP 6
3227 #define IO_TYPE_MASTER_ADAPTER 7
3228 #define IO_TYPE_OPEN_PACKET 8
3229 #define IO_TYPE_TIMER 9
3230 #define IO_TYPE_VPB 10
3231 #define IO_TYPE_ERROR_LOG 11
3232 #define IO_TYPE_ERROR_MESSAGE 12
3233 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
3234
3235 #define IO_TYPE_CSQ_IRP_CONTEXT 1
3236 #define IO_TYPE_CSQ 2
3237
3238 struct _IO_CSQ;
3239
3240 typedef struct _IO_CSQ_IRP_CONTEXT {
3241 ULONG Type;
3242 struct _IRP *Irp;
3243 struct _IO_CSQ *Csq;
3244 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
3245
3246 typedef VOID
3247 (DDKAPI *PIO_CSQ_INSERT_IRP)(
3248 IN struct _IO_CSQ *Csq,
3249 IN PIRP Irp);
3250
3251 typedef VOID
3252 (DDKAPI *PIO_CSQ_REMOVE_IRP)(
3253 IN struct _IO_CSQ *Csq,
3254 IN PIRP Irp);
3255
3256 typedef PIRP
3257 (DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
3258 IN struct _IO_CSQ *Csq,
3259 IN PIRP Irp,
3260 IN PVOID PeekContext);
3261
3262 typedef VOID
3263 (DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
3264 IN struct _IO_CSQ *Csq,
3265 OUT PKIRQL Irql);
3266
3267 typedef VOID
3268 (DDKAPI *PIO_CSQ_RELEASE_LOCK)(
3269 IN struct _IO_CSQ *Csq,
3270 IN KIRQL Irql);
3271
3272 typedef VOID
3273 (DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
3274 IN struct _IO_CSQ *Csq,
3275 IN PIRP Irp);
3276
3277 typedef struct _IO_CSQ {
3278 ULONG Type;
3279 PIO_CSQ_INSERT_IRP CsqInsertIrp;
3280 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
3281 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
3282 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
3283 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
3284 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
3285 PVOID ReservePointer;
3286 } IO_CSQ, *PIO_CSQ;
3287
3288 #if !defined(_ALPHA_)
3289 #include <pshpack4.h>
3290 #endif
3291 typedef struct _IO_STACK_LOCATION {
3292 UCHAR MajorFunction;
3293 UCHAR MinorFunction;
3294 UCHAR Flags;
3295 UCHAR Control;
3296 union {
3297 struct {
3298 PIO_SECURITY_CONTEXT SecurityContext;
3299 ULONG Options;
3300 USHORT POINTER_ALIGNMENT FileAttributes;
3301 USHORT ShareAccess;
3302 ULONG POINTER_ALIGNMENT EaLength;
3303 } Create;
3304 struct {
3305 ULONG Length;
3306 ULONG POINTER_ALIGNMENT Key;
3307 LARGE_INTEGER ByteOffset;
3308 } Read;
3309 struct {
3310 ULONG Length;
3311 ULONG POINTER_ALIGNMENT Key;
3312 LARGE_INTEGER ByteOffset;
3313 } Write;
3314 struct {
3315 ULONG Length;
3316 PUNICODE_STRING FileName;
3317 FILE_INFORMATION_CLASS FileInformationClass;
3318 ULONG FileIndex;
3319 } QueryDirectory;
3320 struct {
3321 ULONG Length;
3322 ULONG CompletionFilter;
3323 } NotifyDirectory;
3324 struct {
3325 ULONG Length;
3326 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
3327 } QueryFile;
3328 struct {
3329 ULONG Length;
3330 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
3331 PFILE_OBJECT FileObject;
3332 _ANONYMOUS_UNION union {
3333 _ANONYMOUS_STRUCT struct {
3334 BOOLEAN ReplaceIfExists;
3335 BOOLEAN AdvanceOnly;
3336 } DUMMYSTRUCTNAME;
3337 ULONG ClusterCount;
3338 HANDLE DeleteHandle;
3339 } DUMMYUNIONNAME;
3340 } SetFile;
3341 struct {
3342 ULONG Length;
3343 PVOID EaList;
3344 ULONG EaListLength;
3345 ULONG EaIndex;
3346 } QueryEa;
3347 struct {
3348 ULONG Length;
3349 } SetEa;
3350 struct {
3351 ULONG Length;
3352 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
3353 } QueryVolume;
3354 struct {
3355 ULONG Length;
3356 FS_INFORMATION_CLASS FsInformationClass;
3357 } SetVolume;
3358 struct {
3359 ULONG OutputBufferLength;
3360 ULONG InputBufferLength;
3361 ULONG FsControlCode;
3362 PVOID Type3InputBuffer;
3363 } FileSystemControl;
3364 struct {
3365 PLARGE_INTEGER Length;
3366 ULONG Key;
3367 LARGE_INTEGER ByteOffset;
3368 } LockControl;
3369 struct {
3370 ULONG OutputBufferLength;
3371 ULONG POINTER_ALIGNMENT InputBufferLength;
3372 ULONG POINTER_ALIGNMENT IoControlCode;
3373 PVOID Type3InputBuffer;
3374 } DeviceIoControl;
3375 struct {
3376 SECURITY_INFORMATION SecurityInformation;
3377 ULONG POINTER_ALIGNMENT Length;
3378 } QuerySecurity;
3379 struct {
3380 SECURITY_INFORMATION SecurityInformation;
3381 PSECURITY_DESCRIPTOR SecurityDescriptor;
3382 } SetSecurity;
3383 struct {
3384 PVPB Vpb;
3385 PDEVICE_OBJECT DeviceObject;
3386 } MountVolume;
3387 struct {
3388 PVPB Vpb;
3389 PDEVICE_OBJECT DeviceObject;
3390 } VerifyVolume;
3391 struct {
3392 struct _SCSI_REQUEST_BLOCK *Srb;
3393 } Scsi;
3394 struct {
3395 ULONG Length;
3396 PSID StartSid;
3397 struct _FILE_GET_QUOTA_INFORMATION *SidList;
3398 ULONG SidListLength;
3399 } QueryQuota;
3400 struct {
3401 ULONG Length;
3402 } SetQuota;
3403 struct {
3404 DEVICE_RELATION_TYPE Type;
3405 } QueryDeviceRelations;
3406 struct {
3407 CONST GUID *InterfaceType;
3408 USHORT Size;
3409 USHORT Version;
3410 PINTERFACE Interface;
3411 PVOID InterfaceSpecificData;
3412 } QueryInterface;
3413 struct {
3414 PDEVICE_CAPABILITIES Capabilities;
3415 } DeviceCapabilities;
3416 struct {
3417 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
3418 } FilterResourceRequirements;
3419 struct {
3420 ULONG WhichSpace;
3421 PVOID Buffer;
3422 ULONG Offset;
3423 ULONG POINTER_ALIGNMENT Length;
3424 } ReadWriteConfig;
3425 struct {
3426 BOOLEAN Lock;
3427 } SetLock;
3428 struct {
3429 BUS_QUERY_ID_TYPE IdType;
3430 } QueryId;
3431 struct {
3432 DEVICE_TEXT_TYPE DeviceTextType;
3433 LCID POINTER_ALIGNMENT LocaleId;
3434 } QueryDeviceText;
3435 struct {
3436 BOOLEAN InPath;
3437 BOOLEAN Reserved[3];
3438 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
3439 } UsageNotification;
3440 struct {
3441 SYSTEM_POWER_STATE PowerState;
3442 } WaitWake;
3443 struct {
3444 PPOWER_SEQUENCE PowerSequence;
3445 } PowerSequence;
3446 struct {
3447 ULONG SystemContext;
3448 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
3449 POWER_STATE POINTER_ALIGNMENT State;
3450 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
3451 } Power;
3452 struct {
3453 PCM_RESOURCE_LIST AllocatedResources;
3454 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
3455 } StartDevice;
3456 struct {
3457 ULONG_PTR ProviderId;
3458 PVOID DataPath;
3459 ULONG BufferSize;
3460 PVOID Buffer;
3461 } WMI;
3462 struct {
3463 PVOID Argument1;
3464 PVOID Argument2;
3465 PVOID Argument3;
3466 PVOID Argument4;
3467 } Others;
3468 } Parameters;
3469 PDEVICE_OBJECT DeviceObject;
3470 PFILE_OBJECT FileObject;
3471 PIO_COMPLETION_ROUTINE CompletionRoutine;
3472 PVOID Context;
3473 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
3474 #if !defined(_ALPHA_)
3475 #include <poppack.h>
3476 #endif
3477
3478 /* IO_STACK_LOCATION.Control */
3479
3480 #define SL_PENDING_RETURNED 0x01
3481 #define SL_INVOKE_ON_CANCEL 0x20
3482 #define SL_INVOKE_ON_SUCCESS 0x40
3483 #define SL_INVOKE_ON_ERROR 0x80
3484
3485 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
3486
3487 #define PCI_WHICHSPACE_CONFIG 0x0
3488 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
3489
3490 typedef enum _KEY_INFORMATION_CLASS {
3491 KeyBasicInformation,
3492 KeyNodeInformation,
3493 KeyFullInformation,
3494 KeyNameInformation,
3495 KeyCachedInformation,
3496 KeyFlagsInformation
3497 } KEY_INFORMATION_CLASS;
3498
3499 typedef struct _KEY_BASIC_INFORMATION {
3500 LARGE_INTEGER LastWriteTime;
3501 ULONG TitleIndex;
3502 ULONG NameLength;
3503 WCHAR Name[1];
3504 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
3505
3506 typedef struct _KEY_FULL_INFORMATION {
3507 LARGE_INTEGER LastWriteTime;
3508 ULONG TitleIndex;
3509 ULONG ClassOffset;
3510 ULONG ClassLength;
3511 ULONG SubKeys;
3512 ULONG MaxNameLen;
3513 ULONG MaxClassLen;
3514 ULONG Values;
3515 ULONG MaxValueNameLen;
3516 ULONG MaxValueDataLen;
3517 WCHAR Class[1];
3518 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
3519
3520 typedef struct _KEY_NODE_INFORMATION {
3521 LARGE_INTEGER LastWriteTime;
3522 ULONG TitleIndex;
3523 ULONG ClassOffset;
3524 ULONG ClassLength;
3525 ULONG NameLength;
3526 WCHAR Name[1];
3527 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
3528
3529 typedef struct _KEY_VALUE_BASIC_INFORMATION {
3530 ULONG TitleIndex;
3531 ULONG Type;
3532 ULONG NameLength;
3533 WCHAR Name[1];
3534 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
3535
3536 typedef struct _KEY_VALUE_FULL_INFORMATION {
3537 ULONG TitleIndex;
3538 ULONG Type;
3539 ULONG DataOffset;
3540 ULONG DataLength;
3541 ULONG NameLength;
3542 WCHAR Name[1];
3543 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
3544
3545 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
3546 ULONG TitleIndex;
3547 ULONG Type;
3548 ULONG DataLength;
3549 UCHAR Data[1];
3550 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
3551
3552 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
3553 ULONG Type;
3554 ULONG DataLength;
3555 UCHAR Data[1];
3556 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
3557
3558 typedef struct _KEY_VALUE_ENTRY {
3559 PUNICODE_STRING ValueName;
3560 ULONG DataLength;
3561 ULONG DataOffset;
3562 ULONG Type;
3563 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
3564
3565 typedef enum _KEY_VALUE_INFORMATION_CLASS {
3566 KeyValueBasicInformation,
3567 KeyValueFullInformation,
3568 KeyValuePartialInformation,
3569 KeyValueFullInformationAlign64,
3570 KeyValuePartialInformationAlign64
3571 } KEY_VALUE_INFORMATION_CLASS;
3572
3573 typedef struct _KEY_WRITE_TIME_INFORMATION {
3574 LARGE_INTEGER LastWriteTime;
3575 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
3576
3577 typedef struct _KEY_USER_FLAGS_INFORMATION {
3578 ULONG UserFlags;
3579 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
3580
3581 typedef enum _KEY_SET_INFORMATION_CLASS {
3582 KeyWriteTimeInformation,
3583 KeyUserFlagsInformation,
3584 MaxKeySetInfoClass
3585 } KEY_SET_INFORMATION_CLASS;
3586
3587 #define REG_CREATED_NEW_KEY 0x00000001L
3588 #define REG_OPENED_EXISTING_KEY 0x00000002L
3589
3590
3591 /* KEY_VALUE_Xxx.Type */
3592
3593 #define REG_NONE 0
3594 #define REG_SZ 1
3595 #define REG_EXPAND_SZ 2
3596 #define REG_BINARY 3
3597 #define REG_DWORD 4
3598 #define REG_DWORD_LITTLE_ENDIAN 4
3599 #define REG_DWORD_BIG_ENDIAN 5
3600 #define REG_LINK 6
3601 #define REG_MULTI_SZ 7
3602 #define REG_RESOURCE_LIST 8
3603 #define REG_FULL_RESOURCE_DESCRIPTOR 9
3604 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3605 #define REG_QWORD 11
3606 #define REG_QWORD_LITTLE_ENDIAN 11
3607
3608 #define PCI_TYPE0_ADDRESSES 6
3609 #define PCI_TYPE1_ADDRESSES 2
3610 #define PCI_TYPE2_ADDRESSES 5
3611
3612 typedef struct _PCI_COMMON_CONFIG {
3613 USHORT VendorID;
3614 USHORT DeviceID;
3615 USHORT Command;
3616 USHORT Status;
3617 UCHAR RevisionID;
3618 UCHAR ProgIf;
3619 UCHAR SubClass;
3620 UCHAR BaseClass;
3621 UCHAR CacheLineSize;
3622 UCHAR LatencyTimer;
3623 UCHAR HeaderType;
3624 UCHAR BIST;
3625 union {
3626 struct _PCI_HEADER_TYPE_0 {
3627 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
3628 ULONG CIS;
3629 USHORT SubVendorID;
3630 USHORT SubSystemID;
3631 ULONG ROMBaseAddress;
3632 UCHAR CapabilitiesPtr;
3633 UCHAR Reserved1[3];
3634 ULONG Reserved2;
3635 UCHAR InterruptLine;
3636 UCHAR InterruptPin;
3637 UCHAR MinimumGrant;
3638 UCHAR MaximumLatency;
3639 } type0;
3640 struct _PCI_HEADER_TYPE_1 {
3641 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
3642 UCHAR PrimaryBus;
3643 UCHAR SecondaryBus;
3644 UCHAR SubordinateBus;
3645 UCHAR SecondaryLatency;
3646 UCHAR IOBase;
3647 UCHAR IOLimit;
3648 USHORT SecondaryStatus;
3649 USHORT MemoryBase;
3650 USHORT MemoryLimit;
3651 USHORT PrefetchBase;
3652 USHORT PrefetchLimit;
3653 ULONG PrefetchBaseUpper32;
3654 ULONG PrefetchLimitUpper32;
3655 USHORT IOBaseUpper16;
3656 USHORT IOLimitUpper16;
3657 UCHAR CapabilitiesPtr;
3658 UCHAR Reserved1[3];
3659 ULONG ROMBaseAddress;
3660 UCHAR InterruptLine;
3661 UCHAR InterruptPin;
3662 USHORT BridgeControl;
3663 } type1;
3664 struct _PCI_HEADER_TYPE_2 {
3665 ULONG SocketRegistersBaseAddress;
3666 UCHAR CapabilitiesPtr;
3667 UCHAR Reserved;
3668 USHORT SecondaryStatus;
3669 UCHAR PrimaryBus;
3670 UCHAR SecondaryBus;
3671 UCHAR SubordinateBus;
3672 UCHAR SecondaryLatency;
3673 struct {
3674 ULONG Base;
3675 ULONG Limit;
3676 } Range[PCI_TYPE2_ADDRESSES - 1];
3677 UCHAR InterruptLine;
3678 UCHAR InterruptPin;
3679 USHORT BridgeControl;
3680 } type2;
3681 } u;
3682 UCHAR DeviceSpecific[192];
3683 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3684
3685 /* PCI_COMMON_CONFIG.Command */
3686
3687 #define PCI_ENABLE_IO_SPACE 0x0001
3688 #define PCI_ENABLE_MEMORY_SPACE 0x0002
3689 #define PCI_ENABLE_BUS_MASTER 0x0004
3690 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
3691 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
3692 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
3693 #define PCI_ENABLE_PARITY 0x0040
3694 #define PCI_ENABLE_WAIT_CYCLE 0x0080
3695 #define PCI_ENABLE_SERR 0x0100
3696 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
3697
3698 /* PCI_COMMON_CONFIG.Status */
3699
3700 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
3701 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
3702 #define PCI_STATUS_UDF_SUPPORTED 0x0040
3703 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
3704 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
3705 #define PCI_STATUS_DEVSEL 0x0600
3706 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
3707 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
3708 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
3709 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
3710 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
3711
3712 /* PCI_COMMON_CONFIG.HeaderType */
3713
3714 #define PCI_MULTIFUNCTION 0x80
3715 #define PCI_DEVICE_TYPE 0x00
3716 #define PCI_BRIDGE_TYPE 0x01
3717 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
3718
3719 #define PCI_CONFIGURATION_TYPE(PciData) \
3720 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
3721
3722 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
3723 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
3724
3725 /* PCI device classes */
3726
3727 #define PCI_CLASS_PRE_20 0x00
3728 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
3729 #define PCI_CLASS_NETWORK_CTLR 0x02
3730 #define PCI_CLASS_DISPLAY_CTLR 0x03
3731 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
3732 #define PCI_CLASS_MEMORY_CTLR 0x05
3733 #define PCI_CLASS_BRIDGE_DEV 0x06
3734 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
3735 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
3736 #define PCI_CLASS_INPUT_DEV 0x09
3737 #define PCI_CLASS_DOCKING_STATION 0x0a
3738 #define PCI_CLASS_PROCESSOR 0x0b
3739 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
3740
3741 /* PCI device subclasses for class 0 */
3742
3743 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
3744 #define PCI_SUBCLASS_PRE_20_VGA 0x01
3745
3746 /* PCI device subclasses for class 1 (mass storage controllers)*/
3747
3748 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
3749 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
3750 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
3751 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
3752 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
3753 #define PCI_SUBCLASS_MSC_OTHER 0x80
3754
3755 /* PCI device subclasses for class 2 (network controllers)*/
3756
3757 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
3758 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
3759 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
3760 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
3761 #define PCI_SUBCLASS_NET_OTHER 0x80
3762
3763 /* PCI device subclasses for class 3 (display controllers)*/
3764
3765 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
3766 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
3767 #define PCI_SUBLCASS_VID_3D_CTLR 0x02
3768 #define PCI_SUBCLASS_VID_OTHER 0x80
3769
3770 /* PCI device subclasses for class 4 (multimedia device)*/
3771
3772 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
3773 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
3774 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
3775 #define PCI_SUBCLASS_MM_OTHER 0x80
3776
3777 /* PCI device subclasses for class 5 (memory controller)*/
3778
3779 #define PCI_SUBCLASS_MEM_RAM 0x00
3780 #define PCI_SUBCLASS_MEM_FLASH 0x01
3781 #define PCI_SUBCLASS_MEM_OTHER 0x80
3782
3783 /* PCI device subclasses for class 6 (bridge device)*/
3784
3785 #define PCI_SUBCLASS_BR_HOST 0x00
3786 #define PCI_SUBCLASS_BR_ISA 0x01
3787 #define PCI_SUBCLASS_BR_EISA 0x02
3788 #define PCI_SUBCLASS_BR_MCA 0x03
3789 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
3790 #define PCI_SUBCLASS_BR_PCMCIA 0x05
3791 #define PCI_SUBCLASS_BR_NUBUS 0x06
3792 #define PCI_SUBCLASS_BR_CARDBUS 0x07
3793 #define PCI_SUBCLASS_BR_OTHER 0x80
3794
3795 /* PCI device subclasses for class C (serial bus controller)*/
3796
3797 #define PCI_SUBCLASS_SB_IEEE1394 0x00
3798 #define PCI_SUBCLASS_SB_ACCESS 0x01
3799 #define PCI_SUBCLASS_SB_SSA 0x02
3800 #define PCI_SUBCLASS_SB_USB 0x03
3801 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
3802
3803 #define PCI_MAX_DEVICES 32
3804 #define PCI_MAX_FUNCTION 8
3805 #define PCI_MAX_BRIDGE_NUMBER 0xFF
3806 #define PCI_INVALID_VENDORID 0xFFFF
3807 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
3808
3809 #define PCI_ADDRESS_IO_SPACE 0x01
3810 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x06
3811 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x08
3812 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
3813 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
3814 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
3815
3816 #define PCI_TYPE_32BIT 0
3817 #define PCI_TYPE_20BIT 2
3818 #define PCI_TYPE_64BIT 4
3819
3820 typedef struct _PCI_SLOT_NUMBER {
3821 union {
3822 struct {
3823 ULONG DeviceNumber : 5;
3824 ULONG FunctionNumber : 3;
3825 ULONG Reserved : 24;
3826 } bits;
3827 ULONG AsULONG;
3828 } u;
3829 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
3830
3831 typedef enum _POOL_TYPE {
3832 NonPagedPool,
3833 PagedPool,
3834 NonPagedPoolMustSucceed,
3835 DontUseThisType,
3836 NonPagedPoolCacheAligned,
3837 PagedPoolCacheAligned,
3838 NonPagedPoolCacheAlignedMustS,
3839 MaxPoolType,
3840 NonPagedPoolSession = 32,
3841 PagedPoolSession,
3842 NonPagedPoolMustSucceedSession,
3843 DontUseThisTypeSession,
3844 NonPagedPoolCacheAlignedSession,
3845 PagedPoolCacheAlignedSession,
3846 NonPagedPoolCacheAlignedMustSSession
3847 } POOL_TYPE;
3848
3849 typedef enum _EX_POOL_PRIORITY {
3850 LowPoolPriority,
3851 LowPoolPrioritySpecialPoolOverrun = 8,
3852 LowPoolPrioritySpecialPoolUnderrun = 9,
3853 NormalPoolPriority = 16,
3854 NormalPoolPrioritySpecialPoolOverrun = 24,
3855 NormalPoolPrioritySpecialPoolUnderrun = 25,
3856 HighPoolPriority = 32,
3857 HighPoolPrioritySpecialPoolOverrun = 40,
3858 HighPoolPrioritySpecialPoolUnderrun = 41
3859 } EX_POOL_PRIORITY;
3860
3861 /* PRIVILEGE_SET.Control */
3862
3863 #define PRIVILEGE_SET_ALL_NECESSARY 1
3864
3865 typedef struct _RTL_OSVERSIONINFOW {
3866 ULONG dwOSVersionInfoSize;
3867 ULONG dwMajorVersion;
3868 ULONG dwMinorVersion;
3869 ULONG dwBuildNumber;
3870 ULONG dwPlatformId;
3871 WCHAR szCSDVersion[128];
3872 } RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
3873
3874 typedef struct _RTL_OSVERSIONINFOEXW {
3875 ULONG dwOSVersionInfoSize;
3876 ULONG dwMajorVersion;
3877 ULONG dwMinorVersion;
3878 ULONG dwBuildNumber;
3879 ULONG dwPlatformId;
3880 WCHAR szCSDVersion[128];
3881 USHORT wServicePackMajor;
3882 USHORT wServicePackMinor;
3883 USHORT wSuiteMask;
3884 UCHAR wProductType;
3885 UCHAR wReserved;
3886 } RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
3887
3888 NTOSAPI
3889 ULONGLONG
3890 DDKAPI
3891 VerSetConditionMask(
3892 IN ULONGLONG ConditionMask,
3893 IN ULONG TypeMask,
3894 IN UCHAR Condition);
3895
3896 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
3897 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
3898 (TypeBitMask), (ComparisonType)))
3899
3900 /* RtlVerifyVersionInfo() TypeMask */
3901
3902 #define VER_MINORVERSION 0x0000001
3903 #define VER_MAJORVERSION 0x0000002
3904 #define VER_BUILDNUMBER 0x0000004
3905 #define VER_PLATFORMID 0x0000008
3906 #define VER_SERVICEPACKMINOR 0x0000010
3907 #define VER_SERVICEPACKMAJOR 0x0000020
3908 #define VER_SUITENAME 0x0000040
3909 #define VER_PRODUCT_TYPE 0x0000080
3910
3911 /* RtlVerifyVersionInfo() ComparisonType */
3912
3913 #define VER_EQUAL 1
3914 #define VER_GREATER 2
3915 #define VER_GREATER_EQUAL 3
3916 #define VER_LESS 4
3917 #define VER_LESS_EQUAL 5
3918 #define VER_AND 6
3919 #define VER_OR 7
3920
3921 #define VER_CONDITION_MASK 7
3922 #define VER_NUM_BITS_PER_CONDITION_MASK 3
3923
3924 typedef struct _RTL_BITMAP {
3925 ULONG SizeOfBitMap;
3926 PULONG Buffer;
3927 } RTL_BITMAP, *PRTL_BITMAP;
3928
3929 typedef struct _RTL_BITMAP_RUN {
3930 ULONG StartingIndex;
3931 ULONG NumberOfBits;
3932 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
3933
3934 typedef struct _RTL_RANGE_LIST
3935 {
3936 LIST_ENTRY ListHead;
3937 ULONG Flags; /* RTL_RANGE_LIST_... flags */
3938 ULONG Count;
3939 ULONG Stamp;
3940 } RTL_RANGE_LIST, *PRTL_RANGE_LIST;
3941
3942 typedef struct _RTL_RANGE
3943 {
3944 ULONGLONG Start;
3945 ULONGLONG End;
3946 PVOID UserData;
3947 PVOID Owner;
3948 UCHAR Attributes;
3949 UCHAR Flags; /* RTL_RANGE_... flags */
3950 } RTL_RANGE, *PRTL_RANGE;
3951
3952 typedef struct _RANGE_LIST_ITERATOR
3953 {
3954 PLIST_ENTRY RangeListHead;
3955 PLIST_ENTRY MergedHead;
3956 PVOID Current;
3957 ULONG Stamp;
3958 } RTL_RANGE_LIST_ITERATOR, *PRTL_RANGE_LIST_ITERATOR;
3959
3960 typedef BOOLEAN
3961 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK) (
3962 PVOID Context,
3963 struct _RTL_RANGE *Range
3964 );
3965
3966 typedef NTSTATUS
3967 (DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
3968 IN PWSTR ValueName,
3969 IN ULONG ValueType,
3970 IN PVOID ValueData,
3971 IN ULONG ValueLength,
3972 IN PVOID Context,
3973 IN PVOID EntryContext);
3974
3975 #define RTL_REGISTRY_ABSOLUTE 0
3976 #define RTL_REGISTRY_SERVICES 1
3977 #define RTL_REGISTRY_CONTROL 2
3978 #define RTL_REGISTRY_WINDOWS_NT 3
3979 #define RTL_REGISTRY_DEVICEMAP 4
3980 #define RTL_REGISTRY_USER 5
3981 #define RTL_REGISTRY_HANDLE 0x40000000
3982 #define RTL_REGISTRY_OPTIONAL 0x80000000
3983
3984 /* RTL_QUERY_REGISTRY_TABLE.Flags */
3985 #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001
3986 #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002
3987 #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004
3988 #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008
3989 #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010
3990 #define RTL_QUERY_REGISTRY_DIRECT 0x00000020
3991 #define RTL_QUERY_REGISTRY_DELETE 0x00000040
3992
3993 typedef struct _RTL_QUERY_REGISTRY_TABLE {
3994 PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
3995 ULONG Flags;
3996 PWSTR Name;
3997 PVOID EntryContext;
3998 ULONG DefaultType;
3999 PVOID DefaultData;
4000 ULONG DefaultLength;
4001 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
4002
4003 typedef struct _TIME_FIELDS {
4004 CSHORT Year;
4005 CSHORT Month;
4006 CSHORT Day;
4007 CSHORT Hour;
4008 CSHORT Minute;
4009 CSHORT Second;
4010 CSHORT Milliseconds;
4011 CSHORT Weekday;
4012 } TIME_FIELDS, *PTIME_FIELDS;
4013
4014 typedef PVOID
4015 (DDKAPI *PALLOCATE_FUNCTION)(
4016 IN POOL_TYPE PoolType,
4017 IN SIZE_T NumberOfBytes,
4018 IN ULONG Tag);
4019
4020 typedef VOID
4021 (DDKAPI *PFREE_FUNCTION)(
4022 IN PVOID Buffer);
4023
4024 typedef struct _GENERAL_LOOKASIDE {
4025 SLIST_HEADER ListHead;
4026 USHORT Depth;
4027 USHORT MaximumDepth;
4028 ULONG TotalAllocates;
4029 union {
4030 ULONG AllocateMisses;
4031 ULONG AllocateHits;
4032 };
4033 ULONG TotalFrees;
4034 union {
4035 ULONG FreeMisses;
4036 ULONG FreeHits;
4037 };
4038 POOL_TYPE Type;
4039 ULONG Tag;
4040 ULONG Size;
4041 PALLOCATE_FUNCTION Allocate;
4042 PFREE_FUNCTION Free;
4043 LIST_ENTRY ListEntry;
4044 ULONG LastTotalAllocates;
4045 union {
4046 ULONG LastAllocateMisses;
4047 ULONG LastAllocateHits;
4048 };
4049 ULONG Future[2];
4050 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
4051
4052 typedef struct _NPAGED_LOOKASIDE_LIST {
4053 GENERAL_LOOKASIDE L;
4054 KSPIN_LOCK Obsoleted;
4055 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
4056
4057 typedef struct _PAGED_LOOKASIDE_LIST {
4058 GENERAL_LOOKASIDE L;
4059 FAST_MUTEX Obsoleted;
4060 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
4061
4062 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
4063
4064 typedef VOID
4065 (DDKAPI *PCALLBACK_FUNCTION)(
4066 IN PVOID CallbackContext,
4067 IN PVOID Argument1,
4068 IN PVOID Argument2);
4069
4070 typedef enum _EVENT_TYPE {
4071 NotificationEvent,
4072 SynchronizationEvent
4073 } EVENT_TYPE;
4074
4075 typedef enum _KWAIT_REASON {
4076 Executive,
4077 FreePage,
4078 PageIn,
4079 PoolAllocation,
4080 DelayExecution,
4081 Suspended,
4082 UserRequest,
4083 WrExecutive,
4084 WrFreePage,
4085 WrPageIn,
4086 WrPoolAllocation,
4087 WrDelayExecution,
4088 WrSuspended,
4089 WrUserRequest,
4090 WrEventPair,
4091 WrQueue,
4092 WrLpcReceive,
4093 WrLpcReply,
4094 WrVirtualMemory,
4095 WrPageOut,
4096 WrRendezvous,
4097 Spare2,
4098 WrGuardedMutex,
4099 Spare4,
4100 Spare5,
4101 Spare6,
4102 WrKernel,
4103 WrResource,
4104 WrPushLock,
4105 WrMutex,
4106 WrQuantumEnd,
4107 WrDispatchInt,
4108 WrPreempted,
4109 WrYieldExecution,
4110 MaximumWaitReason
4111 } KWAIT_REASON;
4112
4113 typedef struct _KWAIT_BLOCK {
4114 LIST_ENTRY WaitListEntry;
4115 struct _KTHREAD * RESTRICTED_POINTER Thread;
4116 PVOID Object;
4117 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
4118 USHORT WaitKey;
4119 USHORT WaitType;
4120 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
4121
4122 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
4123
4124 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
4125 BOOLEAN Removed;
4126 BOOLEAN Reserved[3];
4127 LONG IoCount;
4128 KEVENT RemoveEvent;
4129 } IO_REMOVE_LOCK_COMMON_BLOCK;
4130
4131 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
4132 LONG Signature;
4133 LONG HighWatermark;
4134 LONGLONG MaxLockedTicks;
4135 LONG AllocateTag;
4136 LIST_ENTRY LockList;
4137 KSPIN_LOCK Spin;
4138 LONG LowMemoryCount;
4139 ULONG Reserved1[4];
4140 PVOID Reserved2;
4141 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
4142 } IO_REMOVE_LOCK_DBG_BLOCK;
4143
4144 typedef struct _IO_REMOVE_LOCK {
4145 IO_REMOVE_LOCK_COMMON_BLOCK Common;
4146 #ifdef DBG
4147 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
4148 #endif
4149 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
4150
4151 typedef struct _IO_WORKITEM *PIO_WORKITEM;
4152
4153 typedef VOID
4154 (DDKAPI *PIO_WORKITEM_ROUTINE)(
4155 IN PDEVICE_OBJECT DeviceObject,
4156 IN PVOID Context);
4157
4158 typedef struct _SHARE_ACCESS {
4159 ULONG OpenCount;
4160 ULONG Readers;
4161 ULONG Writers;
4162 ULONG Deleters;
4163 ULONG SharedRead;
4164 ULONG SharedWrite;
4165 ULONG SharedDelete;
4166 } SHARE_ACCESS, *PSHARE_ACCESS;
4167
4168 typedef enum _KINTERRUPT_MODE {
4169 LevelSensitive,
4170 Latched
4171 } KINTERRUPT_MODE;
4172
4173 #define THREAD_WAIT_OBJECTS 3
4174
4175 typedef VOID
4176 (DDKAPI *PKINTERRUPT_ROUTINE)(
4177 VOID);
4178
4179 typedef enum _KPROFILE_SOURCE {
4180 ProfileTime,
4181 ProfileAlignmentFixup,
4182 ProfileTotalIssues,
4183 ProfilePipelineDry,
4184 ProfileLoadInstructions,
4185 ProfilePipelineFrozen,
4186 ProfileBranchInstructions,
4187 ProfileTotalNonissues,
4188 ProfileDcacheMisses,
4189 ProfileIcacheMisses,
4190 ProfileCacheMisses,
4191 ProfileBranchMispredictions,
4192 ProfileStoreInstructions,
4193 ProfileFpInstructions,
4194 ProfileIntegerInstructions,
4195 Profile2Issue,
4196 Profile3Issue,
4197 Profile4Issue,
4198 ProfileSpecialInstructions,
4199 ProfileTotalCycles,
4200 ProfileIcacheIssues,
4201 ProfileDcacheAccesses,
4202 ProfileMemoryBarrierCycles,
4203 ProfileLoadLinkedIssues,
4204 ProfileMaximum
4205 } KPROFILE_SOURCE;
4206
4207 typedef enum _CREATE_FILE_TYPE {
4208 CreateFileTypeNone,
4209 CreateFileTypeNamedPipe,
4210 CreateFileTypeMailslot
4211 } CREATE_FILE_TYPE;
4212
4213 typedef struct _CONFIGURATION_INFORMATION {
4214 ULONG DiskCount;
4215 ULONG FloppyCount;
4216 ULONG CdRomCount;
4217 ULONG TapeCount;
4218 ULONG ScsiPortCount;
4219 ULONG SerialCount;
4220 ULONG ParallelCount;
4221 BOOLEAN AtDiskPrimaryAddressClaimed;
4222 BOOLEAN AtDiskSecondaryAddressClaimed;
4223 ULONG Version;
4224 ULONG MediumChangerCount;
4225 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
4226
4227 typedef enum _CONFIGURATION_TYPE {
4228 ArcSystem,
4229 CentralProcessor,
4230 FloatingPointProcessor,
4231 PrimaryIcache,
4232 PrimaryDcache,
4233 SecondaryIcache,
4234 SecondaryDcache,
4235 SecondaryCache,
4236 EisaAdapter,
4237 TcAdapter,
4238 ScsiAdapter,
4239 DtiAdapter,
4240 MultiFunctionAdapter,
4241 DiskController,
4242 TapeController,
4243 CdromController,
4244 WormController,
4245 SerialController,
4246 NetworkController,
4247 DisplayController,
4248 ParallelController,
4249 PointerController,
4250 KeyboardController,
4251 AudioController,
4252 OtherController,
4253 DiskPeripheral,
4254 FloppyDiskPeripheral,
4255 TapePeripheral,
4256 ModemPeripheral,
4257 MonitorPeripheral,
4258 PrinterPeripheral,
4259 PointerPeripheral,
4260 KeyboardPeripheral,
4261 TerminalPeripheral,
4262 OtherPeripheral,
4263 LinePeripheral,
4264 NetworkPeripheral,
4265 SystemMemory,
4266 DockingInformation,
4267 RealModeIrqRoutingTable,
4268 MaximumType
4269 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
4270
4271 #define IO_FORCE_ACCESS_CHECK 0x001
4272 #define IO_NO_PARAMETER_CHECKING 0x100
4273
4274 typedef NTSTATUS
4275 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
4276 IN PVOID Context,
4277 IN PUNICODE_STRING PathName,
4278 IN INTERFACE_TYPE BusType,
4279 IN ULONG BusNumber,
4280 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
4281 IN CONFIGURATION_TYPE ControllerType,
4282 IN ULONG ControllerNumber,
4283 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
4284 IN CONFIGURATION_TYPE PeripheralType,
4285 IN ULONG PeripheralNumber,
4286 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
4287
4288 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
4289 IoQueryDeviceIdentifier = 0,
4290 IoQueryDeviceConfigurationData,
4291 IoQueryDeviceComponentInformation,
4292 IoQueryDeviceMaxData
4293 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
4294
4295 typedef enum _WORK_QUEUE_TYPE {
4296 CriticalWorkQueue,
4297 DelayedWorkQueue,
4298 HyperCriticalWorkQueue,
4299 MaximumWorkQueue
4300 } WORK_QUEUE_TYPE;
4301
4302 typedef VOID
4303 (DDKAPI *PWORKER_THREAD_ROUTINE)(
4304 IN PVOID Parameter);
4305
4306 typedef struct _WORK_QUEUE_ITEM {
4307 LIST_ENTRY List;
4308 PWORKER_THREAD_ROUTINE WorkerRoutine;
4309 PVOID Parameter;