File tree Expand file tree Collapse file tree
ZHMModSDK/Include/Glacier Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,5 +26,41 @@ class TCheatProtect {
2626template <>
2727class TCheatProtect <ZString> {
2828public:
29+ ZString GetValue () {
30+ const uint32_t s_Length = m_sScrambledString.size ();
31+
32+ std::vector<uint8_t > s_Buffer (s_Length);
33+
34+ memcpy (s_Buffer.data (), m_sScrambledString.c_str (), s_Length);
35+
36+ for (uint32_t i = 0 ; i < s_Length - 1 ; ++i) {
37+ s_Buffer[i] ^= static_cast <uint8_t >(s_Buffer[i + 1 ] + m_sScrambledString.m_nLength );
38+ }
39+
40+ s_Buffer[s_Length - 1 ] ^= static_cast <uint8_t >(m_sScrambledString.m_nLength );
41+
42+ return ZString::AllocateFromCStr (
43+ reinterpret_cast <const char *>(s_Buffer.data ()), s_Length
44+ );
45+ }
46+
47+ void SetValue (const ZString& s_Value) {
48+ const uint32_t s_Length = m_sScrambledString.size ();
49+
50+ std::vector<uint8_t > s_Buffer (s_Length);
51+
52+ memcpy (s_Buffer.data (), s_Value.c_str (), s_Length);
53+
54+ s_Buffer[s_Length - 1 ] ^= static_cast <uint8_t >(s_Value.m_nLength );
55+
56+ for (uint32_t i = s_Length - 2 ; i >= 0 ; --i) {
57+ s_Buffer[i] ^= static_cast <uint8_t >(s_Buffer[i + 1 ] + s_Value.m_nLength );
58+ }
59+
60+ m_sScrambledString = ZString::AllocateFromCStr (
61+ reinterpret_cast <const char *>(s_Buffer.data ()), s_Length
62+ );
63+ }
64+
2965 ZString m_sScrambledString;
3066};
You can’t perform that action at this time.
0 commit comments