diff --git a/src/sys/device.c b/src/sys/device.c index 283136fc..353ad298 100644 --- a/src/sys/device.c +++ b/src/sys/device.c @@ -590,7 +590,9 @@ NTSTATUS FspFsvolDeviceCopyContextByNameList(PDEVICE_OBJECT DeviceObject, *PContextCount = 0; ContextCount = RtlNumberGenericTableElementsAvl(&FsvolDeviceExtension->ContextByNameTable); - Contexts = FspAlloc(sizeof(PVOID) * ContextCount); + + /* if ContextCount == 0 allocate an empty Context list */ + Contexts = FspAlloc(sizeof(PVOID) * (0 != ContextCount ? ContextCount : 1)); if (0 == Contexts) return STATUS_INSUFFICIENT_RESOURCES; diff --git a/src/sys/volume.c b/src/sys/volume.c index be2b220e..6d1173c9 100644 --- a/src/sys/volume.c +++ b/src/sys/volume.c @@ -282,9 +282,30 @@ VOID FspVolumeDelete( { // !PAGED_CODE(); + PDEVICE_OBJECT FsvolDeviceObject = IrpSp->FileObject->FsContext2; + FSP_FILE_NODE **FileNodes; + ULONG FileNodeCount, Index; + NTSTATUS Result; + + FspDeviceReference(FsvolDeviceObject); + FspDeviceGlobalLock(); FspVolumeDeleteNoLock(FsctlDeviceObject, Irp, IrpSp); FspDeviceGlobalUnlock(); + + /* + * Call MmForceSectionClosed on open files to ensure that Mm removes them from Standby List. + */ + Result = FspFileNodeCopyList(FsvolDeviceObject, &FileNodes, &FileNodeCount); + if (NT_SUCCESS(Result)) + { + for (Index = FileNodeCount - 1; FileNodeCount > Index; Index--) + MmForceSectionClosed(&FileNodes[Index]->NonPaged->SectionObjectPointers, TRUE); + + FspFileNodeDeleteList(FileNodes, FileNodeCount); + } + + FspDeviceDereference(FsvolDeviceObject); } static VOID FspVolumeDeleteNoLock( diff --git a/tools/run-tests.bat b/tools/run-tests.bat index ea0ff725..58a4072f 100644 --- a/tools/run-tests.bat +++ b/tools/run-tests.bat @@ -171,13 +171,13 @@ exit /b 0 :standby-memfs-x64-disk M: -copy "%ProjRoot%\build\VStudio\build\%Configuration%\winfsp-tests-x64.exe" +copy "%ProjRoot%\build\VStudio\build\%Configuration%\*" if !ERRORLEVEL! neq 0 goto fail exit /b 0 :standby-memfs-x64-net N: -copy "%ProjRoot%\build\VStudio\build\%Configuration%\winfsp-tests-x64.exe" +copy "%ProjRoot%\build\VStudio\build\%Configuration%\*" if !ERRORLEVEL! neq 0 goto fail exit /b 0 @@ -206,13 +206,13 @@ exit /b 0 :standby-memfs-x86-disk O: -copy "%ProjRoot%\build\VStudio\build\%Configuration%\winfsp-tests-x86.exe" +copy "%ProjRoot%\build\VStudio\build\%Configuration%\*" if !ERRORLEVEL! neq 0 goto fail exit /b 0 :standby-memfs-x86-net P: -copy "%ProjRoot%\build\VStudio\build\%Configuration%\winfsp-tests-x86.exe" +copy "%ProjRoot%\build\VStudio\build\%Configuration%\*" if !ERRORLEVEL! neq 0 goto fail exit /b 0