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