From f188bddb3b38331334d62352a9f63ff0fc922a5a Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Mon, 30 Nov 2015 11:10:48 -0800 Subject: [PATCH] sys: WIP --- src/sys/device.c | 17 ----------------- src/sys/driver.h | 1 - src/sys/fsctl.c | 10 +++++++++- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/sys/device.c b/src/sys/device.c index d1919c9e..c099fcc2 100644 --- a/src/sys/device.c +++ b/src/sys/device.c @@ -22,7 +22,6 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject); static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject); BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject); VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject); -BOOLEAN FspDeviceDeleted(PDEVICE_OBJECT DeviceObject); NTSTATUS FspDeviceCopyList( PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount); VOID FspDeviceDeleteList( @@ -243,22 +242,6 @@ VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject) FspDeviceDelete(DeviceObject); } -BOOLEAN FspDeviceDeleted(PDEVICE_OBJECT DeviceObject) -{ - // !PAGED_CODE(); - - BOOLEAN Result; - FSP_DEVICE_EXTENSION *DeviceExtension; - KIRQL Irql; - - DeviceExtension = FspDeviceExtension(DeviceObject); - KeAcquireSpinLock(&DeviceExtension->SpinLock, &Irql); - Result = 0 == DeviceExtension->RefCount; - KeReleaseSpinLock(&DeviceExtension->SpinLock, Irql); - - return Result; -} - NTSTATUS FspDeviceCopyList( PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount) { diff --git a/src/sys/driver.h b/src/sys/driver.h index be0aca3e..c3fbbe3f 100644 --- a/src/sys/driver.h +++ b/src/sys/driver.h @@ -310,7 +310,6 @@ NTSTATUS FspDeviceCreate(UINT32 Kind, ULONG ExtraSize, VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject); BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject); VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject); -BOOLEAN FspDeviceDeleted(PDEVICE_OBJECT DeviceObject); NTSTATUS FspDeviceCopyList( PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount); VOID FspDeviceDeleteList( diff --git a/src/sys/fsctl.c b/src/sys/fsctl.c index bfa7d37a..8842a34b 100644 --- a/src/sys/fsctl.c +++ b/src/sys/fsctl.c @@ -192,9 +192,15 @@ static NTSTATUS FspFsctlMountVolume( Result = STATUS_UNRECOGNIZED_VOLUME; goto exit; } - if (FspDeviceDeleted(FsvrtDeviceObject) || FsvrtDeviceExtension->Deleted || + if (!FspDeviceRetain(FsvrtDeviceObject)) + { + Result = STATUS_UNRECOGNIZED_VOLUME; + goto exit; + } + if (FsvrtDeviceExtension->Deleted || FILE_DEVICE_VIRTUAL_DISK != FsvrtDeviceObject->DeviceType) { + FspDeviceRelease(FsvrtDeviceObject); Result = STATUS_UNRECOGNIZED_VOLUME; goto exit; } @@ -215,6 +221,8 @@ static NTSTATUS FspFsctlMountVolume( Irp->IoStatus.Information = 0; } + FspDeviceRelease(FsvrtDeviceObject); + exit:; } finally