From edcb0ef245aaca6e77298123cafb65c5a23fa45f Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 17 Apr 2020 07:16:37 -0400 Subject: [PATCH] fixed hook_FindFirstFileExW() not handling trailing slashes updated boost to 1.72 bumped to 4.4.7 --- include/usvfs_version.h | 2 +- src/usvfs_dll/hooks/kernel32.cpp | 11 +++++++++++ vsbuild/external_dependencies.props | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/usvfs_version.h b/include/usvfs_version.h index 12e91f07..4074a31e 100644 --- a/include/usvfs_version.h +++ b/include/usvfs_version.h @@ -3,7 +3,7 @@ #define USVFS_VERSION_MAJOR 0 #define USVFS_VERSION_MINOR 4 #define USVFS_VERSION_BUILD 4 -#define USVFS_VERSION_REVISION 6 +#define USVFS_VERSION_REVISION 7 #define USVFS_BUILD_STRING "" #define USVFS_BUILD_WSTRING L"" diff --git a/src/usvfs_dll/hooks/kernel32.cpp b/src/usvfs_dll/hooks/kernel32.cpp index 05e445aa..d6de7033 100644 --- a/src/usvfs_dll/hooks/kernel32.cpp +++ b/src/usvfs_dll/hooks/kernel32.cpp @@ -1292,6 +1292,17 @@ HANDLE WINAPI usvfs::hook_FindFirstFileExW(LPCWSTR lpFileName, FINDEX_INFO_LEVEL return res; } + // FindFirstFileEx() must fail early if the path ends with a slash + if (lpFileName) { + const auto len = wcslen(lpFileName); + if (len > 0) { + if (lpFileName[len - 1] == L'\\' || lpFileName[len - 1] == L'/') { + spdlog::get("usvfs")->warn("hook_FindFirstFileExW(): path '{}' ends with slash, always fails", fs::path(lpFileName).string()); + return INVALID_HANDLE_VALUE; + } + } + } + fs::path finalPath; RerouteW reroute; fs::path originalPath; diff --git a/vsbuild/external_dependencies.props b/vsbuild/external_dependencies.props index cc7be094..d39cec3e 100644 --- a/vsbuild/external_dependencies.props +++ b/vsbuild/external_dependencies.props @@ -4,7 +4,7 @@ - ..\..\boost_1_71_0 + ..\..\boost_1_72_0 $(BOOST_PATH) ..\..\googletest