Skip to content

Commit

Permalink
extra patches to disable migration in native side
Browse files Browse the repository at this point in the history
  • Loading branch information
p0358 committed Jun 24, 2023
1 parent fc5c95c commit 2e7e2d4
Showing 1 changed file with 64 additions and 3 deletions.
67 changes: 64 additions & 3 deletions src/main/origin_client_dll_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,76 @@
void*(__stdcall *findUserMigrationTimePeriod_org)(void*);
void* __stdcall findUserMigrationTimePeriod_hook(void* a1)
{
// just return an empty Qt JSON object
static auto QJsonObject_QJsonObject = GetExport<void*(__thiscall*)(void*)>(Qt5Core, "??0QJsonObject@@QAE@XZ");
static auto QJsonObject_QJsonObject_destruct = GetExport<void*(__thiscall*)(void*)>(Qt5Core, "??1QJsonObject@@QAE@XZ");
static auto QJsonObject_toVariantMap = GetExport<void*(__thiscall*)(void*, void*)>(Qt5Core, "?toVariantMap@QJsonObject@@QBE?AV?$QMap@VQString@@VQVariant@@@@XZ");
if (!QJsonObject_QJsonObject || !QJsonObject_QJsonObject_destruct || !QJsonObject_toVariantMap)
MessageBoxA(nullptr, "Error in findUserMigrationTimePeriod: one of the functions could not have been resolved, we will crash", ERROR_MSGBOX_CAPTION, MB_ICONERROR);
if (!QJsonObject_QJsonObject || !QJsonObject_QJsonObject_destruct || !QJsonObject_toVariantMap) [[unlikely]]
MessageBoxA(nullptr, ("Error in Origin::Client::JsInterface::ClientSettingsProxy::findUserMigrationTimePeriod: one of the functions could not have been resolved, we will crash\n"
"\nQJsonObject_QJsonObjectl: " + std::to_string(uintptr_t(QJsonObject_QJsonObject))
+ "\nQJsonObject_QJsonObject_destruct: " + std::to_string(uintptr_t(QJsonObject_QJsonObject_destruct))
+ "\nQJsonObject_toVariantMap: " + std::to_string(uintptr_t(QJsonObject_toVariantMap))
).c_str(),
ERROR_MSGBOX_CAPTION, MB_ICONERROR);

// just return an empty Qt JSON object
char json[12] = { 0 };
QJsonObject_QJsonObject(&json);
QJsonObject_toVariantMap(&json, a1);
QJsonObject_QJsonObject_destruct(&json);
return a1;
}

struct migrationConfigDummyStruct
{
bool bool0;
bool bool1;
char pad[12];
int int16;
int int20;
int int24;
int int28;
int int32;
int int36;
int int40;
int int44;
};

// Origin::Services::OriginConfigService::migrationConfig
migrationConfigDummyStruct* (__thiscall* migrationConfig_org)(void*, migrationConfigDummyStruct*);
migrationConfigDummyStruct* __fastcall migrationConfig_hook(void* thisptr, void* /*edx*/, migrationConfigDummyStruct* cfg)
{
migrationConfig_org(thisptr, cfg);
cfg->bool0 = false;
cfg->bool1 = false;
return cfg;
}

// Origin::Services::readSetting
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");
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"
"\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)
{
// override to true
char qv[16] = { 0 };
QVariant_QVariant_from_bool(out_qv, true); // caller will destruct this
return out_qv;
}

return readSetting_org(out_qv, setting, a3, a4);
}

void DoOriginClientDllPatches()
{
{
Expand Down Expand Up @@ -49,4 +106,8 @@ void DoOriginClientDllPatches()

// The function hooked below is used by the primary EA App migration screen, to determine whether said screen should be displayed
CreateHookNamed("OriginClient", "?findUserMigrationTimePeriod@ClientSettingsProxy@JsInterface@Client@Origin@@QAE?AV?$QMap@VQString@@VQVariant@@@@XZ", findUserMigrationTimePeriod_hook, reinterpret_cast<LPVOID*>(&findUserMigrationTimePeriod_org));

// This is for native parts of Origin that check migration config, apart from the JavaScript UI and its notice
CreateHookNamed("OriginClient", "?migrationConfig@OriginConfigService@Services@Origin@@QBE?AUMigrationConfigT@server@@XZ", migrationConfig_hook, reinterpret_cast<LPVOID*>(&migrationConfig_org));
CreateHookNamed("OriginClient", "?readSetting@Services@Origin@@YA?AVVariant@12@ABVSetting@12@V?$QSharedPointer@VAbstractSession@Session@Services@Origin@@@@@Z", readSetting_hook, reinterpret_cast<LPVOID*>(&readSetting_org));
}

0 comments on commit 2e7e2d4

Please sign in to comment.