forked from alimb2/Ayyware-Full-Fixed-Updated-2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetVars.h
86 lines (66 loc) · 1.87 KB
/
NetVars.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Credits to Valve and Shad0w
#pragma once
//uncomment me if you wish to dump netvars
//#define DUMP_NETVARS_TO_FILE
#include "CommonIncludes.h"
#include <memory>
class NetvarDatabase;
struct NetvarTable;
struct netvar_info_s
{
#ifdef DUMP_NETVARS_TO_FILE
char szTableName[128];
char szPropName[128];
#endif
DWORD_PTR dwCRC32;
DWORD_PTR dwOffset;
};
struct RecvTable;
class CNetVar
{
public:
void RetrieveClasses();
void LogNetVar(RecvTable *table, int align);
DWORD_PTR GetNetVar(DWORD_PTR dwCRC32);
void HookProxies();
private:
std::vector<netvar_info_s>vars;
};
class NetvarManager
{
private:
static NetvarManager* instance;
NetvarManager();
~NetvarManager();
NetvarManager(const NetvarManager&) = delete;
public:
static NetvarManager* Instance()
{
if (!instance) instance = new NetvarManager;
return instance;
}
void CreateDatabase();
void DestroyDatabase();
void Dump(std::ostream& stream);
void Dump(const std::string& file);
int GetNetvarCount() { return m_netvarCount; }
int GetTableCount() { return m_tableCount; }
template<typename ...Args>
uint32_t GetOffset(const std::string& szTableName, Args&&... args)
{
return GetOffset(szTableName, { std::forward<Args>(args)... });
}
private:
std::unique_ptr<NetvarTable> InternalLoadTable(RecvTable* pRecvTable, uint32_t offset);
void Dump(std::ostream& output, NetvarTable& table, int level);
uint32_t GetOffset(const std::string& szTableName, const std::initializer_list<std::string>& props);
private:
std::unique_ptr<NetvarDatabase> m_pDatabase = nullptr;
uint32_t m_tableCount = 0;
uint32_t m_netvarCount = 0;
};
#ifdef DUMP_NETVARS_TO_FILE
#define NETVAR_FILENAME "netvars.txt"
#endif
extern CNetVar NetVar;
#define GET_NETVAR(table, ...) NetvarManager::Instance()->GetOffset(table, __VA_ARGS__)