TrinityCore
Loading...
Searching...
No Matches
Warden.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _WARDEN_BASE_H
19#define _WARDEN_BASE_H
20
21#include "ARC4.h"
22#include "AuthDefines.h"
23#include "ByteBuffer.h"
24#include "Optional.h"
25#include "WardenCheckMgr.h"
26#include <array>
27
29{
30 // Client->Server
34 WARDEN_CMSG_MEM_CHECKS_RESULT = 3, // only sent if MEM_CHECK bytes doesn't match
36 WARDEN_CMSG_MODULE_FAILED = 5, // this is sent when client failed to load uploaded module due to cache fail
37
38 // Server->Client
43 WARDEN_SMSG_MEM_CHECKS_REQUEST = 4, // byte len; while (!EOF) { byte unk(1); byte index(++); string module(can be 0); int offset; byte len; byte[] bytes_to_compare[len]; }
45};
46
47#pragma pack(push, 1)
48
50{
52 std::array<uint8, 16> ModuleId;
53 std::array<uint8, 16> ModuleKey;
55};
56static_assert(sizeof(WardenModuleUse) == (1 + 16 + 16 + 4));
57
64static_assert(sizeof(WardenModuleTransfer) == (1 + 2 + 500));
65
67{
69 std::array<uint8, 16> Seed;
70};
71static_assert(sizeof(WardenHashRequest) == (1 + 16));
72
73#pragma pack(pop)
74
76{
77 std::array<uint8, 16> Id;
78 std::array<uint8, 16> Key;
81};
82
83class WorldSession;
84
86{
87 public:
88 Warden();
89 virtual ~Warden();
90
91 virtual void Init(WorldSession* session, SessionKey const& K) = 0;
92 void Update(uint32 diff);
93 void HandleData(ByteBuffer& buff);
94 bool ProcessLuaCheckResponse(std::string const& msg);
95
96 virtual size_t DEBUG_ForceSpecificChecks(std::vector<uint16> const& checks) = 0;
97
98 protected:
99 void DecryptData(uint8* buffer, uint32 length);
100 void EncryptData(uint8* buffer, uint32 length);
101
102 virtual void InitializeModule() = 0;
103 virtual void RequestHash() = 0;
104 virtual void HandleHashResult(ByteBuffer& buff) = 0;
105 virtual void HandleCheckResult(ByteBuffer& buff) = 0;
107 virtual void RequestChecks() = 0;
108
109 void MakeModuleForClient();
110 void SendModuleToClient();
111 void RequestModule();
112
113 static bool IsValidCheckSum(uint32 checksum, const uint8 *data, const uint16 length);
114 static uint32 BuildChecksum(const uint8 *data, uint32 length);
115
116 // If nullptr is passed, the default action from config is executed
117 char const* ApplyPenalty(WardenCheck const* check);
118
120 std::array<uint8, 16> _inputKey = {};
121 std::array<uint8, 16> _outputKey = {};
122 std::array<uint8, 16> _seed = {};
125 uint32 _checkTimer; // Timer for sending check requests
126 uint32 _clientResponseTimer; // Timer for client response delay
130};
131
132#endif
std::array< uint8, SESSION_KEY_LENGTH > SessionKey
Definition AuthDefines.h:25
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
WardenOpcodes
Definition Warden.h:29
@ WARDEN_CMSG_MODULE_MISSING
Definition Warden.h:31
@ WARDEN_SMSG_MEM_CHECKS_REQUEST
Definition Warden.h:43
@ WARDEN_CMSG_HASH_RESULT
Definition Warden.h:35
@ WARDEN_CMSG_MODULE_FAILED
Definition Warden.h:36
@ WARDEN_SMSG_HASH_REQUEST
Definition Warden.h:44
@ WARDEN_CMSG_CHEAT_CHECKS_RESULT
Definition Warden.h:33
@ WARDEN_CMSG_MODULE_OK
Definition Warden.h:32
@ WARDEN_SMSG_MODULE_CACHE
Definition Warden.h:40
@ WARDEN_SMSG_MODULE_INITIALIZE
Definition Warden.h:42
@ WARDEN_SMSG_MODULE_USE
Definition Warden.h:39
@ WARDEN_CMSG_MEM_CHECKS_RESULT
Definition Warden.h:34
@ WARDEN_SMSG_CHEAT_CHECKS_REQUEST
Definition Warden.h:41
Data
virtual void InitializeModuleForClient(ClientWardenModule &module)=0
Optional< ClientWardenModule > _module
Definition Warden.h:128
uint32 _checkTimer
Definition Warden.h:125
uint32 _clientResponseTimer
Definition Warden.h:126
virtual void RequestHash()=0
Trinity::Crypto::ARC4 _outputCrypto
Definition Warden.h:124
Trinity::Crypto::ARC4 _inputCrypto
Definition Warden.h:123
virtual size_t DEBUG_ForceSpecificChecks(std::vector< uint16 > const &checks)=0
bool _dataSent
Definition Warden.h:127
virtual void InitializeModule()=0
virtual void Init(WorldSession *session, SessionKey const &K)=0
bool _initialized
Definition Warden.h:129
virtual void HandleCheckResult(ByteBuffer &buff)=0
virtual void RequestChecks()=0
WorldSession * _session
Definition Warden.h:119
virtual void HandleHashResult(ByteBuffer &buff)=0
Player session in the World.
uint8 const * CompressedData
Definition Warden.h:79
size_t CompressedSize
Definition Warden.h:80
std::array< uint8, 16 > Key
Definition Warden.h:78
std::array< uint8, 16 > Id
Definition Warden.h:77
std::array< uint8, 16 > Seed
Definition Warden.h:69
std::array< uint8, 16 > ModuleKey
Definition Warden.h:53
uint8 Command
Definition Warden.h:51
uint32 Size
Definition Warden.h:54
std::array< uint8, 16 > ModuleId
Definition Warden.h:52