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