Case-insensitive path compare for module verifier (#15889)

This commit is contained in:
kd-11 2024-08-04 16:46:08 +03:00 committed by GitHub
parent a1dcf1f717
commit 4030193f31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,7 @@
#endif
#include <Windows.h>
#include <Shlwapi.h>
#include <util/types.hpp>
#include <util/logs.hpp>
@ -41,8 +42,6 @@ void WIN32_module_verifier::run_module_verification()
report_fatal_error(fmt::format("WIN32_module_verifier: Failed to query WindowsDirectory"), false, true);
}
const std::wstring_view windir_wsv = windir;
for (const auto& module : special_module_infos)
{
const HMODULE hModule = GetModuleHandle(module.name.data());
@ -54,8 +53,7 @@ void WIN32_module_verifier::run_module_verification()
WCHAR wpath[MAX_PATH];
if (const auto len = GetModuleFileName(hModule, wpath, MAX_PATH))
{
const std::wstring_view path_wsv = wpath;
if (path_wsv.find(windir_wsv) != 0)
if (::StrStrI(wpath, windir) != wpath)
{
const std::string path = wchar_to_utf8(wpath);
const std::string win_path = wchar_to_utf8(windir);