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