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