-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVTableFindDiff.py
More file actions
executable file
·77 lines (57 loc) · 1.66 KB
/
VTableFindDiff.py
File metadata and controls
executable file
·77 lines (57 loc) · 1.66 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
#!/usr/bin/python3
import sys
import json
def removeVersion(func):
if func is None:
return "None"
func = getFuncName(func)
keywords = ["X5000", "X6000", "Vega10", "Navi10", "GFX9", "GFX10"]
for keyword in keywords:
func = func.replace(keyword, "")
return func
def getFuncName(func):
if func is None:
return "None"
return func.split("(")[0].split(" ")[-1]
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} (Old type) (New type)")
sys.exit()
db = json.load(open("vtableDB.json"))
a = db[sys.argv[1]]
b = db[sys.argv[2]]
keys = set()
keys.update(a.keys())
keys.update(b.keys())
keys.remove("length")
keys = sorted(list(keys))
aNoVer = {}
bNoVer = {}
misaligns = []
for key in keys:
A = a.get(key, None)
B = b.get(key, None)
aNoVer[key] = removeVersion(A)
bNoVer[removeVersion(B)] = key
if removeVersion(A) != removeVersion(B) or False:
offset = hex(int(key) * 8)
misaligns.append("field_" + offset)
print(f"{key} ({offset.ljust(5)}): {getFuncName(A).ljust(80)} {getFuncName(B)}")
matches = []
while True:
line = input().strip()
if line == "":
break
if "vtable->field" not in line:
continue
if any(x in line for x in misaligns):
addr = line.split("\t")[0]
offset = line.split("field_")[-1].split(")")[0]
key = str(int(offset, 16) // 8).rjust(3, "0")
try:
fixed = bNoVer[aNoVer[key]]
fixedOffset = hex(int(fixed) * 8)
except KeyError:
fixed = None
fixedOffset = None
matches.append(str((addr, aNoVer[key], offset, fixedOffset)))
print("\n".join(matches))