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