From 692c2fb5e60fa4847e8dc70ae31ea8312bf0b2ae Mon Sep 17 00:00:00 2001 From: p0358 Date: Sat, 28 Oct 2023 03:44:40 +0200 Subject: [PATCH] show message box about missing symbols only once --- src/main/ealink_exe_patches.cpp | 9 +++++++-- src/main/origin_client_dll_patches.cpp | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/ealink_exe_patches.cpp b/src/main/ealink_exe_patches.cpp index 8038377..8eadfb7 100644 --- a/src/main/ealink_exe_patches.cpp +++ b/src/main/ealink_exe_patches.cpp @@ -13,12 +13,17 @@ namespace EALinkExePatches static auto SETTING_MigrationDisabled = GetExport(EALinkExe, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@A"); // non-const symbol if (!SETTING_MigrationDisabled) SETTING_MigrationDisabled = GetExport(EALinkExe, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@B"); // const symbol - if (!QVariant_QVariant_from_bool || !SETTING_MigrationDisabled) [[unlikely]] - MessageBoxA(nullptr, ("Error in Origin::Services::readSetting: one of the functions could not have been resolved, we will crash\n" + + static bool didWarnAboutMissingAlready = false; + if (!didWarnAboutMissingAlready && (!QVariant_QVariant_from_bool || !SETTING_MigrationDisabled)) [[unlikely]] + { + didWarnAboutMissingAlready = true; + MessageBoxA(nullptr, ("Error in Origin::Services::readSetting: one of the functions could not have been resolved, we may crash\n" "\nQVariant_QVariant_from_bool: " + std::to_string(uintptr_t(QVariant_QVariant_from_bool)) + "\nSETTING_MigrationDisabled: " + std::to_string(uintptr_t(SETTING_MigrationDisabled)) ).c_str(), ERROR_MSGBOX_CAPTION, MB_ICONERROR); + } if (setting == SETTING_MigrationDisabled) { diff --git a/src/main/origin_client_dll_patches.cpp b/src/main/origin_client_dll_patches.cpp index af1719d..e7d09a1 100644 --- a/src/main/origin_client_dll_patches.cpp +++ b/src/main/origin_client_dll_patches.cpp @@ -56,15 +56,20 @@ void*(__cdecl* readSetting_org)(void*, void*, int, void*); void* __cdecl readSetting_hook(void* out_qv, void* setting, int a3, void* a4) { static auto QVariant_QVariant_from_bool = GetExport(Qt5Core, "??0QVariant@@QAE@_N@Z"); - static auto SETTING_MigrationDisabled = GetExport(OriginClient, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@A"); + static auto SETTING_MigrationDisabled = GetExport(OriginClient, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@A"); // non-const symbol if (!SETTING_MigrationDisabled) - SETTING_MigrationDisabled = GetExport(OriginClient, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@B"); - if (!QVariant_QVariant_from_bool || !SETTING_MigrationDisabled) [[unlikely]] - MessageBoxA(nullptr, ("Error in Origin::Services::readSetting: one of the functions could not have been resolved, we will crash\n" + SETTING_MigrationDisabled = GetExport(OriginClient, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@B"); // const symbol + + static bool didWarnAboutMissingAlready = false; + if (!didWarnAboutMissingAlready && (!QVariant_QVariant_from_bool || !SETTING_MigrationDisabled)) [[unlikely]] + { + didWarnAboutMissingAlready = true; + MessageBoxA(nullptr, ("Error in Origin::Services::readSetting: one of the exports could not have been resolved, we may crash\n" "\nQVariant_QVariant_from_bool: " + std::to_string(uintptr_t(QVariant_QVariant_from_bool)) + "\nSETTING_MigrationDisabled: " + std::to_string(uintptr_t(SETTING_MigrationDisabled)) ).c_str(), ERROR_MSGBOX_CAPTION, MB_ICONERROR); + } if (setting == SETTING_MigrationDisabled) {