Skip to content

Commit

Permalink
fix origin update installation, hopefully this time for good
Browse files Browse the repository at this point in the history
  • Loading branch information
p0358 committed Jan 12, 2025
1 parent cc4d68e commit 27c44b8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern CModule Qt5Network;
extern void DoOriginExePatches();
extern void DoOriginClientServiceExePatches();
extern void DoOriginClientDllPatches();
extern void DoOriginThinSetupInternalExePatches();
extern void DoEALinkExePatches();

template<typename T>
Expand Down
55 changes: 55 additions & 0 deletions src/main/origin_thin_setup_internal_patches.cpp
Original file line number Diff line number Diff line change
@@ -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<void(__thiscall*)(void*)>(Qt5Core, "??1QString@@QAE@XZ");
static auto QString_toStdString = GetExport<void* (__thiscall*)(void*, std::string*)>(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<void* (__thiscall*)(void*, const char*)>(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<LPVOID*>(&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);
}
}

0 comments on commit 27c44b8

Please sign in to comment.