forked from faggotman69/Prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetVarManager.cpp
More file actions
111 lines (88 loc) · 2.28 KB
/
NetVarManager.cpp
File metadata and controls
111 lines (88 loc) · 2.28 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "SDK.h"
#include "CommonIncludes.h"
void CNetVarManager::Initialize()
{
m_tables.clear();
ClientClass *clientClass = g_CHLClient->GetAllClasses();
if (!clientClass)
return;
while (clientClass)
{
RecvTable *recvTable = clientClass->m_pRecvTable;
m_tables.push_back(recvTable);
clientClass = clientClass->m_pNext;
}
}
int CNetVarManager::GetOffset(const char *tableName, const char *propName)
{
int offset = Get_Prop(tableName, propName);
if (!offset)
{
return 0;
}
return offset;
}
bool CNetVarManager::HookProp(const char *tableName, const char *propName, RecvVarProxyFn fun)
{
RecvProp *recvProp = 0;
Get_Prop(tableName, propName, &recvProp);
if (!recvProp)
return false;
recvProp->m_ProxyFn = fun;
return true;
}
DWORD CNetVarManager::hookProp(const char* tableName, const char* propName, void* hkFunc, void* oldFn)
{
RecvProp* recvProp;
Get_Prop(tableName, propName, &recvProp);
if (!recvProp)
return false;
DWORD old = (DWORD)recvProp->m_ProxyFn;
recvProp->m_ProxyFn = (RecvVarProxyFn)hkFunc;
return old;
}
int CNetVarManager::Get_Prop(const char *tableName, const char *propName, RecvProp **prop)
{
RecvTable *recvTable = GetTable(tableName);
if (!recvTable)
return 0;
int offset = Get_Prop(recvTable, propName, prop);
if (!offset)
return 0;
return offset;
}
int CNetVarManager::Get_Prop(RecvTable *recvTable, const char *propName, RecvProp **prop)
{
int extraOffset = 0;
for (int i = 0; i < recvTable->m_nProps; ++i)
{
RecvProp *recvProp = &recvTable->m_pProps[i];
RecvTable *child = recvProp->m_pDataTable;
if (child && (child->m_nProps > 0))
{
int tmp = Get_Prop(child, propName, prop);
if (tmp)
extraOffset += (recvProp->m_Offset + tmp);
}
if (_stricmp(recvProp->m_pVarName, propName))
continue;
if (prop)
*prop = recvProp;
return (recvProp->m_Offset + extraOffset);
}
return extraOffset;
}
RecvTable *CNetVarManager::GetTable(const char *tableName)
{
if (m_tables.empty())
return 0;
for each (RecvTable *table in m_tables)
{
if (!table)
continue;
if (_stricmp(table->m_pNetTableName, tableName) == 0)
return table;
}
return 0;
}
CNetVarManager* NetVarManager = new CNetVarManager;