xref: /reactos/sdk/include/xdk/iotypes.h (revision 84ccccab)
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,
4227   ArbiterRequestLegacyAssigned,
4228   ArbiterRequestPnpDetected,
4229   ArbiterRequestPnpEnumerated
4230 } ARBITER_REQUEST_SOURCE;
4231 
4232 typedef enum _ARBITER_RESULT {
4233   ArbiterResultUndefined = -1,
4234   ArbiterResultSuccess,
4235   ArbiterResultExternalConflict,
4236   ArbiterResultNullRequest
4237 } ARBITER_RESULT;
4238 
4239 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
4240 
4241 typedef struct _ARBITER_LIST_ENTRY {
4242   LIST_ENTRY ListEntry;
4243   ULONG AlternativeCount;
4244   PIO_RESOURCE_DESCRIPTOR Alternatives;
4245   PDEVICE_OBJECT PhysicalDeviceObject;
4246   ARBITER_REQUEST_SOURCE RequestSource;
4247   ULONG Flags;
4248   LONG_PTR WorkSpace;
4249   INTERFACE_TYPE InterfaceType;
4250   ULONG SlotNumber;
4251   ULONG BusNumber;
4252   PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
4253   PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
4254   ARBITER_RESULT Result;
4255 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
4256 
4257 typedef NTSTATUS
4258 (NTAPI *PARBITER_HANDLER)(
4259   _Inout_opt_ PVOID Context,
4260   _In_ ARBITER_ACTION Action,
4261   _Inout_ PARBITER_PARAMETERS Parameters);
4262 
4263 #define ARBITER_PARTIAL 0x00000001
4264 
4265 typedef struct _ARBITER_INTERFACE {
4266   USHORT Size;
4267   USHORT Version;
4268   PVOID Context;
4269   PINTERFACE_REFERENCE InterfaceReference;
4270   PINTERFACE_DEREFERENCE InterfaceDereference;
4271   PARBITER_HANDLER ArbiterHandler;
4272   ULONG Flags;
4273 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
4274 
4275 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
4276   TranslateChildToParent,
4277   TranslateParentToChild
4278 } RESOURCE_TRANSLATION_DIRECTION;
4279 
4280 typedef NTSTATUS
4281 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
4282   _Inout_opt_ PVOID Context,
4283   _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
4284   _In_ RESOURCE_TRANSLATION_DIRECTION Direction,
4285   _In_opt_ ULONG AlternativesCount,
4286   _In_reads_opt_(AlternativesCount) IO_RESOURCE_DESCRIPTOR Alternatives[],
4287   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
4288   _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
4289 
4290 typedef NTSTATUS
4291 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
4292   _Inout_opt_ PVOID Context,
4293   _In_ PIO_RESOURCE_DESCRIPTOR Source,
4294   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
4295   _Out_ PULONG TargetCount,
4296   _Out_writes_(*TargetCount) PIO_RESOURCE_DESCRIPTOR *Target);
4297 
4298 typedef struct _TRANSLATOR_INTERFACE {
4299   USHORT Size;
4300   USHORT Version;
4301   PVOID Context;
4302   PINTERFACE_REFERENCE InterfaceReference;
4303   PINTERFACE_DEREFERENCE InterfaceDereference;
4304   PTRANSLATE_RESOURCE_HANDLER TranslateResources;
4305   PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
4306 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
4307 
4308 typedef struct _PCI_AGP_CAPABILITY {
4309   PCI_CAPABILITIES_HEADER Header;
4310   USHORT Minor:4;
4311   USHORT Major:4;
4312   USHORT Rsvd1:8;
4313   struct _PCI_AGP_STATUS {
4314     ULONG Rate:3;
4315     ULONG Agp3Mode:1;
4316     ULONG FastWrite:1;
4317     ULONG FourGB:1;
4318     ULONG HostTransDisable:1;
4319     ULONG Gart64:1;
4320     ULONG ITA_Coherent:1;
4321     ULONG SideBandAddressing:1;
4322     ULONG CalibrationCycle:3;
4323     ULONG AsyncRequestSize:3;
4324     ULONG Rsvd1:1;
4325     ULONG Isoch:1;
4326     ULONG Rsvd2:6;
4327     ULONG RequestQueueDepthMaximum:8;
4328   } AGPStatus;
4329   struct _PCI_AGP_COMMAND {
4330     ULONG Rate:3;
4331     ULONG Rsvd1:1;
4332     ULONG FastWriteEnable:1;
4333     ULONG FourGBEnable:1;
4334     ULONG Rsvd2:1;
4335     ULONG Gart64:1;
4336     ULONG AGPEnable:1;
4337     ULONG SBAEnable:1;
4338     ULONG CalibrationCycle:3;
4339     ULONG AsyncReqSize:3;
4340     ULONG Rsvd3:8;
4341     ULONG RequestQueueDepth:8;
4342   } AGPCommand;
4343 } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
4344 
4345 typedef enum _EXTENDED_AGP_REGISTER {
4346   IsochStatus,
4347   AgpControl,
4348   ApertureSize,
4349   AperturePageSize,
4350   GartLow,
4351   GartHigh,
4352   IsochCommand
4353 } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
4354 
4355 typedef struct _PCI_AGP_ISOCH_STATUS {
4356   ULONG ErrorCode:2;
4357   ULONG Rsvd1:1;
4358   ULONG Isoch_L:3;
4359   ULONG Isoch_Y:2;
4360   ULONG Isoch_N:8;
4361   ULONG Rsvd2:16;
4362 } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
4363 
4364 typedef struct _PCI_AGP_CONTROL {
4365   ULONG Rsvd1:7;
4366   ULONG GTLB_Enable:1;
4367   ULONG AP_Enable:1;
4368   ULONG CAL_Disable:1;
4369   ULONG Rsvd2:22;
4370 } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
4371 
4372 typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
4373   USHORT PageSizeMask:11;
4374   USHORT Rsvd1:1;
4375   USHORT PageSizeSelect:4;
4376 } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
4377 
4378 typedef struct _PCI_AGP_ISOCH_COMMAND {
4379   USHORT Rsvd1:6;
4380   USHORT Isoch_Y:2;
4381   USHORT Isoch_N:8;
4382 } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
4383 
4384 typedef struct PCI_AGP_EXTENDED_CAPABILITY {
4385   PCI_AGP_ISOCH_STATUS IsochStatus;
4386   PCI_AGP_CONTROL AgpControl;
4387   USHORT ApertureSize;
4388   PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
4389   ULONG GartLow;
4390   ULONG GartHigh;
4391   PCI_AGP_ISOCH_COMMAND IsochCommand;
4392 } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
4393 
4394 #define PCI_AGP_RATE_1X     0x1
4395 #define PCI_AGP_RATE_2X     0x2
4396 #define PCI_AGP_RATE_4X     0x4
4397 
4398 #define PCIX_MODE_CONVENTIONAL_PCI  0x0
4399 #define PCIX_MODE1_66MHZ            0x1
4400 #define PCIX_MODE1_100MHZ           0x2
4401 #define PCIX_MODE1_133MHZ           0x3
4402 #define PCIX_MODE2_266_66MHZ        0x9
4403 #define PCIX_MODE2_266_100MHZ       0xA
4404 #define PCIX_MODE2_266_133MHZ       0xB
4405 #define PCIX_MODE2_533_66MHZ        0xD
4406 #define PCIX_MODE2_533_100MHZ       0xE
4407 #define PCIX_MODE2_533_133MHZ       0xF
4408 
4409 #define PCIX_VERSION_MODE1_ONLY     0x0
4410 #define PCIX_VERSION_MODE2_ECC      0x1
4411 #define PCIX_VERSION_DUAL_MODE_ECC  0x2
4412 
4413 typedef struct _PCIX_BRIDGE_CAPABILITY {
4414   PCI_CAPABILITIES_HEADER Header;
4415   union {
4416     _ANONYMOUS_STRUCT struct {
4417       USHORT Bus64Bit:1;
4418       USHORT Bus133MHzCapable:1;
4419       USHORT SplitCompletionDiscarded:1;
4420       USHORT UnexpectedSplitCompletion:1;
4421       USHORT SplitCompletionOverrun:1;
4422       USHORT SplitRequestDelayed:1;
4423       USHORT BusModeFrequency:4;
4424       USHORT Rsvd:2;
4425       USHORT Version:2;
4426       USHORT Bus266MHzCapable:1;
4427       USHORT Bus533MHzCapable:1;
4428     } DUMMYSTRUCTNAME;
4429   USHORT AsUSHORT;
4430   } SecondaryStatus;
4431   union {
4432     _ANONYMOUS_STRUCT struct {
4433       ULONG FunctionNumber:3;
4434       ULONG DeviceNumber:5;
4435       ULONG BusNumber:8;
4436       ULONG Device64Bit:1;
4437       ULONG Device133MHzCapable:1;
4438       ULONG SplitCompletionDiscarded:1;
4439       ULONG UnexpectedSplitCompletion:1;
4440       ULONG SplitCompletionOverrun:1;
4441       ULONG SplitRequestDelayed:1;
4442       ULONG Rsvd:7;
4443       ULONG DIMCapable:1;
4444       ULONG Device266MHzCapable:1;
4445       ULONG Device533MHzCapable:1;
4446     } DUMMYSTRUCTNAME;
4447     ULONG AsULONG;
4448   } BridgeStatus;
4449   USHORT UpstreamSplitTransactionCapacity;
4450   USHORT UpstreamSplitTransactionLimit;
4451   USHORT DownstreamSplitTransactionCapacity;
4452   USHORT DownstreamSplitTransactionLimit;
4453   union {
4454     _ANONYMOUS_STRUCT struct {
4455       ULONG SelectSecondaryRegisters:1;
4456       ULONG ErrorPresentInOtherBank:1;
4457       ULONG AdditionalCorrectableError:1;
4458       ULONG AdditionalUncorrectableError:1;
4459       ULONG ErrorPhase:3;
4460       ULONG ErrorCorrected:1;
4461       ULONG Syndrome:8;
4462       ULONG ErrorFirstCommand:4;
4463       ULONG ErrorSecondCommand:4;
4464       ULONG ErrorUpperAttributes:4;
4465       ULONG ControlUpdateEnable:1;
4466       ULONG Rsvd:1;
4467       ULONG DisableSingleBitCorrection:1;
4468       ULONG EccMode:1;
4469     } DUMMYSTRUCTNAME;
4470   ULONG AsULONG;
4471   } EccControlStatus;
4472   ULONG EccFirstAddress;
4473   ULONG EccSecondAddress;
4474   ULONG EccAttribute;
4475 } PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY;
4476 
4477 typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY {
4478   PCI_CAPABILITIES_HEADER Header;
4479   USHORT Reserved;
4480   USHORT SubVendorID;
4481   USHORT SubSystemID;
4482 } PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY;
4483 
4484 #define OSC_FIRMWARE_FAILURE                            0x02
4485 #define OSC_UNRECOGNIZED_UUID                           0x04
4486 #define OSC_UNRECOGNIZED_REVISION                       0x08
4487 #define OSC_CAPABILITIES_MASKED                         0x10
4488 
4489 #define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION     0x01
4490 
4491 typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD {
4492   union {
4493     _ANONYMOUS_STRUCT struct {
4494       ULONG ExtendedConfigOpRegions:1;
4495       ULONG ActiveStatePowerManagement:1;
4496       ULONG ClockPowerManagement:1;
4497       ULONG SegmentGroups:1;
4498       ULONG MessageSignaledInterrupts:1;
4499       ULONG WindowsHardwareErrorArchitecture:1;
4500       ULONG Reserved:26;
4501     } DUMMYSTRUCTNAME;
4502     ULONG AsULONG;
4503   } u;
4504 } PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD;
4505 
4506 typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD {
4507   union {
4508     _ANONYMOUS_STRUCT struct {
4509       ULONG ExpressNativeHotPlug:1;
4510       ULONG ShpcNativeHotPlug:1;
4511       ULONG ExpressNativePME:1;
4512       ULONG ExpressAdvancedErrorReporting:1;
4513       ULONG ExpressCapabilityStructure:1;
4514       ULONG Reserved:27;
4515     } DUMMYSTRUCTNAME;
4516   ULONG AsULONG;
4517   } u;
4518 } PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD;
4519 
4520 typedef enum _PCI_HARDWARE_INTERFACE {
4521   PciConventional,
4522   PciXMode1,
4523   PciXMode2,
4524   PciExpress
4525 } PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE;
4526 
4527 typedef enum {
4528   BusWidth32Bits,
4529   BusWidth64Bits
4530 } PCI_BUS_WIDTH;
4531 
4532 typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY {
4533   PCI_HARDWARE_INTERFACE SecondaryInterface;
4534   _ANONYMOUS_STRUCT struct {
4535     BOOLEAN BusCapabilitiesFound;
4536     ULONG CurrentSpeedAndMode;
4537     ULONG SupportedSpeedsAndModes;
4538     BOOLEAN DeviceIDMessagingCapable;
4539     PCI_BUS_WIDTH SecondaryBusWidth;
4540   } DUMMYSTRUCTNAME;
4541   PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport;
4542   PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest;
4543   PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted;
4544 } PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY;
4545 
4546 typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER {
4547   _ANONYMOUS_STRUCT struct {
4548     USHORT CapabilityVersion:4;
4549     USHORT DeviceType:4;
4550     USHORT SlotImplemented:1;
4551     USHORT InterruptMessageNumber:5;
4552     USHORT Rsvd:2;
4553   } DUMMYSTRUCTNAME;
4554   USHORT AsUSHORT;
4555 } PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER;
4556 
4557 typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER {
4558   _ANONYMOUS_STRUCT struct {
4559     ULONG MaxPayloadSizeSupported:3;
4560     ULONG PhantomFunctionsSupported:2;
4561     ULONG ExtendedTagSupported:1;
4562     ULONG L0sAcceptableLatency:3;
4563     ULONG L1AcceptableLatency:3;
4564     ULONG Undefined:3;
4565     ULONG RoleBasedErrorReporting:1;
4566     ULONG Rsvd1:2;
4567     ULONG CapturedSlotPowerLimit:8;
4568     ULONG CapturedSlotPowerLimitScale:2;
4569     ULONG Rsvd2:4;
4570   } DUMMYSTRUCTNAME;
4571   ULONG AsULONG;
4572 } PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER;
4573 
4574 #define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07;
4575 
4576 typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER {
4577   _ANONYMOUS_STRUCT struct {
4578     USHORT CorrectableErrorEnable:1;
4579     USHORT NonFatalErrorEnable:1;
4580     USHORT FatalErrorEnable:1;
4581     USHORT UnsupportedRequestErrorEnable:1;
4582     USHORT EnableRelaxedOrder:1;
4583     USHORT MaxPayloadSize:3;
4584     USHORT ExtendedTagEnable:1;
4585     USHORT PhantomFunctionsEnable:1;
4586     USHORT AuxPowerEnable:1;
4587     USHORT NoSnoopEnable:1;
4588     USHORT MaxReadRequestSize:3;
4589     USHORT BridgeConfigRetryEnable:1;
4590   } DUMMYSTRUCTNAME;
4591   USHORT AsUSHORT;
4592 } PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER;
4593 
4594 #define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F;
4595 
4596 typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER {
4597   _ANONYMOUS_STRUCT struct {
4598     USHORT CorrectableErrorDetected:1;
4599     USHORT NonFatalErrorDetected:1;
4600     USHORT FatalErrorDetected:1;
4601     USHORT UnsupportedRequestDetected:1;
4602     USHORT AuxPowerDetected:1;
4603     USHORT TransactionsPending:1;
4604     USHORT Rsvd:10;
4605   } DUMMYSTRUCTNAME;
4606   USHORT AsUSHORT;
4607 } PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER;
4608 
4609 typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER {
4610   _ANONYMOUS_STRUCT struct {
4611     ULONG MaximumLinkSpeed:4;
4612     ULONG MaximumLinkWidth:6;
4613     ULONG ActiveStatePMSupport:2;
4614     ULONG L0sExitLatency:3;
4615     ULONG L1ExitLatency:3;
4616     ULONG ClockPowerManagement:1;
4617     ULONG SurpriseDownErrorReportingCapable:1;
4618     ULONG DataLinkLayerActiveReportingCapable:1;
4619     ULONG Rsvd:3;
4620     ULONG PortNumber:8;
4621   } DUMMYSTRUCTNAME;
4622   ULONG AsULONG;
4623 } PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER;
4624 
4625 typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER {
4626   _ANONYMOUS_STRUCT struct {
4627     USHORT ActiveStatePMControl:2;
4628     USHORT Rsvd1:1;
4629     USHORT ReadCompletionBoundary:1;
4630     USHORT LinkDisable:1;
4631     USHORT RetrainLink:1;
4632     USHORT CommonClockConfig:1;
4633     USHORT ExtendedSynch:1;
4634     USHORT EnableClockPowerManagement:1;
4635     USHORT Rsvd2:7;
4636   } DUMMYSTRUCTNAME;
4637   USHORT AsUSHORT;
4638 } PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER;
4639 
4640 typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER {
4641   _ANONYMOUS_STRUCT struct {
4642     USHORT LinkSpeed:4;
4643     USHORT LinkWidth:6;
4644     USHORT Undefined:1;
4645     USHORT LinkTraining:1;
4646     USHORT SlotClockConfig:1;
4647     USHORT DataLinkLayerActive:1;
4648     USHORT Rsvd:2;
4649   } DUMMYSTRUCTNAME;
4650   USHORT AsUSHORT;
4651 } PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER;
4652 
4653 typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER {
4654   _ANONYMOUS_STRUCT struct {
4655     ULONG AttentionButtonPresent:1;
4656     ULONG PowerControllerPresent:1;
4657     ULONG MRLSensorPresent:1;
4658     ULONG AttentionIndicatorPresent:1;
4659     ULONG PowerIndicatorPresent:1;
4660     ULONG HotPlugSurprise:1;
4661     ULONG HotPlugCapable:1;
4662     ULONG SlotPowerLimit:8;
4663     ULONG SlotPowerLimitScale:2;
4664     ULONG ElectromechanicalLockPresent:1;
4665     ULONG NoCommandCompletedSupport:1;
4666     ULONG PhysicalSlotNumber:13;
4667   } DUMMYSTRUCTNAME;
4668   ULONG AsULONG;
4669 } PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER;
4670 
4671 typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER {
4672   _ANONYMOUS_STRUCT struct {
4673     USHORT AttentionButtonEnable:1;
4674     USHORT PowerFaultDetectEnable:1;
4675     USHORT MRLSensorEnable:1;
4676     USHORT PresenceDetectEnable:1;
4677     USHORT CommandCompletedEnable:1;
4678     USHORT HotPlugInterruptEnable:1;
4679     USHORT AttentionIndicatorControl:2;
4680     USHORT PowerIndicatorControl:2;
4681     USHORT PowerControllerControl:1;
4682     USHORT ElectromechanicalLockControl:1;
4683     USHORT DataLinkStateChangeEnable:1;
4684     USHORT Rsvd:3;
4685   } DUMMYSTRUCTNAME;
4686   USHORT AsUSHORT;
4687 } PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER;
4688 
4689 typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER {
4690   _ANONYMOUS_STRUCT struct {
4691     USHORT AttentionButtonPressed:1;
4692     USHORT PowerFaultDetected:1;
4693     USHORT MRLSensorChanged:1;
4694     USHORT PresenceDetectChanged:1;
4695     USHORT CommandCompleted:1;
4696     USHORT MRLSensorState:1;
4697     USHORT PresenceDetectState:1;
4698     USHORT ElectromechanicalLockEngaged:1;
4699     USHORT DataLinkStateChanged:1;
4700     USHORT Rsvd:7;
4701   } DUMMYSTRUCTNAME;
4702   USHORT AsUSHORT;
4703 } PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER;
4704 
4705 typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER {
4706   _ANONYMOUS_STRUCT struct {
4707     USHORT CorrectableSerrEnable:1;
4708     USHORT NonFatalSerrEnable:1;
4709     USHORT FatalSerrEnable:1;
4710     USHORT PMEInterruptEnable:1;
4711     USHORT CRSSoftwareVisibilityEnable:1;
4712     USHORT Rsvd:11;
4713   } DUMMYSTRUCTNAME;
4714   USHORT AsUSHORT;
4715 } PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER;
4716 
4717 typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER {
4718   _ANONYMOUS_STRUCT struct {
4719     USHORT CRSSoftwareVisibility:1;
4720     USHORT Rsvd:15;
4721   } DUMMYSTRUCTNAME;
4722   USHORT AsUSHORT;
4723 } PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER;
4724 
4725 typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER {
4726   _ANONYMOUS_STRUCT struct {
4727     ULONG PMERequestorId:16;
4728     ULONG PMEStatus:1;
4729     ULONG PMEPending:1;
4730     ULONG Rsvd:14;
4731   } DUMMYSTRUCTNAME;
4732   ULONG AsULONG;
4733 } PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER;
4734 
4735 typedef struct _PCI_EXPRESS_CAPABILITY {
4736   PCI_CAPABILITIES_HEADER Header;
4737   PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities;
4738   PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities;
4739   PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl;
4740   PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus;
4741   PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities;
4742   PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl;
4743   PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus;
4744   PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities;
4745   PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl;
4746   PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus;
4747   PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl;
4748   PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities;
4749   PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus;
4750 } PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY;
4751 
4752 typedef enum {
4753   MRLClosed = 0,
4754   MRLOpen
4755 } PCI_EXPRESS_MRL_STATE;
4756 
4757 typedef enum {
4758   SlotEmpty = 0,
4759   CardPresent
4760 } PCI_EXPRESS_CARD_PRESENCE;
4761 
4762 typedef enum {
4763   IndicatorOn = 1,
4764   IndicatorBlink,
4765   IndicatorOff
4766 } PCI_EXPRESS_INDICATOR_STATE;
4767 
4768 typedef enum {
4769   PowerOn = 0,
4770   PowerOff
4771 } PCI_EXPRESS_POWER_STATE;
4772 
4773 typedef enum {
4774   L0sEntrySupport = 1,
4775   L0sAndL1EntrySupport = 3
4776 } PCI_EXPRESS_ASPM_SUPPORT;
4777 
4778 typedef enum {
4779   L0sAndL1EntryDisabled,
4780   L0sEntryEnabled,
4781   L1EntryEnabled,
4782   L0sAndL1EntryEnabled
4783 } PCI_EXPRESS_ASPM_CONTROL;
4784 
4785 typedef enum {
4786   L0s_Below64ns = 0,
4787   L0s_64ns_128ns,
4788   L0s_128ns_256ns,
4789   L0s_256ns_512ns,
4790   L0s_512ns_1us,
4791   L0s_1us_2us,
4792   L0s_2us_4us,
4793   L0s_Above4us
4794 } PCI_EXPRESS_L0s_EXIT_LATENCY;
4795 
4796 typedef enum {
4797   L1_Below1us = 0,
4798   L1_1us_2us,
4799   L1_2us_4us,
4800   L1_4us_8us,
4801   L1_8us_16us,
4802   L1_16us_32us,
4803   L1_32us_64us,
4804   L1_Above64us
4805 } PCI_EXPRESS_L1_EXIT_LATENCY;
4806 
4807 typedef enum {
4808   PciExpressEndpoint = 0,
4809   PciExpressLegacyEndpoint,
4810   PciExpressRootPort = 4,
4811   PciExpressUpstreamSwitchPort,
4812   PciExpressDownstreamSwitchPort,
4813   PciExpressToPciXBridge,
4814   PciXToExpressBridge,
4815   PciExpressRootComplexIntegratedEndpoint,
4816   PciExpressRootComplexEventCollector
4817 } PCI_EXPRESS_DEVICE_TYPE;
4818 
4819 typedef enum {
4820   MaxPayload128Bytes = 0,
4821   MaxPayload256Bytes,
4822   MaxPayload512Bytes,
4823   MaxPayload1024Bytes,
4824   MaxPayload2048Bytes,
4825   MaxPayload4096Bytes
4826 } PCI_EXPRESS_MAX_PAYLOAD_SIZE;
4827 
4828 typedef union _PCI_EXPRESS_PME_REQUESTOR_ID {
4829   _ANONYMOUS_STRUCT struct {
4830     USHORT FunctionNumber:3;
4831     USHORT DeviceNumber:5;
4832     USHORT BusNumber:8;
4833   } DUMMYSTRUCTNAME;
4834   USHORT AsUSHORT;
4835 } PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID;
4836 
4837 typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE {
4838   ResourceTypeSingle = 0,
4839   ResourceTypeRange,
4840   ResourceTypeExtendedCounterConfiguration,
4841   ResourceTypeOverflow,
4842   ResourceTypeMax
4843 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE;
4844 
4845 typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR {
4846   PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type;
4847   ULONG Flags;
4848   union {
4849     ULONG CounterIndex;
4850     ULONG ExtendedRegisterAddress;
4851     struct {
4852       ULONG Begin;
4853       ULONG End;
4854     } Range;
4855   } u;
4856 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR;
4857 
4858 typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST {
4859   ULONG Count;
4860   PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY];
4861 } PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST;
4862 
4863 typedef VOID
4864 (NTAPI *PciPin2Line)(
4865   _In_ struct _BUS_HANDLER *BusHandler,
4866   _In_ struct _BUS_HANDLER *RootHandler,
4867   _In_ PCI_SLOT_NUMBER SlotNumber,
4868   _In_ PPCI_COMMON_CONFIG PciData);
4869 
4870 typedef VOID
4871 (NTAPI *PciLine2Pin)(
4872   _In_ struct _BUS_HANDLER *BusHandler,
4873   _In_ struct _BUS_HANDLER *RootHandler,
4874   _In_ PCI_SLOT_NUMBER SlotNumber,
4875   _In_ PPCI_COMMON_CONFIG PciNewData,
4876   _In_ PPCI_COMMON_CONFIG PciOldData);
4877 
4878 typedef VOID
4879 (NTAPI *PciReadWriteConfig)(
4880   _In_ struct _BUS_HANDLER *BusHandler,
4881   _In_ PCI_SLOT_NUMBER Slot,
4882   _In_reads_bytes_(Length) PVOID Buffer,
4883   _In_ ULONG Offset,
4884   _In_ ULONG Length);
4885 
4886 #define PCI_DATA_TAG ' ICP'
4887 #define PCI_DATA_VERSION 1
4888 
4889 typedef struct _PCIBUSDATA {
4890   ULONG Tag;
4891   ULONG Version;
4892   PciReadWriteConfig ReadConfig;
4893   PciReadWriteConfig WriteConfig;
4894   PciPin2Line Pin2Line;
4895   PciLine2Pin Line2Pin;
4896   PCI_SLOT_NUMBER ParentSlot;
4897   PVOID Reserved[4];
4898 } PCIBUSDATA, *PPCIBUSDATA;
4899 
4900 #ifndef _PCIINTRF_X_
4901 #define _PCIINTRF_X_
4902 
4903 typedef ULONG
4904 (NTAPI *PCI_READ_WRITE_CONFIG)(
4905   _In_ PVOID Context,
4906   _In_ ULONG BusOffset,
4907   _In_ ULONG Slot,
4908   _In_reads_bytes_(Length) PVOID Buffer,
4909   _In_ ULONG Offset,
4910   _In_ ULONG Length);
4911 
4912 typedef VOID
4913 (NTAPI *PCI_PIN_TO_LINE)(
4914   _In_ PVOID Context,
4915   _In_ PPCI_COMMON_CONFIG PciData);
4916 
4917 typedef VOID
4918 (NTAPI *PCI_LINE_TO_PIN)(
4919   _In_ PVOID Context,
4920   _In_ PPCI_COMMON_CONFIG PciNewData,
4921   _In_ PPCI_COMMON_CONFIG PciOldData);
4922 
4923 typedef VOID
4924 (NTAPI *PCI_ROOT_BUS_CAPABILITY)(
4925   _In_ PVOID Context,
4926   _Out_ PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability);
4927 
4928 typedef VOID
4929 (NTAPI *PCI_EXPRESS_WAKE_CONTROL)(
4930   _In_ PVOID Context,
4931   _In_ BOOLEAN EnableWake);
4932 
4933 typedef struct _PCI_BUS_INTERFACE_STANDARD {
4934   USHORT Size;
4935   USHORT Version;
4936   PVOID Context;
4937   PINTERFACE_REFERENCE InterfaceReference;
4938   PINTERFACE_DEREFERENCE InterfaceDereference;
4939   PCI_READ_WRITE_CONFIG ReadConfig;
4940   PCI_READ_WRITE_CONFIG WriteConfig;
4941   PCI_PIN_TO_LINE PinToLine;
4942   PCI_LINE_TO_PIN LineToPin;
4943   PCI_ROOT_BUS_CAPABILITY RootBusCapability;
4944   PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl;
4945 } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
4946 
4947 #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
4948 
4949 #endif /* _PCIINTRF_X_ */
4950 
4951 #if (NTDDI_VERSION >= NTDDI_WIN7)
4952 
4953 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX     0x00004000
4954 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX    0x00008000
4955 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \
4956   (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \
4957    FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX)
4958 
4959 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200
4960 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300
4961 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300
4962 
4963 #else
4964 
4965 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL     0x00000200
4966 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL    0x00000300
4967 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK        0x00000300
4968 
4969 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL
4970 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL
4971 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK
4972 
4973 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
4974 
4975 #define FILE_CHARACTERISTICS_PROPAGATED (FILE_REMOVABLE_MEDIA  | \
4976                                          FILE_READ_ONLY_DEVICE | \
4977                                          FILE_FLOPPY_DISKETTE  | \
4978                                          FILE_WRITE_ONCE_MEDIA | \
4979                                          FILE_DEVICE_SECURE_OPEN)
4980 
4981 typedef struct _FILE_ALIGNMENT_INFORMATION {
4982   ULONG AlignmentRequirement;
4983 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
4984 
4985 typedef struct _FILE_NAME_INFORMATION {
4986   ULONG FileNameLength;
4987   WCHAR FileName[1];
4988 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
4989 
4990 
4991 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
4992   ULONG FileAttributes;
4993   ULONG ReparseTag;
4994 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
4995 
4996 typedef struct _FILE_DISPOSITION_INFORMATION {
4997   BOOLEAN DeleteFile;
4998 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
4999 
5000 typedef struct _FILE_END_OF_FILE_INFORMATION {
5001   LARGE_INTEGER EndOfFile;
5002 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
5003 
5004 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
5005   LARGE_INTEGER ValidDataLength;
5006 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
5007 
5008 typedef struct _FILE_FS_LABEL_INFORMATION {
5009   ULONG VolumeLabelLength;
5010   WCHAR VolumeLabel[1];
5011 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
5012 
5013 typedef struct _FILE_FS_VOLUME_INFORMATION {
5014   LARGE_INTEGER VolumeCreationTime;
5015   ULONG VolumeSerialNumber;
5016   ULONG VolumeLabelLength;
5017   BOOLEAN SupportsObjects;
5018   WCHAR VolumeLabel[1];
5019 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
5020 
5021 typedef struct _FILE_FS_SIZE_INFORMATION {
5022   LARGE_INTEGER TotalAllocationUnits;
5023   LARGE_INTEGER AvailableAllocationUnits;
5024   ULONG SectorsPerAllocationUnit;
5025   ULONG BytesPerSector;
5026 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
5027 
5028 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
5029   LARGE_INTEGER TotalAllocationUnits;
5030   LARGE_INTEGER CallerAvailableAllocationUnits;
5031   LARGE_INTEGER ActualAvailableAllocationUnits;
5032   ULONG SectorsPerAllocationUnit;
5033   ULONG BytesPerSector;
5034 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
5035 
5036 typedef struct _FILE_FS_OBJECTID_INFORMATION {
5037   UCHAR ObjectId[16];
5038   UCHAR ExtendedInfo[48];
5039 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
5040 
5041 typedef union _FILE_SEGMENT_ELEMENT {
5042   PVOID64 Buffer;
5043   ULONGLONG Alignment;
5044 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5045 
5046 #define IOCTL_AVIO_ALLOCATE_STREAM      CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5047 #define IOCTL_AVIO_FREE_STREAM          CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5048 #define IOCTL_AVIO_MODIFY_STREAM        CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5049 
5050 typedef enum _BUS_DATA_TYPE {
5051   ConfigurationSpaceUndefined = -1,
5052   Cmos,
5053   EisaConfiguration,
5054   Pos,
5055   CbusConfiguration,
5056   PCIConfiguration,
5057   VMEConfiguration,
5058   NuBusConfiguration,
5059   PCMCIAConfiguration,
5060   MPIConfiguration,
5061   MPSAConfiguration,
5062   PNPISAConfiguration,
5063   SgiInternalConfiguration,
5064   MaximumBusDataType
5065 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
5066 
5067 /* Some Server 2003 DDK definitions */
5068 #define PCI_INT_ROUTE_INTRF_STANDARD_VER 1
5069 
5070 typedef NTSTATUS
5071 (NTAPI *PLEGACY_DEVICE_DETECTION_HANDLER)(
5072   IN PVOID Context,
5073   IN INTERFACE_TYPE LegacyBusType,
5074   IN ULONG BusNumber,
5075   IN ULONG SlotNumber,
5076   OUT PDEVICE_OBJECT *PhysicalDeviceObject);
5077 
5078 typedef struct _ROUTING_TOKEN {
5079   PVOID LinkNode;
5080   ULONG StaticVector;
5081   UCHAR Flags;
5082 } ROUTING_TOKEN, *PROUTING_TOKEN;
5083 
5084 typedef NTSTATUS
5085 (NTAPI *PGET_INTERRUPT_ROUTING)(
5086   IN PDEVICE_OBJECT Pdo,
5087   OUT ULONG *Bus,
5088   OUT ULONG *PciSlot,
5089   OUT UCHAR *InterruptLine,
5090   OUT UCHAR *InterruptPin,
5091   OUT UCHAR *ClassCode,
5092   OUT UCHAR *SubClassCode,
5093   OUT PDEVICE_OBJECT *ParentPdo,
5094   OUT ROUTING_TOKEN *RoutingToken,
5095   OUT UCHAR *Flags);
5096 
5097 typedef NTSTATUS
5098 (NTAPI *PSET_INTERRUPT_ROUTING_TOKEN)(
5099   IN PDEVICE_OBJECT Pdo,
5100   IN PROUTING_TOKEN RoutingToken);
5101 
5102 typedef VOID
5103 (NTAPI *PUPDATE_INTERRUPT_LINE)(
5104   IN PDEVICE_OBJECT Pdo,
5105   IN UCHAR LineRegister);
5106 
5107 typedef struct _INT_ROUTE_INTERFACE_STANDARD {
5108   USHORT Size;
5109   USHORT Version;
5110   PVOID Context;
5111   PINTERFACE_REFERENCE InterfaceReference;
5112   PINTERFACE_DEREFERENCE InterfaceDereference;
5113   PGET_INTERRUPT_ROUTING GetInterruptRouting;
5114   PSET_INTERRUPT_ROUTING_TOKEN SetInterruptRoutingToken;
5115   PUPDATE_INTERRUPT_LINE UpdateInterruptLine;
5116 } INT_ROUTE_INTERFACE_STANDARD, *PINT_ROUTE_INTERFACE_STANDARD;
5117 
5118 typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE {
5119   USHORT Size;
5120   USHORT Version;
5121   PVOID Context;
5122   PINTERFACE_REFERENCE InterfaceReference;
5123   PINTERFACE_DEREFERENCE InterfaceDereference;
5124   PLEGACY_DEVICE_DETECTION_HANDLER LegacyDeviceDetection;
5125 } LEGACY_DEVICE_DETECTION_INTERFACE, *PLEGACY_DEVICE_DETECTION_INTERFACE;
5126 
5127 /* FIXME : These definitions don't exist in public headers */
5128 
5129 #define PCI_CB_INTRF_VERSION             1
5130 #define PCI_PME_INTRF_STANDARD_VER       1
5131 #define PNP_LOCATION_INTERFACE_VERSION   1
5132 
5133 DEFINE_GUID(GUID_PCI_CARDBUS_INTERFACE_PRIVATE, 0xcca82f31, 0x54d6, 0x11d1, 0x82, 0x24, 0x00, 0xa0, 0xc9, 0x32, 0x43, 0x85);
5134 DEFINE_GUID(GUID_PCI_PME_INTERFACE, 0xaac7e6ac, 0xbb0b, 0x11d2, 0xb4, 0x84, 0x00, 0xc0, 0x4f, 0x72, 0xde, 0x8b);
5135 
5136 typedef NTSTATUS
5137 (NTAPI *PCARDBUSADD)(
5138   IN PDEVICE_OBJECT DeviceObject,
5139   IN OUT PVOID *DeviceContext);
5140 
5141 typedef NTSTATUS
5142 (NTAPI *PCARDBUSDELETE)(
5143   IN PVOID DeviceContext);
5144 
5145 typedef NTSTATUS
5146 (NTAPI *PCARDBUSPCIDISPATCH)(
5147   IN PVOID DeviceContext,
5148   IN PIRP Irp);
5149 
5150 typedef VOID
5151 (NTAPI *PPME_SET_PME_ENABLE)(
5152   IN PDEVICE_OBJECT Pdo,
5153   IN BOOLEAN PmeEnable);
5154 
5155 typedef VOID
5156 (NTAPI *PPME_CLEAR_PME_STATUS)(
5157   IN PDEVICE_OBJECT Pdo);
5158 
5159 typedef VOID
5160 (NTAPI *PPME_GET_INFORMATION)(
5161   IN PDEVICE_OBJECT Pdo,
5162   OUT PBOOLEAN PmeCapable,
5163   OUT PBOOLEAN PmeStatus,
5164   OUT PBOOLEAN PmeEnable);
5165 
5166 typedef struct _PCI_CARDBUS_INTERFACE_PRIVATE {
5167   USHORT Size;
5168   USHORT Version;
5169   PVOID Context;
5170   PINTERFACE_REFERENCE InterfaceReference;
5171   PINTERFACE_DEREFERENCE InterfaceDereference;
5172   PDRIVER_OBJECT DriverObject;
5173   PCARDBUSADD AddCardBus;
5174   PCARDBUSDELETE DeleteCardBus;
5175   PCARDBUSPCIDISPATCH DispatchPnp;
5176 } PCI_CARDBUS_INTERFACE_PRIVATE, *PPCI_CARDBUS_INTERFACE_PRIVATE;
5177 
5178 typedef struct _PCI_PME_INTERFACE {
5179   USHORT Size;
5180   USHORT Version;
5181   PVOID Context;
5182   PINTERFACE_REFERENCE InterfaceReference;
5183   PINTERFACE_DEREFERENCE InterfaceDereference;
5184   PPME_GET_INFORMATION GetPmeInformation;
5185   PPME_CLEAR_PME_STATUS ClearPmeStatus;
5186   PPME_SET_PME_ENABLE UpdateEnable;
5187 } PCI_PME_INTERFACE, *PPCI_PME_INTERFACE;
5188 
5189 $endif (_NTDDK_)
5190 $if (_NTIFS_)
5191 
5192 #define FILE_OPLOCK_BROKEN_TO_LEVEL_2   0x00000007
5193 #define FILE_OPLOCK_BROKEN_TO_NONE      0x00000008
5194 #define FILE_OPBATCH_BREAK_UNDERWAY     0x00000009
5195 
5196 /* also in winnt.h */
5197 #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
5198 #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
5199 #define FILE_NOTIFY_CHANGE_NAME         0x00000003
5200 #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
5201 #define FILE_NOTIFY_CHANGE_SIZE         0x00000008
5202 #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
5203 #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
5204 #define FILE_NOTIFY_CHANGE_CREATION     0x00000040
5205 #define FILE_NOTIFY_CHANGE_EA           0x00000080
5206 #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
5207 #define FILE_NOTIFY_CHANGE_STREAM_NAME  0x00000200
5208 #define FILE_NOTIFY_CHANGE_STREAM_SIZE  0x00000400
5209 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5210 #define FILE_NOTIFY_VALID_MASK          0x00000fff
5211 
5212 #define FILE_ACTION_ADDED                   0x00000001
5213 #define FILE_ACTION_REMOVED                 0x00000002
5214 #define FILE_ACTION_MODIFIED                0x00000003
5215 #define FILE_ACTION_RENAMED_OLD_NAME        0x00000004
5216 #define FILE_ACTION_RENAMED_NEW_NAME        0x00000005
5217 #define FILE_ACTION_ADDED_STREAM            0x00000006
5218 #define FILE_ACTION_REMOVED_STREAM          0x00000007
5219 #define FILE_ACTION_MODIFIED_STREAM         0x00000008
5220 #define FILE_ACTION_REMOVED_BY_DELETE       0x00000009
5221 #define FILE_ACTION_ID_NOT_TUNNELLED        0x0000000A
5222 #define FILE_ACTION_TUNNELLED_ID_COLLISION  0x0000000B
5223 /* end  winnt.h */
5224 
5225 #define FILE_PIPE_BYTE_STREAM_TYPE          0x00000000
5226 #define FILE_PIPE_MESSAGE_TYPE              0x00000001
5227 
5228 #define FILE_PIPE_ACCEPT_REMOTE_CLIENTS     0x00000000
5229 #define FILE_PIPE_REJECT_REMOTE_CLIENTS     0x00000002
5230 
5231 #define FILE_PIPE_ACCEPT_REMOTE_CLIENTS     0x00000000
5232 #define FILE_PIPE_REJECT_REMOTE_CLIENTS     0x00000002
5233 #define FILE_PIPE_TYPE_VALID_MASK           0x00000003
5234 
5235 #define FILE_PIPE_BYTE_STREAM_MODE          0x00000000
5236 #define FILE_PIPE_MESSAGE_MODE              0x00000001
5237 
5238 #define FILE_PIPE_QUEUE_OPERATION           0x00000000
5239 #define FILE_PIPE_COMPLETE_OPERATION        0x00000001
5240 
5241 #define FILE_PIPE_INBOUND                   0x00000000
5242 #define FILE_PIPE_OUTBOUND                  0x00000001
5243 #define FILE_PIPE_FULL_DUPLEX               0x00000002
5244 
5245 #define FILE_PIPE_DISCONNECTED_STATE        0x00000001
5246 #define FILE_PIPE_LISTENING_STATE           0x00000002
5247 #define FILE_PIPE_CONNECTED_STATE           0x00000003
5248 #define FILE_PIPE_CLOSING_STATE             0x00000004
5249 
5250 #define FILE_PIPE_CLIENT_END                0x00000000
5251 #define FILE_PIPE_SERVER_END                0x00000001
5252 
5253 #define FILE_CASE_SENSITIVE_SEARCH          0x00000001
5254 #define FILE_CASE_PRESERVED_NAMES           0x00000002
5255 #define FILE_UNICODE_ON_DISK                0x00000004
5256 #define FILE_PERSISTENT_ACLS                0x00000008
5257 #define FILE_FILE_COMPRESSION               0x00000010
5258 #define FILE_VOLUME_QUOTAS                  0x00000020
5259 #define FILE_SUPPORTS_SPARSE_FILES          0x00000040
5260 #define FILE_SUPPORTS_REPARSE_POINTS        0x00000080
5261 #define FILE_SUPPORTS_REMOTE_STORAGE        0x00000100
5262 #define FILE_VOLUME_IS_COMPRESSED           0x00008000
5263 #define FILE_SUPPORTS_OBJECT_IDS            0x00010000
5264 #define FILE_SUPPORTS_ENCRYPTION            0x00020000
5265 #define FILE_NAMED_STREAMS                  0x00040000
5266 #define FILE_READ_ONLY_VOLUME               0x00080000
5267 #define FILE_SEQUENTIAL_WRITE_ONCE          0x00100000
5268 #define FILE_SUPPORTS_TRANSACTIONS          0x00200000
5269 #define FILE_SUPPORTS_HARD_LINKS            0x00400000
5270 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES   0x00800000
5271 #define FILE_SUPPORTS_OPEN_BY_FILE_ID       0x01000000
5272 #define FILE_SUPPORTS_USN_JOURNAL           0x02000000
5273 #define FILE_SUPPORTS_INTEGRITY_STREAMS     0x04000000
5274 #define FILE_SUPPORTS_BLOCK_REFCOUNTING     0x08000000
5275 #define FILE_SUPPORTS_SPARSE_VDL            0x10000000
5276 #define FILE_DAX_VOLUME                     0x20000000
5277 
5278 #define FILE_NEED_EA                    0x00000080
5279 
5280 #define FILE_EA_TYPE_BINARY             0xfffe
5281 #define FILE_EA_TYPE_ASCII              0xfffd
5282 #define FILE_EA_TYPE_BITMAP             0xfffb
5283 #define FILE_EA_TYPE_METAFILE           0xfffa
5284 #define FILE_EA_TYPE_ICON               0xfff9
5285 #define FILE_EA_TYPE_EA                 0xffee
5286 #define FILE_EA_TYPE_MVMT               0xffdf
5287 #define FILE_EA_TYPE_MVST               0xffde
5288 #define FILE_EA_TYPE_ASN1               0xffdd
5289 #define FILE_EA_TYPE_FAMILY_IDS         0xff01
5290 
5291 typedef struct _FILE_NOTIFY_INFORMATION {
5292   ULONG NextEntryOffset;
5293   ULONG Action;
5294   ULONG FileNameLength;
5295   WCHAR FileName[1];
5296 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5297 
5298 typedef struct _FILE_DIRECTORY_INFORMATION {
5299   ULONG NextEntryOffset;
5300   ULONG FileIndex;
5301   LARGE_INTEGER CreationTime;
5302   LARGE_INTEGER LastAccessTime;
5303   LARGE_INTEGER LastWriteTime;
5304   LARGE_INTEGER ChangeTime;
5305   LARGE_INTEGER EndOfFile;
5306   LARGE_INTEGER AllocationSize;
5307   ULONG FileAttributes;
5308   ULONG FileNameLength;
5309   WCHAR FileName[1];
5310 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
5311 
5312 typedef struct _FILE_FULL_DIR_INFORMATION {
5313   ULONG NextEntryOffset;
5314   ULONG FileIndex;
5315   LARGE_INTEGER CreationTime;
5316   LARGE_INTEGER LastAccessTime;
5317   LARGE_INTEGER LastWriteTime;
5318   LARGE_INTEGER ChangeTime;
5319   LARGE_INTEGER EndOfFile;
5320   LARGE_INTEGER AllocationSize;
5321   ULONG FileAttributes;
5322   ULONG FileNameLength;
5323   ULONG EaSize;
5324   WCHAR FileName[1];
5325 } FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
5326 
5327 typedef struct _FILE_ID_FULL_DIR_INFORMATION {
5328   ULONG NextEntryOffset;
5329   ULONG FileIndex;
5330   LARGE_INTEGER CreationTime;
5331   LARGE_INTEGER LastAccessTime;
5332   LARGE_INTEGER LastWriteTime;
5333   LARGE_INTEGER ChangeTime;
5334   LARGE_INTEGER EndOfFile;
5335   LARGE_INTEGER AllocationSize;
5336   ULONG FileAttributes;
5337   ULONG FileNameLength;
5338   ULONG EaSize;
5339   LARGE_INTEGER FileId;
5340   WCHAR FileName[1];
5341 } FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;
5342 
5343 typedef struct _FILE_BOTH_DIR_INFORMATION {
5344   ULONG NextEntryOffset;
5345   ULONG FileIndex;
5346   LARGE_INTEGER CreationTime;
5347   LARGE_INTEGER LastAccessTime;
5348   LARGE_INTEGER LastWriteTime;
5349   LARGE_INTEGER ChangeTime;
5350   LARGE_INTEGER EndOfFile;
5351   LARGE_INTEGER AllocationSize;
5352   ULONG FileAttributes;
5353   ULONG FileNameLength;
5354   ULONG EaSize;
5355   CCHAR ShortNameLength;
5356   WCHAR ShortName[12];
5357   WCHAR FileName[1];
5358 } FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
5359 
5360 typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
5361   ULONG NextEntryOffset;
5362   ULONG FileIndex;
5363   LARGE_INTEGER CreationTime;
5364   LARGE_INTEGER LastAccessTime;
5365   LARGE_INTEGER LastWriteTime;
5366   LARGE_INTEGER ChangeTime;
5367   LARGE_INTEGER EndOfFile;
5368   LARGE_INTEGER AllocationSize;
5369   ULONG FileAttributes;
5370   ULONG FileNameLength;
5371   ULONG EaSize;
5372   CCHAR ShortNameLength;
5373   WCHAR ShortName[12];
5374   LARGE_INTEGER FileId;
5375   WCHAR FileName[1];
5376 } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
5377 
5378 typedef struct _FILE_NAMES_INFORMATION {
5379   ULONG NextEntryOffset;
5380   ULONG FileIndex;
5381   ULONG FileNameLength;
5382   WCHAR FileName[1];
5383 } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
5384 
5385 typedef struct _FILE_ID_GLOBAL_TX_DIR_INFORMATION {
5386   ULONG NextEntryOffset;
5387   ULONG FileIndex;
5388   LARGE_INTEGER CreationTime;
5389   LARGE_INTEGER LastAccessTime;
5390   LARGE_INTEGER LastWriteTime;
5391   LARGE_INTEGER ChangeTime;
5392   LARGE_INTEGER EndOfFile;
5393   LARGE_INTEGER AllocationSize;
5394   ULONG FileAttributes;
5395   ULONG FileNameLength;
5396   LARGE_INTEGER FileId;
5397   GUID LockingTransactionId;
5398   ULONG TxInfoFlags;
5399   WCHAR FileName[1];
5400 } FILE_ID_GLOBAL_TX_DIR_INFORMATION, *PFILE_ID_GLOBAL_TX_DIR_INFORMATION;
5401 
5402 #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_WRITELOCKED         0x00000001
5403 #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_VISIBLE_TO_TX       0x00000002
5404 #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_VISIBLE_OUTSIDE_TX  0x00000004
5405 
5406 typedef struct _FILE_OBJECTID_INFORMATION {
5407   LONGLONG FileReference;
5408   UCHAR ObjectId[16];
5409   _ANONYMOUS_UNION union {
5410     _ANONYMOUS_STRUCT struct {
5411       UCHAR BirthVolumeId[16];
5412       UCHAR BirthObjectId[16];
5413       UCHAR DomainId[16];
5414     } DUMMYSTRUCTNAME;
5415     UCHAR ExtendedInfo[48];
5416   } DUMMYUNIONNAME;
5417 } FILE_OBJECTID_INFORMATION, *PFILE_OBJECTID_INFORMATION;
5418 
5419 #define ANSI_DOS_STAR                   ('<')
5420 #define ANSI_DOS_QM                     ('>')
5421 #define ANSI_DOS_DOT                    ('"')
5422 
5423 #define DOS_STAR                        (L'<')
5424 #define DOS_QM                          (L'>')
5425 #define DOS_DOT                         (L'"')
5426 
5427 typedef struct _FILE_INTERNAL_INFORMATION {
5428   LARGE_INTEGER IndexNumber;
5429 } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
5430 
5431 typedef struct _FILE_EA_INFORMATION {
5432   ULONG EaSize;
5433 } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
5434 
5435 typedef struct _FILE_ACCESS_INFORMATION {
5436   ACCESS_MASK AccessFlags;
5437 } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
5438 
5439 typedef struct _FILE_MODE_INFORMATION {
5440   ULONG Mode;
5441 } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
5442 
5443 typedef struct _FILE_ALL_INFORMATION {
5444   FILE_BASIC_INFORMATION BasicInformation;
5445   FILE_STANDARD_INFORMATION StandardInformation;
5446   FILE_INTERNAL_INFORMATION InternalInformation;
5447   FILE_EA_INFORMATION EaInformation;
5448   FILE_ACCESS_INFORMATION AccessInformation;
5449   FILE_POSITION_INFORMATION PositionInformation;
5450   FILE_MODE_INFORMATION ModeInformation;
5451   FILE_ALIGNMENT_INFORMATION AlignmentInformation;
5452   FILE_NAME_INFORMATION NameInformation;
5453 } FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
5454 
5455 typedef struct _FILE_ALLOCATION_INFORMATION {
5456   LARGE_INTEGER AllocationSize;
5457 } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
5458 
5459 typedef struct _FILE_COMPRESSION_INFORMATION {
5460   LARGE_INTEGER CompressedFileSize;
5461   USHORT CompressionFormat;
5462   UCHAR CompressionUnitShift;
5463   UCHAR ChunkShift;
5464   UCHAR ClusterShift;
5465   UCHAR Reserved[3];
5466 } FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
5467 
5468 typedef struct _FILE_LINK_INFORMATION {
5469   BOOLEAN ReplaceIfExists;
5470   HANDLE RootDirectory;
5471   ULONG FileNameLength;
5472   WCHAR FileName[1];
5473 } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
5474 
5475 typedef struct _FILE_MOVE_CLUSTER_INFORMATION {
5476   ULONG ClusterCount;
5477   HANDLE RootDirectory;
5478   ULONG FileNameLength;
5479   WCHAR FileName[1];
5480 } FILE_MOVE_CLUSTER_INFORMATION, *PFILE_MOVE_CLUSTER_INFORMATION;
5481 
5482 typedef struct _FILE_RENAME_INFORMATION {
5483   BOOLEAN ReplaceIfExists;
5484   HANDLE RootDirectory;
5485   ULONG FileNameLength;
5486   WCHAR FileName[1];
5487 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
5488 
5489 typedef struct _FILE_STREAM_INFORMATION {
5490   ULONG NextEntryOffset;
5491   ULONG StreamNameLength;
5492   LARGE_INTEGER StreamSize;
5493   LARGE_INTEGER StreamAllocationSize;
5494   WCHAR StreamName[1];
5495 } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
5496 
5497 typedef struct _FILE_TRACKING_INFORMATION {
5498   HANDLE DestinationFile;
5499   ULONG ObjectInformationLength;
5500   CHAR ObjectInformation[1];
5501 } FILE_TRACKING_INFORMATION, *PFILE_TRACKING_INFORMATION;
5502 
5503 typedef struct _FILE_COMPLETION_INFORMATION {
5504   HANDLE Port;
5505   PVOID Key;
5506 } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
5507 
5508 typedef struct _FILE_PIPE_INFORMATION {
5509   ULONG ReadMode;
5510   ULONG CompletionMode;
5511 } FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
5512 
5513 typedef struct _FILE_PIPE_LOCAL_INFORMATION {
5514   ULONG NamedPipeType;
5515   ULONG NamedPipeConfiguration;
5516   ULONG MaximumInstances;
5517   ULONG CurrentInstances;
5518   ULONG InboundQuota;
5519   ULONG ReadDataAvailable;
5520   ULONG OutboundQuota;
5521   ULONG WriteQuotaAvailable;
5522   ULONG NamedPipeState;
5523   ULONG NamedPipeEnd;
5524 } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
5525 
5526 typedef struct _FILE_PIPE_REMOTE_INFORMATION {
5527   LARGE_INTEGER CollectDataTime;
5528   ULONG MaximumCollectionCount;
5529 } FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
5530 
5531 typedef struct _FILE_MAILSLOT_QUERY_INFORMATION {
5532   ULONG MaximumMessageSize;
5533   ULONG MailslotQuota;
5534   ULONG NextMessageSize;
5535   ULONG MessagesAvailable;
5536   LARGE_INTEGER ReadTimeout;
5537 } FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION;
5538 
5539 typedef struct _FILE_MAILSLOT_SET_INFORMATION {
5540   PLARGE_INTEGER ReadTimeout;
5541 } FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
5542 
5543 typedef struct _FILE_REPARSE_POINT_INFORMATION {
5544   LONGLONG FileReference;
5545   ULONG Tag;
5546 } FILE_REPARSE_POINT_INFORMATION, *PFILE_REPARSE_POINT_INFORMATION;
5547 
5548 typedef struct _FILE_LINK_ENTRY_INFORMATION {
5549   ULONG NextEntryOffset;
5550   LONGLONG ParentFileId;
5551   ULONG FileNameLength;
5552   WCHAR FileName[1];
5553 } FILE_LINK_ENTRY_INFORMATION, *PFILE_LINK_ENTRY_INFORMATION;
5554 
5555 typedef struct _FILE_LINKS_INFORMATION {
5556   ULONG BytesNeeded;
5557   ULONG EntriesReturned;
5558   FILE_LINK_ENTRY_INFORMATION Entry;
5559 } FILE_LINKS_INFORMATION, *PFILE_LINKS_INFORMATION;
5560 
5561 typedef struct _FILE_NETWORK_PHYSICAL_NAME_INFORMATION {
5562   ULONG FileNameLength;
5563   WCHAR FileName[1];
5564 } FILE_NETWORK_PHYSICAL_NAME_INFORMATION, *PFILE_NETWORK_PHYSICAL_NAME_INFORMATION;
5565 
5566 typedef struct _FILE_STANDARD_LINK_INFORMATION {
5567   ULONG NumberOfAccessibleLinks;
5568   ULONG TotalNumberOfLinks;
5569   BOOLEAN DeletePending;
5570   BOOLEAN Directory;
5571 } FILE_STANDARD_LINK_INFORMATION, *PFILE_STANDARD_LINK_INFORMATION;
5572 
5573 typedef struct _FILE_GET_EA_INFORMATION {
5574   ULONG NextEntryOffset;
5575   UCHAR EaNameLength;
5576   CHAR  EaName[1];
5577 } FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
5578 
5579 #define REMOTE_PROTOCOL_FLAG_LOOPBACK       0x00000001
5580 #define REMOTE_PROTOCOL_FLAG_OFFLINE        0x00000002
5581 
5582 typedef struct _FILE_REMOTE_PROTOCOL_INFORMATION {
5583   USHORT StructureVersion;
5584   USHORT StructureSize;
5585   ULONG  Protocol;
5586   USHORT ProtocolMajorVersion;
5587   USHORT ProtocolMinorVersion;
5588   USHORT ProtocolRevision;
5589   USHORT Reserved;
5590   ULONG  Flags;
5591   struct {
5592     ULONG Reserved[8];
5593   } GenericReserved;
5594   struct {
5595     ULONG Reserved[16];
5596   } ProtocolSpecificReserved;
5597 } FILE_REMOTE_PROTOCOL_INFORMATION, *PFILE_REMOTE_PROTOCOL_INFORMATION;
5598 
5599 typedef struct _FILE_GET_QUOTA_INFORMATION {
5600   ULONG NextEntryOffset;
5601   ULONG SidLength;
5602   SID Sid;
5603 } FILE_GET_QUOTA_INFORMATION, *PFILE_GET_QUOTA_INFORMATION;
5604 
5605 typedef struct _FILE_QUOTA_INFORMATION {
5606   ULONG NextEntryOffset;
5607   ULONG SidLength;
5608   LARGE_INTEGER ChangeTime;
5609   LARGE_INTEGER QuotaUsed;
5610   LARGE_INTEGER QuotaThreshold;
5611   LARGE_INTEGER QuotaLimit;
5612   SID Sid;
5613 } FILE_QUOTA_INFORMATION, *PFILE_QUOTA_INFORMATION;
5614 
5615 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
5616   ULONG FileSystemAttributes;
5617   ULONG MaximumComponentNameLength;
5618   ULONG FileSystemNameLength;
5619   WCHAR FileSystemName[1];
5620 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
5621 
5622 typedef struct _FILE_FS_DRIVER_PATH_INFORMATION {
5623   BOOLEAN DriverInPath;
5624   ULONG DriverNameLength;
5625   WCHAR DriverName[1];
5626 } FILE_FS_DRIVER_PATH_INFORMATION, *PFILE_FS_DRIVER_PATH_INFORMATION;
5627 
5628 typedef struct _FILE_FS_VOLUME_FLAGS_INFORMATION {
5629   ULONG Flags;
5630 } FILE_FS_VOLUME_FLAGS_INFORMATION, *PFILE_FS_VOLUME_FLAGS_INFORMATION;
5631 
5632 #define FILE_VC_QUOTA_NONE              0x00000000
5633 #define FILE_VC_QUOTA_TRACK             0x00000001
5634 #define FILE_VC_QUOTA_ENFORCE           0x00000002
5635 #define FILE_VC_QUOTA_MASK              0x00000003
5636 #define FILE_VC_CONTENT_INDEX_DISABLED  0x00000008
5637 #define FILE_VC_LOG_QUOTA_THRESHOLD     0x00000010
5638 #define FILE_VC_LOG_QUOTA_LIMIT         0x00000020
5639 #define FILE_VC_LOG_VOLUME_THRESHOLD    0x00000040
5640 #define FILE_VC_LOG_VOLUME_LIMIT        0x00000080
5641 #define FILE_VC_QUOTAS_INCOMPLETE       0x00000100
5642 #define FILE_VC_QUOTAS_REBUILDING       0x00000200
5643 #define FILE_VC_VALID_MASK              0x000003ff
5644 
5645 typedef struct _FILE_FS_CONTROL_INFORMATION {
5646   LARGE_INTEGER FreeSpaceStartFiltering;
5647   LARGE_INTEGER FreeSpaceThreshold;
5648   LARGE_INTEGER FreeSpaceStopFiltering;
5649   LARGE_INTEGER DefaultQuotaThreshold;
5650   LARGE_INTEGER DefaultQuotaLimit;
5651   ULONG FileSystemControlFlags;
5652 } FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION;
5653 
5654 #ifndef _FILESYSTEMFSCTL_
5655 #define _FILESYSTEMFSCTL_
5656 
5657 #define FSCTL_REQUEST_OPLOCK_LEVEL_1    CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  0, METHOD_BUFFERED, FILE_ANY_ACCESS)
5658 #define FSCTL_REQUEST_OPLOCK_LEVEL_2    CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  1, METHOD_BUFFERED, FILE_ANY_ACCESS)
5659 #define FSCTL_REQUEST_BATCH_OPLOCK      CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  2, METHOD_BUFFERED, FILE_ANY_ACCESS)
5660 #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE  CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  3, METHOD_BUFFERED, FILE_ANY_ACCESS)
5661 #define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  4, METHOD_BUFFERED, FILE_ANY_ACCESS)
5662 #define FSCTL_OPLOCK_BREAK_NOTIFY       CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  5, METHOD_BUFFERED, FILE_ANY_ACCESS)
5663 #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  6, METHOD_BUFFERED, FILE_ANY_ACCESS)
5664 #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS)
5665 #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS)
5666 #define FSCTL_IS_VOLUME_MOUNTED         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
5667 #define FSCTL_IS_PATHNAME_VALID         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
5668 #define FSCTL_MARK_VOLUME_DIRTY         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
5669 #define FSCTL_QUERY_RETRIEVAL_POINTERS  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER,  FILE_ANY_ACCESS)
5670 #define FSCTL_GET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
5671 #define FSCTL_SET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5672 #define FSCTL_SET_BOOTLOADER_ACCESSED   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER,  FILE_ANY_ACCESS)
5673 
5674 #define FSCTL_OPLOCK_BREAK_ACK_NO_2     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
5675 #define FSCTL_INVALIDATE_VOLUMES        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
5676 #define FSCTL_QUERY_FAT_BPB             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
5677 #define FSCTL_REQUEST_FILTER_OPLOCK     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
5678 #define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)
5679 
5680 #if (_WIN32_WINNT >= 0x0400)
5681 
5682 #define FSCTL_GET_NTFS_VOLUME_DATA      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
5683 #define FSCTL_GET_NTFS_FILE_RECORD      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
5684 #define FSCTL_GET_VOLUME_BITMAP         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER,  FILE_ANY_ACCESS)
5685 #define FSCTL_GET_RETRIEVAL_POINTERS    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER,  FILE_ANY_ACCESS)
5686 #define FSCTL_MOVE_FILE                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5687 #define FSCTL_IS_VOLUME_DIRTY           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
5688 #define FSCTL_ALLOW_EXTENDED_DASD_IO    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER,  FILE_ANY_ACCESS)
5689 
5690 #endif
5691 
5692 #if (_WIN32_WINNT >= 0x0500)
5693 
5694 #define FSCTL_FIND_FILES_BY_SID         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER,  FILE_ANY_ACCESS)
5695 #define FSCTL_SET_OBJECT_ID             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5696 #define FSCTL_GET_OBJECT_ID             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS)
5697 #define FSCTL_DELETE_OBJECT_ID          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5698 #define FSCTL_SET_REPARSE_POINT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5699 #define FSCTL_GET_REPARSE_POINT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
5700 #define FSCTL_DELETE_REPARSE_POINT      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5701 #define FSCTL_ENUM_USN_DATA             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER,  FILE_ANY_ACCESS)
5702 #define FSCTL_SECURITY_ID_CHECK         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER,  FILE_READ_DATA)
5703 #define FSCTL_READ_USN_JOURNAL          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER,  FILE_ANY_ACCESS)
5704 #define FSCTL_SET_OBJECT_ID_EXTENDED    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5705 #define FSCTL_CREATE_OR_GET_OBJECT_ID   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS)
5706 #define FSCTL_SET_SPARSE                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5707 #define FSCTL_SET_ZERO_DATA             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA)
5708 #define FSCTL_QUERY_ALLOCATED_RANGES    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER,  FILE_READ_DATA)
5709 #define FSCTL_ENABLE_UPGRADE            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_DATA)
5710 #define FSCTL_SET_ENCRYPTION            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER,  FILE_ANY_ACCESS)
5711 #define FSCTL_ENCRYPTION_FSCTL_IO       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER,  FILE_ANY_ACCESS)
5712 #define FSCTL_WRITE_RAW_ENCRYPTED       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER,  FILE_SPECIAL_ACCESS)
5713 #define FSCTL_READ_RAW_ENCRYPTED        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER,  FILE_SPECIAL_ACCESS)
5714 #define FSCTL_CREATE_USN_JOURNAL        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER,  FILE_ANY_ACCESS)
5715 #define FSCTL_READ_FILE_USN_DATA        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER,  FILE_ANY_ACCESS)
5716 #define FSCTL_WRITE_USN_CLOSE_RECORD    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER,  FILE_ANY_ACCESS)
5717 #define FSCTL_EXTEND_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
5718 #define FSCTL_QUERY_USN_JOURNAL         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS)
5719 #define FSCTL_DELETE_USN_JOURNAL        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS)
5720 #define FSCTL_MARK_HANDLE               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
5721 #define FSCTL_SIS_COPYFILE              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
5722 #define FSCTL_SIS_LINK_FILES            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5723 #define FSCTL_RECALL_FILE               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
5724 #define FSCTL_READ_FROM_PLEX            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA)
5725 #define FSCTL_FILE_PREFETCH             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5726 
5727 #endif
5728 
5729 #if (_WIN32_WINNT >= 0x0600)
5730 
5731 #define FSCTL_MAKE_MEDIA_COMPATIBLE         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, FILE_WRITE_DATA)
5732 #define FSCTL_SET_DEFECT_MANAGEMENT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, FILE_WRITE_DATA)
5733 #define FSCTL_QUERY_SPARING_INFO            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS)
5734 #define FSCTL_QUERY_ON_DISK_VOLUME_INFO     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS)
5735 #define FSCTL_SET_VOLUME_COMPRESSION_STATE  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5736 #define FSCTL_TXFS_MODIFY_RM                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, FILE_WRITE_DATA)
5737 #define FSCTL_TXFS_QUERY_RM_INFORMATION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, FILE_READ_DATA)
5738 #define FSCTL_TXFS_ROLLFORWARD_REDO         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, FILE_WRITE_DATA)
5739 #define FSCTL_TXFS_ROLLFORWARD_UNDO         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, FILE_WRITE_DATA)
5740 #define FSCTL_TXFS_START_RM                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, FILE_WRITE_DATA)
5741 #define FSCTL_TXFS_SHUTDOWN_RM              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, FILE_WRITE_DATA)
5742 #define FSCTL_TXFS_READ_BACKUP_INFORMATION  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, FILE_READ_DATA)
5743 #define FSCTL_TXFS_WRITE_BACKUP_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, FILE_WRITE_DATA)
5744 #define FSCTL_TXFS_CREATE_SECONDARY_RM      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, FILE_WRITE_DATA)
5745 #define FSCTL_TXFS_GET_METADATA_INFO        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, FILE_READ_DATA)
5746 #define FSCTL_TXFS_GET_TRANSACTED_VERSION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, FILE_READ_DATA)
5747 #define FSCTL_TXFS_SAVEPOINT_INFORMATION    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, FILE_WRITE_DATA)
5748 #define FSCTL_TXFS_CREATE_MINIVERSION       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, FILE_WRITE_DATA)
5749 #define FSCTL_TXFS_TRANSACTION_ACTIVE       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, FILE_READ_DATA)
5750 #define FSCTL_SET_ZERO_ON_DEALLOCATION      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5751 #define FSCTL_SET_REPAIR                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS)
5752 #define FSCTL_GET_REPAIR                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS)
5753 #define FSCTL_WAIT_FOR_REPAIR               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS)
5754 #define FSCTL_INITIATE_REPAIR               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS)
5755 #define FSCTL_CSC_INTERNAL                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER,  FILE_ANY_ACCESS)
5756 #define FSCTL_SHRINK_VOLUME                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5757 #define FSCTL_SET_SHORT_NAME_BEHAVIOR       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS)
5758 #define FSCTL_DFSR_SET_GHOST_HANDLE_STATE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS)
5759 #define FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES \
5760                                             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_READ_DATA)
5761 #define FSCTL_TXFS_LIST_TRANSACTIONS        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, FILE_READ_DATA)
5762 #define FSCTL_QUERY_PAGEFILE_ENCRYPTION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS)
5763 #define FSCTL_RESET_VOLUME_ALLOCATION_HINTS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS)
5764 #define FSCTL_TXFS_READ_BACKUP_INFORMATION2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, FILE_ANY_ACCESS)
5765 
5766 #endif
5767 
5768 #if (_WIN32_WINNT >= 0x0601)
5769 
5770 #define FSCTL_QUERY_DEPENDENT_VOLUME        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, FILE_ANY_ACCESS)
5771 #define FSCTL_SD_GLOBAL_CHANGE              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, FILE_ANY_ACCESS)
5772 #define FSCTL_LOOKUP_STREAM_FROM_CLUSTER    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS)
5773 #define FSCTL_TXFS_WRITE_BACKUP_INFORMATION2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, FILE_ANY_ACCESS)
5774 #define FSCTL_FILE_TYPE_NOTIFICATION        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS)
5775 #define FSCTL_GET_BOOT_AREA_INFO            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, FILE_ANY_ACCESS)
5776 #define FSCTL_GET_RETRIEVAL_POINTER_BASE    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS)
5777 #define FSCTL_SET_PERSISTENT_VOLUME_STATE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, FILE_ANY_ACCESS)
5778 #define FSCTL_QUERY_PERSISTENT_VOLUME_STATE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, FILE_ANY_ACCESS)
5779 #define FSCTL_REQUEST_OPLOCK                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS)
5780 #define FSCTL_CSV_TUNNEL_REQUEST            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, FILE_ANY_ACCESS)
5781 #define FSCTL_IS_CSV_FILE                   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, FILE_ANY_ACCESS)
5782 #define FSCTL_QUERY_FILE_SYSTEM_RECOGNITION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, FILE_ANY_ACCESS)
5783 #define FSCTL_CSV_GET_VOLUME_PATH_NAME      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS)
5784 #define FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS)
5785 #define FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 150,  METHOD_BUFFERED, FILE_ANY_ACCESS)
5786 #define FSCTL_IS_FILE_ON_CSV_VOLUME         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 151,  METHOD_BUFFERED, FILE_ANY_ACCESS)
5787 #define FSCTL_CSV_INTERNAL                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 155,  METHOD_BUFFERED, FILE_ANY_ACCESS)
5788 
5789 typedef struct _CSV_NAMESPACE_INFO {
5790   ULONG Version;
5791   ULONG DeviceNumber;
5792   LARGE_INTEGER StartingOffset;
5793   ULONG SectorSize;
5794 } CSV_NAMESPACE_INFO, *PCSV_NAMESPACE_INFO;
5795 
5796 #define CSV_NAMESPACE_INFO_V1 (sizeof(CSV_NAMESPACE_INFO))
5797 #define CSV_INVALID_DEVICE_NUMBER 0xFFFFFFFF
5798 
5799 #endif
5800 
5801 #if (_WIN32_WINNT >= 0x0602)
5802 
5803 #define FSCTL_FILE_LEVEL_TRIM               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, FILE_WRITE_DATA)
5804 #define FSCTL_CORRUPTION_HANDLING           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS)
5805 #define FSCTL_OFFLOAD_READ                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS)
5806 #define FSCTL_OFFLOAD_WRITE                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS)
5807 #define FSCTL_SET_PURGE_FAILURE_MODE        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS)
5808 #define FSCTL_QUERY_FILE_LAYOUT             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER,  FILE_ANY_ACCESS)
5809 #define FSCTL_IS_VOLUME_OWNED_BYCSVFS       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 158, METHOD_BUFFERED, FILE_ANY_ACCESS)
5810 #define FSCTL_GET_INTEGRITY_INFORMATION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
5811 #define FSCTL_SET_INTEGRITY_INFORMATION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5812 #define FSCTL_QUERY_FILE_REGIONS            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS)
5813 #define FSCTL_DEDUP_FILE                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, FILE_ANY_ACCESS)
5814 #define FSCTL_DEDUP_QUERY_FILE_HASHES       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 166, METHOD_NEITHER,  FILE_READ_DATA)
5815 #define FSCTL_RKF_INTERNAL                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER,  FILE_ANY_ACCESS)
5816 #define FSCTL_SCRUB_DATA                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS)
5817 #define FSCTL_REPAIR_COPIES                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5818 #define FSCTL_DISABLE_LOCAL_BUFFERING       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS)
5819 #define FSCTL_CSV_MGMT_LOCK                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS)
5820 #define FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS \
5821                                             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS)
5822 #define FSCTL_ADVANCE_FILE_ID               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS)
5823 #define FSCTL_CSV_SYNC_TUNNEL_REQUEST       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS)
5824 #define FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS)
5825 #define FSCTL_WRITE_USN_REASON              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS)
5826 #define FSCTL_CSV_CONTROL                   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS)
5827 #define FSCTL_GET_REFS_VOLUME_DATA          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS)
5828 
5829 #endif
5830 
5831 #if (_WIN32_WINNT >= 0x0603)
5832 
5833 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_DATA)
5834 
5835 #endif
5836 
5837 #define FSCTL_MARK_AS_SYSTEM_HIVE           FSCTL_SET_BOOTLOADER_ACCESSED
5838 
5839 typedef struct _PATHNAME_BUFFER {
5840   ULONG PathNameLength;
5841   WCHAR Name[1];
5842 } PATHNAME_BUFFER, *PPATHNAME_BUFFER;
5843 
5844 typedef struct _FSCTL_QUERY_FAT_BPB_BUFFER {
5845   UCHAR First0x24BytesOfBootSector[0x24];
5846 } FSCTL_QUERY_FAT_BPB_BUFFER, *PFSCTL_QUERY_FAT_BPB_BUFFER;
5847 
5848 #if (_WIN32_WINNT >= 0x0400)
5849 
5850 typedef struct _NTFS_VOLUME_DATA_BUFFER {
5851   LARGE_INTEGER VolumeSerialNumber;
5852   LARGE_INTEGER NumberSectors;
5853   LARGE_INTEGER TotalClusters;
5854   LARGE_INTEGER FreeClusters;
5855   LARGE_INTEGER TotalReserved;
5856   ULONG BytesPerSector;
5857   ULONG BytesPerCluster;
5858   ULONG BytesPerFileRecordSegment;
5859   ULONG ClustersPerFileRecordSegment;
5860   LARGE_INTEGER MftValidDataLength;
5861   LARGE_INTEGER MftStartLcn;
5862   LARGE_INTEGER Mft2StartLcn;
5863   LARGE_INTEGER MftZoneStart;
5864   LARGE_INTEGER MftZoneEnd;
5865 } NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;
5866 
5867 typedef struct _NTFS_EXTENDED_VOLUME_DATA {
5868   ULONG ByteCount;
5869   USHORT MajorVersion;
5870   USHORT MinorVersion;
5871 } NTFS_EXTENDED_VOLUME_DATA, *PNTFS_EXTENDED_VOLUME_DATA;
5872 
5873 typedef struct _STARTING_LCN_INPUT_BUFFER {
5874   LARGE_INTEGER StartingLcn;
5875 } STARTING_LCN_INPUT_BUFFER, *PSTARTING_LCN_INPUT_BUFFER;
5876 
5877 typedef struct _VOLUME_BITMAP_BUFFER {
5878   LARGE_INTEGER StartingLcn;
5879   LARGE_INTEGER BitmapSize;
5880   UCHAR Buffer[1];
5881 } VOLUME_BITMAP_BUFFER, *PVOLUME_BITMAP_BUFFER;
5882 
5883 typedef struct _STARTING_VCN_INPUT_BUFFER {
5884   LARGE_INTEGER StartingVcn;
5885 } STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER;
5886 
5887 typedef struct _RETRIEVAL_POINTERS_BUFFER {
5888   ULONG ExtentCount;
5889   LARGE_INTEGER StartingVcn;
5890   struct {
5891     LARGE_INTEGER NextVcn;
5892     LARGE_INTEGER Lcn;
5893   } Extents[1];
5894 } RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER;
5895 
5896 typedef struct _NTFS_FILE_RECORD_INPUT_BUFFER {
5897   LARGE_INTEGER FileReferenceNumber;
5898 } NTFS_FILE_RECORD_INPUT_BUFFER, *PNTFS_FILE_RECORD_INPUT_BUFFER;
5899 
5900 typedef struct _NTFS_FILE_RECORD_OUTPUT_BUFFER {
5901   LARGE_INTEGER FileReferenceNumber;
5902   ULONG FileRecordLength;
5903   UCHAR FileRecordBuffer[1];
5904 } NTFS_FILE_RECORD_OUTPUT_BUFFER, *PNTFS_FILE_RECORD_OUTPUT_BUFFER;
5905 
5906 typedef struct _MOVE_FILE_DATA {
5907   HANDLE FileHandle;
5908   LARGE_INTEGER StartingVcn;
5909   LARGE_INTEGER StartingLcn;
5910   ULONG ClusterCount;
5911 } MOVE_FILE_DATA, *PMOVE_FILE_DATA;
5912 
5913 typedef struct _MOVE_FILE_RECORD_DATA {
5914   HANDLE FileHandle;
5915   LARGE_INTEGER SourceFileRecord;
5916   LARGE_INTEGER TargetFileRecord;
5917 } MOVE_FILE_RECORD_DATA, *PMOVE_FILE_RECORD_DATA;
5918 
5919 #if defined(_WIN64)
5920 typedef struct _MOVE_FILE_DATA32 {
5921   UINT32 FileHandle;
5922   LARGE_INTEGER StartingVcn;
5923   LARGE_INTEGER StartingLcn;
5924   ULONG ClusterCount;
5925 } MOVE_FILE_DATA32, *PMOVE_FILE_DATA32;
5926 #endif
5927 
5928 #endif /* (_WIN32_WINNT >= 0x0400) */
5929 
5930 #if (_WIN32_WINNT >= 0x0500)
5931 
5932 typedef struct _FIND_BY_SID_DATA {
5933   ULONG Restart;
5934   SID Sid;
5935 } FIND_BY_SID_DATA, *PFIND_BY_SID_DATA;
5936 
5937 typedef struct _FIND_BY_SID_OUTPUT {
5938   ULONG NextEntryOffset;
5939   ULONG FileIndex;
5940   ULONG FileNameLength;
5941   WCHAR FileName[1];
5942 } FIND_BY_SID_OUTPUT, *PFIND_BY_SID_OUTPUT;
5943 
5944 typedef struct _MFT_ENUM_DATA {
5945   ULONGLONG StartFileReferenceNumber;
5946   USN LowUsn;
5947   USN HighUsn;
5948 } MFT_ENUM_DATA, *PMFT_ENUM_DATA;
5949 
5950 typedef struct _CREATE_USN_JOURNAL_DATA {
5951   ULONGLONG MaximumSize;
5952   ULONGLONG AllocationDelta;
5953 } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA;
5954 
5955 typedef struct _READ_USN_JOURNAL_DATA {
5956   USN StartUsn;
5957   ULONG ReasonMask;
5958   ULONG ReturnOnlyOnClose;
5959   ULONGLONG Timeout;
5960   ULONGLONG BytesToWaitFor;
5961   ULONGLONG UsnJournalID;
5962 } READ_USN_JOURNAL_DATA, *PREAD_USN_JOURNAL_DATA;
5963 
5964 typedef struct _USN_RECORD {
5965   ULONG RecordLength;
5966   USHORT MajorVersion;
5967   USHORT MinorVersion;
5968   ULONGLONG FileReferenceNumber;
5969   ULONGLONG ParentFileReferenceNumber;
5970   USN Usn;
5971   LARGE_INTEGER TimeStamp;
5972   ULONG Reason;
5973   ULONG SourceInfo;
5974   ULONG SecurityId;
5975   ULONG FileAttributes;
5976   USHORT FileNameLength;
5977   USHORT FileNameOffset;
5978   WCHAR FileName[1];
5979 } USN_RECORD, *PUSN_RECORD;
5980 
5981 #define USN_PAGE_SIZE                    (0x1000)
5982 
5983 #define USN_REASON_DATA_OVERWRITE        (0x00000001)
5984 #define USN_REASON_DATA_EXTEND           (0x00000002)
5985 #define USN_REASON_DATA_TRUNCATION       (0x00000004)
5986 #define USN_REASON_NAMED_DATA_OVERWRITE  (0x00000010)
5987 #define USN_REASON_NAMED_DATA_EXTEND     (0x00000020)
5988 #define USN_REASON_NAMED_DATA_TRUNCATION (0x00000040)
5989 #define USN_REASON_FILE_CREATE           (0x00000100)
5990 #define USN_REASON_FILE_DELETE           (0x00000200)
5991 #define USN_REASON_EA_CHANGE             (0x00000400)
5992 #define USN_REASON_SECURITY_CHANGE       (0x00000800)
5993 #define USN_REASON_RENAME_OLD_NAME       (0x00001000)
5994 #define USN_REASON_RENAME_NEW_NAME       (0x00002000)
5995 #define USN_REASON_INDEXABLE_CHANGE      (0x00004000)
5996 #define USN_REASON_BASIC_INFO_CHANGE     (0x00008000)
5997 #define USN_REASON_HARD_LINK_CHANGE      (0x00010000)
5998 #define USN_REASON_COMPRESSION_CHANGE    (0x00020000)
5999 #define USN_REASON_ENCRYPTION_CHANGE     (0x00040000)
6000 #define USN_REASON_OBJECT_ID_CHANGE      (0x00080000)
6001 #define USN_REASON_REPARSE_POINT_CHANGE  (0x00100000)
6002 #define USN_REASON_STREAM_CHANGE         (0x00200000)
6003 #define USN_REASON_TRANSACTED_CHANGE     (0x00400000)
6004 #define USN_REASON_CLOSE                 (0x80000000)
6005 
6006 typedef struct _USN_JOURNAL_DATA {
6007   ULONGLONG UsnJournalID;
6008   USN FirstUsn;
6009   USN NextUsn;
6010   USN LowestValidUsn;
6011   USN MaxUsn;
6012   ULONGLONG MaximumSize;
6013   ULONGLONG AllocationDelta;
6014 } USN_JOURNAL_DATA, *PUSN_JOURNAL_DATA;
6015 
6016 typedef struct _DELETE_USN_JOURNAL_DATA {
6017   ULONGLONG UsnJournalID;
6018   ULONG DeleteFlags;
6019 } DELETE_USN_JOURNAL_DATA, *PDELETE_USN_JOURNAL_DATA;
6020 
6021 #define USN_DELETE_FLAG_DELETE              (0x00000001)
6022 #define USN_DELETE_FLAG_NOTIFY              (0x00000002)
6023 #define USN_DELETE_VALID_FLAGS              (0x00000003)
6024 
6025 typedef struct _MARK_HANDLE_INFO {
6026   ULONG UsnSourceInfo;
6027   HANDLE VolumeHandle;
6028   ULONG HandleInfo;
6029 } MARK_HANDLE_INFO, *PMARK_HANDLE_INFO;
6030 
6031 #if defined(_WIN64)
6032 typedef struct _MARK_HANDLE_INFO32 {
6033   ULONG UsnSourceInfo;
6034   UINT32 VolumeHandle;
6035   ULONG HandleInfo;
6036 } MARK_HANDLE_INFO32, *PMARK_HANDLE_INFO32;
6037 #endif
6038 
6039 #define USN_SOURCE_DATA_MANAGEMENT          (0x00000001)
6040 #define USN_SOURCE_AUXILIARY_DATA           (0x00000002)
6041 #define USN_SOURCE_REPLICATION_MANAGEMENT   (0x00000004)
6042 
6043 #define MARK_HANDLE_PROTECT_CLUSTERS        (0x00000001)
6044 #define MARK_HANDLE_TXF_SYSTEM_LOG          (0x00000004)
6045 #define MARK_HANDLE_NOT_TXF_SYSTEM_LOG      (0x00000008)
6046 
6047 typedef struct _BULK_SECURITY_TEST_DATA {
6048   ACCESS_MASK DesiredAccess;
6049   ULONG SecurityIds[1];
6050 } BULK_SECURITY_TEST_DATA, *PBULK_SECURITY_TEST_DATA;
6051 
6052 #define VOLUME_IS_DIRTY                  (0x00000001)
6053 #define VOLUME_UPGRADE_SCHEDULED         (0x00000002)
6054 #define VOLUME_SESSION_OPEN              (0x00000004)
6055 
6056 typedef struct _FILE_PREFETCH {
6057   ULONG Type;
6058   ULONG Count;
6059   ULONGLONG Prefetch[1];
6060 } FILE_PREFETCH, *PFILE_PREFETCH;
6061 
6062 typedef struct _FILE_PREFETCH_EX {
6063   ULONG Type;
6064   ULONG Count;
6065   PVOID Context;
6066   ULONGLONG Prefetch[1];
6067 } FILE_PREFETCH_EX, *PFILE_PREFETCH_EX;
6068 
6069 #define FILE_PREFETCH_TYPE_FOR_CREATE       0x1
6070 #define FILE_PREFETCH_TYPE_FOR_DIRENUM      0x2
6071 #define FILE_PREFETCH_TYPE_FOR_CREATE_EX    0x3
6072 #define FILE_PREFETCH_TYPE_FOR_DIRENUM_EX   0x4
6073 
6074 #define FILE_PREFETCH_TYPE_MAX              0x4
6075 
6076 typedef struct _FILE_OBJECTID_BUFFER {
6077   UCHAR ObjectId[16];
6078   _ANONYMOUS_UNION union {
6079     _ANONYMOUS_STRUCT struct {
6080       UCHAR BirthVolumeId[16];
6081       UCHAR BirthObjectId[16];
6082       UCHAR DomainId[16];
6083     } DUMMYSTRUCTNAME;
6084     UCHAR ExtendedInfo[48];
6085   } DUMMYUNIONNAME;
6086 } FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER;
6087 
6088 typedef struct _FILE_SET_SPARSE_BUFFER {
6089   BOOLEAN SetSparse;
6090 } FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER;
6091 
6092 typedef struct _FILE_ZERO_DATA_INFORMATION {
6093   LARGE_INTEGER FileOffset;
6094   LARGE_INTEGER BeyondFinalZero;
6095 } FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION;
6096 
6097 typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
6098   LARGE_INTEGER FileOffset;
6099   LARGE_INTEGER Length;
6100 } FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
6101 
6102 typedef struct _ENCRYPTION_BUFFER {
6103   ULONG EncryptionOperation;
6104   UCHAR Private[1];
6105 } ENCRYPTION_BUFFER, *PENCRYPTION_BUFFER;
6106 
6107 #define FILE_SET_ENCRYPTION         0x00000001
6108 #define FILE_CLEAR_ENCRYPTION       0x00000002
6109 #define STREAM_SET_ENCRYPTION       0x00000003
6110 #define STREAM_CLEAR_ENCRYPTION     0x00000004
6111 
6112 #define MAXIMUM_ENCRYPTION_VALUE    0x00000004
6113 
6114 typedef struct _DECRYPTION_STATUS_BUFFER {
6115   BOOLEAN NoEncryptedStreams;
6116 } DECRYPTION_STATUS_BUFFER, *PDECRYPTION_STATUS_BUFFER;
6117 
6118 #define ENCRYPTION_FORMAT_DEFAULT        (0x01)
6119 
6120 #define COMPRESSION_FORMAT_SPARSE        (0x4000)
6121 
6122 typedef struct _REQUEST_RAW_ENCRYPTED_DATA {
6123   LONGLONG FileOffset;
6124   ULONG Length;
6125 } REQUEST_RAW_ENCRYPTED_DATA, *PREQUEST_RAW_ENCRYPTED_DATA;
6126 
6127 typedef struct _ENCRYPTED_DATA_INFO {
6128   ULONGLONG StartingFileOffset;
6129   ULONG OutputBufferOffset;
6130   ULONG BytesWithinFileSize;
6131   ULONG BytesWithinValidDataLength;
6132   USHORT CompressionFormat;
6133   UCHAR DataUnitShift;
6134   UCHAR ChunkShift;
6135   UCHAR ClusterShift;
6136   UCHAR EncryptionFormat;
6137   USHORT NumberOfDataBlocks;
6138   ULONG DataBlockSize[ANYSIZE_ARRAY];
6139 } ENCRYPTED_DATA_INFO, *PENCRYPTED_DATA_INFO;
6140 
6141 typedef struct _PLEX_READ_DATA_REQUEST {
6142   LARGE_INTEGER ByteOffset;
6143   ULONG ByteLength;
6144   ULONG PlexNumber;
6145 } PLEX_READ_DATA_REQUEST, *PPLEX_READ_DATA_REQUEST;
6146 
6147 typedef struct _SI_COPYFILE {
6148   ULONG SourceFileNameLength;
6149   ULONG DestinationFileNameLength;
6150   ULONG Flags;
6151   WCHAR FileNameBuffer[1];
6152 } SI_COPYFILE, *PSI_COPYFILE;
6153 
6154 #define COPYFILE_SIS_LINK       0x0001
6155 #define COPYFILE_SIS_REPLACE    0x0002
6156 #define COPYFILE_SIS_FLAGS      0x0003
6157 
6158 #endif /* (_WIN32_WINNT >= 0x0500) */
6159 
6160 #if (_WIN32_WINNT >= 0x0600)
6161 
6162 typedef struct _FILE_MAKE_COMPATIBLE_BUFFER {
6163   BOOLEAN CloseDisc;
6164 } FILE_MAKE_COMPATIBLE_BUFFER, *PFILE_MAKE_COMPATIBLE_BUFFER;
6165 
6166 typedef struct _FILE_SET_DEFECT_MGMT_BUFFER {
6167   BOOLEAN Disable;
6168 } FILE_SET_DEFECT_MGMT_BUFFER, *PFILE_SET_DEFECT_MGMT_BUFFER;
6169 
6170 typedef struct _FILE_QUERY_SPARING_BUFFER {
6171   ULONG SparingUnitBytes;
6172   BOOLEAN SoftwareSparing;
6173   ULONG TotalSpareBlocks;
6174   ULONG FreeSpareBlocks;
6175 } FILE_QUERY_SPARING_BUFFER, *PFILE_QUERY_SPARING_BUFFER;
6176 
6177 typedef struct _FILE_QUERY_ON_DISK_VOL_INFO_BUFFER {
6178   LARGE_INTEGER DirectoryCount;
6179   LARGE_INTEGER FileCount;
6180   USHORT FsFormatMajVersion;
6181   USHORT FsFormatMinVersion;
6182   WCHAR FsFormatName[12];
6183   LARGE_INTEGER FormatTime;
6184   LARGE_INTEGER LastUpdateTime;
6185   WCHAR CopyrightInfo[34];
6186   WCHAR AbstractInfo[34];
6187   WCHAR FormattingImplementationInfo[34];
6188   WCHAR LastModifyingImplementationInfo[34];
6189 } FILE_QUERY_ON_DISK_VOL_INFO_BUFFER, *PFILE_QUERY_ON_DISK_VOL_INFO_BUFFER;
6190 
6191 #define SET_REPAIR_ENABLED                                      (0x00000001)
6192 #define SET_REPAIR_VOLUME_BITMAP_SCAN                           (0x00000002)
6193 #define SET_REPAIR_DELETE_CROSSLINK                             (0x00000004)
6194 #define SET_REPAIR_WARN_ABOUT_DATA_LOSS                         (0x00000008)
6195 #define SET_REPAIR_DISABLED_AND_BUGCHECK_ON_CORRUPT             (0x00000010)
6196 #define SET_REPAIR_VALID_MASK                                   (0x0000001F)
6197 
6198 typedef enum _SHRINK_VOLUME_REQUEST_TYPES {
6199   ShrinkPrepare = 1,
6200   ShrinkCommit,
6201   ShrinkAbort
6202 } SHRINK_VOLUME_REQUEST_TYPES, *PSHRINK_VOLUME_REQUEST_TYPES;
6203 
6204 typedef struct _SHRINK_VOLUME_INFORMATION {
6205   SHRINK_VOLUME_REQUEST_TYPES ShrinkRequestType;
6206   ULONGLONG Flags;
6207   LONGLONG NewNumberOfSectors;
6208 } SHRINK_VOLUME_INFORMATION, *PSHRINK_VOLUME_INFORMATION;
6209 
6210 #define TXFS_RM_FLAG_LOGGING_MODE                           0x00000001
6211 #define TXFS_RM_FLAG_RENAME_RM                              0x00000002
6212 #define TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MAX                0x00000004
6213 #define TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MIN                0x00000008
6214 #define TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS    0x00000010
6215 #define TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT           0x00000020
6216 #define TXFS_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE             0x00000040
6217 #define TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX             0x00000080
6218 #define TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN             0x00000100
6219 #define TXFS_RM_FLAG_GROW_LOG                               0x00000400
6220 #define TXFS_RM_FLAG_SHRINK_LOG                             0x00000800
6221 #define TXFS_RM_FLAG_ENFORCE_MINIMUM_SIZE                   0x00001000
6222 #define TXFS_RM_FLAG_PRESERVE_CHANGES                       0x00002000
6223 #define TXFS_RM_FLAG_RESET_RM_AT_NEXT_START                 0x00004000
6224 #define TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START          0x00008000
6225 #define TXFS_RM_FLAG_PREFER_CONSISTENCY                     0x00010000
6226 #define TXFS_RM_FLAG_PREFER_AVAILABILITY                    0x00020000
6227 
6228 #define TXFS_LOGGING_MODE_SIMPLE        (0x0001)
6229 #define TXFS_LOGGING_MODE_FULL          (0x0002)
6230 
6231 #define TXFS_TRANSACTION_STATE_NONE         0x00
6232 #define TXFS_TRANSACTION_STATE_ACTIVE       0x01
6233 #define TXFS_TRANSACTION_STATE_PREPARED     0x02
6234 #define TXFS_TRANSACTION_STATE_NOTACTIVE    0x03
6235 
6236 #define TXFS_MODIFY_RM_VALID_FLAGS (TXFS_RM_FLAG_LOGGING_MODE                        | \
6237                                     TXFS_RM_FLAG_RENAME_RM                           | \
6238                                     TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MAX             | \
6239                                     TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MIN             | \
6240                                     TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS | \
6241                                     TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT        | \
6242                                     TXFS_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE          | \
6243                                     TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX          | \
6244                                     TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN          | \
6245                                     TXFS_RM_FLAG_SHRINK_LOG                          | \
6246                                     TXFS_RM_FLAG_GROW_LOG                            | \
6247                                     TXFS_RM_FLAG_ENFORCE_MINIMUM_SIZE                | \
6248                                     TXFS_RM_FLAG_PRESERVE_CHANGES                    | \
6249                                     TXFS_RM_FLAG_RESET_RM_AT_NEXT_START              | \
6250                                     TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START       | \
6251                                     TXFS_RM_FLAG_PREFER_CONSISTENCY                  | \
6252                                     TXFS_RM_FLAG_PREFER_AVAILABILITY)
6253 
6254 typedef struct _TXFS_MODIFY_RM {
6255   ULONG Flags;
6256   ULONG LogContainerCountMax;
6257   ULONG LogContainerCountMin;
6258   ULONG LogContainerCount;
6259   ULONG LogGrowthIncrement;
6260   ULONG LogAutoShrinkPercentage;
6261   ULONGLONG Reserved;
6262   USHORT LoggingMode;
6263 } TXFS_MODIFY_RM, *PTXFS_MODIFY_RM;
6264 
6265 #define TXFS_RM_STATE_NOT_STARTED       0
6266 #define TXFS_RM_STATE_STARTING          1
6267 #define TXFS_RM_STATE_ACTIVE            2
6268 #define TXFS_RM_STATE_SHUTTING_DOWN     3
6269 
6270 #define TXFS_QUERY_RM_INFORMATION_VALID_FLAGS                           \
6271                 (TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS   |   \
6272                  TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT          |   \
6273                  TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX            |   \
6274                  TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN            |   \
6275                  TXFS_RM_FLAG_RESET_RM_AT_NEXT_START                |   \
6276                  TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START         |   \
6277                  TXFS_RM_FLAG_PREFER_CONSISTENCY                    |   \
6278                  TXFS_RM_FLAG_PREFER_AVAILABILITY)
6279 
6280 typedef struct _TXFS_QUERY_RM_INFORMATION {
6281   ULONG BytesRequired;
6282   ULONGLONG TailLsn;
6283   ULONGLONG CurrentLsn;
6284   ULONGLONG ArchiveTailLsn;
6285   ULONGLONG LogContainerSize;
6286   LARGE_INTEGER HighestVirtualClock;
6287   ULONG LogContainerCount;
6288   ULONG LogContainerCountMax;
6289   ULONG LogContainerCountMin;
6290   ULONG LogGrowthIncrement;
6291   ULONG LogAutoShrinkPercentage;
6292   ULONG Flags;
6293   USHORT LoggingMode;
6294   USHORT Reserved;
6295   ULONG RmState;
6296   ULONGLONG LogCapacity;
6297   ULONGLONG LogFree;
6298   ULONGLONG TopsSize;
6299   ULONGLONG TopsUsed;
6300   ULONGLONG TransactionCount;
6301   ULONGLONG OnePCCount;
6302   ULONGLONG TwoPCCount;
6303   ULONGLONG NumberLogFileFull;
6304   ULONGLONG OldestTransactionAge;
6305   GUID RMName;
6306   ULONG TmLogPathOffset;
6307 } TXFS_QUERY_RM_INFORMATION, *PTXFS_QUERY_RM_INFORMATION;
6308 
6309 #define TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_REDO_LSN        0x01
6310 #define TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_VIRTUAL_CLOCK   0x02
6311 
6312 #define TXFS_ROLLFORWARD_REDO_VALID_FLAGS                               \
6313                 (TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_REDO_LSN |         \
6314                  TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_VIRTUAL_CLOCK)
6315 
6316 typedef struct _TXFS_ROLLFORWARD_REDO_INFORMATION {
6317   LARGE_INTEGER LastVirtualClock;
6318   ULONGLONG LastRedoLsn;
6319   ULONGLONG HighestRecoveryLsn;
6320   ULONG Flags;
6321 } TXFS_ROLLFORWARD_REDO_INFORMATION, *PTXFS_ROLLFORWARD_REDO_INFORMATION;
6322 
6323 #define TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MAX              0x00000001
6324 #define TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MIN              0x00000002
6325 #define TXFS_START_RM_FLAG_LOG_CONTAINER_SIZE                   0x00000004
6326 #define TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS  0x00000008
6327 #define TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT         0x00000010
6328 #define TXFS_START_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE           0x00000020
6329 #define TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX           0x00000040
6330 #define TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN           0x00000080
6331 
6332 #define TXFS_START_RM_FLAG_RECOVER_BEST_EFFORT                  0x00000200
6333 #define TXFS_START_RM_FLAG_LOGGING_MODE                         0x00000400
6334 #define TXFS_START_RM_FLAG_PRESERVE_CHANGES                     0x00000800
6335 
6336 #define TXFS_START_RM_FLAG_PREFER_CONSISTENCY                   0x00001000
6337 #define TXFS_START_RM_FLAG_PREFER_AVAILABILITY                  0x00002000
6338 
6339 #define TXFS_START_RM_VALID_FLAGS                                           \
6340                 (TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MAX             |   \
6341                  TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MIN             |   \
6342                  TXFS_START_RM_FLAG_LOG_CONTAINER_SIZE                  |   \
6343                  TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS |   \
6344                  TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT        |   \
6345                  TXFS_START_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE          |   \
6346                  TXFS_START_RM_FLAG_RECOVER_BEST_EFFORT                 |   \
6347                  TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX          |   \
6348                  TXFS_START_RM_FLAG_LOGGING_MODE                        |   \
6349                  TXFS_START_RM_FLAG_PRESERVE_CHANGES                    |   \
6350                  TXFS_START_RM_FLAG_PREFER_CONSISTENCY                  |   \
6351                  TXFS_START_RM_FLAG_PREFER_AVAILABILITY)
6352 
6353 typedef struct _TXFS_START_RM_INFORMATION {
6354   ULONG Flags;
6355   ULONGLONG LogContainerSize;
6356   ULONG LogContainerCountMin;
6357   ULONG LogContainerCountMax;
6358   ULONG LogGrowthIncrement;
6359   ULONG LogAutoShrinkPercentage;
6360   ULONG TmLogPathOffset;
6361   USHORT TmLogPathLength;
6362   USHORT LoggingMode;
6363   USHORT LogPathLength;
6364   USHORT Reserved;
6365   WCHAR LogPath[1];
6366 } TXFS_START_RM_INFORMATION, *PTXFS_START_RM_INFORMATION;
6367 
6368 typedef struct _TXFS_GET_METADATA_INFO_OUT {
6369   struct {
6370     LONGLONG LowPart;
6371     LONGLONG HighPart;
6372   } TxfFileId;
6373   GUID LockingTransaction;
6374   ULONGLONG LastLsn;
6375   ULONG TransactionState;
6376 } TXFS_GET_METADATA_INFO_OUT, *PTXFS_GET_METADATA_INFO_OUT;
6377 
6378 #define TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY_FLAG_CREATED   0x00000001
6379 #define TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY_FLAG_DELETED   0x00000002
6380 
6381 typedef struct _TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY {
6382   ULONGLONG Offset;
6383   ULONG NameFlags;
6384   LONGLONG FileId;
6385   ULONG Reserved1;
6386   ULONG Reserved2;
6387   LONGLONG Reserved3;
6388   WCHAR FileName[1];
6389 } TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY, *PTXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY;
6390 
6391 typedef struct _TXFS_LIST_TRANSACTION_LOCKED_FILES {
6392   GUID KtmTransaction;
6393   ULONGLONG NumberOfFiles;
6394   ULONGLONG BufferSizeRequired;
6395   ULONGLONG Offset;
6396 } TXFS_LIST_TRANSACTION_LOCKED_FILES, *PTXFS_LIST_TRANSACTION_LOCKED_FILES;
6397 
6398 typedef struct _TXFS_LIST_TRANSACTIONS_ENTRY {
6399   GUID TransactionId;
6400   ULONG TransactionState;
6401   ULONG Reserved1;
6402   ULONG Reserved2;
6403   LONGLONG Reserved3;
6404 } TXFS_LIST_TRANSACTIONS_ENTRY, *PTXFS_LIST_TRANSACTIONS_ENTRY;
6405 
6406 typedef struct _TXFS_LIST_TRANSACTIONS {
6407   ULONGLONG NumberOfTransactions;
6408   ULONGLONG BufferSizeRequired;
6409 } TXFS_LIST_TRANSACTIONS, *PTXFS_LIST_TRANSACTIONS;
6410 
6411 typedef struct _TXFS_READ_BACKUP_INFORMATION_OUT {
6412   _ANONYMOUS_UNION union {
6413     ULONG BufferLength;
6414     UCHAR Buffer[1];
6415   } DUMMYUNIONNAME;
6416 } TXFS_READ_BACKUP_INFORMATION_OUT, *PTXFS_READ_BACKUP_INFORMATION_OUT;
6417 
6418 typedef struct _TXFS_WRITE_BACKUP_INFORMATION {
6419   UCHAR Buffer[1];
6420 } TXFS_WRITE_BACKUP_INFORMATION, *PTXFS_WRITE_BACKUP_INFORMATION;
6421 
6422 #define TXFS_TRANSACTED_VERSION_NONTRANSACTED   0xFFFFFFFE
6423 #define TXFS_TRANSACTED_VERSION_UNCOMMITTED     0xFFFFFFFF
6424 
6425 typedef struct _TXFS_GET_TRANSACTED_VERSION {
6426   ULONG ThisBaseVersion;
6427   ULONG LatestVersion;
6428   USHORT ThisMiniVersion;
6429   USHORT FirstMiniVersion;
6430   USHORT LatestMiniVersion;
6431 } TXFS_GET_TRANSACTED_VERSION, *PTXFS_GET_TRANSACTED_VERSION;
6432 
6433 #define TXFS_SAVEPOINT_SET                      0x00000001
6434 #define TXFS_SAVEPOINT_ROLLBACK                 0x00000002
6435 #define TXFS_SAVEPOINT_CLEAR                    0x00000004
6436 #define TXFS_SAVEPOINT_CLEAR_ALL                0x00000010
6437 
6438 typedef struct _TXFS_SAVEPOINT_INFORMATION {
6439   HANDLE KtmTransaction;
6440   ULONG ActionCode;
6441   ULONG SavepointId;
6442 } TXFS_SAVEPOINT_INFORMATION, *PTXFS_SAVEPOINT_INFORMATION;
6443 
6444 typedef struct _TXFS_CREATE_MINIVERSION_INFO {
6445   USHORT StructureVersion;
6446   USHORT StructureLength;
6447   ULONG BaseVersion;
6448   USHORT MiniVersion;
6449 } TXFS_CREATE_MINIVERSION_INFO, *PTXFS_CREATE_MINIVERSION_INFO;
6450 
6451 typedef struct _TXFS_TRANSACTION_ACTIVE_INFO {
6452   BOOLEAN TransactionsActiveAtSnapshot;
6453 } TXFS_TRANSACTION_ACTIVE_INFO, *PTXFS_TRANSACTION_ACTIVE_INFO;
6454 
6455 #endif /* (_WIN32_WINNT >= 0x0600) */
6456 
6457 #if (_WIN32_WINNT >= 0x0601)
6458 
6459 #define MARK_HANDLE_REALTIME                (0x00000020)
6460 #define MARK_HANDLE_NOT_REALTIME            (0x00000040)
6461 
6462 #define NO_8DOT3_NAME_PRESENT               (0x00000001)
6463 #define REMOVED_8DOT3_NAME                  (0x00000002)
6464 
6465 #define PERSISTENT_VOLUME_STATE_SHORT_NAME_CREATION_DISABLED        (0x00000001)
6466 
6467 typedef struct _BOOT_AREA_INFO {
6468   ULONG BootSectorCount;
6469   struct {
6470     LARGE_INTEGER Offset;
6471   } BootSectors[2];
6472 } BOOT_AREA_INFO, *PBOOT_AREA_INFO;
6473 
6474 typedef struct _RETRIEVAL_POINTER_BASE {
6475   LARGE_INTEGER FileAreaOffset;
6476 } RETRIEVAL_POINTER_BASE, *PRETRIEVAL_POINTER_BASE;
6477 
6478 typedef struct _FILE_FS_PERSISTENT_VOLUME_INFORMATION {
6479   ULONG VolumeFlags;
6480   ULONG FlagMask;
6481   ULONG Version;
6482   ULONG Reserved;
6483 } FILE_FS_PERSISTENT_VOLUME_INFORMATION, *PFILE_FS_PERSISTENT_VOLUME_INFORMATION;
6484 
6485 typedef struct _FILE_SYSTEM_RECOGNITION_INFORMATION {
6486   CHAR FileSystem[9];
6487 } FILE_SYSTEM_RECOGNITION_INFORMATION, *PFILE_SYSTEM_RECOGNITION_INFORMATION;
6488 
6489 #define OPLOCK_LEVEL_CACHE_READ         (0x00000001)
6490 #define OPLOCK_LEVEL_CACHE_HANDLE       (0x00000002)
6491 #define OPLOCK_LEVEL_CACHE_WRITE        (0x00000004)
6492 
6493 #define REQUEST_OPLOCK_INPUT_FLAG_REQUEST               (0x00000001)
6494 #define REQUEST_OPLOCK_INPUT_FLAG_ACK                   (0x00000002)
6495 #define REQUEST_OPLOCK_INPUT_FLAG_COMPLETE_ACK_ON_CLOSE (0x00000004)
6496 
6497 #define REQUEST_OPLOCK_CURRENT_VERSION          1
6498 
6499 typedef struct _REQUEST_OPLOCK_INPUT_BUFFER {
6500   USHORT StructureVersion;
6501   USHORT StructureLength;
6502   ULONG RequestedOplockLevel;
6503   ULONG Flags;
6504 } REQUEST_OPLOCK_INPUT_BUFFER, *PREQUEST_OPLOCK_INPUT_BUFFER;
6505 
6506 #define REQUEST_OPLOCK_OUTPUT_FLAG_ACK_REQUIRED     (0x00000001)
6507 #define REQUEST_OPLOCK_OUTPUT_FLAG_MODES_PROVIDED   (0x00000002)
6508 
6509 typedef struct _REQUEST_OPLOCK_OUTPUT_BUFFER {
6510   USHORT StructureVersion;
6511   USHORT StructureLength;
6512   ULONG OriginalOplockLevel;
6513   ULONG NewOplockLevel;
6514   ULONG Flags;
6515   ACCESS_MASK AccessMode;
6516   USHORT ShareMode;
6517 } REQUEST_OPLOCK_OUTPUT_BUFFER, *PREQUEST_OPLOCK_OUTPUT_BUFFER;
6518 
6519 #define SD_GLOBAL_CHANGE_TYPE_MACHINE_SID   1
6520 
6521 typedef struct _SD_CHANGE_MACHINE_SID_INPUT {
6522   USHORT CurrentMachineSIDOffset;
6523   USHORT CurrentMachineSIDLength;
6524   USHORT NewMachineSIDOffset;
6525   USHORT NewMachineSIDLength;
6526 } SD_CHANGE_MACHINE_SID_INPUT, *PSD_CHANGE_MACHINE_SID_INPUT;
6527 
6528 typedef struct _SD_CHANGE_MACHINE_SID_OUTPUT {
6529   ULONGLONG NumSDChangedSuccess;
6530   ULONGLONG NumSDChangedFail;
6531   ULONGLONG NumSDUnused;
6532   ULONGLONG NumSDTotal;
6533   ULONGLONG NumMftSDChangedSuccess;
6534   ULONGLONG NumMftSDChangedFail;
6535   ULONGLONG NumMftSDTotal;
6536 } SD_CHANGE_MACHINE_SID_OUTPUT, *PSD_CHANGE_MACHINE_SID_OUTPUT;
6537 
6538 typedef struct _SD_GLOBAL_CHANGE_INPUT {
6539   ULONG Flags;
6540   ULONG ChangeType;
6541   _ANONYMOUS_UNION union {
6542     SD_CHANGE_MACHINE_SID_INPUT SdChange;
6543   } DUMMYUNIONNAME;
6544 } SD_GLOBAL_CHANGE_INPUT, *PSD_GLOBAL_CHANGE_INPUT;
6545 
6546 typedef struct _SD_GLOBAL_CHANGE_OUTPUT {
6547   ULONG Flags;
6548   ULONG ChangeType;
6549   _ANONYMOUS_UNION union {
6550     SD_CHANGE_MACHINE_SID_OUTPUT SdChange;
6551   } DUMMYUNIONNAME;
6552 } SD_GLOBAL_CHANGE_OUTPUT, *PSD_GLOBAL_CHANGE_OUTPUT;
6553 
6554 #define ENCRYPTED_DATA_INFO_SPARSE_FILE    1
6555 
6556 typedef struct _EXTENDED_ENCRYPTED_DATA_INFO {
6557   ULONG ExtendedCode;
6558   ULONG Length;
6559   ULONG Flags;
6560   ULONG Reserved;
6561 } EXTENDED_ENCRYPTED_DATA_INFO, *PEXTENDED_ENCRYPTED_DATA_INFO;
6562 
6563 typedef struct _LOOKUP_STREAM_FROM_CLUSTER_INPUT {
6564   ULONG Flags;
6565   ULONG NumberOfClusters;
6566   LARGE_INTEGER Cluster[1];
6567 } LOOKUP_STREAM_FROM_CLUSTER_INPUT, *PLOOKUP_STREAM_FROM_CLUSTER_INPUT;
6568 
6569 typedef struct _LOOKUP_STREAM_FROM_CLUSTER_OUTPUT {
6570   ULONG Offset;
6571   ULONG NumberOfMatches;
6572   ULONG BufferSizeRequired;
6573 } LOOKUP_STREAM_FROM_CLUSTER_OUTPUT, *PLOOKUP_STREAM_FROM_CLUSTER_OUTPUT;
6574 
6575 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_PAGE_FILE          0x00000001
6576 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_DENY_DEFRAG_SET    0x00000002
6577 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_FS_SYSTEM_FILE     0x00000004
6578 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_TXF_SYSTEM_FILE    0x00000008
6579 
6580 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_MASK          0xff000000
6581 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_DATA          0x01000000
6582 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_INDEX         0x02000000
6583 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_SYSTEM        0x03000000
6584 
6585 typedef struct _LOOKUP_STREAM_FROM_CLUSTER_ENTRY {
6586   ULONG OffsetToNext;
6587   ULONG Flags;
6588   LARGE_INTEGER Reserved;
6589   LARGE_INTEGER Cluster;
6590   WCHAR FileName[1];
6591 } LOOKUP_STREAM_FROM_CLUSTER_ENTRY, *PLOOKUP_STREAM_FROM_CLUSTER_ENTRY;
6592 
6593 typedef struct _FILE_TYPE_NOTIFICATION_INPUT {
6594   ULONG Flags;
6595   ULONG NumFileTypeIDs;
6596   GUID FileTypeID[1];
6597 } FILE_TYPE_NOTIFICATION_INPUT, *PFILE_TYPE_NOTIFICATION_INPUT;
6598 
6599 #define FILE_TYPE_NOTIFICATION_FLAG_USAGE_BEGIN     0x00000001
6600 #define FILE_TYPE_NOTIFICATION_FLAG_USAGE_END       0x00000002
6601 
6602 DEFINE_GUID(FILE_TYPE_NOTIFICATION_GUID_PAGE_FILE,         0x0d0a64a1, 0x38fc, 0x4db8, 0x9f, 0xe7, 0x3f, 0x43, 0x52, 0xcd, 0x7c, 0x5c);
6603 DEFINE_GUID(FILE_TYPE_NOTIFICATION_GUID_HIBERNATION_FILE,  0xb7624d64, 0xb9a3, 0x4cf8, 0x80, 0x11, 0x5b, 0x86, 0xc9, 0x40, 0xe7, 0xb7);
6604 DEFINE_GUID(FILE_TYPE_NOTIFICATION_GUID_CRASHDUMP_FILE,    0x9d453eb7, 0xd2a6, 0x4dbd, 0xa2, 0xe3, 0xfb, 0xd0, 0xed, 0x91, 0x09, 0xa9);
6605 
6606 #ifndef _VIRTUAL_STORAGE_TYPE_DEFINED
6607 #define _VIRTUAL_STORAGE_TYPE_DEFINED
6608 typedef struct _VIRTUAL_STORAGE_TYPE {
6609   ULONG DeviceId;
6610   GUID VendorId;
6611 } VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE;
6612 #endif
6613 
6614 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST {
6615   ULONG RequestLevel;
6616   ULONG RequestFlags;
6617 } STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST, *PSTORAGE_QUERY_DEPENDENT_VOLUME_REQUEST;
6618 
6619 #define QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_HOST_VOLUMES    0x1
6620 #define QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_GUEST_VOLUMES   0x2
6621 
6622 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY {
6623   ULONG EntryLength;
6624   ULONG DependencyTypeFlags;
6625   ULONG ProviderSpecificFlags;
6626   VIRTUAL_STORAGE_TYPE VirtualStorageType;
6627 } STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY, *PSTORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY;
6628 
6629 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY {
6630   ULONG EntryLength;
6631   ULONG DependencyTypeFlags;
6632   ULONG ProviderSpecificFlags;
6633   VIRTUAL_STORAGE_TYPE VirtualStorageType;
6634   ULONG AncestorLevel;
6635   ULONG HostVolumeNameOffset;
6636   ULONG HostVolumeNameSize;
6637   ULONG DependentVolumeNameOffset;
6638   ULONG DependentVolumeNameSize;
6639   ULONG RelativePathOffset;
6640   ULONG RelativePathSize;
6641   ULONG DependentDeviceNameOffset;
6642   ULONG DependentDeviceNameSize;
6643 } STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY, *PSTORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY;
6644 
6645 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE {
6646   ULONG ResponseLevel;
6647   ULONG NumberEntries;
6648   _ANONYMOUS_UNION union {
6649     STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY Lev1Depends[0];
6650     STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY Lev2Depends[0];
6651   } DUMMYUNIONNAME;
6652 } STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE, *PSTORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE;
6653 
6654 #endif /* (_WIN32_WINNT >= 0x0601) */
6655 
6656 typedef struct _FILESYSTEM_STATISTICS {
6657   USHORT FileSystemType;
6658   USHORT Version;
6659   ULONG SizeOfCompleteStructure;
6660   ULONG UserFileReads;
6661   ULONG UserFileReadBytes;
6662   ULONG UserDiskReads;
6663   ULONG UserFileWrites;
6664   ULONG UserFileWriteBytes;
6665   ULONG UserDiskWrites;
6666   ULONG MetaDataReads;
6667   ULONG MetaDataReadBytes;
6668   ULONG MetaDataDiskReads;
6669   ULONG MetaDataWrites;
6670   ULONG MetaDataWriteBytes;
6671   ULONG MetaDataDiskWrites;
6672 } FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS;
6673 
6674 #define FILESYSTEM_STATISTICS_TYPE_NTFS     1
6675 #define FILESYSTEM_STATISTICS_TYPE_FAT      2
6676 #define FILESYSTEM_STATISTICS_TYPE_EXFAT    3
6677 
6678 typedef struct _FAT_STATISTICS {
6679   ULONG CreateHits;
6680   ULONG SuccessfulCreates;
6681   ULONG FailedCreates;
6682   ULONG NonCachedReads;
6683   ULONG NonCachedReadBytes;
6684   ULONG NonCachedWrites;
6685   ULONG NonCachedWriteBytes;
6686   ULONG NonCachedDiskReads;
6687   ULONG NonCachedDiskWrites;
6688 } FAT_STATISTICS, *PFAT_STATISTICS;
6689 
6690 typedef struct _EXFAT_STATISTICS {
6691   ULONG CreateHits;
6692   ULONG SuccessfulCreates;
6693   ULONG FailedCreates;
6694   ULONG NonCachedReads;
6695   ULONG NonCachedReadBytes;
6696   ULONG NonCachedWrites;
6697   ULONG NonCachedWriteBytes;
6698   ULONG NonCachedDiskReads;
6699   ULONG NonCachedDiskWrites;
6700 } EXFAT_STATISTICS, *PEXFAT_STATISTICS;
6701 
6702 typedef struct _NTFS_STATISTICS {
6703   ULONG LogFileFullExceptions;
6704   ULONG OtherExceptions;
6705   ULONG MftReads;
6706   ULONG MftReadBytes;
6707   ULONG MftWrites;
6708   ULONG MftWriteBytes;
6709   struct {
6710     USHORT Write;
6711     USHORT Create;
6712     USHORT SetInfo;
6713     USHORT Flush;
6714   } MftWritesUserLevel;
6715   USHORT MftWritesFlushForLogFileFull;
6716   USHORT MftWritesLazyWriter;
6717   USHORT MftWritesUserRequest;
6718   ULONG Mft2Writes;
6719   ULONG Mft2WriteBytes;
6720   struct {
6721     USHORT Write;
6722     USHORT Create;
6723     USHORT SetInfo;
6724     USHORT Flush;
6725   } Mft2WritesUserLevel;
6726   USHORT Mft2WritesFlushForLogFileFull;
6727   USHORT Mft2WritesLazyWriter;
6728   USHORT Mft2WritesUserRequest;
6729   ULONG RootIndexReads;
6730   ULONG RootIndexReadBytes;
6731   ULONG RootIndexWrites;
6732   ULONG RootIndexWriteBytes;
6733   ULONG BitmapReads;
6734   ULONG BitmapReadBytes;
6735   ULONG BitmapWrites;
6736   ULONG BitmapWriteBytes;
6737   USHORT BitmapWritesFlushForLogFileFull;
6738   USHORT BitmapWritesLazyWriter;
6739   USHORT BitmapWritesUserRequest;
6740   struct {
6741     USHORT Write;
6742     USHORT Create;
6743     USHORT SetInfo;
6744   } BitmapWritesUserLevel;
6745   ULONG MftBitmapReads;
6746   ULONG MftBitmapReadBytes;
6747   ULONG MftBitmapWrites;
6748   ULONG MftBitmapWriteBytes;
6749   USHORT MftBitmapWritesFlushForLogFileFull;
6750   USHORT MftBitmapWritesLazyWriter;
6751   USHORT MftBitmapWritesUserRequest;
6752   struct {
6753     USHORT Write;
6754     USHORT Create;
6755     USHORT SetInfo;
6756     USHORT Flush;
6757   } MftBitmapWritesUserLevel;
6758   ULONG UserIndexReads;
6759   ULONG UserIndexReadBytes;
6760   ULONG UserIndexWrites;
6761   ULONG UserIndexWriteBytes;
6762   ULONG LogFileReads;
6763   ULONG LogFileReadBytes;
6764   ULONG LogFileWrites;
6765   ULONG LogFileWriteBytes;
6766   struct {
6767     ULONG Calls;
6768     ULONG Clusters;
6769     ULONG Hints;
6770     ULONG RunsReturned;
6771     ULONG HintsHonored;
6772     ULONG HintsClusters;
6773     ULONG Cache;
6774     ULONG CacheClusters;
6775     ULONG CacheMiss;
6776     ULONG CacheMissClusters;
6777   } Allocate;
6778 } NTFS_STATISTICS, *PNTFS_STATISTICS;
6779 
6780 #endif /* _FILESYSTEMFSCTL_ */
6781 
6782 #define SYMLINK_FLAG_RELATIVE   1
6783 
6784 typedef struct _REPARSE_DATA_BUFFER {
6785   ULONG ReparseTag;
6786   USHORT ReparseDataLength;
6787   USHORT Reserved;
6788   _ANONYMOUS_UNION union {
6789     struct {
6790       USHORT SubstituteNameOffset;
6791       USHORT SubstituteNameLength;
6792       USHORT PrintNameOffset;
6793       USHORT PrintNameLength;
6794       ULONG Flags;
6795       WCHAR PathBuffer[1];
6796     } SymbolicLinkReparseBuffer;
6797     struct {
6798       USHORT SubstituteNameOffset;
6799       USHORT SubstituteNameLength;
6800       USHORT PrintNameOffset;
6801       USHORT PrintNameLength;
6802       WCHAR PathBuffer[1];
6803     } MountPointReparseBuffer;
6804     struct {
6805       UCHAR DataBuffer[1];
6806     } GenericReparseBuffer;
6807   } DUMMYUNIONNAME;
6808 } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
6809 
6810 #define REPARSE_DATA_BUFFER_HEADER_SIZE   FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
6811 
6812 typedef struct _REPARSE_GUID_DATA_BUFFER {
6813   ULONG ReparseTag;
6814   USHORT ReparseDataLength;
6815   USHORT Reserved;
6816   GUID ReparseGuid;
6817   struct {
6818     UCHAR DataBuffer[1];
6819   } GenericReparseBuffer;
6820 } REPARSE_GUID_DATA_BUFFER, *PREPARSE_GUID_DATA_BUFFER;
6821 
6822 #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE   FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer)
6823 
6824 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE      ( 16 * 1024 )
6825 
6826 /* Reserved reparse tags */
6827 #define IO_REPARSE_TAG_RESERVED_ZERO            (0)
6828 #define IO_REPARSE_TAG_RESERVED_ONE             (1)
6829 #define IO_REPARSE_TAG_RESERVED_RANGE           IO_REPARSE_TAG_RESERVED_ONE
6830 
6831 #define IsReparseTagMicrosoft(_tag)             (((_tag) & 0x80000000))
6832 #define IsReparseTagNameSurrogate(_tag)         (((_tag) & 0x20000000))
6833 
6834 #define IO_REPARSE_TAG_VALID_VALUES             (0xF000FFFF)
6835 
6836 #define IsReparseTagValid(tag) (                               \
6837                   !((tag) & ~IO_REPARSE_TAG_VALID_VALUES) &&   \
6838                   ((tag) > IO_REPARSE_TAG_RESERVED_RANGE)      \
6839                 )
6840 
6841 /* MicroSoft reparse point tags */
6842 #define IO_REPARSE_TAG_MOUNT_POINT              (0xA0000003L)
6843 #define IO_REPARSE_TAG_HSM                      (0xC0000004L)
6844 #define IO_REPARSE_TAG_DRIVE_EXTENDER           (0x80000005L)
6845 #define IO_REPARSE_TAG_HSM2                     (0x80000006L)
6846 #define IO_REPARSE_TAG_SIS                      (0x80000007L)
6847 #define IO_REPARSE_TAG_WIM                      (0x80000008L)
6848 #define IO_REPARSE_TAG_CSV                      (0x80000009L)
6849 #define IO_REPARSE_TAG_DFS                      (0x8000000AL)
6850 #define IO_REPARSE_TAG_FILTER_MANAGER           (0x8000000BL)
6851 #define IO_REPARSE_TAG_SYMLINK                  (0xA000000CL)
6852 #define IO_REPARSE_TAG_IIS_CACHE                (0xA0000010L)
6853 #define IO_REPARSE_TAG_DFSR                     (0x80000012L)
6854 
6855 #pragma pack(4)
6856 typedef struct _REPARSE_INDEX_KEY {
6857   ULONG FileReparseTag;
6858   LARGE_INTEGER FileId;
6859 } REPARSE_INDEX_KEY, *PREPARSE_INDEX_KEY;
6860 #pragma pack()
6861 
6862 #define FSCTL_LMR_GET_LINK_TRACKING_INFORMATION   CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,58,METHOD_BUFFERED,FILE_ANY_ACCESS)
6863 #define FSCTL_LMR_SET_LINK_TRACKING_INFORMATION   CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,59,METHOD_BUFFERED,FILE_ANY_ACCESS)
6864 #define IOCTL_LMR_ARE_FILE_OBJECTS_ON_SAME_SERVER CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,60,METHOD_BUFFERED,FILE_ANY_ACCESS)
6865 
6866 #define FSCTL_PIPE_ASSIGN_EVENT             CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
6867 #define FSCTL_PIPE_DISCONNECT               CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
6868 #define FSCTL_PIPE_LISTEN                   CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
6869 #define FSCTL_PIPE_PEEK                     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
6870 #define FSCTL_PIPE_QUERY_EVENT              CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
6871 #define FSCTL_PIPE_TRANSCEIVE               CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER,  FILE_READ_DATA | FILE_WRITE_DATA)
6872 #define FSCTL_PIPE_WAIT                     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
6873 #define FSCTL_PIPE_IMPERSONATE              CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
6874 #define FSCTL_PIPE_SET_CLIENT_PROCESS       CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
6875 #define FSCTL_PIPE_QUERY_CLIENT_PROCESS     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
6876 #define FSCTL_PIPE_GET_PIPE_ATTRIBUTE       CTL_CODE(FILE_DEVICE_NAMED_PIPE, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
6877 #define FSCTL_PIPE_SET_PIPE_ATTRIBUTE       CTL_CODE(FILE_DEVICE_NAMED_PIPE, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
6878 #define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
6879 #define FSCTL_PIPE_SET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
6880 #define FSCTL_PIPE_GET_HANDLE_ATTRIBUTE     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
6881 #define FSCTL_PIPE_SET_HANDLE_ATTRIBUTE     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
6882 #define FSCTL_PIPE_FLUSH                    CTL_CODE(FILE_DEVICE_NAMED_PIPE, 16, METHOD_BUFFERED, FILE_WRITE_DATA)
6883 
6884 #define FSCTL_PIPE_INTERNAL_READ            CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
6885 #define FSCTL_PIPE_INTERNAL_WRITE           CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
6886 #define FSCTL_PIPE_INTERNAL_TRANSCEIVE      CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
6887 #define FSCTL_PIPE_INTERNAL_READ_OVFLOW     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
6888 
6889 #define FILE_PIPE_READ_DATA                 0x00000000
6890 #define FILE_PIPE_WRITE_SPACE               0x00000001
6891 
6892 typedef struct _FILE_PIPE_ASSIGN_EVENT_BUFFER {
6893   HANDLE EventHandle;
6894   ULONG KeyValue;
6895 } FILE_PIPE_ASSIGN_EVENT_BUFFER, *PFILE_PIPE_ASSIGN_EVENT_BUFFER;
6896 
6897 typedef struct _FILE_PIPE_EVENT_BUFFER {
6898   ULONG NamedPipeState;
6899   ULONG EntryType;
6900   ULONG ByteCount;
6901   ULONG KeyValue;
6902   ULONG NumberRequests;
6903 } FILE_PIPE_EVENT_BUFFER, *PFILE_PIPE_EVENT_BUFFER;
6904 
6905 typedef struct _FILE_PIPE_PEEK_BUFFER {
6906   ULONG NamedPipeState;
6907   ULONG ReadDataAvailable;
6908   ULONG NumberOfMessages;
6909   ULONG MessageLength;
6910   CHAR Data[1];
6911 } FILE_PIPE_PEEK_BUFFER, *PFILE_PIPE_PEEK_BUFFER;
6912 
6913 typedef struct _FILE_PIPE_WAIT_FOR_BUFFER {
6914   LARGE_INTEGER Timeout;
6915   ULONG NameLength;
6916   BOOLEAN TimeoutSpecified;
6917   WCHAR Name[1];
6918 } FILE_PIPE_WAIT_FOR_BUFFER, *PFILE_PIPE_WAIT_FOR_BUFFER;
6919 
6920 typedef struct _FILE_PIPE_CLIENT_PROCESS_BUFFER {
6921 #if !defined(BUILD_WOW6432)
6922   PVOID ClientSession;
6923   PVOID ClientProcess;
6924 #else
6925   ULONGLONG ClientSession;
6926   ULONGLONG ClientProcess;
6927 #endif
6928 } FILE_PIPE_CLIENT_PROCESS_BUFFER, *PFILE_PIPE_CLIENT_PROCESS_BUFFER;
6929 
6930 #define FILE_PIPE_COMPUTER_NAME_LENGTH 15
6931 
6932 typedef struct _FILE_PIPE_CLIENT_PROCESS_BUFFER_EX {
6933 #if !defined(BUILD_WOW6432)
6934   PVOID ClientSession;
6935   PVOID ClientProcess;
6936 #else
6937   ULONGLONG ClientSession;
6938   ULONGLONG ClientProcess;
6939 #endif
6940   USHORT ClientComputerNameLength;
6941   WCHAR ClientComputerBuffer[FILE_PIPE_COMPUTER_NAME_LENGTH+1];
6942 } FILE_PIPE_CLIENT_PROCESS_BUFFER_EX, *PFILE_PIPE_CLIENT_PROCESS_BUFFER_EX;
6943 
6944 #define FSCTL_MAILSLOT_PEEK             CTL_CODE(FILE_DEVICE_MAILSLOT, 0, METHOD_NEITHER, FILE_READ_DATA)
6945 
6946 typedef enum _LINK_TRACKING_INFORMATION_TYPE {
6947   NtfsLinkTrackingInformation,
6948   DfsLinkTrackingInformation
6949 } LINK_TRACKING_INFORMATION_TYPE, *PLINK_TRACKING_INFORMATION_TYPE;
6950 
6951 typedef struct _LINK_TRACKING_INFORMATION {
6952   LINK_TRACKING_INFORMATION_TYPE Type;
6953   UCHAR VolumeId[16];
6954 } LINK_TRACKING_INFORMATION, *PLINK_TRACKING_INFORMATION;
6955 
6956 typedef struct _REMOTE_LINK_TRACKING_INFORMATION {
6957   PVOID TargetFileObject;
6958   ULONG TargetLinkTrackingInformationLength;
6959   UCHAR TargetLinkTrackingInformationBuffer[1];
6960 } REMOTE_LINK_TRACKING_INFORMATION, *PREMOTE_LINK_TRACKING_INFORMATION;
6961 
6962 #define IO_OPEN_PAGING_FILE                 0x0002
6963 #define IO_OPEN_TARGET_DIRECTORY            0x0004
6964 #define IO_STOP_ON_SYMLINK                  0x0008
6965 #define IO_MM_PAGING_FILE                   0x0010
6966 
6967 _Function_class_(DRIVER_FS_NOTIFICATION)
6968 typedef VOID
6969 (NTAPI DRIVER_FS_NOTIFICATION)(
6970   _In_ PDEVICE_OBJECT DeviceObject,
6971   _In_ BOOLEAN FsActive);
6972 typedef DRIVER_FS_NOTIFICATION *PDRIVER_FS_NOTIFICATION;
6973 
6974 typedef enum _FS_FILTER_SECTION_SYNC_TYPE {
6975   SyncTypeOther = 0,
6976   SyncTypeCreateSection
6977 } FS_FILTER_SECTION_SYNC_TYPE, *PFS_FILTER_SECTION_SYNC_TYPE;
6978 
6979 typedef enum _FS_FILTER_STREAM_FO_NOTIFICATION_TYPE {
6980   NotifyTypeCreate = 0,
6981   NotifyTypeRetired
6982 } FS_FILTER_STREAM_FO_NOTIFICATION_TYPE, *PFS_FILTER_STREAM_FO_NOTIFICATION_TYPE;
6983 
6984 typedef union _FS_FILTER_PARAMETERS {
6985   struct {
6986     PLARGE_INTEGER EndingOffset;
6987     PERESOURCE *ResourceToRelease;
6988   } AcquireForModifiedPageWriter;
6989   struct {
6990     PERESOURCE ResourceToRelease;
6991   } ReleaseForModifiedPageWriter;
6992   struct {
6993     FS_FILTER_SECTION_SYNC_TYPE SyncType;
6994     ULONG PageProtection;
6995   } AcquireForSectionSynchronization;
6996   struct {
6997     FS_FILTER_STREAM_FO_NOTIFICATION_TYPE NotificationType;
6998     BOOLEAN POINTER_ALIGNMENT SafeToRecurse;
6999   } NotifyStreamFileObject;
7000   struct {
7001     PVOID Argument1;
7002     PVOID Argument2;
7003     PVOID Argument3;
7004     PVOID Argument4;
7005     PVOID Argument5;
7006   } Others;
7007 } FS_FILTER_PARAMETERS, *PFS_FILTER_PARAMETERS;
7008 
7009 #define FS_FILTER_ACQUIRE_FOR_SECTION_SYNCHRONIZATION      (UCHAR)-1
7010 #define FS_FILTER_RELEASE_FOR_SECTION_SYNCHRONIZATION      (UCHAR)-2
7011 #define FS_FILTER_ACQUIRE_FOR_MOD_WRITE                    (UCHAR)-3
7012 #define FS_FILTER_RELEASE_FOR_MOD_WRITE                    (UCHAR)-4
7013 #define FS_FILTER_ACQUIRE_FOR_CC_FLUSH                     (UCHAR)-5
7014 #define FS_FILTER_RELEASE_FOR_CC_FLUSH                     (UCHAR)-6
7015 
7016 typedef struct _FS_FILTER_CALLBACK_DATA {
7017   ULONG SizeOfFsFilterCallbackData;
7018   UCHAR Operation;
7019   UCHAR Reserved;
7020   struct _DEVICE_OBJECT *DeviceObject;
7021   struct _FILE_OBJECT *FileObject;
7022   FS_FILTER_PARAMETERS Parameters;
7023 } FS_FILTER_CALLBACK_DATA, *PFS_FILTER_CALLBACK_DATA;
7024 
7025 typedef NTSTATUS
7026 (NTAPI *PFS_FILTER_CALLBACK) (
7027   _In_ PFS_FILTER_CALLBACK_DATA Data,
7028   _Out_ PVOID *CompletionContext);
7029 
7030 typedef VOID
7031 (NTAPI *PFS_FILTER_COMPLETION_CALLBACK) (
7032   _In_ PFS_FILTER_CALLBACK_DATA Data,
7033   _In_ NTSTATUS OperationStatus,
7034   _In_ PVOID CompletionContext);
7035 
7036 typedef struct _FS_FILTER_CALLBACKS {
7037   ULONG SizeOfFsFilterCallbacks;
7038   ULONG Reserved;
7039   PFS_FILTER_CALLBACK PreAcquireForSectionSynchronization;
7040   PFS_FILTER_COMPLETION_CALLBACK PostAcquireForSectionSynchronization;
7041   PFS_FILTER_CALLBACK PreReleaseForSectionSynchronization;
7042   PFS_FILTER_COMPLETION_CALLBACK PostReleaseForSectionSynchronization;
7043   PFS_FILTER_CALLBACK PreAcquireForCcFlush;
7044   PFS_FILTER_COMPLETION_CALLBACK PostAcquireForCcFlush;
7045   PFS_FILTER_CALLBACK PreReleaseForCcFlush;
7046   PFS_FILTER_COMPLETION_CALLBACK PostReleaseForCcFlush;
7047   PFS_FILTER_CALLBACK PreAcquireForModifiedPageWriter;
7048   PFS_FILTER_COMPLETION_CALLBACK PostAcquireForModifiedPageWriter;
7049   PFS_FILTER_CALLBACK PreReleaseForModifiedPageWriter;
7050   PFS_FILTER_COMPLETION_CALLBACK PostReleaseForModifiedPageWriter;
7051 } FS_FILTER_CALLBACKS, *PFS_FILTER_CALLBACKS;
7052 
7053 extern NTKERNELAPI KSPIN_LOCK    IoStatisticsLock;
7054 extern NTKERNELAPI ULONG         IoReadOperationCount;
7055 extern NTKERNELAPI ULONG         IoWriteOperationCount;
7056 extern NTKERNELAPI ULONG         IoOtherOperationCount;
7057 extern NTKERNELAPI LARGE_INTEGER IoReadTransferCount;
7058 extern NTKERNELAPI LARGE_INTEGER IoWriteTransferCount;
7059 extern NTKERNELAPI LARGE_INTEGER IoOtherTransferCount;
7060 
7061 #define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE    64
7062 #define IO_FILE_OBJECT_PAGED_POOL_CHARGE        1024
7063 
7064 #if (NTDDI_VERSION >= NTDDI_VISTA)
7065 typedef struct _IO_PRIORITY_INFO {
7066   ULONG Size;
7067   ULONG ThreadPriority;
7068   ULONG PagePriority;
7069   IO_PRIORITY_HINT IoPriority;
7070 } IO_PRIORITY_INFO, *PIO_PRIORITY_INFO;
7071 #endif
7072 $endif (_NTIFS_)
7073