Added (io/create.c) IoCreateFile stub.
[reactos.git] / reactos / include / ddk / iotypes.h
1 /* $Id: iotypes.h,v 1.9 1999/12/26 20:21:02 ea Exp $
2 *
3 */
4
5 #ifndef __INCLUDE_DDK_IOTYPES_H
6 #define __INCLUDE_DDK_IOTYPES_H
7
8 /*
9 * These are referenced before they can be fully defined
10 */
11 struct _DRIVER_OBJECT;
12 struct _FILE_OBJECT;
13 struct _DEVICE_OBJECT;
14 struct _IRP;
15 struct _IO_STATUS_BLOCK;
16
17 /* SIMPLE TYPES *************************************************************/
18
19 enum
20 {
21 DeallocateObject,
22 KeepObject,
23 };
24
25
26 typedef enum _CREATE_FILE_TYPE
27 {
28 CreateFileTypeNone,
29 CreateFileTypeNamedPipe,
30 CreateFileTypeMailslot
31 } CREATE_FILE_TYPE;
32
33
34 typedef ULONG INTERFACE_TYPE;
35 typedef INTERFACE_TYPE* PINTERFACE_TYPE;
36
37 /*
38 * FIXME: Definition needed
39 */
40 typedef struct _SHARE_ACCESS
41 {
42 } SHARE_ACCESS, *PSHARE_ACCESS;
43
44 /* FUNCTION TYPES ************************************************************/
45
46 typedef VOID (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
47 PVOID Context,
48 ULONG Count);
49
50 typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
51 PUNICODE_STRING Pathname,
52 INTERFACE_TYPE BusType,
53 ULONG BusNumber,
54 PKEY_VALUE_FULL_INFORMATION* BI,
55 CONFIGURATION_TYPE ControllerType,
56 ULONG ControllerNumber,
57 PKEY_VALUE_FULL_INFORMATION* CI,
58 CONFIGURATION_TYPE PeripheralType,
59 ULONG PeripheralNumber,
60 PKEY_VALUE_FULL_INFORMATION* PI);
61
62 typedef NTSTATUS (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
63 struct _IRP* Irp,
64 PVOID Context);
65
66 typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
67 struct _IO_STATUS_BLOCK* IoStatusBlock,
68 ULONG Reserved);
69
70
71 /* STRUCTURE TYPES ***********************************************************/
72
73 typedef struct _ADAPTER_OBJECT
74 {
75 } ADAPTER_OBJECT, *PADAPTER_OBJECT;
76
77 /*
78 * PURPOSE: Special timer associated with each device
79 * NOTES: This is a guess
80 */
81 typedef struct _IO_TIMER
82 {
83 KTIMER timer;
84 KDPC dpc;
85 } IO_TIMER, *PIO_TIMER;
86
87 typedef struct _IO_SECURITY_CONTEXT
88 {
89 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
90 PACCESS_STATE AccessState;
91 ACCESS_MASK DesiredAccess;
92 ULONG FullCreateOptions;
93 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
94
95 /*
96 * PURPOSE: IRP stack location
97 */
98 typedef struct _IO_STACK_LOCATION
99 {
100 UCHAR MajorFunction;
101 UCHAR MinorFunction;
102 UCHAR Flags;
103 UCHAR Control;
104
105 union
106 {
107 struct
108 {
109 PIO_SECURITY_CONTEXT SecurityContext;
110 ULONG Options;
111 USHORT FileAttributes;
112 USHORT ShareAccess;
113 ULONG EaLength;
114 } Create;
115 struct
116 {
117 ULONG Length;
118 ULONG Key;
119 LARGE_INTEGER ByteOffset;
120 } Read;
121 struct
122 {
123 ULONG Length;
124 ULONG Key;
125 LARGE_INTEGER ByteOffset;
126 } Write;
127 struct
128 {
129 ULONG OutputBufferLength;
130 ULONG InputBufferLength;
131 ULONG IoControlCode;
132 PVOID Type3InputBuffer;
133 } DeviceIoControl;
134 struct
135 {
136 struct _VPB* Vpb;
137 struct _DEVICE_OBJECT* DeviceObject;
138 } Mount;
139 struct {
140 ULONG Length;
141 FILE_INFORMATION_CLASS FileInformationClass;
142 } QueryFile;
143 struct {
144 ULONG Length;
145 FS_INFORMATION_CLASS FileInformationClass;
146 } QueryVolume;
147 struct {
148 ULONG Length;
149 FS_INFORMATION_CLASS FileInformationClass;
150 } SetVolume;
151 struct {
152 ULONG Length;
153 FILE_INFORMATION_CLASS FileInformationClass;
154 struct FILE_OBJECT* FileObject;
155 union {
156 struct {
157 BOOLEAN ReplaceIfExists;
158 BOOLEAN AdvanceOnly;
159 } d;
160 ULONG ClusterCount;
161 HANDLE DeleteHandle;
162 } u;
163 } SetFile;
164 struct
165 {
166 ULONG Length;
167 PUNICODE_STRING FileName;
168 FILE_INFORMATION_CLASS FileInformationClass;
169 ULONG FileIndex;
170 } QueryDirectory;
171 } Parameters;
172
173 PIO_COMPLETION_ROUTINE CompletionRoutine;
174 PVOID CompletionContext;
175
176 struct _DEVICE_OBJECT* DeviceObject;
177
178 struct _FILE_OBJECT* FileObject;
179 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
180
181 typedef struct _IO_STATUS_BLOCK
182 {
183 NTSTATUS Status;
184 ULONG Information;
185 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
186
187 /*
188 * Driver entry point declaration
189 */
190 typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
191 PUNICODE_STRING RegistryPath);
192
193 /*
194 * Driver cancel declaration
195 */
196 typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
197 struct _IRP* RegistryPath);
198
199
200 typedef struct _SECTION_OBJECT_POINTERS
201 {
202 PVOID DataSectionObject;
203 PVOID SharedCacheMap;
204 PVOID ImageSectionObject;
205 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
206
207 typedef struct _IO_COMPLETION_CONTEXT
208 {
209 PVOID Port;
210 ULONG Key;
211 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
212
213 #define FO_FILE_OPEN 0x00000001
214 #define FO_SYNCHRONOUS_IO 0x00000002
215 #define FO_ALERTABLE_IO 0x00000004
216 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
217 #define FO_WRITE_THROUGH 0x00000010
218 #define FO_SEQUENTIAL_ONLY 0x00000020
219 #define FO_CACHE_SUPPORTED 0x00000040
220 #define FO_NAMED_PIPE 0x00000080
221 #define FO_STREAM_FILE 0x00000100
222 #define FO_MAILSLOT 0x00000200
223 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
224 #define FO_DIRECT_DEVICE_OPEN 0x00000800
225 #define FO_FILE_MODIFIED 0x00001000
226 #define FO_FILE_SIZE_CHANGED 0x00002000
227 #define FO_CLEANUP_COMPLETE 0x00004000
228 #define FO_TEMPORARY_FILE 0x00008000
229 #define FO_DELETE_ON_CLOSE 0x00010000
230 #define FO_OPENED_CASE_SENSITIVE 0x00020000
231 #define FO_HANDLE_CREATED 0x00040000
232 #define FO_FILE_FAST_IO_READ 0x00080000
233
234 typedef struct _FILE_OBJECT
235 {
236 CSHORT Type;
237 CSHORT Size;
238 struct _DEVICE_OBJECT* DeviceObject;
239 struct _VPB* Vpb;
240 PVOID FsContext;
241 PVOID FsContext2;
242 PSECTION_OBJECT_POINTERS SectionObjectPointers;
243 PVOID PrivateCacheMap;
244 NTSTATUS FinalStatus;
245 struct _FILE_OBJECT* RelatedFileObject;
246 BOOLEAN LockOperation;
247 BOOLEAN DeletePending;
248 BOOLEAN ReadAccess;
249 BOOLEAN WriteAccess;
250 BOOLEAN DeleteAccess;
251 BOOLEAN SharedRead;
252 BOOLEAN SharedWrite;
253 BOOLEAN SharedDelete;
254 ULONG Flags;
255 UNICODE_STRING FileName;
256 LARGE_INTEGER CurrentByteOffset;
257 ULONG Waiters;
258 ULONG Busy;
259 PVOID LastLock;
260 KEVENT Lock;
261 KEVENT Event;
262 PIO_COMPLETION_CONTEXT CompletionContext;
263 } FILE_OBJECT, *PFILE_OBJECT;
264
265
266 typedef struct _IRP
267 {
268 PMDL MdlAddress;
269 ULONG Flags;
270 union
271 {
272 struct _IRP* MasterIrp;
273 LONG IrpCount;
274 PVOID SystemBuffer;
275 } AssociatedIrp;
276 LIST_ENTRY ThreadListEntry;
277 IO_STATUS_BLOCK IoStatus;
278 KPROCESSOR_MODE RequestorMode;
279 BOOLEAN PendingReturned;
280 BOOLEAN Cancel;
281 KIRQL CancelIrql;
282 PDRIVER_CANCEL CancelRoutine;
283 PVOID UserBuffer;
284 PVOID ApcEnvironment;
285 ULONG AllocationFlags;
286 PIO_STATUS_BLOCK UserIosb;
287 PKEVENT UserEvent;
288 union
289 {
290 struct
291 {
292 PIO_APC_ROUTINE UserApcRoutine;
293 PVOID UserApcContext;
294 } AsynchronousParameters;
295 LARGE_INTEGER AllocationSize;
296 } Overlay;
297 union
298 {
299 struct
300 {
301 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
302 struct _ETHREAD* Thread;
303 PCHAR AuxiliaryBuffer;
304 LIST_ENTRY ListEntry;
305 struct _IO_STACK_LOCATION* CurrentStackLocation;
306 PFILE_OBJECT OriginalFileObject;
307 } Overlay;
308 KAPC Apc;
309 ULONG CompletionKey;
310 } Tail;
311 CHAR StackCount;
312 CHAR CurrentLocation;
313 IO_STACK_LOCATION Stack[1];
314 } IRP, *PIRP;
315
316 #define VPB_MOUNTED 0x00000001
317 #define VPB_LOCKED 0x00000002
318 #define VPB_PERSISTENT 0x00000004
319 #define VPB_REMOVE_PENDING 0x00000008
320
321 typedef struct _VPB
322 {
323 CSHORT Type;
324 CSHORT Size;
325 USHORT Flags;
326 USHORT VolumeLabelLength;
327 struct _DEVICE_OBJECT* DeviceObject;
328 struct _DEVICE_OBJECT* RealDevice;
329 ULONG SerialNumber;
330 ULONG ReferenceCount;
331 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
332 } VPB, *PVPB;
333
334
335 typedef struct _DEVICE_OBJECT
336 {
337 CSHORT Type;
338 CSHORT Size;
339 LONG ReferenceCount;
340 struct _DRIVER_OBJECT* DriverObject;
341 struct _DEVICE_OBJECT* NextDevice;
342 struct _DEVICE_OBJECT* AttachedDevice;
343 struct _IRP* CurrentIrp;
344 PIO_TIMER Timer;
345 ULONG Flags;
346 ULONG Characteristics;
347 PVPB Vpb;
348 PVOID DeviceExtension;
349 DEVICE_TYPE DeviceType;
350 CCHAR StackSize;
351 union
352 {
353 LIST_ENTRY ListHead;
354 WAIT_CONTEXT_BLOCK Wcb;
355 } Queue;
356 ULONG AlignmentRequirement;
357 KDEVICE_QUEUE DeviceQueue;
358 KDPC Dpc;
359 ULONG ActiveThreadCount;
360 PSECURITY_DESCRIPTOR SecurityDescriptor;
361 KEVENT DeviceLock;
362 USHORT SectorSize;
363 USHORT Spare1;
364 struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
365 PVOID Reserved;
366 } DEVICE_OBJECT, *PDEVICE_OBJECT;
367
368 /*
369 * Dispatch routine type declaration
370 */
371 typedef NTSTATUS (*PDRIVER_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
372
373 /*
374 * Fast i/o routine type declaration
375 */
376 typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
377
378 /*
379 * Dispatch routine type declaration
380 */
381 typedef VOID (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*);
382
383 /*
384 * Dispatch routine type declaration
385 */
386 typedef NTSTATUS (*PDRIVER_UNLOAD)(struct _DRIVER_OBJECT*);
387
388 typedef struct _DRIVER_EXTENSION
389 {
390 struct _DRIVER_OBJECT* DriverObject;
391 PDRIVER_ADD_DEVICE AddDevice;
392 ULONG Count;
393 UNICODE_STRING ServiceKeyName;
394 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
395
396 typedef struct _DRIVER_OBJECT
397 {
398 CSHORT Type;
399 CSHORT Size;
400 PDEVICE_OBJECT DeviceObject;
401 ULONG Flags;
402 PVOID DriverStart;
403 ULONG DriverSize;
404 PVOID DriverSection;
405 PDRIVER_EXTENSION DriverExtension;
406 UNICODE_STRING DriverName;
407 PUNICODE_STRING HardwareDatabase;
408 PFAST_IO_DISPATCH FastIoDispatch;
409 PDRIVER_INITIALIZE DriverInit;
410 PDRIVER_STARTIO DriverStartIo;
411 PDRIVER_UNLOAD DriverUnload;
412 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
413 } DRIVER_OBJECT, *PDRIVER_OBJECT;
414
415
416 typedef struct _CONFIGURATION_INFORMATION
417 {
418 ULONG DiskCount;
419 ULONG FloppyCount;
420 ULONG CDRomCount;
421 ULONG TapeCount;
422 ULONG ScsiPortCount;
423 ULONG SerialCount;
424 ULONG ParallelCount;
425 BOOLEAN AtDiskPrimaryAddressClaimed;
426 BOOLEAN AtDiskSecondaryAddressClaimed;
427 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
428
429 typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
430 PDEVICE_OBJECT DeviceObject,
431 PIRP Irp,
432 PVOID Context);
433
434 typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
435 PVOID Context);
436
437 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
438 typedef struct _PARTITION_INFORMATION
439 {
440 LARGE_INTEGER StartingOffset;
441 LARGE_INTEGER PartitionLength;
442 ULONG HiddenSectors;
443 ULONG PartitionNumber;
444 UCHAR PartitionType;
445 BOOLEAN BootIndicator;
446 BOOLEAN RecognizedPartition;
447 BOOLEAN RewritePartition;
448 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
449 #endif
450
451 typedef struct _DRIVER_LAYOUT_INFORMATION
452 {
453 ULONG PartitionCount;
454 ULONG Signature;
455 PARTITION_INFORMATION PartitionEntry[1];
456 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
457
458
459
460
461
462 typedef struct _IO_RESOURCE_DESCRIPTOR
463 {
464 UCHAR Option;
465 UCHAR Type;
466 UCHAR SharedDisposition;
467
468 /*
469 * Reserved for system use
470 */
471 UCHAR Spare1;
472
473 USHORT Flags;
474
475 /*
476 * Reserved for system use
477 */
478 UCHAR Spare2;
479
480 union
481 {
482 struct
483 {
484 ULONG Length;
485 ULONG Alignment;
486 PHYSICAL_ADDRESS MinimumAddress;
487 PHYSICAL_ADDRESS MaximumAddress;
488 } Port;
489 struct
490 {
491 ULONG Length;
492 ULONG Alignment;
493 PHYSICAL_ADDRESS MinimumAddress;
494 PHYSICAL_ADDRESS MaximumAddress;
495 } Memory;
496 struct
497 {
498 ULONG MinimumVector;
499 ULONG MaximumVector;
500 } Interrupt;
501 struct
502 {
503 ULONG MinimumChannel;
504 ULONG MaximumChannel;
505 } Dma;
506 } u;
507 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
508
509 typedef struct _IO_RESOURCE_LIST
510 {
511 USHORT Version;
512 USHORT Revision;
513 ULONG Count;
514 IO_RESOURCE_DESCRIPTOR Descriptors[1];
515 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
516
517 typedef struct _IO_RESOURCES_REQUIREMENTS_LIST
518 {
519 /*
520 * List size in bytes
521 */
522 ULONG ListSize;
523
524 /*
525 * System defined enum for the bus
526 */
527 INTERFACE_TYPE InterfaceType;
528
529 ULONG BusNumber;
530 ULONG SlotNumber;
531 ULONG Reserved[3];
532 ULONG AlternativeLists;
533 IO_RESOURCE_LIST List[1];
534 } IO_RESOURCES_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
535
536 typedef struct
537 {
538 UCHAR Type;
539 UCHAR ShareDisposition;
540 USHORT Flags;
541 union
542 {
543 struct
544 {
545 PHYSICAL_ADDRESS Start;
546 ULONG Length;
547 } Port;
548 struct
549 {
550 ULONG Level;
551 ULONG Vector;
552 ULONG Affinity;
553 } Interrupt;
554 struct
555 {
556 PHYSICAL_ADDRESS Start;
557 ULONG Length;
558 } Memory;
559 struct
560 {
561 ULONG Channel;
562 ULONG Port;
563 ULONG Reserved1;
564 } Dma;
565 struct
566 {
567 ULONG DataSize;
568 ULONG Reserved1;
569 ULONG Reserved2;
570 } DeviceSpecificData;
571 } u;
572 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
573
574 typedef struct
575 {
576 USHORT Version;
577 USHORT Revision;
578 ULONG Count;
579 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
580 } CM_PARTIAL_RESOURCE_LIST;
581
582 typedef struct
583 {
584 INTERFACE_TYPE InterfaceType;
585 ULONG BusNumber;
586 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
587 } CM_FULL_RESOURCE_DESCRIPTOR;
588
589 typedef struct
590 {
591 ULONG Count;
592 CM_FULL_RESOURCE_DESCRIPTOR List[1];
593 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
594
595
596 #endif __INCLUDE_DDK_IOTYPES_H