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;
205 UCHAR ShareDisposition;
211 PHYSICAL_ADDRESS Start;
213 } __attribute__((packed)) Port;
219 } __attribute__((packed))Interrupt;
222 PHYSICAL_ADDRESS Start;
224 } __attribute__((packed))Memory;
230 } __attribute__((packed))Dma;
236 } __attribute__((packed))DeviceSpecificData;
237 } __attribute__((packed)) u;
238 } __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
245 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
246 } __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
250 INTERFACE_TYPE InterfaceType;
252 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
253 } __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR;
258 CM_FULL_RESOURCE_DESCRIPTOR List[1];
259 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
263 * PURPOSE: IRP stack location
265 typedef struct __attribute__((packed)) _IO_STACK_LOCATION
276 PIO_SECURITY_CONTEXT SecurityContext;
278 USHORT FileAttributes;
286 LARGE_INTEGER ByteOffset;
292 LARGE_INTEGER ByteOffset;
296 ULONG OutputBufferLength;
297 ULONG InputBufferLength;
299 PVOID Type3InputBuffer;
303 ULONG OutputBufferLength;
304 ULONG InputBufferLength;
306 PVOID Type3InputBuffer;
311 struct _DEVICE_OBJECT* DeviceObject;
316 struct _DEVICE_OBJECT* DeviceObject;
321 FILE_INFORMATION_CLASS FileInformationClass;
326 FS_INFORMATION_CLASS FsInformationClass;
331 FS_INFORMATION_CLASS FsInformationClass;
336 FILE_INFORMATION_CLASS FileInformationClass;
337 struct _FILE_OBJECT* FileObject;
342 BOOLEAN ReplaceIfExists;
352 PUNICODE_STRING FileName;
353 FILE_INFORMATION_CLASS FileInformationClass;
357 // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
360 DEVICE_RELATION_TYPE Type;
361 } QueryDeviceRelations;
363 // Parameters for IRP_MN_QUERY_INTERFACE
366 CONST GUID *InterfaceType;
369 PINTERFACE Interface;
370 PVOID InterfaceSpecificData;
373 // Parameters for IRP_MN_QUERY_CAPABILITIES
376 PDEVICE_CAPABILITIES Capabilities;
377 } DeviceCapabilities;
379 // Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
382 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
383 } FilterResourceRequirements;
385 // Parameters for IRP_MN_QUERY_ID
388 BUS_QUERY_ID_TYPE IdType;
391 // Parameters for IRP_MN_QUERY_DEVICE_TEXT
394 DEVICE_TEXT_TYPE DeviceTextType;
398 // Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
403 DEVICE_USAGE_NOTIFICATION_TYPE Type;
406 // Parameters for IRP_MN_WAIT_WAKE
409 SYSTEM_POWER_STATE PowerState;
412 // Parameter for IRP_MN_POWER_SEQUENCE
415 PPOWER_SEQUENCE PowerSequence;
418 // Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
422 POWER_STATE_TYPE Type;
424 POWER_ACTION ShutdownType;
427 // Parameters for IRP_MN_START_DEVICE
430 PCM_RESOURCE_LIST AllocatedResources;
431 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
434 /* Parameters for IRP_MN_SCSI_CLASS */
437 struct _SCSI_REQUEST_BLOCK *Srb;
440 //byte range file locking
443 PLARGE_INTEGER Length;
445 LARGE_INTEGER ByteOffset;
448 /* Paramters for other calls */
458 struct _DEVICE_OBJECT* DeviceObject;
459 struct _FILE_OBJECT* FileObject;
461 PIO_COMPLETION_ROUTINE CompletionRoutine;
462 PVOID CompletionContext;
464 } __attribute__((packed)) IO_STACK_LOCATION, *PIO_STACK_LOCATION;
467 typedef struct _IO_STATUS_BLOCK
471 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
474 typedef struct _IO_PIPE_CREATE_BUFFER
476 BOOLEAN WriteModeMessage;
477 BOOLEAN ReadModeMessage;
482 LARGE_INTEGER TimeOut;
483 } IO_PIPE_CREATE_BUFFER, *PIO_PIPE_CREATE_BUFFER;
486 typedef struct _IO_MAILSLOT_CREATE_BUFFER
488 ULONG Param; /* ?? */
489 ULONG MaxMessageSize;
490 LARGE_INTEGER TimeOut;
491 } IO_MAILSLOT_CREATE_BUFFER, *PIO_MAILSLOT_CREATE_BUFFER;
495 * Driver entry point declaration
500 #else /* !LIBCAPTIVE */
502 #endif /* !LIBCAPTIVE */
503 (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
504 PUNICODE_STRING RegistryPath);
507 * Driver cancel declaration
509 typedef NTSTATUS STDCALL_FUNC
510 (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
511 struct _IRP* RegistryPath);
514 typedef struct _SECTION_OBJECT_POINTERS
516 PVOID DataSectionObject;
517 PVOID SharedCacheMap;
518 PVOID ImageSectionObject;
519 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
521 typedef struct _IO_COMPLETION_CONTEXT
525 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
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
549 * ReactOS specific flags
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
557 typedef struct _FILE_OBJECT
561 struct _DEVICE_OBJECT* DeviceObject;
565 PSECTION_OBJECT_POINTERS SectionObjectPointers;
566 PVOID PrivateCacheMap;
567 NTSTATUS FinalStatus;
568 struct _FILE_OBJECT* RelatedFileObject;
569 BOOLEAN LockOperation;
570 BOOLEAN DeletePending;
573 BOOLEAN DeleteAccess;
576 BOOLEAN SharedDelete;
578 UNICODE_STRING FileName;
579 LARGE_INTEGER CurrentByteOffset;
585 PIO_COMPLETION_CONTEXT CompletionContext;
586 } FILE_OBJECT, *PFILE_OBJECT;
597 struct _IRP* MasterIrp;
601 LIST_ENTRY ThreadListEntry;
602 IO_STATUS_BLOCK IoStatus;
603 KPROCESSOR_MODE RequestorMode;
604 BOOLEAN PendingReturned;
606 CHAR CurrentLocation;
609 CCHAR ApcEnvironment;
610 UCHAR AllocationFlags;
611 PIO_STATUS_BLOCK UserIosb;
617 PIO_APC_ROUTINE UserApcRoutine;
618 PVOID UserApcContext;
619 } AsynchronousParameters;
620 LARGE_INTEGER AllocationSize;
622 PDRIVER_CANCEL CancelRoutine;
629 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
630 PVOID DriverContext[4];
632 struct _ETHREAD* Thread;
633 PCHAR AuxiliaryBuffer;
634 LIST_ENTRY ListEntry;
635 struct _IO_STACK_LOCATION* CurrentStackLocation;
636 PFILE_OBJECT OriginalFileObject;
641 IO_STACK_LOCATION Stack[1];
644 #define VPB_MOUNTED 0x00000001
645 #define VPB_LOCKED 0x00000002
646 #define VPB_PERSISTENT 0x00000004
647 #define VPB_REMOVE_PENDING 0x00000008
654 USHORT VolumeLabelLength;
655 struct _DEVICE_OBJECT* DeviceObject;
656 struct _DEVICE_OBJECT* RealDevice;
658 ULONG ReferenceCount;
659 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
665 __attribute__ ((__aligned__(16)))
667 __attribute__ ((__aligned__(8)))
669 #error "Missing _WIN64 or _WIN32"
676 struct _DRIVER_OBJECT* DriverObject;
677 struct _DEVICE_OBJECT* NextDevice;
678 struct _DEVICE_OBJECT* AttachedDevice;
679 struct _IRP* CurrentIrp;
682 ULONG Characteristics;
684 PVOID DeviceExtension;
685 DEVICE_TYPE DeviceType;
690 WAIT_CONTEXT_BLOCK Wcb;
692 ULONG AlignmentRequirement;
693 KDEVICE_QUEUE DeviceQueue;
695 ULONG ActiveThreadCount;
696 PSECURITY_DESCRIPTOR SecurityDescriptor;
700 struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
702 } DEVICE_OBJECT, *PDEVICE_OBJECT;
706 * Fast i/o routine type declaration
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
713 #else /* !LIBCAPTIVE */
715 #endif /* !LIBCAPTIVE */
716 (*PFAST_IO_ROUTINE)(IN struct _FILE_OBJECT *FileObject,
717 IN PLARGE_INTEGER FileOffset,
722 OUT PIO_STATUS_BLOCK IoStatus,
723 IN struct _DEVICE_OBJECT *DeviceObject);
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;
757 * Dispatch routine type declaration
762 #else /* !LIBCAPTIVE */
764 #endif /* !LIBCAPTIVE */
765 (*PDRIVER_DISPATCH)(IN struct _DEVICE_OBJECT *DeviceObject,
766 IN struct _IRP *Irp);
769 * StartIo routine type declaration
774 #else /* !LIBCAPTIVE */
776 #endif /* !LIBCAPTIVE */
777 (*PDRIVER_STARTIO)(IN PDEVICE_OBJECT DeviceObject,
781 * Unload routine type declaration
786 #else /* !LIBCAPTIVE */
788 #endif /* !LIBCAPTIVE */
789 (*PDRIVER_UNLOAD)(IN struct _DRIVER_OBJECT *DriverObject);
792 * AddDevice routine type declaration
794 typedef NTSTATUS STDCALL_FUNC
795 (*PDRIVER_ADD_DEVICE)(IN struct _DRIVER_OBJECT *DriverObject,
796 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
799 typedef struct _DRIVER_EXTENSION
801 struct _DRIVER_OBJECT* DriverObject;
802 PDRIVER_ADD_DEVICE AddDevice;
804 UNICODE_STRING ServiceKeyName;
805 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
809 struct _FAST_IO_DISPATCH_TABLE
812 PFAST_IO_DISPATCH Dispatch;
814 } FAST_IO_DISPATCH_TABLE, * PFAST_IO_DISPATCH_TABLE;
817 typedef struct _DRIVER_OBJECT
821 PDEVICE_OBJECT DeviceObject;
826 PDRIVER_EXTENSION DriverExtension;
827 UNICODE_STRING DriverName;
828 PUNICODE_STRING HardwareDatabase;
830 PFAST_IO_DISPATCH_TABLE FastIoDispatch;
832 PFAST_IO_DISPATCH FastIoDispatch;
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;
841 typedef struct _CONFIGURATION_INFORMATION
850 BOOLEAN AtDiskPrimaryAddressClaimed;
851 BOOLEAN AtDiskSecondaryAddressClaimed;
852 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
854 typedef VOID STDCALL_FUNC
855 (*PIO_DPC_ROUTINE)(PKDPC Dpc,
856 PDEVICE_OBJECT DeviceObject,
860 typedef VOID STDCALL_FUNC
861 (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
864 typedef struct _IO_WORKITEM *PIO_WORKITEM;
865 typedef VOID (*PIO_WORKITEM_ROUTINE)(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context);
867 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
868 typedef struct _PARTITION_INFORMATION
870 LARGE_INTEGER StartingOffset;
871 LARGE_INTEGER PartitionLength;
873 ULONG PartitionNumber;
875 BOOLEAN BootIndicator;
876 BOOLEAN RecognizedPartition;
877 BOOLEAN RewritePartition;
878 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
881 typedef struct _DRIVER_LAYOUT_INFORMATION
883 ULONG PartitionCount;
885 PARTITION_INFORMATION PartitionEntry[1];
886 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
889 typedef IO_ALLOCATION_ACTION STDCALL_FUNC
890 (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
892 PVOID MapRegisterBase,
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)
900 #endif /* __INCLUDE_DDK_IOTYPES_H */