-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.py
76 lines (50 loc) · 2.49 KB
/
demo.py
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
from pdbpy.msf import MultiStreamFile
from pdbpy.streams.directorystream import StreamDirectoryStream
from pdbpy.streams.pdbinfo import PdbInfoStream
from pdbpy.streams.typestream import PdbTypeStream
import pdbpy.utils.hash
def main():
import sys
assert len(sys.argv) == 2, "Accepts only a path to a pdb as argument."
with open(sys.argv[1], "rb") as f:
msf = MultiStreamFile(f)
stream = msf.get("Directory")
pdb_stream_directory = StreamDirectoryStream(stream)
pdb_info_file = pdb_stream_directory.get_stream_by_index(1)
info_stream = PdbInfoStream(pdb_info_file)
type_info_file = pdb_stream_directory.get_stream_by_index(2)
type_stream = PdbTypeStream(type_info_file, pdb_stream_directory, upfront_memory=False)
#print(type_stream)
actor_ti = 267711
acty = type_stream.get_by_type_index(ti = actor_ti)
calc_hash = pdbpy.utils.hash.get_hash_for_string(acty.name)
print("Calculated hash for actor: ", calc_hash)
print("Calculated bucket for actor: ", calc_hash % type_stream.header.buckets)
print(f"Hash for actor: {type_stream.get_hash_for_ti(actor_ti)}")
print()
errory_name = 'TWeakObjectPtr<AActor,FWeakObjectPtr>'
errory_ti = 0x000408ad
calc_hash = pdbpy.utils.hash.get_hash_for_string(errory_name)
print(f"Calculated hash for errory: {calc_hash:x}")
print(f"Calculated bucket for errory: {(calc_hash % type_stream.header.buckets):x}")
print(f"Hash for errory: {type_stream.get_hash_for_ti(errory_ti):x}")
print(f"Hash for errory(fwd): {type_stream.get_hash_for_ti(0x2578):x}")
print()
print(type_stream.get_structy_by_name(errory_name))
import time
s = time.perf_counter()
acty = type_stream.get_by_type_index(ti = type_stream.header.ti_max-1) # 3.9s before thingy
#acty = type_stream.get_by_type_index(ti = type_stream.header.ti_min+3)
#acty = type_stream.get_by_type_index(ti = actor_ti)
print(acty, "\n", time.perf_counter()-s)
s = time.perf_counter()
ti, typ = type_stream.get_structy_by_name('AActor')
print("TI: ", ti)
print("actor class:", typ, "\n", time.perf_counter()-s)
#
#members_typ = type_stream.get_by_type_index(typ.field)
#print("members: ")
#for member in members_typ.members:
# print(member)
if __name__ == '__main__':
main()