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