21#define UDF_CURRENT_BUILD 123456789
24#ifdef UDF_BUG_CHECK_ID
25#undef UDF_BUG_CHECK_ID
27#define UDF_BUG_CHECK_ID UDF_FILE_DEVICE_CONTROL
89 TmPrint((
"UDFDeviceControl: \n"));
107 Irp->IoStatus.Status = RC;
108 Irp->IoStatus.Information = 0;
172 PCHAR ModeSelectData;
174 UDFPrint((
"UDFCommonDeviceControl\n"));
194#ifndef UDF_READ_ONLY_BUILD
208 goto ioctl_do_default;
334 if(!
Irp->AssociatedIrp.SystemBuffer)
335 goto ioctl_do_default;
349 ScsiCommand =
Cdb->
CDB6.OperationCode;
352 UDFPrint((
"Write10, LBA %2.2x%2.2x%2.2x%2.2x\n",
360 UDFPrint((
"Write12, LBA %2.2x%2.2x%2.2x%2.2x\n",
369 switch(ScsiCommand) {
372 ModeSelectData = CdbData+4;
373 switch(ModeSelectData[0]) {
377 UDFPrint((
"Unsafe MODE_SELECT_6 via pass-through (%2.2x)\n", ModeSelectData[0]));
378 goto unsafe_direct_scsi_cmd;
384 ModeSelectData = CdbData+8;
385 switch(ModeSelectData[0]) {
389 UDFPrint((
"Unsafe MODE_SELECT_10 via pass-through (%2.2x)\n", ModeSelectData[0]));
390 goto unsafe_direct_scsi_cmd;
404 UDFPrint((
"UDF Direct media modification via pass-through (%2.2x)\n", ScsiCommand));
405unsafe_direct_scsi_cmd:
407 goto ioctl_do_default;
417#ifdef UDF_DELAYED_CLOSE
434 Vcb->MediaLockCount = 0;
436 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_MOUNTED;
452 goto notify_media_change;
458 UDFPrint((
"UDF Medium/Tray control IOCTL via pass-through\n"));
460 goto ioctl_do_default;
472 goto ioctl_do_default;
476 UDFPrint((
"UDF Register Autoformat\n"));
484 Irp->IoStatus.Information = 0;
512 Irp->IoStatus.Information = 0;
516 UDFPrint((
"UDF Invaidate volume\n"));
523 Irp->IoStatus.Information = 0;
536 if (MountEventHandle)
573 Irp->IoStatus.Information = 0;
585 *(
PBOOLEAN)
Irp->AssociatedIrp.SystemBuffer =
Vcb->IsVolumeJustMounted;
590 Irp->IoStatus.Information = 0;
597 UDFPrint((
"UDF: Get Retrieval Pointers\n"));
603 UDFPrint((
"UDF: Get Spec Retrieval Pointers\n"));
604 PUDF_GET_SPEC_RETRIEVAL_POINTERS_IN SpecRetrPointer;
605 SpecRetrPointer = (PUDF_GET_SPEC_RETRIEVAL_POINTERS_IN)(
Irp->AssociatedIrp.SystemBuffer);
611 UDFPrint((
"UDF: Get File Alloc mode (from ICB)\n"));
616#ifndef UDF_READ_ONLY_BUILD
618 UDFPrint((
"UDF: Set File Alloc mode\n"));
640#ifndef UDF_READ_ONLY_BUILD
644 Irp->IoStatus.Information = 0;
653 UDFPrint((
"UDFUserFsCtrlRequest: IOCTL_UDF_GET_VERSION\n"));
655 Irp->IoStatus.Information = 0;
659 UDFPrint((
"!OutputBufferLength\n"));
677 udf_ver->
header.DriverVersionMj = 0x00010005;
678 udf_ver->
header.DriverVersionMn = 0x12;
688 UDFPrint((
" UDF_USER_FS_FLAGS_RO\n"));
692 UDFPrint((
" UDF_USER_FS_FLAGS_OUR_DRIVER\n"));
696 UDFPrint((
" UDF_USER_FS_FLAGS_RAW\n"));
700 UDFPrint((
" UDF_USER_FS_FLAGS_MEDIA_RO\n"));
704 UDFPrint((
" UDF_USER_FS_FLAGS_FP\n"));
721 UDFPrint((
"UDF: IOCTL_UDF_SET_OPTIONS\n"));
723 Irp->IoStatus.Information = 0;
749 PrevVerifyOnWrite =
Vcb->VerifyOnWrite;
758 if(PrevVerifyOnWrite !=
Vcb->VerifyOnWrite) {
759 if(
Vcb->VerifyOnWrite) {
771 case IOCTL_UDF_GET_OPTIONS_VERSION: {
773 PUDF_GET_OPTIONS_VERSION_OUT udf_opt_ver;
775 UDFPrint((
"UDF: IOCTL_UDF_GET_OPTIONS_VERSION\n"));
777 Irp->IoStatus.Information = 0;
781 UDFPrint((
"OutputBufferLength < %x\n",
sizeof(UDF_GET_OPTIONS_VERSION_OUT)));
785 udf_opt_ver = (PUDF_GET_OPTIONS_VERSION_OUT)(
Irp->AssociatedIrp.SystemBuffer);
798 udf_opt_ver->CfgVersion =
Vcb->CfgVersion;
799 Irp->IoStatus.Information =
sizeof(UDF_GET_OPTIONS_VERSION_OUT);
806 UDFPrint((
"UDF: IOCTL_CDRW_RESET_DRIVER\n"));
807 Vcb->MediaLockCount = 0;
808 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_MEDIA_LOCKED;
809 goto ioctl_do_default;
813 UDFPrint((
"UDFUserFsCtrlRequest: FSCTL_ALLOW_EXTENDED_DASD_IO\n"));
818 Irp->IoStatus.Information = 0;
825 UDFPrint((
"UDFUserFsCtrlRequest: FSCTL_IS_VOLUME_DIRTY\n"));
836 UDFPrint((
"UDF Reset/Eject request\n"));
839 if(
Vcb->EjectWaiter) {
840 UDFPrint((
" Vcb->EjectWaiter present\n"));
841 Irp->IoStatus.Information = 0;
842 Vcb->EjectWaiter->SoftEjectReq =
TRUE;
848 goto ioctl_do_default;
872 UDFPrint((
"UDF Cdrom Disk Type\n"));
875 Irp->IoStatus.Information = 0;
886 for(TrackNumber=
Vcb->FirstTrackNum; TrackNumber<Vcb->LastTrackNum; TrackNumber++) {
909 goto ioctl_do_default;
913 Irp->IoStatus.Information = 0;
918 if(!
buffer->PreventMediaRemoval &&
919 !
Vcb->MediaLockCount) {
921 UDFPrint((
"!locked + unlock req\n"));
924 goto ioctl_do_default;
936#ifdef UDF_DELAYED_CLOSE
947 Vcb->MediaLockCount = 0;
959 Irp->IoStatus.Information = 0;
963 if(
buffer->PreventMediaRemoval) {
965 Vcb->MediaLockCount++;
970 if(
Vcb->MediaLockCount) {
971 UDFPrint((
"lock count %d\n",
Vcb->MediaLockCount));
973 Vcb->MediaLockCount--;
978 goto ioctl_do_default;
988 if(
Vcb && UnsafeIoctl) {
1009 if(
Vcb && UnsafeIoctl) {
1020 AcquiredVcb =
FALSE;
1029 UDFPrint((
" complete Irp %x, ctx %x, status %x, iolen %x\n",
1030 Irp, PtrIrpContext, RC,
Irp->IoStatus.Information));
1031 Irp->IoStatus.Status = RC;
1069 if (
Irp->PendingReturned) {
1145 UDFPrint((
"UDFGetFileAllocModeFromICB\n"));
1153 Irp->IoStatus.Information = 0;
1167#ifndef UDF_READ_ONLY_BUILD
1184 UDFPrint((
"UDFSetFileAllocModeFromICB\n"));
1190 Irp->IoStatus.Information = 0;
1199 RC =
Irp->IoStatus.Status;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
#define Trk_QSubChan_Type_Mask
#define SCSIOP_DOORUNLOCK
#define Trk_QSubChan_Type_Audio
#define SCSIOP_SEND_CUE_SHEET
#define SCSIOP_MEDIUM_REMOVAL
#define SCSIOP_SEND_DVD_STRUCTURE
#define SCSIOP_FORMAT_UNIT
#define SCSIOP_RESERVE_TRACK
#define MODE_PAGE_WRITE_PARAMS
#define SCSIOP_CLOSE_TRACK_SESSION
#define SCSIOP_START_STOP_UNIT
#define SCSIOP_SET_STREAMING
#define SCSIOP_MODE_SELECT10
#define SCSIOP_MODE_SELECT
#define IOCTL_CDRW_READ_ATIP
#define IOCTL_CDRW_GET_WRITE_MODE
#define IOCTL_CDROM_EJECT_MEDIA
#define IOCTL_CDRW_READ_SESSION_INFO
#define IOCTL_CDRW_BUFFER_CAPACITY
#define IOCTL_CDRW_GET_MEDIA_TYPE
#define IOCTL_CDRW_MODE_SENSE
struct _CDROM_DISK_DATA_USER_OUT CDROM_DISK_DATA_USER_OUT
struct _PREVENT_MEDIA_REMOVAL_USER_IN * PPREVENT_MEDIA_REMOVAL_USER_IN
#define IOCTL_DISK_CHECK_VERIFY
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
struct _CDROM_DISK_DATA_USER_OUT * PCDROM_DISK_DATA_USER_OUT
#define IOCTL_CDRW_READ_TOC_EX
#define IOCTL_CDRW_LL_READ
#define IOCTL_DISK_MEDIA_REMOVAL
#define IOCTL_CDRW_READ_TRACK_INFO
#define IOCTL_DISK_EJECT_MEDIA
#define IOCTL_CDRW_LOCK_DOOR
#define IOCTL_DISK_LOAD_MEDIA
#define IOCTL_CDRW_READ_PMA
#define IOCTL_CDRW_GET_DEVICE_NAME
#define IOCTL_DISK_GET_MEDIA_TYPES
#define IOCTL_CDRW_RESET_DRIVER
#define IOCTL_CDRW_GET_SIGNATURE
#define IOCTL_DISK_IS_WRITABLE
#define IOCTL_CDROM_LOAD_MEDIA
#define IOCTL_CDRW_TEST_UNIT_READY
#define IOCTL_DVD_READ_STRUCTURE
#define IOCTL_CDRW_GET_DEVICE_INFO
#define IOCTL_CDROM_MEDIA_REMOVAL
#define IOCTL_CDRW_READ_CD_TEXT
#define IOCTL_CDRW_LL_WRITE
#define IOCTL_CDRW_GET_EVENT
#define IOCTL_CDRW_READ_FULL_TOC
#define IOCTL_CDRW_READ_DISC_INFO
#define IOCTL_CDRW_GET_LAST_ERROR
#define IOCTL_CDRW_GET_MEDIA_TYPE_EX
#define IOCTL_CDRW_SET_SPEED
#define IOCTL_CDRW_FORMAT_UNIT
#define IOCTL_STORAGE_GET_MEDIA_TYPES_EX
#define IOCTL_CDRW_GET_CAPABILITIES
VOID UDFCloseAllDelayed(IN PVCB Vcb)
NTSTATUS UDFGetFileAllocModeFromICB(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
NTSTATUS NTAPI UDFDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI UDFDevIoctlCompletion(PDEVICE_OBJECT PtrDeviceObject, PIRP Irp, VOID *Context)
NTSTATUS UDFProcessLicenseKey(PtrUDFIrpContext IrpContext, PIRP Irp)
NTSTATUS NTAPI UDFCommonDeviceControl(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
#define UDF_CURRENT_BUILD
NTSTATUS UDFSetFileAllocModeFromICB(PtrUDFIrpContext IrpContext, PIRP Irp)
#define NT_SUCCESS(StatCode)
_In_ PIO_STACK_LOCATION IrpSp
NTSTATUS UDFExceptionHandler(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
VOID UDFReadRegKeys(PVCB Vcb, BOOLEAN Update, BOOLEAN UseCfg)
BOOLEAN __fastcall UDFIsIrpTopLevel(PIRP Irp)
VOID UDFLogEvent(NTSTATUS UDFEventLogId, NTSTATUS RC)
VOID UDFDestroyZones(VOID)
PtrUDFIrpContext UDFAllocateIrpContext(PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
long UDFExceptionFilter(PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
#define INTEGRITY_TYPE_OPEN
#define ICB_FLAG_AD_IN_ICB
#define UDFReleaseResource(Resource)
#define UDFDeleteResource(Resource)
#define UDFAcquireResourceShared(Resource, CanWait)
#define UDFAcquireResourceExclusive(Resource, CanWait)
#define UDFInterlockedDecrement(addr)
#define UDFInterlockedIncrement(addr)
#define UDF_ERROR_INTERNAL_ERROR
#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
#define IOCTL_DISK_GET_PARTITION_INFO_EX
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
#define IOCTL_STORAGE_CHECK_VERIFY2
#define IOCTL_STORAGE_LOAD_MEDIA2
ULONG UDFFlushLogicalVolume(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PVCB Vcb, IN ULONG FlushFlags)
ULONG UDFFlushAFile(IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
NTSTATUS UDFUnlockVolume(IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG PID)
NTSTATUS UDFLockVolume(IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG PID)
NTSTATUS UDFGetRetrievalPointers(IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG Special)
NTSTATUS UDFIsVolumeDirty(IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
NTSTATUS UDFInvalidateVolumes(IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
#define IOCTL_CDROM_GET_LAST_SESSION
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX
#define IOCTL_CDROM_SEEK_AUDIO_MSF
#define IOCTL_CDROM_READ_TOC_EX
#define CDROM_DISK_DATA_TRACK
#define IOCTL_CDROM_GET_VOLUME
#define IOCTL_CDROM_CHECK_VERIFY
#define IOCTL_CDROM_DISK_TYPE
#define IOCTL_CDROM_PAUSE_AUDIO
#define CDROM_DISK_AUDIO_TRACK
#define IOCTL_CDROM_SET_VOLUME
#define IOCTL_CDROM_STOP_AUDIO
#define IOCTL_CDROM_GET_CONTROL
#define IOCTL_CDROM_READ_Q_CHANNEL
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY
#define IOCTL_CDROM_GET_CONFIGURATION
#define IOCTL_CDROM_PLAY_AUDIO_MSF
#define IOCTL_CDROM_RESUME_AUDIO
#define IOCTL_CDROM_READ_TOC
#define IOCTL_CDROM_RAW_READ
#define IOCTL_DISK_GET_DRIVE_LAYOUT
#define IOCTL_DISK_GET_PARTITION_INFO
#define IOCTL_STORAGE_CHECK_VERIFY
#define IOCTL_STORAGE_LOAD_MEDIA
#define IOCTL_STORAGE_GET_MEDIA_TYPES
#define IOCTL_STORAGE_EJECT_MEDIA
#define IOCTL_STORAGE_MEDIA_REMOVAL
#define IoSkipCurrentIrpStackLocation(Irp)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
#define IoCompleteRequest
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
VOID NTAPI IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
OSSTATUS UDFDoDismountSequence(IN PVCB Vcb, IN PPREVENT_MEDIA_REMOVAL_USER_IN Buf, IN BOOLEAN Eject)
VOID UDFStopEjectWaiter(PVCB Vcb)
NTSTATUS UDFVerifyVcb(IN PtrUDFIrpContext IrpContext, IN PVCB Vcb)
#define UDFCloseAllSystemDelayedInDir(Vcb, FI)
#define FSCTL_IS_VOLUME_DIRTY
#define _SEH2_AbnormalTermination()
#define _SEH2_EXCEPT(...)
#define _SEH2_GetExceptionInformation()
#define FSCTL_ALLOW_EXTENDED_DASD_IO
VOID UDFVFlush(IN PVCB Vcb)
VOID UDFVRelease(IN PVCB Vcb)
OSSTATUS UDFVInit(IN PVCB Vcb)
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
#define IOCTL_SCSI_PASS_THROUGH
struct _SCSI_PASS_THROUGH * PSCSI_PASS_THROUGH
#define IOCTL_SCSI_PASS_THROUGH_DIRECT
#define offsetof(TYPE, MEMBER)
#define STATUS_BUFFER_TOO_SMALL
struct _UDFIrpContext * PtrUDFIrpContext
struct _UDFContextControlBlock * PtrUDFCCB
#define UDF_NODE_TYPE_VCB
struct _FCB::@729::@732 Fcb
struct _IO_STACK_LOCATION::@1579::@1580 DeviceIoControl
union _IO_STACK_LOCATION::@1579 Parameters
struct _IO_STACK_LOCATION::@3978::@3993 FileSystemControl
PDEVICE_OBJECT TargetDeviceObject
struct _UDF_GET_VERSION_OUT::@970 header
struct _UDF_SET_OPTIONS_IN::@971 header
#define RtlZeroMemory(Destination, Length)
#define UDF_DATA_FLAGS_RESOURCE_INITIALIZED
#define UDF_VCB_IC_DIRTY_RO
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
#define UDF_DATA_FLAGS_ZONES_INITIALIZED
#define UDF_VCB_FLAGS_UNSAFE_IOCTL
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
#define UDF_VCB_FLAGS_RAW_DISK
#define UDF_VCB_FLAGS_MEDIA_READ_ONLY
#define UDF_VCB_FLAGS_OUR_DEVICE_DRIVER
#define UDF_VCB_FLAGS_MEDIA_LOCKED
OSSTATUS UDFConvertFEToNonInICB(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint8 NewAllocMode)
#define UDFGetFileICBAllocMode__(fi)
#define STATUS_INVALID_PARAMETER
#define STATUS_INVALID_USER_BUFFER
#define STATUS_SHARING_VIOLATION
#define STATUS_INSUFFICIENT_RESOURCES
#define UDFClearFlag(Flag, Value)
#define PEXTENDED_IO_STACK_LOCATION
#define UDF_USER_FS_FLAGS_MEDIA_RO
#define IOCTL_UDF_SET_FILE_ALLOCATION_MODE
struct _UDF_GET_VERSION_OUT UDF_GET_VERSION_OUT
struct _UDF_GET_FILE_ALLOCATION_MODE_OUT UDF_GET_FILE_ALLOCATION_MODE_OUT
#define IOCTL_UDF_SET_OPTIONS
#define IOCTL_UDF_REGISTER_AUTOFORMAT
#define UDF_USER_FS_FLAGS_RAW
#define IOCTL_UDF_SET_NOTIFICATION_EVENT
#define IOCTL_UDF_GET_VERSION
#define IOCTL_UDF_GET_RETRIEVAL_POINTERS
#define IOCTL_UDF_INVALIDATE_VOLUMES
struct _UDF_SET_OPTIONS_IN * PUDF_SET_OPTIONS_IN
#define UDF_USER_FS_FLAGS_OUR_DRIVER
#define UDF_SET_OPTIONS_FLAG_TEMPORARY
struct _UDF_GET_FILE_ALLOCATION_MODE_OUT * PUDF_GET_FILE_ALLOCATION_MODE_OUT
PUDF_GET_FILE_ALLOCATION_MODE_OUT PUDF_SET_FILE_ALLOCATION_MODE_IN
struct _UDF_GET_VERSION_OUT * PUDF_GET_VERSION_OUT
#define IOCTL_UDF_GET_SPEC_RETRIEVAL_POINTERS
#define IOCTL_UDF_IS_VOLUME_JUST_MOUNTED
#define UDF_USER_FS_FLAGS_FP
#define UDF_USER_FS_FLAGS_RO
#define IOCTL_UDF_GET_FILE_ALLOCATION_MODE
#define IOCTL_UDF_LOCK_VOLUME_BY_PID
#define IOCTL_UDF_DISABLE_DRIVER
#define IOCTL_UDF_UNLOCK_VOLUME_BY_PID
#define UDF_SET_OPTIONS_FLAG_MASK
#define IOCTL_UDF_SEND_LICENSE_KEY
struct _CDB::_WRITE_CD WRITE_CD
struct _CDB::_CDB12READWRITE CDB12READWRITE
OSSTATUS WCacheFlushBlocks__(IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba, IN ULONG BCount)
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
#define IO_DISK_INCREMENT
#define ObDereferenceObject