Skip to content

Commit

Permalink
show message box about missing symbols only once
Browse files Browse the repository at this point in the history
  • Loading branch information
p0358 committed Oct 28, 2023
1 parent 69b26e1 commit 692c2fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/main/ealink_exe_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ namespace EALinkExePatches
static auto SETTING_MigrationDisabled = GetExport<void*>(EALinkExe, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@A"); // non-const symbol
if (!SETTING_MigrationDisabled)
SETTING_MigrationDisabled = GetExport<void*>(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)
{
Expand Down
13 changes: 9 additions & 4 deletions src/main/origin_client_dll_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*(__thiscall*)(void*, bool)>(Qt5Core, "??0QVariant@@QAE@_N@Z");
static auto SETTING_MigrationDisabled = GetExport<void*>(OriginClient, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@A");
static auto SETTING_MigrationDisabled = GetExport<void*>(OriginClient, "?SETTING_MigrationDisabled@Services@Origin@@3VSetting@12@A"); // non-const symbol
if (!SETTING_MigrationDisabled)
SETTING_MigrationDisabled = GetExport<void*>(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<void*>(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)
{
Expand Down

0 comments on commit 692c2fb

Please sign in to comment.