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