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