update for HEAD-2003091401
[reactos.git] / include / ddk / iotypes.h
1 /* $Id$
2  *
3  */
4
5 #ifndef __INCLUDE_DDK_IOTYPES_H
6 #define __INCLUDE_DDK_IOTYPES_H
7
8 #include <ntos/obtypes.h>
9 #include <ntos/disk.h>
10 #include <ntos/file.h>
11
12 #ifdef __NTOSKRNL__
13 extern POBJECT_TYPE EXPORTED IoAdapterObjectType;
14 extern POBJECT_TYPE EXPORTED IoDeviceHandlerObjectType;
15 extern POBJECT_TYPE EXPORTED IoDeviceObjectType;
16 extern POBJECT_TYPE EXPORTED IoDriverObjectType;
17 extern POBJECT_TYPE EXPORTED IoFileObjectType;
18 #else
19 extern POBJECT_TYPE IMPORTED IoAdapterObjectType;
20 extern POBJECT_TYPE IMPORTED IoDeviceHandlerObjectType;
21 extern POBJECT_TYPE IMPORTED IoDeviceObjectType;
22 extern POBJECT_TYPE IMPORTED IoDriverObjectType;
23 extern POBJECT_TYPE IMPORTED IoFileObjectType;
24 #endif
25
26
27 /* from winddk.h */
28 #define POINTER_ALIGNMENT
29
30
31 /*
32  * These are referenced before they can be fully defined
33  */
34 struct _DRIVER_OBJECT;
35 struct _FILE_OBJECT;
36 struct _DEVICE_OBJECT;
37 struct _IRP;
38 struct _IO_STATUS_BLOCK;
39 struct _SCSI_REQUEST_BLOCK;
40
41 /* SIMPLE TYPES *************************************************************/
42
43 enum
44 {
45    DeallocateObject,
46    KeepObject,
47    DeallocateObjectKeepRegisters
48 };
49
50
51 typedef enum _CREATE_FILE_TYPE
52 {
53    CreateFileTypeNone,
54    CreateFileTypeNamedPipe,
55    CreateFileTypeMailslot
56 } CREATE_FILE_TYPE;
57
58
59 typedef struct _SHARE_ACCESS
60 {
61    ULONG OpenCount;
62    ULONG Readers;
63    ULONG Writers;
64    ULONG Deleters;
65    ULONG SharedRead;
66    ULONG SharedWrite;
67    ULONG SharedDelete;
68 } SHARE_ACCESS, *PSHARE_ACCESS;
69
70 /* FUNCTION TYPES ************************************************************/
71
72 typedef VOID STDCALL_FUNC
73 (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
74                         PVOID Context,
75                         ULONG Count);
76
77 typedef NTSTATUS STDCALL_FUNC
78 (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
79                             PUNICODE_STRING Pathname,
80                             INTERFACE_TYPE BusType,
81                             ULONG BusNumber,
82                             PKEY_VALUE_FULL_INFORMATION* BI,
83                             CONFIGURATION_TYPE ControllerType,
84                             ULONG ControllerNumber,
85                             PKEY_VALUE_FULL_INFORMATION* CI,
86                             CONFIGURATION_TYPE PeripheralType,
87                             ULONG PeripheralNumber,
88                             PKEY_VALUE_FULL_INFORMATION* PI);
89
90 typedef NTSTATUS STDCALL_FUNC
91 (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
92                           struct _IRP* Irp,
93                           PVOID Context);
94
95 typedef VOID STDCALL_FUNC
96 (*PIO_APC_ROUTINE)(PVOID ApcContext,
97                    struct _IO_STATUS_BLOCK* IoStatusBlock,
98                    ULONG Reserved);
99
100
101 /* STRUCTURE TYPES ***********************************************************/
102
103 typedef struct _ADAPTER_OBJECT ADAPTER_OBJECT, *PADAPTER_OBJECT;
104
105 /*
106  * PURPOSE: Special timer associated with each device
107  * NOTES: This is a guess
108  */
109 typedef struct _IO_TIMER
110 {
111    KTIMER timer;
112    KDPC dpc;
113 } IO_TIMER, *PIO_TIMER;
114
115 typedef struct _IO_SECURITY_CONTEXT
116 {
117    PSECURITY_QUALITY_OF_SERVICE SecurityQos;
118    PACCESS_STATE AccessState;
119    ACCESS_MASK DesiredAccess;
120    ULONG FullCreateOptions;
121 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
122
123
124 typedef struct _IO_RESOURCE_DESCRIPTOR
125 {
126    UCHAR Option;
127    UCHAR Type;
128    UCHAR ShareDisposition;
129    
130    /*
131     * Reserved for system use
132     */
133    UCHAR Spare1;
134    
135    USHORT Flags;
136    
137    /*
138     * Reserved for system use
139     */
140    UCHAR Spare2;
141    
142    union
143      {
144         struct
145           {
146              ULONG Length;
147              ULONG Alignment;
148              PHYSICAL_ADDRESS MinimumAddress;
149              PHYSICAL_ADDRESS MaximumAddress;
150           } Port;
151         struct
152           {
153              ULONG Length;
154              ULONG Alignment;
155              PHYSICAL_ADDRESS MinimumAddress;
156              PHYSICAL_ADDRESS MaximumAddress;
157           } Memory;
158         struct
159           { 
160              ULONG MinimumVector;
161              ULONG MaximumVector;
162           } Interrupt;
163         struct
164           {
165              ULONG MinimumChannel;
166              ULONG MaximumChannel;
167           } Dma;
168      } u;
169 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
170
171 // IO_RESOURCE_DESCRIPTOR Options
172 #define IO_RESOURCE_REQUIRED    0x00
173 #define IO_RESOURCE_PREFERRED   0x01
174 #define IO_RESOURCE_DEFAULT     0x02
175 #define IO_RESOURCE_ALTERNATIVE 0x08
176
177 typedef struct _IO_RESOURCE_LIST
178 {
179    USHORT Version;
180    USHORT Revision;
181    ULONG Count;
182    IO_RESOURCE_DESCRIPTOR Descriptors[1];
183 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
184
185 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST
186 {
187    /*
188     * List size in bytes
189     */
190    ULONG ListSize;
191    
192    /*
193     * System defined enum for the bus
194     */
195    INTERFACE_TYPE InterfaceType;
196    
197    ULONG BusNumber;
198    ULONG SlotNumber;
199    ULONG Reserved[3];
200    ULONG AlternativeLists;
201    IO_RESOURCE_LIST List[1];
202 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
203
204
205 /* MicroChannel bus data */
206
207 typedef struct _CM_MCA_POS_DATA
208 {
209   USHORT AdapterId;
210   UCHAR PosData1;
211   UCHAR PosData2;
212   UCHAR PosData3;
213   UCHAR PosData4;
214 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
215
216
217 /* Int13 drive geometry data */
218
219 typedef struct _CM_INT13_DRIVE_PARAMETER
220 {
221   USHORT DriveSelect;
222   ULONG MaxCylinders;
223   USHORT SectorsPerTrack;
224   USHORT MaxHeads;
225   USHORT NumberDrives;
226 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
227
228
229 /* Extended drive geometry data */
230
231 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
232 {
233   ULONG BytesPerSector;
234   ULONG NumberOfCylinders;
235   ULONG SectorsPerTrack;
236   ULONG NumberOfHeads;
237 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
238
239
240 typedef struct
241 {
242    UCHAR Type;
243    UCHAR ShareDisposition;
244    USHORT Flags;
245    union
246      {
247         struct
248           {
249              PHYSICAL_ADDRESS Start;
250              ULONG Length;
251           } __attribute__((packed)) Port;
252         struct
253           {
254              ULONG Level;
255              ULONG Vector;
256              ULONG Affinity;
257           } __attribute__((packed))Interrupt;
258         struct
259           {
260              PHYSICAL_ADDRESS Start;
261              ULONG Length;
262           } __attribute__((packed))Memory;
263         struct
264           {
265              ULONG Channel;
266              ULONG Port;
267              ULONG Reserved1;
268           } __attribute__((packed))Dma;
269         struct
270           {
271              ULONG DataSize;
272              ULONG Reserved1;
273              ULONG Reserved2;
274           } __attribute__((packed))DeviceSpecificData;
275      } __attribute__((packed)) u;
276 } __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
277
278 typedef struct
279 {
280    USHORT Version;
281    USHORT Revision;
282    ULONG Count;
283    CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
284 } __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
285
286 typedef struct
287 {
288    INTERFACE_TYPE InterfaceType;
289    ULONG BusNumber;
290    CM_PARTIAL_RESOURCE_LIST PartialResourceList;
291 } __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
292
293 typedef struct
294 {
295    ULONG Count;
296    CM_FULL_RESOURCE_DESCRIPTOR List[1];
297 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
298
299
300 /*
301  * PURPOSE: IRP stack location
302  */
303
304 /*
305 typedef struct __attribute__((packed)) _IO_STACK_LOCATION
306 {
307   UCHAR MajorFunction;
308   UCHAR MinorFunction;
309   UCHAR Flags;
310   UCHAR Control;
311   
312   union
313     {
314       struct
315         {
316           PIO_SECURITY_CONTEXT SecurityContext;
317           ULONG Options;
318           USHORT FileAttributes;
319           USHORT ShareAccess;
320           ULONG EaLength;
321         } Create;
322       struct
323         {
324           ULONG Length;
325           ULONG Key;
326           LARGE_INTEGER ByteOffset;
327         } Read;
328       struct
329         {
330           ULONG Length;
331           ULONG Key;
332           LARGE_INTEGER ByteOffset;
333         } Write;
334       struct
335         {
336           ULONG OutputBufferLength;
337           ULONG InputBufferLength;
338           ULONG IoControlCode;
339           PVOID Type3InputBuffer;
340         } DeviceIoControl;
341       struct
342         {
343           ULONG OutputBufferLength;
344           ULONG InputBufferLength;
345           ULONG IoControlCode;
346           PVOID Type3InputBuffer;
347         } FileSystemControl;
348       struct
349         {
350           struct _VPB* Vpb;
351           struct _DEVICE_OBJECT* DeviceObject;
352         } MountVolume;
353       struct
354         {
355           struct _VPB* Vpb;
356           struct _DEVICE_OBJECT* DeviceObject;
357         } VerifyVolume;
358       struct
359         {
360           ULONG Length;
361           FILE_INFORMATION_CLASS FileInformationClass;
362         } QueryFile;
363       struct
364         {
365           ULONG Length;
366           FS_INFORMATION_CLASS FsInformationClass;
367         } QueryVolume;
368       struct
369         {
370           ULONG Length;
371           FS_INFORMATION_CLASS FsInformationClass;
372         } SetVolume;
373       struct
374         {
375           ULONG Length;
376           FILE_INFORMATION_CLASS FileInformationClass;
377           struct _FILE_OBJECT* FileObject;
378           union
379             {
380               struct
381                 {
382                   BOOLEAN ReplaceIfExists;
383                   BOOLEAN AdvanceOnly;
384                 } d;
385               ULONG ClusterCount;
386               HANDLE DeleteHandle;
387             } u;
388         } SetFile;
389       struct
390         {
391           ULONG Length;
392           PUNICODE_STRING FileName;
393           FILE_INFORMATION_CLASS FileInformationClass;
394           ULONG FileIndex;
395         } QueryDirectory;
396
397       // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
398       struct
399         {
400           DEVICE_RELATION_TYPE Type;
401         } QueryDeviceRelations;
402
403       // Parameters for IRP_MN_QUERY_INTERFACE
404       struct
405         {
406           CONST GUID *InterfaceType;
407           USHORT Size;
408           USHORT Version;
409           PINTERFACE Interface;
410           PVOID InterfaceSpecificData;
411         } QueryInterface;
412
413       // Parameters for IRP_MN_QUERY_CAPABILITIES
414       struct
415         {
416           PDEVICE_CAPABILITIES Capabilities;
417         } DeviceCapabilities;
418
419       // Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
420       struct
421         {
422       PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
423     } FilterResourceRequirements;
424
425       // Parameters for IRP_MN_QUERY_ID
426       struct
427         {
428           BUS_QUERY_ID_TYPE IdType;
429         } QueryId;
430
431       // Parameters for IRP_MN_QUERY_DEVICE_TEXT
432       struct
433         {
434           DEVICE_TEXT_TYPE DeviceTextType;
435           LCID LocaleId;
436         } QueryDeviceText;
437
438       // Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
439       struct
440         {
441           BOOLEAN InPath;
442           BOOLEAN Reserved[3];
443           DEVICE_USAGE_NOTIFICATION_TYPE Type;
444         } UsageNotification;
445
446       // Parameters for IRP_MN_WAIT_WAKE
447       struct
448         {
449           SYSTEM_POWER_STATE PowerState;
450         } WaitWake;
451
452       // Parameter for IRP_MN_POWER_SEQUENCE
453       struct
454         {
455           PPOWER_SEQUENCE PowerSequence;
456         } PowerSequence;
457
458       // Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
459       struct
460         {
461           ULONG SystemContext;
462           POWER_STATE_TYPE Type;
463           POWER_STATE State;
464           POWER_ACTION ShutdownType;
465         } Power;
466
467       // Parameters for IRP_MN_START_DEVICE
468       struct
469         {
470           PCM_RESOURCE_LIST AllocatedResources;
471           PCM_RESOURCE_LIST AllocatedResourcesTranslated;
472         } StartDevice;
473 */
474       /* Parameters for IRP_MN_SCSI_CLASS */
475 /*      struct
476         {
477           struct _SCSI_REQUEST_BLOCK *Srb;
478         } Scsi;
479
480           //byte range file locking
481           struct 
482         {
483       PLARGE_INTEGER Length;
484       ULONG Key;
485       LARGE_INTEGER ByteOffset;
486     } LockControl;
487 */
488       /* Paramters for other calls */
489 /*      struct
490         {
491           PVOID Argument1;
492           PVOID Argument2;
493           PVOID Argument3;
494           PVOID Argument4;
495         } Others;
496     } Parameters;
497   
498   struct _DEVICE_OBJECT* DeviceObject;
499   struct _FILE_OBJECT* FileObject;
500
501   PIO_COMPLETION_ROUTINE CompletionRoutine;
502   PVOID CompletionContext;
503
504 } __attribute__((packed)) IO_STACK_LOCATION, *PIO_STACK_LOCATION;*/
505
506 typedef struct _IO_STACK_LOCATION {
507   UCHAR  MajorFunction;
508   UCHAR  MinorFunction;
509   UCHAR  Flags;
510   UCHAR  Control;
511   union {
512     struct {
513       PIO_SECURITY_CONTEXT  SecurityContext;
514       ULONG  Options;
515       USHORT POINTER_ALIGNMENT  FileAttributes;
516       USHORT  ShareAccess;
517       ULONG POINTER_ALIGNMENT  EaLength;
518     } Create;
519     struct {
520       ULONG  Length;
521       ULONG POINTER_ALIGNMENT  Key;
522       LARGE_INTEGER  ByteOffset;
523     } Read;
524     struct {
525       ULONG  Length;
526       ULONG POINTER_ALIGNMENT  Key;
527       LARGE_INTEGER  ByteOffset;
528     } Write;
529     struct {
530       ULONG  Length;
531       FILE_INFORMATION_CLASS POINTER_ALIGNMENT  FileInformationClass;
532     } QueryFile;
533     struct {
534       ULONG  Length;
535       FILE_INFORMATION_CLASS POINTER_ALIGNMENT  FileInformationClass;
536       struct _FILE_OBJECT*  FileObject;
537       union {
538         struct {
539           BOOLEAN  ReplaceIfExists;
540           BOOLEAN  AdvanceOnly;
541         };
542         ULONG  ClusterCount;
543         HANDLE  DeleteHandle;
544       };
545     } SetFile;
546     struct {
547       ULONG  Length;
548       FS_INFORMATION_CLASS POINTER_ALIGNMENT  FsInformationClass;
549     } QueryVolume;
550     struct {
551       ULONG  OutputBufferLength;
552       ULONG POINTER_ALIGNMENT  InputBufferLength;
553       ULONG POINTER_ALIGNMENT  IoControlCode;
554       PVOID  Type3InputBuffer;
555     } DeviceIoControl;
556     struct {
557       SECURITY_INFORMATION  SecurityInformation;
558       ULONG POINTER_ALIGNMENT  Length;
559     } QuerySecurity;
560     struct {
561       SECURITY_INFORMATION  SecurityInformation;
562       PSECURITY_DESCRIPTOR  SecurityDescriptor;
563     } SetSecurity;
564     struct {
565       struct _VPB*  Vpb;
566       struct _DEVICE_OBJECT*  DeviceObject;
567     } MountVolume;
568     struct {
569       struct _VPB*  Vpb;
570       struct _DEVICE_OBJECT*  DeviceObject;
571     } VerifyVolume;
572     struct {
573       struct _SCSI_REQUEST_BLOCK  *Srb;
574     } Scsi;
575     struct {
576       DEVICE_RELATION_TYPE  Type;
577     } QueryDeviceRelations;
578     struct {
579       CONST GUID  *InterfaceType;
580       USHORT  Size;
581       USHORT  Version;
582       PINTERFACE  Interface;
583       PVOID  InterfaceSpecificData;
584     } QueryInterface;
585     struct {
586       PDEVICE_CAPABILITIES  Capabilities;
587     } DeviceCapabilities;
588     struct {
589       PIO_RESOURCE_REQUIREMENTS_LIST  IoResourceRequirementList;
590     } FilterResourceRequirements;
591     struct {
592       ULONG  WhichSpace;
593       PVOID  Buffer;
594       ULONG  Offset;
595       ULONG POINTER_ALIGNMENT  Length;
596     } ReadWriteConfig;
597     struct {
598       BOOLEAN  Lock;
599     } SetLock;
600     struct {
601       BUS_QUERY_ID_TYPE  IdType;
602     } QueryId;
603     struct {
604       DEVICE_TEXT_TYPE  DeviceTextType;
605       LCID POINTER_ALIGNMENT  LocaleId;
606     } QueryDeviceText;
607     struct {
608       BOOLEAN  InPath;
609       BOOLEAN  Reserved[3];
610       DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT  Type;
611     } UsageNotification;
612     struct {
613       SYSTEM_POWER_STATE  PowerState;
614     } WaitWake;
615     struct {
616       PPOWER_SEQUENCE  PowerSequence;
617     } PowerSequence;
618     struct {
619       ULONG  SystemContext;
620       POWER_STATE_TYPE POINTER_ALIGNMENT  Type;
621       POWER_STATE POINTER_ALIGNMENT  State;
622       POWER_ACTION POINTER_ALIGNMENT  ShutdownType;
623     } Power;
624     struct {
625       PCM_RESOURCE_LIST  AllocatedResources;
626       PCM_RESOURCE_LIST  AllocatedResourcesTranslated;
627     } StartDevice;
628     struct {
629       ULONG_PTR  ProviderId;
630       PVOID  DataPath;
631       ULONG  BufferSize;
632       PVOID  Buffer;
633     } WMI;
634     struct {
635       PVOID  Argument1;
636       PVOID  Argument2;
637       PVOID  Argument3;
638       PVOID  Argument4;
639     } Others;
640   } Parameters;
641   struct _DEVICE_OBJECT*  DeviceObject;
642   struct _FILE_OBJECT*  FileObject;
643   PIO_COMPLETION_ROUTINE  CompletionRoutine;
644   PVOID  Context;
645 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
646
647
648 // AG: The commented lines in this structure are due to PMAILSLOT_CREATE_PARAMETERS
649 // and PNAMED_PIPE_CREATE_PARAMETERS and PFILE_GET_QUOTA_INFORMATION not being
650 // defined.
651
652 typedef struct _EXTENDED_IO_STACK_LOCATION {
653
654     /* Included for padding */
655     UCHAR MajorFunction;
656     UCHAR MinorFunction;
657     UCHAR Flags;
658     UCHAR Control;
659
660     union {
661
662 //       struct {
663 //          PIO_SECURITY_CONTEXT              SecurityContext;
664 //          ULONG                             Options;
665 //          USHORT                            Reserved;
666 //          USHORT                            ShareAccess;
667 //          PMAILSLOT_CREATE_PARAMETERS       Parameters;
668 //       } CreateMailslot;
669
670 //        struct {
671 //            PIO_SECURITY_CONTEXT            SecurityContext;
672 //            ULONG                           Options;
673 //            USHORT                          Reserved;
674 //            USHORT                          ShareAccess;
675 //            PNAMED_PIPE_CREATE_PARAMETERS   Parameters;
676 //        } CreatePipe;
677
678         struct {
679             ULONG                           OutputBufferLength;
680             ULONG                           InputBufferLength;
681             ULONG                           FsControlCode;
682             PVOID                           Type3InputBuffer;
683         } FileSystemControl;
684
685         struct {
686             PLARGE_INTEGER                  Length;
687             ULONG                           Key;
688             LARGE_INTEGER                   ByteOffset;
689         } LockControl;
690
691         struct {
692             ULONG                           Length;
693             ULONG                           CompletionFilter;
694         } NotifyDirectory;
695
696         struct {
697             ULONG                           Length;
698             PUNICODE_STRING                 FileName;
699             FILE_INFORMATION_CLASS          FileInformationClass;
700             ULONG                           FileIndex;
701         } QueryDirectory;
702
703         struct {
704             ULONG                           Length;
705             PVOID                           EaList;
706             ULONG                           EaListLength;
707             ULONG                           EaIndex;
708         } QueryEa;
709
710 //        struct {
711 //            ULONG                           Length;
712 //            PSID                            StartSid;
713 //            PFILE_GET_QUOTA_INFORMATION     SidList;
714 //            ULONG                           SidListLength;
715 //        } QueryQuota;
716
717         struct {
718             ULONG                           Length;
719         } SetEa;
720
721         struct {
722             ULONG                           Length;
723         } SetQuota;
724
725         struct {
726             ULONG                           Length;
727             FS_INFORMATION_CLASS            FsInformationClass;
728         } SetVolume;
729
730     } Parameters;
731     struct _DEVICE_OBJECT*  DeviceObject;
732     struct _FILE_OBJECT*  FileObject;
733     PIO_COMPLETION_ROUTINE  CompletionRoutine;
734     PVOID  Context;
735
736 } EXTENDED_IO_STACK_LOCATION, *PEXTENDED_IO_STACK_LOCATION;
737
738
739
740 typedef struct _IO_STATUS_BLOCK
741 {
742   NTSTATUS Status;
743   ULONG Information;
744 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
745
746
747 /*
748  * Driver entry point declaration
749  */
750 typedef NTSTATUS STDCALL_FUNC
751 (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
752                       PUNICODE_STRING RegistryPath);
753
754 /*
755  * Driver cancel declaration
756  */
757 typedef NTSTATUS STDCALL_FUNC
758 (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
759                   struct _IRP* RegistryPath);
760
761
762 typedef struct _SECTION_OBJECT_POINTERS
763 {
764    PVOID DataSectionObject;
765    PVOID SharedCacheMap;
766    PVOID ImageSectionObject;
767 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
768
769 typedef struct _IO_COMPLETION_CONTEXT
770 {
771    PVOID Port;
772    ULONG Key;
773 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
774
775 #define FO_FILE_OPEN                    0x00000001
776 #define FO_SYNCHRONOUS_IO               0x00000002
777 #define FO_ALERTABLE_IO                 0x00000004
778 #define FO_NO_INTERMEDIATE_BUFFERING    0x00000008
779 #define FO_WRITE_THROUGH                0x00000010
780 #define FO_SEQUENTIAL_ONLY              0x00000020
781 #define FO_CACHE_SUPPORTED              0x00000040
782 #define FO_NAMED_PIPE                   0x00000080
783 #define FO_STREAM_FILE                  0x00000100
784 #define FO_MAILSLOT                     0x00000200
785 #define FO_GENERATE_AUDIT_ON_CLOSE      0x00000400
786 #define FO_DIRECT_DEVICE_OPEN           0x00000800
787 #define FO_FILE_MODIFIED                0x00001000
788 #define FO_FILE_SIZE_CHANGED            0x00002000
789 #define FO_CLEANUP_COMPLETE             0x00004000
790 #define FO_TEMPORARY_FILE               0x00008000
791 #define FO_DELETE_ON_CLOSE              0x00010000
792 #define FO_OPENED_CASE_SENSITIVE        0x00020000
793 #define FO_HANDLE_CREATED               0x00040000
794 #define FO_FILE_FAST_IO_READ            0x00080000
795
796 /*
797  * ReactOS specific flags
798  */
799 #define FO_DIRECT_CACHE_READ            0x72000001
800 #define FO_DIRECT_CACHE_WRITE           0x72000002
801 #define FO_DIRECT_CACHE_PAGING_READ     0x72000004
802 #define FO_DIRECT_CACHE_PAGING_WRITE    0x72000008
803 #define FO_FCB_IS_VALID                 0x72000010
804
805 typedef struct _FILE_OBJECT
806 {
807    CSHORT Type;
808    CSHORT Size;
809    struct _DEVICE_OBJECT* DeviceObject;
810    struct _VPB* Vpb;
811    PVOID FsContext;
812    PVOID FsContext2;
813    PSECTION_OBJECT_POINTERS SectionObjectPointer;
814    PVOID PrivateCacheMap;
815    NTSTATUS FinalStatus;
816    struct _FILE_OBJECT* RelatedFileObject;
817    BOOLEAN LockOperation;
818    BOOLEAN DeletePending;
819    BOOLEAN ReadAccess;
820    BOOLEAN WriteAccess;
821    BOOLEAN DeleteAccess;
822    BOOLEAN SharedRead;
823    BOOLEAN SharedWrite;
824    BOOLEAN SharedDelete;
825    ULONG Flags;
826    UNICODE_STRING FileName;
827    LARGE_INTEGER CurrentByteOffset;
828    ULONG Waiters;
829    ULONG Busy;
830    PVOID LastLock;
831    KEVENT Lock;
832    KEVENT Event;
833    PIO_COMPLETION_CONTEXT CompletionContext;
834 } FILE_OBJECT, *PFILE_OBJECT;
835
836
837 typedef struct _IRP
838 {
839    CSHORT Type;
840    USHORT Size;
841    PMDL MdlAddress;
842    ULONG Flags;
843    union
844      {
845         struct _IRP* MasterIrp;
846         LONG IrpCount;
847         PVOID SystemBuffer;     
848      } AssociatedIrp;
849    LIST_ENTRY ThreadListEntry;
850    IO_STATUS_BLOCK IoStatus;
851    KPROCESSOR_MODE RequestorMode;
852    BOOLEAN PendingReturned;
853    CHAR StackCount;
854    CHAR CurrentLocation;
855    BOOLEAN Cancel;
856    KIRQL CancelIrql;
857    CCHAR ApcEnvironment;// CCHAR or PVOID?
858    UCHAR AllocationFlags;//UCHAR or ULONG?
859    PIO_STATUS_BLOCK UserIosb;
860    PKEVENT UserEvent;
861    union
862      {
863         struct
864           {
865              PIO_APC_ROUTINE UserApcRoutine;
866              PVOID UserApcContext;
867           } AsynchronousParameters;
868         LARGE_INTEGER AllocationSize;
869      } Overlay;
870    PDRIVER_CANCEL CancelRoutine;
871    PVOID UserBuffer;
872    union
873      {
874         struct
875           {
876              union {
877                KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
878                PVOID DriverContext[4];
879              };
880              struct _ETHREAD* Thread;
881              PCHAR AuxiliaryBuffer;
882              LIST_ENTRY ListEntry;
883              struct _IO_STACK_LOCATION* CurrentStackLocation;
884              PFILE_OBJECT OriginalFileObject;
885           } Overlay;
886         KAPC Apc;
887         ULONG CompletionKey;
888      } Tail;
889    IO_STACK_LOCATION Stack[1];
890 } IRP, *PIRP;
891
892 #define VPB_MOUNTED                     0x00000001
893 #define VPB_LOCKED                      0x00000002
894 #define VPB_PERSISTENT                  0x00000004
895 #define VPB_REMOVE_PENDING              0x00000008
896
897 typedef struct _VPB
898 {
899    CSHORT Type;
900    CSHORT Size;
901    USHORT Flags;
902    USHORT VolumeLabelLength;
903    struct _DEVICE_OBJECT* DeviceObject;
904    struct _DEVICE_OBJECT* RealDevice;
905    ULONG SerialNumber;
906    ULONG ReferenceCount;
907    WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
908 } VPB, *PVPB;
909
910
911 typedef struct _DEVICE_OBJECT
912 {
913    CSHORT Type;
914    CSHORT Size;
915    LONG ReferenceCount;
916    struct _DRIVER_OBJECT* DriverObject;
917    struct _DEVICE_OBJECT* NextDevice;
918    struct _DEVICE_OBJECT* AttachedDevice;
919    struct _IRP* CurrentIrp;
920    PIO_TIMER Timer;
921    ULONG Flags;
922    ULONG Characteristics;
923    PVPB Vpb;
924    PVOID DeviceExtension;
925    DEVICE_TYPE DeviceType;
926    CCHAR StackSize;
927    union
928      {
929         LIST_ENTRY ListHead;
930         WAIT_CONTEXT_BLOCK Wcb;
931      } Queue;
932    ULONG AlignmentRequirement;
933    KDEVICE_QUEUE DeviceQueue;
934    KDPC Dpc;
935    ULONG ActiveThreadCount;
936    PSECURITY_DESCRIPTOR SecurityDescriptor;
937    KEVENT DeviceLock;
938    USHORT SectorSize;
939    USHORT Spare1;
940    struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
941    PVOID Reserved;
942 } DEVICE_OBJECT, *PDEVICE_OBJECT;
943
944
945 /*
946  * Fast i/o routine type declaration
947  */
948 //typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
949 //FIXME : this type is ok for read and write, but not for all routines
950 typedef BOOLEAN STDCALL_FUNC
951 (*PFAST_IO_ROUTINE)(IN struct _FILE_OBJECT *FileObject,
952                     IN PLARGE_INTEGER FileOffset,
953                     IN ULONG Length,
954                     IN BOOLEAN Wait,
955                     IN ULONG LockKey,
956                     OUT PVOID Buffer,
957                     OUT PIO_STATUS_BLOCK IoStatus,
958                     IN struct _DEVICE_OBJECT *DeviceObject);
959
960 typedef struct _FAST_IO_DISPATCH {
961    ULONG SizeOfFastIoDispatch;
962    PFAST_IO_ROUTINE FastIoCheckIfPossible;
963    PFAST_IO_ROUTINE FastIoRead;
964    PFAST_IO_ROUTINE FastIoWrite;
965    PFAST_IO_ROUTINE FastIoQueryBasicInfo;
966    PFAST_IO_ROUTINE FastIoQueryStandardInfo;
967    PFAST_IO_ROUTINE FastIoLock;
968    PFAST_IO_ROUTINE FastIoUnlockSingle;
969    PFAST_IO_ROUTINE FastIoUnlockAll;
970    PFAST_IO_ROUTINE FastIoUnlockAllByKey;
971    PFAST_IO_ROUTINE FastIoDeviceControl;
972    PFAST_IO_ROUTINE AcquireFileForNtCreateSection;
973    PFAST_IO_ROUTINE ReleaseFileForNtCreateSection;
974    PFAST_IO_ROUTINE FastIoDetachDevice;
975    PFAST_IO_ROUTINE FastIoQueryNetworkOpenInfo;
976    PFAST_IO_ROUTINE AcquireForModWrite;
977    PFAST_IO_ROUTINE MdlRead;
978    PFAST_IO_ROUTINE MdlReadComplete;
979    PFAST_IO_ROUTINE PrepareMdlWrite;
980    PFAST_IO_ROUTINE MdlWriteComplete;
981    PFAST_IO_ROUTINE FastIoReadCompressed;
982    PFAST_IO_ROUTINE FastIoWriteCompressed;
983    PFAST_IO_ROUTINE MdlReadCompleteCompressed;
984    PFAST_IO_ROUTINE MdlWriteCompleteCompressed;
985    PFAST_IO_ROUTINE FastIoQueryOpen;
986    PFAST_IO_ROUTINE ReleaseForModWrite;
987    PFAST_IO_ROUTINE AcquireForCcFlush;
988    PFAST_IO_ROUTINE ReleaseForCcFlush;
989 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
990
991 /*
992  * Dispatch routine type declaration
993  */
994 typedef NTSTATUS STDCALL_FUNC
995 (*PDRIVER_DISPATCH)(IN struct _DEVICE_OBJECT *DeviceObject,
996                    IN struct _IRP *Irp);
997
998 /*
999  * StartIo routine type declaration
1000  */
1001 typedef VOID STDCALL_FUNC
1002 (*PDRIVER_STARTIO)(IN PDEVICE_OBJECT DeviceObject,
1003                    IN PIRP Irp);
1004
1005 /*
1006  * Unload routine type declaration
1007  */
1008 typedef VOID STDCALL_FUNC
1009 (*PDRIVER_UNLOAD)(IN struct _DRIVER_OBJECT *DriverObject);
1010
1011 /*
1012  * AddDevice routine type declaration
1013  */
1014 typedef NTSTATUS STDCALL_FUNC
1015 (*PDRIVER_ADD_DEVICE)(IN struct _DRIVER_OBJECT *DriverObject,
1016                       IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
1017
1018
1019 typedef struct _DRIVER_EXTENSION
1020 {
1021    struct _DRIVER_OBJECT* DriverObject;
1022    PDRIVER_ADD_DEVICE AddDevice;
1023    ULONG Count;
1024    UNICODE_STRING ServiceKeyName;
1025 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
1026
1027 #if 0
1028 typedef
1029 struct _FAST_IO_DISPATCH_TABLE
1030 {
1031         ULONG                   Count;
1032         PFAST_IO_DISPATCH       Dispatch;
1033
1034 } FAST_IO_DISPATCH_TABLE, * PFAST_IO_DISPATCH_TABLE;
1035 #endif
1036
1037 typedef struct _DRIVER_OBJECT
1038 {
1039    CSHORT Type;
1040    CSHORT Size;
1041    PDEVICE_OBJECT DeviceObject;
1042    ULONG Flags;
1043    PVOID DriverStart;
1044    ULONG DriverSize;
1045    PVOID DriverSection;
1046    PDRIVER_EXTENSION DriverExtension;
1047    UNICODE_STRING DriverName;
1048    PUNICODE_STRING HardwareDatabase;
1049 #if 0
1050    PFAST_IO_DISPATCH_TABLE FastIoDispatch;
1051 #else
1052    PFAST_IO_DISPATCH FastIoDispatch;
1053 #endif
1054    PDRIVER_INITIALIZE DriverInit;
1055    PDRIVER_STARTIO DriverStartIo;
1056    PDRIVER_UNLOAD DriverUnload;
1057    PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
1058 } DRIVER_OBJECT, *PDRIVER_OBJECT;
1059
1060
1061 typedef struct _CONFIGURATION_INFORMATION
1062 {
1063    ULONG DiskCount;
1064    ULONG FloppyCount;
1065    ULONG CdRomCount;
1066    ULONG TapeCount;
1067    ULONG ScsiPortCount;
1068    ULONG SerialCount;
1069    ULONG ParallelCount;
1070    BOOLEAN AtDiskPrimaryAddressClaimed;
1071    BOOLEAN AtDiskSecondaryAddressClaimed;
1072 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
1073
1074 typedef VOID STDCALL_FUNC
1075 (*PIO_DPC_ROUTINE)(PKDPC Dpc,
1076                    PDEVICE_OBJECT DeviceObject,
1077                    PIRP Irp,
1078                    PVOID Context);
1079
1080 typedef VOID STDCALL_FUNC
1081 (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
1082                      PVOID Context);
1083
1084 typedef struct _IO_WORKITEM *PIO_WORKITEM;
1085 typedef VOID (*PIO_WORKITEM_ROUTINE)(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context);
1086
1087 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
1088 typedef struct _PARTITION_INFORMATION
1089 {
1090    LARGE_INTEGER StartingOffset;
1091    LARGE_INTEGER PartitionLength;
1092    ULONG HiddenSectors;
1093    ULONG PartitionNumber;
1094    UCHAR PartitionType;
1095    BOOLEAN BootIndicator;
1096    BOOLEAN RecognizedPartition;
1097    BOOLEAN RewritePartition;
1098 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
1099 #endif
1100
1101 typedef struct _DRIVER_LAYOUT_INFORMATION
1102 {
1103    ULONG PartitionCount;
1104    ULONG Signature;
1105    PARTITION_INFORMATION PartitionEntry[1];
1106 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
1107
1108
1109 typedef IO_ALLOCATION_ACTION STDCALL_FUNC
1110 (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
1111                    PIRP Irp,
1112                    PVOID MapRegisterBase,
1113                    PVOID Context);
1114 #if (_WIN32_WINNT >= 0x0400)
1115 typedef VOID STDCALL_FUNC
1116 (*PFSDNOTIFICATIONPROC)(IN PDEVICE_OBJECT PtrTargetFileSystemDeviceObject,
1117                         IN BOOLEAN DriverActive);
1118 #endif // (_WIN32_WINNT >= 0x0400)
1119
1120
1121 typedef struct _IO_PIPE_CREATE_BUFFER
1122 {
1123    BOOLEAN WriteModeMessage;
1124    BOOLEAN ReadModeMessage;
1125    BOOLEAN NonBlocking;
1126    ULONG MaxInstances;
1127    ULONG InBufferSize;
1128    ULONG OutBufferSize;
1129    LARGE_INTEGER TimeOut;
1130 } IO_PIPE_CREATE_BUFFER, *PIO_PIPE_CREATE_BUFFER;
1131
1132 typedef struct _IO_MAILSLOT_CREATE_BUFFER
1133 {
1134    ULONG Param; /* ?? */
1135    ULONG MaxMessageSize;
1136    LARGE_INTEGER TimeOut;
1137 } IO_MAILSLOT_CREATE_BUFFER, *PIO_MAILSLOT_CREATE_BUFFER;
1138
1139 #endif /* __INCLUDE_DDK_IOTYPES_H */