From 03aebe8a505af997a438387dba46d64f307b086b Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 2 Jul 2025 22:05:41 +0200 Subject: [PATCH] Always load VC runtime from application directory #3616 --- cmake/FindQt5.cmake | 8 ++++---- src/exe/signaturecheck.cpp | 33 ++++++++++++++------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/cmake/FindQt5.cmake b/cmake/FindQt5.cmake index 5a517531..59df0951 100644 --- a/cmake/FindQt5.cmake +++ b/cmake/FindQt5.cmake @@ -23,13 +23,13 @@ if(Qt5_FIND_REQUIRED AND MSVC) set(FETCHCONTENT_QUIET OFF) if(CMAKE_SIZEOF_VOID_P EQUAL 8) FetchContent_Declare(Qt5 - URL "https://github.com/x64dbg/deps/releases/download/dependencies/qt5.12.12-msvc2017_64.7z" - URL_HASH SHA256=bf302d02366dc09e112a1146e202429717c2097446edba8da3c3168d9a9996b4 + URL "https://github.com/x64dbg/deps/releases/download/2025.07.02/qt5.12.12-msvc2017_64.7z" + URL_HASH SHA256=770490bf09514982c8192ebde9a1fac8821108ba42b021f167bac54e85ada48a ) else() FetchContent_Declare(Qt5 - URL "https://github.com/x64dbg/deps/releases/download/dependencies/qt5.12.12-msvc2017.7z" - URL_HASH SHA256=0ea8bf7ea3ac5d7dfeb87af4ce471eefdadbf0809524fda2b0ca07aaf4654cfb + URL "https://github.com/x64dbg/deps/releases/download/2025.07.02/qt5.12.12-msvc2017.7z" + URL_HASH SHA256=3ff2a58e5ed772be475643cd7bb2df3e5499d7169d794ddf1ed5df5c5e862cb6 ) endif() FetchContent_MakeAvailable(Qt5) diff --git a/src/exe/signaturecheck.cpp b/src/exe/signaturecheck.cpp index a81eaa4e..32775b4f 100644 --- a/src/exe/signaturecheck.cpp +++ b/src/exe/signaturecheck.cpp @@ -487,32 +487,27 @@ bool InitializeSignatureCheck() return false; #endif // DEBUG_SIGNATURE_CHECKS - if(bPerformSignatureChecks) + // Safely load the MSVC runtime DLLs (since they cannot be delay loaded) + auto loadRuntimeDll = [&szSystemDir](const wchar_t* szDll) { - // Safely load the MSVC runtime DLLs (since they cannot be delay loaded) - auto loadRuntimeDll = [&szSystemDir](const wchar_t* szDll) + std::wstring fullDllPath = szApplicationDir; + fullDllPath += L'\\'; + fullDllPath += szDll; + if(FileExists(fullDllPath.c_str())) { - std::wstring fullSystemDllPath; - fullSystemDllPath = szSystemDir; - fullSystemDllPath += L'\\'; - fullSystemDllPath += szDll; - if(FileExists(fullSystemDllPath.c_str())) + if(bPerformSignatureChecks) { - LoadLibraryW(fullSystemDllPath.c_str()); + LoadLibraryCheckedW(fullDllPath.c_str(), true); } else { - std::wstring fullDllPath = szApplicationDir; - fullDllPath += L'\\'; - fullDllPath += szDll; - if(FileExists(fullDllPath.c_str())) - LoadLibraryCheckedW(szDll, true); + LoadLibraryW(fullDllPath.c_str()); } - }; - loadRuntimeDll(L"vcruntime140.dll"); - loadRuntimeDll(L"vcruntime140_1.dll"); - loadRuntimeDll(L"msvcp140.dll"); - } + } + }; + loadRuntimeDll(L"vcruntime140.dll"); + loadRuntimeDll(L"vcruntime140_1.dll"); + loadRuntimeDll(L"msvcp140.dll"); return true; } \ No newline at end of file