38#define VCB_STATE_LOCKED 0x00000001
39#define VCB_STATE_DISMOUNTED 0x00000002
103 Vcb->LocalVpb->Size =
sizeof(
VPB);
104 Vcb->LocalVpb->RealDevice =
Vcb->Vpb->RealDevice;
105 Vcb->LocalVpb->DeviceObject =
NULL;
107 Vcb->Vpb->RealDevice->Vpb =
Vcb->LocalVpb;
124 Vpb->Flags &= ~VPB_MOUNTED;
145 else if (
Vcb->Vpb->ReferenceCount == 0)
178 IoStackLocation->
FileObject->CurrentByteOffset.QuadPart +=
179 Irp->IoStatus.Information;
196 DPRINT(
"RawClose(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
239 DPRINT(
"RawCreate(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
250 if ((!(IoStackLocation->FileObject) ||
251 !(IoStackLocation->FileObject->FileName.Length)) &&
252 ((IoStackLocation->Parameters.Create.Options >> 24) ==
FILE_OPEN) &&
260 Irp->IoStatus.Information = 0;
266 Irp->IoStatus.Information = 0;
273 SecurityContext->DesiredAccess;
276 if (
Vcb->OpenCount > 0)
302 IoStackLocation->FileObject->Vpb =
Vcb->Vpb;
307 IoStackLocation->FileObject->Flags |=
316 Irp->IoStatus.Information = 0;
347 DPRINT(
"RawReadWriteDeviceControl(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
350 if (((IoStackLocation->MajorFunction ==
IRP_MJ_READ) ||
352 !(IoStackLocation->Parameters.Read.Length))
389 DPRINT(
"RawMountVolume(%p)\n", IoStackLocation);
392 DeviceObject = IoStackLocation->Parameters.MountVolume.DeviceObject;
413 IoStackLocation->Parameters.MountVolume.DeviceObject,
414 IoStackLocation->Parameters.MountVolume.Vpb);
422 Volume->Vcb.Vpb->SerialNumber = 0xFFFFFFFF;
423 Volume->Vcb.Vpb->VolumeLabelLength = 0;
430 Volume->DeviceObject.Flags &= ~DO_DEVICE_INITIALIZING;
453 Volume->Vcb.OpenCount += 2;
458 Volume->Vcb.OpenCount -= 2;
471 DPRINT(
"RawUserFsCtrl(%p, %p)\n", IoStackLocation,
Vcb);
482 switch (IoStackLocation->Parameters.FileSystemControl.FsControlCode)
523 Vcb->VcbState &= ~VCB_STATE_LOCKED;
556 switch (IoStackLocation->Parameters.FileSystemControl.FsControlCode)
584 DPRINT(
"RawFileSystemControl(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
587 switch (IoStackLocation->MinorFunction)
615 Vcb->Vpb->RealDevice->Flags &= ~DO_VERIFY_VOLUME;
652 DPRINT(
"RawQueryInformation(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
655 Length = &IoStackLocation->Parameters.QueryFile.Length;
656 Buffer =
Irp->AssociatedIrp.SystemBuffer;
659 if (IoStackLocation->Parameters.QueryFile.FileInformationClass ==
666 Irp->IoStatus.Information = 0;
672 Buffer->CurrentByteOffset = IoStackLocation->FileObject->
699 DPRINT(
"RawSetInformation(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
702 Buffer =
Irp->AssociatedIrp.SystemBuffer;
705 if (IoStackLocation->Parameters.QueryFile.FileInformationClass ==
712 if ((
Buffer->CurrentByteOffset.LowPart &
721 IoStackLocation->FileObject->CurrentByteOffset =
Buffer->
747 Buffer->VolumeSerialNumber =
Vcb->Vpb->SerialNumber;
749 Buffer->VolumeLabelLength = 0;
784 RealDevice =
Vcb->Vpb->RealDevice;
822 DiskHasPartitions =
FALSE;
832 &PartitionInformation,
855 DiskHasPartitions =
FALSE;
861 DiskHasPartitions =
TRUE;
867 Buffer->SectorsPerAllocationUnit = 1;
870 if (DiskHasPartitions)
873 Buffer->TotalAllocationUnits =
881 Buffer->TotalAllocationUnits =
888 Buffer->AvailableAllocationUnits =
Buffer->TotalAllocationUnits;
915 Buffer->Characteristics =
Vcb->TargetDeviceObject->Characteristics;
928 const WCHAR szRawFSName[] =
L"RAW";
936 FileSystemName[
sizeof(szRawFSName) /
sizeof(szRawFSName[0])]);
940 Buffer->FileSystemAttributes = 0;
941 Buffer->MaximumComponentNameLength = 0;
942 Buffer->FileSystemNameLength = 6;
961 DPRINT(
"RawQueryVolumeInformation(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
964 Length = IoStackLocation->Parameters.QueryVolume.Length;
965 Buffer =
Irp->AssociatedIrp.SystemBuffer;
968 switch (IoStackLocation->Parameters.QueryVolume.FsInformationClass)
1003 Irp->IoStatus.Information = IoStackLocation->
1019 DPRINT(
"RawCleanup(%p, %p, %p)\n",
Vcb,
Irp, IoStackLocation);
1088 Vcb = &VolumeDeviceObject->
Vcb;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define FILE_DIRECTORY_FILE
BOOL Delete(LPCTSTR ServiceName)
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
@ FilePositionInformation
@ FileFsDeviceInformation
@ FileFsAttributeInformation
@ FileFsVolumeInformation
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
static void CreateOperation(FILE *Out, unsigned Bpp, PROPINFO RopInfo, unsigned SourceBpp, unsigned Bits)
NTSYSAPI LONGLONG WINAPI RtlExtendedIntegerMultiply(LONGLONG, INT)
NTSYSAPI LONGLONG WINAPI RtlExtendedLargeIntegerDivide(LONGLONG, INT, INT *)
#define EXCEPTION_EXECUTE_HANDLER
HRESULT Create([out]ITransactionReceiver **ppReceiver)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define FSCTL_OPLOCK_BREAK_NOTIFY
#define FSCTL_LOCK_VOLUME
#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE
#define FSCTL_REQUEST_OPLOCK_LEVEL_1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
#define FSCTL_UNLOCK_VOLUME
#define FILE_FLOPPY_DISKETTE
#define FSCTL_REQUEST_OPLOCK_LEVEL_2
#define FSCTL_DISMOUNT_VOLUME
#define UNREFERENCED_PARAMETER(P)
#define IOCTL_DISK_GET_PARTITION_INFO
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define FSRTL_VOLUME_UNLOCK
#define FSRTL_VOLUME_LOCK
#define FSRTL_VOLUME_DISMOUNT_FAILED
#define FSRTL_VOLUME_DISMOUNT
#define FSRTL_VOLUME_MOUNT
#define VPB_REMOVE_PENDING
#define FSRTL_VOLUME_LOCK_FAILED
#define IoCopyCurrentIrpStackLocationToNext(Irp)
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
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)
VOID NTAPI IoSetShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
NTSTATUS NTAPI IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess, IN BOOLEAN Update)
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
PFILE_OBJECT NTAPI IoCreateStreamFileObjectLite(IN PFILE_OBJECT FileObject OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL)
#define IoCompleteRequest
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
VOID NTAPI IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
LONG NTAPI KeReadStateMutant(IN PKMUTANT Mutant)
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
#define STATUS_VOLUME_DISMOUNTED
#define STATUS_NOT_LOCKED
#define FILE_DEVICE_DISK_FILE_SYSTEM
#define FILE_DEVICE_TAPE_FILE_SYSTEM
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
NTSTATUS NTAPI RawShutdown(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI RawReadWriteDeviceControl(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
NTSTATUS NTAPI RawQueryFsDeviceInfo(IN PVCB Vcb, IN PFILE_FS_DEVICE_INFORMATION Buffer, IN OUT PULONG Length)
NTSTATUS NTAPI RawQueryVolumeInformation(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
NTSTATUS NTAPI RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
NTSTATUS NTAPI RawCleanup(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
PDEVICE_OBJECT RawCdromDeviceObject
NTSTATUS NTAPI RawQueryFsVolumeInfo(IN PVCB Vcb, IN PFILE_FS_VOLUME_INFORMATION Buffer, IN OUT PULONG Length)
PDEVICE_OBJECT RawTapeDeviceObject
NTSTATUS NTAPI RawCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
NTSTATUS NTAPI RawQueryFsSizeInfo(IN PVCB Vcb, IN PFILE_FS_SIZE_INFORMATION Buffer, IN OUT PULONG Length)
NTSTATUS NTAPI RawMountVolume(IN PIO_STACK_LOCATION IoStackLocation)
BOOLEAN NTAPI RawCheckForDismount(IN PVCB Vcb, IN BOOLEAN CreateOperation)
NTSTATUS NTAPI RawQueryInformation(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
NTSTATUS NTAPI RawUserFsCtrl(IN PIO_STACK_LOCATION IoStackLocation, IN PVCB Vcb)
PDEVICE_OBJECT RawDiskDeviceObject
NTSTATUS NTAPI RawQueryFsAttributeInfo(IN PVCB Vcb, IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer, IN OUT PULONG Length)
#define VCB_STATE_DISMOUNTED
VOID NTAPI RawUnload(IN PDRIVER_OBJECT DriverObject)
NTSTATUS NTAPI RawInitializeVcb(IN OUT PVCB Vcb, IN PDEVICE_OBJECT TargetDeviceObject, IN PVPB Vpb)
struct _VOLUME_DEVICE_OBJECT VOLUME_DEVICE_OBJECT
NTSTATUS NTAPI RawFileSystemControl(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
NTSTATUS NTAPI RawSetInformation(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
NTSTATUS NTAPI RawCreate(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
NTSTATUS NTAPI RawClose(IN PVCB Vcb, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
struct _VOLUME_DEVICE_OBJECT * PVOLUME_DEVICE_OBJECT
NTSTATUS NTAPI RawDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define IRP_MJ_DEVICE_CONTROL
#define IRP_MJ_QUERY_VOLUME_INFORMATION
#define IRP_MJ_SET_INFORMATION
#define IRP_MJ_QUERY_INFORMATION
#define STATUS_BUFFER_OVERFLOW
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@3980::@3981 Create
PDEVICE_OBJECT TargetDeviceObject
LARGE_INTEGER SectorsOnDisk
DEVICE_OBJECT DeviceObject
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_ACCESS_DENIED
#define STATUS_INVALID_PARAMETER
#define STATUS_WRONG_VOLUME
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_In_ WDFDEVICE _In_ ULONG AlignmentRequirement
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define SL_OVERRIDE_VERIFY_VOLUME
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MN_VERIFY_VOLUME
#define IRP_MN_USER_FS_REQUEST
#define IO_DISK_INCREMENT
#define FO_NO_INTERMEDIATE_BUFFERING
#define FO_SYNCHRONOUS_IO
#define IRP_MN_MOUNT_VOLUME
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define ObDereferenceObject
#define ObReferenceObject