TrinityCore
WardenCheckMgr.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 _WARDENCHECKMGR_H
19#define _WARDENCHECKMGR_H
20
21#include "Define.h"
22#include "World.h"
23#include <unordered_map>
24#include <vector>
25
26// EnumUtils: DESCRIBE THIS
28{
29 WARDEN_ACTION_LOG, // TITLE Log
30 WARDEN_ACTION_KICK, // TITLE Kick
31 WARDEN_ACTION_BAN // TITLE Ban
32};
33
34// EnumUtils: DESCRIBE THIS
36{
37 INJECT_CHECK_CATEGORY = 0, // checks that test whether the client's execution has been interfered with
38 LUA_CHECK_CATEGORY, // checks that test whether the lua sandbox has been modified
39 MODDED_CHECK_CATEGORY, // checks that test whether the client has been modified
40
42};
43
44// EnumUtils: DESCRIBE THIS
46{
47 NONE_CHECK = 0, // SKIP
48 TIMING_CHECK = 87, // nyi
49 DRIVER_CHECK = 113, // uint Seed + byte[20] SHA1 + byte driverNameIndex (check to ensure driver isn't loaded)
50 PROC_CHECK = 126, // nyi
51 LUA_EVAL_CHECK = 139, // evaluate arbitrary Lua check
52 MPQ_CHECK = 152, // get hash of MPQ file (to check it is not modified)
53 PAGE_CHECK_A = 178, // scans all pages for specified SHA1 hash
54 PAGE_CHECK_B = 191, // scans only pages starts with MZ+PE headers for specified hash
55 MODULE_CHECK = 217, // check to make sure module isn't injected
56 MEM_CHECK = 243, // retrieve specific memory
57};
58
60{
61 switch (type)
62 {
72 default: return NUM_CHECK_CATEGORIES;
73 }
74}
75
77{
78 switch (category)
79 {
83 default: return INT_CONFIG_VALUE_COUNT;
84 }
85}
86
88{
89 switch (category)
90 {
91 case INJECT_CHECK_CATEGORY: return false;
92 case LUA_CHECK_CATEGORY: return true;
93 case MODDED_CHECK_CATEGORY: return false;
94 default: return false;
95 }
96}
97
99{
102 std::vector<uint8> Data;
103 uint32 Address = 0; // PROC_CHECK, MEM_CHECK, PAGE_CHECK
104 uint8 Length = 0; // PROC_CHECK, MEM_CHECK, PAGE_CHECK
105 std::string Str; // LUA, MPQ, DRIVER
106 std::string Comment;
107 std::array<char, 4> IdStr = {}; // LUA
109};
110
112
113using WardenCheckResult = std::vector<uint8>;
114
116{
117 private:
119
120 public:
121 static WardenCheckMgr* instance();
122
123 uint16 GetMaxValidCheckId() const { return static_cast<uint16>(_checks.size()); }
124 WardenCheck const& GetCheckData(uint16 Id) const;
125 WardenCheckResult const& GetCheckResult(uint16 Id) const;
126
127 std::vector<uint16> const& GetAvailableChecks(WardenCheckCategory category) { return _pools[category]; }
128
129 void LoadWardenChecks();
130 void LoadWardenOverrides();
131
132 private:
133 std::vector<WardenCheck> _checks;
134 std::unordered_map<uint16, WardenCheckResult> _checkResults;
135 std::array<std::vector<uint16>, NUM_CHECK_CATEGORIES> _pools;
136};
137
138#define sWardenCheckMgr WardenCheckMgr::instance()
139
140#endif
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
constexpr uint8 WARDEN_MAX_LUA_CHECK_LENGTH
constexpr bool IsWardenCategoryInWorldOnly(WardenCheckCategory category)
constexpr WorldIntConfigs GetWardenCategoryCountConfig(WardenCheckCategory category)
std::vector< uint8 > WardenCheckResult
constexpr WardenCheckCategory GetWardenCheckCategory(WardenCheckType type)
WardenCheckCategory
@ NUM_CHECK_CATEGORIES
@ MODDED_CHECK_CATEGORY
@ LUA_CHECK_CATEGORY
@ INJECT_CHECK_CATEGORY
WardenCheckType
@ PROC_CHECK
@ DRIVER_CHECK
@ PAGE_CHECK_A
@ PAGE_CHECK_B
@ LUA_EVAL_CHECK
@ MPQ_CHECK
@ MEM_CHECK
@ TIMING_CHECK
@ MODULE_CHECK
@ NONE_CHECK
WardenActions
@ WARDEN_ACTION_KICK
@ WARDEN_ACTION_BAN
@ WARDEN_ACTION_LOG
Action
std::vector< WardenCheck > _checks
std::unordered_map< uint16, WardenCheckResult > _checkResults
uint16 GetMaxValidCheckId() const
std::array< std::vector< uint16 >, NUM_CHECK_CATEGORIES > _pools
std::vector< uint16 > const & GetAvailableChecks(WardenCheckCategory category)
WorldIntConfigs
Definition: World.h:232
@ CONFIG_WARDEN_NUM_LUA_CHECKS
Definition: World.h:389
@ INT_CONFIG_VALUE_COUNT
Definition: World.h:441
@ CONFIG_WARDEN_NUM_CLIENT_MOD_CHECKS
Definition: World.h:390
@ CONFIG_WARDEN_NUM_INJECT_CHECKS
Definition: World.h:388
std::array< char, 4 > IdStr
std::vector< uint8 > Data
std::string Str
std::string Comment
WardenCheckType Type