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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
// netvars.cpp — ClientClass walk, RecvTable resolution, movetype from pred-TD
#include "hl2h.h"
// RecvTable layout: pProps@0, nProps@4, pDecoder@8, pNetTableName@0xC
// RecvProp layout: pVarName@0, pArrayProp@0x18, pDataTable@0x28, offset@0x2C
// ClientClass (2004-era): CreateFn@0, CreateEventFn@4, Name@8, RecvTable@0xC, Next@0x10
static bool module_string(uintptr_t p, char *out, size_t outn) {
if (!g_client.contains(p))
return false;
const char *s = (const char *)p;
size_t i = 0;
while (i < outn - 1) {
unsigned char ch = (unsigned char)s[i];
if (ch == 0)
break;
if (ch < 0x20 || ch > 0x7E)
return false;
out[i] = (char)ch;
i++;
}
if (i == 0 || i >= outn - 1)
return false;
out[i] = 0;
return true;
}
static int g_dumped_tables = 0;
static void collect_netvars(uintptr_t table, uintptr_t base_off, int depth) {
if (depth > 8)
return;
uintptr_t props = *(uintptr_t *)(table + 0x00);
int32_t nprops = *(int32_t *)(table + 0x04);
if (!props || !g_client.contains(props) || nprops <= 0 || nprops > 512)
return;
char tname[64];
if (!module_string(*(uintptr_t *)(table + 0x0C), tname, sizeof(tname)))
return;
if (strncmp(tname, "DT_", 3) != 0)
return;
bool dump = g_dumped_tables < 2 &&
(strcmp(tname, "DT_BaseEntity") == 0 ||
strcmp(tname, "DT_BasePlayer") == 0);
if (dump) {
g_dumped_tables++;
logd("dump %s: %d props @ table %#lx (base_off %#lx)", tname, nprops,
(unsigned long)table, (unsigned long)base_off);
}
for (int32_t i = 0; i < nprops; i++) {
uintptr_t prop = props + (size_t)i * 0x3C;
if (!g_client.contains(prop))
return;
uintptr_t pname = *(uintptr_t *)(prop + 0x00);
int32_t ptype = *(int32_t *)(prop + 0x04);
int32_t poff = *(int32_t *)(prop + 0x2C);
uintptr_t parray = *(uintptr_t *)(prop + 0x18);
uintptr_t ptable = *(uintptr_t *)(prop + 0x28);
char pname2[64];
if (!module_string(pname, pname2, sizeof(pname2)))
continue;
if (dump)
logd(" [%s] %s type=%d off=%d(0x%x) table=%s array=%s", tname, pname2,
ptype, poff, poff, ptable ? "yes" : "no", parray ? "yes" : "no");
if (ptable) {
collect_netvars(ptable, base_off + (uint32_t)poff, depth + 1);
continue;
}
if (strcmp(pname2, "m_lifeState") == 0 && g_net.lifestate < 0) {
g_net.lifestate = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_nModelIndex") == 0 && g_net.modelindex < 0) {
g_net.modelindex = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_fFlags") == 0 && g_net.flags < 0) {
g_net.flags = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_vecVelocity") == 0 && g_net.velocity < 0) {
if (parray && g_client.contains(parray)) {
int32_t eoff = *(int32_t *)(parray + 0x2C);
g_net.velocity = (int)(base_off + (uint32_t)(eoff ? eoff : poff));
} else {
g_net.velocity = (int)(base_off + (uint32_t)poff);
}
} else if (strcmp(pname2, "m_iHealth") == 0 && g_net.health < 0) {
g_net.health = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_iMaxHealth") == 0 && g_net.maxhealth < 0) {
g_net.maxhealth = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_hActiveWeapon") == 0 &&
g_net.activeweapon < 0) {
g_net.activeweapon = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_clrRender") == 0 && g_net.clr_render < 0) {
int off = (int)(base_off + (uint32_t)poff);
// Reject the 0 offset some embedded tables report; the real render
// colour lives well inside C_BaseEntity.
if (off >= 0x20 && off <= 0x2000)
g_net.clr_render = off;
} else if (strcmp(pname2, "m_vecPunchAngle") == 0 && g_net.punch < 0) {
int off = (int)(base_off + (uint32_t)poff);
if (off >= 0x20 && off <= 0x2000)
g_net.punch = off;
} else if (strcmp(pname2, "m_iDefaultFOV") == 0 &&
g_net.default_fov < 0) {
int off = (int)(base_off + (uint32_t)poff);
if (off >= 0x20 && off <= 0x2000)
g_net.default_fov = off;
} else if (strcmp(pname2, "m_iTeamNum") == 0 && g_net.teamnum < 0) {
g_net.teamnum = (int)(base_off + (uint32_t)poff);
} else if (strcmp(pname2, "m_vecOrigin") == 0 && g_net.origin < 0) {
if (parray && g_client.contains(parray)) {
int32_t eoff = *(int32_t *)(parray + 0x2C);
g_net.origin = (int)(base_off + (uint32_t)(eoff ? eoff : poff));
} else {
g_net.origin = (int)(base_off + (uint32_t)poff);
}
} else if (strncmp(pname2, "m_vecViewOffset", 15) == 0 &&
g_net.viewoffset < 0) {
if (parray && g_client.contains(parray)) {
int32_t eoff = *(int32_t *)(parray + 0x2C);
g_net.viewoffset = (int)(base_off + (uint32_t)(eoff ? eoff : poff));
} else {
g_net.viewoffset = (int)(base_off + (uint32_t)poff);
}
} else if (strcmp(pname2, "m_vecMins") == 0 && g_net.mins < 0) {
if (parray && g_client.contains(parray)) {
int32_t eoff = *(int32_t *)(parray + 0x2C);
g_net.mins = (int)(base_off + (uint32_t)(eoff ? eoff : poff));
} else {
g_net.mins = (int)(base_off + (uint32_t)poff);
}
} else if (strcmp(pname2, "m_vecMaxs") == 0 && g_net.maxs < 0) {
if (parray && g_client.contains(parray)) {
int32_t eoff = *(int32_t *)(parray + 0x2C);
g_net.maxs = (int)(base_off + (uint32_t)(eoff ? eoff : poff));
} else {
g_net.maxs = (int)(base_off + (uint32_t)poff);
}
}
}
}
// prediction datamap scan for m_MoveType (FIELD_CHARACTER, fieldOffset in range)
static bool resolve_movetype() {
static const char needle[] = "m_MoveType";
const size_t nlen = sizeof(needle);
uintptr_t str_va = 0;
for (auto &r : g_client.ranges) {
const uint8_t *base = (const uint8_t *)r.lo;
size_t span = r.hi - r.lo;
for (size_t i = 0; i + nlen <= span; i++) {
if (memcmp(base + i, needle, nlen) == 0) {
str_va = r.lo + i;
break;
}
}
if (str_va)
break;
}
if (!str_va) {
logd("m_MoveType string not found");
return false;
}
uint32_t offs[16];
int counts[16] = {};
int ncand = 0;
const uint32_t target = (uint32_t)str_va;
for (auto &r : g_client.ranges) {
const uint8_t *base = (const uint8_t *)r.lo;
size_t span = r.hi - r.lo;
for (size_t off = 4; off + 8 <= span; off += 4) {
if (*(const uint32_t *)(base + off) != target)
continue;
uint32_t ftype = *(const uint32_t *)(base + off - 4);
int32_t foff = *(const int32_t *)(base + off + 4);
if (ftype != 8 || foff < 0x40 || foff > 0x400)
continue;
int k;
for (k = 0; k < ncand; k++)
if (offs[k] == (uint32_t)foff)
break;
if (k == ncand && ncand < 16) {
offs[ncand] = (uint32_t)foff;
ncand++;
}
if (k < ncand)
counts[k]++;
}
}
if (ncand == 0) {
logd("m_MoveType typedescription not found");
return false;
}
int best = 0;
for (int k = 1; k < ncand; k++)
if (counts[k] > counts[best])
best = k;
g_net.movetype = (int)offs[best];
return true;
}
static bool resolve_absvelocity() {
static const char needle[] = "m_vecAbsVelocity";
const size_t nlen = sizeof(needle);
uintptr_t str_va = 0;
for (auto &r : g_client.ranges) {
const uint8_t *base = (const uint8_t *)r.lo;
size_t span = r.hi - r.lo;
for (size_t i = 0; i + nlen <= span; i++) {
if (memcmp(base + i, needle, nlen) == 0) {
str_va = r.lo + i;
break;
}
}
if (str_va)
break;
}
if (!str_va) {
logd("m_vecAbsVelocity string not found");
return false;
}
uint32_t offs[16];
int counts[16] = {};
int ncand = 0;
const uint32_t target = (uint32_t)str_va;
for (auto &r : g_client.ranges) {
const uint8_t *base = (const uint8_t *)r.lo;
size_t span = r.hi - r.lo;
for (size_t off = 4; off + 8 <= span; off += 4) {
if (*(const uint32_t *)(base + off) != target)
continue;
uint32_t ftype = *(const uint32_t *)(base + off - 4);
int32_t foff = *(const int32_t *)(base + off + 4);
if (ftype != 3 || foff < 0x40 || foff > 0x400)
continue;
int k;
for (k = 0; k < ncand; k++)
if (offs[k] == (uint32_t)foff)
break;
if (k == ncand && ncand < 16) {
offs[ncand] = (uint32_t)foff;
ncand++;
}
if (k < ncand)
counts[k]++;
}
}
if (ncand == 0) {
logd("m_vecAbsVelocity typedescription not found");
return false;
}
int best = 0;
for (int k = 1; k < ncand; k++)
if (counts[k] > counts[best])
best = k;
g_net.absvelocity = (int)offs[best];
return true;
}
void resolve_netvars() {
using GetAllClassesFn = void *(*)(void *);
uintptr_t head =
(uintptr_t)vfunc<GetAllClassesFn>(g_iface.client, 8)(g_iface.client);
if (!g_client.contains(head)) {
logf("GetAllClasses returned %p, outside client module", (void *)head);
return;
}
int classes = 0;
for (uintptr_t cc = head; cc && g_client.contains(cc) && classes < 1024;
cc = *(uintptr_t *)(cc + 0x10)) {
classes++;
collect_netvars(*(uintptr_t *)(cc + 0x0C), 0, 0);
}
logd("client classes walked: %d", classes);
if (g_net.movetype < 0 && !resolve_movetype()) {
// movetype unresolved — bhop still works, just no noclip/ladder guard
logf("movetype guard disabled");
}
if (g_net.absvelocity < 0 && !resolve_absvelocity())
logf("m_vecAbsVelocity unresolved; jumpbug assist disabled");
logf("netvars: flags=%d velocity=%d movetype=%d health=%d maxhealth=%d "
"teamnum=%d origin=%d viewoffset=%d mins=%d maxs=%d lifeste=%d "
"modelindex=%d absvelocity=%d activeweapon=%d owner=%d "
"weapon_owner=%d clr_render=%d punch=%d default_fov=%d",
g_net.flags, g_net.velocity, g_net.movetype, g_net.health,
g_net.maxhealth, g_net.teamnum, g_net.origin, g_net.viewoffset,
g_net.mins, g_net.maxs, g_net.lifestate, g_net.modelindex,
g_net.absvelocity, g_net.activeweapon, g_net.owner,
g_net.weapon_owner, g_net.clr_render, g_net.punch,
g_net.default_fov);
}
|