This commit is contained in:
Bill Zissimopoulos 2015-11-30 11:21:10 -08:00
parent f188bddb3b
commit 44654617e3
3 changed files with 22 additions and 45 deletions

View File

@ -26,7 +26,6 @@ NTSTATUS FspDeviceCopyList(
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount); PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount);
VOID FspDeviceDeleteList( VOID FspDeviceDeleteList(
PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount); PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount);
NTSTATUS FspDeviceOwned(PDEVICE_OBJECT DeviceObject);
VOID FspDeviceDeleteAll(VOID); VOID FspDeviceDeleteAll(VOID);
#ifdef ALLOC_PRAGMA #ifdef ALLOC_PRAGMA
@ -41,7 +40,6 @@ VOID FspDeviceDeleteAll(VOID);
#pragma alloc_text(PAGE, FspFsvolDeviceFini) #pragma alloc_text(PAGE, FspFsvolDeviceFini)
#pragma alloc_text(PAGE, FspDeviceCopyList) #pragma alloc_text(PAGE, FspDeviceCopyList)
#pragma alloc_text(PAGE, FspDeviceDeleteList) #pragma alloc_text(PAGE, FspDeviceDeleteList)
#pragma alloc_text(PAGE, FspDeviceOwned)
#pragma alloc_text(PAGE, FspDeviceDeleteAll) #pragma alloc_text(PAGE, FspDeviceDeleteAll)
#endif #endif
@ -149,7 +147,7 @@ VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject)
} }
ExDeleteResourceLite(&DeviceExtension->Resource); ExDeleteResourceLite(&DeviceExtension->Resource);
RtlZeroMemory(DeviceExtension, DeviceObject->Size - sizeof DEVICE_OBJECT); RtlZeroMemory(DeviceExtension, DeviceObject->Size - sizeof(DEVICE_OBJECT));
IoDeleteDevice(DeviceObject); IoDeleteDevice(DeviceObject);
} }
@ -279,30 +277,6 @@ VOID FspDeviceDeleteList(
ExFreePoolWithTag(DeviceObjects, FSP_TAG); ExFreePoolWithTag(DeviceObjects, FSP_TAG);
} }
NTSTATUS FspDeviceOwned(PDEVICE_OBJECT DeviceObject)
{
PAGED_CODE();
NTSTATUS Result = STATUS_NO_SUCH_DEVICE;
PDEVICE_OBJECT *DeviceObjects = 0;
ULONG DeviceObjectCount = 0;
Result = FspDeviceCopyList(&DeviceObjects, &DeviceObjectCount);
if (!NT_SUCCESS(Result))
return Result;
for (ULONG i = 0; DeviceObjectCount > i; i++)
if (DeviceObjects[i] == DeviceObject)
{
Result = STATUS_SUCCESS;
break;
}
FspDeviceDeleteList(DeviceObjects, DeviceObjectCount);
return Result;
}
VOID FspDeviceDeleteAll(VOID) VOID FspDeviceDeleteAll(VOID)
{ {
PAGED_CODE(); PAGED_CODE();

View File

@ -314,7 +314,6 @@ NTSTATUS FspDeviceCopyList(
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount); PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount);
VOID FspDeviceDeleteList( VOID FspDeviceDeleteList(
PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount); PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount);
NTSTATUS FspDeviceOwned(PDEVICE_OBJECT DeviceObject);
VOID FspDeviceDeleteAll(VOID); VOID FspDeviceDeleteAll(VOID);
/* I/O processing */ /* I/O processing */

View File

@ -177,6 +177,8 @@ static NTSTATUS FspFsctlMountVolume(
ExAcquireResourceExclusiveLite(&FsctlDeviceExtension->Base.Resource, TRUE); ExAcquireResourceExclusiveLite(&FsctlDeviceExtension->Base.Resource, TRUE);
try try
{ {
PDEVICE_OBJECT *DeviceObjects = 0;
ULONG DeviceObjectCount = 0;
PVPB Vpb = IrpSp->Parameters.MountVolume.Vpb; PVPB Vpb = IrpSp->Parameters.MountVolume.Vpb;
PDEVICE_OBJECT FsvrtDeviceObject = Vpb->RealDevice; PDEVICE_OBJECT FsvrtDeviceObject = Vpb->RealDevice;
PDEVICE_OBJECT FsvolDeviceObject; PDEVICE_OBJECT FsvolDeviceObject;
@ -185,25 +187,27 @@ static NTSTATUS FspFsctlMountVolume(
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension; FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
/* check the passed in volume object; it must be one of our own and not marked Deleted */ /* check the passed in volume object; it must be one of our own and not marked Deleted */
Result = FspDeviceOwned(FsvrtDeviceObject); Result = FspDeviceCopyList(&DeviceObjects, &DeviceObjectCount);
if (NT_SUCCESS(Result))
{
Result = STATUS_UNRECOGNIZED_VOLUME;
for (ULONG i = 0; DeviceObjectCount > i; i++)
if (DeviceObjects[i] == FsvrtDeviceObject)
{
if (FspDeviceRetain(FsvrtDeviceObject))
{
if (!FsvrtDeviceExtension->Deleted &&
FILE_DEVICE_VIRTUAL_DISK == FsvrtDeviceObject->DeviceType)
Result = STATUS_SUCCESS;
else
FspDeviceRelease(FsvrtDeviceObject);
}
break;
}
FspDeviceDeleteList(DeviceObjects, DeviceObjectCount);
}
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
{
if (STATUS_NO_SUCH_DEVICE == Result)
Result = STATUS_UNRECOGNIZED_VOLUME;
goto exit; goto exit;
}
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;
}
/* create the file system device object */ /* create the file system device object */
Result = FspDeviceCreate(FspFsvolDeviceExtensionKind, 0, Result = FspDeviceCreate(FspFsvolDeviceExtensionKind, 0,