diff --git a/src/sys/device.c b/src/sys/device.c index 01fe01be..d1919c9e 100644 --- a/src/sys/device.c +++ b/src/sys/device.c @@ -150,6 +150,8 @@ VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject) } ExDeleteResourceLite(&DeviceExtension->Resource); + RtlZeroMemory(DeviceExtension, DeviceObject->Size - sizeof DEVICE_OBJECT); + IoDeleteDevice(DeviceObject); } diff --git a/src/sys/driver.h b/src/sys/driver.h index cbe148ee..be0aca3e 100644 --- a/src/sys/driver.h +++ b/src/sys/driver.h @@ -269,6 +269,7 @@ typedef struct FSP_FSCTL_VOLUME_PARAMS VolumeParams; FSP_IOQ Ioq; PVPB SwapVpb; + BOOLEAN Deleted; UINT8 SecurityDescriptorBuf[]; } FSP_FSVRT_DEVICE_EXTENSION; typedef struct diff --git a/src/sys/fsctl.c b/src/sys/fsctl.c index c000e018..8894b1b2 100644 --- a/src/sys/fsctl.c +++ b/src/sys/fsctl.c @@ -118,7 +118,8 @@ static NTSTATUS FspFsctlMountVolume( PVPB Vpb = IrpSp->Parameters.MountVolume.Vpb; PDEVICE_OBJECT FsvrtDeviceObject = Vpb->RealDevice; PDEVICE_OBJECT FsvolDeviceObject; - FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension; + FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension = + FspFsvrtDeviceExtension(FsvrtDeviceObject); FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension; /* check the passed in volume object; it must be one of our own */ @@ -129,7 +130,7 @@ static NTSTATUS FspFsctlMountVolume( Result = STATUS_UNRECOGNIZED_VOLUME; goto exit; } - if (FspDeviceDeleted(FsvrtDeviceObject) || + if (FspDeviceDeleted(FsvrtDeviceObject) || FsvrtDeviceExtension->Deleted || FILE_DEVICE_VIRTUAL_DISK != FsvrtDeviceObject->DeviceType) { Result = STATUS_UNRECOGNIZED_VOLUME; @@ -142,7 +143,6 @@ static NTSTATUS FspFsctlMountVolume( &FsvolDeviceObject); if (NT_SUCCESS(Result)) { - FsvrtDeviceExtension = FspFsvrtDeviceExtension(FsvrtDeviceObject); FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject); #pragma prefast(suppress:28175, "We are a filesystem: ok to access SectorSize") FsvolDeviceObject->SectorSize = FsvrtDeviceExtension->VolumeParams.SectorSize; @@ -186,6 +186,9 @@ static NTSTATUS FspFsvrtDeleteVolume( if (!NT_SUCCESS(Result)) goto exit; + /* mark the virtual volume device as deleted */ + FsvrtDeviceExtension->Deleted = TRUE; + /* stop the I/O queue */ FspIoqStop(&FsvrtDeviceExtension->Ioq);