xref: /reactos/sdk/include/xdk/iotypes.h (revision 7115d7ba)
1 $if (_WDMDDK_ || _NTDDK_)
2 /******************************************************************************
3  *                         I/O Manager Types                                  *
4  ******************************************************************************/
5 $endif (_WDMDDK_ || _NTDDK_)
6 
7 $if (_WDMDDK_)
8 
9 #define STATUS_CONTINUE_COMPLETION      STATUS_SUCCESS
10 
11 #define CONNECT_FULLY_SPECIFIED         0x1
12 #define CONNECT_LINE_BASED              0x2
13 #define CONNECT_MESSAGE_BASED           0x3
14 #define CONNECT_FULLY_SPECIFIED_GROUP   0x4
15 #define CONNECT_CURRENT_VERSION         0x4
16 
17 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE    0x8
18 #define POOL_RAISE_IF_ALLOCATION_FAILURE    0x10
19 #define POOL_COLD_ALLOCATION                0x100
20 #define POOL_NX_ALLOCATION                  0x200
21 #define POOL_ZERO_ALLOCATION                0x400
22 
23 #define IO_TYPE_ADAPTER                 1
24 #define IO_TYPE_CONTROLLER              2
25 #define IO_TYPE_DEVICE                  3
26 #define IO_TYPE_DRIVER                  4
27 #define IO_TYPE_FILE                    5
28 #define IO_TYPE_IRP                     6
29 #define IO_TYPE_MASTER_ADAPTER          7
30 #define IO_TYPE_OPEN_PACKET             8
31 #define IO_TYPE_TIMER                   9
32 #define IO_TYPE_VPB                     10
33 #define IO_TYPE_ERROR_LOG               11
34 #define IO_TYPE_ERROR_MESSAGE           12
35 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
36 
37 #define IO_TYPE_CSQ_IRP_CONTEXT 1
38 #define IO_TYPE_CSQ 2
39 #define IO_TYPE_CSQ_EX 3
40 
41 /* IO_RESOURCE_DESCRIPTOR.Option */
42 #define IO_RESOURCE_PREFERRED             0x01
43 #define IO_RESOURCE_DEFAULT               0x02
44 #define IO_RESOURCE_ALTERNATIVE           0x08
45 
46 $endif (_WDMDDK_)
47 $if (_WDMDDK_ || _DEVIOCTL_)
48 #define FILE_DEVICE_BEEP                  0x00000001
49 #define FILE_DEVICE_CD_ROM                0x00000002
50 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM    0x00000003
51 #define FILE_DEVICE_CONTROLLER            0x00000004
52 #define FILE_DEVICE_DATALINK              0x00000005
53 #define FILE_DEVICE_DFS                   0x00000006
54 #define FILE_DEVICE_DISK                  0x00000007
55 #define FILE_DEVICE_DISK_FILE_SYSTEM      0x00000008
56 #define FILE_DEVICE_FILE_SYSTEM           0x00000009
57 #define FILE_DEVICE_INPORT_PORT           0x0000000a
58 #define FILE_DEVICE_KEYBOARD              0x0000000b
59 #define FILE_DEVICE_MAILSLOT              0x0000000c
60 #define FILE_DEVICE_MIDI_IN               0x0000000d
61 #define FILE_DEVICE_MIDI_OUT              0x0000000e
62 #define FILE_DEVICE_MOUSE                 0x0000000f
63 #define FILE_DEVICE_MULTI_UNC_PROVIDER    0x00000010
64 #define FILE_DEVICE_NAMED_PIPE            0x00000011
65 #define FILE_DEVICE_NETWORK               0x00000012
66 #define FILE_DEVICE_NETWORK_BROWSER       0x00000013
67 #define FILE_DEVICE_NETWORK_FILE_SYSTEM   0x00000014
68 #define FILE_DEVICE_NULL                  0x00000015
69 #define FILE_DEVICE_PARALLEL_PORT         0x00000016
70 #define FILE_DEVICE_PHYSICAL_NETCARD      0x00000017
71 #define FILE_DEVICE_PRINTER               0x00000018
72 #define FILE_DEVICE_SCANNER               0x00000019
73 #define FILE_DEVICE_SERIAL_MOUSE_PORT     0x0000001a
74 #define FILE_DEVICE_SERIAL_PORT           0x0000001b
75 #define FILE_DEVICE_SCREEN                0x0000001c
76 #define FILE_DEVICE_SOUND                 0x0000001d
77 #define FILE_DEVICE_STREAMS               0x0000001e
78 #define FILE_DEVICE_TAPE                  0x0000001f
79 #define FILE_DEVICE_TAPE_FILE_SYSTEM      0x00000020
80 #define FILE_DEVICE_TRANSPORT             0x00000021
81 #define FILE_DEVICE_UNKNOWN               0x00000022
82 #define FILE_DEVICE_VIDEO                 0x00000023
83 #define FILE_DEVICE_VIRTUAL_DISK          0x00000024
84 #define FILE_DEVICE_WAVE_IN               0x00000025
85 #define FILE_DEVICE_WAVE_OUT              0x00000026
86 #define FILE_DEVICE_8042_PORT             0x00000027
87 #define FILE_DEVICE_NETWORK_REDIRECTOR    0x00000028
88 #define FILE_DEVICE_BATTERY               0x00000029
89 #define FILE_DEVICE_BUS_EXTENDER          0x0000002a
90 #define FILE_DEVICE_MODEM                 0x0000002b
91 #define FILE_DEVICE_VDM                   0x0000002c
92 #define FILE_DEVICE_MASS_STORAGE          0x0000002d
93 #define FILE_DEVICE_SMB                   0x0000002e
94 #define FILE_DEVICE_KS                    0x0000002f
95 #define FILE_DEVICE_CHANGER               0x00000030
96 #define FILE_DEVICE_SMARTCARD             0x00000031
97 #define FILE_DEVICE_ACPI                  0x00000032
98 #define FILE_DEVICE_DVD                   0x00000033
99 #define FILE_DEVICE_FULLSCREEN_VIDEO      0x00000034
100 #define FILE_DEVICE_DFS_FILE_SYSTEM       0x00000035
101 #define FILE_DEVICE_DFS_VOLUME            0x00000036
102 #define FILE_DEVICE_SERENUM               0x00000037
103 #define FILE_DEVICE_TERMSRV               0x00000038
104 #define FILE_DEVICE_KSEC                  0x00000039
105 #define FILE_DEVICE_FIPS                  0x0000003A
106 #define FILE_DEVICE_INFINIBAND            0x0000003B
107 #define FILE_DEVICE_VMBUS                 0x0000003E
108 #define FILE_DEVICE_CRYPT_PROVIDER        0x0000003F
109 #define FILE_DEVICE_WPD                   0x00000040
110 #define FILE_DEVICE_BLUETOOTH             0x00000041
111 #define FILE_DEVICE_MT_COMPOSITE          0x00000042
112 #define FILE_DEVICE_MT_TRANSPORT          0x00000043
113 #define FILE_DEVICE_BIOMETRIC             0x00000044
114 #define FILE_DEVICE_PMI                   0x00000045
115 
116 $endif (_WDMDDK_ || _DEVIOCTL_)
117 $if (_WDMDDK_)
118 #if defined(NT_PROCESSOR_GROUPS)
119 
120 typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
121 
122 typedef enum _IRQ_DEVICE_POLICY_USHORT {
123   IrqPolicyMachineDefault = 0,
124   IrqPolicyAllCloseProcessors = 1,
125   IrqPolicyOneCloseProcessor = 2,
126   IrqPolicyAllProcessorsInMachine = 3,
127   IrqPolicyAllProcessorsInGroup = 3,
128   IrqPolicySpecifiedProcessors = 4,
129   IrqPolicySpreadMessagesAcrossAllProcessors = 5};
130 
131 #else /* defined(NT_PROCESSOR_GROUPS) */
132 
133 typedef enum _IRQ_DEVICE_POLICY {
134   IrqPolicyMachineDefault = 0,
135   IrqPolicyAllCloseProcessors,
136   IrqPolicyOneCloseProcessor,
137   IrqPolicyAllProcessorsInMachine,
138   IrqPolicySpecifiedProcessors,
139   IrqPolicySpreadMessagesAcrossAllProcessors
140 } IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
141 
142 #endif
143 
144 typedef enum _IRQ_PRIORITY {
145   IrqPriorityUndefined = 0,
146   IrqPriorityLow,
147   IrqPriorityNormal,
148   IrqPriorityHigh
149 } IRQ_PRIORITY, *PIRQ_PRIORITY;
150 
151 typedef enum _IRQ_GROUP_POLICY {
152   GroupAffinityAllGroupZero = 0,
153   GroupAffinityDontCare
154 } IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY;
155 
156 #define MAXIMUM_VOLUME_LABEL_LENGTH       (32 * sizeof(WCHAR))
157 
158 typedef struct _OBJECT_HANDLE_INFORMATION {
159   ULONG HandleAttributes;
160   ACCESS_MASK GrantedAccess;
161 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
162 
163 typedef struct _CLIENT_ID {
164   HANDLE UniqueProcess;
165   HANDLE UniqueThread;
166 } CLIENT_ID, *PCLIENT_ID;
167 
168 typedef struct _VPB {
169   CSHORT Type;
170   CSHORT Size;
171   USHORT Flags;
172   USHORT VolumeLabelLength;
173   struct _DEVICE_OBJECT *DeviceObject;
174   struct _DEVICE_OBJECT *RealDevice;
175   ULONG SerialNumber;
176   ULONG ReferenceCount;
177   WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
178 } VPB, *PVPB;
179 
180 typedef enum _IO_ALLOCATION_ACTION {
181   KeepObject = 1,
182   DeallocateObject,
183   DeallocateObjectKeepRegisters
184 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
185 
186 _Function_class_(DRIVER_CONTROL)
187 _IRQL_requires_same_
188 typedef IO_ALLOCATION_ACTION
189 (NTAPI DRIVER_CONTROL)(
190   _In_ struct _DEVICE_OBJECT *DeviceObject,
191   _Inout_ struct _IRP *Irp,
192   _In_ PVOID MapRegisterBase,
193   _In_ PVOID Context);
194 typedef DRIVER_CONTROL *PDRIVER_CONTROL;
195 
196 typedef struct _WAIT_CONTEXT_BLOCK {
197   KDEVICE_QUEUE_ENTRY WaitQueueEntry;
198   PDRIVER_CONTROL DeviceRoutine;
199   PVOID DeviceContext;
200   ULONG NumberOfMapRegisters;
201   PVOID DeviceObject;
202   PVOID CurrentIrp;
203   PKDPC BufferChainingDpc;
204 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
205 
206 $endif (_WDMDDK_)
207 $if (_NTDDK_)
208 /* DEVICE_OBJECT.Flags */
209 #define DO_DEVICE_HAS_NAME                0x00000040
210 #define DO_SYSTEM_BOOT_PARTITION          0x00000100
211 #define DO_LONG_TERM_REQUESTS             0x00000200
212 #define DO_NEVER_LAST_DEVICE              0x00000400
213 #define DO_LOW_PRIORITY_FILESYSTEM        0x00010000
214 #define DO_SUPPORTS_TRANSACTIONS          0x00040000
215 #define DO_FORCE_NEITHER_IO               0x00080000
216 #define DO_VOLUME_DEVICE_OBJECT           0x00100000
217 #define DO_SYSTEM_SYSTEM_PARTITION        0x00200000
218 #define DO_SYSTEM_CRITICAL_PARTITION      0x00400000
219 #define DO_DISALLOW_EXECUTE               0x00800000
220 
221 $endif (_NTDDK_)
222 $if (_WDMDDK_)
223 /* DEVICE_OBJECT.Flags */
224 #define DO_UNLOAD_PENDING                 0x00000001
225 #define DO_VERIFY_VOLUME                  0x00000002
226 #define DO_BUFFERED_IO                    0x00000004
227 #define DO_EXCLUSIVE                      0x00000008
228 #define DO_DIRECT_IO                      0x00000010
229 #define DO_MAP_IO_BUFFER                  0x00000020
230 #define DO_DEVICE_INITIALIZING            0x00000080
231 #define DO_SHUTDOWN_REGISTERED            0x00000800
232 #define DO_BUS_ENUMERATED_DEVICE          0x00001000
233 #define DO_POWER_PAGABLE                  0x00002000
234 #define DO_POWER_INRUSH                   0x00004000
235 
236 /* DEVICE_OBJECT.Characteristics */
237 #define FILE_REMOVABLE_MEDIA              0x00000001
238 #define FILE_READ_ONLY_DEVICE             0x00000002
239 #define FILE_FLOPPY_DISKETTE              0x00000004
240 #define FILE_WRITE_ONCE_MEDIA             0x00000008
241 #define FILE_REMOTE_DEVICE                0x00000010
242 #define FILE_DEVICE_IS_MOUNTED            0x00000020
243 #define FILE_VIRTUAL_VOLUME               0x00000040
244 #define FILE_AUTOGENERATED_DEVICE_NAME    0x00000080
245 #define FILE_DEVICE_SECURE_OPEN           0x00000100
246 #define FILE_CHARACTERISTIC_PNP_DEVICE    0x00000800
247 #define FILE_CHARACTERISTIC_TS_DEVICE     0x00001000
248 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
249 
250 /* DEVICE_OBJECT.AlignmentRequirement */
251 #define FILE_BYTE_ALIGNMENT             0x00000000
252 #define FILE_WORD_ALIGNMENT             0x00000001
253 #define FILE_LONG_ALIGNMENT             0x00000003
254 #define FILE_QUAD_ALIGNMENT             0x00000007
255 #define FILE_OCTA_ALIGNMENT             0x0000000f
256 #define FILE_32_BYTE_ALIGNMENT          0x0000001f
257 #define FILE_64_BYTE_ALIGNMENT          0x0000003f
258 #define FILE_128_BYTE_ALIGNMENT         0x0000007f
259 #define FILE_256_BYTE_ALIGNMENT         0x000000ff
260 #define FILE_512_BYTE_ALIGNMENT         0x000001ff
261 
262 $endif (_NTDDK_)
263 $if (_WDMDDK_ || _DEVIOCTL_)
264 /* DEVICE_OBJECT.DeviceType */
265 #define DEVICE_TYPE ULONG
266 
267 $endif (_WDMDDK_ || _DEVIOCTL_)
268 $if (_WDMDDK_)
269 typedef struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _DEVICE_OBJECT {
270   CSHORT Type;
271   USHORT Size;
272   LONG ReferenceCount;
273   struct _DRIVER_OBJECT *DriverObject;
274   struct _DEVICE_OBJECT *NextDevice;
275   struct _DEVICE_OBJECT *AttachedDevice;
276   struct _IRP *CurrentIrp;
277   PIO_TIMER Timer;
278   ULONG Flags;
279   ULONG Characteristics;
280   volatile PVPB Vpb;
281   PVOID DeviceExtension;
282   DEVICE_TYPE DeviceType;
283   CCHAR StackSize;
284   union {
285     LIST_ENTRY ListEntry;
286     WAIT_CONTEXT_BLOCK Wcb;
287   } Queue;
288   ULONG AlignmentRequirement;
289   KDEVICE_QUEUE DeviceQueue;
290   KDPC Dpc;
291   ULONG ActiveThreadCount;
292   PSECURITY_DESCRIPTOR SecurityDescriptor;
293   KEVENT DeviceLock;
294   USHORT SectorSize;
295   USHORT Spare1;
296   struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
297   PVOID Reserved;
298 } DEVICE_OBJECT, *PDEVICE_OBJECT;
299 
300 typedef enum _IO_SESSION_STATE {
301   IoSessionStateCreated = 1,
302   IoSessionStateInitialized,
303   IoSessionStateConnected,
304   IoSessionStateDisconnected,
305   IoSessionStateDisconnectedLoggedOn,
306   IoSessionStateLoggedOn,
307   IoSessionStateLoggedOff,
308   IoSessionStateTerminated,
309   IoSessionStateMax
310 } IO_SESSION_STATE, *PIO_SESSION_STATE;
311 
312 typedef enum _IO_COMPLETION_ROUTINE_RESULT {
313   ContinueCompletion = STATUS_CONTINUE_COMPLETION,
314   StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
315 } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
316 
317 typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY {
318   PHYSICAL_ADDRESS MessageAddress;
319   KAFFINITY TargetProcessorSet;
320   PKINTERRUPT InterruptObject;
321   ULONG MessageData;
322   ULONG Vector;
323   KIRQL Irql;
324   KINTERRUPT_MODE Mode;
325   KINTERRUPT_POLARITY Polarity;
326 } IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY;
327 
328 typedef struct _IO_INTERRUPT_MESSAGE_INFO {
329   KIRQL UnifiedIrql;
330   ULONG MessageCount;
331   IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1];
332 } IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO;
333 
334 typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS {
335   _In_ PDEVICE_OBJECT PhysicalDeviceObject;
336   _Out_ PKINTERRUPT *InterruptObject;
337   _In_ PKSERVICE_ROUTINE ServiceRoutine;
338   _In_ PVOID ServiceContext;
339   _In_opt_ PKSPIN_LOCK SpinLock;
340   _In_ KIRQL SynchronizeIrql;
341   _In_ BOOLEAN FloatingSave;
342   _In_ BOOLEAN ShareVector;
343   _In_ ULONG Vector;
344   _In_ KIRQL Irql;
345   _In_ KINTERRUPT_MODE InterruptMode;
346   _In_ KAFFINITY ProcessorEnableMask;
347   _In_ USHORT Group;
348 } IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS;
349 
350 typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS {
351   _In_ PDEVICE_OBJECT PhysicalDeviceObject;
352   _Out_ PKINTERRUPT *InterruptObject;
353   _In_ PKSERVICE_ROUTINE ServiceRoutine;
354   _In_ PVOID ServiceContext;
355   _In_opt_ PKSPIN_LOCK SpinLock;
356   _In_opt_ KIRQL SynchronizeIrql;
357   _In_ BOOLEAN FloatingSave;
358 } IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS;
359 
360 typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS {
361   _In_ PDEVICE_OBJECT PhysicalDeviceObject;
362   union {
363     _Out_ PVOID *Generic;
364     _Out_ PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable;
365     _Out_ PKINTERRUPT *InterruptObject;
366   } ConnectionContext;
367   _In_ PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine;
368   _In_ PVOID ServiceContext;
369   _In_opt_ PKSPIN_LOCK SpinLock;
370   _In_opt_ KIRQL SynchronizeIrql;
371   _In_ BOOLEAN FloatingSave;
372   _In_opt_ PKSERVICE_ROUTINE FallBackServiceRoutine;
373 } IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS;
374 
375 typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS {
376   _Inout_ ULONG Version;
377   _ANONYMOUS_UNION union {
378     IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified;
379     IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased;
380     IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased;
381   } DUMMYUNIONNAME;
382 } IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS;
383 
384 typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS {
385   _In_ ULONG Version;
386   union {
387     _In_ PVOID Generic;
388     _In_ PKINTERRUPT InterruptObject;
389     _In_ PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable;
390   } ConnectionContext;
391 } IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS;
392 
393 typedef enum _IO_ACCESS_TYPE {
394   ReadAccess,
395   WriteAccess,
396   ModifyAccess
397 } IO_ACCESS_TYPE;
398 
399 typedef enum _IO_ACCESS_MODE {
400   SequentialAccess,
401   RandomAccess
402 } IO_ACCESS_MODE;
403 
404 typedef enum _IO_CONTAINER_NOTIFICATION_CLASS {
405   IoSessionStateNotification,
406   IoMaxContainerNotificationClass
407 } IO_CONTAINER_NOTIFICATION_CLASS;
408 
409 typedef struct _IO_SESSION_STATE_NOTIFICATION {
410   ULONG Size;
411   ULONG Flags;
412   PVOID IoObject;
413   ULONG EventMask;
414   PVOID Context;
415 } IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION;
416 
417 typedef enum _IO_CONTAINER_INFORMATION_CLASS {
418   IoSessionStateInformation,
419   IoMaxContainerInformationClass
420 } IO_CONTAINER_INFORMATION_CLASS;
421 
422 typedef struct _IO_SESSION_STATE_INFORMATION {
423   ULONG SessionId;
424   IO_SESSION_STATE SessionState;
425   BOOLEAN LocalSession;
426 } IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION;
427 
428 #if (NTDDI_VERSION >= NTDDI_WIN7)
429 
430 typedef NTSTATUS
431 (NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)(
432   VOID);
433 
434 typedef NTSTATUS
435 (NTAPI IO_SESSION_NOTIFICATION_FUNCTION)(
436   _In_ PVOID SessionObject,
437   _In_ PVOID IoObject,
438   _In_ ULONG Event,
439   _In_ PVOID Context,
440   _In_reads_bytes_opt_(PayloadLength) PVOID NotificationPayload,
441   _In_ ULONG PayloadLength);
442 
443 typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION;
444 
445 #endif
446 
447 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
448 
449 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
450   BOOLEAN Removed;
451   BOOLEAN Reserved[3];
452   volatile LONG IoCount;
453   KEVENT RemoveEvent;
454 } IO_REMOVE_LOCK_COMMON_BLOCK;
455 
456 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
457   LONG Signature;
458   LONG HighWatermark;
459   LONGLONG MaxLockedTicks;
460   LONG AllocateTag;
461   LIST_ENTRY LockList;
462   KSPIN_LOCK Spin;
463   volatile LONG LowMemoryCount;
464   ULONG Reserved1[4];
465   PVOID Reserved2;
466   PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
467 } IO_REMOVE_LOCK_DBG_BLOCK;
468 
469 typedef struct _IO_REMOVE_LOCK {
470   IO_REMOVE_LOCK_COMMON_BLOCK Common;
471 #if DBG
472   IO_REMOVE_LOCK_DBG_BLOCK Dbg;
473 #endif
474 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
475 
476 typedef struct _IO_WORKITEM *PIO_WORKITEM;
477 
478 _Function_class_(IO_WORKITEM_ROUTINE)
479 _IRQL_requires_(PASSIVE_LEVEL)
480 _IRQL_requires_same_
481 typedef VOID
482 (NTAPI IO_WORKITEM_ROUTINE)(
483   _In_ PDEVICE_OBJECT DeviceObject,
484   _In_opt_ PVOID Context);
485 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
486 
487 typedef VOID
488 (NTAPI IO_WORKITEM_ROUTINE_EX)(
489   _In_ PVOID IoObject,
490   _In_opt_ PVOID Context,
491   _In_ PIO_WORKITEM IoWorkItem);
492 typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX;
493 
494 typedef struct _SHARE_ACCESS {
495   ULONG OpenCount;
496   ULONG Readers;
497   ULONG Writers;
498   ULONG Deleters;
499   ULONG SharedRead;
500   ULONG SharedWrite;
501   ULONG SharedDelete;
502 } SHARE_ACCESS, *PSHARE_ACCESS;
503 
504 typedef enum _CREATE_FILE_TYPE {
505   CreateFileTypeNone,
506   CreateFileTypeNamedPipe,
507   CreateFileTypeMailslot
508 } CREATE_FILE_TYPE;
509 
510 #define IO_FORCE_ACCESS_CHECK               0x001
511 #define IO_NO_PARAMETER_CHECKING            0x100
512 
513 #define IO_REPARSE                      0x0
514 #define IO_REMOUNT                      0x1
515 
516 typedef struct _IO_STATUS_BLOCK {
517   _ANONYMOUS_UNION union {
518     NTSTATUS Status;
519     PVOID Pointer;
520   } DUMMYUNIONNAME;
521   ULONG_PTR Information;
522 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
523 
524 #if defined(_WIN64)
525 typedef struct _IO_STATUS_BLOCK32 {
526   NTSTATUS Status;
527   ULONG Information;
528 } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
529 #endif
530 
531 typedef VOID
532 (NTAPI *PIO_APC_ROUTINE)(
533   _In_ PVOID ApcContext,
534   _In_ PIO_STATUS_BLOCK IoStatusBlock,
535   _In_ ULONG Reserved);
536 
537 #define PIO_APC_ROUTINE_DEFINED
538 
539 typedef enum _IO_SESSION_EVENT {
540   IoSessionEventIgnore = 0,
541   IoSessionEventCreated,
542   IoSessionEventTerminated,
543   IoSessionEventConnected,
544   IoSessionEventDisconnected,
545   IoSessionEventLogon,
546   IoSessionEventLogoff,
547   IoSessionEventMax
548 } IO_SESSION_EVENT, *PIO_SESSION_EVENT;
549 
550 #define IO_SESSION_STATE_ALL_EVENTS        0xffffffff
551 #define IO_SESSION_STATE_CREATION_EVENT    0x00000001
552 #define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002
553 #define IO_SESSION_STATE_CONNECT_EVENT     0x00000004
554 #define IO_SESSION_STATE_DISCONNECT_EVENT  0x00000008
555 #define IO_SESSION_STATE_LOGON_EVENT       0x00000010
556 #define IO_SESSION_STATE_LOGOFF_EVENT      0x00000020
557 
558 #define IO_SESSION_STATE_VALID_EVENT_MASK  0x0000003f
559 
560 #define IO_SESSION_MAX_PAYLOAD_SIZE        256L
561 
562 typedef struct _IO_SESSION_CONNECT_INFO {
563   ULONG SessionId;
564   BOOLEAN LocalSession;
565 } IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO;
566 
567 #define EVENT_INCREMENT                   1
568 #define IO_NO_INCREMENT                   0
569 #define IO_CD_ROM_INCREMENT               1
570 #define IO_DISK_INCREMENT                 1
571 #define IO_KEYBOARD_INCREMENT             6
572 #define IO_MAILSLOT_INCREMENT             2
573 #define IO_MOUSE_INCREMENT                6
574 #define IO_NAMED_PIPE_INCREMENT           2
575 #define IO_NETWORK_INCREMENT              2
576 #define IO_PARALLEL_INCREMENT             1
577 #define IO_SERIAL_INCREMENT               2
578 #define IO_SOUND_INCREMENT                8
579 #define IO_VIDEO_INCREMENT                1
580 #define SEMAPHORE_INCREMENT               1
581 
582 #define MM_MAXIMUM_DISK_IO_SIZE          (0x10000)
583 
584 typedef struct _BOOTDISK_INFORMATION {
585   LONGLONG BootPartitionOffset;
586   LONGLONG SystemPartitionOffset;
587   ULONG BootDeviceSignature;
588   ULONG SystemDeviceSignature;
589 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
590 
591 typedef struct _BOOTDISK_INFORMATION_EX {
592   LONGLONG BootPartitionOffset;
593   LONGLONG SystemPartitionOffset;
594   ULONG BootDeviceSignature;
595   ULONG SystemDeviceSignature;
596   GUID BootDeviceGuid;
597   GUID SystemDeviceGuid;
598   BOOLEAN BootDeviceIsGpt;
599   BOOLEAN SystemDeviceIsGpt;
600 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
601 
602 #if (NTDDI_VERSION >= NTDDI_WIN7)
603 
604 typedef struct _LOADER_PARTITION_INFORMATION_EX {
605   ULONG PartitionStyle;
606   ULONG PartitionNumber;
607   _ANONYMOUS_UNION union {
608     ULONG Signature;
609     GUID DeviceId;
610   } DUMMYUNIONNAME;
611   ULONG Flags;
612 } LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX;
613 
614 typedef struct _BOOTDISK_INFORMATION_LITE {
615   ULONG NumberEntries;
616   LOADER_PARTITION_INFORMATION_EX Entries[1];
617 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
618 
619 #else
620 
621 #if (NTDDI_VERSION >= NTDDI_VISTA)
622 typedef struct _BOOTDISK_INFORMATION_LITE {
623   ULONG BootDeviceSignature;
624   ULONG SystemDeviceSignature;
625   GUID BootDeviceGuid;
626   GUID SystemDeviceGuid;
627   BOOLEAN BootDeviceIsGpt;
628   BOOLEAN SystemDeviceIsGpt;
629 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
630 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
631 
632 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
633 
634 #include <pshpack1.h>
635 
636 typedef struct _EISA_MEMORY_TYPE {
637   UCHAR ReadWrite:1;
638   UCHAR Cached:1;
639   UCHAR Reserved0:1;
640   UCHAR Type:2;
641   UCHAR Shared:1;
642   UCHAR Reserved1:1;
643   UCHAR MoreEntries:1;
644 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
645 
646 typedef struct _EISA_MEMORY_CONFIGURATION {
647   EISA_MEMORY_TYPE ConfigurationByte;
648   UCHAR DataSize;
649   USHORT AddressLowWord;
650   UCHAR AddressHighByte;
651   USHORT MemorySize;
652 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
653 
654 typedef struct _EISA_IRQ_DESCRIPTOR {
655   UCHAR Interrupt:4;
656   UCHAR Reserved:1;
657   UCHAR LevelTriggered:1;
658   UCHAR Shared:1;
659   UCHAR MoreEntries:1;
660 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
661 
662 typedef struct _EISA_IRQ_CONFIGURATION {
663   EISA_IRQ_DESCRIPTOR ConfigurationByte;
664   UCHAR Reserved;
665 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
666 
667 typedef struct _DMA_CONFIGURATION_BYTE0 {
668   UCHAR Channel:3;
669   UCHAR Reserved:3;
670   UCHAR Shared:1;
671   UCHAR MoreEntries:1;
672 } DMA_CONFIGURATION_BYTE0;
673 
674 typedef struct _DMA_CONFIGURATION_BYTE1 {
675   UCHAR Reserved0:2;
676   UCHAR TransferSize:2;
677   UCHAR Timing:2;
678   UCHAR Reserved1:2;
679 } DMA_CONFIGURATION_BYTE1;
680 
681 typedef struct _EISA_DMA_CONFIGURATION {
682   DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
683   DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
684 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
685 
686 typedef struct _EISA_PORT_DESCRIPTOR {
687   UCHAR NumberPorts:5;
688   UCHAR Reserved:1;
689   UCHAR Shared:1;
690   UCHAR MoreEntries:1;
691 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
692 
693 typedef struct _EISA_PORT_CONFIGURATION {
694   EISA_PORT_DESCRIPTOR Configuration;
695   USHORT PortAddress;
696 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
697 
698 typedef struct _CM_EISA_SLOT_INFORMATION {
699   UCHAR ReturnCode;
700   UCHAR ReturnFlags;
701   UCHAR MajorRevision;
702   UCHAR MinorRevision;
703   USHORT Checksum;
704   UCHAR NumberFunctions;
705   UCHAR FunctionInformation;
706   ULONG CompressedId;
707 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
708 
709 typedef struct _CM_EISA_FUNCTION_INFORMATION {
710   ULONG CompressedId;
711   UCHAR IdSlotFlags1;
712   UCHAR IdSlotFlags2;
713   UCHAR MinorRevision;
714   UCHAR MajorRevision;
715   UCHAR Selections[26];
716   UCHAR FunctionFlags;
717   UCHAR TypeString[80];
718   EISA_MEMORY_CONFIGURATION EisaMemory[9];
719   EISA_IRQ_CONFIGURATION EisaIrq[7];
720   EISA_DMA_CONFIGURATION EisaDma[4];
721   EISA_PORT_CONFIGURATION EisaPort[20];
722   UCHAR InitializationData[60];
723 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
724 
725 #include <poppack.h>
726 
727 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
728 
729 #define EISA_FUNCTION_ENABLED           0x80
730 #define EISA_FREE_FORM_DATA             0x40
731 #define EISA_HAS_PORT_INIT_ENTRY        0x20
732 #define EISA_HAS_PORT_RANGE             0x10
733 #define EISA_HAS_DMA_ENTRY              0x08
734 #define EISA_HAS_IRQ_ENTRY              0x04
735 #define EISA_HAS_MEMORY_ENTRY           0x02
736 #define EISA_HAS_TYPE_ENTRY             0x01
737 #define EISA_HAS_INFORMATION \
738   (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
739   + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
740 
741 #define EISA_MORE_ENTRIES               0x80
742 #define EISA_SYSTEM_MEMORY              0x00
743 #define EISA_MEMORY_TYPE_RAM            0x01
744 
745 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
746 
747 #define EISA_INVALID_SLOT               0x80
748 #define EISA_INVALID_FUNCTION           0x81
749 #define EISA_INVALID_CONFIGURATION      0x82
750 #define EISA_EMPTY_SLOT                 0x83
751 #define EISA_INVALID_BIOS_CALL          0x86
752 
753 /*
754 ** Plug and Play structures
755 */
756 
757 typedef VOID
758 (NTAPI *PINTERFACE_REFERENCE)(
759   PVOID Context);
760 
761 typedef VOID
762 (NTAPI *PINTERFACE_DEREFERENCE)(
763   PVOID Context);
764 
765 _Function_class_(TRANSLATE_BUS_ADDRESS)
766 _IRQL_requires_same_
767 typedef BOOLEAN
768 (NTAPI TRANSLATE_BUS_ADDRESS)(
769   _Inout_opt_ PVOID Context,
770   _In_ PHYSICAL_ADDRESS BusAddress,
771   _In_ ULONG Length,
772   _Out_ PULONG AddressSpace,
773   _Out_ PPHYSICAL_ADDRESS TranslatedAddress);
774 typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS;
775 
776 _Function_class_(GET_DMA_ADAPTER)
777 _IRQL_requires_same_
778 typedef struct _DMA_ADAPTER*
779 (NTAPI GET_DMA_ADAPTER)(
780   _Inout_opt_ PVOID Context,
781   _In_ struct _DEVICE_DESCRIPTION *DeviceDescriptor,
782   _Out_ PULONG NumberOfMapRegisters);
783 typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER;
784 
785 _Function_class_(GET_SET_DEVICE_DATA)
786 _IRQL_requires_same_
787 typedef ULONG
788 (NTAPI GET_SET_DEVICE_DATA)(
789   _Inout_opt_ PVOID Context,
790   _In_ ULONG DataType,
791   _Inout_updates_bytes_(Length) PVOID Buffer,
792   _In_ ULONG Offset,
793   _In_ ULONG Length);
794 typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA;
795 
796 typedef enum _DEVICE_INSTALL_STATE {
797   InstallStateInstalled,
798   InstallStateNeedsReinstall,
799   InstallStateFailedInstall,
800   InstallStateFinishInstall
801 } DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE;
802 
803 typedef struct _LEGACY_BUS_INFORMATION {
804   GUID BusTypeGuid;
805   INTERFACE_TYPE LegacyBusType;
806   ULONG BusNumber;
807 } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
808 
809 typedef enum _DEVICE_REMOVAL_POLICY {
810   RemovalPolicyExpectNoRemoval = 1,
811   RemovalPolicyExpectOrderlyRemoval = 2,
812   RemovalPolicyExpectSurpriseRemoval = 3
813 } DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY;
814 
815 typedef VOID
816 (NTAPI *PREENUMERATE_SELF)(
817   _In_ PVOID Context);
818 
819 typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD {
820   USHORT Size;
821   USHORT Version;
822   PVOID Context;
823   PINTERFACE_REFERENCE InterfaceReference;
824   PINTERFACE_DEREFERENCE InterfaceDereference;
825   PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf;
826 } REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD;
827 
828 typedef VOID
829 (NTAPI *PIO_DEVICE_EJECT_CALLBACK)(
830   _In_ NTSTATUS Status,
831   _Inout_opt_ PVOID Context);
832 
833 #define PCI_DEVICE_PRESENT_INTERFACE_VERSION     1
834 
835 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
836 #define PCI_USE_SUBSYSTEM_IDS   0x00000001
837 #define PCI_USE_REVISION        0x00000002
838 #define PCI_USE_VENDEV_IDS      0x00000004
839 #define PCI_USE_CLASS_SUBCLASS  0x00000008
840 #define PCI_USE_PROGIF          0x00000010
841 #define PCI_USE_LOCAL_BUS       0x00000020
842 #define PCI_USE_LOCAL_DEVICE    0x00000040
843 
844 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
845   ULONG Size;
846   ULONG Flags;
847   USHORT VendorID;
848   USHORT DeviceID;
849   UCHAR RevisionID;
850   USHORT SubVendorID;
851   USHORT SubSystemID;
852   UCHAR BaseClass;
853   UCHAR SubClass;
854   UCHAR ProgIf;
855 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
856 
857 _IRQL_requires_max_(PASSIVE_LEVEL)
858 _Must_inspect_result_
859 typedef BOOLEAN
860 (NTAPI PCI_IS_DEVICE_PRESENT)(
861   _In_ USHORT VendorID,
862   _In_ USHORT DeviceID,
863   _In_ UCHAR RevisionID,
864   _In_ USHORT SubVendorID,
865   _In_ USHORT SubSystemID,
866   _In_ ULONG Flags);
867 typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT;
868 
869 _IRQL_requires_max_(PASSIVE_LEVEL)
870 _Must_inspect_result_
871 typedef BOOLEAN
872 (NTAPI PCI_IS_DEVICE_PRESENT_EX)(
873   _In_ PVOID Context,
874   _In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
875 typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX;
876 
877 typedef struct _BUS_INTERFACE_STANDARD {
878   USHORT Size;
879   USHORT Version;
880   PVOID Context;
881   PINTERFACE_REFERENCE InterfaceReference;
882   PINTERFACE_DEREFERENCE InterfaceDereference;
883   PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
884   PGET_DMA_ADAPTER GetDmaAdapter;
885   PGET_SET_DEVICE_DATA SetBusData;
886   PGET_SET_DEVICE_DATA GetBusData;
887 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
888 
889 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
890   USHORT Size;
891   USHORT Version;
892   PVOID Context;
893   PINTERFACE_REFERENCE InterfaceReference;
894   PINTERFACE_DEREFERENCE InterfaceDereference;
895   PPCI_IS_DEVICE_PRESENT IsDevicePresent;
896   PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
897 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
898 
899 _Struct_size_bytes_(Size)
900 typedef struct _DEVICE_CAPABILITIES {
901   _Field_range_(==, sizeof(struct _DEVICE_CAPABILITIES)) USHORT Size;
902   USHORT Version;
903   ULONG DeviceD1:1;
904   ULONG DeviceD2:1;
905   ULONG LockSupported:1;
906   ULONG EjectSupported:1;
907   ULONG Removable:1;
908   ULONG DockDevice:1;
909   ULONG UniqueID:1;
910   ULONG SilentInstall:1;
911   ULONG RawDeviceOK:1;
912   ULONG SurpriseRemovalOK:1;
913   ULONG WakeFromD0:1;
914   ULONG WakeFromD1:1;
915   ULONG WakeFromD2:1;
916   ULONG WakeFromD3:1;
917   ULONG HardwareDisabled:1;
918   ULONG NonDynamic:1;
919   ULONG WarmEjectSupported:1;
920   ULONG NoDisplayInUI:1;
921   ULONG Reserved:14;
922   ULONG Address;
923   ULONG UINumber;
924   DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
925   SYSTEM_POWER_STATE SystemWake;
926   DEVICE_POWER_STATE DeviceWake;
927   ULONG D1Latency;
928   ULONG D2Latency;
929   ULONG D3Latency;
930 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
931 
932 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
933   USHORT Version;
934   USHORT Size;
935   GUID Event;
936   GUID InterfaceClassGuid;
937   PUNICODE_STRING SymbolicLinkName;
938 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
939 
940 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
941   USHORT Version;
942   USHORT Size;
943   GUID Event;
944 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
945 
946 #undef INTERFACE
947 
948 typedef struct _INTERFACE {
949   USHORT Size;
950   USHORT Version;
951   PVOID Context;
952   PINTERFACE_REFERENCE InterfaceReference;
953   PINTERFACE_DEREFERENCE InterfaceDereference;
954 } INTERFACE, *PINTERFACE;
955 
956 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
957   USHORT Version;
958   USHORT Size;
959   GUID Event;
960 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
961 
962 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
963 
964 /* PNP_DEVICE_STATE */
965 
966 #define PNP_DEVICE_DISABLED                      0x00000001
967 #define PNP_DEVICE_DONT_DISPLAY_IN_UI            0x00000002
968 #define PNP_DEVICE_FAILED                        0x00000004
969 #define PNP_DEVICE_REMOVED                       0x00000008
970 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
971 #define PNP_DEVICE_NOT_DISABLEABLE               0x00000020
972 
973 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
974   USHORT Version;
975   USHORT Size;
976   GUID Event;
977   struct _FILE_OBJECT *FileObject;
978   LONG NameBufferOffset;
979   UCHAR CustomDataBuffer[1];
980 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
981 
982 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
983   USHORT Version;
984   USHORT Size;
985   GUID Event;
986   struct _FILE_OBJECT *FileObject;
987 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
988 
989 #if (NTDDI_VERSION >= NTDDI_VISTA)
990 #include <devpropdef.h>
991 #define PLUGPLAY_PROPERTY_PERSISTENT   0x00000001
992 #endif
993 
994 #define PNP_REPLACE_NO_MAP             MAXLONGLONG
995 
996 _Must_inspect_result_
997 typedef NTSTATUS
998 (NTAPI *PREPLACE_MAP_MEMORY)(
999   _In_ PHYSICAL_ADDRESS TargetPhysicalAddress,
1000   _In_ PHYSICAL_ADDRESS SparePhysicalAddress,
1001   _Inout_ PLARGE_INTEGER NumberOfBytes,
1002   _Outptr_ PVOID *TargetAddress,
1003   _Outptr_ PVOID *SpareAddress);
1004 
1005 typedef struct _PNP_REPLACE_MEMORY_LIST {
1006   ULONG AllocatedCount;
1007   ULONG Count;
1008   ULONGLONG TotalLength;
1009   struct {
1010     PHYSICAL_ADDRESS Address;
1011     ULONGLONG Length;
1012   } Ranges[ANYSIZE_ARRAY];
1013 } PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST;
1014 
1015 typedef struct _PNP_REPLACE_PROCESSOR_LIST {
1016   PKAFFINITY Affinity;
1017   _Field_range_(<=, MAXIMUM_GROUPS) ULONG GroupCount;
1018   ULONG AllocatedCount;
1019   ULONG Count;
1020   ULONG ApicIds[ANYSIZE_ARRAY];
1021 } PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST;
1022 
1023 typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 {
1024   KAFFINITY AffinityMask;
1025   ULONG AllocatedCount;
1026   ULONG Count;
1027   ULONG ApicIds[ANYSIZE_ARRAY];
1028 } PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1;
1029 
1030 #define PNP_REPLACE_PARAMETERS_VERSION           2
1031 
1032 typedef struct _PNP_REPLACE_PARAMETERS {
1033   ULONG Size;
1034   ULONG Version;
1035   ULONG64 Target;
1036   ULONG64 Spare;
1037   PPNP_REPLACE_PROCESSOR_LIST TargetProcessors;
1038   PPNP_REPLACE_PROCESSOR_LIST SpareProcessors;
1039   PPNP_REPLACE_MEMORY_LIST TargetMemory;
1040   PPNP_REPLACE_MEMORY_LIST SpareMemory;
1041   PREPLACE_MAP_MEMORY MapMemory;
1042 } PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS;
1043 
1044 typedef VOID
1045 (NTAPI *PREPLACE_UNLOAD)(
1046   VOID);
1047 
1048 _Must_inspect_result_
1049 typedef NTSTATUS
1050 (NTAPI *PREPLACE_BEGIN)(
1051   _In_ PPNP_REPLACE_PARAMETERS Parameters,
1052   _Outptr_ PVOID *Context);
1053 
1054 _Must_inspect_result_
1055 typedef NTSTATUS
1056 (NTAPI *PREPLACE_END)(
1057   _In_ PVOID Context);
1058 
1059 _Must_inspect_result_
1060 typedef NTSTATUS
1061 (NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)(
1062   _In_ PVOID Context,
1063   _In_ PHYSICAL_ADDRESS PhysicalAddress,
1064   _In_ LARGE_INTEGER ByteCount);
1065 
1066 _Must_inspect_result_
1067 typedef NTSTATUS
1068 (NTAPI *PREPLACE_SET_PROCESSOR_ID)(
1069   _In_ PVOID Context,
1070   _In_ ULONG ApicId,
1071   _In_ BOOLEAN Target);
1072 
1073 _Must_inspect_result_
1074 typedef NTSTATUS
1075 (NTAPI *PREPLACE_SWAP)(
1076   _In_ PVOID Context);
1077 
1078 _Must_inspect_result_
1079 typedef NTSTATUS
1080 (NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)(
1081   _In_ PVOID Context);
1082 
1083 _Must_inspect_result_
1084 typedef NTSTATUS
1085 (NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)(
1086   _In_ PVOID Context);
1087 
1088 _Must_inspect_result_
1089 typedef NTSTATUS
1090 (NTAPI *PREPLACE_GET_MEMORY_DESTINATION)(
1091   _In_ PVOID Context,
1092   _In_ PHYSICAL_ADDRESS SourceAddress,
1093   _Out_ PPHYSICAL_ADDRESS DestinationAddress);
1094 
1095 _Must_inspect_result_
1096 typedef NTSTATUS
1097 (NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)(
1098   _In_ PVOID Context,
1099   _In_ BOOLEAN Enable);
1100 
1101 #define PNP_REPLACE_DRIVER_INTERFACE_VERSION      1
1102 #define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \
1103              FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror)
1104 
1105 #define PNP_REPLACE_MEMORY_SUPPORTED             0x0001
1106 #define PNP_REPLACE_PROCESSOR_SUPPORTED          0x0002
1107 #define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING    0x0004
1108 #define PNP_REPLACE_HARDWARE_PAGE_COPY           0x0008
1109 #define PNP_REPLACE_HARDWARE_QUIESCE             0x0010
1110 
1111 typedef struct _PNP_REPLACE_DRIVER_INTERFACE {
1112   ULONG Size;
1113   ULONG Version;
1114   ULONG Flags;
1115   PREPLACE_UNLOAD Unload;
1116   PREPLACE_BEGIN BeginReplace;
1117   PREPLACE_END EndReplace;
1118   PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory;
1119   PREPLACE_SET_PROCESSOR_ID SetProcessorId;
1120   PREPLACE_SWAP Swap;
1121   PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror;
1122   PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory;
1123   PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination;
1124   PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce;
1125 } PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE;
1126 
1127 _Must_inspect_result_
1128 typedef NTSTATUS
1129 (NTAPI *PREPLACE_DRIVER_INIT)(
1130   _Inout_ PPNP_REPLACE_DRIVER_INTERFACE Interface,
1131   _In_ PVOID Unused);
1132 
1133 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
1134   DeviceUsageTypeUndefined,
1135   DeviceUsageTypePaging,
1136   DeviceUsageTypeHibernation,
1137   DeviceUsageTypeDumpFile
1138 } DEVICE_USAGE_NOTIFICATION_TYPE;
1139 
1140 typedef struct _POWER_SEQUENCE {
1141   ULONG SequenceD1;
1142   ULONG SequenceD2;
1143   ULONG SequenceD3;
1144 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
1145 
1146 #ifdef _PREFAST_
1147 #define __string_type      0x1000
1148 #define __guid_type        0x2000
1149 #define __multiString_type 0x4000
1150 #else
1151 #define __string_type      0
1152 #define __guid_type        0
1153 #define __multiString_type 0
1154 #endif
1155 
1156 typedef enum {
1157   DevicePropertyDeviceDescription = 0x0 | __string_type,
1158   DevicePropertyHardwareID = 0x1 | __multiString_type,
1159   DevicePropertyCompatibleIDs = 0x2 | __multiString_type,
1160   DevicePropertyBootConfiguration = 0x3,
1161   DevicePropertyBootConfigurationTranslated = 0x4,
1162   DevicePropertyClassName = 0x5 | __string_type,
1163   DevicePropertyClassGuid = 0x6 | __string_type,
1164   DevicePropertyDriverKeyName = 0x7 | __string_type,
1165   DevicePropertyManufacturer = 0x8 | __string_type,
1166   DevicePropertyFriendlyName = 0x9 | __string_type,
1167   DevicePropertyLocationInformation = 0xa | __string_type,
1168   DevicePropertyPhysicalDeviceObjectName = 0xb | __string_type,
1169   DevicePropertyBusTypeGuid = 0xc | __guid_type,
1170   DevicePropertyLegacyBusType = 0xd,
1171   DevicePropertyBusNumber = 0xe,
1172   DevicePropertyEnumeratorName = 0xf | __string_type,
1173   DevicePropertyAddress = 0x10,
1174   DevicePropertyUINumber = 0x11,
1175   DevicePropertyInstallState = 0x12,
1176   DevicePropertyRemovalPolicy = 0x13,
1177   DevicePropertyResourceRequirements = 0x14,
1178   DevicePropertyAllocatedResources = 0x15,
1179   DevicePropertyContainerID = 0x16 | __string_type
1180 } DEVICE_REGISTRY_PROPERTY;
1181 
1182 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
1183   EventCategoryReserved,
1184   EventCategoryHardwareProfileChange,
1185   EventCategoryDeviceInterfaceChange,
1186   EventCategoryTargetDeviceChange
1187 } IO_NOTIFICATION_EVENT_CATEGORY;
1188 
1189 typedef enum _IO_PRIORITY_HINT {
1190   IoPriorityVeryLow = 0,
1191   IoPriorityLow,
1192   IoPriorityNormal,
1193   IoPriorityHigh,
1194   IoPriorityCritical,
1195   MaxIoPriorityTypes
1196 } IO_PRIORITY_HINT;
1197 
1198 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES    0x00000001
1199 
1200 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1201 _IRQL_requires_max_(PASSIVE_LEVEL)
1202 typedef NTSTATUS
1203 (NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
1204   _In_ PVOID NotificationStructure,
1205   _Inout_opt_ PVOID Context);
1206 typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE;
1207 
1208 _Function_class_(DEVICE_CHANGE_COMPLETE_CALLBACK)
1209 _IRQL_requires_same_
1210 typedef VOID
1211 (NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)(
1212   _Inout_opt_ PVOID Context);
1213 typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK;
1214 
1215 typedef enum _FILE_INFORMATION_CLASS {
1216   FileDirectoryInformation = 1,
1217   FileFullDirectoryInformation,
1218   FileBothDirectoryInformation,
1219   FileBasicInformation,
1220   FileStandardInformation,
1221   FileInternalInformation,
1222   FileEaInformation,
1223   FileAccessInformation,
1224   FileNameInformation,
1225   FileRenameInformation,
1226   FileLinkInformation,
1227   FileNamesInformation,
1228   FileDispositionInformation,
1229   FilePositionInformation,
1230   FileFullEaInformation,
1231   FileModeInformation,
1232   FileAlignmentInformation,
1233   FileAllInformation,
1234   FileAllocationInformation,
1235   FileEndOfFileInformation,
1236   FileAlternateNameInformation,
1237   FileStreamInformation,
1238   FilePipeInformation,
1239   FilePipeLocalInformation,
1240   FilePipeRemoteInformation,
1241   FileMailslotQueryInformation,
1242   FileMailslotSetInformation,
1243   FileCompressionInformation,
1244   FileObjectIdInformation,
1245   FileCompletionInformation,
1246   FileMoveClusterInformation,
1247   FileQuotaInformation,
1248   FileReparsePointInformation,
1249   FileNetworkOpenInformation,
1250   FileAttributeTagInformation,
1251   FileTrackingInformation,
1252   FileIdBothDirectoryInformation,
1253   FileIdFullDirectoryInformation,
1254   FileValidDataLengthInformation,
1255   FileShortNameInformation,
1256 #if (NTDDI_VERSION >= NTDDI_VISTA)
1257   FileIoCompletionNotificationInformation,
1258   FileIoStatusBlockRangeInformation,
1259   FileIoPriorityHintInformation,
1260   FileSfioReserveInformation,
1261   FileSfioVolumeInformation,
1262   FileHardLinkInformation,
1263   FileProcessIdsUsingFileInformation,
1264   FileNormalizedNameInformation,
1265   FileNetworkPhysicalNameInformation,
1266 #endif
1267 #if (NTDDI_VERSION >= NTDDI_WIN7)
1268   FileIdGlobalTxDirectoryInformation,
1269   FileIsRemoteDeviceInformation,
1270   FileAttributeCacheInformation,
1271   FileNumaNodeInformation,
1272   FileStandardLinkInformation,
1273   FileRemoteProtocolInformation,
1274 #endif
1275   FileMaximumInformation
1276 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
1277 
1278 typedef enum _DIRECTORY_NOTIFY_INFORMATION_CLASS {
1279   DirectoryNotifyInformation = 1,
1280   DirectoryNotifyExtendedInformation
1281 } DIRECTORY_NOTIFY_INFORMATION_CLASS, *PDIRECTORY_NOTIFY_INFORMATION_CLASS;
1282 
1283 typedef struct _FILE_POSITION_INFORMATION {
1284   LARGE_INTEGER CurrentByteOffset;
1285 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
1286 
1287 typedef struct _FILE_BASIC_INFORMATION {
1288   LARGE_INTEGER CreationTime;
1289   LARGE_INTEGER LastAccessTime;
1290   LARGE_INTEGER LastWriteTime;
1291   LARGE_INTEGER ChangeTime;
1292   ULONG FileAttributes;
1293 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
1294 
1295 typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION {
1296   IO_PRIORITY_HINT PriorityHint;
1297 } FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION;
1298 
1299 typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION {
1300   ULONG Flags;
1301 } FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
1302 
1303 typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION {
1304   PUCHAR IoStatusBlockRange;
1305   ULONG Length;
1306 } FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION;
1307 
1308 typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION {
1309   BOOLEAN IsRemote;
1310 } FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION;
1311 
1312 typedef struct _FILE_NUMA_NODE_INFORMATION {
1313   USHORT NodeNumber;
1314 } FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION;
1315 
1316 typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION {
1317   ULONG NumberOfProcessIdsInList;
1318   ULONG_PTR ProcessIdList[1];
1319 } FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION;
1320 
1321 typedef struct _FILE_STANDARD_INFORMATION {
1322   LARGE_INTEGER AllocationSize;
1323   LARGE_INTEGER EndOfFile;
1324   ULONG NumberOfLinks;
1325   BOOLEAN DeletePending;
1326   BOOLEAN Directory;
1327 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
1328 
1329 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
1330   LARGE_INTEGER CreationTime;
1331   LARGE_INTEGER LastAccessTime;
1332   LARGE_INTEGER LastWriteTime;
1333   LARGE_INTEGER ChangeTime;
1334   LARGE_INTEGER AllocationSize;
1335   LARGE_INTEGER EndOfFile;
1336   ULONG FileAttributes;
1337 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
1338 
1339 typedef enum _FSINFOCLASS {
1340   FileFsVolumeInformation = 1,
1341   FileFsLabelInformation,
1342   FileFsSizeInformation,
1343   FileFsDeviceInformation,
1344   FileFsAttributeInformation,
1345   FileFsControlInformation,
1346   FileFsFullSizeInformation,
1347   FileFsObjectIdInformation,
1348   FileFsDriverPathInformation,
1349   FileFsVolumeFlagsInformation,
1350   FileFsMaximumInformation
1351 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
1352 
1353 typedef struct _FILE_FS_DEVICE_INFORMATION {
1354   DEVICE_TYPE DeviceType;
1355   ULONG Characteristics;
1356 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
1357 
1358 typedef struct _FILE_FULL_EA_INFORMATION {
1359   ULONG NextEntryOffset;
1360   UCHAR Flags;
1361   UCHAR EaNameLength;
1362   USHORT EaValueLength;
1363   CHAR EaName[1];
1364 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
1365 
1366 typedef struct _FILE_SFIO_RESERVE_INFORMATION {
1367   ULONG RequestsPerPeriod;
1368   ULONG Period;
1369   BOOLEAN RetryFailures;
1370   BOOLEAN Discardable;
1371   ULONG RequestSize;
1372   ULONG NumOutstandingRequests;
1373 } FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION;
1374 
1375 typedef struct _FILE_SFIO_VOLUME_INFORMATION {
1376   ULONG MaximumRequestsPerPeriod;
1377   ULONG MinimumPeriod;
1378   ULONG MinimumTransferSize;
1379 } FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION;
1380 
1381 #define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS     0x1
1382 #define FILE_SKIP_SET_EVENT_ON_HANDLE            0x2
1383 #define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO      0x4
1384 
1385 #define FM_LOCK_BIT             (0x1)
1386 #define FM_LOCK_BIT_V           (0x0)
1387 #define FM_LOCK_WAITER_WOKEN    (0x2)
1388 #define FM_LOCK_WAITER_INC      (0x4)
1389 
1390 _Function_class_(FAST_IO_CHECK_IF_POSSIBLE)
1391 _IRQL_requires_same_
1392 typedef BOOLEAN
1393 (NTAPI FAST_IO_CHECK_IF_POSSIBLE)(
1394   _In_ struct _FILE_OBJECT *FileObject,
1395   _In_ PLARGE_INTEGER FileOffset,
1396   _In_ ULONG Length,
1397   _In_ BOOLEAN Wait,
1398   _In_ ULONG LockKey,
1399   _In_ BOOLEAN CheckForReadOperation,
1400   _Out_ PIO_STATUS_BLOCK IoStatus,
1401   _In_ struct _DEVICE_OBJECT *DeviceObject);
1402 typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE;
1403 
1404 _Function_class_(FAST_IO_READ)
1405 _IRQL_requires_same_
1406 typedef BOOLEAN
1407 (NTAPI FAST_IO_READ)(
1408   _In_ struct _FILE_OBJECT *FileObject,
1409   _In_ PLARGE_INTEGER FileOffset,
1410   _In_ ULONG Length,
1411   _In_ BOOLEAN Wait,
1412   _In_ ULONG LockKey,
1413   _Out_ PVOID Buffer,
1414   _Out_ PIO_STATUS_BLOCK IoStatus,
1415   _In_ struct _DEVICE_OBJECT *DeviceObject);
1416 typedef FAST_IO_READ *PFAST_IO_READ;
1417 
1418 _Function_class_(FAST_IO_WRITE)
1419 _IRQL_requires_same_
1420 typedef BOOLEAN
1421 (NTAPI FAST_IO_WRITE)(
1422   _In_ struct _FILE_OBJECT *FileObject,
1423   _In_ PLARGE_INTEGER FileOffset,
1424   _In_ ULONG Length,
1425   _In_ BOOLEAN Wait,
1426   _In_ ULONG LockKey,
1427   _In_ PVOID Buffer,
1428   _Out_ PIO_STATUS_BLOCK IoStatus,
1429   _In_ struct _DEVICE_OBJECT *DeviceObject);
1430 typedef FAST_IO_WRITE *PFAST_IO_WRITE;
1431 
1432 _Function_class_(FAST_IO_QUERY_BASIC_INFO)
1433 _IRQL_requires_same_
1434 typedef BOOLEAN
1435 (NTAPI FAST_IO_QUERY_BASIC_INFO)(
1436   _In_ struct _FILE_OBJECT *FileObject,
1437   _In_ BOOLEAN Wait,
1438   _Out_ PFILE_BASIC_INFORMATION Buffer,
1439   _Out_ PIO_STATUS_BLOCK IoStatus,
1440   _In_ struct _DEVICE_OBJECT *DeviceObject);
1441 typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO;
1442 
1443 _Function_class_(FAST_IO_QUERY_STANDARD_INFO)
1444 _IRQL_requires_same_
1445 typedef BOOLEAN
1446 (NTAPI FAST_IO_QUERY_STANDARD_INFO)(
1447   _In_ struct _FILE_OBJECT *FileObject,
1448   _In_ BOOLEAN Wait,
1449   _Out_ PFILE_STANDARD_INFORMATION Buffer,
1450   _Out_ PIO_STATUS_BLOCK IoStatus,
1451   _In_ struct _DEVICE_OBJECT *DeviceObject);
1452 typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO;
1453 
1454 _Function_class_(FAST_IO_LOCK)
1455 _IRQL_requires_same_
1456 typedef BOOLEAN
1457 (NTAPI FAST_IO_LOCK)(
1458   _In_ struct _FILE_OBJECT *FileObject,
1459   _In_ PLARGE_INTEGER FileOffset,
1460   _In_ PLARGE_INTEGER Length,
1461   _In_ PEPROCESS ProcessId,
1462   _In_ ULONG Key,
1463   _In_ BOOLEAN FailImmediately,
1464   _In_ BOOLEAN ExclusiveLock,
1465   _Out_ PIO_STATUS_BLOCK IoStatus,
1466   _In_ struct _DEVICE_OBJECT *DeviceObject);
1467 typedef FAST_IO_LOCK *PFAST_IO_LOCK;
1468 
1469 _Function_class_(FAST_IO_UNLOCK_SINGLE)
1470 _IRQL_requires_same_
1471 typedef BOOLEAN
1472 (NTAPI FAST_IO_UNLOCK_SINGLE)(
1473   _In_ struct _FILE_OBJECT *FileObject,
1474   _In_ PLARGE_INTEGER FileOffset,
1475   _In_ PLARGE_INTEGER Length,
1476   _In_ PEPROCESS ProcessId,
1477   _In_ ULONG Key,
1478   _Out_ PIO_STATUS_BLOCK IoStatus,
1479   _In_ struct _DEVICE_OBJECT *DeviceObject);
1480 typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE;
1481 
1482 _Function_class_(FAST_IO_UNLOCK_ALL)
1483 _IRQL_requires_same_
1484 typedef BOOLEAN
1485 (NTAPI FAST_IO_UNLOCK_ALL)(
1486   _In_ struct _FILE_OBJECT *FileObject,
1487   _In_ PEPROCESS ProcessId,
1488   _Out_ PIO_STATUS_BLOCK IoStatus,
1489   _In_ struct _DEVICE_OBJECT *DeviceObject);
1490 typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL;
1491 
1492 _Function_class_(FAST_IO_UNLOCK_ALL_BY_KEY)
1493 _IRQL_requires_same_
1494 typedef BOOLEAN
1495 (NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)(
1496   _In_ struct _FILE_OBJECT *FileObject,
1497   _In_ PVOID ProcessId,
1498   _In_ ULONG Key,
1499   _Out_ PIO_STATUS_BLOCK IoStatus,
1500   _In_ struct _DEVICE_OBJECT *DeviceObject);
1501 typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY;
1502 
1503 _Function_class_(FAST_IO_DEVICE_CONTROL)
1504 _IRQL_requires_same_
1505 typedef BOOLEAN
1506 (NTAPI FAST_IO_DEVICE_CONTROL)(
1507   _In_ struct _FILE_OBJECT *FileObject,
1508   _In_ BOOLEAN Wait,
1509   _In_opt_ PVOID InputBuffer,
1510   _In_ ULONG InputBufferLength,
1511   _Out_opt_ PVOID OutputBuffer,
1512   _In_ ULONG OutputBufferLength,
1513   _In_ ULONG IoControlCode,
1514   _Out_ PIO_STATUS_BLOCK IoStatus,
1515   _In_ struct _DEVICE_OBJECT *DeviceObject);
1516 typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL;
1517 
1518 _Function_class_(FAST_IO_ACQUIRE_FILE)
1519 _IRQL_requires_same_
1520 typedef VOID
1521 (NTAPI FAST_IO_ACQUIRE_FILE)(
1522   _In_ struct _FILE_OBJECT *FileObject);
1523 typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE;
1524 
1525 _Function_class_(FAST_IO_RELEASE_FILE)
1526 _IRQL_requires_same_
1527 typedef VOID
1528 (NTAPI FAST_IO_RELEASE_FILE)(
1529   _In_ struct _FILE_OBJECT *FileObject);
1530 typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE;
1531 
1532 _Function_class_(FAST_IO_DETACH_DEVICE)
1533 _IRQL_requires_same_
1534 typedef VOID
1535 (NTAPI FAST_IO_DETACH_DEVICE)(
1536   _In_ struct _DEVICE_OBJECT *SourceDevice,
1537   _In_ struct _DEVICE_OBJECT *TargetDevice);
1538 typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE;
1539 
1540 _Function_class_(FAST_IO_QUERY_NETWORK_OPEN_INFO)
1541 _IRQL_requires_same_
1542 typedef BOOLEAN
1543 (NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)(
1544   _In_ struct _FILE_OBJECT *FileObject,
1545   _In_ BOOLEAN Wait,
1546   _Out_ struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
1547   _Out_ struct _IO_STATUS_BLOCK *IoStatus,
1548   _In_ struct _DEVICE_OBJECT *DeviceObject);
1549 typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO;
1550 
1551 _Function_class_(FAST_IO_ACQUIRE_FOR_MOD_WRITE)
1552 _IRQL_requires_same_
1553 typedef NTSTATUS
1554 (NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)(
1555   _In_ struct _FILE_OBJECT *FileObject,
1556   _In_ PLARGE_INTEGER EndingOffset,
1557   _Out_ struct _ERESOURCE **ResourceToRelease,
1558   _In_ struct _DEVICE_OBJECT *DeviceObject);
1559 typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE;
1560 
1561 _Function_class_(FAST_IO_MDL_READ)
1562 _IRQL_requires_same_
1563 typedef BOOLEAN
1564 (NTAPI FAST_IO_MDL_READ)(
1565   _In_ struct _FILE_OBJECT *FileObject,
1566   _In_ PLARGE_INTEGER FileOffset,
1567   _In_ ULONG Length,
1568   _In_ ULONG LockKey,
1569   _Out_ PMDL *MdlChain,
1570   _Out_ PIO_STATUS_BLOCK IoStatus,
1571   _In_ struct _DEVICE_OBJECT *DeviceObject);
1572 typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ;
1573 
1574 _Function_class_(FAST_IO_MDL_READ_COMPLETE)
1575 _IRQL_requires_same_
1576 typedef BOOLEAN
1577 (NTAPI FAST_IO_MDL_READ_COMPLETE)(
1578   _In_ struct _FILE_OBJECT *FileObject,
1579   _In_ PMDL MdlChain,
1580   _In_ struct _DEVICE_OBJECT *DeviceObject);
1581 typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE;
1582 
1583 _Function_class_(FAST_IO_PREPARE_MDL_WRITE)
1584 _IRQL_requires_same_
1585 typedef BOOLEAN
1586 (NTAPI FAST_IO_PREPARE_MDL_WRITE)(
1587   _In_ struct _FILE_OBJECT *FileObject,
1588   _In_ PLARGE_INTEGER FileOffset,
1589   _In_ ULONG Length,
1590   _In_ ULONG LockKey,
1591   _Out_ PMDL *MdlChain,
1592   _Out_ PIO_STATUS_BLOCK IoStatus,
1593   _In_ struct _DEVICE_OBJECT *DeviceObject);
1594 typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE;
1595 
1596 _Function_class_(FAST_IO_MDL_WRITE_COMPLETE)
1597 _IRQL_requires_same_
1598 typedef BOOLEAN
1599 (NTAPI FAST_IO_MDL_WRITE_COMPLETE)(
1600   _In_ struct _FILE_OBJECT *FileObject,
1601   _In_ PLARGE_INTEGER FileOffset,
1602   _In_ PMDL MdlChain,
1603   _In_ struct _DEVICE_OBJECT *DeviceObject);
1604 typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE;
1605 
1606 _Function_class_(FAST_IO_READ_COMPRESSED)
1607 _IRQL_requires_same_
1608 typedef BOOLEAN
1609 (NTAPI FAST_IO_READ_COMPRESSED)(
1610   _In_ struct _FILE_OBJECT *FileObject,
1611   _In_ PLARGE_INTEGER FileOffset,
1612   _In_ ULONG Length,
1613   _In_ ULONG LockKey,
1614   _Out_ PVOID Buffer,
1615   _Out_ PMDL *MdlChain,
1616   _Out_ PIO_STATUS_BLOCK IoStatus,
1617   _Out_ struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1618   _In_ ULONG CompressedDataInfoLength,
1619   _In_ struct _DEVICE_OBJECT *DeviceObject);
1620 typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED;
1621 
1622 _Function_class_(FAST_IO_WRITE_COMPRESSED)
1623 _IRQL_requires_same_
1624 typedef BOOLEAN
1625 (NTAPI FAST_IO_WRITE_COMPRESSED)(
1626   _In_ struct _FILE_OBJECT *FileObject,
1627   _In_ PLARGE_INTEGER FileOffset,
1628   _In_ ULONG Length,
1629   _In_ ULONG LockKey,
1630   _In_ PVOID Buffer,
1631   _Out_ PMDL *MdlChain,
1632   _Out_ PIO_STATUS_BLOCK IoStatus,
1633   _In_ struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1634   _In_ ULONG CompressedDataInfoLength,
1635   _In_ struct _DEVICE_OBJECT *DeviceObject);
1636 typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED;
1637 
1638 _Function_class_(FAST_IO_MDL_READ_COMPLETE_COMPRESSED)
1639 _IRQL_requires_same_
1640 typedef BOOLEAN
1641 (NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
1642   _In_ struct _FILE_OBJECT *FileObject,
1643   _In_ PMDL MdlChain,
1644   _In_ struct _DEVICE_OBJECT *DeviceObject);
1645 typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED;
1646 
1647 _Function_class_(FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)
1648 _IRQL_requires_same_
1649 typedef BOOLEAN
1650 (NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
1651   _In_ struct _FILE_OBJECT *FileObject,
1652   _In_ PLARGE_INTEGER FileOffset,
1653   _In_ PMDL MdlChain,
1654   _In_ struct _DEVICE_OBJECT *DeviceObject);
1655 typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED;
1656 
1657 _Function_class_(FAST_IO_QUERY_OPEN)
1658 _IRQL_requires_same_
1659 typedef BOOLEAN
1660 (NTAPI FAST_IO_QUERY_OPEN)(
1661   _Inout_ struct _IRP *Irp,
1662   _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
1663   _In_ struct _DEVICE_OBJECT *DeviceObject);
1664 typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN;
1665 
1666 _Function_class_(FAST_IO_RELEASE_FOR_MOD_WRITE)
1667 _IRQL_requires_same_
1668 typedef NTSTATUS
1669 (NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)(
1670   _In_ struct _FILE_OBJECT *FileObject,
1671   _In_ struct _ERESOURCE *ResourceToRelease,
1672   _In_ struct _DEVICE_OBJECT *DeviceObject);
1673 typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE;
1674 
1675 _Function_class_(FAST_IO_ACQUIRE_FOR_CCFLUSH)
1676 _IRQL_requires_same_
1677 typedef NTSTATUS
1678 (NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)(
1679   _In_ struct _FILE_OBJECT *FileObject,
1680   _In_ struct _DEVICE_OBJECT *DeviceObject);
1681 typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH;
1682 
1683 _Function_class_(FAST_IO_RELEASE_FOR_CCFLUSH)
1684 _IRQL_requires_same_
1685 typedef NTSTATUS
1686 (NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)(
1687   _In_ struct _FILE_OBJECT *FileObject,
1688   _In_ struct _DEVICE_OBJECT *DeviceObject);
1689 typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH;
1690 
1691 typedef struct _FAST_IO_DISPATCH {
1692   ULONG SizeOfFastIoDispatch;
1693   PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
1694   PFAST_IO_READ FastIoRead;
1695   PFAST_IO_WRITE FastIoWrite;
1696   PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
1697   PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
1698   PFAST_IO_LOCK FastIoLock;
1699   PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
1700   PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
1701   PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
1702   PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
1703   PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
1704   PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
1705   PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
1706   PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
1707   PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
1708   PFAST_IO_MDL_READ MdlRead;
1709   PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
1710   PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
1711   PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
1712   PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
1713   PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
1714   PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
1715   PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
1716   PFAST_IO_QUERY_OPEN FastIoQueryOpen;
1717   PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
1718   PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
1719   PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
1720 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
1721 
1722 typedef struct _SECTION_OBJECT_POINTERS {
1723   PVOID DataSectionObject;
1724   PVOID SharedCacheMap;
1725   PVOID ImageSectionObject;
1726 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
1727 
1728 typedef struct _IO_COMPLETION_CONTEXT {
1729   PVOID Port;
1730   PVOID Key;
1731 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
1732 
1733 /* FILE_OBJECT.Flags */
1734 #define FO_FILE_OPEN                 0x00000001
1735 #define FO_SYNCHRONOUS_IO            0x00000002
1736 #define FO_ALERTABLE_IO              0x00000004
1737 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
1738 #define FO_WRITE_THROUGH             0x00000010
1739 #define FO_SEQUENTIAL_ONLY           0x00000020
1740 #define FO_CACHE_SUPPORTED           0x00000040
1741 #define FO_NAMED_PIPE                0x00000080
1742 #define FO_STREAM_FILE               0x00000100
1743 #define FO_MAILSLOT                  0x00000200
1744 #define FO_GENERATE_AUDIT_ON_CLOSE   0x00000400
1745 #define FO_QUEUE_IRP_TO_THREAD       0x00000400
1746 #define FO_DIRECT_DEVICE_OPEN        0x00000800
1747 #define FO_FILE_MODIFIED             0x00001000
1748 #define FO_FILE_SIZE_CHANGED         0x00002000
1749 #define FO_CLEANUP_COMPLETE          0x00004000
1750 #define FO_TEMPORARY_FILE            0x00008000
1751 #define FO_DELETE_ON_CLOSE           0x00010000
1752 #define FO_OPENED_CASE_SENSITIVE     0x00020000
1753 #define FO_HANDLE_CREATED            0x00040000
1754 #define FO_FILE_FAST_IO_READ         0x00080000
1755 #define FO_RANDOM_ACCESS             0x00100000
1756 #define FO_FILE_OPEN_CANCELLED       0x00200000
1757 #define FO_VOLUME_OPEN               0x00400000
1758 #define FO_REMOTE_ORIGIN             0x01000000
1759 #define FO_DISALLOW_EXCLUSIVE        0x02000000
1760 #define FO_SKIP_COMPLETION_PORT      0x02000000
1761 #define FO_SKIP_SET_EVENT            0x04000000
1762 #define FO_SKIP_SET_FAST_IO          0x08000000
1763 #define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE
1764 
1765 /* VPB.Flags */
1766 #define VPB_MOUNTED                       0x0001
1767 #define VPB_LOCKED                        0x0002
1768 #define VPB_PERSISTENT                    0x0004
1769 #define VPB_REMOVE_PENDING                0x0008
1770 #define VPB_RAW_MOUNT                     0x0010
1771 #define VPB_DIRECT_WRITES_ALLOWED         0x0020
1772 
1773 /* IO_STACK_LOCATION.Flags */
1774 
1775 #define SL_FORCE_ACCESS_CHECK             0x01
1776 #define SL_OPEN_PAGING_FILE               0x02
1777 #define SL_OPEN_TARGET_DIRECTORY          0x04
1778 #define SL_STOP_ON_SYMLINK                0x08
1779 #define SL_CASE_SENSITIVE                 0x80
1780 
1781 #define SL_KEY_SPECIFIED                  0x01
1782 #define SL_OVERRIDE_VERIFY_VOLUME         0x02
1783 #define SL_WRITE_THROUGH                  0x04
1784 #define SL_FT_SEQUENTIAL_WRITE            0x08
1785 #define SL_FORCE_DIRECT_WRITE             0x10
1786 #define SL_REALTIME_STREAM                0x20
1787 
1788 #define SL_READ_ACCESS_GRANTED            0x01
1789 #define SL_WRITE_ACCESS_GRANTED           0x04
1790 
1791 #define SL_FAIL_IMMEDIATELY               0x01
1792 #define SL_EXCLUSIVE_LOCK                 0x02
1793 
1794 #define SL_RESTART_SCAN                   0x01
1795 #define SL_RETURN_SINGLE_ENTRY            0x02
1796 #define SL_INDEX_SPECIFIED                0x04
1797 
1798 #define SL_WATCH_TREE                     0x01
1799 
1800 #define SL_ALLOW_RAW_MOUNT                0x01
1801 
1802 $endif (_WDMDDK_)
1803 $if (_WDMDDK_ || _DEVIOCTL_)
1804 #define CTL_CODE(DeviceType, Function, Method, Access) \
1805   (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1806 
1807 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
1808 
1809 #define METHOD_FROM_CTL_CODE(ctrlCode)          ((ULONG)(ctrlCode & 3))
1810 
1811 $endif (_WDMDDK_ || _DEVIOCTL_)
1812 $if (_WDMDDK_)
1813 
1814 /* IRP.Flags */
1815 #define IRP_NOCACHE                     0x00000001
1816 #define IRP_PAGING_IO                   0x00000002
1817 #define IRP_MOUNT_COMPLETION            0x00000002
1818 #define IRP_SYNCHRONOUS_API             0x00000004
1819 #define IRP_ASSOCIATED_IRP              0x00000008
1820 #define IRP_BUFFERED_IO                 0x00000010
1821 #define IRP_DEALLOCATE_BUFFER           0x00000020
1822 #define IRP_INPUT_OPERATION             0x00000040
1823 #define IRP_SYNCHRONOUS_PAGING_IO       0x00000040
1824 #define IRP_CREATE_OPERATION            0x00000080
1825 #define IRP_READ_OPERATION              0x00000100
1826 #define IRP_WRITE_OPERATION             0x00000200
1827 #define IRP_CLOSE_OPERATION             0x00000400
1828 #define IRP_DEFER_IO_COMPLETION         0x00000800
1829 #define IRP_OB_QUERY_NAME               0x00001000
1830 #define IRP_HOLD_DEVICE_QUEUE           0x00002000
1831 /* The following 2 are missing in latest WDK */
1832 #define IRP_RETRY_IO_COMPLETION         0x00004000
1833 #define IRP_CLASS_CACHE_OPERATION       0x00008000
1834 
1835 /* IRP.AllocationFlags */
1836 #define IRP_QUOTA_CHARGED                 0x01
1837 #define IRP_ALLOCATED_MUST_SUCCEED        0x02
1838 #define IRP_ALLOCATED_FIXED_SIZE          0x04
1839 #define IRP_LOOKASIDE_ALLOCATION          0x08
1840 
1841 /*
1842 ** IRP function codes
1843 */
1844 
1845 #define IRP_MJ_CREATE                     0x00
1846 #define IRP_MJ_CREATE_NAMED_PIPE          0x01
1847 #define IRP_MJ_CLOSE                      0x02
1848 #define IRP_MJ_READ                       0x03
1849 #define IRP_MJ_WRITE                      0x04
1850 #define IRP_MJ_QUERY_INFORMATION          0x05
1851 #define IRP_MJ_SET_INFORMATION            0x06
1852 #define IRP_MJ_QUERY_EA                   0x07
1853 #define IRP_MJ_SET_EA                     0x08
1854 #define IRP_MJ_FLUSH_BUFFERS              0x09
1855 #define IRP_MJ_QUERY_VOLUME_INFORMATION   0x0a
1856 #define IRP_MJ_SET_VOLUME_INFORMATION     0x0b
1857 #define IRP_MJ_DIRECTORY_CONTROL          0x0c
1858 #define IRP_MJ_FILE_SYSTEM_CONTROL        0x0d
1859 #define IRP_MJ_DEVICE_CONTROL             0x0e
1860 #define IRP_MJ_INTERNAL_DEVICE_CONTROL    0x0f
1861 #define IRP_MJ_SCSI                       0x0f
1862 #define IRP_MJ_SHUTDOWN                   0x10
1863 #define IRP_MJ_LOCK_CONTROL               0x11
1864 #define IRP_MJ_CLEANUP                    0x12
1865 #define IRP_MJ_CREATE_MAILSLOT            0x13
1866 #define IRP_MJ_QUERY_SECURITY             0x14
1867 #define IRP_MJ_SET_SECURITY               0x15
1868 #define IRP_MJ_POWER                      0x16
1869 #define IRP_MJ_SYSTEM_CONTROL             0x17
1870 #define IRP_MJ_DEVICE_CHANGE              0x18
1871 #define IRP_MJ_QUERY_QUOTA                0x19
1872 #define IRP_MJ_SET_QUOTA                  0x1a
1873 #define IRP_MJ_PNP                        0x1b
1874 #define IRP_MJ_PNP_POWER                  0x1b
1875 #define IRP_MJ_MAXIMUM_FUNCTION           0x1b
1876 
1877 #define IRP_MN_SCSI_CLASS                 0x01
1878 
1879 #define IRP_MN_START_DEVICE               0x00
1880 #define IRP_MN_QUERY_REMOVE_DEVICE        0x01
1881 #define IRP_MN_REMOVE_DEVICE              0x02
1882 #define IRP_MN_CANCEL_REMOVE_DEVICE       0x03
1883 #define IRP_MN_STOP_DEVICE                0x04
1884 #define IRP_MN_QUERY_STOP_DEVICE          0x05
1885 #define IRP_MN_CANCEL_STOP_DEVICE         0x06
1886 
1887 #define IRP_MN_QUERY_DEVICE_RELATIONS       0x07
1888 #define IRP_MN_QUERY_INTERFACE              0x08
1889 #define IRP_MN_QUERY_CAPABILITIES           0x09
1890 #define IRP_MN_QUERY_RESOURCES              0x0A
1891 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS  0x0B
1892 #define IRP_MN_QUERY_DEVICE_TEXT            0x0C
1893 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
1894 
1895 #define IRP_MN_READ_CONFIG                  0x0F
1896 #define IRP_MN_WRITE_CONFIG                 0x10
1897 #define IRP_MN_EJECT                        0x11
1898 #define IRP_MN_SET_LOCK                     0x12
1899 #define IRP_MN_QUERY_ID                     0x13
1900 #define IRP_MN_QUERY_PNP_DEVICE_STATE       0x14
1901 #define IRP_MN_QUERY_BUS_INFORMATION        0x15
1902 #define IRP_MN_DEVICE_USAGE_NOTIFICATION    0x16
1903 #define IRP_MN_SURPRISE_REMOVAL             0x17
1904 #if (NTDDI_VERSION >= NTDDI_WIN7)
1905 #define IRP_MN_DEVICE_ENUMERATED            0x19
1906 #endif
1907 
1908 #define IRP_MN_WAIT_WAKE                  0x00
1909 #define IRP_MN_POWER_SEQUENCE             0x01
1910 #define IRP_MN_SET_POWER                  0x02
1911 #define IRP_MN_QUERY_POWER                0x03
1912 
1913 #define IRP_MN_QUERY_ALL_DATA             0x00
1914 #define IRP_MN_QUERY_SINGLE_INSTANCE      0x01
1915 #define IRP_MN_CHANGE_SINGLE_INSTANCE     0x02
1916 #define IRP_MN_CHANGE_SINGLE_ITEM         0x03
1917 #define IRP_MN_ENABLE_EVENTS              0x04
1918 #define IRP_MN_DISABLE_EVENTS             0x05
1919 #define IRP_MN_ENABLE_COLLECTION          0x06
1920 #define IRP_MN_DISABLE_COLLECTION         0x07
1921 #define IRP_MN_REGINFO                    0x08
1922 #define IRP_MN_EXECUTE_METHOD             0x09
1923 
1924 #define IRP_MN_REGINFO_EX                 0x0b
1925 
1926 typedef struct _FILE_OBJECT {
1927   CSHORT Type;
1928   CSHORT Size;
1929   PDEVICE_OBJECT DeviceObject;
1930   PVPB Vpb;
1931   PVOID FsContext;
1932   PVOID FsContext2;
1933   PSECTION_OBJECT_POINTERS SectionObjectPointer;
1934   PVOID PrivateCacheMap;
1935   NTSTATUS FinalStatus;
1936   struct _FILE_OBJECT *RelatedFileObject;
1937   BOOLEAN LockOperation;
1938   BOOLEAN DeletePending;
1939   BOOLEAN ReadAccess;
1940   BOOLEAN WriteAccess;
1941   BOOLEAN DeleteAccess;
1942   BOOLEAN SharedRead;
1943   BOOLEAN SharedWrite;
1944   BOOLEAN SharedDelete;
1945   ULONG Flags;
1946   UNICODE_STRING FileName;
1947   LARGE_INTEGER CurrentByteOffset;
1948   volatile ULONG Waiters;
1949   volatile ULONG Busy;
1950   PVOID LastLock;
1951   KEVENT Lock;
1952   KEVENT Event;
1953   volatile PIO_COMPLETION_CONTEXT CompletionContext;
1954   KSPIN_LOCK IrpListLock;
1955   LIST_ENTRY IrpList;
1956   volatile PVOID FileObjectExtension;
1957 } FILE_OBJECT, *PFILE_OBJECT;
1958 
1959 typedef struct _IO_ERROR_LOG_PACKET {
1960   UCHAR MajorFunctionCode;
1961   UCHAR RetryCount;
1962   USHORT DumpDataSize;
1963   USHORT NumberOfStrings;
1964   USHORT StringOffset;
1965   USHORT EventCategory;
1966   NTSTATUS ErrorCode;
1967   ULONG UniqueErrorValue;
1968   NTSTATUS FinalStatus;
1969   ULONG SequenceNumber;
1970   ULONG IoControlCode;
1971   LARGE_INTEGER DeviceOffset;
1972   ULONG DumpData[1];
1973 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
1974 
1975 typedef struct _IO_ERROR_LOG_MESSAGE {
1976   USHORT Type;
1977   USHORT Size;
1978   USHORT DriverNameLength;
1979   LARGE_INTEGER TimeStamp;
1980   ULONG DriverNameOffset;
1981   IO_ERROR_LOG_PACKET EntryData;
1982 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
1983 
1984 /* See ndk/lpctypes.h */
1985 #ifdef _WIN64
1986 #define PORT_MAXIMUM_MESSAGE_LENGTH 512
1987 #else
1988 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
1989 #endif
1990 
1991 #define ERROR_LOG_LIMIT_SIZE               240
1992 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
1993                                             sizeof(IO_ERROR_LOG_PACKET) + \
1994                                             (sizeof(WCHAR) * 40))
1995 #define ERROR_LOG_MESSAGE_LIMIT_SIZE                                          \
1996     (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1997 #define IO_ERROR_LOG_MESSAGE_LENGTH                                           \
1998     ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ?           \
1999         ERROR_LOG_MESSAGE_LIMIT_SIZE :                                        \
2000         PORT_MAXIMUM_MESSAGE_LENGTH)
2001 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH -                 \
2002                                 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
2003 
2004 typedef enum _DMA_WIDTH {
2005   Width8Bits,
2006   Width16Bits,
2007   Width32Bits,
2008   MaximumDmaWidth
2009 } DMA_WIDTH, *PDMA_WIDTH;
2010 
2011 typedef enum _DMA_SPEED {
2012   Compatible,
2013   TypeA,
2014   TypeB,
2015   TypeC,
2016   TypeF,
2017   MaximumDmaSpeed
2018 } DMA_SPEED, *PDMA_SPEED;
2019 
2020 /* DEVICE_DESCRIPTION.Version */
2021 
2022 #define DEVICE_DESCRIPTION_VERSION        0x0000
2023 #define DEVICE_DESCRIPTION_VERSION1       0x0001
2024 #define DEVICE_DESCRIPTION_VERSION2       0x0002
2025 
2026 typedef struct _DEVICE_DESCRIPTION {
2027   ULONG Version;
2028   BOOLEAN Master;
2029   BOOLEAN ScatterGather;
2030   BOOLEAN DemandMode;
2031   BOOLEAN AutoInitialize;
2032   BOOLEAN Dma32BitAddresses;
2033   BOOLEAN IgnoreCount;
2034   BOOLEAN Reserved1;
2035   BOOLEAN Dma64BitAddresses;
2036   ULONG BusNumber;
2037   ULONG DmaChannel;
2038   INTERFACE_TYPE InterfaceType;
2039   DMA_WIDTH DmaWidth;
2040   DMA_SPEED DmaSpeed;
2041   ULONG MaximumLength;
2042   ULONG DmaPort;
2043 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
2044 
2045 typedef enum _DEVICE_RELATION_TYPE {
2046   BusRelations,
2047   EjectionRelations,
2048   PowerRelations,
2049   RemovalRelations,
2050   TargetDeviceRelation,
2051   SingleBusRelations,
2052   TransportRelations
2053 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
2054 
2055 typedef struct _DEVICE_RELATIONS {
2056   ULONG Count;
2057   PDEVICE_OBJECT Objects[1];
2058 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
2059 
2060 typedef struct _DEVOBJ_EXTENSION {
2061   CSHORT Type;
2062   USHORT Size;
2063   PDEVICE_OBJECT DeviceObject;
2064 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
2065 
2066 typedef struct _SCATTER_GATHER_ELEMENT {
2067   PHYSICAL_ADDRESS Address;
2068   ULONG Length;
2069   ULONG_PTR Reserved;
2070 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
2071 
2072 #if defined(_MSC_EXTENSIONS) || defined(__GNUC__)
2073 
2074 #if defined(_MSC_VER)
2075 #if _MSC_VER >= 1200
2076 #pragma warning(push)
2077 #endif
2078 #pragma warning(disable:4200)
2079 #endif /* _MSC_VER */
2080 
2081 typedef struct _SCATTER_GATHER_LIST {
2082   ULONG NumberOfElements;
2083   ULONG_PTR Reserved;
2084   SCATTER_GATHER_ELEMENT Elements[1];
2085 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2086 
2087 #if defined(_MSC_VER)
2088 #if _MSC_VER >= 1200
2089 #pragma warning(pop)
2090 #else
2091 #pragma warning(default:4200)
2092 #endif
2093 #endif /* _MSC_VER */
2094 
2095 #else /* defined(_MSC_EXTENSIONS) || defined(__GNUC__) */
2096 
2097 struct _SCATTER_GATHER_LIST;
2098 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2099 
2100 #endif /* defined(_MSC_EXTENSIONS) || defined(__GNUC__) */
2101 
2102 _Function_class_(DRIVER_ADD_DEVICE)
2103 _IRQL_requires_(PASSIVE_LEVEL)
2104 _IRQL_requires_same_
2105 _When_(return>=0, _Kernel_clear_do_init_(__yes))
2106 typedef NTSTATUS
2107 (NTAPI DRIVER_ADD_DEVICE)(
2108   _In_ struct _DRIVER_OBJECT *DriverObject,
2109   _In_ struct _DEVICE_OBJECT *PhysicalDeviceObject);
2110 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
2111 
2112 typedef struct _DRIVER_EXTENSION {
2113   struct _DRIVER_OBJECT *DriverObject;
2114   PDRIVER_ADD_DEVICE AddDevice;
2115   ULONG Count;
2116   UNICODE_STRING ServiceKeyName;
2117 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2118 
2119 #define DRVO_UNLOAD_INVOKED               0x00000001
2120 #define DRVO_LEGACY_DRIVER                0x00000002
2121 #define DRVO_BUILTIN_DRIVER               0x00000004
2122 
2123 _Function_class_(DRIVER_INITIALIZE)
2124 _IRQL_requires_same_
2125 typedef NTSTATUS
2126 (NTAPI DRIVER_INITIALIZE)(
2127   _In_ struct _DRIVER_OBJECT *DriverObject,
2128   _In_ PUNICODE_STRING RegistryPath);
2129 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
2130 
2131 _Function_class_(DRIVER_STARTIO)
2132 _IRQL_always_function_min_(DISPATCH_LEVEL)
2133 _IRQL_requires_(DISPATCH_LEVEL)
2134 _IRQL_requires_same_
2135 typedef VOID
2136 (NTAPI DRIVER_STARTIO)(
2137   _Inout_ struct _DEVICE_OBJECT *DeviceObject,
2138   _Inout_ struct _IRP *Irp);
2139 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
2140 
2141 _Function_class_(DRIVER_UNLOAD)
2142 _IRQL_requires_(PASSIVE_LEVEL)
2143 _IRQL_requires_same_
2144 typedef VOID
2145 (NTAPI DRIVER_UNLOAD)(
2146   _In_ struct _DRIVER_OBJECT *DriverObject);
2147 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
2148 
2149 _Function_class_(DRIVER_DISPATCH)
2150 _IRQL_requires_max_(DISPATCH_LEVEL)
2151 _IRQL_requires_same_
2152 typedef NTSTATUS
2153 (NTAPI DRIVER_DISPATCH)(
2154   _In_ struct _DEVICE_OBJECT *DeviceObject,
2155   _Inout_ struct _IRP *Irp);
2156 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
2157 typedef DRIVER_DISPATCH DRIVER_DISPATCH_RAISED;
2158 
2159 _Function_class_(DRIVER_DISPATCH)
2160 _IRQL_requires_(PASSIVE_LEVEL)
2161 _IRQL_requires_same_
2162 typedef NTSTATUS
2163 (NTAPI DRIVER_DISPATCH_PAGED)(
2164   _In_ struct _DEVICE_OBJECT *DeviceObject,
2165   _Inout_ struct _IRP *Irp);
2166 typedef DRIVER_DISPATCH_PAGED *PDRIVER_DISPATCH_PAGED;
2167 
2168 typedef struct _DRIVER_OBJECT {
2169   CSHORT Type;
2170   CSHORT Size;
2171   PDEVICE_OBJECT DeviceObject;
2172   ULONG Flags;
2173   PVOID DriverStart;
2174   ULONG DriverSize;
2175   PVOID DriverSection;
2176   PDRIVER_EXTENSION DriverExtension;
2177   UNICODE_STRING DriverName;
2178   PUNICODE_STRING HardwareDatabase;
2179   struct _FAST_IO_DISPATCH *FastIoDispatch;
2180   PDRIVER_INITIALIZE DriverInit;
2181   PDRIVER_STARTIO DriverStartIo;
2182   PDRIVER_UNLOAD DriverUnload;
2183   PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
2184 } DRIVER_OBJECT, *PDRIVER_OBJECT;
2185 
2186 typedef struct _DMA_ADAPTER {
2187   USHORT Version;
2188   USHORT Size;
2189   struct _DMA_OPERATIONS* DmaOperations;
2190 } DMA_ADAPTER, *PDMA_ADAPTER;
2191 
2192 typedef VOID
2193 (NTAPI *PPUT_DMA_ADAPTER)(
2194   PDMA_ADAPTER DmaAdapter);
2195 
2196 typedef PVOID
2197 (NTAPI *PALLOCATE_COMMON_BUFFER)(
2198   _In_ PDMA_ADAPTER DmaAdapter,
2199   _In_ ULONG Length,
2200   _Out_ PPHYSICAL_ADDRESS LogicalAddress,
2201   _In_ BOOLEAN CacheEnabled);
2202 
2203 typedef VOID
2204 (NTAPI *PFREE_COMMON_BUFFER)(
2205   _In_ PDMA_ADAPTER DmaAdapter,
2206   _In_ ULONG Length,
2207   _In_ PHYSICAL_ADDRESS LogicalAddress,
2208   _In_ PVOID VirtualAddress,
2209   _In_ BOOLEAN CacheEnabled);
2210 
2211 typedef NTSTATUS
2212 (NTAPI *PALLOCATE_ADAPTER_CHANNEL)(
2213   _In_ PDMA_ADAPTER DmaAdapter,
2214   _In_ PDEVICE_OBJECT DeviceObject,
2215   _In_ ULONG NumberOfMapRegisters,
2216   _In_ PDRIVER_CONTROL ExecutionRoutine,
2217   _In_ PVOID Context);
2218 
2219 typedef BOOLEAN
2220 (NTAPI *PFLUSH_ADAPTER_BUFFERS)(
2221   _In_ PDMA_ADAPTER DmaAdapter,
2222   _In_ PMDL Mdl,
2223   _In_ PVOID MapRegisterBase,
2224   _In_ PVOID CurrentVa,
2225   _In_ ULONG Length,
2226   _In_ BOOLEAN WriteToDevice);
2227 
2228 typedef VOID
2229 (NTAPI *PFREE_ADAPTER_CHANNEL)(
2230   _In_ PDMA_ADAPTER DmaAdapter);
2231 
2232 typedef VOID
2233 (NTAPI *PFREE_MAP_REGISTERS)(
2234   _In_ PDMA_ADAPTER DmaAdapter,
2235   PVOID MapRegisterBase,
2236   ULONG NumberOfMapRegisters);
2237 
2238 typedef PHYSICAL_ADDRESS
2239 (NTAPI *PMAP_TRANSFER)(
2240   _In_ PDMA_ADAPTER DmaAdapter,
2241   _In_ PMDL Mdl,
2242   _In_ PVOID MapRegisterBase,
2243   _In_ PVOID CurrentVa,
2244   _Inout_ PULONG Length,
2245   _In_ BOOLEAN WriteToDevice);
2246 
2247 typedef ULONG
2248 (NTAPI *PGET_DMA_ALIGNMENT)(
2249   _In_ PDMA_ADAPTER DmaAdapter);
2250 
2251 typedef ULONG
2252 (NTAPI *PREAD_DMA_COUNTER)(
2253   _In_ PDMA_ADAPTER DmaAdapter);
2254 
2255 _Function_class_(DRIVER_LIST_CONTROL)
2256 _IRQL_requires_same_
2257 typedef VOID
2258 (NTAPI DRIVER_LIST_CONTROL)(
2259   _In_ struct _DEVICE_OBJECT *DeviceObject,
2260   _In_ struct _IRP *Irp,
2261   _In_ struct _SCATTER_GATHER_LIST *ScatterGather,
2262   _In_ PVOID Context);
2263 typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL;
2264 
2265 typedef NTSTATUS
2266 (NTAPI *PGET_SCATTER_GATHER_LIST)(
2267   _In_ PDMA_ADAPTER DmaAdapter,
2268   _In_ PDEVICE_OBJECT DeviceObject,
2269   _In_ PMDL Mdl,
2270   _In_ PVOID CurrentVa,
2271   _In_ ULONG Length,
2272   _In_ PDRIVER_LIST_CONTROL ExecutionRoutine,
2273   _In_ PVOID Context,
2274   _In_ BOOLEAN WriteToDevice);
2275 
2276 typedef VOID
2277 (NTAPI *PPUT_SCATTER_GATHER_LIST)(
2278   _In_ PDMA_ADAPTER DmaAdapter,
2279   _In_ PSCATTER_GATHER_LIST ScatterGather,
2280   _In_ BOOLEAN WriteToDevice);
2281 
2282 typedef NTSTATUS
2283 (NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2284   _In_ PDMA_ADAPTER DmaAdapter,
2285   _In_ PMDL Mdl OPTIONAL,
2286   _In_ PVOID CurrentVa,
2287   _In_ ULONG Length,
2288   _Out_ PULONG ScatterGatherListSize,
2289   _Out_ OPTIONAL PULONG pNumberOfMapRegisters);
2290 
2291 typedef NTSTATUS
2292 (NTAPI *PBUILD_SCATTER_GATHER_LIST)(
2293   _In_ PDMA_ADAPTER DmaAdapter,
2294   _In_ PDEVICE_OBJECT DeviceObject,
2295   _In_ PMDL Mdl,
2296   _In_ PVOID CurrentVa,
2297   _In_ ULONG Length,
2298   _In_ PDRIVER_LIST_CONTROL ExecutionRoutine,
2299   _In_ PVOID Context,
2300   _In_ BOOLEAN WriteToDevice,
2301   _In_ PVOID ScatterGatherBuffer,
2302   _In_ ULONG ScatterGatherLength);
2303 
2304 typedef NTSTATUS
2305 (NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2306   _In_ PDMA_ADAPTER DmaAdapter,
2307   _In_ PSCATTER_GATHER_LIST ScatterGather,
2308   _In_ PMDL OriginalMdl,
2309   _Out_ PMDL *TargetMdl);
2310 
2311 typedef struct _DMA_OPERATIONS {
2312   ULONG Size;
2313   PPUT_DMA_ADAPTER PutDmaAdapter;
2314   PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2315   PFREE_COMMON_BUFFER FreeCommonBuffer;
2316   PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2317   PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2318   PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2319   PFREE_MAP_REGISTERS FreeMapRegisters;
2320   PMAP_TRANSFER MapTransfer;
2321   PGET_DMA_ALIGNMENT GetDmaAlignment;
2322   PREAD_DMA_COUNTER ReadDmaCounter;
2323   PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2324   PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2325   PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2326   PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2327   PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2328 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2329 
2330 typedef struct _IO_RESOURCE_DESCRIPTOR {
2331   UCHAR Option;
2332   UCHAR Type;
2333   UCHAR ShareDisposition;
2334   UCHAR Spare1;
2335   USHORT Flags;
2336   USHORT Spare2;
2337   union {
2338     struct {
2339       ULONG Length;
2340       ULONG Alignment;
2341       PHYSICAL_ADDRESS MinimumAddress;
2342       PHYSICAL_ADDRESS MaximumAddress;
2343     } Port;
2344     struct {
2345       ULONG Length;
2346       ULONG Alignment;
2347       PHYSICAL_ADDRESS MinimumAddress;
2348       PHYSICAL_ADDRESS MaximumAddress;
2349     } Memory;
2350     struct {
2351       ULONG MinimumVector;
2352       ULONG MaximumVector;
2353     } Interrupt;
2354     struct {
2355       ULONG MinimumChannel;
2356       ULONG MaximumChannel;
2357     } Dma;
2358     struct {
2359       ULONG Length;
2360       ULONG Alignment;
2361       PHYSICAL_ADDRESS MinimumAddress;
2362       PHYSICAL_ADDRESS MaximumAddress;
2363     } Generic;
2364     struct {
2365       ULONG Data[3];
2366     } DevicePrivate;
2367     struct {
2368       ULONG Length;
2369       ULONG MinBusNumber;
2370       ULONG MaxBusNumber;
2371       ULONG Reserved;
2372     } BusNumber;
2373     struct {
2374       ULONG Priority;
2375       ULONG Reserved1;
2376       ULONG Reserved2;
2377     } ConfigData;
2378   } u;
2379 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
2380 
2381 typedef struct _IO_RESOURCE_LIST {
2382   USHORT Version;
2383   USHORT Revision;
2384   ULONG Count;
2385   IO_RESOURCE_DESCRIPTOR Descriptors[1];
2386 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
2387 
2388 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
2389   ULONG ListSize;
2390   INTERFACE_TYPE InterfaceType;
2391   ULONG BusNumber;
2392   ULONG SlotNumber;
2393   ULONG Reserved[3];
2394   ULONG AlternativeLists;
2395   IO_RESOURCE_LIST List[1];
2396 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
2397 
2398 _Function_class_(DRIVER_CANCEL)
2399 _Requires_lock_held_(_Global_cancel_spin_lock_)
2400 _Releases_lock_(_Global_cancel_spin_lock_)
2401 _IRQL_requires_min_(DISPATCH_LEVEL)
2402 _IRQL_requires_(DISPATCH_LEVEL)
2403 typedef VOID
2404 (NTAPI DRIVER_CANCEL)(
2405   _Inout_ struct _DEVICE_OBJECT *DeviceObject,
2406   _Inout_ _IRQL_uses_cancel_ struct _IRP *Irp);
2407 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
2408 
2409 typedef struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _IRP {
2410   CSHORT Type;
2411   USHORT Size;
2412   struct _MDL *MdlAddress;
2413   ULONG Flags;
2414   union {
2415     struct _IRP *MasterIrp;
2416     volatile LONG IrpCount;
2417     PVOID SystemBuffer;
2418   } AssociatedIrp;
2419   LIST_ENTRY ThreadListEntry;
2420   IO_STATUS_BLOCK IoStatus;
2421   KPROCESSOR_MODE RequestorMode;
2422   BOOLEAN PendingReturned;
2423   CHAR StackCount;
2424   CHAR CurrentLocation;
2425   BOOLEAN Cancel;
2426   KIRQL CancelIrql;
2427   CCHAR ApcEnvironment;
2428   UCHAR AllocationFlags;
2429   PIO_STATUS_BLOCK UserIosb;
2430   PKEVENT UserEvent;
2431   union {
2432     struct {
2433       _ANONYMOUS_UNION union {
2434         PIO_APC_ROUTINE UserApcRoutine;
2435         PVOID IssuingProcess;
2436       } DUMMYUNIONNAME;
2437       PVOID UserApcContext;
2438     } AsynchronousParameters;
2439     LARGE_INTEGER AllocationSize;
2440   } Overlay;
2441   volatile PDRIVER_CANCEL CancelRoutine;
2442   PVOID UserBuffer;
2443   union {
2444     struct {
2445       _ANONYMOUS_UNION union {
2446         KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
2447         _ANONYMOUS_STRUCT struct {
2448           PVOID DriverContext[4];
2449         } DUMMYSTRUCTNAME;
2450       } DUMMYUNIONNAME;
2451       PETHREAD Thread;
2452       PCHAR AuxiliaryBuffer;
2453       _ANONYMOUS_STRUCT struct {
2454         LIST_ENTRY ListEntry;
2455         _ANONYMOUS_UNION union {
2456           struct _IO_STACK_LOCATION *CurrentStackLocation;
2457           ULONG PacketType;
2458         } DUMMYUNIONNAME;
2459       } DUMMYSTRUCTNAME;
2460       struct _FILE_OBJECT *OriginalFileObject;
2461     } Overlay;
2462     KAPC Apc;
2463     PVOID CompletionKey;
2464   } Tail;
2465 } IRP, *PIRP;
2466 
2467 typedef enum _IO_PAGING_PRIORITY {
2468   IoPagingPriorityInvalid,
2469   IoPagingPriorityNormal,
2470   IoPagingPriorityHigh,
2471   IoPagingPriorityReserved1,
2472   IoPagingPriorityReserved2
2473 } IO_PAGING_PRIORITY;
2474 
2475 _Function_class_(IO_COMPLETION_ROUTINE)
2476 _IRQL_requires_same_
2477 typedef NTSTATUS
2478 (NTAPI IO_COMPLETION_ROUTINE)(
2479   _In_ struct _DEVICE_OBJECT *DeviceObject,
2480   _In_ struct _IRP *Irp,
2481   _In_opt_ PVOID Context);
2482 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
2483 
2484 _Function_class_(IO_DPC_ROUTINE)
2485 _IRQL_always_function_min_(DISPATCH_LEVEL)
2486 _IRQL_requires_(DISPATCH_LEVEL)
2487 _IRQL_requires_same_
2488 typedef VOID
2489 (NTAPI IO_DPC_ROUTINE)(
2490   _In_ struct _KDPC *Dpc,
2491   _In_ struct _DEVICE_OBJECT *DeviceObject,
2492   _Inout_ struct _IRP *Irp,
2493   _In_opt_ PVOID Context);
2494 typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE;
2495 
2496 typedef NTSTATUS
2497 (NTAPI *PMM_DLL_INITIALIZE)(
2498   _In_ PUNICODE_STRING RegistryPath);
2499 
2500 typedef NTSTATUS
2501 (NTAPI *PMM_DLL_UNLOAD)(
2502   VOID);
2503 
2504 _Function_class_(IO_TIMER_ROUTINE)
2505 _IRQL_requires_same_
2506 typedef VOID
2507 (NTAPI IO_TIMER_ROUTINE)(
2508   _In_ struct _DEVICE_OBJECT *DeviceObject,
2509   _In_opt_ PVOID Context);
2510 typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
2511 
2512 typedef struct _IO_SECURITY_CONTEXT {
2513   PSECURITY_QUALITY_OF_SERVICE SecurityQos;
2514   PACCESS_STATE AccessState;
2515   ACCESS_MASK DesiredAccess;
2516   ULONG FullCreateOptions;
2517 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
2518 
2519 struct _IO_CSQ;
2520 
2521 typedef struct _IO_CSQ_IRP_CONTEXT {
2522   ULONG Type;
2523   struct _IRP *Irp;
2524   struct _IO_CSQ *Csq;
2525 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
2526 
2527 typedef VOID
2528 (NTAPI IO_CSQ_INSERT_IRP)(
2529   _In_ struct _IO_CSQ *Csq,
2530   _In_ PIRP Irp);
2531 typedef IO_CSQ_INSERT_IRP *PIO_CSQ_INSERT_IRP;
2532 
2533 typedef NTSTATUS
2534 (NTAPI IO_CSQ_INSERT_IRP_EX)(
2535   _In_ struct _IO_CSQ *Csq,
2536   _In_ PIRP Irp,
2537   _In_ PVOID InsertContext);
2538 typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX;
2539 
2540 typedef VOID
2541 (NTAPI IO_CSQ_REMOVE_IRP)(
2542   _In_ struct _IO_CSQ *Csq,
2543   _In_ PIRP Irp);
2544 typedef IO_CSQ_REMOVE_IRP *PIO_CSQ_REMOVE_IRP;
2545 
2546 typedef PIRP
2547 (NTAPI IO_CSQ_PEEK_NEXT_IRP)(
2548   _In_ struct _IO_CSQ *Csq,
2549   _In_ PIRP Irp,
2550   _In_ PVOID PeekContext);
2551 typedef IO_CSQ_PEEK_NEXT_IRP *PIO_CSQ_PEEK_NEXT_IRP;
2552 
2553 typedef VOID
2554 (NTAPI IO_CSQ_ACQUIRE_LOCK)(
2555   _In_ struct _IO_CSQ *Csq,
2556   _Out_ PKIRQL Irql);
2557 typedef IO_CSQ_ACQUIRE_LOCK *PIO_CSQ_ACQUIRE_LOCK;
2558 
2559 typedef VOID
2560 (NTAPI IO_CSQ_RELEASE_LOCK)(
2561   _In_ struct _IO_CSQ *Csq,
2562   _In_ KIRQL Irql);
2563 typedef IO_CSQ_RELEASE_LOCK *PIO_CSQ_RELEASE_LOCK;
2564 
2565 typedef VOID
2566 (NTAPI IO_CSQ_COMPLETE_CANCELED_IRP)(
2567   _In_ struct _IO_CSQ *Csq,
2568   _In_ PIRP Irp);
2569 typedef IO_CSQ_COMPLETE_CANCELED_IRP *PIO_CSQ_COMPLETE_CANCELED_IRP;
2570 
2571 typedef struct _IO_CSQ {
2572   ULONG Type;
2573   PIO_CSQ_INSERT_IRP CsqInsertIrp;
2574   PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
2575   PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
2576   PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
2577   PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
2578   PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
2579   PVOID ReservePointer;
2580 } IO_CSQ, *PIO_CSQ;
2581 
2582 typedef enum _BUS_QUERY_ID_TYPE {
2583   BusQueryDeviceID,
2584   BusQueryHardwareIDs,
2585   BusQueryCompatibleIDs,
2586   BusQueryInstanceID,
2587   BusQueryDeviceSerialNumber
2588 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
2589 
2590 typedef enum _DEVICE_TEXT_TYPE {
2591   DeviceTextDescription,
2592   DeviceTextLocationInformation
2593 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
2594 
2595 typedef BOOLEAN
2596 (NTAPI *PGPE_SERVICE_ROUTINE)(
2597   PVOID,
2598   PVOID);
2599 
2600 _IRQL_requires_max_(DISPATCH_LEVEL)
2601 _Must_inspect_result_
2602 typedef NTSTATUS
2603 (NTAPI *PGPE_CONNECT_VECTOR)(
2604   PDEVICE_OBJECT,
2605   ULONG,
2606   KINTERRUPT_MODE,
2607   BOOLEAN,
2608   PGPE_SERVICE_ROUTINE,
2609   PVOID,
2610   PVOID);
2611 
2612 _IRQL_requires_max_(DISPATCH_LEVEL)
2613 _Must_inspect_result_
2614 typedef NTSTATUS
2615 (NTAPI *PGPE_DISCONNECT_VECTOR)(
2616   PVOID);
2617 
2618 _IRQL_requires_max_(DISPATCH_LEVEL)
2619 _Must_inspect_result_
2620 typedef NTSTATUS
2621 (NTAPI *PGPE_ENABLE_EVENT)(
2622   PDEVICE_OBJECT,
2623   PVOID);
2624 
2625 _IRQL_requires_max_(DISPATCH_LEVEL)
2626 _Must_inspect_result_
2627 typedef NTSTATUS
2628 (NTAPI *PGPE_DISABLE_EVENT)(
2629   PDEVICE_OBJECT,
2630   PVOID);
2631 
2632 _IRQL_requires_max_(DISPATCH_LEVEL)
2633 _Must_inspect_result_
2634 typedef NTSTATUS
2635 (NTAPI *PGPE_CLEAR_STATUS)(
2636   PDEVICE_OBJECT,
2637   PVOID);
2638 
2639 typedef VOID
2640 (NTAPI *PDEVICE_NOTIFY_CALLBACK)(
2641   PVOID,
2642   ULONG);
2643 
2644 _IRQL_requires_max_(DISPATCH_LEVEL)
2645 _Must_inspect_result_
2646 typedef NTSTATUS
2647 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
2648   PDEVICE_OBJECT,
2649   PDEVICE_NOTIFY_CALLBACK,
2650   PVOID);
2651 
2652 _IRQL_requires_max_(DISPATCH_LEVEL)
2653 typedef VOID
2654 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
2655   PDEVICE_OBJECT,
2656   PDEVICE_NOTIFY_CALLBACK);
2657 
2658 typedef struct _ACPI_INTERFACE_STANDARD {
2659   USHORT Size;
2660   USHORT Version;
2661   PVOID Context;
2662   PINTERFACE_REFERENCE InterfaceReference;
2663   PINTERFACE_DEREFERENCE InterfaceDereference;
2664   PGPE_CONNECT_VECTOR GpeConnectVector;
2665   PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
2666   PGPE_ENABLE_EVENT GpeEnableEvent;
2667   PGPE_DISABLE_EVENT GpeDisableEvent;
2668   PGPE_CLEAR_STATUS GpeClearStatus;
2669   PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
2670   PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
2671 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
2672 
2673 typedef BOOLEAN
2674 (NTAPI *PGPE_SERVICE_ROUTINE2)(
2675   PVOID ObjectContext,
2676   PVOID ServiceContext);
2677 
2678 _IRQL_requires_max_(DISPATCH_LEVEL)
2679 _Must_inspect_result_
2680 typedef NTSTATUS
2681 (NTAPI *PGPE_CONNECT_VECTOR2)(
2682   PVOID Context,
2683   ULONG GpeNumber,
2684   KINTERRUPT_MODE Mode,
2685   BOOLEAN Shareable,
2686   PGPE_SERVICE_ROUTINE ServiceRoutine,
2687   PVOID ServiceContext,
2688   PVOID *ObjectContext);
2689 
2690 _IRQL_requires_max_(DISPATCH_LEVEL)
2691 _Must_inspect_result_
2692 typedef NTSTATUS
2693 (NTAPI *PGPE_DISCONNECT_VECTOR2)(
2694   PVOID Context,
2695   PVOID ObjectContext);
2696 
2697 _IRQL_requires_max_(DISPATCH_LEVEL)
2698 _Must_inspect_result_
2699 typedef NTSTATUS
2700 (NTAPI *PGPE_ENABLE_EVENT2)(
2701   PVOID Context,
2702   PVOID ObjectContext);
2703 
2704 _IRQL_requires_max_(DISPATCH_LEVEL)
2705 _Must_inspect_result_
2706 typedef NTSTATUS
2707 (NTAPI *PGPE_DISABLE_EVENT2)(
2708   PVOID Context,
2709   PVOID ObjectContext);
2710 
2711 _IRQL_requires_max_(DISPATCH_LEVEL)
2712 _Must_inspect_result_
2713 typedef NTSTATUS
2714 (NTAPI *PGPE_CLEAR_STATUS2)(
2715   PVOID Context,
2716   PVOID ObjectContext);
2717 
2718 _IRQL_requires_max_(DISPATCH_LEVEL)
2719 typedef VOID
2720 (NTAPI *PDEVICE_NOTIFY_CALLBACK2)(
2721   PVOID NotificationContext,
2722   ULONG NotifyCode);
2723 
2724 _IRQL_requires_max_(DISPATCH_LEVEL)
2725 _Must_inspect_result_
2726 typedef NTSTATUS
2727 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2728   PVOID Context,
2729   PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
2730   PVOID NotificationContext);
2731 
2732 _IRQL_requires_max_(DISPATCH_LEVEL)
2733 typedef VOID
2734 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2735   PVOID Context);
2736 
2737 typedef struct _ACPI_INTERFACE_STANDARD2 {
2738   USHORT Size;
2739   USHORT Version;
2740   PVOID Context;
2741   PINTERFACE_REFERENCE InterfaceReference;
2742   PINTERFACE_DEREFERENCE InterfaceDereference;
2743   PGPE_CONNECT_VECTOR2 GpeConnectVector;
2744   PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
2745   PGPE_ENABLE_EVENT2 GpeEnableEvent;
2746   PGPE_DISABLE_EVENT2 GpeDisableEvent;
2747   PGPE_CLEAR_STATUS2 GpeClearStatus;
2748   PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
2749   PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
2750 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
2751 
2752 #if !defined(_AMD64_) && !defined(_ARM_)
2753 #include <pshpack4.h>
2754 #endif
2755 
2756 typedef struct _IO_STACK_LOCATION {
2757   UCHAR MajorFunction;
2758   UCHAR MinorFunction;
2759   UCHAR Flags;
2760   UCHAR Control;
2761   union {
2762     struct {
2763       PIO_SECURITY_CONTEXT SecurityContext;
2764       ULONG Options;
2765       USHORT POINTER_ALIGNMENT FileAttributes;
2766       USHORT ShareAccess;
2767       ULONG POINTER_ALIGNMENT EaLength;
2768     } Create;
2769     struct {
2770       struct _IO_SECURITY_CONTEXT *SecurityContext;
2771       ULONG Options;
2772       USHORT POINTER_ALIGNMENT Reserved;
2773       USHORT ShareAccess;
2774       struct _NAMED_PIPE_CREATE_PARAMETERS *Parameters;
2775     } CreatePipe;
2776     struct {
2777       PIO_SECURITY_CONTEXT SecurityContext;
2778       ULONG Options;
2779       USHORT POINTER_ALIGNMENT Reserved;
2780       USHORT ShareAccess;
2781       struct _MAILSLOT_CREATE_PARAMETERS *Parameters;
2782     } CreateMailslot;
2783     struct {
2784       ULONG Length;
2785       ULONG POINTER_ALIGNMENT Key;
2786       LARGE_INTEGER ByteOffset;
2787     } Read;
2788     struct {
2789       ULONG Length;
2790       ULONG POINTER_ALIGNMENT Key;
2791       LARGE_INTEGER ByteOffset;
2792     } Write;
2793     struct {
2794       ULONG Length;
2795       PUNICODE_STRING FileName;
2796       FILE_INFORMATION_CLASS FileInformationClass;
2797       ULONG POINTER_ALIGNMENT FileIndex;
2798     } QueryDirectory;
2799     struct {
2800       ULONG Length;
2801       ULONG POINTER_ALIGNMENT CompletionFilter;
2802     } NotifyDirectory;
2803     struct {
2804       ULONG Length;
2805       ULONG POINTER_ALIGNMENT CompletionFilter;
2806       DIRECTORY_NOTIFY_INFORMATION_CLASS POINTER_ALIGNMENT DirectoryNotifyInformationClass;
2807     } NotifyDirectoryEx;
2808     struct {
2809       ULONG Length;
2810       FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2811     } QueryFile;
2812     struct {
2813       ULONG Length;
2814       FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2815       PFILE_OBJECT FileObject;
2816       _ANONYMOUS_UNION union {
2817         _ANONYMOUS_STRUCT struct {
2818           BOOLEAN ReplaceIfExists;
2819           BOOLEAN AdvanceOnly;
2820         } DUMMYSTRUCTNAME;
2821         ULONG ClusterCount;
2822         HANDLE DeleteHandle;
2823       } DUMMYUNIONNAME;
2824     } SetFile;
2825     struct {
2826       ULONG Length;
2827       PVOID EaList;
2828       ULONG EaListLength;
2829       ULONG POINTER_ALIGNMENT EaIndex;
2830     } QueryEa;
2831     struct {
2832       ULONG Length;
2833     } SetEa;
2834     struct {
2835       ULONG Length;
2836       FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2837     } QueryVolume;
2838     struct {
2839       ULONG Length;
2840       FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2841     } SetVolume;
2842     struct {
2843       ULONG OutputBufferLength;
2844       ULONG POINTER_ALIGNMENT InputBufferLength;
2845       ULONG POINTER_ALIGNMENT FsControlCode;
2846       PVOID Type3InputBuffer;
2847     } FileSystemControl;
2848     struct {
2849       PLARGE_INTEGER Length;
2850       ULONG POINTER_ALIGNMENT Key;
2851       LARGE_INTEGER ByteOffset;
2852     } LockControl;
2853     struct {
2854       ULONG OutputBufferLength;
2855       ULONG POINTER_ALIGNMENT InputBufferLength;
2856       ULONG POINTER_ALIGNMENT IoControlCode;
2857       PVOID Type3InputBuffer;
2858     } DeviceIoControl;
2859     struct {
2860       SECURITY_INFORMATION SecurityInformation;
2861       ULONG POINTER_ALIGNMENT Length;
2862     } QuerySecurity;
2863     struct {
2864       SECURITY_INFORMATION SecurityInformation;
2865       PSECURITY_DESCRIPTOR SecurityDescriptor;
2866     } SetSecurity;
2867     struct {
2868       PVPB Vpb;
2869       PDEVICE_OBJECT DeviceObject;
2870     } MountVolume;
2871     struct {
2872       PVPB Vpb;
2873       PDEVICE_OBJECT DeviceObject;
2874     } VerifyVolume;
2875     struct {
2876       struct _SCSI_REQUEST_BLOCK *Srb;
2877     } Scsi;
2878     struct {
2879       ULONG Length;
2880       PSID StartSid;
2881       struct _FILE_GET_QUOTA_INFORMATION *SidList;
2882       ULONG SidListLength;
2883     } QueryQuota;
2884     struct {
2885       ULONG Length;
2886     } SetQuota;
2887     struct {
2888       DEVICE_RELATION_TYPE Type;
2889     } QueryDeviceRelations;
2890     struct {
2891       CONST GUID *InterfaceType;
2892       USHORT Size;
2893       USHORT Version;
2894       PINTERFACE Interface;
2895       PVOID InterfaceSpecificData;
2896     } QueryInterface;
2897     struct {
2898       PDEVICE_CAPABILITIES Capabilities;
2899     } DeviceCapabilities;
2900     struct {
2901       PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
2902     } FilterResourceRequirements;
2903     struct {
2904       ULONG WhichSpace;
2905       PVOID Buffer;
2906       ULONG Offset;
2907       ULONG POINTER_ALIGNMENT Length;
2908     } ReadWriteConfig;
2909     struct {
2910       BOOLEAN Lock;
2911     } SetLock;
2912     struct {
2913       BUS_QUERY_ID_TYPE IdType;
2914     } QueryId;
2915     struct {
2916       DEVICE_TEXT_TYPE DeviceTextType;
2917       LCID POINTER_ALIGNMENT LocaleId;
2918     } QueryDeviceText;
2919     struct {
2920       BOOLEAN InPath;
2921       BOOLEAN Reserved[3];
2922       DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
2923     } UsageNotification;
2924     struct {
2925       SYSTEM_POWER_STATE PowerState;
2926     } WaitWake;
2927     struct {
2928       PPOWER_SEQUENCE PowerSequence;
2929     } PowerSequence;
2930     struct {
2931       union {
2932         ULONG SystemContext;
2933 #if (NTDDI_VERSION >= NTDDI_VISTA)
2934         SYSTEM_POWER_STATE_CONTEXT SystemPowerStateContext;
2935 #endif // (NTDDI_VERSION >= NTDDI_VISTA)
2936       };
2937       POWER_STATE_TYPE POINTER_ALIGNMENT Type;
2938       POWER_STATE POINTER_ALIGNMENT State;
2939       POWER_ACTION POINTER_ALIGNMENT ShutdownType;
2940     } Power;
2941     struct {
2942       PCM_RESOURCE_LIST AllocatedResources;
2943       PCM_RESOURCE_LIST AllocatedResourcesTranslated;
2944     } StartDevice;
2945     struct {
2946       ULONG_PTR ProviderId;
2947       PVOID DataPath;
2948       ULONG BufferSize;
2949       PVOID Buffer;
2950     } WMI;
2951     struct {
2952       PVOID Argument1;
2953       PVOID Argument2;
2954       PVOID Argument3;
2955       PVOID Argument4;
2956     } Others;
2957   } Parameters;
2958   PDEVICE_OBJECT DeviceObject;
2959   PFILE_OBJECT FileObject;
2960   PIO_COMPLETION_ROUTINE CompletionRoutine;
2961   PVOID Context;
2962 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
2963 
2964 #if !defined(_AMD64_) && !defined(_ARM_)
2965 #include "poppack.h"
2966 #endif
2967 
2968 
2969 /* IO_STACK_LOCATION.Control */
2970 
2971 #define SL_PENDING_RETURNED               0x01
2972 #define SL_ERROR_RETURNED                 0x02
2973 #define SL_INVOKE_ON_CANCEL               0x20
2974 #define SL_INVOKE_ON_SUCCESS              0x40
2975 #define SL_INVOKE_ON_ERROR                0x80
2976 
2977 $endif (_WDMDDK_)
2978 $if (_WDMDDK_ || _DEVIOCTL_)
2979 #define METHOD_BUFFERED                   0
2980 #define METHOD_IN_DIRECT                  1
2981 #define METHOD_OUT_DIRECT                 2
2982 #define METHOD_NEITHER                    3
2983 
2984 #define METHOD_DIRECT_TO_HARDWARE       METHOD_IN_DIRECT
2985 #define METHOD_DIRECT_FROM_HARDWARE     METHOD_OUT_DIRECT
2986 
2987 $endif (_WDMDDK_ || _DEVIOCTL_)
2988 $if (_WDMDDK_)
2989 #define FILE_SUPERSEDED                   0x00000000
2990 #define FILE_OPENED                       0x00000001
2991 #define FILE_CREATED                      0x00000002
2992 #define FILE_OVERWRITTEN                  0x00000003
2993 #define FILE_EXISTS                       0x00000004
2994 #define FILE_DOES_NOT_EXIST               0x00000005
2995 
2996 #define FILE_USE_FILE_POINTER_POSITION    0xfffffffe
2997 #define FILE_WRITE_TO_END_OF_FILE         0xffffffff
2998 
2999 /* also in winnt.h */
3000 #define FILE_LIST_DIRECTORY               0x00000001
3001 #define FILE_READ_DATA                    0x00000001
3002 #define FILE_ADD_FILE                     0x00000002
3003 #define FILE_WRITE_DATA                   0x00000002
3004 #define FILE_ADD_SUBDIRECTORY             0x00000004
3005 #define FILE_APPEND_DATA                  0x00000004
3006 #define FILE_CREATE_PIPE_INSTANCE         0x00000004
3007 #define FILE_READ_EA                      0x00000008
3008 #define FILE_WRITE_EA                     0x00000010
3009 #define FILE_EXECUTE                      0x00000020
3010 #define FILE_TRAVERSE                     0x00000020
3011 #define FILE_DELETE_CHILD                 0x00000040
3012 #define FILE_READ_ATTRIBUTES              0x00000080
3013 #define FILE_WRITE_ATTRIBUTES             0x00000100
3014 
3015 #define FILE_SHARE_READ                   0x00000001
3016 #define FILE_SHARE_WRITE                  0x00000002
3017 #define FILE_SHARE_DELETE                 0x00000004
3018 #define FILE_SHARE_VALID_FLAGS            0x00000007
3019 
3020 #define FILE_ATTRIBUTE_READONLY           0x00000001
3021 #define FILE_ATTRIBUTE_HIDDEN             0x00000002
3022 #define FILE_ATTRIBUTE_SYSTEM             0x00000004
3023 #define FILE_ATTRIBUTE_DIRECTORY          0x00000010
3024 #define FILE_ATTRIBUTE_ARCHIVE            0x00000020
3025 #define FILE_ATTRIBUTE_DEVICE             0x00000040
3026 #define FILE_ATTRIBUTE_NORMAL             0x00000080
3027 #define FILE_ATTRIBUTE_TEMPORARY          0x00000100
3028 #define FILE_ATTRIBUTE_SPARSE_FILE        0x00000200
3029 #define FILE_ATTRIBUTE_REPARSE_POINT      0x00000400
3030 #define FILE_ATTRIBUTE_COMPRESSED         0x00000800
3031 #define FILE_ATTRIBUTE_OFFLINE            0x00001000
3032 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
3033 #define FILE_ATTRIBUTE_ENCRYPTED          0x00004000
3034 #define FILE_ATTRIBUTE_INTEGRITY_STREAM   0x00008000
3035 #define FILE_ATTRIBUTE_VIRTUAL            0x00010000
3036 
3037 #define FILE_ATTRIBUTE_VALID_FLAGS        0x00007fb7
3038 #define FILE_ATTRIBUTE_VALID_SET_FLAGS    0x000031a7
3039 
3040 #define FILE_VALID_OPTION_FLAGS           0x00ffffff
3041 #define FILE_VALID_PIPE_OPTION_FLAGS      0x00000032
3042 #define FILE_VALID_MAILSLOT_OPTION_FLAGS  0x00000032
3043 #define FILE_VALID_SET_FLAGS              0x00000036
3044 
3045 #define FILE_SUPERSEDE                    0x00000000
3046 #define FILE_OPEN                         0x00000001
3047 #define FILE_CREATE                       0x00000002
3048 #define FILE_OPEN_IF                      0x00000003
3049 #define FILE_OVERWRITE                    0x00000004
3050 #define FILE_OVERWRITE_IF                 0x00000005
3051 #define FILE_MAXIMUM_DISPOSITION          0x00000005
3052 
3053 #define FILE_DIRECTORY_FILE               0x00000001
3054 #define FILE_WRITE_THROUGH                0x00000002
3055 #define FILE_SEQUENTIAL_ONLY              0x00000004
3056 #define FILE_NO_INTERMEDIATE_BUFFERING    0x00000008
3057 #define FILE_SYNCHRONOUS_IO_ALERT         0x00000010
3058 #define FILE_SYNCHRONOUS_IO_NONALERT      0x00000020
3059 #define FILE_NON_DIRECTORY_FILE           0x00000040
3060 #define FILE_CREATE_TREE_CONNECTION       0x00000080
3061 #define FILE_COMPLETE_IF_OPLOCKED         0x00000100
3062 #define FILE_NO_EA_KNOWLEDGE              0x00000200
3063 #define FILE_OPEN_REMOTE_INSTANCE         0x00000400
3064 #define FILE_RANDOM_ACCESS                0x00000800
3065 #define FILE_DELETE_ON_CLOSE              0x00001000
3066 #define FILE_OPEN_BY_FILE_ID              0x00002000
3067 #define FILE_OPEN_FOR_BACKUP_INTENT       0x00004000
3068 #define FILE_NO_COMPRESSION               0x00008000
3069 #if (NTDDI_VERSION >= NTDDI_WIN7)
3070 #define FILE_OPEN_REQUIRING_OPLOCK        0x00010000
3071 #define FILE_DISALLOW_EXCLUSIVE           0x00020000
3072 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3073 #define FILE_RESERVE_OPFILTER             0x00100000
3074 #define FILE_OPEN_REPARSE_POINT           0x00200000
3075 #define FILE_OPEN_NO_RECALL               0x00400000
3076 #define FILE_OPEN_FOR_FREE_SPACE_QUERY    0x00800000
3077 
3078 $endif (_WDMDDK_)
3079 $if (_WDMDDK_ || _DEVIOCTL_)
3080 #define FILE_ANY_ACCESS                   0x00000000
3081 #define FILE_SPECIAL_ACCESS               FILE_ANY_ACCESS
3082 #define FILE_READ_ACCESS                  0x00000001
3083 #define FILE_WRITE_ACCESS                 0x00000002
3084 
3085 $endif (_WDMDDK_ || _DEVIOCTL_)
3086 $if (_WDMDDK_)
3087 #define FILE_ALL_ACCESS \
3088   (STANDARD_RIGHTS_REQUIRED | \
3089    SYNCHRONIZE | \
3090    0x1FF)
3091 
3092 #define FILE_GENERIC_EXECUTE \
3093   (STANDARD_RIGHTS_EXECUTE | \
3094    FILE_READ_ATTRIBUTES | \
3095    FILE_EXECUTE | \
3096    SYNCHRONIZE)
3097 
3098 #define FILE_GENERIC_READ \
3099   (STANDARD_RIGHTS_READ | \
3100    FILE_READ_DATA | \
3101    FILE_READ_ATTRIBUTES | \
3102    FILE_READ_EA | \
3103    SYNCHRONIZE)
3104 
3105 #define FILE_GENERIC_WRITE \
3106   (STANDARD_RIGHTS_WRITE | \
3107    FILE_WRITE_DATA | \
3108    FILE_WRITE_ATTRIBUTES | \
3109    FILE_WRITE_EA | \
3110    FILE_APPEND_DATA | \
3111    SYNCHRONIZE)
3112 
3113 /* end winnt.h */
3114 
3115 #define WMIREG_ACTION_REGISTER      1
3116 #define WMIREG_ACTION_DEREGISTER    2
3117 #define WMIREG_ACTION_REREGISTER    3
3118 #define WMIREG_ACTION_UPDATE_GUIDS  4
3119 #define WMIREG_ACTION_BLOCK_IRPS    5
3120 
3121 #define WMIREGISTER                 0
3122 #define WMIUPDATE                   1
3123 
3124 _Function_class_(WMI_NOTIFICATION_CALLBACK)
3125 _IRQL_requires_same_
3126 typedef VOID
3127 (NTAPI FWMI_NOTIFICATION_CALLBACK)(
3128   PVOID Wnode,
3129   PVOID Context);
3130 typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK;
3131 
3132 #ifndef _PCI_X_
3133 #define _PCI_X_
3134 
3135 typedef struct _PCI_SLOT_NUMBER {
3136   union {
3137     struct {
3138       ULONG DeviceNumber:5;
3139       ULONG FunctionNumber:3;
3140       ULONG Reserved:24;
3141     } bits;
3142     ULONG AsULONG;
3143   } u;
3144 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
3145 
3146 #define PCI_TYPE0_ADDRESSES               6
3147 #define PCI_TYPE1_ADDRESSES               2
3148 #define PCI_TYPE2_ADDRESSES               5
3149 
3150 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
3151    inheritance, even from a struct renders the type non-POD. So we use
3152    this hack */
3153 #define PCI_COMMON_HEADER_LAYOUT                \
3154   USHORT VendorID;                              \
3155   USHORT DeviceID;                              \
3156   USHORT Command;                               \
3157   USHORT Status;                                \
3158   UCHAR RevisionID;                             \
3159   UCHAR ProgIf;                                 \
3160   UCHAR SubClass;                               \
3161   UCHAR BaseClass;                              \
3162   UCHAR CacheLineSize;                          \
3163   UCHAR LatencyTimer;                           \
3164   UCHAR HeaderType;                             \
3165   UCHAR BIST;                                   \
3166   union {                                       \
3167     struct _PCI_HEADER_TYPE_0 {                 \
3168       ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \
3169       ULONG CIS;                                \
3170       USHORT SubVendorID;                       \
3171       USHORT SubSystemID;                       \
3172       ULONG ROMBaseAddress;                     \
3173       UCHAR CapabilitiesPtr;                    \
3174       UCHAR Reserved1[3];                       \
3175       ULONG Reserved2;                          \
3176       UCHAR InterruptLine;                      \
3177       UCHAR InterruptPin;                       \
3178       UCHAR MinimumGrant;                       \
3179       UCHAR MaximumLatency;                     \
3180     } type0;                                    \
3181     struct _PCI_HEADER_TYPE_1 {                 \
3182       ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \
3183       UCHAR PrimaryBus;                         \
3184       UCHAR SecondaryBus;                       \
3185       UCHAR SubordinateBus;                     \
3186       UCHAR SecondaryLatency;                   \
3187       UCHAR IOBase;                             \
3188       UCHAR IOLimit;                            \
3189       USHORT SecondaryStatus;                   \
3190       USHORT MemoryBase;                        \
3191       USHORT MemoryLimit;                       \
3192       USHORT PrefetchBase;                      \
3193       USHORT PrefetchLimit;                     \
3194       ULONG PrefetchBaseUpper32;                \
3195       ULONG PrefetchLimitUpper32;               \
3196       USHORT IOBaseUpper16;                     \
3197       USHORT IOLimitUpper16;                    \
3198       UCHAR CapabilitiesPtr;                    \
3199       UCHAR Reserved1[3];                       \
3200       ULONG ROMBaseAddress;                     \
3201       UCHAR InterruptLine;                      \
3202       UCHAR InterruptPin;                       \
3203       USHORT BridgeControl;                     \
3204     } type1;                                    \
3205     struct _PCI_HEADER_TYPE_2 {                 \
3206       ULONG SocketRegistersBaseAddress;         \
3207       UCHAR CapabilitiesPtr;                    \
3208       UCHAR Reserved;                           \
3209       USHORT SecondaryStatus;                   \
3210       UCHAR PrimaryBus;                         \
3211       UCHAR SecondaryBus;                       \
3212       UCHAR SubordinateBus;                     \
3213       UCHAR SecondaryLatency;                   \
3214       struct {                                  \
3215         ULONG Base;                             \
3216         ULONG Limit;                            \
3217       } Range[PCI_TYPE2_ADDRESSES-1];           \
3218       UCHAR InterruptLine;                      \
3219       UCHAR InterruptPin;                       \
3220       USHORT BridgeControl;                     \
3221     } type2;                                    \
3222   } u;
3223 
3224 typedef struct _PCI_COMMON_HEADER {
3225   PCI_COMMON_HEADER_LAYOUT
3226 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
3227 
3228 #ifdef __cplusplus
3229 typedef struct _PCI_COMMON_CONFIG {
3230   PCI_COMMON_HEADER_LAYOUT
3231   UCHAR DeviceSpecific[192];
3232 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3233 #else
3234 typedef struct _PCI_COMMON_CONFIG {
3235   PCI_COMMON_HEADER DUMMYSTRUCTNAME;
3236   UCHAR DeviceSpecific[192];
3237 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3238 #endif
3239 
3240 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
3241 
3242 #define PCI_EXTENDED_CONFIG_LENGTH               0x1000
3243 
3244 #define PCI_MAX_DEVICES        32
3245 #define PCI_MAX_FUNCTION       8
3246 #define PCI_MAX_BRIDGE_NUMBER  0xFF
3247 #define PCI_INVALID_VENDORID   0xFFFF
3248 
3249 /* PCI_COMMON_CONFIG.HeaderType */
3250 #define PCI_MULTIFUNCTION                 0x80
3251 #define PCI_DEVICE_TYPE                   0x00
3252 #define PCI_BRIDGE_TYPE                   0x01
3253 #define PCI_CARDBUS_BRIDGE_TYPE           0x02
3254 
3255 #define PCI_CONFIGURATION_TYPE(PciData) \
3256   (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
3257 
3258 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
3259   ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
3260 
3261 /* PCI_COMMON_CONFIG.Command */
3262 #define PCI_ENABLE_IO_SPACE               0x0001
3263 #define PCI_ENABLE_MEMORY_SPACE           0x0002
3264 #define PCI_ENABLE_BUS_MASTER             0x0004
3265 #define PCI_ENABLE_SPECIAL_CYCLES         0x0008
3266 #define PCI_ENABLE_WRITE_AND_INVALIDATE   0x0010
3267 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
3268 #define PCI_ENABLE_PARITY                 0x0040
3269 #define PCI_ENABLE_WAIT_CYCLE             0x0080
3270 #define PCI_ENABLE_SERR                   0x0100
3271 #define PCI_ENABLE_FAST_BACK_TO_BACK      0x0200
3272 #define PCI_DISABLE_LEVEL_INTERRUPT       0x0400
3273 
3274 /* PCI_COMMON_CONFIG.Status */
3275 #define PCI_STATUS_INTERRUPT_PENDING      0x0008
3276 #define PCI_STATUS_CAPABILITIES_LIST      0x0010
3277 #define PCI_STATUS_66MHZ_CAPABLE          0x0020
3278 #define PCI_STATUS_UDF_SUPPORTED          0x0040
3279 #define PCI_STATUS_FAST_BACK_TO_BACK      0x0080
3280 #define PCI_STATUS_DATA_PARITY_DETECTED   0x0100
3281 #define PCI_STATUS_DEVSEL                 0x0600
3282 #define PCI_STATUS_SIGNALED_TARGET_ABORT  0x0800
3283 #define PCI_STATUS_RECEIVED_TARGET_ABORT  0x1000
3284 #define PCI_STATUS_RECEIVED_MASTER_ABORT  0x2000
3285 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR  0x4000
3286 #define PCI_STATUS_DETECTED_PARITY_ERROR  0x8000
3287 
3288 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
3289 
3290 #define PCI_WHICHSPACE_CONFIG             0x0
3291 #define PCI_WHICHSPACE_ROM                0x52696350 /* 'PciR' */
3292 
3293 #define PCI_CAPABILITY_ID_POWER_MANAGEMENT  0x01
3294 #define PCI_CAPABILITY_ID_AGP               0x02
3295 #define PCI_CAPABILITY_ID_VPD               0x03
3296 #define PCI_CAPABILITY_ID_SLOT_ID           0x04
3297 #define PCI_CAPABILITY_ID_MSI               0x05
3298 #define PCI_CAPABILITY_ID_CPCI_HOTSWAP      0x06
3299 #define PCI_CAPABILITY_ID_PCIX              0x07
3300 #define PCI_CAPABILITY_ID_HYPERTRANSPORT    0x08
3301 #define PCI_CAPABILITY_ID_VENDOR_SPECIFIC   0x09
3302 #define PCI_CAPABILITY_ID_DEBUG_PORT        0x0A
3303 #define PCI_CAPABILITY_ID_CPCI_RES_CTRL     0x0B
3304 #define PCI_CAPABILITY_ID_SHPC              0x0C
3305 #define PCI_CAPABILITY_ID_P2P_SSID          0x0D
3306 #define PCI_CAPABILITY_ID_AGP_TARGET        0x0E
3307 #define PCI_CAPABILITY_ID_SECURE            0x0F
3308 #define PCI_CAPABILITY_ID_PCI_EXPRESS       0x10
3309 #define PCI_CAPABILITY_ID_MSIX              0x11
3310 
3311 typedef struct _PCI_CAPABILITIES_HEADER {
3312   UCHAR CapabilityID;
3313   UCHAR Next;
3314 } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
3315 
3316 typedef struct _PCI_PMC {
3317   UCHAR Version:3;
3318   UCHAR PMEClock:1;
3319   UCHAR Rsvd1:1;
3320   UCHAR DeviceSpecificInitialization:1;
3321   UCHAR Rsvd2:2;
3322   struct _PM_SUPPORT {
3323     UCHAR Rsvd2:1;
3324     UCHAR D1:1;
3325     UCHAR D2:1;
3326     UCHAR PMED0:1;
3327     UCHAR PMED1:1;
3328     UCHAR PMED2:1;
3329     UCHAR PMED3Hot:1;
3330     UCHAR PMED3Cold:1;
3331   } Support;
3332 } PCI_PMC, *PPCI_PMC;
3333 
3334 typedef struct _PCI_PMCSR {
3335   USHORT PowerState:2;
3336   USHORT Rsvd1:6;
3337   USHORT PMEEnable:1;
3338   USHORT DataSelect:4;
3339   USHORT DataScale:2;
3340   USHORT PMEStatus:1;
3341 } PCI_PMCSR, *PPCI_PMCSR;
3342 
3343 typedef struct _PCI_PMCSR_BSE {
3344   UCHAR Rsvd1:6;
3345   UCHAR D3HotSupportsStopClock:1;
3346   UCHAR BusPowerClockControlEnabled:1;
3347 } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
3348 
3349 typedef struct _PCI_PM_CAPABILITY {
3350   PCI_CAPABILITIES_HEADER Header;
3351   union {
3352     PCI_PMC Capabilities;
3353     USHORT AsUSHORT;
3354   } PMC;
3355     union {
3356       PCI_PMCSR ControlStatus;
3357       USHORT AsUSHORT;
3358     } PMCSR;
3359     union {
3360       PCI_PMCSR_BSE BridgeSupport;
3361       UCHAR AsUCHAR;
3362     } PMCSR_BSE;
3363   UCHAR Data;
3364 } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
3365 
3366 typedef struct {
3367   PCI_CAPABILITIES_HEADER Header;
3368   union {
3369     struct {
3370       USHORT DataParityErrorRecoveryEnable:1;
3371       USHORT EnableRelaxedOrdering:1;
3372       USHORT MaxMemoryReadByteCount:2;
3373       USHORT MaxOutstandingSplitTransactions:3;
3374       USHORT Reserved:9;
3375     } bits;
3376     USHORT AsUSHORT;
3377   } Command;
3378   union {
3379     struct {
3380       ULONG FunctionNumber:3;
3381       ULONG DeviceNumber:5;
3382       ULONG BusNumber:8;
3383       ULONG Device64Bit:1;
3384       ULONG Capable133MHz:1;
3385       ULONG SplitCompletionDiscarded:1;
3386       ULONG UnexpectedSplitCompletion:1;
3387       ULONG DeviceComplexity:1;
3388       ULONG DesignedMaxMemoryReadByteCount:2;
3389       ULONG DesignedMaxOutstandingSplitTransactions:3;
3390       ULONG DesignedMaxCumulativeReadSize:3;
3391       ULONG ReceivedSplitCompletionErrorMessage:1;
3392       ULONG CapablePCIX266:1;
3393       ULONG CapablePCIX533:1;
3394       } bits;
3395     ULONG AsULONG;
3396   } Status;
3397 } PCI_X_CAPABILITY, *PPCI_X_CAPABILITY;
3398 
3399 #define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID                     0x0001
3400 #define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID                              0x0002
3401 #define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID                         0x0003
3402 #define PCI_EXPRESS_POWER_BUDGETING_CAP_ID                              0x0004
3403 #define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID                          0x0005
3404 #define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID                     0x0006
3405 #define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID      0x0007
3406 #define PCI_EXPRESS_MFVC_CAP_ID                                         0x0008
3407 #define PCI_EXPRESS_VC_AND_MFVC_CAP_ID                                  0x0009
3408 #define PCI_EXPRESS_RCRB_HEADER_CAP_ID                                  0x000A
3409 #define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID                0x0010
3410 
3411 typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER {
3412   USHORT CapabilityID;
3413   USHORT Version:4;
3414   USHORT Next:12;
3415 } PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER;
3416 
3417 typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY {
3418   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3419   ULONG LowSerialNumber;
3420   ULONG HighSerialNumber;
3421 } PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY;
3422 
3423 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS {
3424   _ANONYMOUS_STRUCT struct {
3425     ULONG Undefined:1;
3426     ULONG Reserved1:3;
3427     ULONG DataLinkProtocolError:1;
3428     ULONG SurpriseDownError:1;
3429     ULONG Reserved2:6;
3430     ULONG PoisonedTLP:1;
3431     ULONG FlowControlProtocolError:1;
3432     ULONG CompletionTimeout:1;
3433     ULONG CompleterAbort:1;
3434     ULONG UnexpectedCompletion:1;
3435     ULONG ReceiverOverflow:1;
3436     ULONG MalformedTLP:1;
3437     ULONG ECRCError:1;
3438     ULONG UnsupportedRequestError:1;
3439     ULONG Reserved3:11;
3440   } DUMMYSTRUCTNAME;
3441   ULONG AsULONG;
3442 } PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS;
3443 
3444 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK {
3445   _ANONYMOUS_STRUCT struct {
3446     ULONG Undefined:1;
3447     ULONG Reserved1:3;
3448     ULONG DataLinkProtocolError:1;
3449     ULONG SurpriseDownError:1;
3450     ULONG Reserved2:6;
3451     ULONG PoisonedTLP:1;
3452     ULONG FlowControlProtocolError:1;
3453     ULONG CompletionTimeout:1;
3454     ULONG CompleterAbort:1;
3455     ULONG UnexpectedCompletion:1;
3456     ULONG ReceiverOverflow:1;
3457     ULONG MalformedTLP:1;
3458     ULONG ECRCError:1;
3459     ULONG UnsupportedRequestError:1;
3460     ULONG Reserved3:11;
3461   } DUMMYSTRUCTNAME;
3462   ULONG AsULONG;
3463 } PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK;
3464 
3465 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY {
3466   _ANONYMOUS_STRUCT struct {
3467     ULONG Undefined:1;
3468     ULONG Reserved1:3;
3469     ULONG DataLinkProtocolError:1;
3470     ULONG SurpriseDownError:1;
3471     ULONG Reserved2:6;
3472     ULONG PoisonedTLP:1;
3473     ULONG FlowControlProtocolError:1;
3474     ULONG CompletionTimeout:1;
3475     ULONG CompleterAbort:1;
3476     ULONG UnexpectedCompletion:1;
3477     ULONG ReceiverOverflow:1;
3478     ULONG MalformedTLP:1;
3479     ULONG ECRCError:1;
3480     ULONG UnsupportedRequestError:1;
3481     ULONG Reserved3:11;
3482   } DUMMYSTRUCTNAME;
3483   ULONG AsULONG;
3484 } PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY;
3485 
3486 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS {
3487   _ANONYMOUS_STRUCT struct {
3488     ULONG ReceiverError:1;
3489     ULONG Reserved1:5;
3490     ULONG BadTLP:1;
3491     ULONG BadDLLP:1;
3492     ULONG ReplayNumRollover:1;
3493     ULONG Reserved2:3;
3494     ULONG ReplayTimerTimeout:1;
3495     ULONG AdvisoryNonFatalError:1;
3496     ULONG Reserved3:18;
3497   } DUMMYSTRUCTNAME;
3498   ULONG AsULONG;
3499 } PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS;
3500 
3501 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK {
3502   _ANONYMOUS_STRUCT struct {
3503     ULONG ReceiverError:1;
3504     ULONG Reserved1:5;
3505     ULONG BadTLP:1;
3506     ULONG BadDLLP:1;
3507     ULONG ReplayNumRollover:1;
3508     ULONG Reserved2:3;
3509     ULONG ReplayTimerTimeout:1;
3510     ULONG AdvisoryNonFatalError:1;
3511     ULONG Reserved3:18;
3512   } DUMMYSTRUCTNAME;
3513   ULONG AsULONG;
3514 } PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK;
3515 
3516 typedef union _PCI_EXPRESS_AER_CAPABILITIES {
3517   _ANONYMOUS_STRUCT struct {
3518     ULONG FirstErrorPointer:5;
3519     ULONG ECRCGenerationCapable:1;
3520     ULONG ECRCGenerationEnable:1;
3521     ULONG ECRCCheckCapable:1;
3522     ULONG ECRCCheckEnable:1;
3523     ULONG Reserved:23;
3524   } DUMMYSTRUCTNAME;
3525   ULONG AsULONG;
3526 } PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES;
3527 
3528 typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND {
3529   _ANONYMOUS_STRUCT struct {
3530     ULONG CorrectableErrorReportingEnable:1;
3531     ULONG NonFatalErrorReportingEnable:1;
3532     ULONG FatalErrorReportingEnable:1;
3533     ULONG Reserved:29;
3534   } DUMMYSTRUCTNAME;
3535   ULONG AsULONG;
3536 } PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND;
3537 
3538 typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS {
3539   _ANONYMOUS_STRUCT struct {
3540     ULONG CorrectableErrorReceived:1;
3541     ULONG MultipleCorrectableErrorsReceived:1;
3542     ULONG UncorrectableErrorReceived:1;
3543     ULONG MultipleUncorrectableErrorsReceived:1;
3544     ULONG FirstUncorrectableFatal:1;
3545     ULONG NonFatalErrorMessagesReceived:1;
3546     ULONG FatalErrorMessagesReceived:1;
3547     ULONG Reserved:20;
3548     ULONG AdvancedErrorInterruptMessageNumber:5;
3549   } DUMMYSTRUCTNAME;
3550   ULONG AsULONG;
3551 } PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS;
3552 
3553 typedef union _PCI_EXPRESS_ERROR_SOURCE_ID {
3554   _ANONYMOUS_STRUCT struct {
3555     USHORT CorrectableSourceIdFun:3;
3556     USHORT CorrectableSourceIdDev:5;
3557     USHORT CorrectableSourceIdBus:8;
3558     USHORT UncorrectableSourceIdFun:3;
3559     USHORT UncorrectableSourceIdDev:5;
3560     USHORT UncorrectableSourceIdBus:8;
3561   } DUMMYSTRUCTNAME;
3562   ULONG AsULONG;
3563 } PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID;
3564 
3565 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS {
3566   _ANONYMOUS_STRUCT struct {
3567     ULONG TargetAbortOnSplitCompletion:1;
3568     ULONG MasterAbortOnSplitCompletion:1;
3569     ULONG ReceivedTargetAbort:1;
3570     ULONG ReceivedMasterAbort:1;
3571     ULONG RsvdZ:1;
3572     ULONG UnexpectedSplitCompletionError:1;
3573     ULONG UncorrectableSplitCompletion:1;
3574     ULONG UncorrectableDataError:1;
3575     ULONG UncorrectableAttributeError:1;
3576     ULONG UncorrectableAddressError:1;
3577     ULONG DelayedTransactionDiscardTimerExpired:1;
3578     ULONG PERRAsserted:1;
3579     ULONG SERRAsserted:1;
3580     ULONG InternalBridgeError:1;
3581     ULONG Reserved:18;
3582   } DUMMYSTRUCTNAME;
3583   ULONG AsULONG;
3584 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS;
3585 
3586 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK {
3587   _ANONYMOUS_STRUCT struct {
3588     ULONG TargetAbortOnSplitCompletion:1;
3589     ULONG MasterAbortOnSplitCompletion:1;
3590     ULONG ReceivedTargetAbort:1;
3591     ULONG ReceivedMasterAbort:1;
3592     ULONG RsvdZ:1;
3593     ULONG UnexpectedSplitCompletionError:1;
3594     ULONG UncorrectableSplitCompletion:1;
3595     ULONG UncorrectableDataError:1;
3596     ULONG UncorrectableAttributeError:1;
3597     ULONG UncorrectableAddressError:1;
3598     ULONG DelayedTransactionDiscardTimerExpired:1;
3599     ULONG PERRAsserted:1;
3600     ULONG SERRAsserted:1;
3601     ULONG InternalBridgeError:1;
3602     ULONG Reserved:18;
3603   } DUMMYSTRUCTNAME;
3604   ULONG AsULONG;
3605 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK;
3606 
3607 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY {
3608   _ANONYMOUS_STRUCT struct {
3609     ULONG TargetAbortOnSplitCompletion:1;
3610     ULONG MasterAbortOnSplitCompletion:1;
3611     ULONG ReceivedTargetAbort:1;
3612     ULONG ReceivedMasterAbort:1;
3613     ULONG RsvdZ:1;
3614     ULONG UnexpectedSplitCompletionError:1;
3615     ULONG UncorrectableSplitCompletion:1;
3616     ULONG UncorrectableDataError:1;
3617     ULONG UncorrectableAttributeError:1;
3618     ULONG UncorrectableAddressError:1;
3619     ULONG DelayedTransactionDiscardTimerExpired:1;
3620     ULONG PERRAsserted:1;
3621     ULONG SERRAsserted:1;
3622     ULONG InternalBridgeError:1;
3623     ULONG Reserved:18;
3624   } DUMMYSTRUCTNAME;
3625   ULONG AsULONG;
3626 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY;
3627 
3628 typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES {
3629   _ANONYMOUS_STRUCT struct {
3630     ULONG SecondaryUncorrectableFirstErrorPtr:5;
3631     ULONG Reserved:27;
3632   } DUMMYSTRUCTNAME;
3633   ULONG AsULONG;
3634 } PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES;
3635 
3636 #define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING  0x00000001
3637 #define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING     0x00000002
3638 #define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING        0x00000004
3639 
3640 #define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \
3641     (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \
3642      ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \
3643      ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING)
3644 
3645 typedef struct _PCI_EXPRESS_AER_CAPABILITY {
3646   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3647   PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3648   PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3649   PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3650   PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3651   PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3652   PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3653   ULONG HeaderLog[4];
3654   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
3655   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
3656   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
3657   PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
3658   ULONG SecHeaderLog[4];
3659 } PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY;
3660 
3661 typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY {
3662   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3663   PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3664   PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3665   PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3666   PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3667   PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3668   PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3669   ULONG HeaderLog[4];
3670   PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand;
3671   PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus;
3672   PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId;
3673 } PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY;
3674 
3675 typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY {
3676   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3677   PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3678   PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3679   PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3680   PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3681   PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3682   PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3683   ULONG HeaderLog[4];
3684   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
3685   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
3686   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
3687   PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
3688   ULONG SecHeaderLog[4];
3689 } PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY;
3690 
3691 typedef union _PCI_EXPRESS_SRIOV_CAPS {
3692   _ANONYMOUS_STRUCT struct {
3693     ULONG VFMigrationCapable:1;
3694     ULONG Reserved1:20;
3695     ULONG VFMigrationInterruptNumber:11;
3696   } DUMMYSTRUCTNAME;
3697   ULONG AsULONG;
3698 } PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS;
3699 
3700 typedef union _PCI_EXPRESS_SRIOV_CONTROL {
3701   _ANONYMOUS_STRUCT struct {
3702     USHORT VFEnable:1;
3703     USHORT VFMigrationEnable:1;
3704     USHORT VFMigrationInterruptEnable:1;
3705     USHORT VFMemorySpaceEnable:1;
3706     USHORT ARICapableHierarchy:1;
3707     USHORT Reserved1:11;
3708   } DUMMYSTRUCTNAME;
3709   USHORT AsUSHORT;
3710 } PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL;
3711 
3712 typedef union _PCI_EXPRESS_SRIOV_STATUS {
3713   _ANONYMOUS_STRUCT struct {
3714     USHORT VFMigrationStatus:1;
3715     USHORT Reserved1:15;
3716   } DUMMYSTRUCTNAME;
3717   USHORT AsUSHORT;
3718 } PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS;
3719 
3720 typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY {
3721   _ANONYMOUS_STRUCT struct {
3722     ULONG VFMigrationStateBIR:3;
3723     ULONG VFMigrationStateOffset:29;
3724   } DUMMYSTRUCTNAME;
3725   ULONG AsULONG;
3726 } PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY;
3727 
3728 typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY {
3729   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3730   PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities;
3731   PCI_EXPRESS_SRIOV_CONTROL SRIOVControl;
3732   PCI_EXPRESS_SRIOV_STATUS SRIOVStatus;
3733   USHORT InitialVFs;
3734   USHORT TotalVFs;
3735   USHORT NumVFs;
3736   UCHAR FunctionDependencyLink;
3737   UCHAR RsvdP1;
3738   USHORT FirstVFOffset;
3739   USHORT VFStride;
3740   USHORT RsvdP2;
3741   USHORT VFDeviceId;
3742   ULONG SupportedPageSizes;
3743   ULONG SystemPageSize;
3744   ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
3745   PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset;
3746 } PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY;
3747 
3748 /* PCI device classes */
3749 #define PCI_CLASS_PRE_20                    0x00
3750 #define PCI_CLASS_MASS_STORAGE_CTLR         0x01
3751 #define PCI_CLASS_NETWORK_CTLR              0x02
3752 #define PCI_CLASS_DISPLAY_CTLR              0x03
3753 #define PCI_CLASS_MULTIMEDIA_DEV            0x04
3754 #define PCI_CLASS_MEMORY_CTLR               0x05
3755 #define PCI_CLASS_BRIDGE_DEV                0x06
3756 #define PCI_CLASS_SIMPLE_COMMS_CTLR         0x07
3757 #define PCI_CLASS_BASE_SYSTEM_DEV           0x08
3758 #define PCI_CLASS_INPUT_DEV                 0x09
3759 #define PCI_CLASS_DOCKING_STATION           0x0a
3760 #define PCI_CLASS_PROCESSOR                 0x0b
3761 #define PCI_CLASS_SERIAL_BUS_CTLR           0x0c
3762 #define PCI_CLASS_WIRELESS_CTLR             0x0d
3763 #define PCI_CLASS_INTELLIGENT_IO_CTLR       0x0e
3764 #define PCI_CLASS_SATELLITE_COMMS_CTLR      0x0f
3765 #define PCI_CLASS_ENCRYPTION_DECRYPTION     0x10
3766 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC      0x11
3767 #define PCI_CLASS_NOT_DEFINED               0xff
3768 
3769 /* PCI device subclasses for class 0 */
3770 #define PCI_SUBCLASS_PRE_20_NON_VGA         0x00
3771 #define PCI_SUBCLASS_PRE_20_VGA             0x01
3772 
3773 /* PCI device subclasses for class 1 (mass storage controllers)*/
3774 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR      0x00
3775 #define PCI_SUBCLASS_MSC_IDE_CTLR           0x01
3776 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR        0x02
3777 #define PCI_SUBCLASS_MSC_IPI_CTLR           0x03
3778 #define PCI_SUBCLASS_MSC_RAID_CTLR          0x04
3779 #define PCI_SUBCLASS_MSC_OTHER              0x80
3780 
3781 /* PCI device subclasses for class 2 (network controllers)*/
3782 #define PCI_SUBCLASS_NET_ETHERNET_CTLR      0x00
3783 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR    0x01
3784 #define PCI_SUBCLASS_NET_FDDI_CTLR          0x02
3785 #define PCI_SUBCLASS_NET_ATM_CTLR           0x03
3786 #define PCI_SUBCLASS_NET_ISDN_CTLR          0x04
3787 #define PCI_SUBCLASS_NET_OTHER              0x80
3788 
3789 /* PCI device subclasses for class 3 (display controllers)*/
3790 #define PCI_SUBCLASS_VID_VGA_CTLR           0x00
3791 #define PCI_SUBCLASS_VID_XGA_CTLR           0x01
3792 #define PCI_SUBCLASS_VID_3D_CTLR            0x02
3793 #define PCI_SUBCLASS_VID_OTHER              0x80
3794 
3795 /* PCI device subclasses for class 4 (multimedia device)*/
3796 #define PCI_SUBCLASS_MM_VIDEO_DEV           0x00
3797 #define PCI_SUBCLASS_MM_AUDIO_DEV           0x01
3798 #define PCI_SUBCLASS_MM_TELEPHONY_DEV       0x02
3799 #define PCI_SUBCLASS_MM_OTHER               0x80
3800 
3801 /* PCI device subclasses for class 5 (memory controller)*/
3802 #define PCI_SUBCLASS_MEM_RAM                0x00
3803 #define PCI_SUBCLASS_MEM_FLASH              0x01
3804 #define PCI_SUBCLASS_MEM_OTHER              0x80
3805 
3806 /* PCI device subclasses for class 6 (bridge device)*/
3807 #define PCI_SUBCLASS_BR_HOST                0x00
3808 #define PCI_SUBCLASS_BR_ISA                 0x01
3809 #define PCI_SUBCLASS_BR_EISA                0x02
3810 #define PCI_SUBCLASS_BR_MCA                 0x03
3811 #define PCI_SUBCLASS_BR_PCI_TO_PCI          0x04
3812 #define PCI_SUBCLASS_BR_PCMCIA              0x05
3813 #define PCI_SUBCLASS_BR_NUBUS               0x06
3814 #define PCI_SUBCLASS_BR_CARDBUS             0x07
3815 #define PCI_SUBCLASS_BR_RACEWAY             0x08
3816 #define PCI_SUBCLASS_BR_OTHER               0x80
3817 
3818 #define PCI_SUBCLASS_COM_SERIAL             0x00
3819 #define PCI_SUBCLASS_COM_PARALLEL           0x01
3820 #define PCI_SUBCLASS_COM_MULTIPORT          0x02
3821 #define PCI_SUBCLASS_COM_MODEM              0x03
3822 #define PCI_SUBCLASS_COM_OTHER              0x80
3823 
3824 #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR     0x00
3825 #define PCI_SUBCLASS_SYS_DMA_CTLR           0x01
3826 #define PCI_SUBCLASS_SYS_SYSTEM_TIMER       0x02
3827 #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK    0x03
3828 #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR   0x04
3829 #define PCI_SUBCLASS_SYS_SDIO_CTRL          0x05
3830 #define PCI_SUBCLASS_SYS_OTHER              0x80
3831 
3832 #define PCI_SUBCLASS_INP_KEYBOARD           0x00
3833 #define PCI_SUBCLASS_INP_DIGITIZER          0x01
3834 #define PCI_SUBCLASS_INP_MOUSE              0x02
3835 #define PCI_SUBCLASS_INP_SCANNER            0x03
3836 #define PCI_SUBCLASS_INP_GAMEPORT           0x04
3837 #define PCI_SUBCLASS_INP_OTHER              0x80
3838 
3839 #define PCI_SUBCLASS_DOC_GENERIC            0x00
3840 #define PCI_SUBCLASS_DOC_OTHER              0x80
3841 
3842 #define PCI_SUBCLASS_PROC_386               0x00
3843 #define PCI_SUBCLASS_PROC_486               0x01
3844 #define PCI_SUBCLASS_PROC_PENTIUM           0x02
3845 #define PCI_SUBCLASS_PROC_ALPHA             0x10
3846 #define PCI_SUBCLASS_PROC_POWERPC           0x20
3847 #define PCI_SUBCLASS_PROC_COPROCESSOR       0x40
3848 
3849 /* PCI device subclasses for class C (serial bus controller)*/
3850 #define PCI_SUBCLASS_SB_IEEE1394            0x00
3851 #define PCI_SUBCLASS_SB_ACCESS              0x01
3852 #define PCI_SUBCLASS_SB_SSA                 0x02
3853 #define PCI_SUBCLASS_SB_USB                 0x03
3854 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL       0x04
3855 #define PCI_SUBCLASS_SB_SMBUS               0x05
3856 
3857 #define PCI_SUBCLASS_WIRELESS_IRDA          0x00
3858 #define PCI_SUBCLASS_WIRELESS_CON_IR        0x01
3859 #define PCI_SUBCLASS_WIRELESS_RF            0x10
3860 #define PCI_SUBCLASS_WIRELESS_OTHER         0x80
3861 
3862 #define PCI_SUBCLASS_INTIO_I2O              0x00
3863 
3864 #define PCI_SUBCLASS_SAT_TV                 0x01
3865 #define PCI_SUBCLASS_SAT_AUDIO              0x02
3866 #define PCI_SUBCLASS_SAT_VOICE              0x03
3867 #define PCI_SUBCLASS_SAT_DATA               0x04
3868 
3869 #define PCI_SUBCLASS_CRYPTO_NET_COMP        0x00
3870 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT   0x10
3871 #define PCI_SUBCLASS_CRYPTO_OTHER           0x80
3872 
3873 #define PCI_SUBCLASS_DASP_DPIO              0x00
3874 #define PCI_SUBCLASS_DASP_OTHER             0x80
3875 
3876 #define PCI_ADDRESS_IO_SPACE                0x00000001
3877 #define PCI_ADDRESS_MEMORY_TYPE_MASK        0x00000006
3878 #define PCI_ADDRESS_MEMORY_PREFETCHABLE     0x00000008
3879 #define PCI_ADDRESS_IO_ADDRESS_MASK         0xfffffffc
3880 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK     0xfffffff0
3881 #define PCI_ADDRESS_ROM_ADDRESS_MASK        0xfffff800
3882 
3883 #define PCI_TYPE_32BIT                      0
3884 #define PCI_TYPE_20BIT                      2
3885 #define PCI_TYPE_64BIT                      4
3886 
3887 #define PCI_ROMADDRESS_ENABLED              0x00000001
3888 
3889 #endif /* _PCI_X_ */
3890 
3891 #define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION       1
3892 
3893 _IRQL_requires_max_(PASSIVE_LEVEL)
3894 _Must_inspect_result_
3895 typedef NTSTATUS
3896 (NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)(
3897   _Inout_ PVOID Context);
3898 typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE;
3899 
3900 _IRQL_requires_max_(PASSIVE_LEVEL)
3901 _Must_inspect_result_
3902 typedef NTSTATUS
3903 (NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)(
3904   _Inout_ PVOID Context);
3905 typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE;
3906 
3907 typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE {
3908   USHORT Size;
3909   USHORT Version;
3910   PVOID Context;
3911   PINTERFACE_REFERENCE InterfaceReference;
3912   PINTERFACE_DEREFERENCE InterfaceDereference;
3913   PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode;
3914   PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode;
3915 } PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE;
3916 
3917 #define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION            1
3918 
3919 typedef ULONG
3920 (NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)(
3921   _In_ PVOID Context,
3922   _Out_writes_bytes_(Length) PVOID Buffer,
3923   _In_ ULONG Offset,
3924   _In_ ULONG Length);
3925 
3926 typedef ULONG
3927 (NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)(
3928   _In_ PVOID Context,
3929   _In_reads_bytes_(Length) PVOID Buffer,
3930   _In_ ULONG Offset,
3931   _In_ ULONG Length);
3932 
3933 typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE {
3934   USHORT Size;
3935   USHORT Version;
3936   PVOID Context;
3937   PINTERFACE_REFERENCE InterfaceReference;
3938   PINTERFACE_DEREFERENCE InterfaceDereference;
3939   PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace;
3940   PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace;
3941 } PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE;
3942 
3943 #define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION            1
3944 
3945 _Must_inspect_result_
3946 typedef NTSTATUS
3947 (NTAPI PCI_MSIX_SET_ENTRY)(
3948   _In_ PVOID Context,
3949   _In_ ULONG TableEntry,
3950   _In_ ULONG MessageNumber);
3951 typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY;
3952 
3953 _Must_inspect_result_
3954 typedef NTSTATUS
3955 (NTAPI PCI_MSIX_MASKUNMASK_ENTRY)(
3956   _In_ PVOID Context,
3957   _In_ ULONG TableEntry);
3958 typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY;
3959 
3960 _Must_inspect_result_
3961 typedef NTSTATUS
3962 (NTAPI PCI_MSIX_GET_ENTRY)(
3963   _In_ PVOID Context,
3964   _In_ ULONG TableEntry,
3965   _Out_ PULONG MessageNumber,
3966   _Out_ PBOOLEAN Masked);
3967 typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY;
3968 
3969 _Must_inspect_result_
3970 typedef NTSTATUS
3971 (NTAPI PCI_MSIX_GET_TABLE_SIZE)(
3972   _In_ PVOID Context,
3973   _Out_ PULONG TableSize);
3974 typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE;
3975 
3976 typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE {
3977   USHORT Size;
3978   USHORT Version;
3979   PVOID Context;
3980   PINTERFACE_REFERENCE InterfaceReference;
3981   PINTERFACE_DEREFERENCE InterfaceDereference;
3982   PPCI_MSIX_SET_ENTRY SetTableEntry;
3983   PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry;
3984   PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry;
3985   PPCI_MSIX_GET_ENTRY GetTableEntry;
3986   PPCI_MSIX_GET_TABLE_SIZE GetTableSize;
3987 } PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE;
3988 
3989 #define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \
3990         RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry)
3991 
3992 $endif (_WDMDDK_)
3993 $if (_NTDDK_)
3994 #ifndef _ARC_DDK_
3995 #define _ARC_DDK_
3996 typedef enum _CONFIGURATION_TYPE {
3997   ArcSystem,
3998   CentralProcessor,
3999   FloatingPointProcessor,
4000   PrimaryIcache,
4001   PrimaryDcache,
4002   SecondaryIcache,
4003   SecondaryDcache,
4004   SecondaryCache,
4005   EisaAdapter,
4006   TcAdapter,
4007   ScsiAdapter,
4008   DtiAdapter,
4009   MultiFunctionAdapter,
4010   DiskController,
4011   TapeController,
4012   CdromController,
4013   WormController,
4014   SerialController,
4015   NetworkController,
4016   DisplayController,
4017   ParallelController,
4018   PointerController,
4019   KeyboardController,
4020   AudioController,
4021   OtherController,
4022   DiskPeripheral,
4023   FloppyDiskPeripheral,
4024   TapePeripheral,
4025   ModemPeripheral,
4026   MonitorPeripheral,
4027   PrinterPeripheral,
4028   PointerPeripheral,
4029   KeyboardPeripheral,
4030   TerminalPeripheral,
4031   OtherPeripheral,
4032   LinePeripheral,
4033   NetworkPeripheral,
4034   SystemMemory,
4035   DockingInformation,
4036   RealModeIrqRoutingTable,
4037   RealModePCIEnumeration,
4038   MaximumType
4039 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
4040 #endif /* !_ARC_DDK_ */
4041 
4042 /*
4043 ** IRP function codes
4044 */
4045 
4046 #define IRP_MN_QUERY_DIRECTORY            0x01
4047 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY    0x02
4048 
4049 #define IRP_MN_USER_FS_REQUEST            0x00
4050 #define IRP_MN_MOUNT_VOLUME               0x01
4051 #define IRP_MN_VERIFY_VOLUME              0x02
4052 #define IRP_MN_LOAD_FILE_SYSTEM           0x03
4053 #define IRP_MN_TRACK_LINK                 0x04
4054 #define IRP_MN_KERNEL_CALL                0x04
4055 
4056 #define IRP_MN_LOCK                       0x01
4057 #define IRP_MN_UNLOCK_SINGLE              0x02
4058 #define IRP_MN_UNLOCK_ALL                 0x03
4059 #define IRP_MN_UNLOCK_ALL_BY_KEY          0x04
4060 
4061 #define IRP_MN_FLUSH_AND_PURGE          0x01
4062 
4063 #define IRP_MN_NORMAL                     0x00
4064 #define IRP_MN_DPC                        0x01
4065 #define IRP_MN_MDL                        0x02
4066 #define IRP_MN_COMPLETE                   0x04
4067 #define IRP_MN_COMPRESSED                 0x08
4068 
4069 #define IRP_MN_MDL_DPC                    (IRP_MN_MDL | IRP_MN_DPC)
4070 #define IRP_MN_COMPLETE_MDL               (IRP_MN_COMPLETE | IRP_MN_MDL)
4071 #define IRP_MN_COMPLETE_MDL_DPC           (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
4072 
4073 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
4074 
4075 #define IO_CHECK_CREATE_PARAMETERS      0x0200
4076 #define IO_ATTACH_DEVICE                0x0400
4077 #define IO_IGNORE_SHARE_ACCESS_CHECK    0x0800
4078 
4079 typedef NTSTATUS
4080 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
4081   _In_ PVOID Context,
4082   _In_ PUNICODE_STRING PathName,
4083   _In_ INTERFACE_TYPE BusType,
4084   _In_ ULONG BusNumber,
4085   _In_ PKEY_VALUE_FULL_INFORMATION *BusInformation,
4086   _In_ CONFIGURATION_TYPE ControllerType,
4087   _In_ ULONG ControllerNumber,
4088   _In_ PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
4089   _In_ CONFIGURATION_TYPE PeripheralType,
4090   _In_ ULONG PeripheralNumber,
4091   _In_ PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
4092 
4093 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
4094   IoQueryDeviceIdentifier = 0,
4095   IoQueryDeviceConfigurationData,
4096   IoQueryDeviceComponentInformation,
4097   IoQueryDeviceMaxData
4098 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
4099 
4100 typedef VOID
4101 (NTAPI *PDRIVER_REINITIALIZE)(
4102   _In_ struct _DRIVER_OBJECT *DriverObject,
4103   _In_opt_ PVOID Context,
4104   _In_ ULONG Count);
4105 
4106 typedef struct _CONTROLLER_OBJECT {
4107   CSHORT Type;
4108   CSHORT Size;
4109   PVOID ControllerExtension;
4110   KDEVICE_QUEUE DeviceWaitQueue;
4111   ULONG Spare1;
4112   LARGE_INTEGER Spare2;
4113 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
4114 
4115 #define DRVO_REINIT_REGISTERED          0x00000008
4116 #define DRVO_INITIALIZED                0x00000010
4117 #define DRVO_BOOTREINIT_REGISTERED      0x00000020
4118 #define DRVO_LEGACY_RESOURCES           0x00000040
4119 
4120 typedef struct _CONFIGURATION_INFORMATION {
4121   ULONG DiskCount;
4122   ULONG FloppyCount;
4123   ULONG CdRomCount;
4124   ULONG TapeCount;
4125   ULONG ScsiPortCount;
4126   ULONG SerialCount;
4127   ULONG ParallelCount;
4128   BOOLEAN AtDiskPrimaryAddressClaimed;
4129   BOOLEAN AtDiskSecondaryAddressClaimed;
4130   ULONG Version;
4131   ULONG MediumChangerCount;
4132 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
4133 
4134 typedef struct _DISK_SIGNATURE {
4135   ULONG PartitionStyle;
4136   _ANONYMOUS_UNION union {
4137     struct {
4138       ULONG Signature;
4139       ULONG CheckSum;
4140     } Mbr;
4141     struct {
4142       GUID DiskId;
4143     } Gpt;
4144   } DUMMYUNIONNAME;
4145 } DISK_SIGNATURE, *PDISK_SIGNATURE;
4146 
4147 typedef struct _TXN_PARAMETER_BLOCK {
4148   USHORT Length;
4149   USHORT TxFsContext;
4150   PVOID TransactionObject;
4151 } TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK;
4152 
4153 #define TXF_MINIVERSION_DEFAULT_VIEW        (0xFFFE)
4154 
4155 typedef struct _IO_DRIVER_CREATE_CONTEXT {
4156   CSHORT Size;
4157   struct _ECP_LIST *ExtraCreateParameter;
4158   PVOID DeviceObjectHint;
4159   PTXN_PARAMETER_BLOCK TxnParameters;
4160 } IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT;
4161 
4162 typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD {
4163   USHORT Size;
4164   USHORT Version;
4165   PVOID Context;
4166   PINTERFACE_REFERENCE InterfaceReference;
4167   PINTERFACE_DEREFERENCE InterfaceDereference;
4168   PGET_SET_DEVICE_DATA SetBusData;
4169   PGET_SET_DEVICE_DATA GetBusData;
4170   UCHAR CapabilityID;
4171 } AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD;
4172 
4173 _IRQL_requires_max_(PASSIVE_LEVEL)
4174 _Must_inspect_result_
4175 typedef NTSTATUS
4176 (NTAPI *PGET_LOCATION_STRING)(
4177   _Inout_opt_ PVOID Context,
4178   _Outptr_
4179   _At_(*LocationStrings,
4180     _When_(return == 0, __drv_allocatesMem(Mem)))
4181     PZZWSTR *LocationStrings);
4182 
4183 typedef struct _PNP_LOCATION_INTERFACE {
4184   USHORT Size;
4185   USHORT Version;
4186   PVOID Context;
4187   PINTERFACE_REFERENCE InterfaceReference;
4188   PINTERFACE_DEREFERENCE InterfaceDereference;
4189   PGET_LOCATION_STRING GetLocationString;
4190 } PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE;
4191 
4192 typedef enum _ARBITER_ACTION {
4193   ArbiterActionTestAllocation,
4194   ArbiterActionRetestAllocation,
4195   ArbiterActionCommitAllocation,
4196   ArbiterActionRollbackAllocation,
4197   ArbiterActionQueryAllocatedResources,
4198   ArbiterActionWriteReservedResources,
4199   ArbiterActionQueryConflict,
4200   ArbiterActionQueryArbitrate,
4201   ArbiterActionAddReserved,
4202   ArbiterActionBootAllocation
4203 } ARBITER_ACTION, *PARBITER_ACTION;
4204 
4205 typedef struct _ARBITER_CONFLICT_INFO {
4206   PDEVICE_OBJECT OwningObject;
4207   ULONGLONG Start;
4208   ULONGLONG End;
4209 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
4210 
4211 typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS {
4212   _Inout_ PLIST_ENTRY ArbitrationList;
4213   _In_ ULONG AllocateFromCount;
4214   _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
4215 } ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS;
4216 
4217 typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS {
4218   _Inout_ PLIST_ENTRY ArbitrationList;
4219   _In_ ULONG AllocateFromCount;
4220   _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
4221 } ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS;
4222 
4223 typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS {
4224   _Inout_ PLIST_ENTRY ArbitrationList;
4225 } ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS;
4226 
4227 typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS {
4228   _Out_ PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
4229 } ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS;
4230 
4231 typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS {
4232   _In_ PDEVICE_OBJECT PhysicalDeviceObject;
4233   _In_ PIO_RESOURCE_DESCRIPTOR ConflictingResource;
4234   _Out_ PULONG ConflictCount;
4235   _Out_ PARBITER_CONFLICT_INFO *Conflicts;
4236 } ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS;
4237 
4238 typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS {
4239   _In_ PLIST_ENTRY ArbitrationList;
4240 } ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS;
4241 
4242 typedef struct _ARBITER_ADD_RESERVED_PARAMETERS {
4243   _In_ PDEVICE_OBJECT ReserveDevice;
4244 } ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS;
4245 
4246 typedef struct _ARBITER_PARAMETERS {
4247   union {
4248     ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation;
4249     ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation;
4250     ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation;
4251     ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources;
4252     ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict;
4253     ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate;
4254     ARBITER_ADD_RESERVED_PARAMETERS AddReserved;
4255   } Parameters;
4256 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
4257 
4258 typedef enum _ARBITER_REQUEST_SOURCE {
4259   ArbiterRequestUndefined = -1,
4260   ArbiterRequestLegacyReported,
4261   ArbiterRequestHalReported,
4262   ArbiterRequestLegacyAssigned,
4263   ArbiterRequestPnpDetected,
4264   ArbiterRequestPnpEnumerated
4265 } ARBITER_REQUEST_SOURCE;
4266 
4267 typedef enum _ARBITER_RESULT {
4268   ArbiterResultUndefined = -1,
4269   ArbiterResultSuccess,
4270   ArbiterResultExternalConflict,
4271   ArbiterResultNullRequest
4272 } ARBITER_RESULT;
4273 
4274 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
4275 
4276 typedef struct _ARBITER_LIST_ENTRY {
4277   LIST_ENTRY ListEntry;
4278   ULONG AlternativeCount;
4279   PIO_RESOURCE_DESCRIPTOR Alternatives;
4280   PDEVICE_OBJECT PhysicalDeviceObject;
4281   ARBITER_REQUEST_SOURCE RequestSource;
4282   ULONG Flags;
4283   LONG_PTR WorkSpace;
4284   INTERFACE_TYPE InterfaceType;
4285   ULONG SlotNumber;
4286   ULONG BusNumber;
4287   PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
4288   PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
4289   ARBITER_RESULT Result;
4290 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
4291 
4292 typedef NTSTATUS
4293 (NTAPI *PARBITER_HANDLER)(
4294   _Inout_opt_ PVOID Context,
4295   _In_ ARBITER_ACTION Action,
4296   _Inout_ PARBITER_PARAMETERS Parameters);
4297 
4298 #define ARBITER_PARTIAL 0x00000001
4299 
4300 typedef struct _ARBITER_INTERFACE {
4301   USHORT Size;
4302   USHORT Version;
4303   PVOID Context;
4304   PINTERFACE_REFERENCE InterfaceReference;
4305   PINTERFACE_DEREFERENCE InterfaceDereference;
4306   PARBITER_HANDLER ArbiterHandler;
4307   ULONG Flags;
4308 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
4309 
4310 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
4311   TranslateChildToParent,
4312   TranslateParentToChild
4313 } RESOURCE_TRANSLATION_DIRECTION;
4314 
4315 typedef NTSTATUS
4316 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
4317   _Inout_opt_ PVOID Context,
4318   _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
4319   _In_ RESOURCE_TRANSLATION_DIRECTION Direction,
4320   _In_opt_ ULONG AlternativesCount,
4321   _In_reads_opt_(AlternativesCount) IO_RESOURCE_DESCRIPTOR Alternatives[],
4322   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
4323   _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
4324 
4325 typedef NTSTATUS
4326 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
4327   _Inout_opt_ PVOID Context,
4328   _In_ PIO_RESOURCE_DESCRIPTOR Source,
4329   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
4330   _Out_ PULONG TargetCount,
4331   _Out_writes_(*TargetCount) PIO_RESOURCE_DESCRIPTOR *Target);
4332 
4333 typedef struct _TRANSLATOR_INTERFACE {
4334   USHORT Size;
4335   USHORT Version;
4336   PVOID Context;
4337   PINTERFACE_REFERENCE InterfaceReference;
4338   PINTERFACE_DEREFERENCE InterfaceDereference;
4339   PTRANSLATE_RESOURCE_HANDLER TranslateResources;
4340   PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
4341 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
4342 
4343 typedef struct _PCI_AGP_CAPABILITY {
4344   PCI_CAPABILITIES_HEADER Header;
4345   USHORT Minor:4;
4346   USHORT Major:4;
4347   USHORT Rsvd1:8;
4348   struct _PCI_AGP_STATUS {
4349     ULONG Rate:3;
4350     ULONG Agp3Mode:1;
4351     ULONG FastWrite:1;
4352     ULONG FourGB:1;
4353     ULONG HostTransDisable:1;
4354     ULONG Gart64:1;
4355     ULONG ITA_Coherent:1;
4356     ULONG SideBandAddressing:1;
4357     ULONG CalibrationCycle:3;
4358     ULONG AsyncRequestSize:3;
4359     ULONG Rsvd1:1;
4360     ULONG Isoch:1;
4361     ULONG Rsvd2:6;
4362     ULONG RequestQueueDepthMaximum:8;
4363   } AGPStatus;
4364   struct _PCI_AGP_COMMAND {
4365     ULONG Rate:3;
4366     ULONG Rsvd1:1;
4367     ULONG FastWriteEnable:1;
4368     ULONG FourGBEnable:1;
4369     ULONG Rsvd2:1;
4370     ULONG Gart64:1;
4371     ULONG AGPEnable:1;
4372     ULONG SBAEnable:1;
4373     ULONG CalibrationCycle:3;
4374     ULONG AsyncReqSize:3;
4375     ULONG Rsvd3:8;
4376     ULONG RequestQueueDepth:8;
4377   } AGPCommand;
4378 } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
4379 
4380 typedef enum _EXTENDED_AGP_REGISTER {
4381   IsochStatus,
4382   AgpControl,
4383   ApertureSize,
4384   AperturePageSize,
4385   GartLow,
4386   GartHigh,
4387   IsochCommand
4388 } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
4389 
4390 typedef struct _PCI_AGP_ISOCH_STATUS {
4391   ULONG ErrorCode:2;
4392   ULONG Rsvd1:1;
4393   ULONG Isoch_L:3;
4394   ULONG Isoch_Y:2;
4395   ULONG Isoch_N:8;
4396   ULONG Rsvd2:16;
4397 } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
4398 
4399 typedef struct _PCI_AGP_CONTROL {
4400   ULONG Rsvd1:7;
4401   ULONG GTLB_Enable:1;
4402   ULONG AP_Enable:1;
4403   ULONG CAL_Disable:1;
4404   ULONG Rsvd2:22;
4405 } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
4406 
4407 typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
4408   USHORT PageSizeMask:11;
4409   USHORT Rsvd1:1;
4410   USHORT PageSizeSelect:4;
4411 } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
4412 
4413 typedef struct _PCI_AGP_ISOCH_COMMAND {
4414   USHORT Rsvd1:6;
4415   USHORT Isoch_Y:2;
4416   USHORT Isoch_N:8;
4417 } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
4418 
4419 typedef struct PCI_AGP_EXTENDED_CAPABILITY {
4420   PCI_AGP_ISOCH_STATUS IsochStatus;
4421   PCI_AGP_CONTROL AgpControl;
4422   USHORT ApertureSize;
4423   PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
4424   ULONG GartLow;
4425   ULONG GartHigh;
4426   PCI_AGP_ISOCH_COMMAND IsochCommand;
4427 } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
4428 
4429 #define PCI_AGP_RATE_1X     0x1
4430 #define PCI_AGP_RATE_2X     0x2
4431 #define PCI_AGP_RATE_4X     0x4
4432 
4433 #define PCIX_MODE_CONVENTIONAL_PCI  0x0
4434 #define PCIX_MODE1_66MHZ            0x1
4435 #define PCIX_MODE1_100MHZ           0x2
4436 #define PCIX_MODE1_133MHZ           0x3
4437 #define PCIX_MODE2_266_66MHZ        0x9
4438 #define PCIX_MODE2_266_100MHZ       0xA
4439 #define PCIX_MODE2_266_133MHZ       0xB
4440 #define PCIX_MODE2_533_66MHZ        0xD
4441 #define PCIX_MODE2_533_100MHZ       0xE
4442 #define PCIX_MODE2_533_133MHZ       0xF
4443 
4444 #define PCIX_VERSION_MODE1_ONLY     0x0
4445 #define PCIX_VERSION_MODE2_ECC      0x1
4446 #define PCIX_VERSION_DUAL_MODE_ECC  0x2
4447 
4448 typedef struct _PCIX_BRIDGE_CAPABILITY {
4449   PCI_CAPABILITIES_HEADER Header;
4450   union {
4451     _ANONYMOUS_STRUCT struct {
4452       USHORT Bus64Bit:1;
4453       USHORT Bus133MHzCapable:1;
4454       USHORT SplitCompletionDiscarded:1;
4455       USHORT UnexpectedSplitCompletion:1;
4456       USHORT SplitCompletionOverrun:1;
4457       USHORT SplitRequestDelayed:1;
4458       USHORT BusModeFrequency:4;
4459       USHORT Rsvd:2;
4460       USHORT Version:2;
4461       USHORT Bus266MHzCapable:1;
4462       USHORT Bus533MHzCapable:1;
4463     } DUMMYSTRUCTNAME;
4464   USHORT AsUSHORT;
4465   } SecondaryStatus;
4466   union {
4467     _ANONYMOUS_STRUCT struct {
4468       ULONG FunctionNumber:3;
4469       ULONG DeviceNumber:5;
4470       ULONG BusNumber:8;
4471       ULONG Device64Bit:1;
4472       ULONG Device133MHzCapable:1;
4473       ULONG SplitCompletionDiscarded:1;
4474       ULONG UnexpectedSplitCompletion:1;
4475       ULONG SplitCompletionOverrun:1;
4476       ULONG SplitRequestDelayed:1;
4477       ULONG Rsvd:7;
4478       ULONG DIMCapable:1;
4479       ULONG Device266MHzCapable:1;
4480       ULONG Device533MHzCapable:1;
4481     } DUMMYSTRUCTNAME;
4482     ULONG AsULONG;
4483   } BridgeStatus;
4484   USHORT UpstreamSplitTransactionCapacity;
4485   USHORT UpstreamSplitTransactionLimit;
4486   USHORT DownstreamSplitTransactionCapacity;
4487   USHORT DownstreamSplitTransactionLimit;
4488   union {
4489     _ANONYMOUS_STRUCT struct {
4490       ULONG SelectSecondaryRegisters:1;
4491       ULONG ErrorPresentInOtherBank:1;
4492       ULONG AdditionalCorrectableError:1;
4493       ULONG AdditionalUncorrectableError:1;
4494       ULONG ErrorPhase:3;
4495       ULONG ErrorCorrected:1;
4496       ULONG Syndrome:8;
4497       ULONG ErrorFirstCommand:4;
4498       ULONG ErrorSecondCommand:4;
4499       ULONG ErrorUpperAttributes:4;
4500       ULONG ControlUpdateEnable:1;
4501       ULONG Rsvd:1;
4502       ULONG DisableSingleBitCorrection:1;
4503       ULONG EccMode:1;
4504     } DUMMYSTRUCTNAME;
4505   ULONG AsULONG;
4506   } EccControlStatus;
4507   ULONG EccFirstAddress;
4508   ULONG EccSecondAddress;
4509   ULONG EccAttribute;
4510 } PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY;
4511 
4512 typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY {
4513   PCI_CAPABILITIES_HEADER Header;
4514   USHORT Reserved;
4515   USHORT SubVendorID;
4516   USHORT SubSystemID;
4517 } PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY;
4518 
4519 #define OSC_FIRMWARE_FAILURE                            0x02
4520 #define OSC_UNRECOGNIZED_UUID                           0x04
4521 #define OSC_UNRECOGNIZED_REVISION                       0x08
4522 #define OSC_CAPABILITIES_MASKED                         0x10
4523 
4524 #define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION     0x01
4525 
4526 typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD {
4527   union {
4528     _ANONYMOUS_STRUCT struct {
4529       ULONG ExtendedConfigOpRegions:1;
4530       ULONG ActiveStatePowerManagement:1;
4531       ULONG ClockPowerManagement:1;
4532       ULONG SegmentGroups:1;
4533       ULONG MessageSignaledInterrupts:1;
4534       ULONG WindowsHardwareErrorArchitecture:1;
4535       ULONG Reserved:26;
4536     } DUMMYSTRUCTNAME;
4537     ULONG AsULONG;
4538   } u;
4539 } PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD;
4540 
4541 typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD {
4542   union {
4543     _ANONYMOUS_STRUCT struct {
4544       ULONG ExpressNativeHotPlug:1;
4545       ULONG ShpcNativeHotPlug:1;
4546       ULONG ExpressNativePME:1;
4547       ULONG ExpressAdvancedErrorReporting:1;
4548       ULONG ExpressCapabilityStructure:1;
4549       ULONG Reserved:27;
4550     } DUMMYSTRUCTNAME;
4551   ULONG AsULONG;
4552   } u;
4553 } PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD;
4554 
4555 typedef enum _PCI_HARDWARE_INTERFACE {
4556   PciConventional,
4557   PciXMode1,
4558   PciXMode2,
4559   PciExpress
4560 } PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE;
4561 
4562 typedef enum {
4563   BusWidth32Bits,
4564   BusWidth64Bits
4565 } PCI_BUS_WIDTH;
4566 
4567 typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY {
4568   PCI_HARDWARE_INTERFACE SecondaryInterface;
4569   _ANONYMOUS_STRUCT struct {
4570     BOOLEAN BusCapabilitiesFound;
4571     ULONG CurrentSpeedAndMode;
4572     ULONG SupportedSpeedsAndModes;
4573     BOOLEAN DeviceIDMessagingCapable;
4574     PCI_BUS_WIDTH SecondaryBusWidth;
4575   } DUMMYSTRUCTNAME;
4576   PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport;
4577   PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest;
4578   PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted;
4579 } PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY;
4580 
4581 typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER {
4582   _ANONYMOUS_STRUCT struct {
4583     USHORT CapabilityVersion:4;
4584     USHORT DeviceType:4;
4585     USHORT SlotImplemented:1;
4586     USHORT InterruptMessageNumber:5;
4587     USHORT Rsvd:2;
4588   } DUMMYSTRUCTNAME;
4589   USHORT AsUSHORT;
4590 } PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER;
4591 
4592 typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER {
4593   _ANONYMOUS_STRUCT struct {
4594     ULONG MaxPayloadSizeSupported:3;
4595     ULONG PhantomFunctionsSupported:2;
4596     ULONG ExtendedTagSupported:1;
4597     ULONG L0sAcceptableLatency:3;
4598     ULONG L1AcceptableLatency:3;
4599     ULONG Undefined:3;
4600     ULONG RoleBasedErrorReporting:1;
4601     ULONG Rsvd1:2;
4602     ULONG CapturedSlotPowerLimit:8;
4603     ULONG CapturedSlotPowerLimitScale:2;
4604     ULONG Rsvd2:4;
4605   } DUMMYSTRUCTNAME;
4606   ULONG AsULONG;
4607 } PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER;
4608 
4609 #define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07;
4610 
4611 typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER {
4612   _ANONYMOUS_STRUCT struct {
4613     USHORT CorrectableErrorEnable:1;
4614     USHORT NonFatalErrorEnable:1;
4615     USHORT FatalErrorEnable:1;
4616     USHORT UnsupportedRequestErrorEnable:1;
4617     USHORT EnableRelaxedOrder:1;
4618     USHORT MaxPayloadSize:3;
4619     USHORT ExtendedTagEnable:1;
4620     USHORT PhantomFunctionsEnable:1;
4621     USHORT AuxPowerEnable:1;
4622     USHORT NoSnoopEnable:1;
4623     USHORT MaxReadRequestSize:3;
4624     USHORT BridgeConfigRetryEnable:1;
4625   } DUMMYSTRUCTNAME;
4626   USHORT AsUSHORT;
4627 } PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER;
4628 
4629 #define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F;
4630 
4631 typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER {
4632   _ANONYMOUS_STRUCT struct {
4633     USHORT CorrectableErrorDetected:1;
4634     USHORT NonFatalErrorDetected:1;
4635     USHORT FatalErrorDetected:1;
4636     USHORT UnsupportedRequestDetected:1;
4637     USHORT AuxPowerDetected:1;
4638     USHORT TransactionsPending:1;
4639     USHORT Rsvd:10;
4640   } DUMMYSTRUCTNAME;
4641   USHORT AsUSHORT;
4642 } PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER;
4643 
4644 typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER {
4645   _ANONYMOUS_STRUCT struct {
4646     ULONG MaximumLinkSpeed:4;
4647     ULONG MaximumLinkWidth:6;
4648     ULONG ActiveStatePMSupport:2;
4649     ULONG L0sExitLatency:3;
4650     ULONG L1ExitLatency:3;
4651     ULONG ClockPowerManagement:1;
4652     ULONG SurpriseDownErrorReportingCapable:1;
4653     ULONG DataLinkLayerActiveReportingCapable:1;
4654     ULONG Rsvd:3;
4655     ULONG PortNumber:8;
4656   } DUMMYSTRUCTNAME;
4657   ULONG AsULONG;
4658 } PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER;
4659 
4660 typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER {
4661   _ANONYMOUS_STRUCT struct {
4662     USHORT ActiveStatePMControl:2;
4663     USHORT Rsvd1:1;
4664     USHORT ReadCompletionBoundary:1;
4665     USHORT LinkDisable:1;
4666     USHORT RetrainLink:1;
4667     USHORT CommonClockConfig:1;
4668     USHORT ExtendedSynch:1;
4669     USHORT EnableClockPowerManagement:1;
4670     USHORT Rsvd2:7;
4671   } DUMMYSTRUCTNAME;
4672   USHORT AsUSHORT;
4673 } PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER;
4674 
4675 typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER {
4676   _ANONYMOUS_STRUCT struct {
4677     USHORT LinkSpeed:4;
4678     USHORT LinkWidth:6;
4679     USHORT Undefined:1;
4680     USHORT LinkTraining:1;
4681     USHORT SlotClockConfig:1;
4682     USHORT DataLinkLayerActive:1;
4683     USHORT Rsvd:2;
4684   } DUMMYSTRUCTNAME;
4685   USHORT AsUSHORT;
4686 } PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER;
4687 
4688 typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER {
4689   _ANONYMOUS_STRUCT struct {
4690     ULONG AttentionButtonPresent:1;
4691     ULONG PowerControllerPresent:1;
4692     ULONG MRLSensorPresent:1;
4693     ULONG AttentionIndicatorPresent:1;
4694     ULONG PowerIndicatorPresent:1;
4695     ULONG HotPlugSurprise:1;
4696     ULONG HotPlugCapable:1;
4697     ULONG SlotPowerLimit:8;
4698     ULONG SlotPowerLimitScale:2;
4699     ULONG ElectromechanicalLockPresent:1;
4700     ULONG NoCommandCompletedSupport:1;
4701     ULONG PhysicalSlotNumber:13;
4702   } DUMMYSTRUCTNAME;
4703   ULONG AsULONG;
4704 } PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER;
4705 
4706 typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER {
4707   _ANONYMOUS_STRUCT struct {
4708     USHORT AttentionButtonEnable:1;
4709     USHORT PowerFaultDetectEnable:1;
4710     USHORT MRLSensorEnable:1;
4711     USHORT PresenceDetectEnable:1;
4712     USHORT CommandCompletedEnable:1;
4713     USHORT HotPlugInterruptEnable:1;
4714     USHORT AttentionIndicatorControl:2;
4715     USHORT PowerIndicatorControl:2;
4716     USHORT PowerControllerControl:1;
4717     USHORT ElectromechanicalLockControl:1;
4718     USHORT DataLinkStateChangeEnable:1;
4719     USHORT Rsvd:3;
4720   } DUMMYSTRUCTNAME;
4721   USHORT AsUSHORT;
4722 } PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER;
4723 
4724 typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER {
4725   _ANONYMOUS_STRUCT struct {
4726     USHORT AttentionButtonPressed:1;
4727     USHORT PowerFaultDetected:1;
4728     USHORT MRLSensorChanged:1;
4729     USHORT PresenceDetectChanged:1;
4730     USHORT CommandCompleted:1;
4731     USHORT MRLSensorState:1;
4732     USHORT PresenceDetectState:1;
4733     USHORT ElectromechanicalLockEngaged:1;
4734     USHORT DataLinkStateChanged:1;
4735     USHORT Rsvd:7;
4736   } DUMMYSTRUCTNAME;
4737   USHORT AsUSHORT;
4738 } PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER;
4739 
4740 typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER {
4741   _ANONYMOUS_STRUCT struct {
4742     USHORT CorrectableSerrEnable:1;
4743     USHORT NonFatalSerrEnable:1;
4744     USHORT FatalSerrEnable:1;
4745     USHORT PMEInterruptEnable:1;
4746     USHORT CRSSoftwareVisibilityEnable:1;
4747     USHORT Rsvd:11;
4748   } DUMMYSTRUCTNAME;
4749   USHORT AsUSHORT;
4750 } PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER;
4751 
4752 typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER {
4753   _ANONYMOUS_STRUCT struct {
4754     USHORT CRSSoftwareVisibility:1;
4755     USHORT Rsvd:15;
4756   } DUMMYSTRUCTNAME;
4757   USHORT AsUSHORT;
4758 } PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER;
4759 
4760 typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER {
4761   _ANONYMOUS_STRUCT struct {
4762     ULONG PMERequestorId:16;
4763     ULONG PMEStatus:1;
4764     ULONG PMEPending:1;
4765     ULONG Rsvd:14;
4766   } DUMMYSTRUCTNAME;
4767   ULONG AsULONG;
4768 } PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER;
4769 
4770 typedef struct _PCI_EXPRESS_CAPABILITY {
4771   PCI_CAPABILITIES_HEADER Header;
4772   PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities;
4773   PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities;
4774   PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl;
4775   PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus;
4776   PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities;
4777   PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl;
4778   PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus;
4779   PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities;
4780   PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl;
4781   PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus;
4782   PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl;
4783   PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities;
4784   PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus;
4785 } PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY;
4786 
4787 typedef enum {
4788   MRLClosed = 0,
4789   MRLOpen
4790 } PCI_EXPRESS_MRL_STATE;
4791 
4792 typedef enum {
4793   SlotEmpty = 0,
4794   CardPresent
4795 } PCI_EXPRESS_CARD_PRESENCE;
4796 
4797 typedef enum {
4798   IndicatorOn = 1,
4799   IndicatorBlink,
4800   IndicatorOff
4801 } PCI_EXPRESS_INDICATOR_STATE;
4802 
4803 typedef enum {
4804   PowerOn = 0,
4805   PowerOff
4806 } PCI_EXPRESS_POWER_STATE;
4807 
4808 typedef enum {
4809   L0sEntrySupport = 1,
4810   L0sAndL1EntrySupport = 3
4811 } PCI_EXPRESS_ASPM_SUPPORT;
4812 
4813 typedef enum {
4814   L0sAndL1EntryDisabled,
4815   L0sEntryEnabled,
4816   L1EntryEnabled,
4817   L0sAndL1EntryEnabled
4818 } PCI_EXPRESS_ASPM_CONTROL;
4819 
4820 typedef enum {
4821   L0s_Below64ns = 0,
4822   L0s_64ns_128ns,
4823   L0s_128ns_256ns,
4824   L0s_256ns_512ns,
4825   L0s_512ns_1us,
4826   L0s_1us_2us,
4827   L0s_2us_4us,
4828   L0s_Above4us
4829 } PCI_EXPRESS_L0s_EXIT_LATENCY;
4830 
4831 typedef enum {
4832   L1_Below1us = 0,
4833   L1_1us_2us,
4834   L1_2us_4us,
4835   L1_4us_8us,
4836   L1_8us_16us,
4837   L1_16us_32us,
4838   L1_32us_64us,
4839   L1_Above64us
4840 } PCI_EXPRESS_L1_EXIT_LATENCY;
4841 
4842 typedef enum {
4843   PciExpressEndpoint = 0,
4844   PciExpressLegacyEndpoint,
4845   PciExpressRootPort = 4,
4846   PciExpressUpstreamSwitchPort,
4847   PciExpressDownstreamSwitchPort,
4848   PciExpressToPciXBridge,
4849   PciXToExpressBridge,
4850   PciExpressRootComplexIntegratedEndpoint,
4851   PciExpressRootComplexEventCollector
4852 } PCI_EXPRESS_DEVICE_TYPE;
4853 
4854 typedef enum {
4855   MaxPayload128Bytes = 0,
4856   MaxPayload256Bytes,
4857   MaxPayload512Bytes,
4858   MaxPayload1024Bytes,
4859   MaxPayload2048Bytes,
4860   MaxPayload4096Bytes
4861 } PCI_EXPRESS_MAX_PAYLOAD_SIZE;
4862 
4863 typedef union _PCI_EXPRESS_PME_REQUESTOR_ID {
4864   _ANONYMOUS_STRUCT struct {
4865     USHORT FunctionNumber:3;
4866     USHORT DeviceNumber:5;
4867     USHORT BusNumber:8;
4868   } DUMMYSTRUCTNAME;
4869   USHORT AsUSHORT;
4870 } PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID;
4871 
4872 typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE {
4873   ResourceTypeSingle = 0,
4874   ResourceTypeRange,
4875   ResourceTypeExtendedCounterConfiguration,
4876   ResourceTypeOverflow,
4877   ResourceTypeMax
4878 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE;
4879 
4880 typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR {
4881   PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type;
4882   ULONG Flags;
4883   union {
4884     ULONG CounterIndex;
4885     ULONG ExtendedRegisterAddress;
4886     struct {
4887       ULONG Begin;
4888       ULONG End;
4889     } Range;
4890   } u;
4891 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR;
4892 
4893 typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST {
4894   ULONG Count;
4895   PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY];
4896 } PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST;
4897 
4898 typedef VOID
4899 (NTAPI *PciPin2Line)(
4900   _In_ struct _BUS_HANDLER *BusHandler,
4901   _In_ struct _BUS_HANDLER *RootHandler,
4902   _In_ PCI_SLOT_NUMBER SlotNumber,
4903   _In_ PPCI_COMMON_CONFIG PciData);
4904 
4905 typedef VOID
4906 (NTAPI *PciLine2Pin)(
4907   _In_ struct _BUS_HANDLER *BusHandler,
4908   _In_ struct _BUS_HANDLER *RootHandler,
4909   _In_ PCI_SLOT_NUMBER SlotNumber,
4910   _In_ PPCI_COMMON_CONFIG PciNewData,
4911   _In_ PPCI_COMMON_CONFIG PciOldData);
4912 
4913 typedef VOID
4914 (NTAPI *PciReadWriteConfig)(
4915   _In_ struct _BUS_HANDLER *BusHandler,
4916   _In_ PCI_SLOT_NUMBER Slot,
4917   _In_reads_bytes_(Length) PVOID Buffer,
4918   _In_ ULONG Offset,
4919   _In_ ULONG Length);
4920 
4921 #define PCI_DATA_TAG ' ICP'
4922 #define PCI_DATA_VERSION 1
4923 
4924 typedef struct _PCIBUSDATA {
4925   ULONG Tag;
4926   ULONG Version;
4927   PciReadWriteConfig ReadConfig;
4928   PciReadWriteConfig WriteConfig;
4929   PciPin2Line Pin2Line;
4930   PciLine2Pin Line2Pin;
4931   PCI_SLOT_NUMBER ParentSlot;
4932   PVOID Reserved[4];
4933 } PCIBUSDATA, *PPCIBUSDATA;
4934 
4935 #ifndef _PCIINTRF_X_
4936 #define _PCIINTRF_X_
4937 
4938 typedef ULONG
4939 (NTAPI *PCI_READ_WRITE_CONFIG)(
4940   _In_ PVOID Context,
4941   _In_ ULONG BusOffset,
4942   _In_ ULONG Slot,
4943   _In_reads_bytes_(Length) PVOID Buffer,
4944   _In_ ULONG Offset,
4945   _In_ ULONG Length);
4946 
4947 typedef VOID
4948 (NTAPI *PCI_PIN_TO_LINE)(
4949   _In_ PVOID Context,
4950   _In_ PPCI_COMMON_CONFIG PciData);
4951 
4952 typedef VOID
4953 (NTAPI *PCI_LINE_TO_PIN)(
4954   _In_ PVOID Context,
4955   _In_ PPCI_COMMON_CONFIG PciNewData,
4956   _In_ PPCI_COMMON_CONFIG PciOldData);
4957 
4958 typedef VOID
4959 (NTAPI *PCI_ROOT_BUS_CAPABILITY)(
4960   _In_ PVOID Context,
4961   _Out_ PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability);
4962 
4963 typedef VOID
4964 (NTAPI *PCI_EXPRESS_WAKE_CONTROL)(
4965   _In_ PVOID Context,
4966   _In_ BOOLEAN EnableWake);
4967 
4968 typedef struct _PCI_BUS_INTERFACE_STANDARD {
4969   USHORT Size;
4970   USHORT Version;
4971   PVOID Context;
4972   PINTERFACE_REFERENCE InterfaceReference;
4973   PINTERFACE_DEREFERENCE InterfaceDereference;
4974   PCI_READ_WRITE_CONFIG ReadConfig;
4975   PCI_READ_WRITE_CONFIG WriteConfig;
4976   PCI_PIN_TO_LINE PinToLine;
4977   PCI_LINE_TO_PIN LineToPin;
4978   PCI_ROOT_BUS_CAPABILITY RootBusCapability;
4979   PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl;
4980 } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
4981 
4982 #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
4983 
4984 #endif /* _PCIINTRF_X_ */
4985 
4986 #if (NTDDI_VERSION >= NTDDI_WIN7)
4987 
4988 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX     0x00004000
4989 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX    0x00008000
4990 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \
4991   (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \
4992    FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX)
4993 
4994 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200
4995 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300
4996 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300
4997 
4998 #else
4999 
5000 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL     0x00000200
5001 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL    0x00000300
5002 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK        0x00000300
5003 
5004 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL
5005 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL
5006 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK
5007 
5008 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
5009 
5010 #define FILE_CHARACTERISTICS_PROPAGATED (FILE_REMOVABLE_MEDIA  | \
5011                                          FILE_READ_ONLY_DEVICE | \
5012                                          FILE_FLOPPY_DISKETTE  | \
5013                                          FILE_WRITE_ONCE_MEDIA | \
5014                                          FILE_DEVICE_SECURE_OPEN)
5015 
5016 typedef struct _FILE_ALIGNMENT_INFORMATION {
5017   ULONG AlignmentRequirement;
5018 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
5019 
5020 typedef struct _FILE_NAME_INFORMATION {
5021   ULONG FileNameLength;
5022   WCHAR FileName[1];
5023 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
5024 
5025 
5026 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
5027   ULONG FileAttributes;
5028   ULONG ReparseTag;
5029 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
5030 
5031 typedef struct _FILE_DISPOSITION_INFORMATION {
5032   BOOLEAN DeleteFile;
5033 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
5034 
5035 typedef struct _FILE_END_OF_FILE_INFORMATION {
5036   LARGE_INTEGER EndOfFile;
5037 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
5038 
5039 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
5040   LARGE_INTEGER ValidDataLength;
5041 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
5042 
5043 typedef struct _FILE_FS_LABEL_INFORMATION {
5044   ULONG VolumeLabelLength;
5045   WCHAR VolumeLabel[1];
5046 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
5047 
5048 typedef struct _FILE_FS_VOLUME_INFORMATION {
5049   LARGE_INTEGER VolumeCreationTime;
5050   ULONG VolumeSerialNumber;
5051   ULONG VolumeLabelLength;
5052   BOOLEAN SupportsObjects;
5053   WCHAR VolumeLabel[1];
5054 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
5055 
5056 typedef struct _FILE_FS_SIZE_INFORMATION {
5057   LARGE_INTEGER TotalAllocationUnits;
5058   LARGE_INTEGER AvailableAllocationUnits;
5059   ULONG SectorsPerAllocationUnit;
5060   ULONG BytesPerSector;
5061 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
5062 
5063 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
5064   LARGE_INTEGER TotalAllocationUnits;
5065   LARGE_INTEGER CallerAvailableAllocationUnits;
5066   LARGE_INTEGER ActualAvailableAllocationUnits;
5067   ULONG SectorsPerAllocationUnit;
5068   ULONG BytesPerSector;
5069 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
5070 
5071 typedef struct _FILE_FS_OBJECTID_INFORMATION {
5072   UCHAR ObjectId[16];
5073   UCHAR ExtendedInfo[48];
5074 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
5075 
5076 typedef union _FILE_SEGMENT_ELEMENT {
5077   PVOID64 Buffer;
5078   ULONGLONG Alignment;
5079 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5080 
5081 #define IOCTL_AVIO_ALLOCATE_STREAM      CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5082 #define IOCTL_AVIO_FREE_STREAM          CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5083 #define IOCTL_AVIO_MODIFY_STREAM        CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5084 
5085 typedef enum _BUS_DATA_TYPE {
5086   ConfigurationSpaceUndefined = -1,
5087   Cmos,
5088   EisaConfiguration,
5089   Pos,
5090   CbusConfiguration,
5091   PCIConfiguration,
5092   VMEConfiguration,
5093   NuBusConfiguration,
5094   PCMCIAConfiguration,
5095   MPIConfiguration,
5096   MPSAConfiguration,
5097   PNPISAConfiguration,
5098   SgiInternalConfiguration,
5099   MaximumBusDataType
5100 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
5101 
5102 /* Some Server 2003 DDK definitions */
5103 #define PCI_INT_ROUTE_INTRF_STANDARD_VER 1
5104 
5105 typedef NTSTATUS
5106 (NTAPI *PLEGACY_DEVICE_DETECTION_HANDLER)(
5107   IN PVOID Context,
5108   IN INTERFACE_TYPE LegacyBusType,
5109   IN ULONG BusNumber,
5110   IN ULONG SlotNumber,
5111   OUT PDEVICE_OBJECT *PhysicalDeviceObject);
5112 
5113 typedef struct _ROUTING_TOKEN {
5114   PVOID LinkNode;
5115   ULONG StaticVector;
5116   UCHAR Flags;
5117 } ROUTING_TOKEN, *PROUTING_TOKEN;
5118 
5119 typedef NTSTATUS
5120 (NTAPI *PGET_INTERRUPT_ROUTING)(
5121   IN PDEVICE_OBJECT Pdo,
5122   OUT ULONG *Bus,
5123   OUT ULONG *PciSlot,
5124   OUT UCHAR *InterruptLine,
5125   OUT UCHAR *InterruptPin,
5126   OUT UCHAR *ClassCode,
5127   OUT UCHAR *SubClassCode,
5128   OUT PDEVICE_OBJECT *ParentPdo,
5129   OUT ROUTING_TOKEN *RoutingToken,
5130   OUT UCHAR *Flags);
5131 
5132 typedef NTSTATUS
5133 (NTAPI *PSET_INTERRUPT_ROUTING_TOKEN)(
5134   IN PDEVICE_OBJECT Pdo,
5135   IN PROUTING_TOKEN RoutingToken);
5136 
5137 typedef VOID
5138 (NTAPI *PUPDATE_INTERRUPT_LINE)(
5139   IN PDEVICE_OBJECT Pdo,
5140   IN UCHAR LineRegister);
5141 
5142 typedef struct _INT_ROUTE_INTERFACE_STANDARD {
5143   USHORT Size;
5144   USHORT Version;
5145   PVOID Context;
5146   PINTERFACE_REFERENCE InterfaceReference;
5147   PINTERFACE_DEREFERENCE InterfaceDereference;
5148   PGET_INTERRUPT_ROUTING GetInterruptRouting;
5149   PSET_INTERRUPT_ROUTING_TOKEN SetInterruptRoutingToken;
5150   PUPDATE_INTERRUPT_LINE UpdateInterruptLine;
5151 } INT_ROUTE_INTERFACE_STANDARD, *PINT_ROUTE_INTERFACE_STANDARD;
5152 
5153 typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE {
5154   USHORT Size;
5155   USHORT Version;
5156   PVOID Context;
5157   PINTERFACE_REFERENCE InterfaceReference;
5158   PINTERFACE_DEREFERENCE InterfaceDereference;
5159   PLEGACY_DEVICE_DETECTION_HANDLER LegacyDeviceDetection;
5160 } LEGACY_DEVICE_DETECTION_INTERFACE, *PLEGACY_DEVICE_DETECTION_INTERFACE;
5161 
5162 /* FIXME : These definitions don't exist in public headers */
5163 
5164 #define PCI_CB_INTRF_VERSION             1
5165 #define PCI_PME_INTRF_STANDARD_VER       1
5166 #define PNP_LOCATION_INTERFACE_VERSION   1
5167 
5168 DEFINE_GUID(GUID_PCI_CARDBUS_INTERFACE_PRIVATE, 0xcca82f31, 0x54d6, 0x11d1, 0x82, 0x24, 0x00, 0xa0, 0xc9, 0x32, 0x43, 0x85);
5169 DEFINE_GUID(GUID_PCI_PME_INTERFACE, 0xaac7e6ac, 0xbb0b, 0x11d2, 0xb4, 0x84, 0x00, 0xc0, 0x4f, 0x72, 0xde, 0x8b);
5170 
5171 typedef NTSTATUS
5172 (NTAPI *PCARDBUSADD)(
5173   IN PDEVICE_OBJECT DeviceObject,
5174   IN OUT PVOID *DeviceContext);
5175 
5176 typedef NTSTATUS
5177 (NTAPI *PCARDBUSDELETE)(
5178   IN PVOID DeviceContext);
5179 
5180 typedef NTSTATUS
5181 (NTAPI *PCARDBUSPCIDISPATCH)(
5182   IN PVOID DeviceContext,
5183   IN PIRP Irp);
5184 
5185 typedef VOID
5186 (NTAPI *PPME_SET_PME_ENABLE)(
5187   IN PDEVICE_OBJECT Pdo,
5188   IN BOOLEAN PmeEnable);
5189 
5190 typedef VOID
5191 (NTAPI *PPME_CLEAR_PME_STATUS)(
5192   IN PDEVICE_OBJECT Pdo);
5193 
5194 typedef VOID
5195 (NTAPI *PPME_GET_INFORMATION)(
5196   IN PDEVICE_OBJECT Pdo,
5197   OUT PBOOLEAN PmeCapable,
5198   OUT PBOOLEAN PmeStatus,
5199   OUT PBOOLEAN PmeEnable);
5200 
5201 typedef struct _PCI_CARDBUS_INTERFACE_PRIVATE {
5202   USHORT Size;
5203   USHORT Version;
5204   PVOID Context;
5205   PINTERFACE_REFERENCE InterfaceReference;
5206   PINTERFACE_DEREFERENCE InterfaceDereference;
5207   PDRIVER_OBJECT DriverObject;
5208   PCARDBUSADD AddCardBus;
5209   PCARDBUSDELETE DeleteCardBus;
5210   PCARDBUSPCIDISPATCH DispatchPnp;
5211 } PCI_CARDBUS_INTERFACE_PRIVATE, *PPCI_CARDBUS_INTERFACE_PRIVATE;
5212 
5213 typedef struct _PCI_PME_INTERFACE {
5214   USHORT Size;
5215   USHORT Version;
5216   PVOID Context;
5217   PINTERFACE_REFERENCE InterfaceReference;
5218   PINTERFACE_DEREFERENCE InterfaceDereference;
5219   PPME_GET_INFORMATION GetPmeInformation;
5220   PPME_CLEAR_PME_STATUS ClearPmeStatus;
5221   PPME_SET_PME_ENABLE UpdateEnable;
5222 } PCI_PME_INTERFACE, *PPCI_PME_INTERFACE;
5223 
5224 $endif (_NTDDK_)
5225 $if (_NTIFS_)
5226 
5227 #define FILE_OPLOCK_BROKEN_TO_LEVEL_2   0x00000007
5228 #define FILE_OPLOCK_BROKEN_TO_NONE      0x00000008
5229 #define FILE_OPBATCH_BREAK_UNDERWAY     0x00000009
5230 
5231 /* also in winnt.h */
5232 #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
5233 #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
5234 #define FILE_NOTIFY_CHANGE_NAME         0x00000003
5235 #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
5236 #define FILE_NOTIFY_CHANGE_SIZE         0x00000008
5237 #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
5238 #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
5239 #define FILE_NOTIFY_CHANGE_CREATION     0x00000040
5240 #define FILE_NOTIFY_CHANGE_EA           0x00000080
5241 #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
5242 #define FILE_NOTIFY_CHANGE_STREAM_NAME  0x00000200
5243 #define FILE_NOTIFY_CHANGE_STREAM_SIZE  0x00000400
5244 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5245 #define FILE_NOTIFY_VALID_MASK          0x00000fff
5246 
5247 #define FILE_ACTION_ADDED                   0x00000001
5248 #define FILE_ACTION_REMOVED                 0x00000002
5249 #define FILE_ACTION_MODIFIED                0x00000003
5250 #define FILE_ACTION_RENAMED_OLD_NAME        0x00000004
5251 #define FILE_ACTION_RENAMED_NEW_NAME        0x00000005
5252 #define FILE_ACTION_ADDED_STREAM            0x00000006
5253 #define FILE_ACTION_REMOVED_STREAM          0x00000007
5254 #define FILE_ACTION_MODIFIED_STREAM         0x00000008
5255 #define FILE_ACTION_REMOVED_BY_DELETE       0x00000009
5256 #define FILE_ACTION_ID_NOT_TUNNELLED        0x0000000A
5257 #define FILE_ACTION_TUNNELLED_ID_COLLISION  0x0000000B
5258 /* end  winnt.h */
5259 
5260 #define FILE_PIPE_BYTE_STREAM_TYPE          0x00000000
5261 #define FILE_PIPE_MESSAGE_TYPE              0x00000001
5262 
5263 #define FILE_PIPE_ACCEPT_REMOTE_CLIENTS     0x00000000
5264 #define FILE_PIPE_REJECT_REMOTE_CLIENTS     0x00000002
5265 
5266 #define FILE_PIPE_ACCEPT_REMOTE_CLIENTS     0x00000000
5267 #define FILE_PIPE_REJECT_REMOTE_CLIENTS     0x00000002
5268 #define FILE_PIPE_TYPE_VALID_MASK           0x00000003
5269 
5270 #define FILE_PIPE_BYTE_STREAM_MODE          0x00000000
5271 #define FILE_PIPE_MESSAGE_MODE              0x00000001
5272 
5273 #define FILE_PIPE_QUEUE_OPERATION           0x00000000
5274 #define FILE_PIPE_COMPLETE_OPERATION        0x00000001
5275 
5276 #define FILE_PIPE_INBOUND                   0x00000000
5277 #define FILE_PIPE_OUTBOUND                  0x00000001
5278 #define FILE_PIPE_FULL_DUPLEX               0x00000002
5279 
5280 #define FILE_PIPE_DISCONNECTED_STATE        0x00000001
5281 #define FILE_PIPE_LISTENING_STATE           0x00000002
5282 #define FILE_PIPE_CONNECTED_STATE           0x00000003
5283 #define FILE_PIPE_CLOSING_STATE             0x00000004
5284 
5285 #define FILE_PIPE_CLIENT_END                0x00000000
5286 #define FILE_PIPE_SERVER_END                0x00000001
5287 
5288 #define FILE_CASE_SENSITIVE_SEARCH          0x00000001
5289 #define FILE_CASE_PRESERVED_NAMES           0x00000002
5290 #define FILE_UNICODE_ON_DISK                0x00000004
5291 #define FILE_PERSISTENT_ACLS                0x00000008
5292 #define FILE_FILE_COMPRESSION               0x00000010
5293 #define FILE_VOLUME_QUOTAS                  0x00000020
5294 #define FILE_SUPPORTS_SPARSE_FILES          0x00000040
5295 #define FILE_SUPPORTS_REPARSE_POINTS        0x00000080
5296 #define FILE_SUPPORTS_REMOTE_STORAGE        0x00000100
5297 #define FILE_VOLUME_IS_COMPRESSED           0x00008000
5298 #define FILE_SUPPORTS_OBJECT_IDS            0x00010000
5299 #define FILE_SUPPORTS_ENCRYPTION            0x00020000
5300 #define FILE_NAMED_STREAMS                  0x00040000
5301 #define FILE_READ_ONLY_VOLUME               0x00080000
5302 #define FILE_SEQUENTIAL_WRITE_ONCE          0x00100000
5303 #define FILE_SUPPORTS_TRANSACTIONS          0x00200000
5304 #define FILE_SUPPORTS_HARD_LINKS            0x00400000
5305 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES   0x00800000
5306 #define FILE_SUPPORTS_OPEN_BY_FILE_ID       0x01000000
5307 #define FILE_SUPPORTS_USN_JOURNAL           0x02000000
5308 #define FILE_SUPPORTS_INTEGRITY_STREAMS     0x04000000
5309 #define FILE_SUPPORTS_BLOCK_REFCOUNTING     0x08000000
5310 #define FILE_SUPPORTS_SPARSE_VDL            0x10000000
5311 #define FILE_DAX_VOLUME                     0x20000000
5312 
5313 #define FILE_NEED_EA                    0x00000080
5314 
5315 #define FILE_EA_TYPE_BINARY             0xfffe
5316 #define FILE_EA_TYPE_ASCII              0xfffd
5317 #define FILE_EA_TYPE_BITMAP             0xfffb
5318 #define FILE_EA_TYPE_METAFILE           0xfffa
5319 #define FILE_EA_TYPE_ICON               0xfff9
5320 #define FILE_EA_TYPE_EA                 0xffee
5321 #define FILE_EA_TYPE_MVMT               0xffdf
5322 #define FILE_EA_TYPE_MVST               0xffde
5323 #define FILE_EA_TYPE_ASN1               0xffdd
5324 #define FILE_EA_TYPE_FAMILY_IDS         0xff01
5325 
5326 typedef struct _FILE_NOTIFY_INFORMATION {
5327   ULONG NextEntryOffset;
5328   ULONG Action;
5329   ULONG FileNameLength;
5330   WCHAR FileName[1];
5331 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5332 
5333 typedef struct _FILE_DIRECTORY_INFORMATION {
5334   ULONG NextEntryOffset;
5335   ULONG FileIndex;
5336   LARGE_INTEGER CreationTime;
5337   LARGE_INTEGER LastAccessTime;
5338   LARGE_INTEGER LastWriteTime;
5339   LARGE_INTEGER ChangeTime;
5340   LARGE_INTEGER EndOfFile;
5341   LARGE_INTEGER AllocationSize;
5342   ULONG FileAttributes;
5343   ULONG FileNameLength;
5344   WCHAR FileName[1];
5345 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
5346 
5347 typedef struct _FILE_FULL_DIR_INFORMATION {
5348   ULONG NextEntryOffset;
5349   ULONG FileIndex;
5350   LARGE_INTEGER CreationTime;
5351   LARGE_INTEGER LastAccessTime;
5352   LARGE_INTEGER LastWriteTime;
5353   LARGE_INTEGER ChangeTime;
5354   LARGE_INTEGER EndOfFile;
5355   LARGE_INTEGER AllocationSize;
5356   ULONG FileAttributes;
5357   ULONG FileNameLength;
5358   ULONG EaSize;
5359   WCHAR FileName[1];
5360 } FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
5361 
5362 typedef struct _FILE_ID_FULL_DIR_INFORMATION {
5363   ULONG NextEntryOffset;
5364   ULONG FileIndex;
5365   LARGE_INTEGER CreationTime;
5366   LARGE_INTEGER LastAccessTime;
5367   LARGE_INTEGER LastWriteTime;
5368   LARGE_INTEGER ChangeTime;
5369   LARGE_INTEGER EndOfFile;
5370   LARGE_INTEGER AllocationSize;
5371   ULONG FileAttributes;
5372   ULONG FileNameLength;
5373   ULONG EaSize;
5374   LARGE_INTEGER FileId;
5375   WCHAR FileName[1];
5376 } FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;
5377 
5378 typedef struct _FILE_BOTH_DIR_INFORMATION {
5379   ULONG NextEntryOffset;
5380   ULONG FileIndex;
5381   LARGE_INTEGER CreationTime;
5382   LARGE_INTEGER LastAccessTime;
5383   LARGE_INTEGER LastWriteTime;
5384   LARGE_INTEGER ChangeTime;
5385   LARGE_INTEGER EndOfFile;
5386   LARGE_INTEGER AllocationSize;
5387   ULONG FileAttributes;
5388   ULONG FileNameLength;
5389   ULONG EaSize;
5390   CCHAR ShortNameLength;
5391   WCHAR ShortName[12];
5392   WCHAR FileName[1];
5393 } FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
5394 
5395 typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
5396   ULONG NextEntryOffset;
5397   ULONG FileIndex;
5398   LARGE_INTEGER CreationTime;
5399   LARGE_INTEGER LastAccessTime;
5400   LARGE_INTEGER LastWriteTime;
5401   LARGE_INTEGER ChangeTime;
5402   LARGE_INTEGER EndOfFile;
5403   LARGE_INTEGER AllocationSize;
5404   ULONG FileAttributes;
5405   ULONG FileNameLength;
5406   ULONG EaSize;
5407   CCHAR ShortNameLength;
5408   WCHAR ShortName[12];
5409   LARGE_INTEGER FileId;
5410   WCHAR FileName[1];
5411 } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
5412 
5413 typedef struct _FILE_NAMES_INFORMATION {
5414   ULONG NextEntryOffset;
5415   ULONG FileIndex;
5416   ULONG FileNameLength;
5417   WCHAR FileName[1];
5418 } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
5419 
5420 typedef struct _FILE_ID_GLOBAL_TX_DIR_INFORMATION {
5421   ULONG NextEntryOffset;
5422   ULONG FileIndex;
5423   LARGE_INTEGER CreationTime;
5424   LARGE_INTEGER LastAccessTime;
5425   LARGE_INTEGER LastWriteTime;
5426   LARGE_INTEGER ChangeTime;
5427   LARGE_INTEGER EndOfFile;
5428   LARGE_INTEGER AllocationSize;
5429   ULONG FileAttributes;
5430   ULONG FileNameLength;
5431   LARGE_INTEGER FileId;
5432   GUID LockingTransactionId;
5433   ULONG TxInfoFlags;
5434   WCHAR FileName[1];
5435 } FILE_ID_GLOBAL_TX_DIR_INFORMATION, *PFILE_ID_GLOBAL_TX_DIR_INFORMATION;
5436 
5437 #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_WRITELOCKED         0x00000001
5438 #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_VISIBLE_TO_TX       0x00000002
5439 #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_VISIBLE_OUTSIDE_TX  0x00000004
5440 
5441 typedef struct _FILE_OBJECTID_INFORMATION {
5442   LONGLONG FileReference;
5443   UCHAR ObjectId[16];
5444   _ANONYMOUS_UNION union {
5445     _ANONYMOUS_STRUCT struct {
5446       UCHAR BirthVolumeId[16];
5447       UCHAR BirthObjectId[16];
5448       UCHAR DomainId[16];
5449     } DUMMYSTRUCTNAME;
5450     UCHAR ExtendedInfo[48];
5451   } DUMMYUNIONNAME;
5452 } FILE_OBJECTID_INFORMATION, *PFILE_OBJECTID_INFORMATION;
5453 
5454 #define ANSI_DOS_STAR                   ('<')
5455 #define ANSI_DOS_QM                     ('>')
5456 #define ANSI_DOS_DOT                    ('"')
5457 
5458 #define DOS_STAR                        (L'<')
5459 #define DOS_QM                          (L'>')
5460 #define DOS_DOT                         (L'"')
5461 
5462 typedef struct _FILE_INTERNAL_INFORMATION {
5463   LARGE_INTEGER IndexNumber;
5464 } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
5465 
5466 typedef struct _FILE_EA_INFORMATION {
5467   ULONG EaSize;
5468 } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
5469 
5470 typedef struct _FILE_ACCESS_INFORMATION {
5471   ACCESS_MASK AccessFlags;
5472 } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
5473 
5474 typedef struct _FILE_MODE_INFORMATION {
5475   ULONG Mode;
5476 } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
5477 
5478 typedef struct _FILE_ALL_INFORMATION {
5479   FILE_BASIC_INFORMATION BasicInformation;
5480   FILE_STANDARD_INFORMATION StandardInformation;
5481   FILE_INTERNAL_INFORMATION InternalInformation;
5482   FILE_EA_INFORMATION EaInformation;
5483   FILE_ACCESS_INFORMATION AccessInformation;
5484   FILE_POSITION_INFORMATION PositionInformation;
5485   FILE_MODE_INFORMATION ModeInformation;
5486   FILE_ALIGNMENT_INFORMATION AlignmentInformation;
5487   FILE_NAME_INFORMATION NameInformation;
5488 } FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
5489 
5490 typedef struct _FILE_ALLOCATION_INFORMATION {
5491   LARGE_INTEGER AllocationSize;
5492 } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
5493 
5494 typedef struct _FILE_COMPRESSION_INFORMATION {
5495   LARGE_INTEGER CompressedFileSize;
5496   USHORT CompressionFormat;
5497   UCHAR CompressionUnitShift;
5498   UCHAR ChunkShift;
5499   UCHAR ClusterShift;
5500   UCHAR Reserved[3];
5501 } FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
5502 
5503 typedef struct _FILE_LINK_INFORMATION {
5504   BOOLEAN ReplaceIfExists;
5505   HANDLE RootDirectory;
5506   ULONG FileNameLength;
5507   WCHAR FileName[1];
5508 } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
5509 
5510 typedef struct _FILE_MOVE_CLUSTER_INFORMATION {
5511   ULONG ClusterCount;
5512   HANDLE RootDirectory;
5513   ULONG FileNameLength;
5514   WCHAR FileName[1];
5515 } FILE_MOVE_CLUSTER_INFORMATION, *PFILE_MOVE_CLUSTER_INFORMATION;
5516 
5517 typedef struct _FILE_RENAME_INFORMATION {
5518   BOOLEAN ReplaceIfExists;
5519   HANDLE RootDirectory;
5520   ULONG FileNameLength;
5521   WCHAR FileName[1];
5522 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
5523 
5524 typedef struct _FILE_STREAM_INFORMATION {
5525   ULONG NextEntryOffset;
5526   ULONG StreamNameLength;
5527   LARGE_INTEGER StreamSize;
5528   LARGE_INTEGER StreamAllocationSize;
5529   WCHAR StreamName[1];
5530 } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
5531 
5532 typedef struct _FILE_TRACKING_INFORMATION {
5533   HANDLE DestinationFile;
5534   ULONG ObjectInformationLength;
5535   CHAR ObjectInformation[1];
5536 } FILE_TRACKING_INFORMATION, *PFILE_TRACKING_INFORMATION;
5537 
5538 typedef struct _FILE_COMPLETION_INFORMATION {
5539   HANDLE Port;
5540   PVOID Key;
5541 } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
5542 
5543 typedef struct _FILE_PIPE_INFORMATION {
5544   ULONG ReadMode;
5545   ULONG CompletionMode;
5546 } FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
5547 
5548 typedef struct _FILE_PIPE_LOCAL_INFORMATION {
5549   ULONG NamedPipeType;
5550   ULONG NamedPipeConfiguration;
5551   ULONG MaximumInstances;
5552   ULONG CurrentInstances;
5553   ULONG InboundQuota;
5554   ULONG ReadDataAvailable;
5555   ULONG OutboundQuota;
5556   ULONG WriteQuotaAvailable;
5557   ULONG NamedPipeState;
5558   ULONG NamedPipeEnd;
5559 } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
5560 
5561 typedef struct _FILE_PIPE_REMOTE_INFORMATION {
5562   LARGE_INTEGER CollectDataTime;
5563   ULONG MaximumCollectionCount;
5564 } FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
5565 
5566 typedef struct _FILE_MAILSLOT_QUERY_INFORMATION {
5567   ULONG MaximumMessageSize;
5568   ULONG MailslotQuota;
5569   ULONG NextMessageSize;
5570   ULONG MessagesAvailable;
5571   LARGE_INTEGER ReadTimeout;
5572 } FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION;
5573 
5574 typedef struct _FILE_MAILSLOT_SET_INFORMATION {
5575   PLARGE_INTEGER ReadTimeout;
5576 } FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
5577 
5578 typedef struct _FILE_REPARSE_POINT_INFORMATION {
5579   LONGLONG FileReference;
5580   ULONG Tag;
5581 } FILE_REPARSE_POINT_INFORMATION, *PFILE_REPARSE_POINT_INFORMATION;
5582 
5583 typedef struct _FILE_LINK_ENTRY_INFORMATION {
5584   ULONG NextEntryOffset;
5585   LONGLONG ParentFileId;
5586   ULONG FileNameLength;
5587   WCHAR FileName[1];
5588 } FILE_LINK_ENTRY_INFORMATION, *PFILE_LINK_ENTRY_INFORMATION;
5589 
5590 typedef struct _FILE_LINKS_INFORMATION {
5591   ULONG BytesNeeded;
5592   ULONG EntriesReturned;
5593   FILE_LINK_ENTRY_INFORMATION Entry;
5594 } FILE_LINKS_INFORMATION, *PFILE_LINKS_INFORMATION;
5595 
5596 typedef struct _FILE_NETWORK_PHYSICAL_NAME_INFORMATION {
5597   ULONG FileNameLength;
5598   WCHAR FileName[1];
5599 } FILE_NETWORK_PHYSICAL_NAME_INFORMATION, *PFILE_NETWORK_PHYSICAL_NAME_INFORMATION;
5600 
5601 typedef struct _FILE_STANDARD_LINK_INFORMATION {
5602   ULONG NumberOfAccessibleLinks;
5603   ULONG TotalNumberOfLinks;
5604   BOOLEAN DeletePending;
5605   BOOLEAN Directory;
5606 } FILE_STANDARD_LINK_INFORMATION, *PFILE_STANDARD_LINK_INFORMATION;
5607 
5608 typedef struct _FILE_GET_EA_INFORMATION {
5609   ULONG NextEntryOffset;
5610   UCHAR EaNameLength;
5611   CHAR  EaName[1];
5612 } FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
5613 
5614 #define REMOTE_PROTOCOL_FLAG_LOOPBACK       0x00000001
5615 #define REMOTE_PROTOCOL_FLAG_OFFLINE        0x00000002
5616 
5617 typedef struct _FILE_REMOTE_PROTOCOL_INFORMATION {
5618   USHORT StructureVersion;
5619   USHORT StructureSize;
5620   ULONG  Protocol;
5621   USHORT ProtocolMajorVersion;
5622   USHORT ProtocolMinorVersion;
5623   USHORT ProtocolRevision;
5624   USHORT Reserved;
5625   ULONG  Flags;
5626   struct {
5627     ULONG Reserved[8];
5628   } GenericReserved;
5629   struct {
5630     ULONG Reserved[16];
5631   } ProtocolSpecificReserved;
5632 } FILE_REMOTE_PROTOCOL_INFORMATION, *PFILE_REMOTE_PROTOCOL_INFORMATION;
5633 
5634 typedef struct _FILE_GET_QUOTA_INFORMATION {
5635   ULONG NextEntryOffset;
5636   ULONG SidLength;
5637   SID Sid;
5638 } FILE_GET_QUOTA_INFORMATION, *PFILE_GET_QUOTA_INFORMATION;
5639 
5640 typedef struct _FILE_QUOTA_INFORMATION {
5641   ULONG NextEntryOffset;
5642   ULONG SidLength;
5643   LARGE_INTEGER ChangeTime;
5644   LARGE_INTEGER QuotaUsed;
5645   LARGE_INTEGER QuotaThreshold;
5646   LARGE_INTEGER QuotaLimit;
5647   SID Sid;
5648 } FILE_QUOTA_INFORMATION, *PFILE_QUOTA_INFORMATION;
5649 
5650 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
5651   ULONG FileSystemAttributes;
5652   ULONG MaximumComponentNameLength;
5653   ULONG FileSystemNameLength;
5654   WCHAR FileSystemName[1];
5655 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
5656 
5657 typedef struct _FILE_FS_DRIVER_PATH_INFORMATION {
5658   BOOLEAN DriverInPath;
5659   ULONG DriverNameLength;
5660   WCHAR DriverName[1];
5661 } FILE_FS_DRIVER_PATH_INFORMATION, *PFILE_FS_DRIVER_PATH_INFORMATION;
5662 
5663 typedef struct _FILE_FS_VOLUME_FLAGS_INFORMATION {
5664   ULONG Flags;
5665 } FILE_FS_VOLUME_FLAGS_INFORMATION, *PFILE_FS_VOLUME_FLAGS_INFORMATION;
5666 
5667 #define FILE_VC_QUOTA_NONE              0x00000000
5668 #define FILE_VC_QUOTA_TRACK             0x00000001
5669 #define FILE_VC_QUOTA_ENFORCE           0x00000002
5670 #define FILE_VC_QUOTA_MASK              0x00000003
5671 #define FILE_VC_CONTENT_INDEX_DISABLED  0x00000008
5672 #define FILE_VC_LOG_QUOTA_THRESHOLD     0x00000010
5673 #define FILE_VC_LOG_QUOTA_LIMIT         0x00000020
5674 #define FILE_VC_LOG_VOLUME_THRESHOLD    0x00000040
5675 #define FILE_VC_LOG_VOLUME_LIMIT        0x00000080
5676 #define FILE_VC_QUOTAS_INCOMPLETE       0x00000100
5677 #define FILE_VC_QUOTAS_REBUILDING       0x00000200
5678 #define FILE_VC_VALID_MASK              0x000003ff
5679 
5680 typedef struct _FILE_FS_CONTROL_INFORMATION {
5681   LARGE_INTEGER FreeSpaceStartFiltering;
5682   LARGE_INTEGER FreeSpaceThreshold;
5683   LARGE_INTEGER FreeSpaceStopFiltering;
5684   LARGE_INTEGER DefaultQuotaThreshold;
5685   LARGE_INTEGER DefaultQuotaLimit;
5686   ULONG FileSystemControlFlags;
5687 } FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION;
5688 
5689 #ifndef _FILESYSTEMFSCTL_
5690 #define _FILESYSTEMFSCTL_
5691 
5692 #define FSCTL_REQUEST_OPLOCK_LEVEL_1    CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  0, METHOD_BUFFERED, FILE_ANY_ACCESS)
5693 #define FSCTL_REQUEST_OPLOCK_LEVEL_2    CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  1, METHOD_BUFFERED, FILE_ANY_ACCESS)
5694 #define FSCTL_REQUEST_BATCH_OPLOCK      CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  2, METHOD_BUFFERED, FILE_ANY_ACCESS)
5695 #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE  CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  3, METHOD_BUFFERED, FILE_ANY_ACCESS)
5696 #define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  4, METHOD_BUFFERED, FILE_ANY_ACCESS)
5697 #define FSCTL_OPLOCK_BREAK_NOTIFY       CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  5, METHOD_BUFFERED, FILE_ANY_ACCESS)
5698 #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  6, METHOD_BUFFERED, FILE_ANY_ACCESS)
5699 #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS)
5700 #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS)
5701 #define FSCTL_IS_VOLUME_MOUNTED         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
5702 #define FSCTL_IS_PATHNAME_VALID         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
5703 #define FSCTL_MARK_VOLUME_DIRTY         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
5704 #define FSCTL_QUERY_RETRIEVAL_POINTERS  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER,  FILE_ANY_ACCESS)
5705 #define FSCTL_GET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
5706 #define FSCTL_SET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5707 #define FSCTL_SET_BOOTLOADER_ACCESSED   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER,  FILE_ANY_ACCESS)
5708 
5709 #define FSCTL_OPLOCK_BREAK_ACK_NO_2     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
5710 #define FSCTL_INVALIDATE_VOLUMES        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
5711 #define FSCTL_QUERY_FAT_BPB             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
5712 #define FSCTL_REQUEST_FILTER_OPLOCK     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
5713 #define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)
5714 
5715 #if (_WIN32_WINNT >= 0x0400)
5716 
5717 #define FSCTL_GET_NTFS_VOLUME_DATA      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
5718 #define FSCTL_GET_NTFS_FILE_RECORD      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
5719 #define FSCTL_GET_VOLUME_BITMAP         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER,  FILE_ANY_ACCESS)
5720 #define FSCTL_GET_RETRIEVAL_POINTERS    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER,  FILE_ANY_ACCESS)
5721 #define FSCTL_MOVE_FILE                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5722 #define FSCTL_IS_VOLUME_DIRTY           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
5723 #define FSCTL_ALLOW_EXTENDED_DASD_IO    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER,  FILE_ANY_ACCESS)
5724 
5725 #endif
5726 
5727 #if (_WIN32_WINNT >= 0x0500)
5728 
5729 #define FSCTL_FIND_FILES_BY_SID         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER,  FILE_ANY_ACCESS)
5730 #define FSCTL_SET_OBJECT_ID             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5731 #define FSCTL_GET_OBJECT_ID             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS)
5732 #define FSCTL_DELETE_OBJECT_ID          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5733 #define FSCTL_SET_REPARSE_POINT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5734 #define FSCTL_GET_REPARSE_POINT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
5735 #define FSCTL_DELETE_REPARSE_POINT      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5736 #define FSCTL_ENUM_USN_DATA             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER,  FILE_ANY_ACCESS)
5737 #define FSCTL_SECURITY_ID_CHECK         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER,  FILE_READ_DATA)
5738 #define FSCTL_READ_USN_JOURNAL          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER,  FILE_ANY_ACCESS)
5739 #define FSCTL_SET_OBJECT_ID_EXTENDED    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5740 #define FSCTL_CREATE_OR_GET_OBJECT_ID   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS)
5741 #define FSCTL_SET_SPARSE                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5742 #define FSCTL_SET_ZERO_DATA             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA)
5743 #define FSCTL_QUERY_ALLOCATED_RANGES    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER,  FILE_READ_DATA)
5744 #define FSCTL_ENABLE_UPGRADE            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_DATA)
5745 #define FSCTL_SET_ENCRYPTION            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER,  FILE_ANY_ACCESS)
5746 #define FSCTL_ENCRYPTION_FSCTL_IO       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER,  FILE_ANY_ACCESS)
5747 #define FSCTL_WRITE_RAW_ENCRYPTED       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER,  FILE_SPECIAL_ACCESS)
5748 #define FSCTL_READ_RAW_ENCRYPTED        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER,  FILE_SPECIAL_ACCESS)
5749 #define FSCTL_CREATE_USN_JOURNAL        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER,  FILE_ANY_ACCESS)
5750 #define FSCTL_READ_FILE_USN_DATA        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER,  FILE_ANY_ACCESS)
5751 #define FSCTL_WRITE_USN_CLOSE_RECORD    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER,  FILE_ANY_ACCESS)
5752 #define FSCTL_EXTEND_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
5753 #define FSCTL_QUERY_USN_JOURNAL         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS)
5754 #define FSCTL_DELETE_USN_JOURNAL        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS)
5755 #define FSCTL_MARK_HANDLE               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
5756 #define FSCTL_SIS_COPYFILE              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
5757 #define FSCTL_SIS_LINK_FILES            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5758 #define FSCTL_RECALL_FILE               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
5759 #define FSCTL_READ_FROM_PLEX            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA)
5760 #define FSCTL_FILE_PREFETCH             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5761 
5762 #endif
5763 
5764 #if (_WIN32_WINNT >= 0x0600)
5765 
5766 #define FSCTL_MAKE_MEDIA_COMPATIBLE         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, FILE_WRITE_DATA)
5767 #define FSCTL_SET_DEFECT_MANAGEMENT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, FILE_WRITE_DATA)
5768 #define FSCTL_QUERY_SPARING_INFO            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS)
5769 #define FSCTL_QUERY_ON_DISK_VOLUME_INFO     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS)
5770 #define FSCTL_SET_VOLUME_COMPRESSION_STATE  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5771 #define FSCTL_TXFS_MODIFY_RM                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, FILE_WRITE_DATA)
5772 #define FSCTL_TXFS_QUERY_RM_INFORMATION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, FILE_READ_DATA)
5773 #define FSCTL_TXFS_ROLLFORWARD_REDO         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, FILE_WRITE_DATA)
5774 #define FSCTL_TXFS_ROLLFORWARD_UNDO         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, FILE_WRITE_DATA)
5775 #define FSCTL_TXFS_START_RM                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, FILE_WRITE_DATA)
5776 #define FSCTL_TXFS_SHUTDOWN_RM              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, FILE_WRITE_DATA)
5777 #define FSCTL_TXFS_READ_BACKUP_INFORMATION  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, FILE_READ_DATA)
5778 #define FSCTL_TXFS_WRITE_BACKUP_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, FILE_WRITE_DATA)
5779 #define FSCTL_TXFS_CREATE_SECONDARY_RM      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, FILE_WRITE_DATA)
5780 #define FSCTL_TXFS_GET_METADATA_INFO        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, FILE_READ_DATA)
5781 #define FSCTL_TXFS_GET_TRANSACTED_VERSION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, FILE_READ_DATA)
5782 #define FSCTL_TXFS_SAVEPOINT_INFORMATION    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, FILE_WRITE_DATA)
5783 #define FSCTL_TXFS_CREATE_MINIVERSION       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, FILE_WRITE_DATA)
5784 #define FSCTL_TXFS_TRANSACTION_ACTIVE       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, FILE_READ_DATA)
5785 #define FSCTL_SET_ZERO_ON_DEALLOCATION      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5786 #define FSCTL_SET_REPAIR                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS)
5787 #define FSCTL_GET_REPAIR                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS)
5788 #define FSCTL_WAIT_FOR_REPAIR               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS)
5789 #define FSCTL_INITIATE_REPAIR               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS)
5790 #define FSCTL_CSC_INTERNAL                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER,  FILE_ANY_ACCESS)
5791 #define FSCTL_SHRINK_VOLUME                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
5792 #define FSCTL_SET_SHORT_NAME_BEHAVIOR       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS)
5793 #define FSCTL_DFSR_SET_GHOST_HANDLE_STATE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS)
5794 #define FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES \
5795                                             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_READ_DATA)
5796 #define FSCTL_TXFS_LIST_TRANSACTIONS        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, FILE_READ_DATA)
5797 #define FSCTL_QUERY_PAGEFILE_ENCRYPTION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS)
5798 #define FSCTL_RESET_VOLUME_ALLOCATION_HINTS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS)
5799 #define FSCTL_TXFS_READ_BACKUP_INFORMATION2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, FILE_ANY_ACCESS)
5800 
5801 #endif
5802 
5803 #if (_WIN32_WINNT >= 0x0601)
5804 
5805 #define FSCTL_QUERY_DEPENDENT_VOLUME        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, FILE_ANY_ACCESS)
5806 #define FSCTL_SD_GLOBAL_CHANGE              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, FILE_ANY_ACCESS)
5807 #define FSCTL_LOOKUP_STREAM_FROM_CLUSTER    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS)
5808 #define FSCTL_TXFS_WRITE_BACKUP_INFORMATION2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, FILE_ANY_ACCESS)
5809 #define FSCTL_FILE_TYPE_NOTIFICATION        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS)
5810 #define FSCTL_GET_BOOT_AREA_INFO            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, FILE_ANY_ACCESS)
5811 #define FSCTL_GET_RETRIEVAL_POINTER_BASE    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS)
5812 #define FSCTL_SET_PERSISTENT_VOLUME_STATE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, FILE_ANY_ACCESS)
5813 #define FSCTL_QUERY_PERSISTENT_VOLUME_STATE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, FILE_ANY_ACCESS)
5814 #define FSCTL_REQUEST_OPLOCK                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS)
5815 #define FSCTL_CSV_TUNNEL_REQUEST            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, FILE_ANY_ACCESS)
5816 #define FSCTL_IS_CSV_FILE                   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, FILE_ANY_ACCESS)
5817 #define FSCTL_QUERY_FILE_SYSTEM_RECOGNITION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, FILE_ANY_ACCESS)
5818 #define FSCTL_CSV_GET_VOLUME_PATH_NAME      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS)
5819 #define FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS)
5820 #define FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 150,  METHOD_BUFFERED, FILE_ANY_ACCESS)
5821 #define FSCTL_IS_FILE_ON_CSV_VOLUME         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 151,  METHOD_BUFFERED, FILE_ANY_ACCESS)
5822 #define FSCTL_CSV_INTERNAL                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 155,  METHOD_BUFFERED, FILE_ANY_ACCESS)
5823 
5824 typedef struct _CSV_NAMESPACE_INFO {
5825   ULONG Version;
5826   ULONG DeviceNumber;
5827   LARGE_INTEGER StartingOffset;
5828   ULONG SectorSize;
5829 } CSV_NAMESPACE_INFO, *PCSV_NAMESPACE_INFO;
5830 
5831 #define CSV_NAMESPACE_INFO_V1 (sizeof(CSV_NAMESPACE_INFO))
5832 #define CSV_INVALID_DEVICE_NUMBER 0xFFFFFFFF
5833 
5834 #endif
5835 
5836 #if (_WIN32_WINNT >= 0x0602)
5837 
5838 #define FSCTL_FILE_LEVEL_TRIM               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, FILE_WRITE_DATA)
5839 #define FSCTL_CORRUPTION_HANDLING           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS)
5840 #define FSCTL_OFFLOAD_READ                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS)
5841 #define FSCTL_OFFLOAD_WRITE                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS)
5842 #define FSCTL_SET_PURGE_FAILURE_MODE        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS)
5843 #define FSCTL_QUERY_FILE_LAYOUT             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER,  FILE_ANY_ACCESS)
5844 #define FSCTL_IS_VOLUME_OWNED_BYCSVFS       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 158, METHOD_BUFFERED, FILE_ANY_ACCESS)
5845 #define FSCTL_GET_INTEGRITY_INFORMATION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
5846 #define FSCTL_SET_INTEGRITY_INFORMATION     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5847 #define FSCTL_QUERY_FILE_REGIONS            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS)
5848 #define FSCTL_DEDUP_FILE                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, FILE_ANY_ACCESS)
5849 #define FSCTL_DEDUP_QUERY_FILE_HASHES       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 166, METHOD_NEITHER,  FILE_READ_DATA)
5850 #define FSCTL_RKF_INTERNAL                  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER,  FILE_ANY_ACCESS)
5851 #define FSCTL_SCRUB_DATA                    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS)
5852 #define FSCTL_REPAIR_COPIES                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
5853 #define FSCTL_DISABLE_LOCAL_BUFFERING       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS)
5854 #define FSCTL_CSV_MGMT_LOCK                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS)
5855 #define FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS \
5856                                             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS)
5857 #define FSCTL_ADVANCE_FILE_ID               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS)
5858 #define FSCTL_CSV_SYNC_TUNNEL_REQUEST       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS)
5859 #define FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS)
5860 #define FSCTL_WRITE_USN_REASON              CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS)
5861 #define FSCTL_CSV_CONTROL                   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS)
5862 #define FSCTL_GET_REFS_VOLUME_DATA          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS)
5863 
5864 #endif
5865 
5866 #if (_WIN32_WINNT >= 0x0603)
5867 
5868 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_DATA)
5869 
5870 #endif
5871 
5872 #define FSCTL_MARK_AS_SYSTEM_HIVE           FSCTL_SET_BOOTLOADER_ACCESSED
5873 
5874 typedef struct _PATHNAME_BUFFER {
5875   ULONG PathNameLength;
5876   WCHAR Name[1];
5877 } PATHNAME_BUFFER, *PPATHNAME_BUFFER;
5878 
5879 typedef struct _FSCTL_QUERY_FAT_BPB_BUFFER {
5880   UCHAR First0x24BytesOfBootSector[0x24];
5881 } FSCTL_QUERY_FAT_BPB_BUFFER, *PFSCTL_QUERY_FAT_BPB_BUFFER;
5882 
5883 #if (_WIN32_WINNT >= 0x0400)
5884 
5885 typedef struct _NTFS_VOLUME_DATA_BUFFER {
5886   LARGE_INTEGER VolumeSerialNumber;
5887   LARGE_INTEGER NumberSectors;
5888   LARGE_INTEGER TotalClusters;
5889   LARGE_INTEGER FreeClusters;
5890   LARGE_INTEGER TotalReserved;
5891   ULONG BytesPerSector;
5892   ULONG BytesPerCluster;
5893   ULONG BytesPerFileRecordSegment;
5894   ULONG ClustersPerFileRecordSegment;
5895   LARGE_INTEGER MftValidDataLength;
5896   LARGE_INTEGER MftStartLcn;
5897   LARGE_INTEGER Mft2StartLcn;
5898   LARGE_INTEGER MftZoneStart;
5899   LARGE_INTEGER MftZoneEnd;
5900 } NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;
5901 
5902 typedef struct _NTFS_EXTENDED_VOLUME_DATA {
5903   ULONG ByteCount;
5904   USHORT MajorVersion;
5905   USHORT MinorVersion;
5906 } NTFS_EXTENDED_VOLUME_DATA, *PNTFS_EXTENDED_VOLUME_DATA;
5907 
5908 typedef struct _STARTING_LCN_INPUT_BUFFER {
5909   LARGE_INTEGER StartingLcn;
5910 } STARTING_LCN_INPUT_BUFFER, *PSTARTING_LCN_INPUT_BUFFER;
5911 
5912 typedef struct _VOLUME_BITMAP_BUFFER {
5913   LARGE_INTEGER StartingLcn;
5914   LARGE_INTEGER BitmapSize;
5915   UCHAR Buffer[1];
5916 } VOLUME_BITMAP_BUFFER, *PVOLUME_BITMAP_BUFFER;
5917 
5918 typedef struct _STARTING_VCN_INPUT_BUFFER {
5919   LARGE_INTEGER StartingVcn;
5920 } STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER;
5921 
5922 typedef struct _RETRIEVAL_POINTERS_BUFFER {
5923   ULONG ExtentCount;
5924   LARGE_INTEGER StartingVcn;
5925   struct {
5926     LARGE_INTEGER NextVcn;
5927     LARGE_INTEGER Lcn;
5928   } Extents[1];
5929 } RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER;
5930 
5931 typedef struct _NTFS_FILE_RECORD_INPUT_BUFFER {
5932   LARGE_INTEGER FileReferenceNumber;
5933 } NTFS_FILE_RECORD_INPUT_BUFFER, *PNTFS_FILE_RECORD_INPUT_BUFFER;
5934 
5935 typedef struct _NTFS_FILE_RECORD_OUTPUT_BUFFER {
5936   LARGE_INTEGER FileReferenceNumber;
5937   ULONG FileRecordLength;
5938   UCHAR FileRecordBuffer[1];
5939 } NTFS_FILE_RECORD_OUTPUT_BUFFER, *PNTFS_FILE_RECORD_OUTPUT_BUFFER;
5940 
5941 typedef struct _MOVE_FILE_DATA {
5942   HANDLE FileHandle;
5943   LARGE_INTEGER StartingVcn;
5944   LARGE_INTEGER StartingLcn;
5945   ULONG ClusterCount;
5946 } MOVE_FILE_DATA, *PMOVE_FILE_DATA;
5947 
5948 typedef struct _MOVE_FILE_RECORD_DATA {
5949   HANDLE FileHandle;
5950   LARGE_INTEGER SourceFileRecord;
5951   LARGE_INTEGER TargetFileRecord;
5952 } MOVE_FILE_RECORD_DATA, *PMOVE_FILE_RECORD_DATA;
5953 
5954 #if defined(_WIN64)
5955 typedef struct _MOVE_FILE_DATA32 {
5956   UINT32 FileHandle;
5957   LARGE_INTEGER StartingVcn;
5958   LARGE_INTEGER StartingLcn;
5959   ULONG ClusterCount;
5960 } MOVE_FILE_DATA32, *PMOVE_FILE_DATA32;
5961 #endif
5962 
5963 #endif /* (_WIN32_WINNT >= 0x0400) */
5964 
5965 #if (_WIN32_WINNT >= 0x0500)
5966 
5967 typedef struct _FIND_BY_SID_DATA {
5968   ULONG Restart;
5969   SID Sid;
5970 } FIND_BY_SID_DATA, *PFIND_BY_SID_DATA;
5971 
5972 typedef struct _FIND_BY_SID_OUTPUT {
5973   ULONG NextEntryOffset;
5974   ULONG FileIndex;
5975   ULONG FileNameLength;
5976   WCHAR FileName[1];
5977 } FIND_BY_SID_OUTPUT, *PFIND_BY_SID_OUTPUT;
5978 
5979 typedef struct _MFT_ENUM_DATA {
5980   ULONGLONG StartFileReferenceNumber;
5981   USN LowUsn;
5982   USN HighUsn;
5983 } MFT_ENUM_DATA, *PMFT_ENUM_DATA;
5984 
5985 typedef struct _CREATE_USN_JOURNAL_DATA {
5986   ULONGLONG MaximumSize;
5987   ULONGLONG AllocationDelta;
5988 } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA;
5989 
5990 typedef struct _READ_USN_JOURNAL_DATA {
5991   USN StartUsn;
5992   ULONG ReasonMask;
5993   ULONG ReturnOnlyOnClose;
5994   ULONGLONG Timeout;
5995   ULONGLONG BytesToWaitFor;
5996   ULONGLONG UsnJournalID;
5997 } READ_USN_JOURNAL_DATA, *PREAD_USN_JOURNAL_DATA;
5998 
5999 typedef struct _USN_RECORD {
6000   ULONG RecordLength;
6001   USHORT MajorVersion;
6002   USHORT MinorVersion;
6003   ULONGLONG FileReferenceNumber;
6004   ULONGLONG ParentFileReferenceNumber;
6005   USN Usn;
6006   LARGE_INTEGER TimeStamp;
6007   ULONG Reason;
6008   ULONG SourceInfo;
6009   ULONG SecurityId;
6010   ULONG FileAttributes;
6011   USHORT FileNameLength;
6012   USHORT FileNameOffset;
6013   WCHAR FileName[1];
6014 } USN_RECORD, *PUSN_RECORD;
6015 
6016 #define USN_PAGE_SIZE                    (0x1000)
6017 
6018 #define USN_REASON_DATA_OVERWRITE        (0x00000001)
6019 #define USN_REASON_DATA_EXTEND           (0x00000002)
6020 #define USN_REASON_DATA_TRUNCATION       (0x00000004)
6021 #define USN_REASON_NAMED_DATA_OVERWRITE  (0x00000010)
6022 #define USN_REASON_NAMED_DATA_EXTEND     (0x00000020)
6023 #define USN_REASON_NAMED_DATA_TRUNCATION (0x00000040)
6024 #define USN_REASON_FILE_CREATE           (0x00000100)
6025 #define USN_REASON_FILE_DELETE           (0x00000200)
6026 #define USN_REASON_EA_CHANGE             (0x00000400)
6027 #define USN_REASON_SECURITY_CHANGE       (0x00000800)
6028 #define USN_REASON_RENAME_OLD_NAME       (0x00001000)
6029 #define USN_REASON_RENAME_NEW_NAME       (0x00002000)
6030 #define USN_REASON_INDEXABLE_CHANGE      (0x00004000)
6031 #define USN_REASON_BASIC_INFO_CHANGE     (0x00008000)
6032 #define USN_REASON_HARD_LINK_CHANGE      (0x00010000)
6033 #define USN_REASON_COMPRESSION_CHANGE    (0x00020000)
6034 #define USN_REASON_ENCRYPTION_CHANGE     (0x00040000)
6035 #define USN_REASON_OBJECT_ID_CHANGE      (0x00080000)
6036 #define USN_REASON_REPARSE_POINT_CHANGE  (0x00100000)
6037 #define USN_REASON_STREAM_CHANGE         (0x00200000)
6038 #define USN_REASON_TRANSACTED_CHANGE     (0x00400000)
6039 #define USN_REASON_CLOSE                 (0x80000000)
6040 
6041 typedef struct _USN_JOURNAL_DATA {
6042   ULONGLONG UsnJournalID;
6043   USN FirstUsn;
6044   USN NextUsn;
6045   USN LowestValidUsn;
6046   USN MaxUsn;
6047   ULONGLONG MaximumSize;
6048   ULONGLONG AllocationDelta;
6049 } USN_JOURNAL_DATA, *PUSN_JOURNAL_DATA;
6050 
6051 typedef struct _DELETE_USN_JOURNAL_DATA {
6052   ULONGLONG UsnJournalID;
6053   ULONG DeleteFlags;
6054 } DELETE_USN_JOURNAL_DATA, *PDELETE_USN_JOURNAL_DATA;
6055 
6056 #define USN_DELETE_FLAG_DELETE              (0x00000001)
6057 #define USN_DELETE_FLAG_NOTIFY              (0x00000002)
6058 #define USN_DELETE_VALID_FLAGS              (0x00000003)
6059 
6060 typedef struct _MARK_HANDLE_INFO {
6061   ULONG UsnSourceInfo;
6062   HANDLE VolumeHandle;
6063   ULONG HandleInfo;
6064 } MARK_HANDLE_INFO, *PMARK_HANDLE_INFO;
6065 
6066 #if defined(_WIN64)
6067 typedef struct _MARK_HANDLE_INFO32 {
6068   ULONG UsnSourceInfo;
6069   UINT32 VolumeHandle;
6070   ULONG HandleInfo;
6071 } MARK_HANDLE_INFO32, *PMARK_HANDLE_INFO32;
6072 #endif
6073 
6074 #define USN_SOURCE_DATA_MANAGEMENT          (0x00000001)
6075 #define USN_SOURCE_AUXILIARY_DATA           (0x00000002)
6076 #define USN_SOURCE_REPLICATION_MANAGEMENT   (0x00000004)
6077 
6078 #define MARK_HANDLE_PROTECT_CLUSTERS        (0x00000001)
6079 #define MARK_HANDLE_TXF_SYSTEM_LOG          (0x00000004)
6080 #define MARK_HANDLE_NOT_TXF_SYSTEM_LOG      (0x00000008)
6081 
6082 typedef struct _BULK_SECURITY_TEST_DATA {
6083   ACCESS_MASK DesiredAccess;
6084   ULONG SecurityIds[1];
6085 } BULK_SECURITY_TEST_DATA, *PBULK_SECURITY_TEST_DATA;
6086 
6087 #define VOLUME_IS_DIRTY                  (0x00000001)
6088 #define VOLUME_UPGRADE_SCHEDULED         (0x00000002)
6089 #define VOLUME_SESSION_OPEN              (0x00000004)
6090 
6091 typedef struct _FILE_PREFETCH {
6092   ULONG Type;
6093   ULONG Count;
6094   ULONGLONG Prefetch[1];
6095 } FILE_PREFETCH, *PFILE_PREFETCH;
6096 
6097 typedef struct _FILE_PREFETCH_EX {
6098   ULONG Type;
6099   ULONG Count;
6100   PVOID Context;
6101   ULONGLONG Prefetch[1];
6102 } FILE_PREFETCH_EX, *PFILE_PREFETCH_EX;
6103 
6104 #define FILE_PREFETCH_TYPE_FOR_CREATE       0x1
6105 #define FILE_PREFETCH_TYPE_FOR_DIRENUM      0x2
6106 #define FILE_PREFETCH_TYPE_FOR_CREATE_EX    0x3
6107 #define FILE_PREFETCH_TYPE_FOR_DIRENUM_EX   0x4
6108 
6109 #define FILE_PREFETCH_TYPE_MAX              0x4
6110 
6111 typedef struct _FILE_OBJECTID_BUFFER {
6112   UCHAR ObjectId[16];
6113   _ANONYMOUS_UNION union {
6114     _ANONYMOUS_STRUCT struct {
6115       UCHAR BirthVolumeId[16];
6116       UCHAR BirthObjectId[16];
6117       UCHAR DomainId[16];
6118     } DUMMYSTRUCTNAME;
6119     UCHAR ExtendedInfo[48];
6120   } DUMMYUNIONNAME;
6121 } FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER;
6122 
6123 typedef struct _FILE_SET_SPARSE_BUFFER {
6124   BOOLEAN SetSparse;
6125 } FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER;
6126 
6127 typedef struct _FILE_ZERO_DATA_INFORMATION {
6128   LARGE_INTEGER FileOffset;
6129   LARGE_INTEGER BeyondFinalZero;
6130 } FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION;
6131 
6132 typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
6133   LARGE_INTEGER FileOffset;
6134   LARGE_INTEGER Length;
6135 } FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
6136 
6137 typedef struct _ENCRYPTION_BUFFER {
6138   ULONG EncryptionOperation;
6139   UCHAR Private[1];
6140 } ENCRYPTION_BUFFER, *PENCRYPTION_BUFFER;
6141 
6142 #define FILE_SET_ENCRYPTION         0x00000001
6143 #define FILE_CLEAR_ENCRYPTION       0x00000002
6144 #define STREAM_SET_ENCRYPTION       0x00000003
6145 #define STREAM_CLEAR_ENCRYPTION     0x00000004
6146 
6147 #define MAXIMUM_ENCRYPTION_VALUE    0x00000004
6148 
6149 typedef struct _DECRYPTION_STATUS_BUFFER {
6150   BOOLEAN NoEncryptedStreams;
6151 } DECRYPTION_STATUS_BUFFER, *PDECRYPTION_STATUS_BUFFER;
6152 
6153 #define ENCRYPTION_FORMAT_DEFAULT        (0x01)
6154 
6155 #define COMPRESSION_FORMAT_SPARSE        (0x4000)
6156 
6157 typedef struct _REQUEST_RAW_ENCRYPTED_DATA {
6158   LONGLONG FileOffset;
6159   ULONG Length;
6160 } REQUEST_RAW_ENCRYPTED_DATA, *PREQUEST_RAW_ENCRYPTED_DATA;
6161 
6162 typedef struct _ENCRYPTED_DATA_INFO {
6163   ULONGLONG StartingFileOffset;
6164   ULONG OutputBufferOffset;
6165   ULONG BytesWithinFileSize;
6166   ULONG BytesWithinValidDataLength;
6167   USHORT CompressionFormat;
6168   UCHAR DataUnitShift;
6169   UCHAR ChunkShift;
6170   UCHAR ClusterShift;
6171   UCHAR EncryptionFormat;
6172   USHORT NumberOfDataBlocks;
6173   ULONG DataBlockSize[ANYSIZE_ARRAY];
6174 } ENCRYPTED_DATA_INFO, *PENCRYPTED_DATA_INFO;
6175 
6176 typedef struct _PLEX_READ_DATA_REQUEST {
6177   LARGE_INTEGER ByteOffset;
6178   ULONG ByteLength;
6179   ULONG PlexNumber;
6180 } PLEX_READ_DATA_REQUEST, *PPLEX_READ_DATA_REQUEST;
6181 
6182 typedef struct _SI_COPYFILE {
6183   ULONG SourceFileNameLength;
6184   ULONG DestinationFileNameLength;
6185   ULONG Flags;
6186   WCHAR FileNameBuffer[1];
6187 } SI_COPYFILE, *PSI_COPYFILE;
6188 
6189 #define COPYFILE_SIS_LINK       0x0001
6190 #define COPYFILE_SIS_REPLACE    0x0002
6191 #define COPYFILE_SIS_FLAGS      0x0003
6192 
6193 #endif /* (_WIN32_WINNT >= 0x0500) */
6194 
6195 #if (_WIN32_WINNT >= 0x0600)
6196 
6197 typedef struct _FILE_MAKE_COMPATIBLE_BUFFER {
6198   BOOLEAN CloseDisc;
6199 } FILE_MAKE_COMPATIBLE_BUFFER, *PFILE_MAKE_COMPATIBLE_BUFFER;
6200 
6201 typedef struct _FILE_SET_DEFECT_MGMT_BUFFER {
6202   BOOLEAN Disable;
6203 } FILE_SET_DEFECT_MGMT_BUFFER, *PFILE_SET_DEFECT_MGMT_BUFFER;
6204 
6205 typedef struct _FILE_QUERY_SPARING_BUFFER {
6206   ULONG SparingUnitBytes;
6207   BOOLEAN SoftwareSparing;
6208   ULONG TotalSpareBlocks;
6209   ULONG FreeSpareBlocks;
6210 } FILE_QUERY_SPARING_BUFFER, *PFILE_QUERY_SPARING_BUFFER;
6211 
6212 typedef struct _FILE_QUERY_ON_DISK_VOL_INFO_BUFFER {
6213   LARGE_INTEGER DirectoryCount;
6214   LARGE_INTEGER FileCount;
6215   USHORT FsFormatMajVersion;
6216   USHORT FsFormatMinVersion;
6217   WCHAR FsFormatName[12];
6218   LARGE_INTEGER FormatTime;
6219   LARGE_INTEGER LastUpdateTime;
6220   WCHAR CopyrightInfo[34];
6221   WCHAR AbstractInfo[34];
6222   WCHAR FormattingImplementationInfo[34];
6223   WCHAR LastModifyingImplementationInfo[34];
6224 } FILE_QUERY_ON_DISK_VOL_INFO_BUFFER, *PFILE_QUERY_ON_DISK_VOL_INFO_BUFFER;
6225 
6226 #define SET_REPAIR_ENABLED                                      (0x00000001)
6227 #define SET_REPAIR_VOLUME_BITMAP_SCAN                           (0x00000002)
6228 #define SET_REPAIR_DELETE_CROSSLINK                             (0x00000004)
6229 #define SET_REPAIR_WARN_ABOUT_DATA_LOSS                         (0x00000008)
6230 #define SET_REPAIR_DISABLED_AND_BUGCHECK_ON_CORRUPT             (0x00000010)
6231 #define SET_REPAIR_VALID_MASK                                   (0x0000001F)
6232 
6233 typedef enum _SHRINK_VOLUME_REQUEST_TYPES {
6234   ShrinkPrepare = 1,
6235   ShrinkCommit,
6236   ShrinkAbort
6237 } SHRINK_VOLUME_REQUEST_TYPES, *PSHRINK_VOLUME_REQUEST_TYPES;
6238 
6239 typedef struct _SHRINK_VOLUME_INFORMATION {
6240   SHRINK_VOLUME_REQUEST_TYPES ShrinkRequestType;
6241   ULONGLONG Flags;
6242   LONGLONG NewNumberOfSectors;
6243 } SHRINK_VOLUME_INFORMATION, *PSHRINK_VOLUME_INFORMATION;
6244 
6245 #define TXFS_RM_FLAG_LOGGING_MODE                           0x00000001
6246 #define TXFS_RM_FLAG_RENAME_RM                              0x00000002
6247 #define TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MAX                0x00000004
6248 #define TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MIN                0x00000008
6249 #define TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS    0x00000010
6250 #define TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT           0x00000020
6251 #define TXFS_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE             0x00000040
6252 #define TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX             0x00000080
6253 #define TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN             0x00000100
6254 #define TXFS_RM_FLAG_GROW_LOG                               0x00000400
6255 #define TXFS_RM_FLAG_SHRINK_LOG                             0x00000800
6256 #define TXFS_RM_FLAG_ENFORCE_MINIMUM_SIZE                   0x00001000
6257 #define TXFS_RM_FLAG_PRESERVE_CHANGES                       0x00002000
6258 #define TXFS_RM_FLAG_RESET_RM_AT_NEXT_START                 0x00004000
6259 #define TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START          0x00008000
6260 #define TXFS_RM_FLAG_PREFER_CONSISTENCY                     0x00010000
6261 #define TXFS_RM_FLAG_PREFER_AVAILABILITY                    0x00020000
6262 
6263 #define TXFS_LOGGING_MODE_SIMPLE        (0x0001)
6264 #define TXFS_LOGGING_MODE_FULL          (0x0002)
6265 
6266 #define TXFS_TRANSACTION_STATE_NONE         0x00
6267 #define TXFS_TRANSACTION_STATE_ACTIVE       0x01
6268 #define TXFS_TRANSACTION_STATE_PREPARED     0x02
6269 #define TXFS_TRANSACTION_STATE_NOTACTIVE    0x03
6270 
6271 #define TXFS_MODIFY_RM_VALID_FLAGS (TXFS_RM_FLAG_LOGGING_MODE                        | \
6272                                     TXFS_RM_FLAG_RENAME_RM                           | \
6273                                     TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MAX             | \
6274                                     TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MIN             | \
6275                                     TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS | \
6276                                     TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT        | \
6277                                     TXFS_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE          | \
6278                                     TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX          | \
6279                                     TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN          | \
6280                                     TXFS_RM_FLAG_SHRINK_LOG                          | \
6281                                     TXFS_RM_FLAG_GROW_LOG                            | \
6282                                     TXFS_RM_FLAG_ENFORCE_MINIMUM_SIZE                | \
6283                                     TXFS_RM_FLAG_PRESERVE_CHANGES                    | \
6284                                     TXFS_RM_FLAG_RESET_RM_AT_NEXT_START              | \
6285                                     TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START       | \
6286                                     TXFS_RM_FLAG_PREFER_CONSISTENCY                  | \
6287                                     TXFS_RM_FLAG_PREFER_AVAILABILITY)
6288 
6289 typedef struct _TXFS_MODIFY_RM {
6290   ULONG Flags;
6291   ULONG LogContainerCountMax;
6292   ULONG LogContainerCountMin;
6293   ULONG LogContainerCount;
6294   ULONG LogGrowthIncrement;
6295   ULONG LogAutoShrinkPercentage;
6296   ULONGLONG Reserved;
6297   USHORT LoggingMode;
6298 } TXFS_MODIFY_RM, *PTXFS_MODIFY_RM;
6299 
6300 #define TXFS_RM_STATE_NOT_STARTED       0
6301 #define TXFS_RM_STATE_STARTING          1
6302 #define TXFS_RM_STATE_ACTIVE            2
6303 #define TXFS_RM_STATE_SHUTTING_DOWN     3
6304 
6305 #define TXFS_QUERY_RM_INFORMATION_VALID_FLAGS                           \
6306                 (TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS   |   \
6307                  TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT          |   \
6308                  TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX            |   \
6309                  TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN            |   \
6310                  TXFS_RM_FLAG_RESET_RM_AT_NEXT_START                |   \
6311                  TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START         |   \
6312                  TXFS_RM_FLAG_PREFER_CONSISTENCY                    |   \
6313                  TXFS_RM_FLAG_PREFER_AVAILABILITY)
6314 
6315 typedef struct _TXFS_QUERY_RM_INFORMATION {
6316   ULONG BytesRequired;
6317   ULONGLONG TailLsn;
6318   ULONGLONG CurrentLsn;
6319   ULONGLONG ArchiveTailLsn;
6320   ULONGLONG LogContainerSize;
6321   LARGE_INTEGER HighestVirtualClock;
6322   ULONG LogContainerCount;
6323   ULONG LogContainerCountMax;
6324   ULONG LogContainerCountMin;
6325   ULONG LogGrowthIncrement;
6326   ULONG LogAutoShrinkPercentage;
6327   ULONG Flags;
6328   USHORT LoggingMode;
6329   USHORT Reserved;
6330   ULONG RmState;
6331   ULONGLONG LogCapacity;
6332   ULONGLONG LogFree;
6333   ULONGLONG TopsSize;
6334   ULONGLONG TopsUsed;
6335   ULONGLONG TransactionCount;
6336   ULONGLONG OnePCCount;
6337   ULONGLONG TwoPCCount;
6338   ULONGLONG NumberLogFileFull;
6339   ULONGLONG OldestTransactionAge;
6340   GUID RMName;
6341   ULONG TmLogPathOffset;
6342 } TXFS_QUERY_RM_INFORMATION, *PTXFS_QUERY_RM_INFORMATION;
6343 
6344 #define TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_REDO_LSN        0x01
6345 #define TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_VIRTUAL_CLOCK   0x02
6346 
6347 #define TXFS_ROLLFORWARD_REDO_VALID_FLAGS                               \
6348                 (TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_REDO_LSN |         \
6349                  TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_VIRTUAL_CLOCK)
6350 
6351 typedef struct _TXFS_ROLLFORWARD_REDO_INFORMATION {
6352   LARGE_INTEGER LastVirtualClock;
6353   ULONGLONG LastRedoLsn;
6354   ULONGLONG HighestRecoveryLsn;
6355   ULONG Flags;
6356 } TXFS_ROLLFORWARD_REDO_INFORMATION, *PTXFS_ROLLFORWARD_REDO_INFORMATION;
6357 
6358 #define TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MAX              0x00000001
6359 #define TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MIN              0x00000002
6360 #define TXFS_START_RM_FLAG_LOG_CONTAINER_SIZE                   0x00000004
6361 #define TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS  0x00000008
6362 #define TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT         0x00000010
6363 #define TXFS_START_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE           0x00000020
6364 #define TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX           0x00000040
6365 #define TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN           0x00000080
6366 
6367 #define TXFS_START_RM_FLAG_RECOVER_BEST_EFFORT                  0x00000200
6368 #define TXFS_START_RM_FLAG_LOGGING_MODE                         0x00000400
6369 #define TXFS_START_RM_FLAG_PRESERVE_CHANGES                     0x00000800
6370 
6371 #define TXFS_START_RM_FLAG_PREFER_CONSISTENCY                   0x00001000
6372 #define TXFS_START_RM_FLAG_PREFER_AVAILABILITY                  0x00002000
6373 
6374 #define TXFS_START_RM_VALID_FLAGS                                           \
6375                 (TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MAX             |   \
6376                  TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MIN             |   \
6377                  TXFS_START_RM_FLAG_LOG_CONTAINER_SIZE                  |   \
6378                  TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS |   \
6379                  TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT        |   \
6380                  TXFS_START_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE          |   \
6381                  TXFS_START_RM_FLAG_RECOVER_BEST_EFFORT                 |   \
6382                  TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX          |   \
6383                  TXFS_START_RM_FLAG_LOGGING_MODE                        |   \
6384                  TXFS_START_RM_FLAG_PRESERVE_CHANGES                    |   \
6385                  TXFS_START_RM_FLAG_PREFER_CONSISTENCY                  |   \
6386                  TXFS_START_RM_FLAG_PREFER_AVAILABILITY)
6387 
6388 typedef struct _TXFS_START_RM_INFORMATION {
6389   ULONG Flags;
6390   ULONGLONG LogContainerSize;
6391   ULONG LogContainerCountMin;
6392   ULONG LogContainerCountMax;
6393   ULONG LogGrowthIncrement;
6394   ULONG LogAutoShrinkPercentage;
6395   ULONG TmLogPathOffset;
6396   USHORT TmLogPathLength;
6397   USHORT LoggingMode;
6398   USHORT LogPathLength;
6399   USHORT Reserved;
6400   WCHAR LogPath[1];
6401 } TXFS_START_RM_INFORMATION, *PTXFS_START_RM_INFORMATION;
6402 
6403 typedef struct _TXFS_GET_METADATA_INFO_OUT {
6404   struct {
6405     LONGLONG LowPart;
6406     LONGLONG HighPart;
6407   } TxfFileId;
6408   GUID LockingTransaction;
6409   ULONGLONG LastLsn;
6410   ULONG TransactionState;
6411 } TXFS_GET_METADATA_INFO_OUT, *PTXFS_GET_METADATA_INFO_OUT;
6412 
6413 #define TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY_FLAG_CREATED   0x00000001
6414 #define TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY_FLAG_DELETED   0x00000002
6415 
6416 typedef struct _TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY {
6417   ULONGLONG Offset;
6418   ULONG NameFlags;
6419   LONGLONG FileId;
6420   ULONG Reserved1;
6421   ULONG Reserved2;
6422   LONGLONG Reserved3;
6423   WCHAR FileName[1];
6424 } TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY, *PTXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY;
6425 
6426 typedef struct _TXFS_LIST_TRANSACTION_LOCKED_FILES {
6427   GUID KtmTransaction;
6428   ULONGLONG NumberOfFiles;
6429   ULONGLONG BufferSizeRequired;
6430   ULONGLONG Offset;
6431 } TXFS_LIST_TRANSACTION_LOCKED_FILES, *PTXFS_LIST_TRANSACTION_LOCKED_FILES;
6432 
6433 typedef struct _TXFS_LIST_TRANSACTIONS_ENTRY {
6434   GUID TransactionId;
6435   ULONG TransactionState;
6436   ULONG Reserved1;
6437   ULONG Reserved2;
6438   LONGLONG Reserved3;
6439 } TXFS_LIST_TRANSACTIONS_ENTRY, *PTXFS_LIST_TRANSACTIONS_ENTRY;
6440 
6441 typedef struct _TXFS_LIST_TRANSACTIONS {
6442   ULONGLONG NumberOfTransactions;
6443   ULONGLONG BufferSizeRequired;
6444 } TXFS_LIST_TRANSACTIONS, *PTXFS_LIST_TRANSACTIONS;
6445 
6446 typedef struct _TXFS_READ_BACKUP_INFORMATION_OUT {
6447   _ANONYMOUS_UNION union {
6448     ULONG BufferLength;
6449     UCHAR Buffer[1];
6450   } DUMMYUNIONNAME;
6451 } TXFS_READ_BACKUP_INFORMATION_OUT, *PTXFS_READ_BACKUP_INFORMATION_OUT;
6452 
6453 typedef struct _TXFS_WRITE_BACKUP_INFORMATION {
6454   UCHAR Buffer[1];
6455 } TXFS_WRITE_BACKUP_INFORMATION, *PTXFS_WRITE_BACKUP_INFORMATION;
6456 
6457 #define TXFS_TRANSACTED_VERSION_NONTRANSACTED   0xFFFFFFFE
6458 #define TXFS_TRANSACTED_VERSION_UNCOMMITTED     0xFFFFFFFF
6459 
6460 typedef struct _TXFS_GET_TRANSACTED_VERSION {
6461   ULONG ThisBaseVersion;
6462   ULONG LatestVersion;
6463   USHORT ThisMiniVersion;
6464   USHORT FirstMiniVersion;
6465   USHORT LatestMiniVersion;
6466 } TXFS_GET_TRANSACTED_VERSION, *PTXFS_GET_TRANSACTED_VERSION;
6467 
6468 #define TXFS_SAVEPOINT_SET                      0x00000001
6469 #define TXFS_SAVEPOINT_ROLLBACK                 0x00000002
6470 #define TXFS_SAVEPOINT_CLEAR                    0x00000004
6471 #define TXFS_SAVEPOINT_CLEAR_ALL                0x00000010
6472 
6473 typedef struct _TXFS_SAVEPOINT_INFORMATION {
6474   HANDLE KtmTransaction;
6475   ULONG ActionCode;
6476   ULONG SavepointId;
6477 } TXFS_SAVEPOINT_INFORMATION, *PTXFS_SAVEPOINT_INFORMATION;
6478 
6479 typedef struct _TXFS_CREATE_MINIVERSION_INFO {
6480   USHORT StructureVersion;
6481   USHORT StructureLength;
6482   ULONG BaseVersion;
6483   USHORT MiniVersion;
6484 } TXFS_CREATE_MINIVERSION_INFO, *PTXFS_CREATE_MINIVERSION_INFO;
6485 
6486 typedef struct _TXFS_TRANSACTION_ACTIVE_INFO {
6487   BOOLEAN TransactionsActiveAtSnapshot;
6488 } TXFS_TRANSACTION_ACTIVE_INFO, *PTXFS_TRANSACTION_ACTIVE_INFO;
6489 
6490 #endif /* (_WIN32_WINNT >= 0x0600) */
6491 
6492 #if (_WIN32_WINNT >= 0x0601)
6493 
6494 #define MARK_HANDLE_REALTIME                (0x00000020)
6495 #define MARK_HANDLE_NOT_REALTIME            (0x00000040)
6496 
6497 #define NO_8DOT3_NAME_PRESENT               (0x00000001)
6498 #define REMOVED_8DOT3_NAME                  (0x00000002)
6499 
6500 #define PERSISTENT_VOLUME_STATE_SHORT_NAME_CREATION_DISABLED        (0x00000001)
6501 
6502 typedef struct _BOOT_AREA_INFO {
6503   ULONG BootSectorCount;
6504   struct {
6505     LARGE_INTEGER Offset;
6506   } BootSectors[2];
6507 } BOOT_AREA_INFO, *PBOOT_AREA_INFO;
6508 
6509 typedef struct _RETRIEVAL_POINTER_BASE {
6510   LARGE_INTEGER FileAreaOffset;
6511 } RETRIEVAL_POINTER_BASE, *PRETRIEVAL_POINTER_BASE;
6512 
6513 typedef struct _FILE_FS_PERSISTENT_VOLUME_INFORMATION {
6514   ULONG VolumeFlags;
6515   ULONG FlagMask;
6516   ULONG Version;
6517   ULONG Reserved;
6518 } FILE_FS_PERSISTENT_VOLUME_INFORMATION, *PFILE_FS_PERSISTENT_VOLUME_INFORMATION;
6519 
6520 typedef struct _FILE_SYSTEM_RECOGNITION_INFORMATION {
6521   CHAR FileSystem[9];
6522 } FILE_SYSTEM_RECOGNITION_INFORMATION, *PFILE_SYSTEM_RECOGNITION_INFORMATION;
6523 
6524 #define OPLOCK_LEVEL_CACHE_READ         (0x00000001)
6525 #define OPLOCK_LEVEL_CACHE_HANDLE       (0x00000002)
6526 #define OPLOCK_LEVEL_CACHE_WRITE        (0x00000004)
6527 
6528 #define REQUEST_OPLOCK_INPUT_FLAG_REQUEST               (0x00000001)
6529 #define REQUEST_OPLOCK_INPUT_FLAG_ACK                   (0x00000002)
6530 #define REQUEST_OPLOCK_INPUT_FLAG_COMPLETE_ACK_ON_CLOSE (0x00000004)
6531 
6532 #define REQUEST_OPLOCK_CURRENT_VERSION          1
6533 
6534 typedef struct _REQUEST_OPLOCK_INPUT_BUFFER {
6535   USHORT StructureVersion;
6536   USHORT StructureLength;
6537   ULONG RequestedOplockLevel;
6538   ULONG Flags;
6539 } REQUEST_OPLOCK_INPUT_BUFFER, *PREQUEST_OPLOCK_INPUT_BUFFER;
6540 
6541 #define REQUEST_OPLOCK_OUTPUT_FLAG_ACK_REQUIRED     (0x00000001)
6542 #define REQUEST_OPLOCK_OUTPUT_FLAG_MODES_PROVIDED   (0x00000002)
6543 
6544 typedef struct _REQUEST_OPLOCK_OUTPUT_BUFFER {
6545   USHORT StructureVersion;
6546   USHORT StructureLength;
6547   ULONG OriginalOplockLevel;
6548   ULONG NewOplockLevel;
6549   ULONG Flags;
6550   ACCESS_MASK AccessMode;
6551   USHORT ShareMode;
6552 } REQUEST_OPLOCK_OUTPUT_BUFFER, *PREQUEST_OPLOCK_OUTPUT_BUFFER;
6553 
6554 #define SD_GLOBAL_CHANGE_TYPE_MACHINE_SID   1
6555 
6556 typedef struct _SD_CHANGE_MACHINE_SID_INPUT {
6557   USHORT CurrentMachineSIDOffset;
6558   USHORT CurrentMachineSIDLength;
6559   USHORT NewMachineSIDOffset;
6560   USHORT NewMachineSIDLength;
6561 } SD_CHANGE_MACHINE_SID_INPUT, *PSD_CHANGE_MACHINE_SID_INPUT;
6562 
6563 typedef struct _SD_CHANGE_MACHINE_SID_OUTPUT {
6564   ULONGLONG NumSDChangedSuccess;
6565   ULONGLONG NumSDChangedFail;
6566   ULONGLONG NumSDUnused;
6567   ULONGLONG NumSDTotal;
6568   ULONGLONG NumMftSDChangedSuccess;
6569   ULONGLONG NumMftSDChangedFail;
6570   ULONGLONG NumMftSDTotal;
6571 } SD_CHANGE_MACHINE_SID_OUTPUT, *PSD_CHANGE_MACHINE_SID_OUTPUT;
6572 
6573 typedef struct _SD_GLOBAL_CHANGE_INPUT {
6574   ULONG Flags;
6575   ULONG ChangeType;
6576   _ANONYMOUS_UNION union {
6577     SD_CHANGE_MACHINE_SID_INPUT SdChange;
6578   } DUMMYUNIONNAME;
6579 } SD_GLOBAL_CHANGE_INPUT, *PSD_GLOBAL_CHANGE_INPUT;
6580 
6581 typedef struct _SD_GLOBAL_CHANGE_OUTPUT {
6582   ULONG Flags;
6583   ULONG ChangeType;
6584   _ANONYMOUS_UNION union {
6585     SD_CHANGE_MACHINE_SID_OUTPUT SdChange;
6586   } DUMMYUNIONNAME;
6587 } SD_GLOBAL_CHANGE_OUTPUT, *PSD_GLOBAL_CHANGE_OUTPUT;
6588 
6589 #define ENCRYPTED_DATA_INFO_SPARSE_FILE    1
6590 
6591 typedef struct _EXTENDED_ENCRYPTED_DATA_INFO {
6592   ULONG ExtendedCode;
6593   ULONG Length;
6594   ULONG Flags;
6595   ULONG Reserved;
6596 } EXTENDED_ENCRYPTED_DATA_INFO, *PEXTENDED_ENCRYPTED_DATA_INFO;
6597 
6598 typedef struct _LOOKUP_STREAM_FROM_CLUSTER_INPUT {
6599   ULONG Flags;
6600   ULONG NumberOfClusters;
6601   LARGE_INTEGER Cluster[1];
6602 } LOOKUP_STREAM_FROM_CLUSTER_INPUT, *PLOOKUP_STREAM_FROM_CLUSTER_INPUT;
6603 
6604 typedef struct _LOOKUP_STREAM_FROM_CLUSTER_OUTPUT {
6605   ULONG Offset;
6606   ULONG NumberOfMatches;
6607   ULONG BufferSizeRequired;
6608 } LOOKUP_STREAM_FROM_CLUSTER_OUTPUT, *PLOOKUP_STREAM_FROM_CLUSTER_OUTPUT;
6609 
6610 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_PAGE_FILE          0x00000001
6611 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_DENY_DEFRAG_SET    0x00000002
6612 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_FS_SYSTEM_FILE     0x00000004
6613 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_TXF_SYSTEM_FILE    0x00000008
6614 
6615 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_MASK          0xff000000
6616 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_DATA          0x01000000
6617 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_INDEX         0x02000000
6618 #define LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_SYSTEM        0x03000000
6619 
6620 typedef struct _LOOKUP_STREAM_FROM_CLUSTER_ENTRY {
6621   ULONG OffsetToNext;
6622   ULONG Flags;
6623   LARGE_INTEGER Reserved;
6624   LARGE_INTEGER Cluster;
6625   WCHAR FileName[1];
6626 } LOOKUP_STREAM_FROM_CLUSTER_ENTRY, *PLOOKUP_STREAM_FROM_CLUSTER_ENTRY;
6627 
6628 typedef struct _FILE_TYPE_NOTIFICATION_INPUT {
6629   ULONG Flags;
6630   ULONG NumFileTypeIDs;
6631   GUID FileTypeID[1];
6632 } FILE_TYPE_NOTIFICATION_INPUT, *PFILE_TYPE_NOTIFICATION_INPUT;
6633 
6634 #define FILE_TYPE_NOTIFICATION_FLAG_USAGE_BEGIN     0x00000001
6635 #define FILE_TYPE_NOTIFICATION_FLAG_USAGE_END       0x00000002
6636 
6637 DEFINE_GUID(FILE_TYPE_NOTIFICATION_GUID_PAGE_FILE,         0x0d0a64a1, 0x38fc, 0x4db8, 0x9f, 0xe7, 0x3f, 0x43, 0x52, 0xcd, 0x7c, 0x5c);
6638 DEFINE_GUID(FILE_TYPE_NOTIFICATION_GUID_HIBERNATION_FILE,  0xb7624d64, 0xb9a3, 0x4cf8, 0x80, 0x11, 0x5b, 0x86, 0xc9, 0x40, 0xe7, 0xb7);
6639 DEFINE_GUID(FILE_TYPE_NOTIFICATION_GUID_CRASHDUMP_FILE,    0x9d453eb7, 0xd2a6, 0x4dbd, 0xa2, 0xe3, 0xfb, 0xd0, 0xed, 0x91, 0x09, 0xa9);
6640 
6641 #ifndef _VIRTUAL_STORAGE_TYPE_DEFINED
6642 #define _VIRTUAL_STORAGE_TYPE_DEFINED
6643 typedef struct _VIRTUAL_STORAGE_TYPE {
6644   ULONG DeviceId;
6645   GUID VendorId;
6646 } VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE;
6647 #endif
6648 
6649 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST {
6650   ULONG RequestLevel;
6651   ULONG RequestFlags;
6652 } STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST, *PSTORAGE_QUERY_DEPENDENT_VOLUME_REQUEST;
6653 
6654 #define QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_HOST_VOLUMES    0x1
6655 #define QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_GUEST_VOLUMES   0x2
6656 
6657 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY {
6658   ULONG EntryLength;
6659   ULONG DependencyTypeFlags;
6660   ULONG ProviderSpecificFlags;
6661   VIRTUAL_STORAGE_TYPE VirtualStorageType;
6662 } STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY, *PSTORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY;
6663 
6664 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY {
6665   ULONG EntryLength;
6666   ULONG DependencyTypeFlags;
6667   ULONG ProviderSpecificFlags;
6668   VIRTUAL_STORAGE_TYPE VirtualStorageType;
6669   ULONG AncestorLevel;
6670   ULONG HostVolumeNameOffset;
6671   ULONG HostVolumeNameSize;
6672   ULONG DependentVolumeNameOffset;
6673   ULONG DependentVolumeNameSize;
6674   ULONG RelativePathOffset;
6675   ULONG RelativePathSize;
6676   ULONG DependentDeviceNameOffset;
6677   ULONG DependentDeviceNameSize;
6678 } STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY, *PSTORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY;
6679 
6680 typedef struct _STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE {
6681   ULONG ResponseLevel;
6682   ULONG NumberEntries;
6683   _ANONYMOUS_UNION union {
6684     STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY Lev1Depends[0];
6685     STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY Lev2Depends[0];
6686   } DUMMYUNIONNAME;
6687 } STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE, *PSTORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE;
6688 
6689 #endif /* (_WIN32_WINNT >= 0x0601) */
6690 
6691 typedef struct _FILESYSTEM_STATISTICS {
6692   USHORT FileSystemType;
6693   USHORT Version;
6694   ULONG SizeOfCompleteStructure;
6695   ULONG UserFileReads;
6696   ULONG UserFileReadBytes;
6697   ULONG UserDiskReads;
6698   ULONG UserFileWrites;
6699   ULONG UserFileWriteBytes;
6700   ULONG UserDiskWrites;
6701   ULONG MetaDataReads;
6702   ULONG MetaDataReadBytes;
6703   ULONG MetaDataDiskReads;
6704   ULONG MetaDataWrites;
6705   ULONG MetaDataWriteBytes;
6706   ULONG MetaDataDiskWrites;
6707 } FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS;
6708 
6709 #define FILESYSTEM_STATISTICS_TYPE_NTFS     1
6710 #define FILESYSTEM_STATISTICS_TYPE_FAT      2
6711 #define FILESYSTEM_STATISTICS_TYPE_EXFAT    3
6712 
6713 typedef struct _FAT_STATISTICS {
6714   ULONG CreateHits;
6715   ULONG SuccessfulCreates;
6716   ULONG FailedCreates;
6717   ULONG NonCachedReads;
6718   ULONG NonCachedReadBytes;
6719   ULONG NonCachedWrites;
6720   ULONG NonCachedWriteBytes;
6721   ULONG NonCachedDiskReads;
6722   ULONG NonCachedDiskWrites;
6723 } FAT_STATISTICS, *PFAT_STATISTICS;
6724 
6725 typedef struct _EXFAT_STATISTICS {
6726   ULONG CreateHits;
6727   ULONG SuccessfulCreates;
6728   ULONG FailedCreates;
6729   ULONG NonCachedReads;
6730   ULONG NonCachedReadBytes;
6731   ULONG NonCachedWrites;
6732   ULONG NonCachedWriteBytes;
6733   ULONG NonCachedDiskReads;
6734   ULONG NonCachedDiskWrites;
6735 } EXFAT_STATISTICS, *PEXFAT_STATISTICS;
6736 
6737 typedef struct _NTFS_STATISTICS {
6738   ULONG LogFileFullExceptions;
6739   ULONG OtherExceptions;
6740   ULONG MftReads;
6741   ULONG MftReadBytes;
6742   ULONG MftWrites;
6743   ULONG MftWriteBytes;
6744   struct {
6745     USHORT Write;
6746     USHORT Create;
6747     USHORT SetInfo;
6748     USHORT Flush;
6749   } MftWritesUserLevel;
6750   USHORT MftWritesFlushForLogFileFull;
6751   USHORT MftWritesLazyWriter;
6752   USHORT MftWritesUserRequest;
6753   ULONG Mft2Writes;
6754   ULONG Mft2WriteBytes;
6755   struct {
6756     USHORT Write;
6757     USHORT Create;
6758     USHORT SetInfo;
6759     USHORT Flush;
6760   } Mft2WritesUserLevel;
6761   USHORT Mft2WritesFlushForLogFileFull;
6762   USHORT Mft2WritesLazyWriter;
6763   USHORT Mft2WritesUserRequest;
6764   ULONG RootIndexReads;
6765   ULONG RootIndexReadBytes;
6766   ULONG RootIndexWrites;
6767   ULONG RootIndexWriteBytes;
6768   ULONG BitmapReads;
6769   ULONG BitmapReadBytes;
6770   ULONG BitmapWrites;
6771   ULONG BitmapWriteBytes;
6772   USHORT BitmapWritesFlushForLogFileFull;
6773   USHORT BitmapWritesLazyWriter;
6774   USHORT BitmapWritesUserRequest;
6775   struct {
6776     USHORT Write;
6777     USHORT Create;
6778     USHORT SetInfo;
6779   } BitmapWritesUserLevel;
6780   ULONG MftBitmapReads;
6781   ULONG MftBitmapReadBytes;
6782   ULONG MftBitmapWrites;
6783   ULONG MftBitmapWriteBytes;
6784   USHORT MftBitmapWritesFlushForLogFileFull;
6785   USHORT MftBitmapWritesLazyWriter;
6786   USHORT MftBitmapWritesUserRequest;
6787   struct {
6788     USHORT Write;
6789     USHORT Create;
6790     USHORT SetInfo;
6791     USHORT Flush;
6792   } MftBitmapWritesUserLevel;
6793   ULONG UserIndexReads;
6794   ULONG UserIndexReadBytes;
6795   ULONG UserIndexWrites;
6796   ULONG UserIndexWriteBytes;
6797   ULONG LogFileReads;
6798   ULONG LogFileReadBytes;
6799   ULONG LogFileWrites;
6800   ULONG LogFileWriteBytes;
6801   struct {
6802     ULONG Calls;
6803     ULONG Clusters;
6804     ULONG Hints;
6805     ULONG RunsReturned;
6806     ULONG HintsHonored;
6807     ULONG HintsClusters;
6808     ULONG Cache;
6809     ULONG CacheClusters;
6810     ULONG CacheMiss;
6811     ULONG CacheMissClusters;
6812   } Allocate;
6813 } NTFS_STATISTICS, *PNTFS_STATISTICS;
6814 
6815 #endif /* _FILESYSTEMFSCTL_ */
6816 
6817 #define SYMLINK_FLAG_RELATIVE   1
6818 
6819 typedef struct _REPARSE_DATA_BUFFER {
6820   ULONG ReparseTag;
6821   USHORT ReparseDataLength;
6822   USHORT Reserved;
6823   _ANONYMOUS_UNION union {
6824     struct {
6825       USHORT SubstituteNameOffset;
6826       USHORT SubstituteNameLength;
6827       USHORT PrintNameOffset;
6828       USHORT PrintNameLength;
6829       ULONG Flags;
6830       WCHAR PathBuffer[1];
6831     } SymbolicLinkReparseBuffer;
6832     struct {
6833       USHORT SubstituteNameOffset;
6834       USHORT SubstituteNameLength;
6835       USHORT PrintNameOffset;
6836       USHORT PrintNameLength;
6837       WCHAR PathBuffer[1];
6838     } MountPointReparseBuffer;
6839     struct {
6840       UCHAR DataBuffer[1];
6841     } GenericReparseBuffer;
6842   } DUMMYUNIONNAME;
6843 } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
6844 
6845 #define REPARSE_DATA_BUFFER_HEADER_SIZE   FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
6846 
6847 typedef struct _REPARSE_GUID_DATA_BUFFER {
6848   ULONG ReparseTag;
6849   USHORT ReparseDataLength;
6850   USHORT Reserved;
6851   GUID ReparseGuid;
6852   struct {
6853     UCHAR DataBuffer[1];
6854   } GenericReparseBuffer;
6855 } REPARSE_GUID_DATA_BUFFER, *PREPARSE_GUID_DATA_BUFFER;
6856 
6857 #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE   FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer)
6858 
6859 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE      ( 16 * 1024 )
6860 
6861 /* Reserved reparse tags */
6862 #define IO_REPARSE_TAG_RESERVED_ZERO            (0)
6863 #define IO_REPARSE_TAG_RESERVED_ONE             (1)
6864 #define IO_REPARSE_TAG_RESERVED_RANGE           IO_REPARSE_TAG_RESERVED_ONE
6865 
6866 #define IsReparseTagMicrosoft(_tag)             (((_tag) & 0x80000000))
6867 #define IsReparseTagNameSurrogate(_tag)         (((_tag) & 0x20000000))
6868 
6869 #define IO_REPARSE_TAG_VALID_VALUES             (0xF000FFFF)
6870 
6871 #define IsReparseTagValid(tag) (                               \
6872                   !((tag) & ~IO_REPARSE_TAG_VALID_VALUES) &&   \
6873                   ((tag) > IO_REPARSE_TAG_RESERVED_RANGE)      \
6874                 )
6875 
6876 /* MicroSoft reparse point tags */
6877 #define IO_REPARSE_TAG_MOUNT_POINT              (0xA0000003L)
6878 #define IO_REPARSE_TAG_HSM                      (0xC0000004L)
6879 #define IO_REPARSE_TAG_DRIVE_EXTENDER           (0x80000005L)
6880 #define IO_REPARSE_TAG_HSM2                     (0x80000006L)
6881 #define IO_REPARSE_TAG_SIS                      (0x80000007L)
6882 #define IO_REPARSE_TAG_WIM                      (0x80000008L)
6883 #define IO_REPARSE_TAG_CSV                      (0x80000009L)
6884 #define IO_REPARSE_TAG_DFS                      (0x8000000AL)
6885 #define IO_REPARSE_TAG_FILTER_MANAGER           (0x8000000BL)
6886 #define IO_REPARSE_TAG_SYMLINK                  (0xA000000CL)
6887 #define IO_REPARSE_TAG_IIS_CACHE                (0xA0000010L)
6888 #define IO_REPARSE_TAG_DFSR                     (0x80000012L)
6889 
6890 #pragma pack(4)
6891 typedef struct _REPARSE_INDEX_KEY {
6892   ULONG FileReparseTag;
6893   LARGE_INTEGER FileId;
6894 } REPARSE_INDEX_KEY, *PREPARSE_INDEX_KEY;
6895 #pragma pack()
6896 
6897 #define FSCTL_LMR_GET_LINK_TRACKING_INFORMATION   CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,58,METHOD_BUFFERED,FILE_ANY_ACCESS)
6898 #define FSCTL_LMR_SET_LINK_TRACKING_INFORMATION   CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,59,METHOD_BUFFERED,FILE_ANY_ACCESS)
6899 #define IOCTL_LMR_ARE_FILE_OBJECTS_ON_SAME_SERVER CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,60,METHOD_BUFFERED,FILE_ANY_ACCESS)
6900 
6901 #define FSCTL_PIPE_ASSIGN_EVENT             CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
6902 #define FSCTL_PIPE_DISCONNECT               CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
6903 #define FSCTL_PIPE_LISTEN                   CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
6904 #define FSCTL_PIPE_PEEK                     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
6905 #define FSCTL_PIPE_QUERY_EVENT              CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
6906 #define FSCTL_PIPE_TRANSCEIVE               CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER,  FILE_READ_DATA | FILE_WRITE_DATA)
6907 #define FSCTL_PIPE_WAIT                     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
6908 #define FSCTL_PIPE_IMPERSONATE              CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
6909 #define FSCTL_PIPE_SET_CLIENT_PROCESS       CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
6910 #define FSCTL_PIPE_QUERY_CLIENT_PROCESS     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
6911 #define FSCTL_PIPE_GET_PIPE_ATTRIBUTE       CTL_CODE(FILE_DEVICE_NAMED_PIPE, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
6912 #define FSCTL_PIPE_SET_PIPE_ATTRIBUTE       CTL_CODE(FILE_DEVICE_NAMED_PIPE, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
6913 #define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
6914 #define FSCTL_PIPE_SET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
6915 #define FSCTL_PIPE_GET_HANDLE_ATTRIBUTE     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
6916 #define FSCTL_PIPE_SET_HANDLE_ATTRIBUTE     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
6917 #define FSCTL_PIPE_FLUSH                    CTL_CODE(FILE_DEVICE_NAMED_PIPE, 16, METHOD_BUFFERED, FILE_WRITE_DATA)
6918 
6919 #define FSCTL_PIPE_INTERNAL_READ            CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
6920 #define FSCTL_PIPE_INTERNAL_WRITE           CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
6921 #define FSCTL_PIPE_INTERNAL_TRANSCEIVE      CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
6922 #define FSCTL_PIPE_INTERNAL_READ_OVFLOW     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
6923 
6924 #define FILE_PIPE_READ_DATA                 0x00000000
6925 #define FILE_PIPE_WRITE_SPACE               0x00000001
6926 
6927 typedef struct _FILE_PIPE_ASSIGN_EVENT_BUFFER {
6928   HANDLE EventHandle;
6929   ULONG KeyValue;
6930 } FILE_PIPE_ASSIGN_EVENT_BUFFER, *PFILE_PIPE_ASSIGN_EVENT_BUFFER;
6931 
6932 typedef struct _FILE_PIPE_EVENT_BUFFER {
6933   ULONG NamedPipeState;
6934   ULONG EntryType;
6935   ULONG ByteCount;
6936   ULONG KeyValue;
6937   ULONG NumberRequests;
6938 } FILE_PIPE_EVENT_BUFFER, *PFILE_PIPE_EVENT_BUFFER;
6939 
6940 typedef struct _FILE_PIPE_PEEK_BUFFER {
6941   ULONG NamedPipeState;
6942   ULONG ReadDataAvailable;
6943   ULONG NumberOfMessages;
6944   ULONG MessageLength;
6945   CHAR Data[1];
6946 } FILE_PIPE_PEEK_BUFFER, *PFILE_PIPE_PEEK_BUFFER;
6947 
6948 typedef struct _FILE_PIPE_WAIT_FOR_BUFFER {
6949   LARGE_INTEGER Timeout;
6950   ULONG NameLength;
6951   BOOLEAN TimeoutSpecified;
6952   WCHAR Name[1];
6953 } FILE_PIPE_WAIT_FOR_BUFFER, *PFILE_PIPE_WAIT_FOR_BUFFER;
6954 
6955 typedef struct _FILE_PIPE_CLIENT_PROCESS_BUFFER {
6956 #if !defined(BUILD_WOW6432)
6957   PVOID ClientSession;
6958   PVOID ClientProcess;
6959 #else
6960   ULONGLONG ClientSession;
6961   ULONGLONG ClientProcess;
6962 #endif
6963 } FILE_PIPE_CLIENT_PROCESS_BUFFER, *PFILE_PIPE_CLIENT_PROCESS_BUFFER;
6964 
6965 #define FILE_PIPE_COMPUTER_NAME_LENGTH 15
6966 
6967 typedef struct _FILE_PIPE_CLIENT_PROCESS_BUFFER_EX {
6968 #if !defined(BUILD_WOW6432)
6969   PVOID ClientSession;
6970   PVOID ClientProcess;
6971 #else
6972   ULONGLONG ClientSession;
6973   ULONGLONG ClientProcess;
6974 #endif
6975   USHORT ClientComputerNameLength;
6976   WCHAR ClientComputerBuffer[FILE_PIPE_COMPUTER_NAME_LENGTH+1];
6977 } FILE_PIPE_CLIENT_PROCESS_BUFFER_EX, *PFILE_PIPE_CLIENT_PROCESS_BUFFER_EX;
6978 
6979 #define FSCTL_MAILSLOT_PEEK             CTL_CODE(FILE_DEVICE_MAILSLOT, 0, METHOD_NEITHER, FILE_READ_DATA)
6980 
6981 typedef enum _LINK_TRACKING_INFORMATION_TYPE {
6982   NtfsLinkTrackingInformation,
6983   DfsLinkTrackingInformation
6984 } LINK_TRACKING_INFORMATION_TYPE, *PLINK_TRACKING_INFORMATION_TYPE;
6985 
6986 typedef struct _LINK_TRACKING_INFORMATION {
6987   LINK_TRACKING_INFORMATION_TYPE Type;
6988   UCHAR VolumeId[16];
6989 } LINK_TRACKING_INFORMATION, *PLINK_TRACKING_INFORMATION;
6990 
6991 typedef struct _REMOTE_LINK_TRACKING_INFORMATION {
6992   PVOID TargetFileObject;
6993   ULONG TargetLinkTrackingInformationLength;
6994   UCHAR TargetLinkTrackingInformationBuffer[1];
6995 } REMOTE_LINK_TRACKING_INFORMATION, *PREMOTE_LINK_TRACKING_INFORMATION;
6996 
6997 #define IO_OPEN_PAGING_FILE                 0x0002
6998 #define IO_OPEN_TARGET_DIRECTORY            0x0004
6999 #define IO_STOP_ON_SYMLINK                  0x0008
7000 #define IO_MM_PAGING_FILE                   0x0010
7001 
7002 _Function_class_(DRIVER_FS_NOTIFICATION)
7003 typedef VOID
7004 (NTAPI DRIVER_FS_NOTIFICATION)(
7005   _In_ PDEVICE_OBJECT DeviceObject,
7006   _In_ BOOLEAN FsActive);
7007 typedef DRIVER_FS_NOTIFICATION *PDRIVER_FS_NOTIFICATION;
7008 
7009 typedef enum _FS_FILTER_SECTION_SYNC_TYPE {
7010   SyncTypeOther = 0,
7011   SyncTypeCreateSection
7012 } FS_FILTER_SECTION_SYNC_TYPE, *PFS_FILTER_SECTION_SYNC_TYPE;
7013 
7014 typedef enum _FS_FILTER_STREAM_FO_NOTIFICATION_TYPE {
7015   NotifyTypeCreate = 0,
7016   NotifyTypeRetired
7017 } FS_FILTER_STREAM_FO_NOTIFICATION_TYPE, *PFS_FILTER_STREAM_FO_NOTIFICATION_TYPE;
7018 
7019 typedef union _FS_FILTER_PARAMETERS {
7020   struct {
7021     PLARGE_INTEGER EndingOffset;
7022     PERESOURCE *ResourceToRelease;
7023   } AcquireForModifiedPageWriter;
7024   struct {
7025     PERESOURCE ResourceToRelease;
7026   } ReleaseForModifiedPageWriter;
7027   struct {
7028     FS_FILTER_SECTION_SYNC_TYPE SyncType;
7029     ULONG PageProtection;
7030   } AcquireForSectionSynchronization;
7031   struct {
7032     FS_FILTER_STREAM_FO_NOTIFICATION_TYPE NotificationType;
7033     BOOLEAN POINTER_ALIGNMENT SafeToRecurse;
7034   } NotifyStreamFileObject;
7035   struct {
7036     PVOID Argument1;
7037     PVOID Argument2;
7038     PVOID Argument3;
7039     PVOID Argument4;
7040     PVOID Argument5;
7041   } Others;
7042 } FS_FILTER_PARAMETERS, *PFS_FILTER_PARAMETERS;
7043 
7044 #define FS_FILTER_ACQUIRE_FOR_SECTION_SYNCHRONIZATION      (UCHAR)-1
7045 #define FS_FILTER_RELEASE_FOR_SECTION_SYNCHRONIZATION      (UCHAR)-2
7046 #define FS_FILTER_ACQUIRE_FOR_MOD_WRITE                    (UCHAR)-3
7047 #define FS_FILTER_RELEASE_FOR_MOD_WRITE                    (UCHAR)-4
7048 #define FS_FILTER_ACQUIRE_FOR_CC_FLUSH                     (UCHAR)-5
7049 #define FS_FILTER_RELEASE_FOR_CC_FLUSH                     (UCHAR)-6
7050 
7051 typedef struct _FS_FILTER_CALLBACK_DATA {
7052   ULONG SizeOfFsFilterCallbackData;
7053   UCHAR Operation;
7054   UCHAR Reserved;
7055   struct _DEVICE_OBJECT *DeviceObject;
7056   struct _FILE_OBJECT *FileObject;
7057   FS_FILTER_PARAMETERS Parameters;
7058 } FS_FILTER_CALLBACK_DATA, *PFS_FILTER_CALLBACK_DATA;
7059 
7060 typedef NTSTATUS
7061 (NTAPI *PFS_FILTER_CALLBACK) (
7062   _In_ PFS_FILTER_CALLBACK_DATA Data,
7063   _Out_ PVOID *CompletionContext);
7064 
7065 typedef VOID
7066 (NTAPI *PFS_FILTER_COMPLETION_CALLBACK) (
7067   _In_ PFS_FILTER_CALLBACK_DATA Data,
7068   _In_ NTSTATUS OperationStatus,
7069   _In_ PVOID CompletionContext);
7070 
7071 typedef struct _FS_FILTER_CALLBACKS {
7072   ULONG SizeOfFsFilterCallbacks;
7073   ULONG Reserved;
7074   PFS_FILTER_CALLBACK PreAcquireForSectionSynchronization;
7075   PFS_FILTER_COMPLETION_CALLBACK PostAcquireForSectionSynchronization;
7076   PFS_FILTER_CALLBACK PreReleaseForSectionSynchronization;
7077   PFS_FILTER_COMPLETION_CALLBACK PostReleaseForSectionSynchronization;
7078   PFS_FILTER_CALLBACK PreAcquireForCcFlush;
7079   PFS_FILTER_COMPLETION_CALLBACK PostAcquireForCcFlush;
7080   PFS_FILTER_CALLBACK PreReleaseForCcFlush;
7081   PFS_FILTER_COMPLETION_CALLBACK PostReleaseForCcFlush;
7082   PFS_FILTER_CALLBACK PreAcquireForModifiedPageWriter;
7083   PFS_FILTER_COMPLETION_CALLBACK PostAcquireForModifiedPageWriter;
7084   PFS_FILTER_CALLBACK PreReleaseForModifiedPageWriter;
7085   PFS_FILTER_COMPLETION_CALLBACK PostReleaseForModifiedPageWriter;
7086 } FS_FILTER_CALLBACKS, *PFS_FILTER_CALLBACKS;
7087 
7088 extern NTKERNELAPI KSPIN_LOCK    IoStatisticsLock;
7089 extern NTKERNELAPI ULONG         IoReadOperationCount;
7090 extern NTKERNELAPI ULONG         IoWriteOperationCount;
7091 extern NTKERNELAPI ULONG         IoOtherOperationCount;
7092 extern NTKERNELAPI LARGE_INTEGER IoReadTransferCount;
7093 extern NTKERNELAPI LARGE_INTEGER IoWriteTransferCount;
7094 extern NTKERNELAPI LARGE_INTEGER IoOtherTransferCount;
7095 
7096 #define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE    64
7097 #define IO_FILE_OBJECT_PAGED_POOL_CHARGE        1024
7098 
7099 #if (NTDDI_VERSION >= NTDDI_VISTA)
7100 typedef struct _IO_PRIORITY_INFO {
7101   ULONG Size;
7102   ULONG ThreadPriority;
7103   ULONG PagePriority;
7104   IO_PRIORITY_HINT IoPriority;
7105 } IO_PRIORITY_INFO, *PIO_PRIORITY_INFO;
7106 #endif
7107 $endif (_NTIFS_)
7108