Skip if msvcrt dll does not have version info (#2363)

This commit is contained in:
srkizer 2025-08-11 01:49:41 +09:00 committed by GitHub
parent 6c1e538da5
commit b09a1cde0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,10 +14,12 @@ HMODULE g_hModule;
HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr); HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr);
void CheckMsvcrtVersion() { void CheckMsvcrtVersion() {
if (utils::is_running_on_wine()) { // Commit introducing inline mutex ctor: tagged vs-2022-17.14 (2024-06-18)
logging::I("Running on Wine, skipping MSVCRT version check."); // - https://github.com/microsoft/STL/commit/22a88260db4d754bbc067e2002430144d6ec5391
return; // MSVC Redist versions:
} // - https://github.com/abbodi1406/vcredist/blob/master/source_links/README.md
// - 14.40.33810.0 dsig 2024-04-28
// - 14.40.33816.0 dsig 2024-09-11
constexpr WORD RequiredMsvcrtVersionComponents[] = {14, 40, 33816, 0}; constexpr WORD RequiredMsvcrtVersionComponents[] = {14, 40, 33816, 0};
constexpr auto RequiredMsvcrtVersion = 0ULL constexpr auto RequiredMsvcrtVersion = 0ULL
@ -48,21 +50,18 @@ void CheckMsvcrtVersion() {
continue; continue;
} }
const auto& versionFull = mod.get_file_version(); try {
logging::I("Runtime DLL {} has version {}.", runtimeDllName, utils::format_file_version(versionFull)); const auto& versionFull = mod.get_file_version();
logging::I("Runtime DLL {} has version {}.", runtimeDllName, utils::format_file_version(versionFull));
const auto version = (static_cast<uint64_t>(versionFull.dwFileVersionMS) << 32) | const auto version = (static_cast<uint64_t>(versionFull.dwFileVersionMS) << 32) |
static_cast<uint64_t>(versionFull.dwFileVersionLS); static_cast<uint64_t>(versionFull.dwFileVersionLS);
// Commit introducing inline mutex ctor: tagged vs-2022-17.14 (2024-06-18) if (version < RequiredMsvcrtVersion && (lowestVersion == 0 || lowestVersion > version))
// - https://github.com/microsoft/STL/commit/22a88260db4d754bbc067e2002430144d6ec5391 lowestVersion = version;
// MSVC Redist versions: } catch (const std::exception& e) {
// - https://github.com/abbodi1406/vcredist/blob/master/source_links/README.md logging::E("Failed to detect Runtime DLL version for {}: {}", runtimeDllName, e.what());
// - 14.40.33810.0 dsig 2024-04-28 }
// - 14.40.33816.0 dsig 2024-09-11
if (version < RequiredMsvcrtVersion && (lowestVersion == 0 || lowestVersion > version))
lowestVersion = version;
} }
if (lowestVersion) { if (lowestVersion) {
@ -96,8 +95,6 @@ void CheckMsvcrtVersion() {
HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) { HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
g_startInfo.from_envvars(); g_startInfo.from_envvars();
CheckMsvcrtVersion();
std::string jsonParseError; std::string jsonParseError;
try { try {
from_json(nlohmann::json::parse(std::string_view(static_cast<char*>(lpParam))), g_startInfo); from_json(nlohmann::json::parse(std::string_view(static_cast<char*>(lpParam))), g_startInfo);
@ -176,6 +173,8 @@ HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
if ((g_startInfo.BootWaitMessageBox & DalamudStartInfo::WaitMessageboxFlags::BeforeInitialize) != DalamudStartInfo::WaitMessageboxFlags::None) if ((g_startInfo.BootWaitMessageBox & DalamudStartInfo::WaitMessageboxFlags::BeforeInitialize) != DalamudStartInfo::WaitMessageboxFlags::None)
MessageBoxW(nullptr, L"Press OK to continue (BeforeInitialize)", L"Dalamud Boot", MB_OK); MessageBoxW(nullptr, L"Press OK to continue (BeforeInitialize)", L"Dalamud Boot", MB_OK);
CheckMsvcrtVersion();
if (g_startInfo.BootDebugDirectX) { if (g_startInfo.BootDebugDirectX) {
logging::I("Enabling DirectX Debugging."); logging::I("Enabling DirectX Debugging.");