From 79f71f3dd4bf62637ba9179d8ab07afc39b893c3 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 11 Nov 2026 10:16:02 +0000 Subject: [PATCH] Maintenance: Centralize the 4 remaining EncryptedText copies (GameModePackets, ServiceConfiguration, SoundConfiguration, AccountLinke Batch #16859 by ragnarok-clanker: no function's compiled code changes; checked with 4 compiled unit(s). --- Source/Client/Mode/GameModePackets.cpp | 38 ++--------------- .../Configuration/ServiceConfiguration.cpp | 41 ++----------------- Source/Contents/Sound/SoundConfiguration.cpp | 34 +-------------- .../UserData/AccountLinkedUserDataMgr.cpp | 35 +--------------- 4 files changed, 10 insertions(+), 138 deletions(-) diff --git a/Source/Client/Mode/GameModePackets.cpp b/Source/Client/Mode/GameModePackets.cpp index d0e8d5b23..2fcac2c27 100644 --- a/Source/Client/Mode/GameModePackets.cpp +++ b/Source/Client/Mode/GameModePackets.cpp @@ -146,6 +146,7 @@ #include "UI/Guild/UIGuild_Storage_Log.h" #include "Contents/Actors/GroundScope.h" #include "Contents/Ground/TerrainHeight.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include // OFFSET: 0x00D7AF70 @@ -178,7 +179,6 @@ void __fastcall RefreshPartyWindows(CSession* session); // GLOBAL: gl_24992 char g_pendingWhisperCount; - namespace { #pragma pack(push, 1) struct SimulationPacketHeader { @@ -4538,7 +4538,6 @@ void CGameMode::ReceiveParChange(unsigned char* data) { g_modeMgr.GetGameMode(); std::string text; - switch (packet->type) { case SP_SPEED: if (*reinterpret_cast(&g_session.healthPoints[0]) != packet->value) { @@ -15610,37 +15609,6 @@ void CGameMode::ReceiveTaggedBroadcast(const unsigned char* data) { } } -namespace { - template - class EncryptedText { - public: - explicit EncryptedText(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedText() { - 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(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; -} - // OFFSET: 0x00D231F0 // FUNCTION: fn_21661 void CGameMode::ReceiveRefineStatusGraded(const char* playerName, int itemId, unsigned char refine, unsigned char grade, bool success) { @@ -15652,10 +15620,10 @@ void CGameMode::ReceiveRefineStatusGraded(const char* playerName, int itemId, un int job = 0; const std::uint8_t signatureSource[] = {0x1B, 0x2D, 0xBB, 0xD1}; - thread_local EncryptedText signature(signatureSource); + thread_local EncryptedName signature(signatureSource); const char* signatureText = signature.Text(); const std::uint8_t functionSource[] = {0xB6, 0xA2, 0x4D, 0x4C, 0x66, 0x0C, 0x26, 0x81, 0xBB, 0xA8, 0x5B, 0x09}; - thread_local EncryptedText function(functionSource); + thread_local EncryptedName function(functionSource); g_session.m_hotkeyScript->Call(function.Text(), signatureText, itemId, &job); if (job != 0) { item.identity[0] = 0x15; diff --git a/Source/Contents/Configuration/ServiceConfiguration.cpp b/Source/Contents/Configuration/ServiceConfiguration.cpp index a736f72aa..b36e68aa6 100644 --- a/Source/Contents/Configuration/ServiceConfiguration.cpp +++ b/Source/Contents/Configuration/ServiceConfiguration.cpp @@ -20,6 +20,7 @@ #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" #include "UI/Login/UILoginWnd.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -118,53 +119,17 @@ const int s_monsterJobIds[48] = { 9100786, 9100787, 9100788, 9100789, 9100790, 9100791, 9100792, 9100793 }; -template -class EncryptedText { -public: - explicit EncryptedText(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - explicit EncryptedText(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedText() { - 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(this->m_text); - } - -private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptText(const std::uint8_t (&source)[Length]) { - thread_local EncryptedText text(source); + thread_local EncryptedName text(source); return text.Text(); } // INLINED template const char* DecryptString(const char (&source)[Length]) { - thread_local EncryptedText text(source); + thread_local EncryptedName text(source); return text.Text(); } diff --git a/Source/Contents/Sound/SoundConfiguration.cpp b/Source/Contents/Sound/SoundConfiguration.cpp index 1486ab6da..67e432e81 100644 --- a/Source/Contents/Sound/SoundConfiguration.cpp +++ b/Source/Contents/Sound/SoundConfiguration.cpp @@ -4,45 +4,15 @@ #include "UI/Dialogs/UITipOfTheDayWnd.h" #include "UI/GameSettings/GameSettingsUI.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include -template -class EncryptedText { -public: - // INLINED - template - explicit EncryptedText(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedText() { - 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(this->m_text); - } - -private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptText(const Byte (&source)[Length]) { - thread_local EncryptedText text(source); + thread_local EncryptedName text(source); return text.Text(); } diff --git a/Source/Contents/UserData/AccountLinkedUserDataMgr.cpp b/Source/Contents/UserData/AccountLinkedUserDataMgr.cpp index 20f000c19..5a3601e07 100644 --- a/Source/Contents/UserData/AccountLinkedUserDataMgr.cpp +++ b/Source/Contents/UserData/AccountLinkedUserDataMgr.cpp @@ -10,6 +10,7 @@ #include "Contents/Messenger/WhisperBlockMgr.h" #include "Utility/Async/AsyncDiagnostic.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -17,42 +18,10 @@ #include namespace { - template - class EncryptedText { - public: - // INLINED - explicit EncryptedText(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - ~EncryptedText() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - // INLINED - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptText(const std::uint8_t (&source)[Length]) { - thread_local EncryptedText text(source); + thread_local EncryptedName text(source); return text.Text(); }