xref: /reactos/sdk/include/ndk/iotypes.h (revision 682f85ad)
1 /*++ NDK Version: 0098
2 
3 Copyright (c) Alex Ionescu.  All rights reserved.
4 
5 Header Name:
6 
7     iotypes.h
8 
9 Abstract:
10 
11     Type definitions for the I/O Manager.
12 
13 Author:
14 
15     Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16 
17 --*/
18 #ifndef _IOTYPES_H
19 #define _IOTYPES_H
20 
21 //
22 // Dependencies
23 //
24 #include <umtypes.h>
25 #include <ifssupp.h>
26 #include <potypes.h>
27 
28 //
29 // I/O Completion Access Rights
30 //
31 #define IO_COMPLETION_QUERY_STATE               0x0001
32 #ifndef NTOS_MODE_USER
33 #define IO_COMPLETION_MODIFY_STATE              0x0002
34 #define IO_COMPLETION_ALL_ACCESS                (STANDARD_RIGHTS_REQUIRED | \
35                                                  SYNCHRONIZE | \
36                                                  0x3)
37 
38 //
39 // Kernel Exported Object Types
40 //
41 extern POBJECT_TYPE NTSYSAPI IoAdapterObjectType;
42 extern POBJECT_TYPE NTSYSAPI IoDeviceHandlerObjectType;
43 extern POBJECT_TYPE NTSYSAPI IoDeviceObjectType;
44 extern POBJECT_TYPE NTSYSAPI IoDriverObjectType;
45 
46 #else
47 
48 //
49 // Symbolic Link Access Rights
50 //
51 #define SYMBOLIC_LINK_QUERY                     0x0001
52 #define SYMBOLIC_LINK_ALL_ACCESS                STANDARD_RIGHTS_REQUIRED | 0x0001
53 #endif
54 
55 #ifdef NTOS_MODE_USER
56 
57 /* File System Attributes Flags */
58 #define FILE_READ_ONLY_VOLUME 0x00080000
59 
60 #endif
61 
62 //
63 // NtCreateFile Result Flags
64 //
65 #define FILE_SUPERSEDED                         0x00000000
66 #define FILE_OPENED                             0x00000001
67 #define FILE_CREATED                            0x00000002
68 #define FILE_OVERWRITTEN                        0x00000003
69 #define FILE_EXISTS                             0x00000004
70 #define FILE_DOES_NOT_EXIST                     0x00000005
71 
72 //
73 // Pipe Flags
74 //
75 #define FILE_PIPE_BYTE_STREAM_TYPE              0x00000000
76 #define FILE_PIPE_MESSAGE_TYPE                  0x00000001
77 #define FILE_PIPE_BYTE_STREAM_MODE              0x00000000
78 #define FILE_PIPE_MESSAGE_MODE                  0x00000001
79 #define FILE_PIPE_QUEUE_OPERATION               0x00000000
80 #define FILE_PIPE_COMPLETE_OPERATION            0x00000001
81 #define FILE_PIPE_INBOUND                       0x00000000
82 #define FILE_PIPE_OUTBOUND                      0x00000001
83 #define FILE_PIPE_FULL_DUPLEX                   0x00000002
84 #define FILE_PIPE_CLIENT_END                    0x00000000
85 #define FILE_PIPE_SERVER_END                    0x00000001
86 
87 //
88 // NtCreateFile Attributes
89 //
90 #define FILE_ATTRIBUTE_VALID_FLAGS              0x00007fb7
91 #define FILE_ATTRIBUTE_VALID_SET_FLAGS          0x000031a7
92 
93 //
94 // NtCreateFile OpenType Flags
95 //
96 #define FILE_SUPERSEDE                          0x00000000
97 #define FILE_OPEN                               0x00000001
98 #define FILE_CREATE                             0x00000002
99 #define FILE_OPEN_IF                            0x00000003
100 #define FILE_OVERWRITE                          0x00000004
101 #define FILE_OVERWRITE_IF                       0x00000005
102 #define FILE_MAXIMUM_DISPOSITION                0x00000005
103 
104 //
105 // NtCreateFile Flags
106 //
107 #define FILE_DIRECTORY_FILE                     0x00000001
108 #define FILE_WRITE_THROUGH                      0x00000002
109 #define FILE_SEQUENTIAL_ONLY                    0x00000004
110 #define FILE_NO_INTERMEDIATE_BUFFERING          0x00000008
111 #define FILE_SYNCHRONOUS_IO_ALERT               0x00000010
112 #define FILE_SYNCHRONOUS_IO_NONALERT            0x00000020
113 #define FILE_NON_DIRECTORY_FILE                 0x00000040
114 #define FILE_CREATE_TREE_CONNECTION             0x00000080
115 #define FILE_COMPLETE_IF_OPLOCKED               0x00000100
116 #define FILE_NO_EA_KNOWLEDGE                    0x00000200
117 #define FILE_OPEN_REMOTE_INSTANCE               0x00000400
118 #define FILE_RANDOM_ACCESS                      0x00000800
119 #define FILE_DELETE_ON_CLOSE                    0x00001000
120 #define FILE_OPEN_BY_FILE_ID                    0x00002000
121 #define FILE_OPEN_FOR_BACKUP_INTENT             0x00004000
122 #define FILE_NO_COMPRESSION                     0x00008000
123 #define FILE_RESERVE_OPFILTER                   0x00100000
124 #define FILE_OPEN_REPARSE_POINT                 0x00200000
125 #define FILE_OPEN_NO_RECALL                     0x00400000
126 #define FILE_OPEN_FOR_FREE_SPACE_QUERY          0x00800000
127 
128 //
129 // Device Charactertics
130 //
131 #define FILE_REMOVABLE_MEDIA                    0x00000001
132 #define FILE_READ_ONLY_DEVICE                   0x00000002
133 #define FILE_FLOPPY_DISKETTE                    0x00000004
134 #define FILE_WRITE_ONCE_MEDIA                   0x00000008
135 #define FILE_REMOTE_DEVICE                      0x00000010
136 #define FILE_DEVICE_IS_MOUNTED                  0x00000020
137 #define FILE_VIRTUAL_VOLUME                     0x00000040
138 #define FILE_AUTOGENERATED_DEVICE_NAME          0x00000080
139 #define FILE_DEVICE_SECURE_OPEN                 0x00000100
140 
141 //
142 // File Object Flags
143 //
144 #define FO_FILE_OBJECT_HAS_EXTENSION            0x00800000
145 
146 //
147 // Device Object Extension Flags
148 //
149 #define DOE_UNLOAD_PENDING                      0x1
150 #define DOE_DELETE_PENDING                      0x2
151 #define DOE_REMOVE_PENDING                      0x4
152 #define DOE_REMOVE_PROCESSED                    0x8
153 #define DOE_START_PENDING                       0x10
154 
155 //
156 // Device Object StartIo Flags
157 //
158 #define DOE_SIO_NO_KEY                          0x20
159 #define DOE_SIO_WITH_KEY                        0x40
160 #define DOE_SIO_CANCELABLE                      0x80
161 #define DOE_SIO_DEFERRED                        0x100
162 #define DOE_SIO_NO_CANCEL                       0x200
163 
164 //
165 // Device Node Flags
166 //
167 
168 // this set of flags is relevant for w2k3 and newer
169 // w2k has a completely different set of flags
170 #define DNF_MADEUP                              0x00000001
171 #define DNF_DUPLICATE                           0x00000002
172 #define DNF_HAL_NODE                            0x00000004
173 #define DNF_REENUMERATE                         0x00000008
174 #define DNF_ENUMERATED                          0x00000010
175 #define DNF_IDS_QUERIED                         0x00000020
176 #define DNF_HAS_BOOT_CONFIG                     0x00000040
177 #define DNF_BOOT_CONFIG_RESERVED                0x00000080
178 #define DNF_NO_RESOURCE_REQUIRED                0x00000100
179 #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00000200
180 #define DNF_RESOURCE_REQUIREMENTS_CHANGED       0x00000400
181 #define DNF_NON_STOPPED_REBALANCE               0x00000800
182 #define DNF_LEGACY_DRIVER                       0x00001000
183 #define DNF_HAS_PROBLEM                         0x00002000
184 #define DNF_HAS_PRIVATE_PROBLEM                 0x00004000
185 #define DNF_HARDWARE_VERIFICATION               0x00008000
186 #define DNF_DEVICE_GONE                         0x00010000
187 #define DNF_LEGACY_RESOURCE_DEVICENODE          0x00020000
188 #define DNF_NEEDS_REBALANCE                     0x00040000
189 #define DNF_LOCKED_FOR_EJECT                    0x00080000
190 #define DNF_DRIVER_BLOCKED                      0x00100000
191 #define DNF_CHILD_WITH_INVALID_ID               0x00200000
192 
193 // these flags were added in Vista or later
194 #define DNF_ASYNC_START_NOT_SUPPORTED           0x00400000
195 #define DNF_ASYNC_ENUMERATION_NOT_SUPPORTED     0x00800000
196 #define DNF_LOCKED_FOR_REBALANCE                0x01000000
197 #define DNF_UNINSTALLED                         0x02000000
198 #define DNF_NO_LOWER_DEVICE_FILTERS             0x04000000
199 #define DNF_NO_LOWER_CLASS_FILTERS              0x08000000
200 #define DNF_NO_SERVICE                          0x10000000
201 #define DNF_NO_UPPER_DEVICE_FILTERS             0x20000000
202 #define DNF_NO_UPPER_CLASS_FILTERS              0x40000000
203 #define DNF_WAITING_FOR_FDO                     0x80000000
204 
205 //
206 // Device Node User Flags
207 //
208 #define DNUF_WILL_BE_REMOVED                    0x0001
209 #define DNUF_DONT_SHOW_IN_UI                    0x0002
210 #define DNUF_NEED_RESTART                       0x0004
211 #define DNUF_NOT_DISABLEABLE                    0x0008
212 #define DNUF_SHUTDOWN_QUERIED                   0x0010
213 #define DNUF_SHUTDOWN_SUBTREE_DONE              0x0020
214 
215 //
216 // Internal Option Flags
217 //
218 #define IO_ATTACH_DEVICE_API                    0x80000000
219 
220 //
221 // Undocumented WMI Registration Flags
222 //
223 #define WMIREG_FLAG_TRACE_PROVIDER              0x00010000
224 #define WMIREG_FLAG_TRACE_NOTIFY_MASK           0x00F00000
225 #define WMIREG_NOTIFY_DISK_IO                   0x00100000
226 #define WMIREG_NOTIFY_TDI_IO                    0x00200000
227 
228 //
229 // I/O Completion Information Class for NtQueryIoCompletionInformation
230 //
231 typedef enum _IO_COMPLETION_INFORMATION_CLASS
232 {
233     IoCompletionBasicInformation
234 } IO_COMPLETION_INFORMATION_CLASS;
235 
236 #ifdef NTOS_MODE_USER
237 
238 //
239 // Hardware Interface Type
240 //
241 typedef enum _INTERFACE_TYPE
242 {
243     InterfaceTypeUndefined = -1,
244     Internal,
245     Isa,
246     Eisa,
247     MicroChannel,
248     TurboChannel,
249     PCIBus,
250     VMEBus,
251     NuBus,
252     PCMCIABus,
253     CBus,
254     MPIBus,
255     MPSABus,
256     ProcessorInternal,
257     InternalPowerBus,
258     PNPISABus,
259     PNPBus,
260     MaximumInterfaceType
261 }INTERFACE_TYPE, *PINTERFACE_TYPE;
262 
263 typedef enum _BUS_DATA_TYPE
264 {
265     ConfigurationSpaceUndefined = -1,
266     Cmos,
267     EisaConfiguration,
268     Pos,
269     CbusConfiguration,
270     PCIConfiguration,
271     VMEConfiguration,
272     NuBusConfiguration,
273     PCMCIAConfiguration,
274     MPIConfiguration,
275     MPSAConfiguration,
276     PNPISAConfiguration,
277     SgiInternalConfiguration,
278     MaximumBusDataType
279 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
280 
281 //
282 // File Information Classes for NtQueryInformationFile
283 //
284 typedef enum _FILE_INFORMATION_CLASS
285 {
286     FileDirectoryInformation = 1,
287     FileFullDirectoryInformation,
288     FileBothDirectoryInformation,
289     FileBasicInformation,
290     FileStandardInformation,
291     FileInternalInformation,
292     FileEaInformation,
293     FileAccessInformation,
294     FileNameInformation,
295     FileRenameInformation,
296     FileLinkInformation,
297     FileNamesInformation,
298     FileDispositionInformation,
299     FilePositionInformation,
300     FileFullEaInformation,
301     FileModeInformation,
302     FileAlignmentInformation,
303     FileAllInformation,
304     FileAllocationInformation,
305     FileEndOfFileInformation,
306     FileAlternateNameInformation,
307     FileStreamInformation,
308     FilePipeInformation,
309     FilePipeLocalInformation,
310     FilePipeRemoteInformation,
311     FileMailslotQueryInformation,
312     FileMailslotSetInformation,
313     FileCompressionInformation,
314     FileObjectIdInformation,
315     FileCompletionInformation,
316     FileMoveClusterInformation,
317     FileQuotaInformation,
318     FileReparsePointInformation,
319     FileNetworkOpenInformation,
320     FileAttributeTagInformation,
321     FileTrackingInformation,
322     FileIdBothDirectoryInformation,
323     FileIdFullDirectoryInformation,
324     FileValidDataLengthInformation,
325     FileShortNameInformation,
326 #if (NTDDI_VERSION >= NTDDI_VISTA)
327     FileIoCompletionNotificationInformation,
328     FileIoStatusBlockRangeInformation,
329     FileIoPriorityHintInformation,
330     FileSfioReserveInformation,
331     FileSfioVolumeInformation,
332     FileHardLinkInformation,
333     FileProcessIdsUsingFileInformation,
334     FileNormalizedNameInformation,
335     FileNetworkPhysicalNameInformation,
336 #endif
337 #if (NTDDI_VERSION >= NTDDI_WIN7)
338     FileIdGlobalTxDirectoryInformation,
339     FileIsRemoteDeviceInformation,
340     FileUnusedInformation,
341     FileNumaNodeInformation,
342     FileStandardLinkInformation,
343     FileRemoteProtocolInformation,
344 #endif
345     FileMaximumInformation
346 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
347 
348 //
349 // File Information Classes for NtQueryInformationFileSystem
350 //
351 typedef enum _FSINFOCLASS
352 {
353     FileFsVolumeInformation = 1,
354     FileFsLabelInformation,
355     FileFsSizeInformation,
356     FileFsDeviceInformation,
357     FileFsAttributeInformation,
358     FileFsControlInformation,
359     FileFsFullSizeInformation,
360     FileFsObjectIdInformation,
361     FileFsDriverPathInformation,
362     FileFsMaximumInformation
363 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
364 
365 #endif
366 
367 //
368 // Dock Profile Status
369 //
370 typedef enum _PROFILE_STATUS
371 {
372     DOCK_NOTDOCKDEVICE,
373     DOCK_QUIESCENT,
374     DOCK_ARRIVING,
375     DOCK_DEPARTING,
376     DOCK_EJECTIRP_COMPLETED
377 } PROFILE_STATUS, *PPROFILE_STATUS;
378 
379 //
380 // Device Node States
381 //
382 typedef enum _PNP_DEVNODE_STATE
383 {
384     DeviceNodeUnspecified = 0x300,
385     DeviceNodeUninitialized = 0x301,
386     DeviceNodeInitialized = 0x302,
387     DeviceNodeDriversAdded = 0x303,
388     DeviceNodeResourcesAssigned = 0x304,
389     DeviceNodeStartPending = 0x305,
390     DeviceNodeStartCompletion = 0x306,
391     DeviceNodeStartPostWork = 0x307,
392     DeviceNodeStarted = 0x308,
393     DeviceNodeQueryStopped = 0x309,
394     DeviceNodeStopped = 0x30a,
395     DeviceNodeRestartCompletion = 0x30b,
396     DeviceNodeEnumeratePending = 0x30c,
397     DeviceNodeEnumerateCompletion = 0x30d,
398     DeviceNodeAwaitingQueuedDeletion = 0x30e,
399     DeviceNodeAwaitingQueuedRemoval = 0x30f,
400     DeviceNodeQueryRemoved = 0x310,
401     DeviceNodeRemovePendingCloses = 0x311,
402     DeviceNodeRemoved = 0x312,
403     DeviceNodeDeletePendingCloses = 0x313,
404     DeviceNodeDeleted = 0x314,
405     MaxDeviceNodeState = 0x315,
406 } PNP_DEVNODE_STATE;
407 
408 #ifdef NTOS_MODE_USER
409 
410 //
411 // I/O Status Block
412 //
413 typedef struct _IO_STATUS_BLOCK
414 {
415     union
416     {
417         NTSTATUS Status;
418         PVOID Pointer;
419     };
420     ULONG_PTR Information;
421 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
422 
423 //
424 // File Information structures for NtQueryInformationFile
425 //
426 typedef struct _FILE_BASIC_INFORMATION
427 {
428     LARGE_INTEGER CreationTime;
429     LARGE_INTEGER LastAccessTime;
430     LARGE_INTEGER LastWriteTime;
431     LARGE_INTEGER ChangeTime;
432     ULONG FileAttributes;
433 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
434 
435 typedef struct _FILE_STANDARD_INFORMATION
436 {
437     LARGE_INTEGER AllocationSize;
438     LARGE_INTEGER EndOfFile;
439     ULONG NumberOfLinks;
440     BOOLEAN DeletePending;
441     BOOLEAN Directory;
442 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
443 
444 typedef struct _FILE_STREAM_INFORMATION
445 {
446     ULONG NextEntryOffset;
447     ULONG StreamNameLength;
448     LARGE_INTEGER StreamSize;
449     LARGE_INTEGER StreamAllocationSize;
450     WCHAR StreamName[1];
451 } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
452 
453 typedef struct _FILE_NETWORK_OPEN_INFORMATION
454 {
455     LARGE_INTEGER CreationTime;
456     LARGE_INTEGER LastAccessTime;
457     LARGE_INTEGER LastWriteTime;
458     LARGE_INTEGER ChangeTime;
459     LARGE_INTEGER AllocationSize;
460     LARGE_INTEGER EndOfFile;
461     ULONG FileAttributes;
462 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
463 
464 typedef struct _FILE_EA_INFORMATION
465 {
466     ULONG EaSize;
467 } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
468 
469 typedef struct _FILE_ACCESS_INFORMATION
470 {
471     ACCESS_MASK AccessFlags;
472 } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
473 
474 typedef struct _FILE_COMPRESSION_INFORMATION
475 {
476     LARGE_INTEGER CompressedFileSize;
477     USHORT CompressionFormat;
478     UCHAR CompressionUnitShift;
479     UCHAR ChunkShift;
480     UCHAR ClusterShift;
481     UCHAR Reserved[3];
482 } FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
483 
484 typedef struct _FILE_POSITION_INFORMATION
485 {
486   LARGE_INTEGER CurrentByteOffset;
487 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
488 
489 typedef struct _FILE_DISPOSITION_INFORMATION
490 {
491     BOOLEAN DeleteFile;
492 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
493 
494 typedef struct _FILE_FULL_EA_INFORMATION
495 {
496     ULONG NextEntryOffset;
497     UCHAR Flags;
498     UCHAR EaNameLength;
499     USHORT EaValueLength;
500     CHAR EaName[1];
501 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
502 
503 typedef struct _FILE_QUOTA_INFORMATION
504 {
505     ULONG NextEntryOffset;
506     ULONG SidLength;
507     LARGE_INTEGER ChangeTime;
508     LARGE_INTEGER QuotaUsed;
509     LARGE_INTEGER QuotaThreshold;
510     LARGE_INTEGER QuotaLimit;
511     SID Sid;
512 } FILE_QUOTA_INFORMATION, *PFILE_QUOTA_INFORMATION;
513 
514 typedef struct _FILE_INTERNAL_INFORMATION
515 {
516     LARGE_INTEGER IndexNumber;
517 } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
518 
519 typedef struct _FILE_RENAME_INFORMATION
520 {
521     BOOLEAN ReplaceIfExists;
522     HANDLE  RootDirectory;
523     ULONG FileNameLength;
524     WCHAR FileName[1];
525 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
526 
527 typedef struct _FILE_PIPE_INFORMATION
528 {
529     ULONG ReadMode;
530     ULONG CompletionMode;
531 } FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
532 
533 typedef struct _FILE_PIPE_LOCAL_INFORMATION
534 {
535     ULONG NamedPipeType;
536     ULONG NamedPipeConfiguration;
537     ULONG MaximumInstances;
538     ULONG CurrentInstances;
539     ULONG InboundQuota;
540     ULONG ReadDataAvailable;
541     ULONG OutboundQuota;
542     ULONG WriteQuotaAvailable;
543     ULONG NamedPipeState;
544     ULONG NamedPipeEnd;
545 } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
546 
547 typedef struct _FILE_PIPE_REMOTE_INFORMATION
548 {
549     LARGE_INTEGER CollectDataTime;
550     ULONG MaximumCollectionCount;
551 } FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
552 
553 typedef struct _FILE_MAILSLOT_QUERY_INFORMATION
554 {
555     ULONG MaximumMessageSize;
556     ULONG MailslotQuota;
557     ULONG NextMessageSize;
558     ULONG MessagesAvailable;
559     LARGE_INTEGER ReadTimeout;
560 } FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION;
561 
562 typedef struct _FILE_MAILSLOT_SET_INFORMATION
563 {
564     PLARGE_INTEGER ReadTimeout;
565 } FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
566 
567 typedef struct _FILE_FULL_DIR_INFORMATION
568 {
569     ULONG NextEntryOffset;
570     ULONG FileIndex;
571     LARGE_INTEGER CreationTime;
572     LARGE_INTEGER LastAccessTime;
573     LARGE_INTEGER LastWriteTime;
574     LARGE_INTEGER ChangeTime;
575     LARGE_INTEGER EndOfFile;
576     LARGE_INTEGER AllocationSize;
577     ULONG FileAttributes;
578     ULONG FileNameLength;
579     ULONG EaSize;
580     WCHAR FileName[1];
581 } FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
582 
583 typedef struct _FILE_BOTH_DIR_INFORMATION
584 {
585     ULONG NextEntryOffset;
586     ULONG FileIndex;
587     LARGE_INTEGER CreationTime;
588     LARGE_INTEGER LastAccessTime;
589     LARGE_INTEGER LastWriteTime;
590     LARGE_INTEGER ChangeTime;
591     LARGE_INTEGER EndOfFile;
592     LARGE_INTEGER AllocationSize;
593     ULONG FileAttributes;
594     ULONG FileNameLength;
595     ULONG EaSize;
596     CCHAR ShortNameLength;
597     WCHAR ShortName[12];
598     WCHAR FileName[1];
599 } FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
600 
601 typedef struct _FILE_COMPLETION_INFORMATION
602 {
603     HANDLE Port;
604     PVOID Key;
605 } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
606 
607 typedef struct _FILE_LINK_INFORMATION
608 {
609     BOOLEAN ReplaceIfExists;
610     HANDLE RootDirectory;
611     ULONG FileNameLength;
612     WCHAR FileName[1];
613 } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
614 
615 typedef struct _FILE_NAME_INFORMATION
616 {
617     ULONG FileNameLength;
618     WCHAR FileName[1];
619 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
620 
621 typedef struct _FILE_ALLOCATION_INFORMATION
622 {
623     LARGE_INTEGER AllocationSize;
624 } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
625 
626 typedef struct _FILE_END_OF_FILE_INFORMATION
627 {
628     LARGE_INTEGER EndOfFile;
629 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
630 
631 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION
632 {
633     LARGE_INTEGER ValidDataLength;
634 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
635 
636 typedef struct _FILE_DIRECTORY_INFORMATION
637 {
638     ULONG NextEntryOffset;
639     ULONG FileIndex;
640     LARGE_INTEGER CreationTime;
641     LARGE_INTEGER LastAccessTime;
642     LARGE_INTEGER LastWriteTime;
643     LARGE_INTEGER ChangeTime;
644     LARGE_INTEGER EndOfFile;
645     LARGE_INTEGER AllocationSize;
646     ULONG FileAttributes;
647     ULONG FileNameLength;
648     WCHAR FileName[1];
649 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
650 
651 typedef struct _FILE_IO_COMPLETION_INFORMATION
652 {
653     PVOID KeyContext;
654     PVOID ApcContext;
655     IO_STATUS_BLOCK IoStatusBlock;
656 } FILE_IO_COMPLETION_INFORMATION, *PFILE_IO_COMPLETION_INFORMATION;
657 
658 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION
659 {
660     ULONG FileAttributes;
661     ULONG ReparseTag;
662 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
663 
664 typedef struct _FILE_TRACKING_INFORMATION
665 {
666     HANDLE DestinationFile;
667     ULONG ObjectInformationLength;
668     CHAR ObjectInformation[1];
669 } FILE_TRACKING_INFORMATION, *PFILE_TRACKING_INFORMATION;
670 
671 //
672 // File System Information structures for NtQueryInformationFile
673 //
674 typedef struct _FILE_FS_DEVICE_INFORMATION
675 {
676     DEVICE_TYPE DeviceType;
677     ULONG Characteristics;
678 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
679 
680 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
681 {
682     ULONG FileSystemAttributes;
683     ULONG MaximumComponentNameLength;
684     ULONG FileSystemNameLength;
685     WCHAR FileSystemName[1];
686 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
687 
688 typedef struct _FILE_FS_SIZE_INFORMATION
689 {
690     LARGE_INTEGER TotalAllocationUnits;
691     LARGE_INTEGER AvailableAllocationUnits;
692     ULONG SectorsPerAllocationUnit;
693     ULONG BytesPerSector;
694 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
695 
696 typedef struct _FILE_FS_FULL_SIZE_INFORMATION
697 {
698     LARGE_INTEGER   TotalAllocationUnits;
699     LARGE_INTEGER   CallerAvailableAllocationUnits;
700     LARGE_INTEGER   ActualAvailableAllocationUnits;
701     ULONG           SectorsPerAllocationUnit;
702     ULONG           BytesPerSector;
703 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
704 
705 typedef struct _FILE_FS_LABEL_INFORMATION
706 {
707     ULONG VolumeLabelLength;
708     WCHAR VolumeLabel[1];
709 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
710 
711 typedef struct _FILE_FS_VOLUME_INFORMATION
712 {
713     LARGE_INTEGER VolumeCreationTime;
714     ULONG VolumeSerialNumber;
715     ULONG VolumeLabelLength;
716     BOOLEAN SupportsObjects;
717     WCHAR VolumeLabel[1];
718 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
719 
720 //
721 // Pipe Structures for IOCTL_PIPE_XXX
722 //
723 typedef struct _FILE_PIPE_WAIT_FOR_BUFFER
724 {
725     LARGE_INTEGER Timeout;
726     ULONG NameLength;
727     BOOLEAN TimeoutSpecified;
728     WCHAR Name[1];
729 } FILE_PIPE_WAIT_FOR_BUFFER, *PFILE_PIPE_WAIT_FOR_BUFFER;
730 
731 typedef struct _FILE_PIPE_PEEK_BUFFER
732 {
733     ULONG NamedPipeState;
734     ULONG ReadDataAvailable;
735     ULONG NumberOfMessages;
736     ULONG MessageLength;
737     CHAR Data[1];
738 } FILE_PIPE_PEEK_BUFFER, *PFILE_PIPE_PEEK_BUFFER;
739 
740 //
741 // I/O Error Log Structures
742 //
743 typedef struct _IO_ERROR_LOG_PACKET
744 {
745     UCHAR MajorFunctionCode;
746     UCHAR RetryCount;
747     USHORT DumpDataSize;
748     USHORT NumberOfStrings;
749     USHORT StringOffset;
750     USHORT EventCategory;
751     NTSTATUS ErrorCode;
752     ULONG UniqueErrorValue;
753     NTSTATUS FinalStatus;
754     ULONG SequenceNumber;
755     ULONG IoControlCode;
756     LARGE_INTEGER DeviceOffset;
757     ULONG DumpData[1];
758 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
759 
760 typedef struct _IO_ERROR_LOG_MESSAGE
761 {
762     USHORT Type;
763     USHORT Size;
764     USHORT DriverNameLength;
765     LARGE_INTEGER TimeStamp;
766     ULONG DriverNameOffset;
767     IO_ERROR_LOG_PACKET EntryData;
768 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
769 
770 #endif
771 
772 //
773 // I/O Completion Information structures
774 //
775 typedef struct _IO_COMPLETION_BASIC_INFORMATION
776 {
777     LONG Depth;
778 } IO_COMPLETION_BASIC_INFORMATION, *PIO_COMPLETION_BASIC_INFORMATION;
779 
780 //
781 // Parameters for NtCreateMailslotFile/NtCreateNamedPipeFile
782 //
783 typedef struct _MAILSLOT_CREATE_PARAMETERS
784 {
785     ULONG MailslotQuota;
786     ULONG MaximumMessageSize;
787     LARGE_INTEGER ReadTimeout;
788     BOOLEAN TimeoutSpecified;
789 } MAILSLOT_CREATE_PARAMETERS, *PMAILSLOT_CREATE_PARAMETERS;
790 
791 typedef struct _NAMED_PIPE_CREATE_PARAMETERS
792 {
793     ULONG NamedPipeType;
794     ULONG ReadMode;
795     ULONG CompletionMode;
796     ULONG MaximumInstances;
797     ULONG InboundQuota;
798     ULONG OutboundQuota;
799     LARGE_INTEGER DefaultTimeout;
800     BOOLEAN TimeoutSpecified;
801 } NAMED_PIPE_CREATE_PARAMETERS, *PNAMED_PIPE_CREATE_PARAMETERS;
802 
803 #ifndef NTOS_MODE_USER
804 
805 //
806 // I/O Timer Object
807 //
808 typedef struct _IO_TIMER
809 {
810     USHORT Type;
811     USHORT TimerEnabled;
812     LIST_ENTRY IoTimerList;
813     PIO_TIMER_ROUTINE TimerRoutine;
814     PVOID Context;
815     PDEVICE_OBJECT DeviceObject;
816 } IO_TIMER;
817 
818 //
819 // Driver Extension
820 //
821 typedef struct _IO_CLIENT_EXTENSION
822 {
823     struct _IO_CLIENT_EXTENSION *NextExtension;
824     PVOID ClientIdentificationAddress;
825 } IO_CLIENT_EXTENSION, *PIO_CLIENT_EXTENSION;
826 
827 #define DEVNODE_HISTORY_SIZE 20
828 
829 //
830 // Device Node
831 //
832 typedef struct _DEVICE_NODE
833 {
834     struct _DEVICE_NODE *Sibling;
835     struct _DEVICE_NODE *Child;
836     struct _DEVICE_NODE *Parent;
837     struct _DEVICE_NODE *LastChild;
838     ULONG Level;
839     struct _PO_DEVICE_NOTIFY *Notify;
840     PO_IRP_MANAGER PoIrpManager;
841     PNP_DEVNODE_STATE State;
842     PNP_DEVNODE_STATE PreviousState;
843     PNP_DEVNODE_STATE StateHistory[DEVNODE_HISTORY_SIZE];
844     ULONG StateHistoryEntry;
845     NTSTATUS CompletionStatus;
846     PIRP PendingIrp;
847     ULONG Flags;
848     ULONG UserFlags;
849     ULONG Problem;
850     PDEVICE_OBJECT PhysicalDeviceObject;
851     PCM_RESOURCE_LIST ResourceList;
852     PCM_RESOURCE_LIST ResourceListTranslated;
853     UNICODE_STRING InstancePath;
854     UNICODE_STRING ServiceName;
855     PDEVICE_OBJECT DuplicatePDO;
856     PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements;
857     INTERFACE_TYPE InterfaceType;
858     ULONG BusNumber;
859     INTERFACE_TYPE ChildInterfaceType;
860     ULONG ChildBusNumber;
861     USHORT ChildBusTypeIndex;
862     UCHAR RemovalPolicy;
863     UCHAR HardwareRemovalPolicy;
864     LIST_ENTRY TargetDeviceNotify;
865     LIST_ENTRY DeviceArbiterList;
866     LIST_ENTRY DeviceTranslatorList;
867     USHORT NoTranslatorMask;
868     USHORT QueryTranslatorMask;
869     USHORT NoArbiterMask;
870     USHORT QueryArbiterMask;
871     union
872     {
873         struct _DEVICE_NODE *LegacyDeviceNode;
874         PDEVICE_RELATIONS PendingDeviceRelations;
875     } OverUsed1;
876     union
877     {
878         struct _DEVICE_NODE *NextResourceDeviceNode;
879     } OverUsed2;
880     PCM_RESOURCE_LIST BootResources;
881 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
882     PCM_RESOURCE_LIST BootResourcesTranslated;
883 #endif
884     ULONG CapabilityFlags;
885     struct
886     {
887         PROFILE_STATUS DockStatus;
888         LIST_ENTRY ListEntry;
889         WCHAR *SerialNumber;
890     } DockInfo;
891     ULONG DisableableDepends;
892     LIST_ENTRY PendedSetInterfaceState;
893     LIST_ENTRY LegacyBusListEntry;
894     ULONG DriverUnloadRetryCount;
895     struct _DEVICE_NODE *PreviousParent;
896     ULONG DeletedChildren;
897 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
898     ULONG NumaNodeIndex;
899 #endif
900 } DEVICE_NODE, *PDEVICE_NODE;
901 
902 //
903 // Resource Aribtrer Entry
904 //
905 typedef struct _PI_RESOURCE_ARBITER_ENTRY
906 {
907     LIST_ENTRY DeviceArbiterList;
908     UCHAR ResourceType;
909     PARBITER_INTERFACE ArbiterInterface;
910     ULONG Level;
911     LIST_ENTRY ResourceList;
912     LIST_ENTRY BestResourceList;
913     LIST_ENTRY BestConfig;
914     LIST_ENTRY ActiveArbiterList;
915     UCHAR State;
916     UCHAR ResourcesChanged;
917 } PI_RESOURCE_ARBITER_ENTRY, *PPI_RESOURCE_ARBITER_ENTRY;
918 
919 //
920 // Extended Device Object Extension Structure
921 //
922 typedef struct _EXTENDED_DEVOBJ_EXTENSION
923 {
924     CSHORT Type;
925     USHORT Size;
926     PDEVICE_OBJECT DeviceObject;
927     ULONG PowerFlags;
928     struct _DEVICE_OBJECT_POWER_EXTENSION *Dope;
929     ULONG ExtensionFlags;
930     struct _DEVICE_NODE *DeviceNode;
931     PDEVICE_OBJECT AttachedTo;
932     LONG StartIoCount;
933     LONG StartIoKey;
934     ULONG StartIoFlags;
935     struct _VPB *Vpb;
936 } EXTENDED_DEVOBJ_EXTENSION, *PEXTENDED_DEVOBJ_EXTENSION;
937 
938 //
939 // Extended Driver Object Extension Structure
940 //
941 typedef struct _EXTENDED_DRIVER_EXTENSION
942 {
943     struct _DRIVER_OBJECT *DriverObject;
944     PDRIVER_ADD_DEVICE AddDevice;
945     ULONG Count;
946     UNICODE_STRING ServiceKeyName;
947     PIO_CLIENT_EXTENSION ClientDriverExtension;
948     PFS_FILTER_CALLBACKS FsFilterCallbacks;
949 } EXTENDED_DRIVER_EXTENSION, *PEXTENDED_DRIVER_EXTENSION;
950 
951 #endif // !NTOS_MODE_USER
952 
953 //
954 // Firmware Boot File Path
955 //
956 typedef struct _FILE_PATH
957 {
958     ULONG Version;
959     ULONG Length;
960     ULONG Type;
961     CHAR FilePath[1];
962 } FILE_PATH, *PFILE_PATH;
963 
964 //
965 // Firmware Boot Options
966 //
967 typedef struct _BOOT_OPTIONS
968 {
969     ULONG Version;
970     ULONG Length;
971     ULONG Timeout;
972     ULONG CurrentBootEntryId;
973     ULONG NextBootEntryId;
974     WCHAR HeadlessRedirection[1];
975 } BOOT_OPTIONS, *PBOOT_OPTIONS;
976 
977 //
978 // Firmware Boot Entry
979 //
980 typedef struct _BOOT_ENTRY
981 {
982     ULONG Version;
983     ULONG Length;
984     ULONG Id;
985     ULONG Attributes;
986     ULONG FriendlyNameOffset;
987     ULONG BootFilePathOffset;
988     ULONG OsOptionsLength;
989     CHAR OsOptions[1];
990 } BOOT_ENTRY, *PBOOT_ENTRY;
991 
992 //
993 // Firmware Driver Entry
994 //
995 typedef struct _EFI_DRIVER_ENTRY
996 {
997     ULONG Version;
998     ULONG Length;
999     ULONG Id;
1000     ULONG Attributes;
1001     ULONG FriendlyNameOffset;
1002     ULONG DriverFilePathOffset;
1003 } EFI_DRIVER_ENTRY, *PEFI_DRIVER_ENTRY;
1004 
1005 #ifdef NTOS_MODE_USER
1006 
1007 //
1008 // APC Callback for NtCreateFile
1009 //
1010 typedef VOID
1011 (NTAPI *PIO_APC_ROUTINE)(
1012     _In_ PVOID ApcContext,
1013     _In_ PIO_STATUS_BLOCK IoStatusBlock,
1014     _In_ ULONG Reserved);
1015 
1016 //
1017 // Mailslot IOCTL Codes
1018 //
1019 #define FSCTL_MAILSLOT_PEEK             \
1020     CTL_CODE(FILE_DEVICE_MAILSLOT, 0, METHOD_NEITHER, FILE_READ_DATA)
1021 
1022 //
1023 // Pipe IOCTL Codes
1024 //
1025 #define FSCTL_PIPE_ASSIGN_EVENT         \
1026     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
1027 #define FSCTL_PIPE_DISCONNECT           \
1028     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
1029 #define FSCTL_PIPE_LISTEN               \
1030     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
1031 #define FSCTL_PIPE_PEEK                 \
1032     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
1033 #define FSCTL_PIPE_QUERY_EVENT          \
1034     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
1035 #define FSCTL_PIPE_TRANSCEIVE           \
1036     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER,  FILE_READ_DATA | FILE_WRITE_DATA)
1037 #define FSCTL_PIPE_WAIT                 \
1038     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
1039 #define FSCTL_PIPE_IMPERSONATE          \
1040     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
1041 #define FSCTL_PIPE_SET_CLIENT_PROCESS   \
1042     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
1043 #define FSCTL_PIPE_QUERY_CLIENT_PROCESS \
1044     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
1045 #define FSCTL_PIPE_INTERNAL_READ        \
1046     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
1047 #define FSCTL_PIPE_INTERNAL_WRITE       \
1048     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
1049 #define FSCTL_PIPE_INTERNAL_TRANSCEIVE  \
1050     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
1051 #define FSCTL_PIPE_INTERNAL_READ_OVFLOW \
1052     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
1053 
1054 //
1055 // Tape IOCTL Codes
1056 //
1057 #define IOCTL_TAPE_ERASE                \
1058     CTL_CODE(FILE_DEVICE_TAPE, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1059 #define IOCTL_TAPE_PREPARE              \
1060     CTL_CODE(FILE_DEVICE_TAPE, 1, METHOD_BUFFERED, FILE_READ_ACCESS)
1061 #define IOCTL_TAPE_WRITE_MARKS          \
1062     CTL_CODE(FILE_DEVICE_TAPE, 2, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1063 #define IOCTL_TAPE_GET_POSITION         \
1064     CTL_CODE(FILE_DEVICE_TAPE, 3, METHOD_BUFFERED, FILE_READ_ACCESS)
1065 #define IOCTL_TAPE_SET_POSITION         \
1066     CTL_CODE(FILE_DEVICE_TAPE, 4, METHOD_BUFFERED, FILE_READ_ACCESS)
1067 #define IOCTL_TAPE_GET_DRIVE_PARAMS     \
1068     CTL_CODE(FILE_DEVICE_TAPE, 5, METHOD_BUFFERED, FILE_READ_ACCESS)
1069 #define IOCTL_TAPE_SET_DRIVE_PARAMS     \
1070     CTL_CODE(FILE_DEVICE_TAPE, 6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1071 #define IOCTL_TAPE_GET_MEDIA_PARAMS     \
1072     CTL_CODE(FILE_DEVICE_TAPE, 7, METHOD_BUFFERED, FILE_READ_ACCESS)
1073 #define IOCTL_TAPE_SET_MEDIA_PARAMS     \
1074     CTL_CODE(FILE_DEVICE_TAPE, 8, METHOD_BUFFERED, FILE_READ_ACCESS)
1075 #define IOCTL_TAPE_GET_STATUS           \
1076     CTL_CODE(FILE_DEVICE_TAPE, 9, METHOD_BUFFERED, FILE_READ_ACCESS)
1077 #define IOCTL_TAPE_CREATE_PARTITION     \
1078     CTL_CODE(FILE_DEVICE_TAPE, 10, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1079 
1080 //
1081 // Reparse points
1082 //
1083 
1084 #define SYMLINK_FLAG_RELATIVE   1
1085 
1086 typedef struct _REPARSE_DATA_BUFFER {
1087   ULONG ReparseTag;
1088   USHORT ReparseDataLength;
1089   USHORT Reserved;
1090   _ANONYMOUS_UNION union {
1091     struct {
1092       USHORT SubstituteNameOffset;
1093       USHORT SubstituteNameLength;
1094       USHORT PrintNameOffset;
1095       USHORT PrintNameLength;
1096       ULONG Flags;
1097       WCHAR PathBuffer[1];
1098     } SymbolicLinkReparseBuffer;
1099     struct {
1100       USHORT SubstituteNameOffset;
1101       USHORT SubstituteNameLength;
1102       USHORT PrintNameOffset;
1103       USHORT PrintNameLength;
1104       WCHAR PathBuffer[1];
1105     } MountPointReparseBuffer;
1106     struct {
1107       UCHAR DataBuffer[1];
1108     } GenericReparseBuffer;
1109   } DUMMYUNIONNAME;
1110 } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
1111 
1112 #endif // NTOS_MODE_USER
1113 
1114 #endif
1115