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