Decompile 3 functions in Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp

Batch #10625 by cremane: 0 byte-identical, 3 confirmed by peer review.

- fn_03916 CCharacterLinkedUserDataLoadAsyncWork::CCharacterLinkedUserDataLoadAsyncWork: logic confirmed by peer review
- fn_03918 CCharacterLinkedUserDataLoadAsyncWork::Bind: logic confirmed by peer review
- fn_03921 CCharacterLinkedUserDataLoadAsyncWork::Execute: logic confirmed by peer review

Peer-reviewed-by: ragnarok-clanker, Tanke, StrawberrysherbetIX
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-04 16:59:31 +00:00
commit 986a10f543

View file

@ -2,6 +2,8 @@
#include "Contents/UserData/CharacterLinkedUserDataMgr.h"
#include "Network/Http/CURLPostHander.h"
#include "Network/TextEncoding.h"
#include "Utility/Cipher/XorBytes.h"
#include "Utility/Text/FormatString.h"
#include <cstdio>
#include <windows.h>
@ -13,16 +15,53 @@ namespace {
"aracterLinkedUserDataLoadAsyncWork.cpp";
// INLINED
AsyncDiagnostic Diagnostic(bool success, const char* text, std::uint32_t line) {
__forceinline AsyncDiagnostic Diagnostic(bool success, const char* text, std::uint32_t line) {
std::string message = text;
return AsyncDiagnostic(&success, &message, sourceFile, &line);
}
template <std::size_t Length, std::uint64_t Key>
class EncryptedName {
public:
explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) {
for (std::uint64_t index = 0; index < Length; ++index) {
this->m_text[index] = source[index];
}
}
~EncryptedName() {
for (std::uint64_t index = 0; index < Length; ++index) {
this->m_text[index] = 0;
}
}
const char* Text() {
if (this->m_encrypted) {
utility::XorBytes(this->m_text, Length, Key);
this->m_encrypted = false;
}
return reinterpret_cast<const char*>(this->m_text);
}
private:
/* 0000 */ std::uint8_t m_text[Length];
bool m_encrypted;
};
// INLINED
template <std::uint64_t Key, std::size_t Length>
const char* DecryptName(const std::uint8_t (&source)[Length]) {
thread_local EncryptedName<Length, Key> name(source);
return name.Text();
}
}
// OFFSET: 0x005E4A50
// FUNCTION: fn_03916
CCharacterLinkedUserDataLoadAsyncWork::CCharacterLinkedUserDataLoadAsyncWork()
: NAsyncWork("CharacterLinkedUserData_Load"), m_accountId(0), m_characterId(0), m_diagnostic(Diagnostic(false, "unknwon", 29)) {
: NAsyncWork("CharacterLinkedUserData_Load"), m_accountId(0), m_characterId(0),
m_diagnostic(Diagnostic(false, DecryptName<0x17359BF953C367B3ULL>({0xC6, 0x09, 0xA8, 0x3D, 0x8E, 0xF4, 0x5B, 0x17}), 29)) {
}
// INLINED
@ -45,9 +84,10 @@ void CCharacterLinkedUserDataLoadAsyncWork::Bind(
this->m_accountName = accountName;
this->m_url = url;
this->m_token = token;
this->m_response.clear();
this->m_response = "";
AsyncDiagnostic diagnostic = Diagnostic(false, "unknwon", 55);
const std::uint8_t unknown[] = {0x52, 0x6F, 0x6C, 0x03, 0x74, 0xAA, 0x9D, 0x2F};
AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x2FF3C5036D070127ULL>(unknown), 55);
this->m_diagnostic.MoveFrom(diagnostic);
}
@ -55,20 +95,25 @@ void CCharacterLinkedUserDataLoadAsyncWork::Bind(
// FUNCTION: fn_03921
bool CCharacterLinkedUserDataLoadAsyncWork::Execute() {
char accountId[64] = {};
StringFormat(accountId, sizeof(accountId), _TRUNCATE, "%lu", this->m_accountId);
char characterId[64] = {};
_snprintf_s(accountId, sizeof(accountId), _TRUNCATE, "%d", static_cast<std::int32_t>(this->m_accountId));
_snprintf_s(characterId, sizeof(characterId), _TRUNCATE, "%d", static_cast<std::int32_t>(this->m_characterId));
StringFormat(characterId, sizeof(characterId), _TRUNCATE, "%lu", this->m_characterId);
std::string name = ToUtf8(this->m_accountName);
CCURLPostHander handler(this->m_url);
handler.AddField("AID", accountId, 4);
handler.AddField("GID", characterId, 4);
handler.AddField("AuthToken", this->m_token, 4);
handler.AddField("WorldName", name, 4);
const std::uint8_t aid[] = {0x5E, 0x78, 0x89, 0xE7};
handler.AddField(DecryptName<0x1D6D75EDE7CD311FULL>(aid), accountId, 4);
const std::uint8_t gid[] = {0x12, 0xB4, 0xF1, 0xDB};
handler.AddField(DecryptName<0x3375B1C7DBB5FD55ULL>(gid), characterId, 4);
const std::uint8_t authToken[] = {0xF6, 0x72, 0x23, 0xA5, 0x7F, 0x88, 0x40, 0xE4, 0xD9, 0x07};
handler.AddField(DecryptName<0x812BE72BCD5707B7ULL>(authToken), this->m_token, 4);
const std::uint8_t worldName[] = {0xF6, 0x52, 0xED, 0xBB, 0x07, 0xC1, 0x46, 0x34, 0xC4, 0x3D};
handler.AddField(DecryptName<0x59278F63D79F3DA1ULL>(worldName), name, 4);
if (handler.Perform() == 0) {
this->m_response = FromUtf8(handler.Response());
AsyncDiagnostic diagnostic = Diagnostic(true, "good", 103);
const std::uint8_t good[] = {0x0A, 0x8C, 0x2A, 0xC7, 0xED};
AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x31D7C1EDA345E36DULL>(good), 103);
this->m_diagnostic.MoveFrom(diagnostic);
}