xref: /reactos/sdk/include/ndk/iotypes.h (revision 3c797b31)
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     FileIoCompletionNotificationInformation,
327 #if (NTDDI_VERSION >= NTDDI_VISTA)
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_IO_COMPLETION_NOTIFICATION_INFORMATION
608 {
609     ULONG Flags;
610 } FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
611 
612 typedef struct _FILE_LINK_INFORMATION
613 {
614     BOOLEAN ReplaceIfExists;
615     HANDLE RootDirectory;
616     ULONG FileNameLength;
617     WCHAR FileName[1];
618 } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
619 
620 typedef struct _FILE_NAME_INFORMATION
621 {
622     ULONG FileNameLength;
623     WCHAR FileName[1];
624 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
625 
626 typedef struct _FILE_ALLOCATION_INFORMATION
627 {
628     LARGE_INTEGER AllocationSize;
629 } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
630 
631 typedef struct _FILE_END_OF_FILE_INFORMATION
632 {
633     LARGE_INTEGER EndOfFile;
634 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
635 
636 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION
637 {
638     LARGE_INTEGER ValidDataLength;
639 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
640 
641 typedef struct _FILE_DIRECTORY_INFORMATION
642 {
643     ULONG NextEntryOffset;
644     ULONG FileIndex;
645     LARGE_INTEGER CreationTime;
646     LARGE_INTEGER LastAccessTime;
647     LARGE_INTEGER LastWriteTime;
648     LARGE_INTEGER ChangeTime;
649     LARGE_INTEGER EndOfFile;
650     LARGE_INTEGER AllocationSize;
651     ULONG FileAttributes;
652     ULONG FileNameLength;
653     WCHAR FileName[1];
654 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
655 
656 typedef struct _FILE_IO_COMPLETION_INFORMATION
657 {
658     PVOID KeyContext;
659     PVOID ApcContext;
660     IO_STATUS_BLOCK IoStatusBlock;
661 } FILE_IO_COMPLETION_INFORMATION, *PFILE_IO_COMPLETION_INFORMATION;
662 
663 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION
664 {
665     ULONG FileAttributes;
666     ULONG ReparseTag;
667 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
668 
669 typedef struct _FILE_TRACKING_INFORMATION
670 {
671     HANDLE DestinationFile;
672     ULONG ObjectInformationLength;
673     CHAR ObjectInformation[1];
674 } FILE_TRACKING_INFORMATION, *PFILE_TRACKING_INFORMATION;
675 
676 //
677 // File System Information structures for NtQueryInformationFile
678 //
679 typedef struct _FILE_FS_DEVICE_INFORMATION
680 {
681     DEVICE_TYPE DeviceType;
682     ULONG Characteristics;
683 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
684 
685 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
686 {
687     ULONG FileSystemAttributes;
688     ULONG MaximumComponentNameLength;
689     ULONG FileSystemNameLength;
690     WCHAR FileSystemName[1];
691 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
692 
693 typedef struct _FILE_FS_SIZE_INFORMATION
694 {
695     LARGE_INTEGER TotalAllocationUnits;
696     LARGE_INTEGER AvailableAllocationUnits;
697     ULONG SectorsPerAllocationUnit;
698     ULONG BytesPerSector;
699 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
700 
701 typedef struct _FILE_FS_FULL_SIZE_INFORMATION
702 {
703     LARGE_INTEGER   TotalAllocationUnits;
704     LARGE_INTEGER   CallerAvailableAllocationUnits;
705     LARGE_INTEGER   ActualAvailableAllocationUnits;
706     ULONG           SectorsPerAllocationUnit;
707     ULONG           BytesPerSector;
708 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
709 
710 typedef struct _FILE_FS_LABEL_INFORMATION
711 {
712     ULONG VolumeLabelLength;
713     WCHAR VolumeLabel[1];
714 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
715 
716 typedef struct _FILE_FS_VOLUME_INFORMATION
717 {
718     LARGE_INTEGER VolumeCreationTime;
719     ULONG VolumeSerialNumber;
720     ULONG VolumeLabelLength;
721     BOOLEAN SupportsObjects;
722     WCHAR VolumeLabel[1];
723 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
724 
725 //
726 // Pipe Structures for IOCTL_PIPE_XXX
727 //
728 typedef struct _FILE_PIPE_WAIT_FOR_BUFFER
729 {
730     LARGE_INTEGER Timeout;
731     ULONG NameLength;
732     BOOLEAN TimeoutSpecified;
733     WCHAR Name[1];
734 } FILE_PIPE_WAIT_FOR_BUFFER, *PFILE_PIPE_WAIT_FOR_BUFFER;
735 
736 typedef struct _FILE_PIPE_PEEK_BUFFER
737 {
738     ULONG NamedPipeState;
739     ULONG ReadDataAvailable;
740     ULONG NumberOfMessages;
741     ULONG MessageLength;
742     CHAR Data[1];
743 } FILE_PIPE_PEEK_BUFFER, *PFILE_PIPE_PEEK_BUFFER;
744 
745 //
746 // I/O Error Log Structures
747 //
748 typedef struct _IO_ERROR_LOG_PACKET
749 {
750     UCHAR MajorFunctionCode;
751     UCHAR RetryCount;
752     USHORT DumpDataSize;
753     USHORT NumberOfStrings;
754     USHORT StringOffset;
755     USHORT EventCategory;
756     NTSTATUS ErrorCode;
757     ULONG UniqueErrorValue;
758     NTSTATUS FinalStatus;
759     ULONG SequenceNumber;
760     ULONG IoControlCode;
761     LARGE_INTEGER DeviceOffset;
762     ULONG DumpData[1];
763 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
764 
765 typedef struct _IO_ERROR_LOG_MESSAGE
766 {
767     USHORT Type;
768     USHORT Size;
769     USHORT DriverNameLength;
770     LARGE_INTEGER TimeStamp;
771     ULONG DriverNameOffset;
772     IO_ERROR_LOG_PACKET EntryData;
773 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
774 
775 #endif
776 
777 //
778 // I/O Completion Information structures
779 //
780 typedef struct _IO_COMPLETION_BASIC_INFORMATION
781 {
782     LONG Depth;
783 } IO_COMPLETION_BASIC_INFORMATION, *PIO_COMPLETION_BASIC_INFORMATION;
784 
785 //
786 // Parameters for NtCreateMailslotFile/NtCreateNamedPipeFile
787 //
788 typedef struct _MAILSLOT_CREATE_PARAMETERS
789 {
790     ULONG MailslotQuota;
791     ULONG MaximumMessageSize;
792     LARGE_INTEGER ReadTimeout;
793     BOOLEAN TimeoutSpecified;
794 } MAILSLOT_CREATE_PARAMETERS, *PMAILSLOT_CREATE_PARAMETERS;
795 
796 typedef struct _NAMED_PIPE_CREATE_PARAMETERS
797 {
798     ULONG NamedPipeType;
799     ULONG ReadMode;
800     ULONG CompletionMode;
801     ULONG MaximumInstances;
802     ULONG InboundQuota;
803     ULONG OutboundQuota;
804     LARGE_INTEGER DefaultTimeout;
805     BOOLEAN TimeoutSpecified;
806 } NAMED_PIPE_CREATE_PARAMETERS, *PNAMED_PIPE_CREATE_PARAMETERS;
807 
808 #ifndef NTOS_MODE_USER
809 
810 //
811 // I/O Timer Object
812 //
813 typedef struct _IO_TIMER
814 {
815     USHORT Type;
816     USHORT TimerEnabled;
817     LIST_ENTRY IoTimerList;
818     PIO_TIMER_ROUTINE TimerRoutine;
819     PVOID Context;
820     PDEVICE_OBJECT DeviceObject;
821 } IO_TIMER;
822 
823 //
824 // Driver Extension
825 //
826 typedef struct _IO_CLIENT_EXTENSION
827 {
828     struct _IO_CLIENT_EXTENSION *NextExtension;
829     PVOID ClientIdentificationAddress;
830 } IO_CLIENT_EXTENSION, *PIO_CLIENT_EXTENSION;
831 
832 #define DEVNODE_HISTORY_SIZE 20
833 
834 //
835 // Device Node
836 //
837 typedef struct _DEVICE_NODE
838 {
839     struct _DEVICE_NODE *Sibling;
840     struct _DEVICE_NODE *Child;
841     struct _DEVICE_NODE *Parent;
842     struct _DEVICE_NODE *LastChild;
843     ULONG Level;
844     struct _PO_DEVICE_NOTIFY *Notify;
845     PO_IRP_MANAGER PoIrpManager;
846     PNP_DEVNODE_STATE State;
847     PNP_DEVNODE_STATE PreviousState;
848     PNP_DEVNODE_STATE StateHistory[DEVNODE_HISTORY_SIZE];
849     ULONG StateHistoryEntry;
850     NTSTATUS CompletionStatus;
851     PIRP PendingIrp;
852     ULONG Flags;
853     ULONG UserFlags;
854     ULONG Problem;
855     PDEVICE_OBJECT PhysicalDeviceObject;
856     PCM_RESOURCE_LIST ResourceList;
857     PCM_RESOURCE_LIST ResourceListTranslated;
858     UNICODE_STRING InstancePath;
859     UNICODE_STRING ServiceName;
860     PDEVICE_OBJECT DuplicatePDO;
861     PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements;
862     INTERFACE_TYPE InterfaceType;
863     ULONG BusNumber;
864     INTERFACE_TYPE ChildInterfaceType;
865     ULONG ChildBusNumber;
866     USHORT ChildBusTypeIndex;
867     UCHAR RemovalPolicy;
868     UCHAR HardwareRemovalPolicy;
869     LIST_ENTRY TargetDeviceNotify;
870     LIST_ENTRY DeviceArbiterList;
871     LIST_ENTRY DeviceTranslatorList;
872     USHORT NoTranslatorMask;
873     USHORT QueryTranslatorMask;
874     USHORT NoArbiterMask;
875     USHORT QueryArbiterMask;
876     union
877     {
878         struct _DEVICE_NODE *LegacyDeviceNode;
879         PDEVICE_RELATIONS PendingDeviceRelations;
880     } OverUsed1;
881     union
882     {
883         struct _DEVICE_NODE *NextResourceDeviceNode;
884     } OverUsed2;
885     PCM_RESOURCE_LIST BootResources;
886 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
887     PCM_RESOURCE_LIST BootResourcesTranslated;
888 #endif
889     ULONG CapabilityFlags;
890     struct
891     {
892         PROFILE_STATUS DockStatus;
893         LIST_ENTRY ListEntry;
894         WCHAR *SerialNumber;
895     } DockInfo;
896     ULONG DisableableDepends;
897     LIST_ENTRY PendedSetInterfaceState;
898     LIST_ENTRY LegacyBusListEntry;
899     ULONG DriverUnloadRetryCount;
900     struct _DEVICE_NODE *PreviousParent;
901     ULONG DeletedChildren;
902 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
903     ULONG NumaNodeIndex;
904 #endif
905 } DEVICE_NODE, *PDEVICE_NODE;
906 
907 //
908 // Resource Aribtrer Entry
909 //
910 typedef struct _PI_RESOURCE_ARBITER_ENTRY
911 {
912     LIST_ENTRY DeviceArbiterList;
913     UCHAR ResourceType;
914     PARBITER_INTERFACE ArbiterInterface;
915     ULONG Level;
916     LIST_ENTRY ResourceList;
917     LIST_ENTRY BestResourceList;
918     LIST_ENTRY BestConfig;
919     LIST_ENTRY ActiveArbiterList;
920     UCHAR State;
921     UCHAR ResourcesChanged;
922 } PI_RESOURCE_ARBITER_ENTRY, *PPI_RESOURCE_ARBITER_ENTRY;
923 
924 //
925 // Extended Device Object Extension Structure
926 //
927 typedef struct _EXTENDED_DEVOBJ_EXTENSION
928 {
929     CSHORT Type;
930     USHORT Size;
931     PDEVICE_OBJECT DeviceObject;
932     ULONG PowerFlags;
933     struct _DEVICE_OBJECT_POWER_EXTENSION *Dope;
934     ULONG ExtensionFlags;
935     struct _DEVICE_NODE *DeviceNode;
936     PDEVICE_OBJECT AttachedTo;
937     LONG StartIoCount;
938     LONG StartIoKey;
939     ULONG StartIoFlags;
940     struct _VPB *Vpb;
941 } EXTENDED_DEVOBJ_EXTENSION, *PEXTENDED_DEVOBJ_EXTENSION;
942 
943 //
944 // Extended Driver Object Extension Structure
945 //
946 typedef struct _EXTENDED_DRIVER_EXTENSION
947 {
948     struct _DRIVER_OBJECT *DriverObject;
949     PDRIVER_ADD_DEVICE AddDevice;
950     ULONG Count;
951     UNICODE_STRING ServiceKeyName;
952     PIO_CLIENT_EXTENSION ClientDriverExtension;
953     PFS_FILTER_CALLBACKS FsFilterCallbacks;
954 } EXTENDED_DRIVER_EXTENSION, *PEXTENDED_DRIVER_EXTENSION;
955 
956 #endif // !NTOS_MODE_USER
957 
958 //
959 // Firmware Boot File Path
960 //
961 typedef struct _FILE_PATH
962 {
963     ULONG Version;
964     ULONG Length;
965     ULONG Type;
966     CHAR FilePath[1];
967 } FILE_PATH, *PFILE_PATH;
968 
969 //
970 // Firmware Boot Options
971 //
972 typedef struct _BOOT_OPTIONS
973 {
974     ULONG Version;
975     ULONG Length;
976     ULONG Timeout;
977     ULONG CurrentBootEntryId;
978     ULONG NextBootEntryId;
979     WCHAR HeadlessRedirection[1];
980 } BOOT_OPTIONS, *PBOOT_OPTIONS;
981 
982 //
983 // Firmware Boot Entry
984 //
985 typedef struct _BOOT_ENTRY
986 {
987     ULONG Version;
988     ULONG Length;
989     ULONG Id;
990     ULONG Attributes;
991     ULONG FriendlyNameOffset;
992     ULONG BootFilePathOffset;
993     ULONG OsOptionsLength;
994     CHAR OsOptions[1];
995 } BOOT_ENTRY, *PBOOT_ENTRY;
996 
997 //
998 // Firmware Driver Entry
999 //
1000 typedef struct _EFI_DRIVER_ENTRY
1001 {
1002     ULONG Version;
1003     ULONG Length;
1004     ULONG Id;
1005     ULONG Attributes;
1006     ULONG FriendlyNameOffset;
1007     ULONG DriverFilePathOffset;
1008 } EFI_DRIVER_ENTRY, *PEFI_DRIVER_ENTRY;
1009 
1010 #ifdef NTOS_MODE_USER
1011 
1012 //
1013 // APC Callback for NtReadFile, NtWriteFile
1014 //
1015 typedef VOID
1016 (NTAPI *PIO_APC_ROUTINE)(
1017     _In_ PVOID ApcContext,
1018     _In_ PIO_STATUS_BLOCK IoStatusBlock,
1019     _In_ ULONG Reserved);
1020 
1021 //
1022 // Mailslot IOCTL Codes
1023 //
1024 #define FSCTL_MAILSLOT_PEEK             \
1025     CTL_CODE(FILE_DEVICE_MAILSLOT, 0, METHOD_NEITHER, FILE_READ_DATA)
1026 
1027 //
1028 // Pipe IOCTL Codes
1029 //
1030 #define FSCTL_PIPE_ASSIGN_EVENT         \
1031     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
1032 #define FSCTL_PIPE_DISCONNECT           \
1033     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
1034 #define FSCTL_PIPE_LISTEN               \
1035     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
1036 #define FSCTL_PIPE_PEEK                 \
1037     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
1038 #define FSCTL_PIPE_QUERY_EVENT          \
1039     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
1040 #define FSCTL_PIPE_TRANSCEIVE           \
1041     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER,  FILE_READ_DATA | FILE_WRITE_DATA)
1042 #define FSCTL_PIPE_WAIT                 \
1043     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
1044 #define FSCTL_PIPE_IMPERSONATE          \
1045     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
1046 #define FSCTL_PIPE_SET_CLIENT_PROCESS   \
1047     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
1048 #define FSCTL_PIPE_QUERY_CLIENT_PROCESS \
1049     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
1050 #define FSCTL_PIPE_INTERNAL_READ        \
1051     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
1052 #define FSCTL_PIPE_INTERNAL_WRITE       \
1053     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
1054 #define FSCTL_PIPE_INTERNAL_TRANSCEIVE  \
1055     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
1056 #define FSCTL_PIPE_INTERNAL_READ_OVFLOW \
1057     CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
1058 
1059 //
1060 // Tape IOCTL Codes
1061 //
1062 #define IOCTL_TAPE_ERASE                \
1063     CTL_CODE(FILE_DEVICE_TAPE, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1064 #define IOCTL_TAPE_PREPARE              \
1065     CTL_CODE(FILE_DEVICE_TAPE, 1, METHOD_BUFFERED, FILE_READ_ACCESS)
1066 #define IOCTL_TAPE_WRITE_MARKS          \
1067     CTL_CODE(FILE_DEVICE_TAPE, 2, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1068 #define IOCTL_TAPE_GET_POSITION         \
1069     CTL_CODE(FILE_DEVICE_TAPE, 3, METHOD_BUFFERED, FILE_READ_ACCESS)
1070 #define IOCTL_TAPE_SET_POSITION         \
1071     CTL_CODE(FILE_DEVICE_TAPE, 4, METHOD_BUFFERED, FILE_READ_ACCESS)
1072 #define IOCTL_TAPE_GET_DRIVE_PARAMS     \
1073     CTL_CODE(FILE_DEVICE_TAPE, 5, METHOD_BUFFERED, FILE_READ_ACCESS)
1074 #define IOCTL_TAPE_SET_DRIVE_PARAMS     \
1075     CTL_CODE(FILE_DEVICE_TAPE, 6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1076 #define IOCTL_TAPE_GET_MEDIA_PARAMS     \
1077     CTL_CODE(FILE_DEVICE_TAPE, 7, METHOD_BUFFERED, FILE_READ_ACCESS)
1078 #define IOCTL_TAPE_SET_MEDIA_PARAMS     \
1079     CTL_CODE(FILE_DEVICE_TAPE, 8, METHOD_BUFFERED, FILE_READ_ACCESS)
1080 #define IOCTL_TAPE_GET_STATUS           \
1081     CTL_CODE(FILE_DEVICE_TAPE, 9, METHOD_BUFFERED, FILE_READ_ACCESS)
1082 #define IOCTL_TAPE_CREATE_PARTITION     \
1083     CTL_CODE(FILE_DEVICE_TAPE, 10, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
1084 
1085 //
1086 // Reparse points
1087 //
1088 
1089 #define SYMLINK_FLAG_RELATIVE   1
1090 
1091 typedef struct _REPARSE_DATA_BUFFER {
1092   ULONG ReparseTag;
1093   USHORT ReparseDataLength;
1094   USHORT Reserved;
1095   _ANONYMOUS_UNION union {
1096     struct {
1097       USHORT SubstituteNameOffset;
1098       USHORT SubstituteNameLength;
1099       USHORT PrintNameOffset;
1100       USHORT PrintNameLength;
1101       ULONG Flags;
1102       WCHAR PathBuffer[1];
1103     } SymbolicLinkReparseBuffer;
1104     struct {
1105       USHORT SubstituteNameOffset;
1106       USHORT SubstituteNameLength;
1107       USHORT PrintNameOffset;
1108       USHORT PrintNameLength;
1109       WCHAR PathBuffer[1];
1110     } MountPointReparseBuffer;
1111     struct {
1112       UCHAR DataBuffer[1];
1113     } GenericReparseBuffer;
1114   } DUMMYUNIONNAME;
1115 } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
1116 
1117 #endif // NTOS_MODE_USER
1118 
1119 #endif
1120