ReactOS 0.4.16-dev-340-g0540c21
devcntrl.cpp File Reference
#include "udffs.h"
#include "CDRW/scsi_port.h"
Include dependency graph for devcntrl.cpp:

Go to the source code of this file.

Macros

#define UDF_CURRENT_BUILD   123456789
 
#define UDF_BUG_CHECK_ID   UDF_FILE_DEVICE_CONTROL
 

Functions

NTSTATUS UDFGetFileAllocModeFromICB (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS UDFSetFileAllocModeFromICB (PtrUDFIrpContext IrpContext, PIRP Irp)
 
NTSTATUS UDFProcessLicenseKey (PtrUDFIrpContext IrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFDeviceControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI UDFCommonDeviceControl (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFDevIoctlCompletion (PDEVICE_OBJECT PtrDeviceObject, PIRP Irp, VOID *Context)
 

Macro Definition Documentation

◆ UDF_BUG_CHECK_ID

#define UDF_BUG_CHECK_ID   UDF_FILE_DEVICE_CONTROL

Definition at line 27 of file devcntrl.cpp.

◆ UDF_CURRENT_BUILD

#define UDF_CURRENT_BUILD   123456789

Definition at line 21 of file devcntrl.cpp.

Function Documentation

◆ UDFCommonDeviceControl()

NTSTATUS NTAPI UDFCommonDeviceControl ( PtrUDFIrpContext  PtrIrpContext,
PIRP  Irp 
)

Definition at line 149 of file devcntrl.cpp.

153{
156// PIO_STACK_LOCATION PtrNextIoStackLocation = NULL;
160 PVCB Vcb = NULL;
163// PVOID BufferPointer = NULL;
164 BOOLEAN AcquiredVcb = FALSE;
165 BOOLEAN FSDevObj;
166 ULONG TrackNumber;
167 BOOLEAN UnsafeIoctl = TRUE;
168 UCHAR ScsiCommand;
169 PPREVENT_MEDIA_REMOVAL_USER_IN Buf = NULL; // FSD buffer
170 PCDB Cdb;
171 PCHAR CdbData;
172 PCHAR ModeSelectData;
173
174 UDFPrint(("UDFCommonDeviceControl\n"));
175
176 _SEH2_TRY {
177 // First, get a pointer to the current I/O stack location
179 ASSERT(IrpSp);
180
181 // Get the IoControlCode value
183
186
187 FSDevObj = UDFIsFSDevObj(PtrIrpContext->TargetDeviceObject);
188
189 if(FSDevObj) {
190 switch (IoControlCode) {
194#ifndef UDF_READ_ONLY_BUILD
196#endif //UDF_READ_ONLY_BUILD
198 break;
199 default:
200 UDFPrint(("UDFCommonDeviceControl: STATUS_INVALID_PARAMETER %x for FsDevObj\n", IoControlCode));
203 }
204 } else {
205 Ccb = (PtrUDFCCB)(FileObject->FsContext2);
206 if(!Ccb) {
207 UDFPrint((" !Ccb\n"));
208 goto ioctl_do_default;
209 }
210 ASSERT(Ccb);
211 Fcb = Ccb->Fcb;
212 ASSERT(Fcb);
213
214 // Check if the IOCTL is suitable for this type of File
215 if (Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB) {
216 // Everything is acceptable for Volume
217 Vcb = (PVCB)(Fcb);
218 } else {
219 Vcb = Fcb->Vcb;
221 // For files/disrs only the following are acceptable
222 switch (IoControlCode) {
226 break;
227 default:
228 UDFPrint(("UDFCommonDeviceControl: STATUS_INVALID_PARAMETER %x for File/Dir Obj\n", IoControlCode));
230 }
231 }
232 // check 'safe' IOCTLs
233 switch (IoControlCode) {
235
240
245
250
255
269
274
278
280
298
300
303
310// case :
311
313
314 UnsafeIoctl = FALSE;
315 break;
316 }
317
319 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
320 } else {
321 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
322 }
323 AcquiredVcb = TRUE;
324 }
325
326 UDFPrint(("UDF Irp %x, ctx %x, DevIoCtl %x\n", Irp, PtrIrpContext, IoControlCode));
327
328 // We may wish to allow only volume open operations.
329 switch (IoControlCode) {
330
333
334 if(!Irp->AssociatedIrp.SystemBuffer)
335 goto ioctl_do_default;
336
338 Cdb = (PCDB)&(((PSCSI_PASS_THROUGH_DIRECT)(Irp->AssociatedIrp.SystemBuffer))->Cdb);
339 CdbData = (PCHAR)(((PSCSI_PASS_THROUGH_DIRECT)(Irp->AssociatedIrp.SystemBuffer))->DataBuffer);
340 } else {
341 Cdb = (PCDB)&(((PSCSI_PASS_THROUGH)(Irp->AssociatedIrp.SystemBuffer))->Cdb);
342 if(((PSCSI_PASS_THROUGH)(Irp->AssociatedIrp.SystemBuffer))->DataBufferOffset) {
343 CdbData = ((PCHAR)Cdb) +
344 ((PSCSI_PASS_THROUGH)(Irp->AssociatedIrp.SystemBuffer))->DataBufferOffset;
345 } else {
346 CdbData = NULL;
347 }
348 }
349 ScsiCommand = Cdb->CDB6.OperationCode;
350
351 if(ScsiCommand == SCSIOP_WRITE_CD) {
352 UDFPrint(("Write10, LBA %2.2x%2.2x%2.2x%2.2x\n",
353 Cdb->WRITE_CD.LBA[0],
354 Cdb->WRITE_CD.LBA[1],
355 Cdb->WRITE_CD.LBA[2],
356 Cdb->WRITE_CD.LBA[3]
357 ));
358 } else
359 if(ScsiCommand == SCSIOP_WRITE12) {
360 UDFPrint(("Write12, LBA %2.2x%2.2x%2.2x%2.2x\n",
361 Cdb->CDB12READWRITE.LBA[0],
362 Cdb->CDB12READWRITE.LBA[1],
363 Cdb->CDB12READWRITE.LBA[2],
364 Cdb->CDB12READWRITE.LBA[3]
365 ));
366 } else {
367 }
368
369 switch(ScsiCommand) {
370 case SCSIOP_MODE_SELECT: {
371// PMODE_PARAMETER_HEADER ParamHdr = (PMODE_PARAMETER_HEADER)CdbData;
372 ModeSelectData = CdbData+4;
373 switch(ModeSelectData[0]) {
374 case MODE_PAGE_MRW2:
376 case MODE_PAGE_MRW:
377 UDFPrint(("Unsafe MODE_SELECT_6 via pass-through (%2.2x)\n", ModeSelectData[0]));
378 goto unsafe_direct_scsi_cmd;
379 }
380 break; }
381
383// PMODE_PARAMETER_HEADER10 ParamHdr = (PMODE_PARAMETER_HEADER10)CdbData;
384 ModeSelectData = CdbData+8;
385 switch(ModeSelectData[0]) {
386 case MODE_PAGE_MRW2:
388 case MODE_PAGE_MRW:
389 UDFPrint(("Unsafe MODE_SELECT_10 via pass-through (%2.2x)\n", ModeSelectData[0]));
390 goto unsafe_direct_scsi_cmd;
391 }
392 break; }
393
399 case SCSIOP_WRITE6:
400 case SCSIOP_WRITE_CD:
401 case SCSIOP_BLANK:
402 case SCSIOP_WRITE12:
404 UDFPrint(("UDF Direct media modification via pass-through (%2.2x)\n", ScsiCommand));
405unsafe_direct_scsi_cmd:
406 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED))
407 goto ioctl_do_default;
408
409 UDFPrint(("Forget this volume\n"));
410 // Acquire Vcb resource (Shared -> Exclusive)
411 UDFInterlockedIncrement((PLONG)&(Vcb->VCBOpenCount));
412 UDFReleaseResource(&(Vcb->VCBResource));
413
414 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK)) {
415 UDFCloseAllSystemDelayedInDir(Vcb, Vcb->RootDirFCB->FileInfo);
416 }
417#ifdef UDF_DELAYED_CLOSE
418 // Acquire exclusive access to the Vcb.
420#endif //UDF_DELAYED_CLOSE
421
422 // allocate tmp buffer for FSD calls
424 if(!Buf)
426
427 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
428 AcquiredVcb = TRUE;
429 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
430
432 MyFreePool__(Buf);
433 Buf = NULL;
434 Vcb->MediaLockCount = 0;
435
436 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_MOUNTED;
437 Vcb->WriteSecurity = FALSE;
438
439 // Release the Vcb resource.
440 UDFReleaseResource(&(Vcb->VCBResource));
441 AcquiredVcb = FALSE;
442 // disable Eject Request Waiter if any
444
445 // Make sure, that volume will never be quick-remounted
446 // It is very important for ChkUdf utility and
447 // some CD-recording libraries
448 Vcb->SerialNumber--;
449
450 UDFPrint(("Forgotten\n"));
451
452 goto notify_media_change;
453
455 case SCSIOP_DOORLOCK:
458 UDFPrint(("UDF Medium/Tray control IOCTL via pass-through\n"));
459 }
460 goto ioctl_do_default;
461
462 case IOCTL_CDRW_BLANK:
465
466notify_media_change:
467/* Vcb->VCBFlags |= UDF_VCB_FLAGS_UNSAFE_IOCTL;
468 // Make sure, that volume will never be quick-remounted
469 // It is very important for ChkUdf utility and
470 // some CD-recording libraries
471 Vcb->SerialNumber--;
472*/ goto ioctl_do_default;
473
475
476 UDFPrint(("UDF Register Autoformat\n"));
479 } else {
481 RC = STATUS_SUCCESS;
482 }
484 Irp->IoStatus.Information = 0;
485 break;
486 }
487
489
490 UDFPrint(("UDF Disable driver\n"));
491 IoUnregisterFileSystem(UDFGlobalData.UDFDeviceObject);
492 // Now, delete any device objects, etc. we may have created
493 if (UDFGlobalData.UDFDeviceObject) {
494 IoDeleteDevice(UDFGlobalData.UDFDeviceObject);
495 UDFGlobalData.UDFDeviceObject = NULL;
496 }
497
498 // free up any memory we might have reserved for zones/lookaside
499 // lists
502 }
503
504 // delete the resource we may have initialized
506 // un-initialize this resource
507 UDFDeleteResource(&(UDFGlobalData.GlobalDataResource));
509 }
510 RC = STATUS_SUCCESS;
512 Irp->IoStatus.Information = 0;
513 break;
514 }
516 UDFPrint(("UDF Invaidate volume\n"));
517 if(AcquiredVcb) {
518 UDFReleaseResource(&(Vcb->VCBResource));
519 AcquiredVcb = FALSE;
520 }
521 RC = UDFInvalidateVolumes( PtrIrpContext, Irp );
523 Irp->IoStatus.Information = 0;
524 break;
525 }
526
528 {
529 if (IrpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof(HANDLE))
530 {
532 }
533 else
534 {
535 HANDLE MountEventHandle = *(PHANDLE)Irp->AssociatedIrp.SystemBuffer;
536 if (MountEventHandle)
537 {
538 if (!UDFGlobalData.MountEvent)
539 {
541 MountEventHandle,
542 0,
543 NULL,
544 UserMode,
545 (PVOID *) &UDFGlobalData.MountEvent,
546 NULL);
547
548 if (!NT_SUCCESS(RC))
549 {
550 UDFGlobalData.MountEvent = NULL;
551 }
552 }
553 else
554 {
556 }
557 }
558 else
559 {
560 if (!UDFGlobalData.MountEvent)
561 {
563 }
564 else
565 {
567 UDFGlobalData.MountEvent = NULL;
568 }
569 }
570 }
571
573 Irp->IoStatus.Information = 0;
574 break;
575 }
576
578 {
579 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(BOOLEAN))
580 {
582 }
583 else
584 {
585 *(PBOOLEAN)Irp->AssociatedIrp.SystemBuffer = Vcb->IsVolumeJustMounted;
586 Vcb->IsVolumeJustMounted = FALSE;
587 }
588
590 Irp->IoStatus.Information = 0;
591 break;
592 }
593
594
595 //case FSCTL_GET_RETRIEVAL_POINTERS
597 UDFPrint(("UDF: Get Retrieval Pointers\n"));
598 RC = UDFGetRetrievalPointers( PtrIrpContext, Irp, 0 );
600 break;
601 }
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);
606 RC = UDFGetRetrievalPointers( PtrIrpContext, Irp, SpecRetrPointer->Special );
608 break;
609 }
611 UDFPrint(("UDF: Get File Alloc mode (from ICB)\n"));
612 RC = UDFGetFileAllocModeFromICB( PtrIrpContext, Irp );
614 break;
615 }
616#ifndef UDF_READ_ONLY_BUILD
618 UDFPrint(("UDF: Set File Alloc mode\n"));
619 RC = UDFSetFileAllocModeFromICB( PtrIrpContext, Irp );
621 break;
622 }
623#endif //UDF_READ_ONLY_BUILD
625 if(AcquiredVcb) {
626 UDFReleaseResource(&(Vcb->VCBResource));
627 AcquiredVcb = FALSE;
628 }
629 RC = UDFLockVolume( PtrIrpContext, Irp, GetCurrentPID() );
631 break;
633 if(AcquiredVcb) {
634 UDFReleaseResource(&(Vcb->VCBResource));
635 AcquiredVcb = FALSE;
636 }
637 RC = UDFUnlockVolume( PtrIrpContext, Irp, GetCurrentPID() );
639 break;
640#ifndef UDF_READ_ONLY_BUILD
642 RC = STATUS_SUCCESS;
643
644 Irp->IoStatus.Information = 0;
645 Irp->IoStatus.Status = STATUS_SUCCESS;
647 break;
648#endif //UDF_READ_ONLY_BUILD
650
651 PUDF_GET_VERSION_OUT udf_ver;
652
653 UDFPrint(("UDFUserFsCtrlRequest: IOCTL_UDF_GET_VERSION\n"));
654
655 Irp->IoStatus.Information = 0;
657
658 if(!IrpSp->Parameters.DeviceIoControl.OutputBufferLength) {
659 UDFPrint(("!OutputBufferLength\n"));
661 }
662 // Check the size of the output buffer.
663 if(IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(UDF_GET_VERSION_OUT)) {
664 UDFPrint(("OutputBufferLength < %x\n", sizeof(UDF_GET_VERSION_OUT)));
666 }
667
668 udf_ver = (PUDF_GET_VERSION_OUT)(Irp->AssociatedIrp.SystemBuffer);
669 if(!udf_ver) {
670 UDFPrint(("!udf_ver\n"));
672 }
673
674 RtlZeroMemory(udf_ver, IrpSp->Parameters.DeviceIoControl.OutputBufferLength);
675
676 udf_ver->header.Length = sizeof(UDF_GET_VERSION_OUT);
677 udf_ver->header.DriverVersionMj = 0x00010005;
678 udf_ver->header.DriverVersionMn = 0x12;
679 udf_ver->header.DriverVersionBuild = UDF_CURRENT_BUILD;
680
681 udf_ver->FSVersionMj = Vcb->CurrentUDFRev >> 8;
682 udf_ver->FSVersionMn = Vcb->CurrentUDFRev & 0xff;
683 udf_ver->FSFlags = Vcb->UserFSFlags;
684 if( ((Vcb->origIntegrityType == INTEGRITY_TYPE_OPEN) &&
685 (Vcb->CompatFlags & UDF_VCB_IC_DIRTY_RO))
686 ||
687 (Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) ) {
688 UDFPrint((" UDF_USER_FS_FLAGS_RO\n"));
689 udf_ver->FSFlags |= UDF_USER_FS_FLAGS_RO;
690 }
691 if(Vcb->VCBFlags & UDF_VCB_FLAGS_OUR_DEVICE_DRIVER) {
692 UDFPrint((" UDF_USER_FS_FLAGS_OUR_DRIVER\n"));
694 }
695 if(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK) {
696 UDFPrint((" UDF_USER_FS_FLAGS_RAW\n"));
697 udf_ver->FSFlags |= UDF_USER_FS_FLAGS_RAW;
698 }
699 if(Vcb->VCBFlags & UDF_VCB_FLAGS_MEDIA_READ_ONLY) {
700 UDFPrint((" UDF_USER_FS_FLAGS_MEDIA_RO\n"));
702 }
703 if(Vcb->FP_disc) {
704 UDFPrint((" UDF_USER_FS_FLAGS_FP\n"));
705 udf_ver->FSFlags |= UDF_USER_FS_FLAGS_FP;
706 }
707 udf_ver->FSCompatFlags = Vcb->CompatFlags;
708
709 udf_ver->FSCfgVersion = Vcb->CfgVersion;
710
711 Irp->IoStatus.Information = sizeof(UDF_GET_VERSION_OUT);
712 RC = STATUS_SUCCESS;
714
715 break; }
717
718 PUDF_SET_OPTIONS_IN udf_opt;
719 BOOLEAN PrevVerifyOnWrite;
720
721 UDFPrint(("UDF: IOCTL_UDF_SET_OPTIONS\n"));
722
723 Irp->IoStatus.Information = 0;
725
726 if(IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(UDF_SET_OPTIONS_IN)) {
727 UDFPrint(("InputBufferLength < %x\n", sizeof(UDF_SET_OPTIONS_IN)));
729 }
730
731 udf_opt = (PUDF_SET_OPTIONS_IN)(Irp->AssociatedIrp.SystemBuffer);
732 if(!udf_opt) {
733 UDFPrint(("!udf_opt\n"));
735 }
736
738 UDFPrint(("invalid opt target\n"));
740 }
741
742 if(AcquiredVcb) {
743 UDFReleaseResource(&(Vcb->VCBResource));
744 AcquiredVcb = FALSE;
745 }
746 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
747 AcquiredVcb = TRUE;
748
749 PrevVerifyOnWrite = Vcb->VerifyOnWrite;
750
751 Vcb->Cfg = ((PUCHAR)(udf_opt)) + udf_opt->header.HdrLength;
752 Vcb->CfgLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength - offsetof(UDF_SET_OPTIONS_IN, Data);
753 UDFReadRegKeys(Vcb, TRUE /*update*/, TRUE /*cfg*/);
754 Vcb->Cfg = NULL;
755 Vcb->CfgLength = 0;
756 Vcb->CfgVersion++;
757 //UDFReadRegKeys(Vcb, TRUE /*update*/, TRUE);
758 if(PrevVerifyOnWrite != Vcb->VerifyOnWrite) {
759 if(Vcb->VerifyOnWrite) {
760 UDFVInit(Vcb);
761 } else {
762 WCacheFlushBlocks__(&(Vcb->FastCache), Vcb, 0, Vcb->LastLBA);
763 UDFVFlush(Vcb);
765 }
766 }
767
768 RC = STATUS_SUCCESS;
769 break; }
770#if 0
771 case IOCTL_UDF_GET_OPTIONS_VERSION: {
772
773 PUDF_GET_OPTIONS_VERSION_OUT udf_opt_ver;
774
775 UDFPrint(("UDF: IOCTL_UDF_GET_OPTIONS_VERSION\n"));
776
777 Irp->IoStatus.Information = 0;
779
780 if(IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(UDF_GET_OPTIONS_VERSION_OUT)) {
781 UDFPrint(("OutputBufferLength < %x\n", sizeof(UDF_GET_OPTIONS_VERSION_OUT)));
783 }
784
785 udf_opt_ver = (PUDF_GET_OPTIONS_VERSION_OUT)(Irp->AssociatedIrp.SystemBuffer);
786 if(!udf_opt_ver) {
787 UDFPrint(("!udf_opt-ver\n"));
789 }
790/*
791 if(AcquiredVcb) {
792 UDFReleaseResource(&(Vcb->VCBResource));
793 AcquiredVcb = FALSE;
794 }
795 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
796 AcquiredVcb = TRUE;
797*/
798 udf_opt_ver->CfgVersion = Vcb->CfgVersion;
799 Irp->IoStatus.Information = sizeof(UDF_GET_OPTIONS_VERSION_OUT);
800
801 RC = STATUS_SUCCESS;
802 break; }
803#endif //0
805
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;
810
812
813 UDFPrint(("UDFUserFsCtrlRequest: FSCTL_ALLOW_EXTENDED_DASD_IO\n"));
814 // DASD i/o is always permitted
815 // So, no-op this call
816 RC = STATUS_SUCCESS;
817
818 Irp->IoStatus.Information = 0;
819 Irp->IoStatus.Status = STATUS_SUCCESS;
821 break;
822
824
825 UDFPrint(("UDFUserFsCtrlRequest: FSCTL_IS_VOLUME_DIRTY\n"));
826 // DASD i/o is always permitted
827 // So, no-op this call
828 RC = UDFIsVolumeDirty(PtrIrpContext, Irp);
830 break;
831
835
836 UDFPrint(("UDF Reset/Eject request\n"));
837// PPREVENT_MEDIA_REMOVAL_USER_IN Buf;
838
839 if(Vcb->EjectWaiter) {
840 UDFPrint((" Vcb->EjectWaiter present\n"));
841 Irp->IoStatus.Information = 0;
842 Vcb->EjectWaiter->SoftEjectReq = TRUE;
843 Vcb->SoftEjectReq = TRUE;
846 }
847 UDFPrint((" !Vcb->EjectWaiter\n"));
848 goto ioctl_do_default;
849/*
850 Buf = (PPREVENT_MEDIA_REMOVAL_USER_IN)MyAllocatePool__(NonPagedPool, sizeof(PREVENT_MEDIA_REMOVAL_USER_IN));
851 if(!Buf) try_return(RC = STATUS_INSUFFICIENT_RESOURCES);
852 // Acquire Vcb resource (Shared -> Exclusive)
853 UDFReleaseResource(&(Vcb->VCBResource));
854 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
855
856 Vcb->Vpb->RealDevice->Flags |= DO_VERIFY_VOLUME;
857 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_MOUNTED;
858
859 UDFDoDismountSequence(Vcb, Buf, IoControlCode == IOCTL_CDROM_EJECT_MEDIA);
860 // disable Eject Request Waiter if any
861 MyFreePool__(Buf);
862 // Release the Vcb resource.
863 UDFReleaseResource(&(Vcb->VCBResource));
864 AcquiredVcb = FALSE;
865 UDFStopEjectWaiter(Vcb);
866 CompleteIrp = TRUE;
867 RC = STATUS_SUCCESS;
868 break;*/
869 }
871
872 UDFPrint(("UDF Cdrom Disk Type\n"));
874 // Verify the Vcb in this case to detect if the volume has changed.
875 Irp->IoStatus.Information = 0;
876 RC = UDFVerifyVcb(PtrIrpContext,Vcb);
877 if(!NT_SUCCESS(RC))
878 try_return(RC);
879
880 // Check the size of the output buffer.
881 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CDROM_DISK_DATA_USER_OUT))
883
884 // Copy the data from the Vcb.
885 ((PCDROM_DISK_DATA_USER_OUT)(Irp->AssociatedIrp.SystemBuffer))->DiskData = CDROM_DISK_DATA_TRACK;
886 for(TrackNumber=Vcb->FirstTrackNum; TrackNumber<Vcb->LastTrackNum; TrackNumber++) {
887 if((Vcb->TrackMap[TrackNumber].TrackParam & Trk_QSubChan_Type_Mask) ==
889 ((PCDROM_DISK_DATA_USER_OUT)(Irp->AssociatedIrp.SystemBuffer))->DiskData |= CDROM_DISK_AUDIO_TRACK;
890 break;
891 }
892 }
893
894 Irp->IoStatus.Information = sizeof(CDROM_DISK_DATA_USER_OUT);
895 RC = STATUS_SUCCESS;
896 break;
897 }
898
903 UDFPrint(("UDF Lock/Unlock\n"));
904 PPREVENT_MEDIA_REMOVAL_USER_IN buffer; // user supplied buffer
905 buffer = (PPREVENT_MEDIA_REMOVAL_USER_IN)(Irp->AssociatedIrp.SystemBuffer);
906 if(!buffer) {
907 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) {
908 UDFPrint(("!mounted\n"));
909 goto ioctl_do_default;
910 }
911 UDFPrint(("abort\n"));
913 Irp->IoStatus.Information = 0;
914 UnsafeIoctl = FALSE;
916 break;
917 }
918 if(!buffer->PreventMediaRemoval &&
919 !Vcb->MediaLockCount) {
920
921 UDFPrint(("!locked + unlock req\n"));
922 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) {
923 UDFPrint(("!mounted\n"));
924 goto ioctl_do_default;
925 }
926#if 0
927 // allocate tmp buffer for FSD calls
929 if(!Buf)
931
932 // Acquire Vcb resource (Shared -> Exclusive)
933 UDFInterlockedIncrement((PLONG)&(Vcb->VCBOpenCount));
934 UDFReleaseResource(&(Vcb->VCBResource));
935
936#ifdef UDF_DELAYED_CLOSE
937 // Acquire exclusive access to the Vcb.
939#endif //UDF_DELAYED_CLOSE
940
941 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
942 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
943
945 MyFreePool__(Buf);
946 Buf = NULL;
947 Vcb->MediaLockCount = 0;
948 // Release the Vcb resource.
949 UDFReleaseResource(&(Vcb->VCBResource));
950 AcquiredVcb = FALSE;
951 // disable Eject Request Waiter if any
953#else
954 // just ignore
955#endif
956ignore_lock:
957 UDFPrint(("ignore lock/unlock\n"));
959 Irp->IoStatus.Information = 0;
960 RC = STATUS_SUCCESS;
961 break;
962 }
963 if(buffer->PreventMediaRemoval) {
964 UDFPrint(("lock req\n"));
965 Vcb->MediaLockCount++;
966 Vcb->VCBFlags |= UDF_VCB_FLAGS_MEDIA_LOCKED;
967 UnsafeIoctl = FALSE;
968 } else {
969 UDFPrint(("unlock req\n"));
970 if(Vcb->MediaLockCount) {
971 UDFPrint(("lock count %d\n", Vcb->MediaLockCount));
972 UnsafeIoctl = FALSE;
973 Vcb->MediaLockCount--;
974 }
975 }
976 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) {
977 UDFPrint(("!mounted\n"));
978 goto ioctl_do_default;
979 }
980 goto ignore_lock;
981 }
982 default:
983
984 UDFPrint(("default processing Irp %x, ctx %x, DevIoCtl %x\n", Irp, PtrIrpContext, IoControlCode));
985ioctl_do_default:
986
987 // make sure volume is Sync'ed BEFORE sending unsafe IOCTL
988 if(Vcb && UnsafeIoctl) {
990 UDFPrint((" sync'ed\n"));
991 }
992 // Invoke the lower level driver in the chain.
993 //PtrNextIoStackLocation = IoGetNextIrpStackLocation(Irp);
994 //*PtrNextIoStackLocation = *IrpSp;
996/*
997 // Set a completion routine.
998 IoSetCompletionRoutine(Irp, UDFDevIoctlCompletion, PtrIrpContext, TRUE, TRUE, TRUE);
999 // Send the request.
1000*/
1001 RC = IoCallDriver(Vcb->TargetDeviceObject, Irp);
1002 if(!CompleteIrp) {
1003 // since now we do not use IoSetCompletionRoutine()
1004 UDFReleaseIrpContext(PtrIrpContext);
1005 }
1006 break;
1007 }
1008
1009 if(Vcb && UnsafeIoctl) {
1010 UDFPrint((" set UnsafeIoctl\n"));
1011 Vcb->VCBFlags |= UDF_VCB_FLAGS_UNSAFE_IOCTL;
1012 }
1013
1014try_exit: NOTHING;
1015
1016 } _SEH2_FINALLY {
1017
1018 if(AcquiredVcb) {
1019 UDFReleaseResource(&(Vcb->VCBResource));
1020 AcquiredVcb = FALSE;
1021 }
1022
1023 if(Buf) {
1024 MyFreePool__(Buf);
1025 }
1026
1028 CompleteIrp) {
1029 UDFPrint((" complete Irp %x, ctx %x, status %x, iolen %x\n",
1030 Irp, PtrIrpContext, RC, Irp->IoStatus.Information));
1031 Irp->IoStatus.Status = RC;
1032 // complete the IRP
1034 // Release the IRP context
1035 UDFReleaseIrpContext(PtrIrpContext);
1036 }
1037 } _SEH2_END;
1038
1039 return(RC);
1040} // end UDFCommonDeviceControl()
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
#define try_return(S)
Definition: cdprocs.h:2179
#define SCSIOP_WRITE_CD
Definition: cdrw_hw.h:907
#define Trk_QSubChan_Type_Mask
Definition: cdrw_hw.h:2370
#define SCSIOP_DOORUNLOCK
Definition: cdrw_hw.h:972
#define Trk_QSubChan_Type_Audio
Definition: cdrw_hw.h:2372
#define SCSIOP_SEND_CUE_SHEET
Definition: cdrw_hw.h:949
#define SCSIOP_WRITE6
Definition: cdrw_hw.h:876
#define MODE_PAGE_MRW2
Definition: cdrw_hw.h:843
#define SCSIOP_MEDIUM_REMOVAL
Definition: cdrw_hw.h:902
#define SCSIOP_SEND_DVD_STRUCTURE
Definition: cdrw_hw.h:969
#define SCSIOP_FORMAT_UNIT
Definition: cdrw_hw.h:871
#define SCSIOP_RESERVE_TRACK
Definition: cdrw_hw.h:941
#define MODE_PAGE_WRITE_PARAMS
Definition: cdrw_hw.h:844
#define MODE_PAGE_MRW
Definition: cdrw_hw.h:855
#define SCSIOP_CLOSE_TRACK_SESSION
Definition: cdrw_hw.h:947
#define SCSIOP_BLANK
Definition: cdrw_hw.h:950
#define SCSIOP_DOORLOCK
Definition: cdrw_hw.h:971
#define SCSIOP_WRITE12
Definition: cdrw_hw.h:957
union _CDB * PCDB
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SCSIOP_SET_STREAMING
Definition: cdrw_hw.h:963
#define SCSIOP_MODE_SELECT10
Definition: cdrw_hw.h:943
#define SCSIOP_MODE_SELECT
Definition: cdrw_hw.h:891
#define IOCTL_CDRW_READ_ATIP
Definition: cdrw_usr.h:116
#define IOCTL_CDRW_GET_WRITE_MODE
Definition: cdrw_usr.h:85
#define IOCTL_CDROM_EJECT_MEDIA
Definition: cdrw_usr.h:60
#define IOCTL_CDRW_READ_SESSION_INFO
Definition: cdrw_usr.h:115
#define IOCTL_CDRW_BUFFER_CAPACITY
Definition: cdrw_usr.h:94
#define IOCTL_CDRW_GET_MEDIA_TYPE
Definition: cdrw_usr.h:84
#define IOCTL_CDRW_MODE_SENSE
Definition: cdrw_usr.h:104
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
Definition: cdrw_usr.h:175
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
struct _CDROM_DISK_DATA_USER_OUT * PCDROM_DISK_DATA_USER_OUT
#define IOCTL_CDRW_READ_TOC_EX
Definition: cdrw_usr.h:118
#define IOCTL_CDRW_BLANK
Definition: cdrw_usr.h:88
#define IOCTL_CDRW_LL_READ
Definition: cdrw_usr.h:110
#define IOCTL_DISK_MEDIA_REMOVAL
Definition: cdrw_usr.h:176
#define IOCTL_CDRW_READ_TRACK_INFO
Definition: cdrw_usr.h:92
#define IOCTL_DISK_EJECT_MEDIA
Definition: cdrw_usr.h:177
#define IOCTL_CDRW_LOCK_DOOR
Definition: cdrw_usr.h:79
#define IOCTL_DISK_LOAD_MEDIA
Definition: cdrw_usr.h:178
#define IOCTL_CDRW_READ_PMA
Definition: cdrw_usr.h:114
#define IOCTL_CDRW_GET_DEVICE_NAME
Definition: cdrw_usr.h:121
#define IOCTL_DISK_GET_MEDIA_TYPES
Definition: cdrw_usr.h:182
#define IOCTL_CDRW_RESET_DRIVER
Definition: cdrw_usr.h:96
#define IOCTL_CDRW_GET_SIGNATURE
Definition: cdrw_usr.h:95
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
#define IOCTL_CDROM_LOAD_MEDIA
Definition: cdrw_usr.h:61
#define IOCTL_CDRW_TEST_UNIT_READY
Definition: cdrw_usr.h:101
#define IOCTL_DVD_READ_STRUCTURE
Definition: cdrw_usr.h:157
#define IOCTL_CDRW_GET_DEVICE_INFO
Definition: cdrw_usr.h:119
#define IOCTL_CDROM_MEDIA_REMOVAL
Definition: cdrw_usr.h:59
#define IOCTL_CDRW_READ_CD_TEXT
Definition: cdrw_usr.h:117
#define IOCTL_CDRW_LL_WRITE
Definition: cdrw_usr.h:91
#define IOCTL_CDRW_GET_EVENT
Definition: cdrw_usr.h:120
#define IOCTL_CDRW_READ_FULL_TOC
Definition: cdrw_usr.h:113
#define IOCTL_CDRW_READ_DISC_INFO
Definition: cdrw_usr.h:93
#define IOCTL_CDRW_GET_LAST_ERROR
Definition: cdrw_usr.h:103
#define IOCTL_CDRW_GET_MEDIA_TYPE_EX
Definition: cdrw_usr.h:123
#define IOCTL_CDRW_SET_SPEED
Definition: cdrw_usr.h:80
#define IOCTL_CDRW_FORMAT_UNIT
Definition: cdrw_usr.h:98
#define IOCTL_STORAGE_GET_MEDIA_TYPES_EX
Definition: cdrw_usr.h:190
#define IOCTL_CDRW_GET_CAPABILITIES
Definition: cdrw_usr.h:82
struct _VCB * PVCB
Definition: fatstruc.h:557
VOID UDFCloseAllDelayed(IN PVCB Vcb)
Definition: close.cpp:754
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS UDFGetFileAllocModeFromICB(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: devcntrl.cpp:1132
#define UDF_CURRENT_BUILD
Definition: devcntrl.cpp:21
NTSTATUS UDFSetFileAllocModeFromICB(PtrUDFIrpContext IrpContext, PIRP Irp)
Definition: devcntrl.cpp:1169
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
VOID UDFReadRegKeys(PVCB Vcb, BOOLEAN Update, BOOLEAN UseCfg)
Definition: misc.cpp:1780
VOID UDFDestroyZones(VOID)
Definition: misc.cpp:177
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
Definition: misc.cpp:1086
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
#define INTEGRITY_TYPE_OPEN
Definition: ecma_167.h:357
#define GetCurrentPID()
Definition: env_spec.h:152
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
#define UDFDeleteResource(Resource)
Definition: env_spec_w32.h:663
#define UDFAcquireResourceShared(Resource, CanWait)
Definition: env_spec_w32.h:658
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define UDFInterlockedDecrement(addr)
Definition: env_spec_w32.h:677
#define NonPagedPool
Definition: env_spec_w32.h:307
#define UDFInterlockedIncrement(addr)
Definition: env_spec_w32.h:675
#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
Definition: ntddk_ex.h:208
#define IOCTL_DISK_GET_PARTITION_INFO_EX
Definition: ntddk_ex.h:206
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
Definition: ntddk_ex.h:207
#define IOCTL_STORAGE_CHECK_VERIFY2
Definition: ntddk_ex.h:212
#define IOCTL_STORAGE_LOAD_MEDIA2
Definition: ntddk_ex.h:210
ULONG UDFFlushLogicalVolume(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PVCB Vcb, IN ULONG FlushFlags)
Definition: flush.cpp:506
NTSTATUS UDFUnlockVolume(IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG PID)
Definition: fscntrl.cpp:1859
NTSTATUS UDFLockVolume(IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG PID)
Definition: fscntrl.cpp:1724
NTSTATUS UDFGetRetrievalPointers(IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG Special)
Definition: fscntrl.cpp:2205
NTSTATUS UDFIsVolumeDirty(IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
Definition: fscntrl.cpp:2367
NTSTATUS UDFInvalidateVolumes(IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
Definition: fscntrl.cpp:2441
GLuint buffer
Definition: glext.h:5915
#define NOTHING
Definition: input_list.c:10
if(dx< 0)
Definition: linetemp.h:194
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:44
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:91
#define UserMode
Definition: asm.h:35
#define IOCTL_CDROM_GET_LAST_SESSION
Definition: ntddcdrm.h:64
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX
Definition: ntddcdrm.h:76
#define IOCTL_CDROM_SEEK_AUDIO_MSF
Definition: ntddcdrm.h:37
#define IOCTL_CDROM_READ_TOC_EX
Definition: ntddcdrm.h:79
#define CDROM_DISK_DATA_TRACK
Definition: ntddcdrm.h:146
#define IOCTL_CDROM_GET_VOLUME
Definition: ntddcdrm.h:49
#define IOCTL_CDROM_CHECK_VERIFY
Definition: ntddcdrm.h:103
#define IOCTL_CDROM_DISK_TYPE
Definition: ntddcdrm.h:70
#define IOCTL_CDROM_PAUSE_AUDIO
Definition: ntddcdrm.h:43
#define CDROM_DISK_AUDIO_TRACK
Definition: ntddcdrm.h:145
#define IOCTL_CDROM_SET_VOLUME
Definition: ntddcdrm.h:55
#define IOCTL_CDROM_STOP_AUDIO
Definition: ntddcdrm.h:40
#define IOCTL_CDROM_GET_CONTROL
Definition: ntddcdrm.h:61
#define IOCTL_CDROM_READ_Q_CHANNEL
Definition: ntddcdrm.h:58
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY
Definition: ntddcdrm.h:73
#define IOCTL_CDROM_GET_CONFIGURATION
Definition: ntddcdrm.h:82
#define IOCTL_CDROM_PLAY_AUDIO_MSF
Definition: ntddcdrm.h:52
#define IOCTL_CDROM_RESUME_AUDIO
Definition: ntddcdrm.h:46
#define IOCTL_CDROM_READ_TOC
Definition: ntddcdrm.h:34
#define IOCTL_CDROM_RAW_READ
Definition: ntddcdrm.h:67
#define IOCTL_DISK_GET_DRIVE_LAYOUT
Definition: ntdddisk.h:91
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:106
#define IOCTL_STORAGE_CHECK_VERIFY
Definition: ntddstor.h:98
#define IOCTL_STORAGE_LOAD_MEDIA
Definition: ntddstor.h:110
#define IOCTL_STORAGE_GET_MEDIA_TYPES
Definition: ntddstor.h:131
#define IOCTL_STORAGE_EJECT_MEDIA
Definition: ntddstor.h:107
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:1056
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
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)
Definition: obref.c:494
#define Vcb
Definition: cdprocs.h:1415
OSSTATUS UDFDoDismountSequence(IN PVCB Vcb, IN PPREVENT_MEDIA_REMOVAL_USER_IN Buf, IN BOOLEAN Eject)
Definition: phys_eject.cpp:704
VOID UDFStopEjectWaiter(PVCB Vcb)
Definition: phys_eject.cpp:673
NTSTATUS UDFVerifyVcb(IN PtrUDFIrpContext IrpContext, IN PVCB Vcb)
Definition: verfysup.cpp:37
#define UDFCloseAllSystemDelayedInDir(Vcb, FI)
Definition: protos.h:99
#define FSCTL_IS_VOLUME_DIRTY
Definition: winioctl.h:755
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:166
#define _SEH2_FINALLY
Definition: pseh2_64.h:114
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define FSCTL_ALLOW_EXTENDED_DASD_IO
Definition: winioctl.h:124
VOID UDFVFlush(IN PVCB Vcb)
Definition: remap.cpp:742
VOID UDFVRelease(IN PVCB Vcb)
Definition: remap.cpp:132
OSSTATUS UDFVInit(IN PVCB Vcb)
Definition: remap.cpp:54
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
Definition: scratch.h:159
#define IOCTL_SCSI_PASS_THROUGH
Definition: scsi_port.h:47
struct _SCSI_PASS_THROUGH * PSCSI_PASS_THROUGH
#define IOCTL_SCSI_PASS_THROUGH_DIRECT
Definition: scsi_port.h:51
#define offsetof(TYPE, MEMBER)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _UDFContextControlBlock * PtrUDFCCB
#define UDF_NODE_TYPE_VCB
Definition: struct.h:61
PVCB Vcb
Definition: cdstruc.h:933
struct _FCB::@731::@734 Fcb
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@1581::@1582 DeviceIoControl
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
PVOID AutoFormatCount
Definition: udf_common.h:629
uint32 UDFFlags
Definition: udf_common.h:627
PDEVICE_OBJECT TargetDeviceObject
Definition: struct.h:374
struct _UDF_GET_VERSION_OUT::@972 header
struct _UDF_SET_OPTIONS_IN::@973 header
Definition: cdstruc.h:498
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
int32_t * PLONG
Definition: typedefs.h:58
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define UDF_DATA_FLAGS_RESOURCE_INITIALIZED
Definition: udf_common.h:634
#define UDF_VCB_IC_DIRTY_RO
Definition: udf_common.h:516
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
Definition: udf_common.h:459
#define UDF_DATA_FLAGS_ZONES_INITIALIZED
Definition: udf_common.h:635
#define UDF_VCB_FLAGS_UNSAFE_IOCTL
Definition: udf_common.h:488
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
Definition: udf_common.h:463
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
#define UDF_VCB_FLAGS_MEDIA_READ_ONLY
Definition: udf_common.h:481
#define UDF_VCB_FLAGS_OUR_DEVICE_DRIVER
Definition: udf_common.h:466
#define UDF_VCB_FLAGS_MEDIA_LOCKED
Definition: udf_common.h:469
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
UDFData UDFGlobalData
Definition: udfinit.cpp:25
#define UDFClearFlag(Flag, Value)
Definition: udffs.h:190
#define UDFPrint(Args)
Definition: udffs.h:223
#define UDF_USER_FS_FLAGS_MEDIA_RO
Definition: udfpubl.h:111
#define IOCTL_UDF_SET_FILE_ALLOCATION_MODE
Definition: udfpubl.h:41
struct _UDF_GET_VERSION_OUT UDF_GET_VERSION_OUT
#define IOCTL_UDF_SET_OPTIONS
Definition: udfpubl.h:50
#define IOCTL_UDF_REGISTER_AUTOFORMAT
Definition: udfpubl.h:49
#define UDF_USER_FS_FLAGS_RAW
Definition: udfpubl.h:108
#define IOCTL_UDF_SET_NOTIFICATION_EVENT
Definition: udfpubl.h:47
#define IOCTL_UDF_GET_VERSION
Definition: udfpubl.h:46
#define IOCTL_UDF_GET_RETRIEVAL_POINTERS
Definition: udfpubl.h:39
#define IOCTL_UDF_INVALIDATE_VOLUMES
Definition: udfpubl.h:38
struct _UDF_SET_OPTIONS_IN * PUDF_SET_OPTIONS_IN
#define UDF_USER_FS_FLAGS_OUR_DRIVER
Definition: udfpubl.h:109
#define UDF_SET_OPTIONS_FLAG_TEMPORARY
Definition: udfpubl.h:132
struct _UDF_GET_VERSION_OUT * PUDF_GET_VERSION_OUT
#define IOCTL_UDF_GET_SPEC_RETRIEVAL_POINTERS
Definition: udfpubl.h:45
#define IOCTL_UDF_IS_VOLUME_JUST_MOUNTED
Definition: udfpubl.h:48
#define UDF_USER_FS_FLAGS_FP
Definition: udfpubl.h:110
#define UDF_USER_FS_FLAGS_RO
Definition: udfpubl.h:107
#define IOCTL_UDF_GET_FILE_ALLOCATION_MODE
Definition: udfpubl.h:40
#define IOCTL_UDF_LOCK_VOLUME_BY_PID
Definition: udfpubl.h:42
#define IOCTL_UDF_DISABLE_DRIVER
Definition: udfpubl.h:36
#define IOCTL_UDF_UNLOCK_VOLUME_BY_PID
Definition: udfpubl.h:43
#define UDF_SET_OPTIONS_FLAG_MASK
Definition: udfpubl.h:136
#define IOCTL_UDF_SEND_LICENSE_KEY
Definition: udfpubl.h:44
Definition: cdrw_hw.h:28
struct _CDB::_CDB6 CDB6
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_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
* PFILE_OBJECT
Definition: iotypes.h:1998
#define IO_DISK_INCREMENT
Definition: iotypes.h:600
#define ObDereferenceObject
Definition: obfuncs.h:203
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by UDFDeviceControl().

◆ UDFDeviceControl()

NTSTATUS NTAPI UDFDeviceControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 81 of file devcntrl.cpp.

84{
86 PtrUDFIrpContext PtrIrpContext = NULL;
87 BOOLEAN AreWeTopLevel = FALSE;
88
89 TmPrint(("UDFDeviceControl: \n"));
90
93 ASSERT(Irp);
94
95 // set the top level context
96 AreWeTopLevel = UDFIsIrpTopLevel(Irp);
97 //ASSERT(!UDFIsFSDevObj(DeviceObject));
98
99 _SEH2_TRY {
100
101 // get an IRP context structure and issue the request
102 PtrIrpContext = UDFAllocateIrpContext(Irp, DeviceObject);
103 if(PtrIrpContext) {
104 RC = UDFCommonDeviceControl(PtrIrpContext, Irp);
105 } else {
107 Irp->IoStatus.Status = RC;
108 Irp->IoStatus.Information = 0;
109 // complete the IRP
111 }
112
114
115 RC = UDFExceptionHandler(PtrIrpContext, Irp);
116
118 } _SEH2_END;
119
120 if (AreWeTopLevel) {
122 }
123
125
126 return(RC);
127} // end UDFDeviceControl()
NTSTATUS NTAPI UDFCommonDeviceControl(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: devcntrl.cpp:149
NTSTATUS UDFExceptionHandler(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: misc.cpp:358
BOOLEAN __fastcall UDFIsIrpTopLevel(PIRP Irp)
Definition: misc.cpp:228
VOID UDFLogEvent(NTSTATUS UDFEventLogId, NTSTATUS RC)
Definition: misc.cpp:575
PtrUDFIrpContext UDFAllocateIrpContext(PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
Definition: misc.cpp:985
long UDFExceptionFilter(PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
Definition: misc.cpp:265
#define TmPrint(_x_)
Definition: env_spec_w32.h:290
#define UDF_ERROR_INTERNAL_ERROR
Definition: errmsg.h:71
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by UDFInitializeFunctionPointers().

◆ UDFDevIoctlCompletion()

NTSTATUS NTAPI UDFDevIoctlCompletion ( PDEVICE_OBJECT  PtrDeviceObject,
PIRP  Irp,
VOID Context 
)

Definition at line 1059 of file devcntrl.cpp.

1063{
1064/* PIO_STACK_LOCATION IrpSp = NULL;
1065 ULONG IoControlCode = 0;*/
1066 PtrUDFIrpContext PtrIrpContext = (PtrUDFIrpContext)Context;
1067
1068 UDFPrint(("UDFDevIoctlCompletion Irp %x, ctx %x\n", Irp, Context));
1069 if (Irp->PendingReturned) {
1070 UDFPrint((" IoMarkIrpPending\n"));
1072 }
1073
1074 UDFReleaseIrpContext(PtrIrpContext);
1075/* if(Irp->IoStatus.Status == STATUS_SUCCESS) {
1076 IrpSp = IoGetCurrentIrpStackLocation(Irp);
1077 IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
1078
1079 switch(IoControlCode) {
1080 case IOCTL_CDRW_RESET_DRIVER: {
1081 Vcb->MediaLockCount = 0;
1082 }
1083 }
1084 }*/
1085
1086 return STATUS_SUCCESS;
1087} // end UDFDevIoctlCompletion()
IoMarkIrpPending(Irp)
struct _UDFIrpContext * PtrUDFIrpContext

◆ UDFGetFileAllocModeFromICB()

NTSTATUS UDFGetFileAllocModeFromICB ( PtrUDFIrpContext  PtrIrpContext,
PIRP  Irp 
)

Definition at line 1132 of file devcntrl.cpp.

1136{
1139
1140// PVCB Vcb;
1141 PtrUDFFCB Fcb;
1142 PtrUDFCCB Ccb;
1144
1145 UDFPrint(("UDFGetFileAllocModeFromICB\n"));
1146
1147 // Decode the file object, the only type of opens we accept are
1148 // user volume opens.
1149 Ccb = (PtrUDFCCB)(IrpSp->FileObject->FsContext2);
1150 Fcb = Ccb->Fcb;
1151// Vcb = Fcb->Vcb;
1152
1153 Irp->IoStatus.Information = 0;
1154 if(IrpSp->Parameters.FileSystemControl.OutputBufferLength < sizeof(UDF_GET_FILE_ALLOCATION_MODE_OUT))
1156
1157 OutputBuffer = (PUDF_GET_FILE_ALLOCATION_MODE_OUT)(Irp->AssociatedIrp.SystemBuffer);
1158 if(!OutputBuffer)
1160
1161 OutputBuffer->AllocMode = UDFGetFileICBAllocMode__(Fcb->FileInfo);
1162 Irp->IoStatus.Information = sizeof(UDF_GET_FILE_ALLOCATION_MODE_OUT);
1163
1164 return STATUS_SUCCESS;
1165} // end UDFGetFileAllocModeFromICB()
struct _IO_STACK_LOCATION::@3980::@3995 FileSystemControl
#define UDFGetFileICBAllocMode__(fi)
Definition: udf_info.h:1081
#define PEXTENDED_IO_STACK_LOCATION
Definition: udffs.h:119
struct _UDF_GET_FILE_ALLOCATION_MODE_OUT UDF_GET_FILE_ALLOCATION_MODE_OUT
struct _UDF_GET_FILE_ALLOCATION_MODE_OUT * PUDF_GET_FILE_ALLOCATION_MODE_OUT
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863

Referenced by UDFCommonDeviceControl().

◆ UDFProcessLicenseKey()

NTSTATUS UDFProcessLicenseKey ( PtrUDFIrpContext  IrpContext,
PIRP  Irp 
)

◆ UDFSetFileAllocModeFromICB()

NTSTATUS UDFSetFileAllocModeFromICB ( PtrUDFIrpContext  IrpContext,
PIRP  Irp 
)

Definition at line 1169 of file devcntrl.cpp.

1173{
1176
1177 PVCB Vcb;
1178 PtrUDFFCB Fcb;
1179 PtrUDFCCB Ccb;
1181 NTSTATUS RC;
1182 UCHAR AllocMode;
1183
1184 UDFPrint(("UDFSetFileAllocModeFromICB\n"));
1185
1186 Ccb = (PtrUDFCCB)(IrpSp->FileObject->FsContext2);
1187 Fcb = Ccb->Fcb;
1188 Vcb = Fcb->Vcb;
1189
1190 Irp->IoStatus.Information = 0;
1191 if(IrpSp->Parameters.FileSystemControl.InputBufferLength < sizeof(UDF_SET_FILE_ALLOCATION_MODE_IN))
1193
1194 InputBuffer = (PUDF_SET_FILE_ALLOCATION_MODE_IN)(Irp->AssociatedIrp.SystemBuffer);
1195 if(!InputBuffer)
1197
1198 UDFFlushAFile(Fcb, Ccb, &(Irp->IoStatus), 0);
1199 RC = Irp->IoStatus.Status;
1200 if(!NT_SUCCESS(RC))
1201 return RC;
1202
1203 if(InputBuffer->AllocMode != ICB_FLAG_AD_IN_ICB) {
1204 AllocMode = UDFGetFileICBAllocMode__(Fcb->FileInfo);
1205 if(AllocMode == ICB_FLAG_AD_IN_ICB) {
1206 RC = UDFConvertFEToNonInICB(Vcb, Fcb->FileInfo, InputBuffer->AllocMode);
1207 } else
1208 if(AllocMode != InputBuffer->AllocMode) {
1210 } else {
1211 RC = STATUS_SUCCESS;
1212 }
1213 } else {
1215 }
1216
1217 return STATUS_SUCCESS;
1218} // end UDFSetFileAllocModeFromICB()
#define ICB_FLAG_AD_IN_ICB
Definition: ecma_167.h:496
ULONG UDFFlushAFile(IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
Definition: flush.cpp:288
OSSTATUS UDFConvertFEToNonInICB(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint8 NewAllocMode)
Definition: udf_info.cpp:5358
PUDF_GET_FILE_ALLOCATION_MODE_OUT PUDF_SET_FILE_ALLOCATION_MODE_IN
Definition: udfpubl.h:62
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

Referenced by UDFCommonDeviceControl().