TrinityCore
Loading...
Searching...
No Matches
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 <shared_mutex>
24#include <unordered_map>
25#include <vector>
26
27// EnumUtils: DESCRIBE THIS
29{
30 WARDEN_ACTION_LOG, // TITLE Log
31 WARDEN_ACTION_KICK, // TITLE Kick
32 WARDEN_ACTION_BAN // TITLE Ban
33};
34
35// EnumUtils: DESCRIBE THIS
37{
38 INJECT_CHECK_CATEGORY = 0, // checks that test whether the client's execution has been interfered with
39 LUA_CHECK_CATEGORY, // checks that test whether the lua sandbox has been modified
40 MODDED_CHECK_CATEGORY, // checks that test whether the client has been modified
41
43};
44
45// EnumUtils: DESCRIBE THIS
47{
48 NONE_CHECK = 0, // SKIP
49 TIMING_CHECK = 87, // nyi
50 DRIVER_CHECK = 113, // uint Seed + byte[20] SHA1 + byte driverNameIndex (check to ensure driver isn't loaded)
51 PROC_CHECK = 126, // nyi
52 LUA_EVAL_CHECK = 139, // evaluate arbitrary Lua check
53 MPQ_CHECK = 152, // get hash of MPQ file (to check it is not modified)
54 PAGE_CHECK_A = 178, // scans all pages for specified SHA1 hash
55 PAGE_CHECK_B = 191, // scans only pages starts with MZ+PE headers for specified hash
56 MODULE_CHECK = 217, // check to make sure module isn't injected
57 MEM_CHECK = 243, // retrieve specific memory
58};
59
61{
62 switch (type)
63 {
73 default: return NUM_CHECK_CATEGORIES;
74 }
75}
76
87
89{
90 switch (category)
91 {
92 case INJECT_CHECK_CATEGORY: return false;
93 case LUA_CHECK_CATEGORY: return true;
94 case MODDED_CHECK_CATEGORY: return false;
95 default: return false;
96 }
97}
98
100{
103 std::vector<uint8> Data;
104 uint32 Address = 0; // PROC_CHECK, MEM_CHECK, PAGE_CHECK
105 uint8 Length = 0; // PROC_CHECK, MEM_CHECK, PAGE_CHECK
106 std::string Str; // LUA, MPQ, DRIVER
107 std::string Comment;
108 std::array<char, 4> IdStr = {}; // LUA
110};
111
113
114using WardenCheckResult = std::vector<uint8>;
115
117{
118 private:
120
121 public:
122 static WardenCheckMgr* instance();
123
124 uint16 GetMaxValidCheckId() const { return static_cast<uint16>(_checks.size()); }
125 WardenCheck const& GetCheckData(uint16 Id) const;
126 WardenCheckResult const& GetCheckResult(uint16 Id) const;
127
128 std::vector<uint16> const& GetAvailableChecks(WardenCheckCategory category) { return _pools[category]; }
129
130 void LoadWardenChecks();
131 void LoadWardenOverrides();
132
133 private:
134 std::vector<WardenCheck> _checks;
135 std::unordered_map<uint16, WardenCheckResult> _checkResults;
136 std::array<std::vector<uint16>, NUM_CHECK_CATEGORIES> _pools;
137};
138
139#define sWardenCheckMgr WardenCheckMgr::instance()
140
141#endif
#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
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:210
@ CONFIG_WARDEN_NUM_LUA_CHECKS
Definition World.h:363
@ INT_CONFIG_VALUE_COUNT
Definition World.h:404
@ CONFIG_WARDEN_NUM_CLIENT_MOD_CHECKS
Definition World.h:364
@ CONFIG_WARDEN_NUM_INJECT_CHECKS
Definition World.h:362
std::array< char, 4 > IdStr
std::vector< uint8 > Data
std::string Str
std::string Comment
WardenCheckType Type