|
| 1 | +// Patches for OriginClientService.exe |
| 2 | + |
| 3 | +#include "pch.hpp" |
| 4 | +#include "main.hpp" |
| 5 | + |
| 6 | +namespace OriginThinSetupInternalExePatches |
| 7 | +{ |
| 8 | + // Origin::ThinSetup::ThinSetupController::onDownloadUpdateContent |
| 9 | + bool(__thiscall* onDownloadUpdateContent_org)(uint32_t**); |
| 10 | + bool __fastcall onDownloadUpdateContent_hook(uint32_t** thisptr) |
| 11 | + { |
| 12 | + static auto QString_destroy = GetExport<void(__thiscall*)(void*)>(Qt5Core, "??1QString@@QAE@XZ"); |
| 13 | + 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"); |
| 14 | + static auto QString_QString_from_cchar = GetExport<void* (__thiscall*)(void*, const char*)>(Qt5Core, "??0QString@@QAE@PBD@Z"); |
| 15 | + |
| 16 | + if (QString_destroy && QString_toStdString && QString_QString_from_cchar) |
| 17 | + { |
| 18 | + void* updateURL = thisptr[17] + 17; |
| 19 | + |
| 20 | + std::string qss; |
| 21 | + QString_toStdString(updateURL, &qss); |
| 22 | + //MessageBoxA(0, qss.c_str(), "updateURL", 0); |
| 23 | + |
| 24 | + if (qss == "https://origin-a.akamaihd.net/Stage-Origin-Client-Download/origin/live/OriginUpdate_10_5_129_55742.zip") |
| 25 | + { |
| 26 | + QString_destroy(updateURL); |
| 27 | + QString_QString_from_cchar(updateURL, "https://origin-a.akamaihd.net/Origin-Client-Download/origin/live/OriginUpdate_10_5_129_55742.zip"); |
| 28 | + |
| 29 | + std::string qss; |
| 30 | + QString_toStdString(updateURL, &qss); |
| 31 | + //MessageBoxA(0, qss.c_str(), "updateURL overriden", 0); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + auto ret = onDownloadUpdateContent_org(thisptr); |
| 36 | + return ret; |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +void DoOriginThinSetupInternalExePatches() |
| 41 | +{ |
| 42 | + using namespace OriginThinSetupInternalExePatches; |
| 43 | + |
| 44 | + auto OriginExe = CModule("OriginThinSetupInternal.exe", uintptr_t(GetModuleHandleA(nullptr))); |
| 45 | + |
| 46 | + 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); |
| 47 | + if (onDownloadUpdateContent_adr) |
| 48 | + { |
| 49 | + CreateHook(onDownloadUpdateContent_adr.GetPtr(), onDownloadUpdateContent_hook, reinterpret_cast<LPVOID*>(&onDownloadUpdateContent_org)); |
| 50 | + } |
| 51 | + else |
| 52 | + { |
| 53 | + MessageBoxA(nullptr, "Failed resolving pattern of Origin::ThinSetup::ThinSetupController::onDownloadUpdateContent, we may fail to fix up Origin update.", ERROR_MSGBOX_CAPTION, MB_ICONERROR); |
| 54 | + } |
| 55 | +} |
0 commit comments