From af01a4fcd414ddb67696f633bc7cfb67fb9f080e Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 13:52:51 +0000 Subject: [PATCH] Decompile fn_24371 (ReplaceClientExecutable) Batch #8061 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_24371 ReplaceClientExecutable: logic confirmed by peer review Peer-reviewed-by: eAthena, secret Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Application/Launcher.cpp | 42 ++++++++++++++++++++++++++ Source/Client/Application/Launcher.h | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Source/Client/Application/Launcher.cpp b/Source/Client/Application/Launcher.cpp index 66a08c82..793c4e0b 100644 --- a/Source/Client/Application/Launcher.cpp +++ b/Source/Client/Application/Launcher.cpp @@ -10,6 +10,7 @@ #include #include #include +#include // STATIC: 0x0173ad64 // GLOBAL: gl_24472 @@ -760,3 +761,44 @@ HANDLE StartClientProcess(char* program) { CreateProcessA(nullptr, commandLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startup, &process); return process.hProcess; } + +// OFFSET: 0x00E5C100 +// FUNCTION: fn_24371 +bool ReplaceClientExecutable(char* executable, const char* update) { + ApplyAiPatch(); + if (_access(update, 0) != 0) { + return false; + } + + const char* format; + if (g_serviceType == 12) { + const std::uint8_t messageSource[] = {0xBA, 0xB0, 0x67, 0xDB, 0x84, 0x2E, 0xC1, 0xFC, 0xF0, 0xA7, 0x2E, 0xDB, 0x82, 0x24, 0x80, 0xF5, + 0xFE, 0xED, 0x67, 0xFE, 0x87, 0x2E, 0x90, 0xE4, 0xFA, 0xE3, 0x22, 0xD0, 0xCB, 0x08, 0x8A, 0xB1, + 0xEF, 0xA2, 0x35, 0xDC, 0xCB, 0x24, 0x8E, 0xFF, 0xEB, 0xAA, 0x29, 0xC8, 0x8A, 0x35, 0xCF, 0x91}; + thread_local EncryptedName message(messageSource); + format = message.Text(); + } else { + const std::uint8_t messageSource[] = {0x24, 0x24, 0xB7, 0xB6, 0x60, 0xA5, 0x30, 0xB9, 0x60, 0x39, 0xF0, 0xBA, 0x77, 0xAB, 0x73, 0x81, 0x73, 0x32, + 0xE4, 0xAC, 0x33, 0xEA, 0x38, 0xF1, 0x75, 0x38, 0xB7, 0xAD, 0x76, 0xF6, 0x27, 0xB0, 0x73, 0x23, 0x97}; + thread_local EncryptedName message(messageSource); + format = message.Text(); + } + + char text[256]; + std::sprintf(text, format, executable); + + const std::uint8_t titleSource[] = {0x0C, 0x49, 0xFC, 0x3B, 0x27, 0x43}; + thread_local EncryptedName title(titleSource); + if (MessageBoxA(nullptr, text, title.Text(), MB_OKCANCEL | MB_ICONINFORMATION) != IDOK) { + return false; + } + + _chmod(executable, _S_IWRITE); + _unlink(executable); + if (std::rename(update, executable) != 0) { + return false; + } + + StartClientProcess(executable); + return true; +} diff --git a/Source/Client/Application/Launcher.h b/Source/Client/Application/Launcher.h index 20912c71..7cef8eba 100644 --- a/Source/Client/Application/Launcher.h +++ b/Source/Client/Application/Launcher.h @@ -19,6 +19,6 @@ extern char g_launchAccountPassword[24]; extern char g_launchAccountSex; extern bool g_launchPassCommandLine; -HANDLE StartClientProcess(char* program); +__declspec(noinline) HANDLE StartClientProcess(char* program); #endif