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 ************************************************************/
68 #else /* !LIBCAPTIVE */
70 #endif /* !LIBCAPTIVE */
71 (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
75 typedef NTSTATUS STDCALL_FUNC
76 (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
77 PUNICODE_STRING Pathname,
78 INTERFACE_TYPE BusType,
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);
88 typedef NTSTATUS STDCALL_FUNC
89 (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
93 typedef VOID STDCALL_FUNC
94 (*PIO_APC_ROUTINE)(PVOID ApcContext,
95 struct _IO_STATUS_BLOCK* IoStatusBlock,
99 /* STRUCTURE TYPES ***********************************************************/
101 typedef struct _ADAPTER_OBJECT ADAPTER_OBJECT, *PADAPTER_OBJECT;
104 * PURPOSE: Special timer associated with each device
105 * NOTES: This is a guess
107 typedef struct _IO_TIMER
111 } IO_TIMER, *PIO_TIMER;
113 typedef struct _IO_SECURITY_CONTEXT
115 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
116 PACCESS_STATE AccessState;
117 ACCESS_MASK DesiredAccess;
118 ULONG FullCreateOptions;
119 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
122 typedef struct _IO_RESOURCE_DESCRIPTOR
126 UCHAR ShareDisposition;
129 * Reserved for system use
136 * Reserved for system use
146 PHYSICAL_ADDRESS MinimumAddress;
147 PHYSICAL_ADDRESS MaximumAddress;
153 PHYSICAL_ADDRESS MinimumAddress;
154 PHYSICAL_ADDRESS MaximumAddress;
163 ULONG MinimumChannel;
164 ULONG MaximumChannel;
167 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
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
175 typedef struct _IO_RESOURCE_LIST
180 IO_RESOURCE_DESCRIPTOR Descriptors[1];
181 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
183 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST
191 * System defined enum for the bus
193 INTERFACE_TYPE InterfaceType;
198 ULONG AlternativeLists;
199 IO_RESOURCE_LIST List[1];
200 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
203 /* MicroChannel bus data */
205 typedef struct _CM_MCA_POS_DATA
212 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
215 /* Int13 drive geometry data */
217 typedef struct _CM_INT13_DRIVE_PARAMETER
221 USHORT SectorsPerTrack;
224 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
227 /* Extended drive geometry data */
229 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
231 ULONG BytesPerSector;
232 ULONG NumberOfCylinders;
233 ULONG SectorsPerTrack;
235 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
241 UCHAR ShareDisposition;
247 PHYSICAL_ADDRESS Start;
249 } __attribute__((packed)) Port;
255 } __attribute__((packed))Interrupt;
258 PHYSICAL_ADDRESS Start;
260 } __attribute__((packed))Memory;
266 } __attribute__((packed))Dma;
272 } __attribute__((packed))DeviceSpecificData;
273 } __attribute__((packed)) u;
274 } __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
281 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
282 } __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
286 INTERFACE_TYPE InterfaceType;
288 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
289 } __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
294 CM_FULL_RESOURCE_DESCRIPTOR List[1];
295 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
299 * PURPOSE: IRP stack location
301 typedef struct __attribute__((packed)) _IO_STACK_LOCATION
312 PIO_SECURITY_CONTEXT SecurityContext;
314 USHORT FileAttributes;
322 LARGE_INTEGER ByteOffset;
328 LARGE_INTEGER ByteOffset;
332 ULONG OutputBufferLength;
333 ULONG InputBufferLength;
335 PVOID Type3InputBuffer;
339 ULONG OutputBufferLength;
340 ULONG InputBufferLength;
342 PVOID Type3InputBuffer;
347 struct _DEVICE_OBJECT* DeviceObject;
352 struct _DEVICE_OBJECT* DeviceObject;
357 FILE_INFORMATION_CLASS FileInformationClass;
362 FS_INFORMATION_CLASS FsInformationClass;
367 FS_INFORMATION_CLASS FsInformationClass;
372 FILE_INFORMATION_CLASS FileInformationClass;
373 struct _FILE_OBJECT* FileObject;
378 BOOLEAN ReplaceIfExists;
388 PUNICODE_STRING FileName;
389 FILE_INFORMATION_CLASS FileInformationClass;
393 // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
396 DEVICE_RELATION_TYPE Type;
397 } QueryDeviceRelations;
399 // Parameters for IRP_MN_QUERY_INTERFACE
402 CONST GUID *InterfaceType;
405 PINTERFACE Interface;
406 PVOID InterfaceSpecificData;
409 // Parameters for IRP_MN_QUERY_CAPABILITIES
412 PDEVICE_CAPABILITIES Capabilities;
413 } DeviceCapabilities;
415 // Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
418 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
419 } FilterResourceRequirements;
421 // Parameters for IRP_MN_QUERY_ID
424 BUS_QUERY_ID_TYPE IdType;
427 // Parameters for IRP_MN_QUERY_DEVICE_TEXT
430 DEVICE_TEXT_TYPE DeviceTextType;
434 // Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
439 DEVICE_USAGE_NOTIFICATION_TYPE Type;
442 // Parameters for IRP_MN_WAIT_WAKE
445 SYSTEM_POWER_STATE PowerState;
448 // Parameter for IRP_MN_POWER_SEQUENCE
451 PPOWER_SEQUENCE PowerSequence;
454 // Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
458 POWER_STATE_TYPE Type;
460 POWER_ACTION ShutdownType;
463 // Parameters for IRP_MN_START_DEVICE
466 PCM_RESOURCE_LIST AllocatedResources;
467 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
470 /* Parameters for IRP_MN_SCSI_CLASS */
473 struct _SCSI_REQUEST_BLOCK *Srb;
476 //byte range file locking
479 PLARGE_INTEGER Length;
481 LARGE_INTEGER ByteOffset;
484 /* Paramters for other calls */
494 struct _DEVICE_OBJECT* DeviceObject;
495 struct _FILE_OBJECT* FileObject;
497 PIO_COMPLETION_ROUTINE CompletionRoutine;
498 PVOID CompletionContext;
500 } __attribute__((packed)) IO_STACK_LOCATION, *PIO_STACK_LOCATION;
503 typedef struct _IO_STATUS_BLOCK
507 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
509 typedef struct _IO_COMPLETION_PACKET{
512 IO_STATUS_BLOCK IoStatus;
513 LIST_ENTRY ListEntry;
514 } IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;
516 typedef struct _IO_PIPE_CREATE_BUFFER
518 BOOLEAN WriteModeMessage;
519 BOOLEAN ReadModeMessage;
524 LARGE_INTEGER TimeOut;
525 } IO_PIPE_CREATE_BUFFER, *PIO_PIPE_CREATE_BUFFER;
528 typedef struct _IO_MAILSLOT_CREATE_BUFFER
530 ULONG Param; /* ?? */
531 ULONG MaxMessageSize;
532 LARGE_INTEGER TimeOut;
533 } IO_MAILSLOT_CREATE_BUFFER, *PIO_MAILSLOT_CREATE_BUFFER;
537 * Driver entry point declaration
542 #else /* !LIBCAPTIVE */
544 #endif /* !LIBCAPTIVE */
545 (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
546 PUNICODE_STRING RegistryPath);
549 * Driver cancel declaration
551 typedef NTSTATUS STDCALL_FUNC
552 (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
553 struct _IRP* RegistryPath);
556 typedef struct _SECTION_OBJECT_POINTERS
558 PVOID DataSectionObject;
559 PVOID SharedCacheMap;
560 PVOID ImageSectionObject;
561 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
563 typedef struct _IO_COMPLETION_CONTEXT
567 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
569 #define FO_FILE_OPEN 0x00000001
570 #define FO_SYNCHRONOUS_IO 0x00000002
571 #define FO_ALERTABLE_IO 0x00000004
572 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
573 #define FO_WRITE_THROUGH 0x00000010
574 #define FO_SEQUENTIAL_ONLY 0x00000020
575 #define FO_CACHE_SUPPORTED 0x00000040
576 #define FO_NAMED_PIPE 0x00000080
577 #define FO_STREAM_FILE 0x00000100
578 #define FO_MAILSLOT 0x00000200
579 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
580 #define FO_DIRECT_DEVICE_OPEN 0x00000800
581 #define FO_FILE_MODIFIED 0x00001000
582 #define FO_FILE_SIZE_CHANGED 0x00002000
583 #define FO_CLEANUP_COMPLETE 0x00004000
584 #define FO_TEMPORARY_FILE 0x00008000
585 #define FO_DELETE_ON_CLOSE 0x00010000
586 #define FO_OPENED_CASE_SENSITIVE 0x00020000
587 #define FO_HANDLE_CREATED 0x00040000
588 #define FO_FILE_FAST_IO_READ 0x00080000
591 * ReactOS specific flags
593 #define FO_DIRECT_CACHE_READ 0x72000001
594 #define FO_DIRECT_CACHE_WRITE 0x72000002
595 #define FO_DIRECT_CACHE_PAGING_READ 0x72000004
596 #define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008
597 #define FO_FCB_IS_VALID 0x72000010
599 typedef struct _FILE_OBJECT
603 struct _DEVICE_OBJECT* DeviceObject;
607 PSECTION_OBJECT_POINTERS SectionObjectPointers;
608 PVOID PrivateCacheMap;
609 NTSTATUS FinalStatus;
610 struct _FILE_OBJECT* RelatedFileObject;
611 BOOLEAN LockOperation;
612 BOOLEAN DeletePending;
615 BOOLEAN DeleteAccess;
618 BOOLEAN SharedDelete;
620 UNICODE_STRING FileName;
621 LARGE_INTEGER CurrentByteOffset;
627 PIO_COMPLETION_CONTEXT CompletionContext;
628 } FILE_OBJECT, *PFILE_OBJECT;
639 struct _IRP* MasterIrp;
643 LIST_ENTRY ThreadListEntry;
644 IO_STATUS_BLOCK IoStatus;
645 KPROCESSOR_MODE RequestorMode;
646 BOOLEAN PendingReturned;
648 CHAR CurrentLocation;
651 CCHAR ApcEnvironment;
652 UCHAR AllocationFlags;
653 PIO_STATUS_BLOCK UserIosb;
659 PIO_APC_ROUTINE UserApcRoutine;
660 PVOID UserApcContext;
661 } AsynchronousParameters;
662 LARGE_INTEGER AllocationSize;
664 PDRIVER_CANCEL CancelRoutine;
671 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
672 PVOID DriverContext[4];
674 struct _ETHREAD* Thread;
675 PCHAR AuxiliaryBuffer;
676 LIST_ENTRY ListEntry;
677 struct _IO_STACK_LOCATION* CurrentStackLocation;
678 PFILE_OBJECT OriginalFileObject;
683 IO_STACK_LOCATION Stack[1];
686 #define VPB_MOUNTED 0x00000001
687 #define VPB_LOCKED 0x00000002
688 #define VPB_PERSISTENT 0x00000004
689 #define VPB_REMOVE_PENDING 0x00000008
696 USHORT VolumeLabelLength;
697 struct _DEVICE_OBJECT* DeviceObject;
698 struct _DEVICE_OBJECT* RealDevice;
700 ULONG ReferenceCount;
701 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
707 __attribute__ ((__aligned__(16)))
709 __attribute__ ((__aligned__(8)))
711 #error "Missing _WIN64 or _WIN32"
718 struct _DRIVER_OBJECT* DriverObject;
719 struct _DEVICE_OBJECT* NextDevice;
720 struct _DEVICE_OBJECT* AttachedDevice;
721 struct _IRP* CurrentIrp;
724 ULONG Characteristics;
726 PVOID DeviceExtension;
727 DEVICE_TYPE DeviceType;
732 WAIT_CONTEXT_BLOCK Wcb;
734 ULONG AlignmentRequirement;
735 KDEVICE_QUEUE DeviceQueue;
737 ULONG ActiveThreadCount;
738 PSECURITY_DESCRIPTOR SecurityDescriptor;
742 struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
744 } DEVICE_OBJECT, *PDEVICE_OBJECT;
748 * Fast i/o routine type declaration
750 //typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
751 //FIXME : this type is ok for read and write, but not for all routines
755 #else /* !LIBCAPTIVE */
757 #endif /* !LIBCAPTIVE */
758 (*PFAST_IO_ROUTINE)(IN struct _FILE_OBJECT *FileObject,
759 IN PLARGE_INTEGER FileOffset,
764 OUT PIO_STATUS_BLOCK IoStatus,
765 IN struct _DEVICE_OBJECT *DeviceObject);
767 typedef struct _FAST_IO_DISPATCH {
768 ULONG SizeOfFastIoDispatch;
769 PFAST_IO_ROUTINE FastIoCheckIfPossible;
770 PFAST_IO_ROUTINE FastIoRead;
771 PFAST_IO_ROUTINE FastIoWrite;
772 PFAST_IO_ROUTINE FastIoQueryBasicInfo;
773 PFAST_IO_ROUTINE FastIoQueryStandardInfo;
774 PFAST_IO_ROUTINE FastIoLock;
775 PFAST_IO_ROUTINE FastIoUnlockSingle;
776 PFAST_IO_ROUTINE FastIoUnlockAll;
777 PFAST_IO_ROUTINE FastIoUnlockAllByKey;
778 PFAST_IO_ROUTINE FastIoDeviceControl;
779 PFAST_IO_ROUTINE AcquireFileForNtCreateSection;
780 PFAST_IO_ROUTINE ReleaseFileForNtCreateSection;
781 PFAST_IO_ROUTINE FastIoDetachDevice;
782 PFAST_IO_ROUTINE FastIoQueryNetworkOpenInfo;
783 PFAST_IO_ROUTINE AcquireForModWrite;
784 PFAST_IO_ROUTINE MdlRead;
785 PFAST_IO_ROUTINE MdlReadComplete;
786 PFAST_IO_ROUTINE PrepareMdlWrite;
787 PFAST_IO_ROUTINE MdlWriteComplete;
788 PFAST_IO_ROUTINE FastIoReadCompressed;
789 PFAST_IO_ROUTINE FastIoWriteCompressed;
790 PFAST_IO_ROUTINE MdlReadCompleteCompressed;
791 PFAST_IO_ROUTINE MdlWriteCompleteCompressed;
792 PFAST_IO_ROUTINE FastIoQueryOpen;
793 PFAST_IO_ROUTINE ReleaseForModWrite;
794 PFAST_IO_ROUTINE AcquireForCcFlush;
795 PFAST_IO_ROUTINE ReleaseForCcFlush;
796 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
799 * Dispatch routine type declaration
804 #else /* !LIBCAPTIVE */
806 #endif /* !LIBCAPTIVE */
807 (*PDRIVER_DISPATCH)(IN struct _DEVICE_OBJECT *DeviceObject,
808 IN struct _IRP *Irp);
811 * StartIo routine type declaration
816 #else /* !LIBCAPTIVE */
818 #endif /* !LIBCAPTIVE */
819 (*PDRIVER_STARTIO)(IN PDEVICE_OBJECT DeviceObject,
823 * Unload routine type declaration
828 #else /* !LIBCAPTIVE */
830 #endif /* !LIBCAPTIVE */
831 (*PDRIVER_UNLOAD)(IN struct _DRIVER_OBJECT *DriverObject);
834 * AddDevice routine type declaration
836 typedef NTSTATUS STDCALL_FUNC
837 (*PDRIVER_ADD_DEVICE)(IN struct _DRIVER_OBJECT *DriverObject,
838 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
841 typedef struct _DRIVER_EXTENSION
843 struct _DRIVER_OBJECT* DriverObject;
844 PDRIVER_ADD_DEVICE AddDevice;
846 UNICODE_STRING ServiceKeyName;
847 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
851 struct _FAST_IO_DISPATCH_TABLE
854 PFAST_IO_DISPATCH Dispatch;
856 } FAST_IO_DISPATCH_TABLE, * PFAST_IO_DISPATCH_TABLE;
859 typedef struct _DRIVER_OBJECT
863 PDEVICE_OBJECT DeviceObject;
868 PDRIVER_EXTENSION DriverExtension;
869 UNICODE_STRING DriverName;
870 PUNICODE_STRING HardwareDatabase;
872 PFAST_IO_DISPATCH_TABLE FastIoDispatch;
874 PFAST_IO_DISPATCH FastIoDispatch;
876 PDRIVER_INITIALIZE DriverInit;
877 PDRIVER_STARTIO DriverStartIo;
878 PDRIVER_UNLOAD DriverUnload;
879 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
880 } DRIVER_OBJECT, *PDRIVER_OBJECT;
883 typedef struct _CONFIGURATION_INFORMATION
892 BOOLEAN AtDiskPrimaryAddressClaimed;
893 BOOLEAN AtDiskSecondaryAddressClaimed;
894 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
896 typedef VOID STDCALL_FUNC
897 (*PIO_DPC_ROUTINE)(PKDPC Dpc,
898 PDEVICE_OBJECT DeviceObject,
902 typedef VOID STDCALL_FUNC
903 (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
906 typedef struct _IO_WORKITEM *PIO_WORKITEM;
907 typedef VOID (*PIO_WORKITEM_ROUTINE)(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context);
909 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
910 typedef struct _PARTITION_INFORMATION
912 LARGE_INTEGER StartingOffset;
913 LARGE_INTEGER PartitionLength;
915 ULONG PartitionNumber;
917 BOOLEAN BootIndicator;
918 BOOLEAN RecognizedPartition;
919 BOOLEAN RewritePartition;
920 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
923 typedef struct _DRIVER_LAYOUT_INFORMATION
925 ULONG PartitionCount;
927 PARTITION_INFORMATION PartitionEntry[1];
928 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
931 typedef IO_ALLOCATION_ACTION STDCALL_FUNC
932 (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
934 PVOID MapRegisterBase,
936 #if (_WIN32_WINNT >= 0x0400)
937 typedef VOID STDCALL_FUNC
938 (*PFSDNOTIFICATIONPROC)(IN PDEVICE_OBJECT PtrTargetFileSystemDeviceObject,
939 IN BOOLEAN DriverActive);
940 #endif // (_WIN32_WINNT >= 0x0400)
942 #endif /* __INCLUDE_DDK_IOTYPES_H */