41#define TOC_DATA_TRACK 0x04
42#define TOC_LAST_TRACK 0xaa
45#define DEFAULT_STRING_SIZE 50
60 DeviceExtension->VolumeObject =
NULL;
61 DeviceExtension->ChangeCount = 0;
62 DeviceExtension->GlobalName.Buffer =
NULL;
63 DeviceExtension->GlobalName.MaximumLength = 0;
64 DeviceExtension->GlobalName.Length = 0;
65 DeviceExtension->ImageName.Buffer =
NULL;
66 DeviceExtension->ImageName.MaximumLength = 0;
67 DeviceExtension->ImageName.Length = 0;
143 if (DeviceExtension->VolumeObject !=
NULL)
146 DeviceExtension->VolumeObject =
NULL;
190 WCHAR DriveLetter[3], CurLetter;
234 FALSE, &LocalDeviceObject);
248 for (CurLetter =
Letter; CurLetter >=
'A'; CurLetter--)
253 DeviceExtension->Flags = 0;
256 DeviceExtension->GlobalName.Length = 0;
263 DriveLetter[0] = CurLetter;
264 DriveLetter[1] =
L':';
284 *EffectiveLetter = CurLetter;
303 if (CurLetter == (
L'A' - 1))
348 Status = ZwQueryInformationFile(ImgHandle, &
IoStatus, &FileStdInfo,
352 DPRINT1(
"Failed to query image information\n");
365 DeviceExtension->SectorSize = 2048;
369 DeviceExtension->SectorSize =
Buffer[1];
373 if (DeviceExtension->SectorSize == 512)
375 DeviceExtension->SectorShift = 9;
379 for (
i = 512, SectorShift = 9;
i < DeviceExtension->SectorSize;
i =
i * 2, ++SectorShift);
380 if (
i == DeviceExtension->SectorSize)
382 DeviceExtension->SectorShift = SectorShift;
386 DeviceExtension->SectorShift = 11;
392 (
PVOID *)&DeviceExtension->VolumeObject,
NULL);
396 DeviceExtension->VolumeObject =
NULL;
402 ++DeviceExtension->ChangeCount;
420 WCHAR EffectiveLetter;
437 WCHAR PathBuffer[100], ResBuffer[100];
454 Path.Buffer = PathBuffer;
456 Path.MaximumLength =
sizeof(PathBuffer);
462 ResString.MaximumLength =
sizeof(ResBuffer);
488 Irp->IoStatus.Information = 0;
507 if (LowerIrp ==
NULL)
516 LowerIrp->MdlAddress =
Mdl;
520 LowerIrp->UserEvent =
Event;
523 LowerIrp->Tail.Overlay.OriginalFileObject =
File;
531 Stack->Parameters.Read.ByteOffset.QuadPart =
Offset->QuadPart;
552 if (DeviceExtension->VolumeObject ==
NULL)
570 if (
Stack->Parameters.Read.Length >
Irp->MdlAddress->ByteCount)
600 if (
Stack->Parameters.Read.ByteOffset.QuadPart / DeviceExtension->SectorSize < 0x20)
664 if (
Stack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(
WCHAR))
683 if (DeviceExtension->VolumeObject ==
NULL)
703 DiskGeo =
Irp->AssociatedIrp.SystemBuffer;
706 DiskGeo->
SectorsPerTrack = DeviceExtension->VolumeSize.QuadPart >> DeviceExtension->SectorShift;
723 if (DeviceExtension->VolumeObject ==
NULL)
737 Buffer =
Irp->AssociatedIrp.SystemBuffer;
740 *
Buffer = DeviceExtension->ChangeCount;
760 if (DeviceExtension->VolumeObject !=
NULL)
778 Local[2] =
Address % 4500 / 75;
779 Local[3] =
Address + 108 * Local[1] - 75 * Local[2];
781 return *(
ULONG *)(&Local[0]);
791 TrackData->
Adr = Adr;
805 if (DeviceExtension->VolumeObject ==
NULL)
819 if (
Stack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(
CDROM_TOC))
825 Toc =
Irp->AssociatedIrp.SystemBuffer;
848 if (DeviceExtension->VolumeObject ==
NULL)
874 TocEx =
Irp->AssociatedIrp.SystemBuffer;
900 Toc =
Irp->AssociatedIrp.SystemBuffer;
923 if (DeviceExtension->VolumeObject ==
NULL)
943 Toc =
Irp->AssociatedIrp.SystemBuffer;
964 if (
Stack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(
DRIVES_LIST))
974 for (CurrentDO =
DeviceObject->DriverObject->DeviceObject; CurrentDO !=
NULL;
975 CurrentDO = CurrentDO->NextDevice)
979 if (DeviceExtension->GlobalName.Length !=
981 L"\\??\\VirtualCdRom",
982 DeviceExtension->GlobalName.Length))
1003 if (
Stack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(
IMAGE_PATH))
1010 ImagePath =
Irp->AssociatedIrp.SystemBuffer;
1011 ImagePath->
Mounted = (DeviceExtension->VolumeObject !=
NULL);
1012 ImagePath->
Length = DeviceExtension->ImageName.Length;
1014 if (DeviceExtension->ImageName.Length != 0)
1016 RtlCopyMemory(ImagePath->
Path, DeviceExtension->ImageName.Buffer, DeviceExtension->ImageName.Length);
1036 if (DeviceExtension->VolumeObject !=
NULL)
1040 ++DeviceExtension->ChangeCount;
1041 DeviceExtension->VolumeObject =
NULL;
1094 switch (
Stack->Parameters.DeviceIoControl.IoControlCode)
1106 MountParameters =
Irp->AssociatedIrp.SystemBuffer;
1110 DeviceExtension->Flags = MountParameters->
Flags;
1159 if (DeviceExtension->ImageName.Buffer ==
NULL || DeviceExtension->VolumeObject !=
NULL)
1171 DPRINT1(
"IOCTL: %x not supported\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
vector< wstring > DrivesList
PRTL_UNICODE_STRING_BUFFER Path
#define IOCTL_CDROM_EJECT_MEDIA
#define IOCTL_DISK_CHECK_VERIFY
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define FILE_ATTRIBUTE_NORMAL
DRIVER_INITIALIZE DriverEntry
#define ExAllocatePoolWithTag(hernya, size, tag)
#define PsGetCurrentThread()
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define RtlCompareMemory(s1, s2, l)
#define KeInitializeEvent(pEvt, foo, foo2)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define DO_DEVICE_INITIALIZING
#define ClearFlag(_F, _SF)
#define BooleanFlagOn(F, SF)
#define FILE_SYNCHRONOUS_IO_NONALERT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
#define MAXIMUM_CDROM_SIZE
#define OBJ_CASE_INSENSITIVE
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define EXCEPTION_EXECUTE_HANDLER
#define ExFreePoolWithTag(_P, _T)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject(_Out_ PHANDLE SymbolicLinkHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define RTL_QUERY_REGISTRY_SUBKEY
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_REGISTRY_ABSOLUTE
#define FILE_READ_ONLY_DEVICE
#define RTL_QUERY_REGISTRY_DIRECT
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
#define FILE_FLOPPY_DISKETTE
#define CDROM_READ_TOC_EX_FORMAT_SESSION
#define IOCTL_CDROM_GET_LAST_SESSION
#define ADR_NO_MODE_INFORMATION
#define IOCTL_CDROM_READ_TOC_EX
#define CDROM_READ_TOC_EX_FORMAT_FULL_TOC
#define IOCTL_CDROM_CHECK_VERIFY
#define CDROM_READ_TOC_EX_FORMAT_PMA
#define CDROM_READ_TOC_EX_FORMAT_TOC
#define CDROM_READ_TOC_EX_FORMAT_ATIP
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY
#define IOCTL_CDROM_READ_TOC
#define CDROM_READ_TOC_EX_FORMAT_CDTEXT
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IOCTL_STORAGE_LOAD_MEDIA
#define IOCTL_STORAGE_EJECT_MEDIA
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
#define IoCompleteRequest
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
#define STATUS_OBJECT_NAME_EXISTS
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)
#define FILE_DEVICE_CD_ROM
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define IRP_MJ_DEVICE_CONTROL
#define FileStandardInformation
#define STATUS_DEVICE_NOT_READY
#define STATUS_BUFFER_TOO_SMALL
convenient loading of string resources
UCHAR FirstCompleteSession
UCHAR LastCompleteSession
TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]
PFILE_OBJECT VolumeObject
PDEVICE_OBJECT DeviceObject
UNICODE_STRING GlobalName
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_UNRECOGNIZED_MEDIA
#define STATUS_MEDIA_WRITE_PROTECTED
#define STATUS_INVALID_PARAMETER
#define STATUS_IO_TIMEOUT
#define STATUS_WRONG_VOLUME
#define STATUS_NO_MEDIA_IN_DEVICE
#define STATUS_INFO_LENGTH_MISMATCH
#define STATUS_VERIFY_REQUIRED
#define STATUS_INSUFFICIENT_RESOURCES
#define IOCTL_VCDROM_DELETE_DRIVE
#define MOUNT_FLAG_SUPP_UDF
#define IOCTL_VCDROM_GET_IMAGE_PATH
#define MOUNT_FLAG_SUPP_JOLIET
#define IOCTL_VCDROM_MOUNT_IMAGE
#define IOCTL_VCDROM_CREATE_DRIVE
#define IOCTL_VCDROM_ENUMERATE_DRIVES
NTSTATUS ViCheckVerify(PDEVICE_OBJECT DeviceObject, PIRP Irp)
VOID ViInitializeDeviceExtension(PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI VcdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
struct _DEVICE_EXTENSION DEVICE_EXTENSION
NTSTATUS ViGetImagePath(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS ViCreateDriveLetter(PDRIVER_OBJECT DriverObject, WCHAR Letter, WCHAR *EffectiveLetter, PDEVICE_OBJECT *DeviceObject)
VOID ViFillInTrackData(PTRACK_DATA TrackData, UCHAR Control, UCHAR Adr, UCHAR TrackNumber, ULONG Address)
NTSTATUS ViEjectMedia(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS ViEnumerateDrives(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS ViRemountMedia(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS ViReadFile(PFILE_OBJECT File, PMDL Mdl, PLARGE_INTEGER Offset, PKEVENT Event, ULONG Length, PIO_STATUS_BLOCK IoStatusBlock)
VOID ViFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS ViGetLastSession(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI VcdHandle(PDEVICE_OBJECT DeviceObject, PIRP Irp)
VOID ViLoadImagesFromRegistry(PDRIVER_OBJECT DriverObject, LPCWSTR RegistryPath)
NTSTATUS ViCreateDevice(PDRIVER_OBJECT DriverObject, PIRP Irp)
NTSTATUS ViReadTocEx(PDEVICE_OBJECT DeviceObject, PIRP Irp)
#define DEFAULT_STRING_SIZE
NTSTATUS ViAllocateUnicodeString(USHORT BufferLength, PUNICODE_STRING UnicodeString)
VOID NTAPI VcdUnload(PDRIVER_OBJECT DriverObject)
NTSTATUS ViIssueMountImage(PDEVICE_OBJECT DeviceObject, PUNICODE_STRING Image, PIRP Irp)
ULONG ViComputeAddress(ULONG Address)
NTSTATUS ViVerifyVolume(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS ViDeleteDevice(PDEVICE_OBJECT DeviceObject, PIRP Irp)
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
VOID ViCreateDriveAndMountImage(PDRIVER_OBJECT DriverObject, WCHAR Letter, LPCWSTR ImagePath)
NTSTATUS ViSetIoStatus(NTSTATUS Status, ULONG_PTR Information, PIRP Irp)
NTSTATUS ViMountImage(PDEVICE_OBJECT DeviceObject, PUNICODE_STRING Image)
NTSTATUS ViReadToc(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS ViGetDriveGeometry(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI VcdDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
_In_ WDF_WMI_PROVIDER_CONTROL Control
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define SL_OVERRIDE_VERIFY_VOLUME
#define IO_DISK_INCREMENT
#define IRP_SYNCHRONOUS_PAGING_IO
#define MDL_ALLOCATED_FIXED_SIZE
#define MDL_MAPPED_TO_SYSTEM_VA
#define ObDereferenceObject