From 27c44b8bd6552874f5543255d4eaaadfa82400b1 Mon Sep 17 00:00:00 2001 From: p0358 Date: Sun, 12 Jan 2025 23:28:39 +0100 Subject: [PATCH] fix origin update installation, hopefully this time for good --- src/main/main.cpp | 8 +++ src/main/main.hpp | 1 + .../origin_thin_setup_internal_patches.cpp | 55 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/main/origin_thin_setup_internal_patches.cpp diff --git a/src/main/main.cpp b/src/main/main.cpp index f863339..be062db 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -54,6 +54,7 @@ void InternalSetup() auto exe_name = GetExeName(); bool isOriginExe = exe_name == "Origin.exe"; bool isOriginClientServiceExe = exe_name == "OriginClientService.exe"; + bool isOriginThinSetupInternalExe = exe_name == "OriginThinSetupInternal.exe"; bool isEALinkExe = exe_name == "EALink.exe"; OriginExe = CModule("Origin.exe", uintptr_t(GetModuleHandleA(nullptr))); @@ -76,6 +77,13 @@ void InternalSetup() DoOriginClientServiceExePatches(); } + else if (isOriginThinSetupInternalExe) + { + // statically imported by OriginThinSetupInternal.exe + Qt5Core = CModule("Qt5Core.dll"); + + DoOriginThinSetupInternalExePatches(); + } else if (isEALinkExe) { // statically imported by EALinkExe.exe diff --git a/src/main/main.hpp b/src/main/main.hpp index ca4ce76..a370018 100644 --- a/src/main/main.hpp +++ b/src/main/main.hpp @@ -21,6 +21,7 @@ extern CModule Qt5Network; extern void DoOriginExePatches(); extern void DoOriginClientServiceExePatches(); extern void DoOriginClientDllPatches(); +extern void DoOriginThinSetupInternalExePatches(); extern void DoEALinkExePatches(); template diff --git a/src/main/origin_thin_setup_internal_patches.cpp b/src/main/origin_thin_setup_internal_patches.cpp new file mode 100644 index 0000000..491c932 --- /dev/null +++ b/src/main/origin_thin_setup_internal_patches.cpp @@ -0,0 +1,55 @@ +// Patches for OriginClientService.exe + +#include "pch.hpp" +#include "main.hpp" + +namespace OriginThinSetupInternalExePatches +{ + // Origin::ThinSetup::ThinSetupController::onDownloadUpdateContent + bool(__thiscall* onDownloadUpdateContent_org)(uint32_t**); + bool __fastcall onDownloadUpdateContent_hook(uint32_t** thisptr) + { + static auto QString_destroy = GetExport(Qt5Core, "??1QString@@QAE@XZ"); + static auto QString_toStdString = GetExport(Qt5Core, "?toStdString@QString@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ"); + static auto QString_QString_from_cchar = GetExport(Qt5Core, "??0QString@@QAE@PBD@Z"); + + if (QString_destroy && QString_toStdString && QString_QString_from_cchar) + { + void* updateURL = thisptr[17] + 17; + + std::string qss; + QString_toStdString(updateURL, &qss); + //MessageBoxA(0, qss.c_str(), "updateURL", 0); + + if (qss == "https://origin-a.akamaihd.net/Stage-Origin-Client-Download/origin/live/OriginUpdate_10_5_129_55742.zip") + { + QString_destroy(updateURL); + QString_QString_from_cchar(updateURL, "https://origin-a.akamaihd.net/Origin-Client-Download/origin/live/OriginUpdate_10_5_129_55742.zip"); + + std::string qss; + QString_toStdString(updateURL, &qss); + //MessageBoxA(0, qss.c_str(), "updateURL overriden", 0); + } + } + + auto ret = onDownloadUpdateContent_org(thisptr); + return ret; + } +} + +void DoOriginThinSetupInternalExePatches() +{ + using namespace OriginThinSetupInternalExePatches; + + auto OriginExe = CModule("OriginThinSetupInternal.exe", uintptr_t(GetModuleHandleA(nullptr))); + + auto onDownloadUpdateContent_adr = CMemory(OriginExe.GetModuleBase()).FindPattern("55 8B EC 6A ? 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC ? 56 A1 ? ? ? ? 33 C5 50 8D 45 ? 64 A3 ? ? ? ? 8B F1 8B 4E ? 8D 45 ? 50 E8 ? ? ? ? 68", CMemory::Direction::DOWN, 25 * 1024 * 1024); + if (onDownloadUpdateContent_adr) + { + CreateHook(onDownloadUpdateContent_adr.GetPtr(), onDownloadUpdateContent_hook, reinterpret_cast(&onDownloadUpdateContent_org)); + } + else + { + MessageBoxA(nullptr, "Failed resolving pattern of Origin::ThinSetup::ThinSetupController::onDownloadUpdateContent, we may fail to fix up Origin update.", ERROR_MSGBOX_CAPTION, MB_ICONERROR); + } +}