73d0fe3bff0364135b64e4c524ea246b910a82b4
[reactos.git] / include / xdk / iotypes.h
1 /******************************************************************************
2 * I/O Manager Types *
3 ******************************************************************************/
4
5 #define WDM_MAJORVERSION 0x06
6 #define WDM_MINORVERSION 0x00
7
8 #if defined(_WIN64)
9
10 #ifndef USE_DMA_MACROS
11 #define USE_DMA_MACROS
12 #endif
13
14 #ifndef NO_LEGACY_DRIVERS
15 #define NO_LEGACY_DRIVERS
16 #endif
17
18 #endif /* defined(_WIN64) */
19
20 #define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS
21
22 #define CONNECT_FULLY_SPECIFIED 0x1
23 #define CONNECT_LINE_BASED 0x2
24 #define CONNECT_MESSAGE_BASED 0x3
25 #define CONNECT_FULLY_SPECIFIED_GROUP 0x4
26 #define CONNECT_CURRENT_VERSION 0x4
27
28 /* PCI_COMMON_CONFIG.Command */
29 #define PCI_ENABLE_IO_SPACE 0x0001
30 #define PCI_ENABLE_MEMORY_SPACE 0x0002
31 #define PCI_ENABLE_BUS_MASTER 0x0004
32 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
33 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
34 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
35 #define PCI_ENABLE_PARITY 0x0040
36 #define PCI_ENABLE_WAIT_CYCLE 0x0080
37 #define PCI_ENABLE_SERR 0x0100
38 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
39 #define PCI_DISABLE_LEVEL_INTERRUPT 0x0400
40
41 /* PCI_COMMON_CONFIG.Status */
42 #define PCI_STATUS_INTERRUPT_PENDING 0x0008
43 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
44 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
45 #define PCI_STATUS_UDF_SUPPORTED 0x0040
46 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
47 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
48 #define PCI_STATUS_DEVSEL 0x0600
49 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
50 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
51 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
52 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
53 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
54
55 /* PCI_COMMON_CONFIG.HeaderType */
56 #define PCI_MULTIFUNCTION 0x80
57 #define PCI_DEVICE_TYPE 0x00
58 #define PCI_BRIDGE_TYPE 0x01
59 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
60
61 #define PCI_CONFIGURATION_TYPE(PciData) \
62 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
63
64 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
65 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
66
67 /* PCI device classes */
68 #define PCI_CLASS_PRE_20 0x00
69 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
70 #define PCI_CLASS_NETWORK_CTLR 0x02
71 #define PCI_CLASS_DISPLAY_CTLR 0x03
72 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
73 #define PCI_CLASS_MEMORY_CTLR 0x05
74 #define PCI_CLASS_BRIDGE_DEV 0x06
75 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
76 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
77 #define PCI_CLASS_INPUT_DEV 0x09
78 #define PCI_CLASS_DOCKING_STATION 0x0a
79 #define PCI_CLASS_PROCESSOR 0x0b
80 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
81 #define PCI_CLASS_WIRELESS_CTLR 0x0d
82 #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
83 #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
84 #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
85 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
86
87 /* PCI device subclasses for class 0 */
88 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
89 #define PCI_SUBCLASS_PRE_20_VGA 0x01
90
91 /* PCI device subclasses for class 1 (mass storage controllers)*/
92 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
93 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
94 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
95 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
96 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
97 #define PCI_SUBCLASS_MSC_OTHER 0x80
98
99 /* PCI device subclasses for class 2 (network controllers)*/
100 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
101 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
102 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
103 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
104 #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
105 #define PCI_SUBCLASS_NET_OTHER 0x80
106
107 /* PCI device subclasses for class 3 (display controllers)*/
108 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
109 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
110 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
111 #define PCI_SUBCLASS_VID_OTHER 0x80
112
113 /* PCI device subclasses for class 4 (multimedia device)*/
114 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
115 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
116 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
117 #define PCI_SUBCLASS_MM_OTHER 0x80
118
119 /* PCI device subclasses for class 5 (memory controller)*/
120 #define PCI_SUBCLASS_MEM_RAM 0x00
121 #define PCI_SUBCLASS_MEM_FLASH 0x01
122 #define PCI_SUBCLASS_MEM_OTHER 0x80
123
124 /* PCI device subclasses for class 6 (bridge device)*/
125 #define PCI_SUBCLASS_BR_HOST 0x00
126 #define PCI_SUBCLASS_BR_ISA 0x01
127 #define PCI_SUBCLASS_BR_EISA 0x02
128 #define PCI_SUBCLASS_BR_MCA 0x03
129 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
130 #define PCI_SUBCLASS_BR_PCMCIA 0x05
131 #define PCI_SUBCLASS_BR_NUBUS 0x06
132 #define PCI_SUBCLASS_BR_CARDBUS 0x07
133 #define PCI_SUBCLASS_BR_RACEWAY 0x08
134 #define PCI_SUBCLASS_BR_OTHER 0x80
135
136 /* PCI device subclasses for class C (serial bus controller)*/
137 #define PCI_SUBCLASS_SB_IEEE1394 0x00
138 #define PCI_SUBCLASS_SB_ACCESS 0x01
139 #define PCI_SUBCLASS_SB_SSA 0x02
140 #define PCI_SUBCLASS_SB_USB 0x03
141 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
142 #define PCI_SUBCLASS_SB_SMBUS 0x05
143
144 #define PCI_MAX_DEVICES 32
145 #define PCI_MAX_FUNCTION 8
146 #define PCI_MAX_BRIDGE_NUMBER 0xFF
147 #define PCI_INVALID_VENDORID 0xFFFF
148 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
149
150 #define PCI_ADDRESS_IO_SPACE 0x00000001
151 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
152 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
153 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
154 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
155 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
156
157 #define PCI_TYPE_32BIT 0
158 #define PCI_TYPE_20BIT 2
159 #define PCI_TYPE_64BIT 4
160
161 #define POOL_COLD_ALLOCATION 256
162 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
163 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
164
165 #define PCI_TYPE0_ADDRESSES 6
166 #define PCI_TYPE1_ADDRESSES 2
167 #define PCI_TYPE2_ADDRESSES 5
168
169 #define IO_TYPE_ADAPTER 1
170 #define IO_TYPE_CONTROLLER 2
171 #define IO_TYPE_DEVICE 3
172 #define IO_TYPE_DRIVER 4
173 #define IO_TYPE_FILE 5
174 #define IO_TYPE_IRP 6
175 #define IO_TYPE_MASTER_ADAPTER 7
176 #define IO_TYPE_OPEN_PACKET 8
177 #define IO_TYPE_TIMER 9
178 #define IO_TYPE_VPB 10
179 #define IO_TYPE_ERROR_LOG 11
180 #define IO_TYPE_ERROR_MESSAGE 12
181 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
182
183 #define IO_TYPE_CSQ_IRP_CONTEXT 1
184 #define IO_TYPE_CSQ 2
185 #define IO_TYPE_CSQ_EX 3
186
187 /* IO_RESOURCE_DESCRIPTOR.Option */
188 #define IO_RESOURCE_PREFERRED 0x01
189 #define IO_RESOURCE_DEFAULT 0x02
190 #define IO_RESOURCE_ALTERNATIVE 0x08
191
192 /* DEVICE_OBJECT.Flags */
193 #define DO_VERIFY_VOLUME 0x00000002
194 #define DO_BUFFERED_IO 0x00000004
195 #define DO_EXCLUSIVE 0x00000008
196 #define DO_DIRECT_IO 0x00000010
197 #define DO_MAP_IO_BUFFER 0x00000020
198 #define DO_DEVICE_INITIALIZING 0x00000080
199 #define DO_SHUTDOWN_REGISTERED 0x00000800
200 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
201 #define DO_POWER_PAGABLE 0x00002000
202 #define DO_POWER_INRUSH 0x00004000
203
204 /* DEVICE_OBJECT.Characteristics */
205 #define FILE_REMOVABLE_MEDIA 0x00000001
206 #define FILE_READ_ONLY_DEVICE 0x00000002
207 #define FILE_FLOPPY_DISKETTE 0x00000004
208 #define FILE_WRITE_ONCE_MEDIA 0x00000008
209 #define FILE_REMOTE_DEVICE 0x00000010
210 #define FILE_DEVICE_IS_MOUNTED 0x00000020
211 #define FILE_VIRTUAL_VOLUME 0x00000040
212 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
213 #define FILE_DEVICE_SECURE_OPEN 0x00000100
214 #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800
215 #define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000
216 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
217
218 /* DEVICE_OBJECT.AlignmentRequirement */
219 #define FILE_BYTE_ALIGNMENT 0x00000000
220 #define FILE_WORD_ALIGNMENT 0x00000001
221 #define FILE_LONG_ALIGNMENT 0x00000003
222 #define FILE_QUAD_ALIGNMENT 0x00000007
223 #define FILE_OCTA_ALIGNMENT 0x0000000f
224 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
225 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
226 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
227 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
228 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
229
230 /* DEVICE_OBJECT.DeviceType */
231 #define DEVICE_TYPE ULONG
232
233 #define FILE_DEVICE_BEEP 0x00000001
234 #define FILE_DEVICE_CD_ROM 0x00000002
235 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
236 #define FILE_DEVICE_CONTROLLER 0x00000004
237 #define FILE_DEVICE_DATALINK 0x00000005
238 #define FILE_DEVICE_DFS 0x00000006
239 #define FILE_DEVICE_DISK 0x00000007
240 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
241 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
242 #define FILE_DEVICE_INPORT_PORT 0x0000000a
243 #define FILE_DEVICE_KEYBOARD 0x0000000b
244 #define FILE_DEVICE_MAILSLOT 0x0000000c
245 #define FILE_DEVICE_MIDI_IN 0x0000000d
246 #define FILE_DEVICE_MIDI_OUT 0x0000000e
247 #define FILE_DEVICE_MOUSE 0x0000000f
248 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
249 #define FILE_DEVICE_NAMED_PIPE 0x00000011
250 #define FILE_DEVICE_NETWORK 0x00000012
251 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
252 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
253 #define FILE_DEVICE_NULL 0x00000015
254 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
255 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
256 #define FILE_DEVICE_PRINTER 0x00000018
257 #define FILE_DEVICE_SCANNER 0x00000019
258 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
259 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
260 #define FILE_DEVICE_SCREEN 0x0000001c
261 #define FILE_DEVICE_SOUND 0x0000001d
262 #define FILE_DEVICE_STREAMS 0x0000001e
263 #define FILE_DEVICE_TAPE 0x0000001f
264 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
265 #define FILE_DEVICE_TRANSPORT 0x00000021
266 #define FILE_DEVICE_UNKNOWN 0x00000022
267 #define FILE_DEVICE_VIDEO 0x00000023
268 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
269 #define FILE_DEVICE_WAVE_IN 0x00000025
270 #define FILE_DEVICE_WAVE_OUT 0x00000026
271 #define FILE_DEVICE_8042_PORT 0x00000027
272 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
273 #define FILE_DEVICE_BATTERY 0x00000029
274 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
275 #define FILE_DEVICE_MODEM 0x0000002b
276 #define FILE_DEVICE_VDM 0x0000002c
277 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
278 #define FILE_DEVICE_SMB 0x0000002e
279 #define FILE_DEVICE_KS 0x0000002f
280 #define FILE_DEVICE_CHANGER 0x00000030
281 #define FILE_DEVICE_SMARTCARD 0x00000031
282 #define FILE_DEVICE_ACPI 0x00000032
283 #define FILE_DEVICE_DVD 0x00000033
284 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
285 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
286 #define FILE_DEVICE_DFS_VOLUME 0x00000036
287 #define FILE_DEVICE_SERENUM 0x00000037
288 #define FILE_DEVICE_TERMSRV 0x00000038
289 #define FILE_DEVICE_KSEC 0x00000039
290 #define FILE_DEVICE_FIPS 0x0000003A
291 #define FILE_DEVICE_INFINIBAND 0x0000003B
292 #define FILE_DEVICE_VMBUS 0x0000003E
293 #define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F
294 #define FILE_DEVICE_WPD 0x00000040
295 #define FILE_DEVICE_BLUETOOTH 0x00000041
296 #define FILE_DEVICE_MT_COMPOSITE 0x00000042
297 #define FILE_DEVICE_MT_TRANSPORT 0x00000043
298 #define FILE_DEVICE_BIOMETRIC 0x00000044
299 #define FILE_DEVICE_PMI 0x00000045
300
301 #if defined(NT_PROCESSOR_GROUPS)
302
303 typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
304
305 typedef enum _IRQ_DEVICE_POLICY_USHORT {
306 IrqPolicyMachineDefault = 0,
307 IrqPolicyAllCloseProcessors = 1,
308 IrqPolicyOneCloseProcessor = 2,
309 IrqPolicyAllProcessorsInMachine = 3,
310 IrqPolicyAllProcessorsInGroup = 3,
311 IrqPolicySpecifiedProcessors = 4,
312 IrqPolicySpreadMessagesAcrossAllProcessors = 5};
313
314 #else /* defined(NT_PROCESSOR_GROUPS) */
315
316 typedef enum _IRQ_DEVICE_POLICY {
317 IrqPolicyMachineDefault = 0,
318 IrqPolicyAllCloseProcessors,
319 IrqPolicyOneCloseProcessor,
320 IrqPolicyAllProcessorsInMachine,
321 IrqPolicySpecifiedProcessors,
322 IrqPolicySpreadMessagesAcrossAllProcessors
323 } IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
324
325 #endif
326
327 typedef enum _IRQ_PRIORITY {
328 IrqPriorityUndefined = 0,
329 IrqPriorityLow,
330 IrqPriorityNormal,
331 IrqPriorityHigh
332 } IRQ_PRIORITY, *PIRQ_PRIORITY;
333
334 typedef enum _IRQ_GROUP_POLICY {
335 GroupAffinityAllGroupZero = 0,
336 GroupAffinityDontCare
337 } IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY;
338
339 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
340
341 typedef struct _OBJECT_HANDLE_INFORMATION {
342 ULONG HandleAttributes;
343 ACCESS_MASK GrantedAccess;
344 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
345
346 typedef struct _CLIENT_ID {
347 HANDLE UniqueProcess;
348 HANDLE UniqueThread;
349 } CLIENT_ID, *PCLIENT_ID;
350
351 typedef struct _VPB {
352 CSHORT Type;
353 CSHORT Size;
354 USHORT Flags;
355 USHORT VolumeLabelLength;
356 struct _DEVICE_OBJECT *DeviceObject;
357 struct _DEVICE_OBJECT *RealDevice;
358 ULONG SerialNumber;
359 ULONG ReferenceCount;
360 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
361 } VPB, *PVPB;
362
363 typedef enum _IO_ALLOCATION_ACTION {
364 KeepObject = 1,
365 DeallocateObject,
366 DeallocateObjectKeepRegisters
367 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
368
369 typedef IO_ALLOCATION_ACTION
370 (NTAPI DRIVER_CONTROL)(
371 IN struct _DEVICE_OBJECT *DeviceObject,
372 IN struct _IRP *Irp,
373 IN PVOID MapRegisterBase,
374 IN PVOID Context);
375 typedef DRIVER_CONTROL *PDRIVER_CONTROL;
376
377 typedef struct _WAIT_CONTEXT_BLOCK {
378 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
379 PDRIVER_CONTROL DeviceRoutine;
380 PVOID DeviceContext;
381 ULONG NumberOfMapRegisters;
382 PVOID DeviceObject;
383 PVOID CurrentIrp;
384 PKDPC BufferChainingDpc;
385 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
386
387 typedef struct _DEVICE_OBJECT {
388 CSHORT Type;
389 USHORT Size;
390 LONG ReferenceCount;
391 struct _DRIVER_OBJECT *DriverObject;
392 struct _DEVICE_OBJECT *NextDevice;
393 struct _DEVICE_OBJECT *AttachedDevice;
394 struct _IRP *CurrentIrp;
395 PIO_TIMER Timer;
396 ULONG Flags;
397 ULONG Characteristics;
398 volatile PVPB Vpb;
399 PVOID DeviceExtension;
400 DEVICE_TYPE DeviceType;
401 CCHAR StackSize;
402 union {
403 LIST_ENTRY ListEntry;
404 WAIT_CONTEXT_BLOCK Wcb;
405 } Queue;
406 ULONG AlignmentRequirement;
407 KDEVICE_QUEUE DeviceQueue;
408 KDPC Dpc;
409 ULONG ActiveThreadCount;
410 PSECURITY_DESCRIPTOR SecurityDescriptor;
411 KEVENT DeviceLock;
412 USHORT SectorSize;
413 USHORT Spare1;
414 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
415 PVOID Reserved;
416 } DEVICE_OBJECT, *PDEVICE_OBJECT;
417
418 typedef enum _IO_SESSION_STATE {
419 IoSessionStateCreated = 1,
420 IoSessionStateInitialized,
421 IoSessionStateConnected,
422 IoSessionStateDisconnected,
423 IoSessionStateDisconnectedLoggedOn,
424 IoSessionStateLoggedOn,
425 IoSessionStateLoggedOff,
426 IoSessionStateTerminated,
427 IoSessionStateMax
428 } IO_SESSION_STATE, *PIO_SESSION_STATE;
429
430 typedef enum _IO_COMPLETION_ROUTINE_RESULT {
431 ContinueCompletion = STATUS_CONTINUE_COMPLETION,
432 StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
433 } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
434
435 typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY {
436 PHYSICAL_ADDRESS MessageAddress;
437 KAFFINITY TargetProcessorSet;
438 PKINTERRUPT InterruptObject;
439 ULONG MessageData;
440 ULONG Vector;
441 KIRQL Irql;
442 KINTERRUPT_MODE Mode;
443 KINTERRUPT_POLARITY Polarity;
444 } IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY;
445
446 typedef struct _IO_INTERRUPT_MESSAGE_INFO {
447 KIRQL UnifiedIrql;
448 ULONG MessageCount;
449 IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1];
450 } IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO;
451
452 typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS {
453 IN PDEVICE_OBJECT PhysicalDeviceObject;
454 OUT PKINTERRUPT *InterruptObject;
455 IN PKSERVICE_ROUTINE ServiceRoutine;
456 IN PVOID ServiceContext;
457 IN PKSPIN_LOCK SpinLock OPTIONAL;
458 IN KIRQL SynchronizeIrql;
459 IN BOOLEAN FloatingSave;
460 IN BOOLEAN ShareVector;
461 IN ULONG Vector;
462 IN KIRQL Irql;
463 IN KINTERRUPT_MODE InterruptMode;
464 IN KAFFINITY ProcessorEnableMask;
465 IN USHORT Group;
466 } IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS;
467
468 typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS {
469 IN PDEVICE_OBJECT PhysicalDeviceObject;
470 OUT PKINTERRUPT *InterruptObject;
471 IN PKSERVICE_ROUTINE ServiceRoutine;
472 IN PVOID ServiceContext;
473 IN PKSPIN_LOCK SpinLock OPTIONAL;
474 IN KIRQL SynchronizeIrql OPTIONAL;
475 IN BOOLEAN FloatingSave;
476 } IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS;
477
478 typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS {
479 IN PDEVICE_OBJECT PhysicalDeviceObject;
480 union {
481 OUT PVOID *Generic;
482 OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable;
483 OUT PKINTERRUPT *InterruptObject;
484 } ConnectionContext;
485 IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine;
486 IN PVOID ServiceContext;
487 IN PKSPIN_LOCK SpinLock OPTIONAL;
488 IN KIRQL SynchronizeIrql OPTIONAL;
489 IN BOOLEAN FloatingSave;
490 IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL;
491 } IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS;
492
493 typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS {
494 IN OUT ULONG Version;
495 union {
496 IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified;
497 IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased;
498 IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased;
499 };
500 } IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS;
501
502 typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS {
503 IN ULONG Version;
504 union {
505 IN PVOID Generic;
506 IN PKINTERRUPT InterruptObject;
507 IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable;
508 } ConnectionContext;
509 } IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS;
510
511 typedef enum _IO_ACCESS_TYPE {
512 ReadAccess,
513 WriteAccess,
514 ModifyAccess
515 } IO_ACCESS_TYPE;
516
517 typedef enum _IO_ACCESS_MODE {
518 SequentialAccess,
519 RandomAccess
520 } IO_ACCESS_MODE;
521
522 typedef enum _IO_CONTAINER_NOTIFICATION_CLASS {
523 IoSessionStateNotification,
524 IoMaxContainerNotificationClass
525 } IO_CONTAINER_NOTIFICATION_CLASS;
526
527 typedef struct _IO_SESSION_STATE_NOTIFICATION {
528 ULONG Size;
529 ULONG Flags;
530 PVOID IoObject;
531 ULONG EventMask;
532 PVOID Context;
533 } IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION;
534
535 typedef enum _IO_CONTAINER_INFORMATION_CLASS {
536 IoSessionStateInformation,
537 IoMaxContainerInformationClass
538 } IO_CONTAINER_INFORMATION_CLASS;
539
540 typedef struct _IO_SESSION_STATE_INFORMATION {
541 ULONG SessionId;
542 IO_SESSION_STATE SessionState;
543 BOOLEAN LocalSession;
544 } IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION;
545
546 #if (NTDDI_VERSION >= NTDDI_WIN7)
547
548 typedef NTSTATUS
549 (NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)(
550 VOID);
551
552 typedef NTSTATUS
553 (NTAPI IO_SESSION_NOTIFICATION_FUNCTION)(
554 IN PVOID SessionObject,
555 IN PVOID IoObject,
556 IN ULONG Event,
557 IN PVOID Context,
558 IN PVOID NotificationPayload,
559 IN ULONG PayloadLength);
560
561 typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION;
562
563 #endif
564
565 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
566
567 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
568 BOOLEAN Removed;
569 BOOLEAN Reserved[3];
570 volatile LONG IoCount;
571 KEVENT RemoveEvent;
572 } IO_REMOVE_LOCK_COMMON_BLOCK;
573
574 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
575 LONG Signature;
576 LONG HighWatermark;
577 LONGLONG MaxLockedTicks;
578 LONG AllocateTag;
579 LIST_ENTRY LockList;
580 KSPIN_LOCK Spin;
581 volatile LONG LowMemoryCount;
582 ULONG Reserved1[4];
583 PVOID Reserved2;
584 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
585 } IO_REMOVE_LOCK_DBG_BLOCK;
586
587 typedef struct _IO_REMOVE_LOCK {
588 IO_REMOVE_LOCK_COMMON_BLOCK Common;
589 #if DBG
590 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
591 #endif
592 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
593
594 typedef struct _IO_WORKITEM *PIO_WORKITEM;
595
596 typedef VOID
597 (NTAPI IO_WORKITEM_ROUTINE)(
598 IN PDEVICE_OBJECT DeviceObject,
599 IN PVOID Context);
600 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
601
602 typedef VOID
603 (NTAPI IO_WORKITEM_ROUTINE_EX)(
604 IN PVOID IoObject,
605 IN PVOID Context OPTIONAL,
606 IN PIO_WORKITEM IoWorkItem);
607 typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX;
608
609 typedef struct _SHARE_ACCESS {
610 ULONG OpenCount;
611 ULONG Readers;
612 ULONG Writers;
613 ULONG Deleters;
614 ULONG SharedRead;
615 ULONG SharedWrite;
616 ULONG SharedDelete;
617 } SHARE_ACCESS, *PSHARE_ACCESS;
618
619 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
620 inheritance, even from a struct renders the type non-POD. So we use
621 this hack */
622 #define PCI_COMMON_HEADER_LAYOUT \
623 USHORT VendorID; \
624 USHORT DeviceID; \
625 USHORT Command; \
626 USHORT Status; \
627 UCHAR RevisionID; \
628 UCHAR ProgIf; \
629 UCHAR SubClass; \
630 UCHAR BaseClass; \
631 UCHAR CacheLineSize; \
632 UCHAR LatencyTimer; \
633 UCHAR HeaderType; \
634 UCHAR BIST; \
635 union { \
636 struct _PCI_HEADER_TYPE_0 { \
637 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \
638 ULONG CIS; \
639 USHORT SubVendorID; \
640 USHORT SubSystemID; \
641 ULONG ROMBaseAddress; \
642 UCHAR CapabilitiesPtr; \
643 UCHAR Reserved1[3]; \
644 ULONG Reserved2; \
645 UCHAR InterruptLine; \
646 UCHAR InterruptPin; \
647 UCHAR MinimumGrant; \
648 UCHAR MaximumLatency; \
649 } type0; \
650 struct _PCI_HEADER_TYPE_1 { \
651 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \
652 UCHAR PrimaryBus; \
653 UCHAR SecondaryBus; \
654 UCHAR SubordinateBus; \
655 UCHAR SecondaryLatency; \
656 UCHAR IOBase; \
657 UCHAR IOLimit; \
658 USHORT SecondaryStatus; \
659 USHORT MemoryBase; \
660 USHORT MemoryLimit; \
661 USHORT PrefetchBase; \
662 USHORT PrefetchLimit; \
663 ULONG PrefetchBaseUpper32; \
664 ULONG PrefetchLimitUpper32; \
665 USHORT IOBaseUpper16; \
666 USHORT IOLimitUpper16; \
667 UCHAR CapabilitiesPtr; \
668 UCHAR Reserved1[3]; \
669 ULONG ROMBaseAddress; \
670 UCHAR InterruptLine; \
671 UCHAR InterruptPin; \
672 USHORT BridgeControl; \
673 } type1; \
674 struct _PCI_HEADER_TYPE_2 { \
675 ULONG SocketRegistersBaseAddress; \
676 UCHAR CapabilitiesPtr; \
677 UCHAR Reserved; \
678 USHORT SecondaryStatus; \
679 UCHAR PrimaryBus; \
680 UCHAR SecondaryBus; \
681 UCHAR SubordinateBus; \
682 UCHAR SecondaryLatency; \
683 struct { \
684 ULONG Base; \
685 ULONG Limit; \
686 } Range[PCI_TYPE2_ADDRESSES-1]; \
687 UCHAR InterruptLine; \
688 UCHAR InterruptPin; \
689 USHORT BridgeControl; \
690 } type2; \
691 } u;
692
693 typedef struct _PCI_CAPABILITIES_HEADER {
694 UCHAR CapabilityID;
695 UCHAR Next;
696 } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
697
698 typedef struct _PCI_COMMON_HEADER {
699 PCI_COMMON_HEADER_LAYOUT
700 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
701
702 #ifdef __cplusplus
703 typedef struct _PCI_COMMON_CONFIG {
704 PCI_COMMON_HEADER_LAYOUT
705 UCHAR DeviceSpecific[192];
706 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
707 #else
708 typedef struct _PCI_COMMON_CONFIG {
709 PCI_COMMON_HEADER DUMMYSTRUCTNAME;
710 UCHAR DeviceSpecific[192];
711 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
712 #endif
713
714 typedef enum _CREATE_FILE_TYPE {
715 CreateFileTypeNone,
716 CreateFileTypeNamedPipe,
717 CreateFileTypeMailslot
718 } CREATE_FILE_TYPE;
719
720 #define IO_FORCE_ACCESS_CHECK 0x001
721 #define IO_NO_PARAMETER_CHECKING 0x100
722
723 #define IO_REPARSE 0x0
724 #define IO_REMOUNT 0x1
725
726 typedef struct _IO_STATUS_BLOCK {
727 _ANONYMOUS_UNION union {
728 NTSTATUS Status;
729 PVOID Pointer;
730 } DUMMYUNIONNAME;
731 ULONG_PTR Information;
732 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
733
734 #if defined(_WIN64)
735 typedef struct _IO_STATUS_BLOCK32 {
736 NTSTATUS Status;
737 ULONG Information;
738 } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
739 #endif
740
741 typedef struct _PCI_SLOT_NUMBER {
742 union {
743 struct {
744 ULONG DeviceNumber:5;
745 ULONG FunctionNumber:3;
746 ULONG Reserved:24;
747 } bits;
748 ULONG AsULONG;
749 } u;
750 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
751
752 typedef VOID
753 (NTAPI *PIO_APC_ROUTINE)(
754 IN PVOID ApcContext,
755 IN PIO_STATUS_BLOCK IoStatusBlock,
756 IN ULONG Reserved);
757
758 #define PIO_APC_ROUTINE_DEFINED
759
760 typedef enum _IO_SESSION_EVENT {
761 IoSessionEventIgnore = 0,
762 IoSessionEventCreated,
763 IoSessionEventTerminated,
764 IoSessionEventConnected,
765 IoSessionEventDisconnected,
766 IoSessionEventLogon,
767 IoSessionEventLogoff,
768 IoSessionEventMax
769 } IO_SESSION_EVENT, *PIO_SESSION_EVENT;
770
771 #define IO_SESSION_STATE_ALL_EVENTS 0xffffffff
772 #define IO_SESSION_STATE_CREATION_EVENT 0x00000001
773 #define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002
774 #define IO_SESSION_STATE_CONNECT_EVENT 0x00000004
775 #define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008
776 #define IO_SESSION_STATE_LOGON_EVENT 0x00000010
777 #define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020
778
779 #define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f
780
781 #define IO_SESSION_MAX_PAYLOAD_SIZE 256L
782
783 typedef struct _IO_SESSION_CONNECT_INFO {
784 ULONG SessionId;
785 BOOLEAN LocalSession;
786 } IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO;
787
788 #define EVENT_INCREMENT 1
789 #define IO_NO_INCREMENT 0
790 #define IO_CD_ROM_INCREMENT 1
791 #define IO_DISK_INCREMENT 1
792 #define IO_KEYBOARD_INCREMENT 6
793 #define IO_MAILSLOT_INCREMENT 2
794 #define IO_MOUSE_INCREMENT 6
795 #define IO_NAMED_PIPE_INCREMENT 2
796 #define IO_NETWORK_INCREMENT 2
797 #define IO_PARALLEL_INCREMENT 1
798 #define IO_SERIAL_INCREMENT 2
799 #define IO_SOUND_INCREMENT 8
800 #define IO_VIDEO_INCREMENT 1
801 #define SEMAPHORE_INCREMENT 1
802
803 #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
804
805 typedef struct _BOOTDISK_INFORMATION {
806 LONGLONG BootPartitionOffset;
807 LONGLONG SystemPartitionOffset;
808 ULONG BootDeviceSignature;
809 ULONG SystemDeviceSignature;
810 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
811
812 typedef struct _BOOTDISK_INFORMATION_EX {
813 LONGLONG BootPartitionOffset;
814 LONGLONG SystemPartitionOffset;
815 ULONG BootDeviceSignature;
816 ULONG SystemDeviceSignature;
817 GUID BootDeviceGuid;
818 GUID SystemDeviceGuid;
819 BOOLEAN BootDeviceIsGpt;
820 BOOLEAN SystemDeviceIsGpt;
821 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
822
823 #if (NTDDI_VERSION >= NTDDI_WIN7)
824
825 typedef struct _LOADER_PARTITION_INFORMATION_EX {
826 ULONG PartitionStyle;
827 ULONG PartitionNumber;
828 union {
829 ULONG Signature;
830 GUID DeviceId;
831 };
832 ULONG Flags;
833 } LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX;
834
835 typedef struct _BOOTDISK_INFORMATION_LITE {
836 ULONG NumberEntries;
837 LOADER_PARTITION_INFORMATION_EX Entries[1];
838 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
839
840 #else
841
842 #if (NTDDI_VERSION >= NTDDI_VISTA)
843 typedef struct _BOOTDISK_INFORMATION_LITE {
844 ULONG BootDeviceSignature;
845 ULONG SystemDeviceSignature;
846 GUID BootDeviceGuid;
847 GUID SystemDeviceGuid;
848 BOOLEAN BootDeviceIsGpt;
849 BOOLEAN SystemDeviceIsGpt;
850 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
851 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
852
853 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
854
855 #include <pshpack1.h>
856
857 typedef struct _EISA_MEMORY_TYPE {
858 UCHAR ReadWrite:1;
859 UCHAR Cached:1;
860 UCHAR Reserved0:1;
861 UCHAR Type:2;
862 UCHAR Shared:1;
863 UCHAR Reserved1:1;
864 UCHAR MoreEntries:1;
865 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
866
867 typedef struct _EISA_MEMORY_CONFIGURATION {
868 EISA_MEMORY_TYPE ConfigurationByte;
869 UCHAR DataSize;
870 USHORT AddressLowWord;
871 UCHAR AddressHighByte;
872 USHORT MemorySize;
873 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
874
875 typedef struct _EISA_IRQ_DESCRIPTOR {
876 UCHAR Interrupt:4;
877 UCHAR Reserved:1;
878 UCHAR LevelTriggered:1;
879 UCHAR Shared:1;
880 UCHAR MoreEntries:1;
881 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
882
883 typedef struct _EISA_IRQ_CONFIGURATION {
884 EISA_IRQ_DESCRIPTOR ConfigurationByte;
885 UCHAR Reserved;
886 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
887
888 typedef struct _DMA_CONFIGURATION_BYTE0 {
889 UCHAR Channel:3;
890 UCHAR Reserved:3;
891 UCHAR Shared:1;
892 UCHAR MoreEntries:1;
893 } DMA_CONFIGURATION_BYTE0;
894
895 typedef struct _DMA_CONFIGURATION_BYTE1 {
896 UCHAR Reserved0:2;
897 UCHAR TransferSize:2;
898 UCHAR Timing:2;
899 UCHAR Reserved1:2;
900 } DMA_CONFIGURATION_BYTE1;
901
902 typedef struct _EISA_DMA_CONFIGURATION {
903 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
904 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
905 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
906
907 typedef struct _EISA_PORT_DESCRIPTOR {
908 UCHAR NumberPorts:5;
909 UCHAR Reserved:1;
910 UCHAR Shared:1;
911 UCHAR MoreEntries:1;
912 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
913
914 typedef struct _EISA_PORT_CONFIGURATION {
915 EISA_PORT_DESCRIPTOR Configuration;
916 USHORT PortAddress;
917 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
918
919 typedef struct _CM_EISA_SLOT_INFORMATION {
920 UCHAR ReturnCode;
921 UCHAR ReturnFlags;
922 UCHAR MajorRevision;
923 UCHAR MinorRevision;
924 USHORT Checksum;
925 UCHAR NumberFunctions;
926 UCHAR FunctionInformation;
927 ULONG CompressedId;
928 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
929
930 typedef struct _CM_EISA_FUNCTION_INFORMATION {
931 ULONG CompressedId;
932 UCHAR IdSlotFlags1;
933 UCHAR IdSlotFlags2;
934 UCHAR MinorRevision;
935 UCHAR MajorRevision;
936 UCHAR Selections[26];
937 UCHAR FunctionFlags;
938 UCHAR TypeString[80];
939 EISA_MEMORY_CONFIGURATION EisaMemory[9];
940 EISA_IRQ_CONFIGURATION EisaIrq[7];
941 EISA_DMA_CONFIGURATION EisaDma[4];
942 EISA_PORT_CONFIGURATION EisaPort[20];
943 UCHAR InitializationData[60];
944 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
945
946 #include <poppack.h>
947
948 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
949
950 #define EISA_FUNCTION_ENABLED 0x80
951 #define EISA_FREE_FORM_DATA 0x40
952 #define EISA_HAS_PORT_INIT_ENTRY 0x20
953 #define EISA_HAS_PORT_RANGE 0x10
954 #define EISA_HAS_DMA_ENTRY 0x08
955 #define EISA_HAS_IRQ_ENTRY 0x04
956 #define EISA_HAS_MEMORY_ENTRY 0x02
957 #define EISA_HAS_TYPE_ENTRY 0x01
958 #define EISA_HAS_INFORMATION \
959 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
960 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
961
962 #define EISA_MORE_ENTRIES 0x80
963 #define EISA_SYSTEM_MEMORY 0x00
964 #define EISA_MEMORY_TYPE_RAM 0x01
965
966 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
967
968 #define EISA_INVALID_SLOT 0x80
969 #define EISA_INVALID_FUNCTION 0x81
970 #define EISA_INVALID_CONFIGURATION 0x82
971 #define EISA_EMPTY_SLOT 0x83
972 #define EISA_INVALID_BIOS_CALL 0x86
973
974 /*
975 ** Plug and Play structures
976 */
977
978 typedef VOID
979 (NTAPI *PINTERFACE_REFERENCE)(
980 PVOID Context);
981
982 typedef VOID
983 (NTAPI *PINTERFACE_DEREFERENCE)(
984 PVOID Context);
985
986 typedef BOOLEAN
987 (NTAPI *PTRANSLATE_BUS_ADDRESS)(
988 IN PVOID Context,
989 IN PHYSICAL_ADDRESS BusAddress,
990 IN ULONG Length,
991 IN OUT PULONG AddressSpace,
992 OUT PPHYSICAL_ADDRESS TranslatedAddress);
993
994 typedef struct _DMA_ADAPTER*
995 (NTAPI *PGET_DMA_ADAPTER)(
996 IN PVOID Context,
997 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
998 OUT PULONG NumberOfMapRegisters);
999
1000 typedef ULONG
1001 (NTAPI *PGET_SET_DEVICE_DATA)(
1002 IN PVOID Context,
1003 IN ULONG DataType,
1004 IN PVOID Buffer,
1005 IN ULONG Offset,
1006 IN ULONG Length);
1007
1008 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
1009 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
1010 #define PCI_USE_REVISION 0x00000002
1011 #define PCI_USE_VENDEV_IDS 0x00000004
1012 #define PCI_USE_CLASS_SUBCLASS 0x00000008
1013 #define PCI_USE_PROGIF 0x00000010
1014 #define PCI_USE_LOCAL_BUS 0x00000020
1015 #define PCI_USE_LOCAL_DEVICE 0x00000040
1016
1017 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
1018 ULONG Size;
1019 ULONG Flags;
1020 USHORT VendorID;
1021 USHORT DeviceID;
1022 UCHAR RevisionID;
1023 USHORT SubVendorID;
1024 USHORT SubSystemID;
1025 UCHAR BaseClass;
1026 UCHAR SubClass;
1027 UCHAR ProgIf;
1028 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
1029
1030 typedef BOOLEAN
1031 (NTAPI *PPCI_IS_DEVICE_PRESENT)(
1032 IN USHORT VendorID,
1033 IN USHORT DeviceID,
1034 IN UCHAR RevisionID,
1035 IN USHORT SubVendorID,
1036 IN USHORT SubSystemID,
1037 IN ULONG Flags);
1038
1039 typedef BOOLEAN
1040 (NTAPI *PPCI_IS_DEVICE_PRESENT_EX)(
1041 IN PVOID Context,
1042 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
1043
1044 typedef struct _BUS_INTERFACE_STANDARD {
1045 USHORT Size;
1046 USHORT Version;
1047 PVOID Context;
1048 PINTERFACE_REFERENCE InterfaceReference;
1049 PINTERFACE_DEREFERENCE InterfaceDereference;
1050 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
1051 PGET_DMA_ADAPTER GetDmaAdapter;
1052 PGET_SET_DEVICE_DATA SetBusData;
1053 PGET_SET_DEVICE_DATA GetBusData;
1054 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
1055
1056 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
1057 USHORT Size;
1058 USHORT Version;
1059 PVOID Context;
1060 PINTERFACE_REFERENCE InterfaceReference;
1061 PINTERFACE_DEREFERENCE InterfaceDereference;
1062 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
1063 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
1064 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
1065
1066 typedef struct _DEVICE_CAPABILITIES {
1067 USHORT Size;
1068 USHORT Version;
1069 ULONG DeviceD1:1;
1070 ULONG DeviceD2:1;
1071 ULONG LockSupported:1;
1072 ULONG EjectSupported:1;
1073 ULONG Removable:1;
1074 ULONG DockDevice:1;
1075 ULONG UniqueID:1;
1076 ULONG SilentInstall:1;
1077 ULONG RawDeviceOK:1;
1078 ULONG SurpriseRemovalOK:1;
1079 ULONG WakeFromD0:1;
1080 ULONG WakeFromD1:1;
1081 ULONG WakeFromD2:1;
1082 ULONG WakeFromD3:1;
1083 ULONG HardwareDisabled:1;
1084 ULONG NonDynamic:1;
1085 ULONG WarmEjectSupported:1;
1086 ULONG NoDisplayInUI:1;
1087 ULONG Reserved:14;
1088 ULONG Address;
1089 ULONG UINumber;
1090 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
1091 SYSTEM_POWER_STATE SystemWake;
1092 DEVICE_POWER_STATE DeviceWake;
1093 ULONG D1Latency;
1094 ULONG D2Latency;
1095 ULONG D3Latency;
1096 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
1097
1098 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
1099 USHORT Version;
1100 USHORT Size;
1101 GUID Event;
1102 GUID InterfaceClassGuid;
1103 PUNICODE_STRING SymbolicLinkName;
1104 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
1105
1106 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
1107 USHORT Version;
1108 USHORT Size;
1109 GUID Event;
1110 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
1111
1112 #undef INTERFACE
1113
1114 typedef struct _INTERFACE {
1115 USHORT Size;
1116 USHORT Version;
1117 PVOID Context;
1118 PINTERFACE_REFERENCE InterfaceReference;
1119 PINTERFACE_DEREFERENCE InterfaceDereference;
1120 } INTERFACE, *PINTERFACE;
1121
1122 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
1123 USHORT Version;
1124 USHORT Size;
1125 GUID Event;
1126 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
1127
1128 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
1129
1130 /* PNP_DEVICE_STATE */
1131
1132 #define PNP_DEVICE_DISABLED 0x00000001
1133 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
1134 #define PNP_DEVICE_FAILED 0x00000004
1135 #define PNP_DEVICE_REMOVED 0x00000008
1136 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
1137 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
1138
1139 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
1140 USHORT Version;
1141 USHORT Size;
1142 GUID Event;
1143 struct _FILE_OBJECT *FileObject;
1144 LONG NameBufferOffset;
1145 UCHAR CustomDataBuffer[1];
1146 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
1147
1148 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
1149 USHORT Version;
1150 USHORT Size;
1151 GUID Event;
1152 struct _FILE_OBJECT *FileObject;
1153 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
1154
1155 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
1156 DeviceUsageTypeUndefined,
1157 DeviceUsageTypePaging,
1158 DeviceUsageTypeHibernation,
1159 DeviceUsageTypeDumpFile
1160 } DEVICE_USAGE_NOTIFICATION_TYPE;
1161
1162 typedef struct _POWER_SEQUENCE {
1163 ULONG SequenceD1;
1164 ULONG SequenceD2;
1165 ULONG SequenceD3;
1166 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
1167
1168 typedef enum {
1169 DevicePropertyDeviceDescription = 0x0,
1170 DevicePropertyHardwareID = 0x1,
1171 DevicePropertyCompatibleIDs = 0x2,
1172 DevicePropertyBootConfiguration = 0x3,
1173 DevicePropertyBootConfigurationTranslated = 0x4,
1174 DevicePropertyClassName = 0x5,
1175 DevicePropertyClassGuid = 0x6,
1176 DevicePropertyDriverKeyName = 0x7,
1177 DevicePropertyManufacturer = 0x8,
1178 DevicePropertyFriendlyName = 0x9,
1179 DevicePropertyLocationInformation = 0xa,
1180 DevicePropertyPhysicalDeviceObjectName = 0xb,
1181 DevicePropertyBusTypeGuid = 0xc,
1182 DevicePropertyLegacyBusType = 0xd,
1183 DevicePropertyBusNumber = 0xe,
1184 DevicePropertyEnumeratorName = 0xf,
1185 DevicePropertyAddress = 0x10,
1186 DevicePropertyUINumber = 0x11,
1187 DevicePropertyInstallState = 0x12,
1188 DevicePropertyRemovalPolicy = 0x13,
1189 DevicePropertyResourceRequirements = 0x14,
1190 DevicePropertyAllocatedResources = 0x15,
1191 DevicePropertyContainerID = 0x16
1192 } DEVICE_REGISTRY_PROPERTY;
1193
1194 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
1195 EventCategoryReserved,
1196 EventCategoryHardwareProfileChange,
1197 EventCategoryDeviceInterfaceChange,
1198 EventCategoryTargetDeviceChange
1199 } IO_NOTIFICATION_EVENT_CATEGORY;
1200
1201 typedef enum _IO_PRIORITY_HINT {
1202 IoPriorityVeryLow = 0,
1203 IoPriorityLow,
1204 IoPriorityNormal,
1205 IoPriorityHigh,
1206 IoPriorityCritical,
1207 MaxIoPriorityTypes
1208 } IO_PRIORITY_HINT;
1209
1210 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
1211
1212 typedef NTSTATUS
1213 (NTAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
1214 IN PVOID NotificationStructure,
1215 IN PVOID Context);
1216
1217 typedef VOID
1218 (NTAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
1219 IN PVOID Context);
1220
1221 typedef enum _FILE_INFORMATION_CLASS {
1222 FileDirectoryInformation = 1,
1223 FileFullDirectoryInformation,
1224 FileBothDirectoryInformation,
1225 FileBasicInformation,
1226 FileStandardInformation,
1227 FileInternalInformation,
1228 FileEaInformation,
1229 FileAccessInformation,
1230 FileNameInformation,
1231 FileRenameInformation,
1232 FileLinkInformation,
1233 FileNamesInformation,
1234 FileDispositionInformation,
1235 FilePositionInformation,
1236 FileFullEaInformation,
1237 FileModeInformation,
1238 FileAlignmentInformation,
1239 FileAllInformation,
1240 FileAllocationInformation,
1241 FileEndOfFileInformation,
1242 FileAlternateNameInformation,
1243 FileStreamInformation,
1244 FilePipeInformation,
1245 FilePipeLocalInformation,
1246 FilePipeRemoteInformation,
1247 FileMailslotQueryInformation,
1248 FileMailslotSetInformation,
1249 FileCompressionInformation,
1250 FileObjectIdInformation,
1251 FileCompletionInformation,
1252 FileMoveClusterInformation,
1253 FileQuotaInformation,
1254 FileReparsePointInformation,
1255 FileNetworkOpenInformation,
1256 FileAttributeTagInformation,
1257 FileTrackingInformation,
1258 FileIdBothDirectoryInformation,
1259 FileIdFullDirectoryInformation,
1260 FileValidDataLengthInformation,
1261 FileShortNameInformation,
1262 FileIoCompletionNotificationInformation,
1263 FileIoStatusBlockRangeInformation,
1264 FileIoPriorityHintInformation,
1265 FileSfioReserveInformation,
1266 FileSfioVolumeInformation,
1267 FileHardLinkInformation,
1268 FileProcessIdsUsingFileInformation,
1269 FileNormalizedNameInformation,
1270 FileNetworkPhysicalNameInformation,
1271 FileIdGlobalTxDirectoryInformation,
1272 FileIsRemoteDeviceInformation,
1273 FileAttributeCacheInformation,
1274 FileNumaNodeInformation,
1275 FileStandardLinkInformation,
1276 FileRemoteProtocolInformation,
1277 FileMaximumInformation
1278 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
1279
1280 typedef struct _FILE_POSITION_INFORMATION {
1281 LARGE_INTEGER CurrentByteOffset;
1282 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
1283
1284 typedef struct _FILE_BASIC_INFORMATION {
1285 LARGE_INTEGER CreationTime;
1286 LARGE_INTEGER LastAccessTime;
1287 LARGE_INTEGER LastWriteTime;
1288 LARGE_INTEGER ChangeTime;
1289 ULONG FileAttributes;
1290 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
1291
1292 typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION {
1293 IO_PRIORITY_HINT PriorityHint;
1294 } FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION;
1295
1296 typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION {
1297 ULONG Flags;
1298 } FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
1299
1300 typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION {
1301 PUCHAR IoStatusBlockRange;
1302 ULONG Length;
1303 } FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION;
1304
1305 typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION {
1306 BOOLEAN IsRemote;
1307 } FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION;
1308
1309 typedef struct _FILE_NUMA_NODE_INFORMATION {
1310 USHORT NodeNumber;
1311 } FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION;
1312
1313 typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION {
1314 ULONG NumberOfProcessIdsInList;
1315 ULONG_PTR ProcessIdList[1];
1316 } FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION;
1317
1318 typedef struct _FILE_STANDARD_INFORMATION {
1319 LARGE_INTEGER AllocationSize;
1320 LARGE_INTEGER EndOfFile;
1321 ULONG NumberOfLinks;
1322 BOOLEAN DeletePending;
1323 BOOLEAN Directory;
1324 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
1325
1326 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
1327 LARGE_INTEGER CreationTime;
1328 LARGE_INTEGER LastAccessTime;
1329 LARGE_INTEGER LastWriteTime;
1330 LARGE_INTEGER ChangeTime;
1331 LARGE_INTEGER AllocationSize;
1332 LARGE_INTEGER EndOfFile;
1333 ULONG FileAttributes;
1334 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
1335
1336 typedef enum _FSINFOCLASS {
1337 FileFsVolumeInformation = 1,
1338 FileFsLabelInformation,
1339 FileFsSizeInformation,
1340 FileFsDeviceInformation,
1341 FileFsAttributeInformation,
1342 FileFsControlInformation,
1343 FileFsFullSizeInformation,
1344 FileFsObjectIdInformation,
1345 FileFsDriverPathInformation,
1346 FileFsVolumeFlagsInformation,
1347 FileFsMaximumInformation
1348 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
1349
1350 typedef struct _FILE_FS_DEVICE_INFORMATION {
1351 DEVICE_TYPE DeviceType;
1352 ULONG Characteristics;
1353 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
1354
1355 typedef struct _FILE_FULL_EA_INFORMATION {
1356 ULONG NextEntryOffset;
1357 UCHAR Flags;
1358 UCHAR EaNameLength;
1359 USHORT EaValueLength;
1360 CHAR EaName[1];
1361 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
1362
1363 typedef struct _FILE_SFIO_RESERVE_INFORMATION {
1364 ULONG RequestsPerPeriod;
1365 ULONG Period;
1366 BOOLEAN RetryFailures;
1367 BOOLEAN Discardable;
1368 ULONG RequestSize;
1369 ULONG NumOutstandingRequests;
1370 } FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION;
1371
1372 typedef struct _FILE_SFIO_VOLUME_INFORMATION {
1373 ULONG MaximumRequestsPerPeriod;
1374 ULONG MinimumPeriod;
1375 ULONG MinimumTransferSize;
1376 } FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION;
1377
1378 #define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1
1379 #define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2
1380 #define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4
1381
1382 #define FM_LOCK_BIT (0x1)
1383 #define FM_LOCK_BIT_V (0x0)
1384 #define FM_LOCK_WAITER_WOKEN (0x2)
1385 #define FM_LOCK_WAITER_INC (0x4)
1386
1387 typedef BOOLEAN
1388 (NTAPI FAST_IO_CHECK_IF_POSSIBLE)(
1389 IN struct _FILE_OBJECT *FileObject,
1390 IN PLARGE_INTEGER FileOffset,
1391 IN ULONG Length,
1392 IN BOOLEAN Wait,
1393 IN ULONG LockKey,
1394 IN BOOLEAN CheckForReadOperation,
1395 OUT PIO_STATUS_BLOCK IoStatus,
1396 IN struct _DEVICE_OBJECT *DeviceObject);
1397 typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE;
1398
1399 typedef BOOLEAN
1400 (NTAPI FAST_IO_READ)(
1401 IN struct _FILE_OBJECT *FileObject,
1402 IN PLARGE_INTEGER FileOffset,
1403 IN ULONG Length,
1404 IN BOOLEAN Wait,
1405 IN ULONG LockKey,
1406 OUT PVOID Buffer,
1407 OUT PIO_STATUS_BLOCK IoStatus,
1408 IN struct _DEVICE_OBJECT *DeviceObject);
1409 typedef FAST_IO_READ *PFAST_IO_READ;
1410
1411 typedef BOOLEAN
1412 (NTAPI FAST_IO_WRITE)(
1413 IN struct _FILE_OBJECT *FileObject,
1414 IN PLARGE_INTEGER FileOffset,
1415 IN ULONG Length,
1416 IN BOOLEAN Wait,
1417 IN ULONG LockKey,
1418 IN PVOID Buffer,
1419 OUT PIO_STATUS_BLOCK IoStatus,
1420 IN struct _DEVICE_OBJECT *DeviceObject);
1421 typedef FAST_IO_WRITE *PFAST_IO_WRITE;
1422
1423 typedef BOOLEAN
1424 (NTAPI FAST_IO_QUERY_BASIC_INFO)(
1425 IN struct _FILE_OBJECT *FileObject,
1426 IN BOOLEAN Wait,
1427 OUT PFILE_BASIC_INFORMATION Buffer,
1428 OUT PIO_STATUS_BLOCK IoStatus,
1429 IN struct _DEVICE_OBJECT *DeviceObject);
1430 typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO;
1431
1432 typedef BOOLEAN
1433 (NTAPI FAST_IO_QUERY_STANDARD_INFO)(
1434 IN struct _FILE_OBJECT *FileObject,
1435 IN BOOLEAN Wait,
1436 OUT PFILE_STANDARD_INFORMATION Buffer,
1437 OUT PIO_STATUS_BLOCK IoStatus,
1438 IN struct _DEVICE_OBJECT *DeviceObject);
1439 typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO;
1440
1441 typedef BOOLEAN
1442 (NTAPI FAST_IO_LOCK)(
1443 IN struct _FILE_OBJECT *FileObject,
1444 IN PLARGE_INTEGER FileOffset,
1445 IN PLARGE_INTEGER Length,
1446 PEPROCESS ProcessId,
1447 ULONG Key,
1448 BOOLEAN FailImmediately,
1449 BOOLEAN ExclusiveLock,
1450 OUT PIO_STATUS_BLOCK IoStatus,
1451 IN struct _DEVICE_OBJECT *DeviceObject);
1452 typedef FAST_IO_LOCK *PFAST_IO_LOCK;
1453
1454 typedef BOOLEAN
1455 (NTAPI FAST_IO_UNLOCK_SINGLE)(
1456 IN struct _FILE_OBJECT *FileObject,
1457 IN PLARGE_INTEGER FileOffset,
1458 IN PLARGE_INTEGER Length,
1459 PEPROCESS ProcessId,
1460 ULONG Key,
1461 OUT PIO_STATUS_BLOCK IoStatus,
1462 IN struct _DEVICE_OBJECT *DeviceObject);
1463 typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE;
1464
1465 typedef BOOLEAN
1466 (NTAPI FAST_IO_UNLOCK_ALL)(
1467 IN struct _FILE_OBJECT *FileObject,
1468 PEPROCESS ProcessId,
1469 OUT PIO_STATUS_BLOCK IoStatus,
1470 IN struct _DEVICE_OBJECT *DeviceObject);
1471 typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL;
1472
1473 typedef BOOLEAN
1474 (NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)(
1475 IN struct _FILE_OBJECT *FileObject,
1476 PVOID ProcessId,
1477 ULONG Key,
1478 OUT PIO_STATUS_BLOCK IoStatus,
1479 IN struct _DEVICE_OBJECT *DeviceObject);
1480 typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY;
1481
1482 typedef BOOLEAN
1483 (NTAPI FAST_IO_DEVICE_CONTROL)(
1484 IN struct _FILE_OBJECT *FileObject,
1485 IN BOOLEAN Wait,
1486 IN PVOID InputBuffer OPTIONAL,
1487 IN ULONG InputBufferLength,
1488 OUT PVOID OutputBuffer OPTIONAL,
1489 IN ULONG OutputBufferLength,
1490 IN ULONG IoControlCode,
1491 OUT PIO_STATUS_BLOCK IoStatus,
1492 IN struct _DEVICE_OBJECT *DeviceObject);
1493 typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL;
1494
1495 typedef VOID
1496 (NTAPI FAST_IO_ACQUIRE_FILE)(
1497 IN struct _FILE_OBJECT *FileObject);
1498 typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE;
1499
1500 typedef VOID
1501 (NTAPI FAST_IO_RELEASE_FILE)(
1502 IN struct _FILE_OBJECT *FileObject);
1503 typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE;
1504
1505 typedef VOID
1506 (NTAPI FAST_IO_DETACH_DEVICE)(
1507 IN struct _DEVICE_OBJECT *SourceDevice,
1508 IN struct _DEVICE_OBJECT *TargetDevice);
1509 typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE;
1510
1511 typedef BOOLEAN
1512 (NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)(
1513 IN struct _FILE_OBJECT *FileObject,
1514 IN BOOLEAN Wait,
1515 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
1516 OUT struct _IO_STATUS_BLOCK *IoStatus,
1517 IN struct _DEVICE_OBJECT *DeviceObject);
1518 typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO;
1519
1520 typedef NTSTATUS
1521 (NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)(
1522 IN struct _FILE_OBJECT *FileObject,
1523 IN PLARGE_INTEGER EndingOffset,
1524 OUT struct _ERESOURCE **ResourceToRelease,
1525 IN struct _DEVICE_OBJECT *DeviceObject);
1526 typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE;
1527
1528 typedef BOOLEAN
1529 (NTAPI FAST_IO_MDL_READ)(
1530 IN struct _FILE_OBJECT *FileObject,
1531 IN PLARGE_INTEGER FileOffset,
1532 IN ULONG Length,
1533 IN ULONG LockKey,
1534 OUT PMDL *MdlChain,
1535 OUT PIO_STATUS_BLOCK IoStatus,
1536 IN struct _DEVICE_OBJECT *DeviceObject);
1537 typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ;
1538
1539 typedef BOOLEAN
1540 (NTAPI FAST_IO_MDL_READ_COMPLETE)(
1541 IN struct _FILE_OBJECT *FileObject,
1542 IN PMDL MdlChain,
1543 IN struct _DEVICE_OBJECT *DeviceObject);
1544 typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE;
1545
1546 typedef BOOLEAN
1547 (NTAPI FAST_IO_PREPARE_MDL_WRITE)(
1548 IN struct _FILE_OBJECT *FileObject,
1549 IN PLARGE_INTEGER FileOffset,
1550 IN ULONG Length,
1551 IN ULONG LockKey,
1552 OUT PMDL *MdlChain,
1553 OUT PIO_STATUS_BLOCK IoStatus,
1554 IN struct _DEVICE_OBJECT *DeviceObject);
1555 typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE;
1556
1557 typedef BOOLEAN
1558 (NTAPI FAST_IO_MDL_WRITE_COMPLETE)(
1559 IN struct _FILE_OBJECT *FileObject,
1560 IN PLARGE_INTEGER FileOffset,
1561 IN PMDL MdlChain,
1562 IN struct _DEVICE_OBJECT *DeviceObject);
1563 typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE;
1564
1565 typedef BOOLEAN
1566 (NTAPI FAST_IO_READ_COMPRESSED)(
1567 IN struct _FILE_OBJECT *FileObject,
1568 IN PLARGE_INTEGER FileOffset,
1569 IN ULONG Length,
1570 IN ULONG LockKey,
1571 OUT PVOID Buffer,
1572 OUT PMDL *MdlChain,
1573 OUT PIO_STATUS_BLOCK IoStatus,
1574 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1575 IN ULONG CompressedDataInfoLength,
1576 IN struct _DEVICE_OBJECT *DeviceObject);
1577 typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED;
1578
1579 typedef BOOLEAN
1580 (NTAPI FAST_IO_WRITE_COMPRESSED)(
1581 IN struct _FILE_OBJECT *FileObject,
1582 IN PLARGE_INTEGER FileOffset,
1583 IN ULONG Length,
1584 IN ULONG LockKey,
1585 IN PVOID Buffer,
1586 OUT PMDL *MdlChain,
1587 OUT PIO_STATUS_BLOCK IoStatus,
1588 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1589 IN ULONG CompressedDataInfoLength,
1590 IN struct _DEVICE_OBJECT *DeviceObject);
1591 typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED;
1592
1593 typedef BOOLEAN
1594 (NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
1595 IN struct _FILE_OBJECT *FileObject,
1596 IN PMDL MdlChain,
1597 IN struct _DEVICE_OBJECT *DeviceObject);
1598 typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED;
1599
1600 typedef BOOLEAN
1601 (NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
1602 IN struct _FILE_OBJECT *FileObject,
1603 IN PLARGE_INTEGER FileOffset,
1604 IN PMDL MdlChain,
1605 IN struct _DEVICE_OBJECT *DeviceObject);
1606 typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED;
1607
1608 typedef BOOLEAN
1609 (NTAPI FAST_IO_QUERY_OPEN)(
1610 IN struct _IRP *Irp,
1611 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
1612 IN struct _DEVICE_OBJECT *DeviceObject);
1613 typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN;
1614
1615 typedef NTSTATUS
1616 (NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)(
1617 IN struct _FILE_OBJECT *FileObject,
1618 IN struct _ERESOURCE *ResourceToRelease,
1619 IN struct _DEVICE_OBJECT *DeviceObject);
1620 typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE;
1621
1622 typedef NTSTATUS
1623 (NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)(
1624 IN struct _FILE_OBJECT *FileObject,
1625 IN struct _DEVICE_OBJECT *DeviceObject);
1626 typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH;
1627
1628 typedef NTSTATUS
1629 (NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)(
1630 IN struct _FILE_OBJECT *FileObject,
1631 IN struct _DEVICE_OBJECT *DeviceObject);
1632 typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH;
1633
1634 typedef struct _FAST_IO_DISPATCH {
1635 ULONG SizeOfFastIoDispatch;
1636 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
1637 PFAST_IO_READ FastIoRead;
1638 PFAST_IO_WRITE FastIoWrite;
1639 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
1640 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
1641 PFAST_IO_LOCK FastIoLock;
1642 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
1643 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
1644 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
1645 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
1646 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
1647 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
1648 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
1649 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
1650 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
1651 PFAST_IO_MDL_READ MdlRead;
1652 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
1653 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
1654 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
1655 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
1656 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
1657 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
1658 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
1659 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
1660 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
1661 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
1662 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
1663 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
1664
1665 typedef struct _SECTION_OBJECT_POINTERS {
1666 PVOID DataSectionObject;
1667 PVOID SharedCacheMap;
1668 PVOID ImageSectionObject;
1669 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
1670
1671 typedef struct _IO_COMPLETION_CONTEXT {
1672 PVOID Port;
1673 PVOID Key;
1674 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
1675
1676 /* FILE_OBJECT.Flags */
1677 #define FO_FILE_OPEN 0x00000001
1678 #define FO_SYNCHRONOUS_IO 0x00000002
1679 #define FO_ALERTABLE_IO 0x00000004
1680 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
1681 #define FO_WRITE_THROUGH 0x00000010
1682 #define FO_SEQUENTIAL_ONLY 0x00000020
1683 #define FO_CACHE_SUPPORTED 0x00000040
1684 #define FO_NAMED_PIPE 0x00000080
1685 #define FO_STREAM_FILE 0x00000100
1686 #define FO_MAILSLOT 0x00000200
1687 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
1688 #define FO_QUEUE_IRP_TO_THREAD 0x00000400
1689 #define FO_DIRECT_DEVICE_OPEN 0x00000800
1690 #define FO_FILE_MODIFIED 0x00001000
1691 #define FO_FILE_SIZE_CHANGED 0x00002000
1692 #define FO_CLEANUP_COMPLETE 0x00004000
1693 #define FO_TEMPORARY_FILE 0x00008000
1694 #define FO_DELETE_ON_CLOSE 0x00010000
1695 #define FO_OPENED_CASE_SENSITIVE 0x00020000
1696 #define FO_HANDLE_CREATED 0x00040000
1697 #define FO_FILE_FAST_IO_READ 0x00080000
1698 #define FO_RANDOM_ACCESS 0x00100000
1699 #define FO_FILE_OPEN_CANCELLED 0x00200000
1700 #define FO_VOLUME_OPEN 0x00400000
1701 #define FO_REMOTE_ORIGIN 0x01000000
1702 #define FO_DISALLOW_EXCLUSIVE 0x02000000
1703 #define FO_SKIP_COMPLETION_PORT 0x02000000
1704 #define FO_SKIP_SET_EVENT 0x04000000
1705 #define FO_SKIP_SET_FAST_IO 0x08000000
1706 #define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE
1707
1708 /* VPB.Flags */
1709 #define VPB_MOUNTED 0x0001
1710 #define VPB_LOCKED 0x0002
1711 #define VPB_PERSISTENT 0x0004
1712 #define VPB_REMOVE_PENDING 0x0008
1713 #define VPB_RAW_MOUNT 0x0010
1714 #define VPB_DIRECT_WRITES_ALLOWED 0x0020
1715
1716 /* IRP.Flags */
1717
1718 #define SL_FORCE_ACCESS_CHECK 0x01
1719 #define SL_OPEN_PAGING_FILE 0x02
1720 #define SL_OPEN_TARGET_DIRECTORY 0x04
1721 #define SL_STOP_ON_SYMLINK 0x08
1722 #define SL_CASE_SENSITIVE 0x80
1723
1724 #define SL_KEY_SPECIFIED 0x01
1725 #define SL_OVERRIDE_VERIFY_VOLUME 0x02
1726 #define SL_WRITE_THROUGH 0x04
1727 #define SL_FT_SEQUENTIAL_WRITE 0x08
1728 #define SL_FORCE_DIRECT_WRITE 0x10
1729 #define SL_REALTIME_STREAM 0x20
1730
1731 #define SL_READ_ACCESS_GRANTED 0x01
1732 #define SL_WRITE_ACCESS_GRANTED 0x04
1733
1734 #define SL_FAIL_IMMEDIATELY 0x01
1735 #define SL_EXCLUSIVE_LOCK 0x02
1736
1737 #define SL_RESTART_SCAN 0x01
1738 #define SL_RETURN_SINGLE_ENTRY 0x02
1739 #define SL_INDEX_SPECIFIED 0x04
1740
1741 #define SL_WATCH_TREE 0x01
1742
1743 #define SL_ALLOW_RAW_MOUNT 0x01
1744
1745 #define CTL_CODE(DeviceType, Function, Method, Access) \
1746 (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1747
1748 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
1749
1750 #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3))
1751
1752 #define IRP_NOCACHE 0x00000001
1753 #define IRP_PAGING_IO 0x00000002
1754 #define IRP_MOUNT_COMPLETION 0x00000002
1755 #define IRP_SYNCHRONOUS_API 0x00000004
1756 #define IRP_ASSOCIATED_IRP 0x00000008
1757 #define IRP_BUFFERED_IO 0x00000010
1758 #define IRP_DEALLOCATE_BUFFER 0x00000020
1759 #define IRP_INPUT_OPERATION 0x00000040
1760 #define IRP_SYNCHRONOUS_PAGING_IO 0x00000040
1761 #define IRP_CREATE_OPERATION 0x00000080
1762 #define IRP_READ_OPERATION 0x00000100
1763 #define IRP_WRITE_OPERATION 0x00000200
1764 #define IRP_CLOSE_OPERATION 0x00000400
1765 #define IRP_DEFER_IO_COMPLETION 0x00000800
1766 #define IRP_OB_QUERY_NAME 0x00001000
1767 #define IRP_HOLD_DEVICE_QUEUE 0x00002000
1768
1769 #define IRP_QUOTA_CHARGED 0x01
1770 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
1771 #define IRP_ALLOCATED_FIXED_SIZE 0x04
1772 #define IRP_LOOKASIDE_ALLOCATION 0x08
1773
1774 /*
1775 ** IRP function codes
1776 */
1777
1778 #define IRP_MJ_CREATE 0x00
1779 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
1780 #define IRP_MJ_CLOSE 0x02
1781 #define IRP_MJ_READ 0x03
1782 #define IRP_MJ_WRITE 0x04
1783 #define IRP_MJ_QUERY_INFORMATION 0x05
1784 #define IRP_MJ_SET_INFORMATION 0x06
1785 #define IRP_MJ_QUERY_EA 0x07
1786 #define IRP_MJ_SET_EA 0x08
1787 #define IRP_MJ_FLUSH_BUFFERS 0x09
1788 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
1789 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
1790 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
1791 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
1792 #define IRP_MJ_DEVICE_CONTROL 0x0e
1793 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
1794 #define IRP_MJ_SCSI 0x0f
1795 #define IRP_MJ_SHUTDOWN 0x10
1796 #define IRP_MJ_LOCK_CONTROL 0x11
1797 #define IRP_MJ_CLEANUP 0x12
1798 #define IRP_MJ_CREATE_MAILSLOT 0x13
1799 #define IRP_MJ_QUERY_SECURITY 0x14
1800 #define IRP_MJ_SET_SECURITY 0x15
1801 #define IRP_MJ_POWER 0x16
1802 #define IRP_MJ_SYSTEM_CONTROL 0x17
1803 #define IRP_MJ_DEVICE_CHANGE 0x18
1804 #define IRP_MJ_QUERY_QUOTA 0x19
1805 #define IRP_MJ_SET_QUOTA 0x1a
1806 #define IRP_MJ_PNP 0x1b
1807 #define IRP_MJ_PNP_POWER 0x1b
1808 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
1809
1810 #define IRP_MN_SCSI_CLASS 0x01
1811
1812 #define IRP_MN_START_DEVICE 0x00
1813 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
1814 #define IRP_MN_REMOVE_DEVICE 0x02
1815 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
1816 #define IRP_MN_STOP_DEVICE 0x04
1817 #define IRP_MN_QUERY_STOP_DEVICE 0x05
1818 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
1819
1820 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
1821 #define IRP_MN_QUERY_INTERFACE 0x08
1822 #define IRP_MN_QUERY_CAPABILITIES 0x09
1823 #define IRP_MN_QUERY_RESOURCES 0x0A
1824 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
1825 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
1826 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
1827
1828 #define IRP_MN_READ_CONFIG 0x0F
1829 #define IRP_MN_WRITE_CONFIG 0x10
1830 #define IRP_MN_EJECT 0x11
1831 #define IRP_MN_SET_LOCK 0x12
1832 #define IRP_MN_QUERY_ID 0x13
1833 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
1834 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
1835 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
1836 #define IRP_MN_SURPRISE_REMOVAL 0x17
1837 #if (NTDDI_VERSION >= NTDDI_WIN7)
1838 #define IRP_MN_DEVICE_ENUMERATED 0x19
1839 #endif
1840
1841 #define IRP_MN_WAIT_WAKE 0x00
1842 #define IRP_MN_POWER_SEQUENCE 0x01
1843 #define IRP_MN_SET_POWER 0x02
1844 #define IRP_MN_QUERY_POWER 0x03
1845
1846 #define IRP_MN_QUERY_ALL_DATA 0x00
1847 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
1848 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
1849 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
1850 #define IRP_MN_ENABLE_EVENTS 0x04
1851 #define IRP_MN_DISABLE_EVENTS 0x05
1852 #define IRP_MN_ENABLE_COLLECTION 0x06
1853 #define IRP_MN_DISABLE_COLLECTION 0x07
1854 #define IRP_MN_REGINFO 0x08
1855 #define IRP_MN_EXECUTE_METHOD 0x09
1856
1857 #define IRP_MN_REGINFO_EX 0x0b
1858
1859 typedef struct _FILE_OBJECT {
1860 CSHORT Type;
1861 CSHORT Size;
1862 PDEVICE_OBJECT DeviceObject;
1863 PVPB Vpb;
1864 PVOID FsContext;
1865 PVOID FsContext2;
1866 PSECTION_OBJECT_POINTERS SectionObjectPointer;
1867 PVOID PrivateCacheMap;
1868 NTSTATUS FinalStatus;
1869 struct _FILE_OBJECT *RelatedFileObject;
1870 BOOLEAN LockOperation;
1871 BOOLEAN DeletePending;
1872 BOOLEAN ReadAccess;
1873 BOOLEAN WriteAccess;
1874 BOOLEAN DeleteAccess;
1875 BOOLEAN SharedRead;
1876 BOOLEAN SharedWrite;
1877 BOOLEAN SharedDelete;
1878 ULONG Flags;
1879 UNICODE_STRING FileName;
1880 LARGE_INTEGER CurrentByteOffset;
1881 volatile ULONG Waiters;
1882 volatile ULONG Busy;
1883 PVOID LastLock;
1884 KEVENT Lock;
1885 KEVENT Event;
1886 volatile PIO_COMPLETION_CONTEXT CompletionContext;
1887 KSPIN_LOCK IrpListLock;
1888 LIST_ENTRY IrpList;
1889 volatile PVOID FileObjectExtension;
1890 } FILE_OBJECT, *PFILE_OBJECT;
1891
1892 typedef struct _IO_ERROR_LOG_PACKET {
1893 UCHAR MajorFunctionCode;
1894 UCHAR RetryCount;
1895 USHORT DumpDataSize;
1896 USHORT NumberOfStrings;
1897 USHORT StringOffset;
1898 USHORT EventCategory;
1899 NTSTATUS ErrorCode;
1900 ULONG UniqueErrorValue;
1901 NTSTATUS FinalStatus;
1902 ULONG SequenceNumber;
1903 ULONG IoControlCode;
1904 LARGE_INTEGER DeviceOffset;
1905 ULONG DumpData[1];
1906 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
1907
1908 typedef struct _IO_ERROR_LOG_MESSAGE {
1909 USHORT Type;
1910 USHORT Size;
1911 USHORT DriverNameLength;
1912 LARGE_INTEGER TimeStamp;
1913 ULONG DriverNameOffset;
1914 IO_ERROR_LOG_PACKET EntryData;
1915 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
1916
1917 #define ERROR_LOG_LIMIT_SIZE 240
1918 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
1919 sizeof(IO_ERROR_LOG_PACKET) + \
1920 (sizeof(WCHAR) * 40))
1921 #define ERROR_LOG_MESSAGE_LIMIT_SIZE \
1922 (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1923 #define IO_ERROR_LOG_MESSAGE_LENGTH \
1924 ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \
1925 ERROR_LOG_MESSAGE_LIMIT_SIZE : \
1926 PORT_MAXIMUM_MESSAGE_LENGTH)
1927 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
1928 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1929
1930 #ifdef _WIN64
1931 #define PORT_MAXIMUM_MESSAGE_LENGTH 512
1932 #else
1933 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
1934 #endif
1935
1936 typedef enum _DMA_WIDTH {
1937 Width8Bits,
1938 Width16Bits,
1939 Width32Bits,
1940 MaximumDmaWidth
1941 } DMA_WIDTH, *PDMA_WIDTH;
1942
1943 typedef enum _DMA_SPEED {
1944 Compatible,
1945 TypeA,
1946 TypeB,
1947 TypeC,
1948 TypeF,
1949 MaximumDmaSpeed
1950 } DMA_SPEED, *PDMA_SPEED;
1951
1952 /* DEVICE_DESCRIPTION.Version */
1953
1954 #define DEVICE_DESCRIPTION_VERSION 0x0000
1955 #define DEVICE_DESCRIPTION_VERSION1 0x0001
1956 #define DEVICE_DESCRIPTION_VERSION2 0x0002
1957
1958 typedef struct _DEVICE_DESCRIPTION {
1959 ULONG Version;
1960 BOOLEAN Master;
1961 BOOLEAN ScatterGather;
1962 BOOLEAN DemandMode;
1963 BOOLEAN AutoInitialize;
1964 BOOLEAN Dma32BitAddresses;
1965 BOOLEAN IgnoreCount;
1966 BOOLEAN Reserved1;
1967 BOOLEAN Dma64BitAddresses;
1968 ULONG BusNumber;
1969 ULONG DmaChannel;
1970 INTERFACE_TYPE InterfaceType;
1971 DMA_WIDTH DmaWidth;
1972 DMA_SPEED DmaSpeed;
1973 ULONG MaximumLength;
1974 ULONG DmaPort;
1975 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
1976
1977 typedef enum _DEVICE_RELATION_TYPE {
1978 BusRelations,
1979 EjectionRelations,
1980 PowerRelations,
1981 RemovalRelations,
1982 TargetDeviceRelation,
1983 SingleBusRelations,
1984 TransportRelations
1985 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
1986
1987 typedef struct _DEVICE_RELATIONS {
1988 ULONG Count;
1989 PDEVICE_OBJECT Objects[1];
1990 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
1991
1992 typedef struct _DEVOBJ_EXTENSION {
1993 CSHORT Type;
1994 USHORT Size;
1995 PDEVICE_OBJECT DeviceObject;
1996 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
1997
1998 typedef struct _SCATTER_GATHER_ELEMENT {
1999 PHYSICAL_ADDRESS Address;
2000 ULONG Length;
2001 ULONG_PTR Reserved;
2002 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
2003
2004 #if defined(_MSC_EXTENSIONS)
2005
2006 #if _MSC_VER >= 1200
2007 #pragma warning(push)
2008 #endif
2009 #pragma warning(disable:4200)
2010 typedef struct _SCATTER_GATHER_LIST {
2011 ULONG NumberOfElements;
2012 ULONG_PTR Reserved;
2013 SCATTER_GATHER_ELEMENT Elements[1];
2014 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2015
2016 #if _MSC_VER >= 1200
2017 #pragma warning(pop)
2018 #else
2019 #pragma warning(default:4200)
2020 #endif
2021
2022 #else
2023
2024 struct _SCATTER_GATHER_LIST;
2025 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2026
2027 #endif
2028
2029 typedef NTSTATUS
2030 (NTAPI DRIVER_ADD_DEVICE)(
2031 IN struct _DRIVER_OBJECT *DriverObject,
2032 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
2033 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
2034
2035 typedef struct _DRIVER_EXTENSION {
2036 struct _DRIVER_OBJECT *DriverObject;
2037 PDRIVER_ADD_DEVICE AddDevice;
2038 ULONG Count;
2039 UNICODE_STRING ServiceKeyName;
2040 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2041
2042 #define DRVO_UNLOAD_INVOKED 0x00000001
2043 #define DRVO_LEGACY_DRIVER 0x00000002
2044 #define DRVO_BUILTIN_DRIVER 0x00000004
2045
2046 typedef NTSTATUS
2047 (NTAPI DRIVER_INITIALIZE)(
2048 IN struct _DRIVER_OBJECT *DriverObject,
2049 IN PUNICODE_STRING RegistryPath);
2050 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
2051
2052 typedef VOID
2053 (NTAPI DRIVER_STARTIO)(
2054 IN struct _DEVICE_OBJECT *DeviceObject,
2055 IN struct _IRP *Irp);
2056 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
2057
2058 typedef VOID
2059 (NTAPI DRIVER_UNLOAD)(
2060 IN struct _DRIVER_OBJECT *DriverObject);
2061 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
2062
2063 typedef NTSTATUS
2064 (NTAPI DRIVER_DISPATCH)(
2065 IN struct _DEVICE_OBJECT *DeviceObject,
2066 IN struct _IRP *Irp);
2067 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
2068
2069 typedef struct _DRIVER_OBJECT {
2070 CSHORT Type;
2071 CSHORT Size;
2072 PDEVICE_OBJECT DeviceObject;
2073 ULONG Flags;
2074 PVOID DriverStart;
2075 ULONG DriverSize;
2076 PVOID DriverSection;
2077 PDRIVER_EXTENSION DriverExtension;
2078 UNICODE_STRING DriverName;
2079 PUNICODE_STRING HardwareDatabase;
2080 struct _FAST_IO_DISPATCH *FastIoDispatch;
2081 PDRIVER_INITIALIZE DriverInit;
2082 PDRIVER_STARTIO DriverStartIo;
2083 PDRIVER_UNLOAD DriverUnload;
2084 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
2085 } DRIVER_OBJECT, *PDRIVER_OBJECT;
2086
2087 typedef struct _DMA_ADAPTER {
2088 USHORT Version;
2089 USHORT Size;
2090 struct _DMA_OPERATIONS* DmaOperations;
2091 } DMA_ADAPTER, *PDMA_ADAPTER;
2092
2093 typedef VOID
2094 (NTAPI *PPUT_DMA_ADAPTER)(
2095 IN PDMA_ADAPTER DmaAdapter);
2096
2097 typedef PVOID
2098 (NTAPI *PALLOCATE_COMMON_BUFFER)(
2099 IN PDMA_ADAPTER DmaAdapter,
2100 IN ULONG Length,
2101 OUT PPHYSICAL_ADDRESS LogicalAddress,
2102 IN BOOLEAN CacheEnabled);
2103
2104 typedef VOID
2105 (NTAPI *PFREE_COMMON_BUFFER)(
2106 IN PDMA_ADAPTER DmaAdapter,
2107 IN ULONG Length,
2108 IN PHYSICAL_ADDRESS LogicalAddress,
2109 IN PVOID VirtualAddress,
2110 IN BOOLEAN CacheEnabled);
2111
2112 typedef NTSTATUS
2113 (NTAPI *PALLOCATE_ADAPTER_CHANNEL)(
2114 IN PDMA_ADAPTER DmaAdapter,
2115 IN PDEVICE_OBJECT DeviceObject,
2116 IN ULONG NumberOfMapRegisters,
2117 IN PDRIVER_CONTROL ExecutionRoutine,
2118 IN PVOID Context);
2119
2120 typedef BOOLEAN
2121 (NTAPI *PFLUSH_ADAPTER_BUFFERS)(
2122 IN PDMA_ADAPTER DmaAdapter,
2123 IN PMDL Mdl,
2124 IN PVOID MapRegisterBase,
2125 IN PVOID CurrentVa,
2126 IN ULONG Length,
2127 IN BOOLEAN WriteToDevice);
2128
2129 typedef VOID
2130 (NTAPI *PFREE_ADAPTER_CHANNEL)(
2131 IN PDMA_ADAPTER DmaAdapter);
2132
2133 typedef VOID
2134 (NTAPI *PFREE_MAP_REGISTERS)(
2135 IN PDMA_ADAPTER DmaAdapter,
2136 PVOID MapRegisterBase,
2137 ULONG NumberOfMapRegisters);
2138
2139 typedef PHYSICAL_ADDRESS
2140 (NTAPI *PMAP_TRANSFER)(
2141 IN PDMA_ADAPTER DmaAdapter,
2142 IN PMDL Mdl,
2143 IN PVOID MapRegisterBase,
2144 IN PVOID CurrentVa,
2145 IN OUT PULONG Length,
2146 IN BOOLEAN WriteToDevice);
2147
2148 typedef ULONG
2149 (NTAPI *PGET_DMA_ALIGNMENT)(
2150 IN PDMA_ADAPTER DmaAdapter);
2151
2152 typedef ULONG
2153 (NTAPI *PREAD_DMA_COUNTER)(
2154 IN PDMA_ADAPTER DmaAdapter);
2155
2156 typedef VOID
2157 (NTAPI *PDRIVER_LIST_CONTROL)(
2158 IN struct _DEVICE_OBJECT *DeviceObject,
2159 IN struct _IRP *Irp,
2160 IN struct _SCATTER_GATHER_LIST *ScatterGather,
2161 IN PVOID Context);
2162
2163 typedef NTSTATUS
2164 (NTAPI *PGET_SCATTER_GATHER_LIST)(
2165 IN PDMA_ADAPTER DmaAdapter,
2166 IN PDEVICE_OBJECT DeviceObject,
2167 IN PMDL Mdl,
2168 IN PVOID CurrentVa,
2169 IN ULONG Length,
2170 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2171 IN PVOID Context,
2172 IN BOOLEAN WriteToDevice);
2173
2174 typedef VOID
2175 (NTAPI *PPUT_SCATTER_GATHER_LIST)(
2176 IN PDMA_ADAPTER DmaAdapter,
2177 IN PSCATTER_GATHER_LIST ScatterGather,
2178 IN BOOLEAN WriteToDevice);
2179
2180 typedef NTSTATUS
2181 (NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2182 IN PDMA_ADAPTER DmaAdapter,
2183 IN PMDL Mdl OPTIONAL,
2184 IN PVOID CurrentVa,
2185 IN ULONG Length,
2186 OUT PULONG ScatterGatherListSize,
2187 OUT PULONG pNumberOfMapRegisters OPTIONAL);
2188
2189 typedef NTSTATUS
2190 (NTAPI *PBUILD_SCATTER_GATHER_LIST)(
2191 IN PDMA_ADAPTER DmaAdapter,
2192 IN PDEVICE_OBJECT DeviceObject,
2193 IN PMDL Mdl,
2194 IN PVOID CurrentVa,
2195 IN ULONG Length,
2196 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2197 IN PVOID Context,
2198 IN BOOLEAN WriteToDevice,
2199 IN PVOID ScatterGatherBuffer,
2200 IN ULONG ScatterGatherLength);
2201
2202 typedef NTSTATUS
2203 (NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2204 IN PDMA_ADAPTER DmaAdapter,
2205 IN PSCATTER_GATHER_LIST ScatterGather,
2206 IN PMDL OriginalMdl,
2207 OUT PMDL *TargetMdl);
2208
2209 typedef struct _DMA_OPERATIONS {
2210 ULONG Size;
2211 PPUT_DMA_ADAPTER PutDmaAdapter;
2212 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2213 PFREE_COMMON_BUFFER FreeCommonBuffer;
2214 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2215 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2216 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2217 PFREE_MAP_REGISTERS FreeMapRegisters;
2218 PMAP_TRANSFER MapTransfer;
2219 PGET_DMA_ALIGNMENT GetDmaAlignment;
2220 PREAD_DMA_COUNTER ReadDmaCounter;
2221 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2222 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2223 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2224 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2225 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2226 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2227
2228 typedef struct _IO_RESOURCE_DESCRIPTOR {
2229 UCHAR Option;
2230 UCHAR Type;
2231 UCHAR ShareDisposition;
2232 UCHAR Spare1;
2233 USHORT Flags;
2234 USHORT Spare2;
2235 union {
2236 struct {
2237 ULONG Length;
2238 ULONG Alignment;
2239 PHYSICAL_ADDRESS MinimumAddress;
2240 PHYSICAL_ADDRESS MaximumAddress;
2241 } Port;
2242 struct {
2243 ULONG Length;
2244 ULONG Alignment;
2245 PHYSICAL_ADDRESS MinimumAddress;
2246 PHYSICAL_ADDRESS MaximumAddress;
2247 } Memory;
2248 struct {
2249 ULONG MinimumVector;
2250 ULONG MaximumVector;
2251 } Interrupt;
2252 struct {
2253 ULONG MinimumChannel;
2254 ULONG MaximumChannel;
2255 } Dma;
2256 struct {
2257 ULONG Length;
2258 ULONG Alignment;
2259 PHYSICAL_ADDRESS MinimumAddress;
2260 PHYSICAL_ADDRESS MaximumAddress;
2261 } Generic;
2262 struct {
2263 ULONG Data[3];
2264 } DevicePrivate;
2265 struct {
2266 ULONG Length;
2267 ULONG MinBusNumber;
2268 ULONG MaxBusNumber;
2269 ULONG Reserved;
2270 } BusNumber;
2271 struct {
2272 ULONG Priority;
2273 ULONG Reserved1;
2274 ULONG Reserved2;
2275 } ConfigData;
2276 } u;
2277 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
2278
2279 typedef struct _IO_RESOURCE_LIST {
2280 USHORT Version;
2281 USHORT Revision;
2282 ULONG Count;
2283 IO_RESOURCE_DESCRIPTOR Descriptors[1];
2284 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
2285
2286 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
2287 ULONG ListSize;
2288 INTERFACE_TYPE InterfaceType;
2289 ULONG BusNumber;
2290 ULONG SlotNumber;
2291 ULONG Reserved[3];
2292 ULONG AlternativeLists;
2293 IO_RESOURCE_LIST List[1];
2294 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
2295
2296 typedef VOID
2297 (NTAPI DRIVER_CANCEL)(
2298 IN struct _DEVICE_OBJECT *DeviceObject,
2299 IN struct _IRP *Irp);
2300 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
2301
2302 typedef struct _IRP {
2303 CSHORT Type;
2304 USHORT Size;
2305 struct _MDL *MdlAddress;
2306 ULONG Flags;
2307 union {
2308 struct _IRP *MasterIrp;
2309 volatile LONG IrpCount;
2310 PVOID SystemBuffer;
2311 } AssociatedIrp;
2312 LIST_ENTRY ThreadListEntry;
2313 IO_STATUS_BLOCK IoStatus;
2314 KPROCESSOR_MODE RequestorMode;
2315 BOOLEAN PendingReturned;
2316 CHAR StackCount;
2317 CHAR CurrentLocation;
2318 BOOLEAN Cancel;
2319 KIRQL CancelIrql;
2320 CCHAR ApcEnvironment;
2321 UCHAR AllocationFlags;
2322 PIO_STATUS_BLOCK UserIosb;
2323 PKEVENT UserEvent;
2324 union {
2325 struct {
2326 _ANONYMOUS_UNION union {
2327 PIO_APC_ROUTINE UserApcRoutine;
2328 PVOID IssuingProcess;
2329 } DUMMYUNIONNAME;
2330 PVOID UserApcContext;
2331 } AsynchronousParameters;
2332 LARGE_INTEGER AllocationSize;
2333 } Overlay;
2334 volatile PDRIVER_CANCEL CancelRoutine;
2335 PVOID UserBuffer;
2336 union {
2337 struct {
2338 _ANONYMOUS_UNION union {
2339 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
2340 _ANONYMOUS_STRUCT struct {
2341 PVOID DriverContext[4];
2342 } DUMMYSTRUCTNAME;
2343 } DUMMYUNIONNAME;
2344 PETHREAD Thread;
2345 PCHAR AuxiliaryBuffer;
2346 _ANONYMOUS_STRUCT struct {
2347 LIST_ENTRY ListEntry;
2348 _ANONYMOUS_UNION union {
2349 struct _IO_STACK_LOCATION *CurrentStackLocation;
2350 ULONG PacketType;
2351 } DUMMYUNIONNAME;
2352 } DUMMYSTRUCTNAME;
2353 struct _FILE_OBJECT *OriginalFileObject;
2354 } Overlay;
2355 KAPC Apc;
2356 PVOID CompletionKey;
2357 } Tail;
2358 } IRP, *PIRP;
2359
2360 typedef enum _IO_PAGING_PRIORITY {
2361 IoPagingPriorityInvalid,
2362 IoPagingPriorityNormal,
2363 IoPagingPriorityHigh,
2364 IoPagingPriorityReserved1,
2365 IoPagingPriorityReserved2
2366 } IO_PAGING_PRIORITY;
2367
2368 typedef NTSTATUS
2369 (NTAPI IO_COMPLETION_ROUTINE)(
2370 IN struct _DEVICE_OBJECT *DeviceObject,
2371 IN struct _IRP *Irp,
2372 IN PVOID Context);
2373 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
2374
2375 typedef VOID
2376 (NTAPI IO_DPC_ROUTINE)(
2377 IN struct _KDPC *Dpc,
2378 IN struct _DEVICE_OBJECT *DeviceObject,
2379 IN struct _IRP *Irp,
2380 IN PVOID Context);
2381 typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE;
2382
2383 typedef NTSTATUS
2384 (NTAPI *PMM_DLL_INITIALIZE)(
2385 IN PUNICODE_STRING RegistryPath);
2386
2387 typedef NTSTATUS
2388 (NTAPI *PMM_DLL_UNLOAD)(
2389 VOID);
2390
2391 typedef VOID
2392 (NTAPI IO_TIMER_ROUTINE)(
2393 IN struct _DEVICE_OBJECT *DeviceObject,
2394 IN PVOID Context);
2395 typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
2396
2397 typedef struct _IO_SECURITY_CONTEXT {
2398 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
2399 PACCESS_STATE AccessState;
2400 ACCESS_MASK DesiredAccess;
2401 ULONG FullCreateOptions;
2402 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
2403
2404 struct _IO_CSQ;
2405
2406 typedef struct _IO_CSQ_IRP_CONTEXT {
2407 ULONG Type;
2408 struct _IRP *Irp;
2409 struct _IO_CSQ *Csq;
2410 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
2411
2412 typedef VOID
2413 (NTAPI *PIO_CSQ_INSERT_IRP)(
2414 IN struct _IO_CSQ *Csq,
2415 IN PIRP Irp);
2416
2417 typedef NTSTATUS
2418 (NTAPI IO_CSQ_INSERT_IRP_EX)(
2419 IN struct _IO_CSQ *Csq,
2420 IN PIRP Irp,
2421 IN PVOID InsertContext);
2422 typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX;
2423
2424 typedef VOID
2425 (NTAPI *PIO_CSQ_REMOVE_IRP)(
2426 IN struct _IO_CSQ *Csq,
2427 IN PIRP Irp);
2428
2429 typedef PIRP
2430 (NTAPI *PIO_CSQ_PEEK_NEXT_IRP)(
2431 IN struct _IO_CSQ *Csq,
2432 IN PIRP Irp,
2433 IN PVOID PeekContext);
2434
2435 typedef VOID
2436 (NTAPI *PIO_CSQ_ACQUIRE_LOCK)(
2437 IN struct _IO_CSQ *Csq,
2438 OUT PKIRQL Irql);
2439
2440 typedef VOID
2441 (NTAPI *PIO_CSQ_RELEASE_LOCK)(
2442 IN struct _IO_CSQ *Csq,
2443 IN KIRQL Irql);
2444
2445 typedef VOID
2446 (NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
2447 IN struct _IO_CSQ *Csq,
2448 IN PIRP Irp);
2449
2450 typedef struct _IO_CSQ {
2451 ULONG Type;
2452 PIO_CSQ_INSERT_IRP CsqInsertIrp;
2453 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
2454 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
2455 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
2456 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
2457 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
2458 PVOID ReservePointer;
2459 } IO_CSQ, *PIO_CSQ;
2460
2461 typedef enum _BUS_QUERY_ID_TYPE {
2462 BusQueryDeviceID,
2463 BusQueryHardwareIDs,
2464 BusQueryCompatibleIDs,
2465 BusQueryInstanceID,
2466 BusQueryDeviceSerialNumber
2467 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
2468
2469 typedef enum _DEVICE_TEXT_TYPE {
2470 DeviceTextDescription,
2471 DeviceTextLocationInformation
2472 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
2473
2474 typedef BOOLEAN
2475 (*PGPE_SERVICE_ROUTINE2)(
2476 PVOID ObjectContext,
2477 PVOID ServiceContext);
2478
2479 typedef NTSTATUS
2480 (*PGPE_CONNECT_VECTOR2)(
2481 PVOID Context,
2482 ULONG GpeNumber,
2483 KINTERRUPT_MODE Mode,
2484 BOOLEAN Shareable,
2485 PGPE_SERVICE_ROUTINE2 ServiceRoutine,
2486 PVOID ServiceContext,
2487 PVOID *ObjectContext);
2488
2489 typedef NTSTATUS
2490 (*PGPE_DISCONNECT_VECTOR2)(
2491 PVOID Context,
2492 PVOID ObjectContext);
2493
2494 typedef NTSTATUS
2495 (*PGPE_ENABLE_EVENT2)(
2496 PVOID Context,
2497 PVOID ObjectContext);
2498
2499 typedef NTSTATUS
2500 (*PGPE_DISABLE_EVENT2)(
2501 PVOID Context,
2502 PVOID ObjectContext);
2503
2504 typedef NTSTATUS
2505 (*PGPE_CLEAR_STATUS2)(
2506 PVOID Context,
2507 PVOID ObjectContext);
2508
2509 typedef VOID
2510 (*PDEVICE_NOTIFY_CALLBACK2)(
2511 PVOID NotificationContext,
2512 ULONG NotifyCode);
2513
2514 typedef NTSTATUS
2515 (*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2516 PVOID Context,
2517 PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
2518 PVOID NotificationContext);
2519
2520 typedef VOID
2521 (*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2522 PVOID Context);
2523
2524 typedef struct _ACPI_INTERFACE_STANDARD2 {
2525 USHORT Size;
2526 USHORT Version;
2527 PVOID Context;
2528 PINTERFACE_REFERENCE InterfaceReference;
2529 PINTERFACE_DEREFERENCE InterfaceDereference;
2530 PGPE_CONNECT_VECTOR2 GpeConnectVector;
2531 PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
2532 PGPE_ENABLE_EVENT2 GpeEnableEvent;
2533 PGPE_DISABLE_EVENT2 GpeDisableEvent;
2534 PGPE_CLEAR_STATUS2 GpeClearStatus;
2535 PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
2536 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
2537 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
2538
2539 #if !defined(_AMD64_) && !defined(_IA64_)
2540 #include <pshpack4.h>
2541 #endif
2542 typedef struct _IO_STACK_LOCATION {
2543 UCHAR MajorFunction;
2544 UCHAR MinorFunction;
2545 UCHAR Flags;
2546 UCHAR Control;
2547 union {
2548 struct {
2549 PIO_SECURITY_CONTEXT SecurityContext;
2550 ULONG Options;
2551 USHORT POINTER_ALIGNMENT FileAttributes;
2552 USHORT ShareAccess;
2553 ULONG POINTER_ALIGNMENT EaLength;
2554 } Create;
2555 struct {
2556 ULONG Length;
2557 ULONG POINTER_ALIGNMENT Key;
2558 LARGE_INTEGER ByteOffset;
2559 } Read;
2560 struct {
2561 ULONG Length;
2562 ULONG POINTER_ALIGNMENT Key;
2563 LARGE_INTEGER ByteOffset;
2564 } Write;
2565 struct {
2566 ULONG Length;
2567 PUNICODE_STRING FileName;
2568 FILE_INFORMATION_CLASS FileInformationClass;
2569 ULONG FileIndex;
2570 } QueryDirectory;
2571 struct {
2572 ULONG Length;
2573 ULONG CompletionFilter;
2574 } NotifyDirectory;
2575 struct {
2576 ULONG Length;
2577 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2578 } QueryFile;
2579 struct {
2580 ULONG Length;
2581 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2582 PFILE_OBJECT FileObject;
2583 _ANONYMOUS_UNION union {
2584 _ANONYMOUS_STRUCT struct {
2585 BOOLEAN ReplaceIfExists;
2586 BOOLEAN AdvanceOnly;
2587 } DUMMYSTRUCTNAME;
2588 ULONG ClusterCount;
2589 HANDLE DeleteHandle;
2590 } DUMMYUNIONNAME;
2591 } SetFile;
2592 struct {
2593 ULONG Length;
2594 PVOID EaList;
2595 ULONG EaListLength;
2596 ULONG EaIndex;
2597 } QueryEa;
2598 struct {
2599 ULONG Length;
2600 } SetEa;
2601 struct {
2602 ULONG Length;
2603 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2604 } QueryVolume;
2605 struct {
2606 ULONG Length;
2607 FS_INFORMATION_CLASS FsInformationClass;
2608 } SetVolume;
2609 struct {
2610 ULONG OutputBufferLength;
2611 ULONG InputBufferLength;
2612 ULONG FsControlCode;
2613 PVOID Type3InputBuffer;
2614 } FileSystemControl;
2615 struct {
2616 PLARGE_INTEGER Length;
2617 ULONG Key;
2618 LARGE_INTEGER ByteOffset;
2619 } LockControl;
2620 struct {
2621 ULONG OutputBufferLength;
2622 ULONG POINTER_ALIGNMENT InputBufferLength;
2623 ULONG POINTER_ALIGNMENT IoControlCode;
2624 PVOID Type3InputBuffer;
2625 } DeviceIoControl;
2626 struct {
2627 SECURITY_INFORMATION SecurityInformation;
2628 ULONG POINTER_ALIGNMENT Length;
2629 } QuerySecurity;
2630 struct {
2631 SECURITY_INFORMATION SecurityInformation;
2632 PSECURITY_DESCRIPTOR SecurityDescriptor;
2633 } SetSecurity;
2634 struct {
2635 PVPB Vpb;
2636 PDEVICE_OBJECT DeviceObject;
2637 } MountVolume;
2638 struct {
2639 PVPB Vpb;
2640 PDEVICE_OBJECT DeviceObject;
2641 } VerifyVolume;
2642 struct {
2643 struct _SCSI_REQUEST_BLOCK *Srb;
2644 } Scsi;
2645 struct {
2646 ULONG Length;
2647 PSID StartSid;
2648 struct _FILE_GET_QUOTA_INFORMATION *SidList;
2649 ULONG SidListLength;
2650 } QueryQuota;
2651 struct {
2652 ULONG Length;
2653 } SetQuota;
2654 struct {
2655 DEVICE_RELATION_TYPE Type;
2656 } QueryDeviceRelations;
2657 struct {
2658 CONST GUID *InterfaceType;
2659 USHORT Size;
2660 USHORT Version;
2661 PINTERFACE Interface;
2662 PVOID InterfaceSpecificData;
2663 } QueryInterface;
2664 struct {
2665 PDEVICE_CAPABILITIES Capabilities;
2666 } DeviceCapabilities;
2667 struct {
2668 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
2669 } FilterResourceRequirements;
2670 struct {
2671 ULONG WhichSpace;
2672 PVOID Buffer;
2673 ULONG Offset;
2674 ULONG POINTER_ALIGNMENT Length;
2675 } ReadWriteConfig;
2676 struct {
2677 BOOLEAN Lock;
2678 } SetLock;
2679 struct {
2680 BUS_QUERY_ID_TYPE IdType;
2681 } QueryId;
2682 struct {
2683 DEVICE_TEXT_TYPE DeviceTextType;
2684 LCID POINTER_ALIGNMENT LocaleId;
2685 } QueryDeviceText;
2686 struct {
2687 BOOLEAN InPath;
2688 BOOLEAN Reserved[3];
2689 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
2690 } UsageNotification;
2691 struct {
2692 SYSTEM_POWER_STATE PowerState;
2693 } WaitWake;
2694 struct {
2695 PPOWER_SEQUENCE PowerSequence;
2696 } PowerSequence;
2697 struct {
2698 ULONG SystemContext;
2699 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
2700 POWER_STATE POINTER_ALIGNMENT State;
2701 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
2702 } Power;
2703 struct {
2704 PCM_RESOURCE_LIST AllocatedResources;
2705 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
2706 } StartDevice;
2707 struct {
2708 ULONG_PTR ProviderId;
2709 PVOID DataPath;
2710 ULONG BufferSize;
2711 PVOID Buffer;
2712 } WMI;
2713 struct {
2714 PVOID Argument1;
2715 PVOID Argument2;
2716 PVOID Argument3;
2717 PVOID Argument4;
2718 } Others;
2719 } Parameters;
2720 PDEVICE_OBJECT DeviceObject;
2721 PFILE_OBJECT FileObject;
2722 PIO_COMPLETION_ROUTINE CompletionRoutine;
2723 PVOID Context;
2724 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
2725 #if !defined(_AMD64_) && !defined(_IA64_)
2726 #include <poppack.h>
2727 #endif
2728
2729 /* IO_STACK_LOCATION.Control */
2730
2731 #define SL_PENDING_RETURNED 0x01
2732 #define SL_ERROR_RETURNED 0x02
2733 #define SL_INVOKE_ON_CANCEL 0x20
2734 #define SL_INVOKE_ON_SUCCESS 0x40
2735 #define SL_INVOKE_ON_ERROR 0x80
2736
2737 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
2738
2739 #define PCI_WHICHSPACE_CONFIG 0x0
2740 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
2741
2742 #define METHOD_BUFFERED 0
2743 #define METHOD_IN_DIRECT 1
2744 #define METHOD_OUT_DIRECT 2
2745 #define METHOD_NEITHER 3
2746
2747 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT
2748 #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT
2749
2750 #define FILE_SUPERSEDED 0x00000000
2751 #define FILE_OPENED 0x00000001
2752 #define FILE_CREATED 0x00000002
2753 #define FILE_OVERWRITTEN 0x00000003
2754 #define FILE_EXISTS 0x00000004
2755 #define FILE_DOES_NOT_EXIST 0x00000005
2756
2757 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
2758 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
2759
2760 /* also in winnt.h */
2761 #define FILE_LIST_DIRECTORY 0x00000001
2762 #define FILE_READ_DATA 0x00000001
2763 #define FILE_ADD_FILE 0x00000002
2764 #define FILE_WRITE_DATA 0x00000002
2765 #define FILE_ADD_SUBDIRECTORY 0x00000004
2766 #define FILE_APPEND_DATA 0x00000004
2767 #define FILE_CREATE_PIPE_INSTANCE 0x00000004
2768 #define FILE_READ_EA 0x00000008
2769 #define FILE_WRITE_EA 0x00000010
2770 #define FILE_EXECUTE 0x00000020
2771 #define FILE_TRAVERSE 0x00000020
2772 #define FILE_DELETE_CHILD 0x00000040
2773 #define FILE_READ_ATTRIBUTES 0x00000080
2774 #define FILE_WRITE_ATTRIBUTES 0x00000100
2775
2776 #define FILE_SHARE_READ 0x00000001
2777 #define FILE_SHARE_WRITE 0x00000002
2778 #define FILE_SHARE_DELETE 0x00000004
2779 #define FILE_SHARE_VALID_FLAGS 0x00000007
2780
2781 #define FILE_ATTRIBUTE_READONLY 0x00000001
2782 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
2783 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
2784 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
2785 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
2786 #define FILE_ATTRIBUTE_DEVICE 0x00000040
2787 #define FILE_ATTRIBUTE_NORMAL 0x00000080
2788 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
2789 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
2790 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
2791 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
2792 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
2793 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
2794 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
2795 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
2796
2797 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
2798 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
2799
2800 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
2801 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
2802 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
2803 #define FILE_VALID_SET_FLAGS 0x00000036
2804
2805 #define FILE_SUPERSEDE 0x00000000
2806 #define FILE_OPEN 0x00000001
2807 #define FILE_CREATE 0x00000002
2808 #define FILE_OPEN_IF 0x00000003
2809 #define FILE_OVERWRITE 0x00000004
2810 #define FILE_OVERWRITE_IF 0x00000005
2811 #define FILE_MAXIMUM_DISPOSITION 0x00000005
2812
2813 #define FILE_DIRECTORY_FILE 0x00000001
2814 #define FILE_WRITE_THROUGH 0x00000002
2815 #define FILE_SEQUENTIAL_ONLY 0x00000004
2816 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
2817 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
2818 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
2819 #define FILE_NON_DIRECTORY_FILE 0x00000040
2820 #define FILE_CREATE_TREE_CONNECTION 0x00000080
2821 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
2822 #define FILE_NO_EA_KNOWLEDGE 0x00000200
2823 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400
2824 #define FILE_RANDOM_ACCESS 0x00000800
2825 #define FILE_DELETE_ON_CLOSE 0x00001000
2826 #define FILE_OPEN_BY_FILE_ID 0x00002000
2827 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
2828 #define FILE_NO_COMPRESSION 0x00008000
2829 #if (NTDDI_VERSION >= NTDDI_WIN7)
2830 #define FILE_OPEN_REQUIRING_OPLOCK 0x00010000
2831 #define FILE_DISALLOW_EXCLUSIVE 0x00020000
2832 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2833 #define FILE_RESERVE_OPFILTER 0x00100000
2834 #define FILE_OPEN_REPARSE_POINT 0x00200000
2835 #define FILE_OPEN_NO_RECALL 0x00400000
2836 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
2837
2838 #define FILE_ANY_ACCESS 0x00000000
2839 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS
2840 #define FILE_READ_ACCESS 0x00000001
2841 #define FILE_WRITE_ACCESS 0x00000002
2842
2843 #define FILE_ALL_ACCESS \
2844 (STANDARD_RIGHTS_REQUIRED | \
2845 SYNCHRONIZE | \
2846 0x1FF)
2847
2848 #define FILE_GENERIC_EXECUTE \
2849 (STANDARD_RIGHTS_EXECUTE | \
2850 FILE_READ_ATTRIBUTES | \
2851 FILE_EXECUTE | \
2852 SYNCHRONIZE)
2853
2854 #define FILE_GENERIC_READ \
2855 (STANDARD_RIGHTS_READ | \
2856 FILE_READ_DATA | \
2857 FILE_READ_ATTRIBUTES | \
2858 FILE_READ_EA | \
2859 SYNCHRONIZE)
2860
2861 #define FILE_GENERIC_WRITE \
2862 (STANDARD_RIGHTS_WRITE | \
2863 FILE_WRITE_DATA | \
2864 FILE_WRITE_ATTRIBUTES | \
2865 FILE_WRITE_EA | \
2866 FILE_APPEND_DATA | \
2867 SYNCHRONIZE)
2868
2869 /* end winnt.h */
2870
2871 #define WMIREG_ACTION_REGISTER 1
2872 #define WMIREG_ACTION_DEREGISTER 2
2873 #define WMIREG_ACTION_REREGISTER 3
2874 #define WMIREG_ACTION_UPDATE_GUIDS 4
2875 #define WMIREG_ACTION_BLOCK_IRPS 5
2876
2877 #define WMIREGISTER 0
2878 #define WMIUPDATE 1
2879
2880 typedef VOID
2881 (NTAPI FWMI_NOTIFICATION_CALLBACK)(
2882 PVOID Wnode,
2883 PVOID Context);
2884 typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK;
2885