Compare commits

..

10 Commits

13 changed files with 221 additions and 10 deletions

View File

@ -1,5 +1,13 @@
= Changelog
v1.7B1 (2020.1 B1)::
Changes since v1.6:
* [FIX] Workaround an incompatibility with Avast Antivirus. (GitHub issue #221.)
* [FIX] Fix junction (mount point reparse point) handling. (GitHub issue #269.)
v1.6 (2020)::
Changes since v1.5:

View File

@ -101,7 +101,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MEMFS_STANDALONE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\inc</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -117,7 +117,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MEMFS_STANDALONE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\inc</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -135,7 +135,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MEMFS_STANDALONE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\inc</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -155,7 +155,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MEMFS_STANDALONE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\inc</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>

View File

@ -16,10 +16,10 @@
<MyCompanyName>Navimatics LLC</MyCompanyName>
<MyCopyright>2015-$([System.DateTime]::Now.ToString(`yyyy`)) Bill Zissimopoulos</MyCopyright>
<MyCanonicalVersion>1.6</MyCanonicalVersion>
<MyCanonicalVersion>1.7</MyCanonicalVersion>
<MyProductVersion>2020</MyProductVersion>
<MyProductStage>Gold</MyProductStage>
<MyProductVersion>2020.1 B1</MyProductVersion>
<MyProductStage>Beta</MyProductStage>
<MyVersion>$(MyCanonicalVersion).$(MyBuildNumber)</MyVersion>
<MyVersionWithCommas>$(MyVersion.Replace('.',',')),0</MyVersionWithCommas>

View File

@ -176,7 +176,8 @@ enum
UINT32 CasePreservedExtendedAttributes:1; /* preserve case of EA (default is UPPERCASE) */\
UINT32 WslFeatures:1; /* support features required for WSLinux */\
UINT32 DirectoryMarkerAsNextOffset:1; /* directory marker is next offset instead of last name */\
UINT32 KmReservedFlags:4;\
UINT32 RejectIrpPriorToTransact0:1; /* reject IRP's prior to FspFsctlTransact with 0 buffers */\
UINT32 KmReservedFlags:3;\
WCHAR Prefix[FSP_FSCTL_VOLUME_PREFIX_SIZE / sizeof(WCHAR)]; /* UNC prefix (\Server\Share) */\
WCHAR FileSystemName[FSP_FSCTL_VOLUME_FSNAME_SIZE / sizeof(WCHAR)];
#define FSP_FSCTL_VOLUME_PARAMS_V1_FIELD_DEFN\

View File

@ -273,6 +273,11 @@ static DWORD WINAPI FspFileSystemDispatcherThread(PVOID FileSystem0)
OperationContext.Response = Response;
TlsSetValue(FspFileSystemTlsKey, &OperationContext);
Result = FspFsctlTransact(FileSystem->VolumeHandle, 0, 0, 0, 0, FALSE);
/* send a Transact0 to inform the FSD that the dispatcher is ready */
if (!NT_SUCCESS(Result))
goto exit;
memset(Response, 0, sizeof *Response);
for (;;)
{

View File

@ -1748,9 +1748,15 @@ reparse_data_exit:
return IO_REPARSE_TAG_SYMLINK != ReparseData->ReparseTag ?
STATUS_IO_REPARSE_DATA_INVALID : STATUS_REPARSE_POINT_NOT_RESOLVED;
if (IO_REPARSE_TAG_MOUNT_POINT == ReparseData->ReparseTag)
RemainderPathSize = lstrlenW(RemainderPath) * sizeof(WCHAR);
*PSize = ReparseDataSize;
memcpy(Buffer, ReparseData, ReparseDataSize);
if (IO_REPARSE_TAG_MOUNT_POINT == ReparseData->ReparseTag)
OutputReparseData->Reserved = RemainderPathSize;
PIoStatus->Status = STATUS_REPARSE;
PIoStatus->Information = ReparseData->ReparseTag;
return STATUS_REPARSE;

View File

@ -284,6 +284,11 @@ static NTSTATUS FspFsvolCreateNoLock(
return STATUS_SUCCESS;
}
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
if (!FspFsvolDeviceReadyToAcceptIrp(FsvolDeviceObject))
return STATUS_CANCELLED;
#endif
PACCESS_STATE AccessState = IrpSp->Parameters.Create.SecurityContext->AccessState;
ULONG CreateDisposition = (IrpSp->Parameters.Create.Options >> 24) & 0xff;
ULONG CreateOptions = IrpSp->Parameters.Create.Options;

View File

@ -1028,6 +1028,7 @@ NTSTATUS FspStatisticsCopy(FSP_STATISTICS *Statistics, PVOID Buffer, PULONG PLen
#define FspStatisticsAdd(S,F,V) ((S)->F += (V))
/* device management */
#define FSP_DEVICE_REJECT_EARLY_IRP
enum
{
FspFsvolDeviceSecurityCacheCapacity = 100,
@ -1082,6 +1083,9 @@ typedef struct
FSP_FSEXT_PROVIDER *Provider;
UNICODE_STRING VolumePrefix;
UNICODE_PREFIX_TABLE_ENTRY VolumePrefixEntry;
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
LONG ReadyToAcceptIrp;
#endif
FSP_IOQ *Ioq;
FSP_META_CACHE *SecurityCache;
FSP_META_CACHE *DirInfoCache;
@ -1181,6 +1185,24 @@ VOID FspFsvolDeviceGetVolumeInfo(PDEVICE_OBJECT DeviceObject, FSP_FSCTL_VOLUME_I
BOOLEAN FspFsvolDeviceTryGetVolumeInfo(PDEVICE_OBJECT DeviceObject, FSP_FSCTL_VOLUME_INFO *VolumeInfo);
VOID FspFsvolDeviceSetVolumeInfo(PDEVICE_OBJECT DeviceObject, const FSP_FSCTL_VOLUME_INFO *VolumeInfo);
VOID FspFsvolDeviceInvalidateVolumeInfo(PDEVICE_OBJECT DeviceObject);
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
static inline
BOOLEAN FspFsvolDeviceReadyToAcceptIrp(PDEVICE_OBJECT DeviceObject)
{
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
if (!FsvolDeviceExtension->VolumeParams.RejectIrpPriorToTransact0)
return TRUE;
return 0 != InterlockedCompareExchange(&FsvolDeviceExtension->ReadyToAcceptIrp, 0, 0);
}
static inline
VOID FspFsvolDeviceSetReadyToAcceptIrp(PDEVICE_OBJECT DeviceObject)
{
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
if (!FsvolDeviceExtension->VolumeParams.RejectIrpPriorToTransact0)
return;
InterlockedExchange(&FsvolDeviceExtension->ReadyToAcceptIrp, 1);
}
#endif
static inline
BOOLEAN FspFsvolDeviceVolumePrefixInString(PDEVICE_OBJECT DeviceObject, PUNICODE_STRING String)
{

View File

@ -286,6 +286,11 @@ static NTSTATUS FspFsvolQueryVolumeInformation(
{
PAGED_CODE();
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
if (!FspFsvolDeviceReadyToAcceptIrp(FsvolDeviceObject))
return STATUS_CANCELLED;
#endif
NTSTATUS Result;
PUINT8 Buffer = Irp->AssociatedIrp.SystemBuffer;
PUINT8 BufferEnd = Buffer + IrpSp->Parameters.QueryVolume.Length;
@ -414,6 +419,11 @@ static NTSTATUS FspFsvolSetVolumeInformation(
{
PAGED_CODE();
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
if (!FspFsvolDeviceReadyToAcceptIrp(FsvolDeviceObject))
return STATUS_CANCELLED;
#endif
NTSTATUS Result;
FS_INFORMATION_CLASS FsInformationClass = IrpSp->Parameters.SetVolume.FsInformationClass;
PVOID Buffer = Irp->AssociatedIrp.SystemBuffer;

View File

@ -277,6 +277,10 @@ static NTSTATUS FspVolumeCreateNoLock(
RtlInitEmptyUnicodeString(&FsvolDeviceExtension->VolumeName,
FsvolDeviceExtension->VolumeNameBuf, sizeof FsvolDeviceExtension->VolumeNameBuf);
RtlCopyUnicodeString(&FsvolDeviceExtension->VolumeName, &VolumeName);
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
if (!FsvolDeviceExtension->VolumeParams.RejectIrpPriorToTransact0)
FsvolDeviceExtension->ReadyToAcceptIrp = 1;
#endif
Result = FspDeviceInitialize(FsvolDeviceObject);
if (NT_SUCCESS(Result))
{
@ -767,6 +771,11 @@ NTSTATUS FspVolumeTransact(
if (!FspDeviceReference(FsvolDeviceObject))
return STATUS_CANCELLED;
#if defined(FSP_DEVICE_REJECT_EARLY_IRP)
if (0 == InputBufferLength && 0 == OutputBufferLength)
FspFsvolDeviceSetReadyToAcceptIrp(FsvolDeviceObject);
#endif
NTSTATUS Result;
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
PUINT8 BufferEnd;

118
tools/build-choco.bat Normal file
View File

@ -0,0 +1,118 @@
@echo off
setlocal
setlocal EnableDelayedExpansion
set MsiName="WinFsp - Windows File System Proxy"
set CrossCert="%~dp0DigiCert High Assurance EV Root CA.crt"
set Issuer="DigiCert"
set Subject="Navimatics LLC"
set Configuration=Release
set SignedPackage=
if not X%1==X set Configuration=%1
if not X%2==X set SignedPackage=%2
if X%~nx0==Xbuild-choco.bat (
cd %~dp0..\build\VStudio
goto :choco
)
call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64
if not X%SignedPackage%==X (
if not exist "%~dp0..\build\VStudio\build\%Configuration%\winfsp-*.msi" (echo previous build not found >&2 & exit /b 1)
if not exist "%SignedPackage%" (echo signed package not found >&2 & exit /b 1)
del "%~dp0..\build\VStudio\build\%Configuration%\winfsp-*.msi"
if exist "%~dp0..\build\VStudio\build\%Configuration%\winfsp.*.nupkg" del "%~dp0..\build\VStudio\build\%Configuration%\winfsp.*.nupkg"
for /R "%SignedPackage%" %%f in (*.sys) do (
copy "%%f" "%~dp0..\build\VStudio\build\%Configuration%" >nul
)
)
cd %~dp0..\build\VStudio
set signfail=0
if X%SignedPackage%==X (
if exist build\ for /R build\ %%d in (%Configuration%) do (
if exist "%%d" rmdir /s/q "%%d"
)
devenv winfsp.sln /build "%Configuration%|x64"
if errorlevel 1 goto fail
devenv winfsp.sln /build "%Configuration%|x86"
if errorlevel 1 goto fail
for %%f in (build\%Configuration%\winfsp-x64.sys build\%Configuration%\winfsp-x86.sys) do (
signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha1 /t http://timestamp.digicert.com %%f
if errorlevel 1 set /a signfail=signfail+1
signtool sign /as /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha256 /tr http://timestamp.digicert.com /td sha256 %%f
if errorlevel 1 set /a signfail=signfail+1
)
pushd build\%Configuration%
echo .OPTION EXPLICIT >driver.ddf
echo .Set CabinetFileCountThreshold=0 >>driver.ddf
echo .Set FolderFileCountThreshold=0 >>driver.ddf
echo .Set FolderSizeThreshold=0 >>driver.ddf
echo .Set MaxCabinetSize=0 >>driver.ddf
echo .Set MaxDiskFileCount=0 >>driver.ddf
echo .Set MaxDiskSize=0 >>driver.ddf
echo .Set CompressionType=MSZIP >>driver.ddf
echo .Set Cabinet=on >>driver.ddf
echo .Set Compress=on >>driver.ddf
echo .Set CabinetNameTemplate=driver.cab >>driver.ddf
echo .Set DiskDirectory1=. >>driver.ddf
echo .Set DestinationDir=x64 >>driver.ddf
echo driver-x64.inf >>driver.ddf
echo winfsp-x64.sys >>driver.ddf
echo .Set DestinationDir=x86 >>driver.ddf
echo driver-x86.inf >>driver.ddf
echo winfsp-x86.sys >>driver.ddf
makecab /F driver.ddf
signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /t http://timestamp.digicert.com driver.cab
if errorlevel 1 set /a signfail=signfail+1
popd
)
devenv winfsp.sln /build "Installer.%Configuration%|x86"
if errorlevel 1 goto fail
for %%f in (build\%Configuration%\winfsp-*.msi) do (
signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha1 /t http://timestamp.digicert.com /d %MsiName% %%f
if errorlevel 1 set /a signfail=signfail+1
REM signtool sign /ac %CrossCert% /i %Issuer% /n %Subject% /fd sha256 /tr http://timestamp.digicert.com /td sha256 /d %MsiName% %%f
REM if errorlevel 1 set /a signfail=signfail+1
)
if not %signfail%==0 echo SIGNING FAILED! The product has been successfully built, but not signed.
set Version=
for %%f in (build\%Configuration%\winfsp-*.msi) do set Version=%%~nf
set Version=!Version:winfsp-=!
if X%SignedPackage%==X (
pushd build\%Configuration%
powershell -command "Compress-Archive -Path winfsp-tests-*.exe,..\..\..\..\License.txt,..\..\..\..\tst\winfsp-tests\README.md -DestinationPath winfsp-tests-!Version!.zip"
if errorlevel 1 goto fail
popd
)
:choco
if not exist "build\%Configuration%\winfsp-*.msi" (echo installer msi not found >&2 & exit /b 1)
set Version=
for %%f in (build\%Configuration%\winfsp-*.msi) do set Version=%%~nf
set Version=!Version:winfsp-=!
where /q choco.exe
if %ERRORLEVEL% equ 0 (
copy ..\choco\* build\%Configuration%
copy ..\choco\LICENSE.TXT /B + ..\..\License.txt /B build\%Configuration%\LICENSE.txt /B
certutil -hashfile build\%Configuration%\winfsp-!Version!.msi SHA256 >>build\%Configuration%\VERIFICATION.txt
choco pack build\%Configuration%\winfsp.nuspec --version=!Version! --outputdirectory=build\%Configuration%
if errorlevel 1 goto fail
)
exit /b 0
:fail
exit /b 1

View File

@ -14,6 +14,11 @@ set SignedPackage=
if not X%1==X set Configuration=%1
if not X%2==X set SignedPackage=%2
if X%~nx0==Xbuild-choco.bat (
cd %~dp0..\build\VStudio
goto :choco
)
call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64
if not X%SignedPackage%==X (
@ -83,9 +88,9 @@ for %%f in (build\%Configuration%\winfsp-*.msi) do (
if not %signfail%==0 echo SIGNING FAILED! The product has been successfully built, but not signed.
set Version=
for %%f in (build\%Configuration%\winfsp-*.msi) do set Version=%%~nf
set Version=!Version:winfsp-=!
if X%SignedPackage%==X (
pushd build\%Configuration%
powershell -command "Compress-Archive -Path winfsp-tests-*.exe,..\..\..\..\License.txt,..\..\..\..\tst\winfsp-tests\README.md -DestinationPath winfsp-tests-!Version!.zip"
@ -93,6 +98,11 @@ if X%SignedPackage%==X (
popd
)
:choco
if not exist "build\%Configuration%\winfsp-*.msi" (echo installer msi not found >&2 & exit /b 1)
set Version=
for %%f in (build\%Configuration%\winfsp-*.msi) do set Version=%%~nf
set Version=!Version:winfsp-=!
where /q choco.exe
if %ERRORLEVEL% equ 0 (
copy ..\choco\* build\%Configuration%

View File

@ -34,6 +34,12 @@
FSP_FSCTL_STATIC_ASSERT(MEMFS_MAX_PATH > MAX_PATH,
"MEMFS_MAX_PATH must be greater than MAX_PATH.");
/*
* Define the MEMFS_STANDALONE macro when building MEMFS as a standalone file system.
* This macro should be defined in the Visual Studio project settings, Makefile, etc.
*/
//#define MEMFS_STANDALONE
/*
* Define the MEMFS_NAME_NORMALIZATION macro to include name normalization support.
*/
@ -74,7 +80,15 @@ FSP_FSCTL_STATIC_ASSERT(MEMFS_MAX_PATH > MAX_PATH,
*/
#define MEMFS_WSL
/*
/*
* Define the MEMFS_REJECT_EARLY_IRP macro to reject IRP's sent
* to the file system prior to the dispatcher being started.
*/
#if defined(MEMFS_STANDALONE)
#define MEMFS_REJECT_EARLY_IRP
#endif
/*
* Define the DEBUG_BUFFER_CHECK macro on Windows 8 or above. This includes
* a check for the Write buffer to ensure that it is read-only.
*
@ -2387,6 +2401,9 @@ NTSTATUS MemfsCreateFunnel(
VolumeParams.WslFeatures = 1;
#endif
VolumeParams.AllowOpenInKernelMode = 1;
#if defined(MEMFS_REJECT_EARLY_IRP)
VolumeParams.RejectIrpPriorToTransact0 = 1;
#endif
if (0 != VolumePrefix)
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), VolumePrefix);
wcscpy_s(VolumeParams.FileSystemName, sizeof VolumeParams.FileSystemName / sizeof(WCHAR),