diff --git a/rpcs3/module_verifier.hpp b/rpcs3/module_verifier.hpp index 8e30a0f64a..0399d590c8 100644 --- a/rpcs3/module_verifier.hpp +++ b/rpcs3/module_verifier.hpp @@ -32,30 +32,38 @@ class WIN32_module_verifier { L"vcruntime140_1.dll", "Microsoft Visual C++ 2015-2019 Redistributable", "https://aka.ms/vs/16/release/VC_redist.x64.exe" } }; - // Unless we support ReactOS in future, this is a constant - const std::wstring_view system_root = L"C:\\WINDOWS\\"; - // Inline impl. This class is only referenced once. void run_module_verification() { + WCHAR windir[MAX_PATH]; + if (!GetWindowsDirectory(windir, MAX_PATH)) + { + 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 auto hModule = GetModuleHandle(module.name.data()); + const HMODULE hModule = GetModuleHandle(module.name.data()); if (hModule == NULL) { continue; } - WCHAR path[MAX_PATH]; - if (const auto len = GetModuleFileName(hModule, path, MAX_PATH)) + WCHAR wpath[MAX_PATH]; + if (const auto len = GetModuleFileName(hModule, wpath, MAX_PATH)) { - const std::wstring_view s = path; - if (s.find(system_root) != 0) + const std::wstring_view path_wsv = wpath; + if (path_wsv.find(windir_wsv) != 0) { - const auto module_name = wchar_to_utf8(module.name); - const auto error_message = fmt::format( + const std::string path = wchar_to_utf8(wpath); + const std::string module_name = wchar_to_utf8(module.name); + const std::string error_message = fmt::format( "
"
- "The module %s was incorrectly installed.
"
+ "The module %s was incorrectly installed at
"
+ "'%s'
"
+ "
"
"This module is part of the %s package.
"
"Install this package, then delete %s from rpcs3's installation directory.
"
"
"
@@ -63,6 +71,7 @@ class WIN32_module_verifier
"%s"
"