5 #ifndef __INCLUDE_DDK_IOTYPES_H
6 #define __INCLUDE_DDK_IOTYPES_H
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;
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;
26 * These are referenced before they can be fully defined
28 struct _DRIVER_OBJECT;
30 struct _DEVICE_OBJECT;
32 struct _IO_STATUS_BLOCK;
33 struct _SCSI_REQUEST_BLOCK;
35 /* SIMPLE TYPES *************************************************************/
44 typedef enum _CREATE_FILE_TYPE
47 CreateFileTypeNamedPipe,
48 CreateFileTypeMailslot
52 typedef struct _SHARE_ACCESS
61 } SHARE_ACCESS, *PSHARE_ACCESS;
63 /* FUNCTION TYPES ************************************************************/
65 typedef VOID STDCALL_FUNC
66 (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
70 typedef NTSTATUS STDCALL_FUNC
71 (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
72 PUNICODE_STRING Pathname,
73 INTERFACE_TYPE BusType,
75 PKEY_VALUE_FULL_INFORMATION* BI,
76 CONFIGURATION_TYPE ControllerType,
77 ULONG ControllerNumber,
78 PKEY_VALUE_FULL_INFORMATION* CI,
79 CONFIGURATION_TYPE PeripheralType,
80 ULONG PeripheralNumber,
81 PKEY_VALUE_FULL_INFORMATION* PI);
83 typedef NTSTATUS STDCALL_FUNC
84 (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
88 typedef VOID STDCALL_FUNC
89 (*PIO_APC_ROUTINE)(PVOID ApcContext,
90 struct _IO_STATUS_BLOCK* IoStatusBlock,
94 /* STRUCTURE TYPES ***********************************************************/
96 typedef struct _ADAPTER_OBJECT ADAPTER_OBJECT, *PADAPTER_OBJECT;
99 * PURPOSE: Special timer associated with each device
100 * NOTES: This is a guess
102 typedef struct _IO_TIMER
106 } IO_TIMER, *PIO_TIMER;
108 typedef struct _IO_SECURITY_CONTEXT
110 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
111 PACCESS_STATE AccessState;
112 ACCESS_MASK DesiredAccess;
113 ULONG FullCreateOptions;
114 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
117 typedef struct _IO_RESOURCE_DESCRIPTOR
121 UCHAR ShareDisposition;
124 * Reserved for system use
131 * Reserved for system use
141 PHYSICAL_ADDRESS MinimumAddress;
142 PHYSICAL_ADDRESS MaximumAddress;
148 PHYSICAL_ADDRESS MinimumAddress;
149 PHYSICAL_ADDRESS MaximumAddress;
158 ULONG MinimumChannel;
159 ULONG MaximumChannel;
162 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
164 // IO_RESOURCE_DESCRIPTOR Options
165 #define IO_RESOURCE_REQUIRED 0x00
166 #define IO_RESOURCE_PREFERRED 0x01
167 #define IO_RESOURCE_DEFAULT 0x02
168 #define IO_RESOURCE_ALTERNATIVE 0x08
170 typedef struct _IO_RESOURCE_LIST
175 IO_RESOURCE_DESCRIPTOR Descriptors[1];
176 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
178 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST
186 * System defined enum for the bus
188 INTERFACE_TYPE InterfaceType;
193 ULONG AlternativeLists;
194 IO_RESOURCE_LIST List[1];
195 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
200 UCHAR ShareDisposition;
206 PHYSICAL_ADDRESS Start;
208 } __attribute__((packed)) Port;
214 } __attribute__((packed))Interrupt;
217 PHYSICAL_ADDRESS Start;
219 } __attribute__((packed))Memory;
225 } __attribute__((packed))Dma;
231 } __attribute__((packed))DeviceSpecificData;
232 } __attribute__((packed)) u;
233 } __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
240 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
241 } __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
245 INTERFACE_TYPE InterfaceType;
247 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
248 } __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR;
253 CM_FULL_RESOURCE_DESCRIPTOR List[1];
254 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
258 * PURPOSE: IRP stack location
260 typedef struct __attribute__((packed)) _IO_STACK_LOCATION
271 PIO_SECURITY_CONTEXT SecurityContext;
273 USHORT FileAttributes;
281 LARGE_INTEGER ByteOffset;
287 LARGE_INTEGER ByteOffset;
291 ULONG OutputBufferLength;
292 ULONG InputBufferLength;
294 PVOID Type3InputBuffer;
298 ULONG OutputBufferLength;
299 ULONG InputBufferLength;
301 PVOID Type3InputBuffer;
306 struct _DEVICE_OBJECT* DeviceObject;
311 struct _DEVICE_OBJECT* DeviceObject;
316 FILE_INFORMATION_CLASS FileInformationClass;
321 FS_INFORMATION_CLASS FsInformationClass;
326 FS_INFORMATION_CLASS FsInformationClass;
331 FILE_INFORMATION_CLASS FileInformationClass;
332 struct _FILE_OBJECT* FileObject;
337 BOOLEAN ReplaceIfExists;
347 PUNICODE_STRING FileName;
348 FILE_INFORMATION_CLASS FileInformationClass;
352 // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
355 DEVICE_RELATION_TYPE Type;
356 } QueryDeviceRelations;
358 // Parameters for IRP_MN_QUERY_INTERFACE
361 CONST GUID *InterfaceType;
364 PINTERFACE Interface;
365 PVOID InterfaceSpecificData;
368 // Parameters for IRP_MN_QUERY_CAPABILITIES
371 PDEVICE_CAPABILITIES Capabilities;
372 } DeviceCapabilities;
374 // Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
377 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
378 } FilterResourceRequirements;
380 // Parameters for IRP_MN_QUERY_ID
383 BUS_QUERY_ID_TYPE IdType;
386 // Parameters for IRP_MN_QUERY_DEVICE_TEXT
389 DEVICE_TEXT_TYPE DeviceTextType;
393 // Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
398 DEVICE_USAGE_NOTIFICATION_TYPE Type;
401 // Parameters for IRP_MN_WAIT_WAKE
404 SYSTEM_POWER_STATE PowerState;
407 // Parameter for IRP_MN_POWER_SEQUENCE
410 PPOWER_SEQUENCE PowerSequence;
413 // Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
417 POWER_STATE_TYPE Type;
419 POWER_ACTION ShutdownType;
422 // Parameters for IRP_MN_START_DEVICE
425 PCM_RESOURCE_LIST AllocatedResources;
426 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
429 /* Parameters for IRP_MN_SCSI_CLASS */
432 struct _SCSI_REQUEST_BLOCK *Srb;
435 //byte range file locking
438 PLARGE_INTEGER Length;
440 LARGE_INTEGER ByteOffset;
443 /* Paramters for other calls */
453 struct _DEVICE_OBJECT* DeviceObject;
454 struct _FILE_OBJECT* FileObject;
456 PIO_COMPLETION_ROUTINE CompletionRoutine;
457 PVOID CompletionContext;
459 } __attribute__((packed)) IO_STACK_LOCATION, *PIO_STACK_LOCATION;
462 typedef struct _IO_STATUS_BLOCK
466 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
469 typedef struct _IO_PIPE_CREATE_BUFFER
471 BOOLEAN WriteModeMessage;
472 BOOLEAN ReadModeMessage;
477 LARGE_INTEGER TimeOut;
478 } IO_PIPE_CREATE_BUFFER, *PIO_PIPE_CREATE_BUFFER;
481 typedef struct _IO_MAILSLOT_CREATE_BUFFER
483 ULONG Param; /* ?? */
484 ULONG MaxMessageSize;
485 LARGE_INTEGER TimeOut;
486 } IO_MAILSLOT_CREATE_BUFFER, *PIO_MAILSLOT_CREATE_BUFFER;
490 * Driver entry point declaration
495 #else /* !LIBCAPTIVE */
497 #endif /* !LIBCAPTIVE */
498 (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
499 PUNICODE_STRING RegistryPath);
502 * Driver cancel declaration
504 typedef NTSTATUS STDCALL_FUNC
505 (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
506 struct _IRP* RegistryPath);
509 typedef struct _SECTION_OBJECT_POINTERS
511 PVOID DataSectionObject;
512 PVOID SharedCacheMap;
513 PVOID ImageSectionObject;
514 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
516 typedef struct _IO_COMPLETION_CONTEXT
520 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
522 #define FO_FILE_OPEN 0x00000001
523 #define FO_SYNCHRONOUS_IO 0x00000002
524 #define FO_ALERTABLE_IO 0x00000004
525 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
526 #define FO_WRITE_THROUGH 0x00000010
527 #define FO_SEQUENTIAL_ONLY 0x00000020
528 #define FO_CACHE_SUPPORTED 0x00000040
529 #define FO_NAMED_PIPE 0x00000080
530 #define FO_STREAM_FILE 0x00000100
531 #define FO_MAILSLOT 0x00000200
532 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
533 #define FO_DIRECT_DEVICE_OPEN 0x00000800
534 #define FO_FILE_MODIFIED 0x00001000
535 #define FO_FILE_SIZE_CHANGED 0x00002000
536 #define FO_CLEANUP_COMPLETE 0x00004000
537 #define FO_TEMPORARY_FILE 0x00008000
538 #define FO_DELETE_ON_CLOSE 0x00010000
539 #define FO_OPENED_CASE_SENSITIVE 0x00020000
540 #define FO_HANDLE_CREATED 0x00040000
541 #define FO_FILE_FAST_IO_READ 0x00080000
544 * ReactOS specific flags
546 #define FO_DIRECT_CACHE_READ 0x72000001
547 #define FO_DIRECT_CACHE_WRITE 0x72000002
548 #define FO_DIRECT_CACHE_PAGING_READ 0x72000004
549 #define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008
550 #define FO_FCB_IS_VALID 0x72000010
552 typedef struct _FILE_OBJECT
556 struct _DEVICE_OBJECT* DeviceObject;
560 PSECTION_OBJECT_POINTERS SectionObjectPointers;
561 PVOID PrivateCacheMap;
562 NTSTATUS FinalStatus;
563 struct _FILE_OBJECT* RelatedFileObject;
564 BOOLEAN LockOperation;
565 BOOLEAN DeletePending;
568 BOOLEAN DeleteAccess;
571 BOOLEAN SharedDelete;
573 UNICODE_STRING FileName;
574 LARGE_INTEGER CurrentByteOffset;
580 PIO_COMPLETION_CONTEXT CompletionContext;
581 } FILE_OBJECT, *PFILE_OBJECT;
592 struct _IRP* MasterIrp;
596 LIST_ENTRY ThreadListEntry;
597 IO_STATUS_BLOCK IoStatus;
598 KPROCESSOR_MODE RequestorMode;
599 BOOLEAN PendingReturned;
601 CHAR CurrentLocation;
604 CCHAR ApcEnvironment;
605 UCHAR AllocationFlags;
606 PIO_STATUS_BLOCK UserIosb;
612 PIO_APC_ROUTINE UserApcRoutine;
613 PVOID UserApcContext;
614 } AsynchronousParameters;
615 LARGE_INTEGER AllocationSize;
617 PDRIVER_CANCEL CancelRoutine;
624 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
625 PVOID DriverContext[4];
627 struct _ETHREAD* Thread;
628 PCHAR AuxiliaryBuffer;
629 LIST_ENTRY ListEntry;
630 struct _IO_STACK_LOCATION* CurrentStackLocation;
631 PFILE_OBJECT OriginalFileObject;
636 IO_STACK_LOCATION Stack[1];
639 #define VPB_MOUNTED 0x00000001
640 #define VPB_LOCKED 0x00000002
641 #define VPB_PERSISTENT 0x00000004
642 #define VPB_REMOVE_PENDING 0x00000008
649 USHORT VolumeLabelLength;
650 struct _DEVICE_OBJECT* DeviceObject;
651 struct _DEVICE_OBJECT* RealDevice;
653 ULONG ReferenceCount;
654 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
660 __attribute__ ((__aligned__(16)))
662 __attribute__ ((__aligned__(8)))
664 #error "Missing _WIN64 or _WIN32"
671 struct _DRIVER_OBJECT* DriverObject;
672 struct _DEVICE_OBJECT* NextDevice;
673 struct _DEVICE_OBJECT* AttachedDevice;
674 struct _IRP* CurrentIrp;
677 ULONG Characteristics;
679 PVOID DeviceExtension;
680 DEVICE_TYPE DeviceType;
685 WAIT_CONTEXT_BLOCK Wcb;
687 ULONG AlignmentRequirement;
688 KDEVICE_QUEUE DeviceQueue;
690 ULONG ActiveThreadCount;
691 PSECURITY_DESCRIPTOR SecurityDescriptor;
695 struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
697 } DEVICE_OBJECT, *PDEVICE_OBJECT;
701 * Fast i/o routine type declaration
703 //typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
704 //FIXME : this type is ok for read and write, but not for all routines
708 #else /* !LIBCAPTIVE */
710 #endif /* !LIBCAPTIVE */
711 (*PFAST_IO_ROUTINE)(IN struct _FILE_OBJECT *FileObject,
712 IN PLARGE_INTEGER FileOffset,
717 OUT PIO_STATUS_BLOCK IoStatus,
718 IN struct _DEVICE_OBJECT *DeviceObject);
720 typedef struct _FAST_IO_DISPATCH {
721 ULONG SizeOfFastIoDispatch;
722 PFAST_IO_ROUTINE FastIoCheckIfPossible;
723 PFAST_IO_ROUTINE FastIoRead;
724 PFAST_IO_ROUTINE FastIoWrite;
725 PFAST_IO_ROUTINE FastIoQueryBasicInfo;
726 PFAST_IO_ROUTINE FastIoQueryStandardInfo;
727 PFAST_IO_ROUTINE FastIoLock;
728 PFAST_IO_ROUTINE FastIoUnlockSingle;
729 PFAST_IO_ROUTINE FastIoUnlockAll;
730 PFAST_IO_ROUTINE FastIoUnlockAllByKey;
731 PFAST_IO_ROUTINE FastIoDeviceControl;
732 PFAST_IO_ROUTINE AcquireFileForNtCreateSection;
733 PFAST_IO_ROUTINE ReleaseFileForNtCreateSection;
734 PFAST_IO_ROUTINE FastIoDetachDevice;
735 PFAST_IO_ROUTINE FastIoQueryNetworkOpenInfo;
736 PFAST_IO_ROUTINE AcquireForModWrite;
737 PFAST_IO_ROUTINE MdlRead;
738 PFAST_IO_ROUTINE MdlReadComplete;
739 PFAST_IO_ROUTINE PrepareMdlWrite;
740 PFAST_IO_ROUTINE MdlWriteComplete;
741 PFAST_IO_ROUTINE FastIoReadCompressed;
742 PFAST_IO_ROUTINE FastIoWriteCompressed;
743 PFAST_IO_ROUTINE MdlReadCompleteCompressed;
744 PFAST_IO_ROUTINE MdlWriteCompleteCompressed;
745 PFAST_IO_ROUTINE FastIoQueryOpen;
746 PFAST_IO_ROUTINE ReleaseForModWrite;
747 PFAST_IO_ROUTINE AcquireForCcFlush;
748 PFAST_IO_ROUTINE ReleaseForCcFlush;
749 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
752 * Dispatch routine type declaration
757 #else /* !LIBCAPTIVE */
759 #endif /* !LIBCAPTIVE */
760 (*PDRIVER_DISPATCH)(IN struct _DEVICE_OBJECT *DeviceObject,
761 IN struct _IRP *Irp);
764 * StartIo routine type declaration
769 #else /* !LIBCAPTIVE */
771 #endif /* !LIBCAPTIVE */
772 (*PDRIVER_STARTIO)(IN PDEVICE_OBJECT DeviceObject,
776 * Unload routine type declaration
781 #else /* !LIBCAPTIVE */
783 #endif /* !LIBCAPTIVE */
784 (*PDRIVER_UNLOAD)(IN struct _DRIVER_OBJECT *DriverObject);
787 * AddDevice routine type declaration
789 typedef NTSTATUS STDCALL_FUNC
790 (*PDRIVER_ADD_DEVICE)(IN struct _DRIVER_OBJECT *DriverObject,
791 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
794 typedef struct _DRIVER_EXTENSION
796 struct _DRIVER_OBJECT* DriverObject;
797 PDRIVER_ADD_DEVICE AddDevice;
799 UNICODE_STRING ServiceKeyName;
800 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
804 struct _FAST_IO_DISPATCH_TABLE
807 PFAST_IO_DISPATCH Dispatch;
809 } FAST_IO_DISPATCH_TABLE, * PFAST_IO_DISPATCH_TABLE;
812 typedef struct _DRIVER_OBJECT
816 PDEVICE_OBJECT DeviceObject;
821 PDRIVER_EXTENSION DriverExtension;
822 UNICODE_STRING DriverName;
823 PUNICODE_STRING HardwareDatabase;
825 PFAST_IO_DISPATCH_TABLE FastIoDispatch;
827 PFAST_IO_DISPATCH FastIoDispatch;
829 PDRIVER_INITIALIZE DriverInit;
830 PDRIVER_STARTIO DriverStartIo;
831 PDRIVER_UNLOAD DriverUnload;
832 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
833 } DRIVER_OBJECT, *PDRIVER_OBJECT;
836 typedef struct _CONFIGURATION_INFORMATION
845 BOOLEAN AtDiskPrimaryAddressClaimed;
846 BOOLEAN AtDiskSecondaryAddressClaimed;
847 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
849 typedef VOID STDCALL_FUNC
850 (*PIO_DPC_ROUTINE)(PKDPC Dpc,
851 PDEVICE_OBJECT DeviceObject,
855 typedef VOID STDCALL_FUNC
856 (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
859 typedef struct _IO_WORKITEM *PIO_WORKITEM;
860 typedef VOID (*PIO_WORKITEM_ROUTINE)(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context);
862 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
863 typedef struct _PARTITION_INFORMATION
865 LARGE_INTEGER StartingOffset;
866 LARGE_INTEGER PartitionLength;
868 ULONG PartitionNumber;
870 BOOLEAN BootIndicator;
871 BOOLEAN RecognizedPartition;
872 BOOLEAN RewritePartition;
873 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
876 typedef struct _DRIVER_LAYOUT_INFORMATION
878 ULONG PartitionCount;
880 PARTITION_INFORMATION PartitionEntry[1];
881 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
884 typedef IO_ALLOCATION_ACTION STDCALL_FUNC
885 (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
887 PVOID MapRegisterBase,
889 #if (_WIN32_WINNT >= 0x0400)
890 typedef VOID STDCALL_FUNC
891 (*PFSDNOTIFICATIONPROC)(IN PDEVICE_OBJECT PtrTargetFileSystemDeviceObject,
892 IN BOOLEAN DriverActive);
893 #endif // (_WIN32_WINNT >= 0x0400)
895 #endif /* __INCLUDE_DDK_IOTYPES_H */