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