-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolve_handle.py
More file actions
67 lines (51 loc) · 2.06 KB
/
resolve_handle.py
File metadata and controls
67 lines (51 loc) · 2.06 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
import pymem
import json
def get_entity_by_handle(pm, client_base, entity_list_offset, handle):
if not handle or handle == 0xFFFFFFFF:
return 0
index = handle & 0x7FFF
try:
entity_list = pm.read_longlong(client_base + entity_list_offset)
if not entity_list:
print("Entity list base is 0")
return 0
chunk_idx = (index >> 9) & 0x7FFF
print(f"Chunk Index: {chunk_idx}")
list_entry = pm.read_longlong(entity_list + 0x10 + 8 * chunk_idx)
print(f"List Entry (Chunk): {hex(list_entry)}")
if not list_entry: return 0
ent_idx_in_chunk = index & 0x1FF
pawn_ptr_addr = list_entry + 120 * ent_idx_in_chunk
print(f"Pawn Ptr Address: {hex(pawn_ptr_addr)}")
pawn = pm.read_longlong(pawn_ptr_addr)
print(f"Pawn: {hex(pawn)}")
return pawn
except Exception as e:
print(f"Exception in get_entity: {e}")
return 0
def resolve():
try:
pm = pymem.Pymem("cs2.exe")
client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
with open('offsets.json', 'r') as f:
offs = json.load(f)
dwEntityList = offs['client.dll']['dwEntityList'] # 38445272 = 0x24AA4D8
# Candidate handles
handles = [0x135004e, 0x970048]
for h in handles:
ent = get_entity_by_handle(pm, client, dwEntityList, h)
print(f"Handle {hex(h)} -> Entity {hex(ent)}")
if ent:
# Check FOV at 9252
try:
fov = pm.read_float(ent + 9252)
print(f" FOV at 9252: {fov}")
# Dump start of entity to see vtable
vt = pm.read_longlong(ent)
print(f" VTable: {hex(vt)}")
except:
pass
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
resolve()