forked from camthesaxman/gbadisasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmore.py
57 lines (43 loc) · 1.53 KB
/
more.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
import os
current_config_lines = open("new_test.cfg").readlines()
def test():
return os.system("./gbadisasm mb_chao_garden.gba -c new_test.cfg > test.s")
def write_config():
with open('new_test.cfg', 'w') as config:
config.write("".join(current_config_lines))
more_found = True
while more_found:
more_found = False
potential_functions = []
with open('test.s') as assembly:
lines = assembly.readlines()
for i in range(len(lines)):
line = lines[i]
if line.startswith("_02"):
next_line = lines[i + 1]
if ".byte" in next_line and not next_line.startswith("_02"):
potential_functions.append(line[1:-2])
for func in potential_functions:
already_found = False
for config_line in current_config_lines:
if func in config_line:
already_found = True
if already_found:
continue
more_found = True
address = f"0x{func}"
print(address)
current_config_lines.append(f"thumb_func {address} sub_{func}\n")
write_config()
error = test()
if not error:
continue
current_config_lines.pop(-1)
current_config_lines.append(f"arm_func {address} sub_{func}\n")
write_config()
error = test()
if not error:
continue
current_config_lines.pop(-1)
current_config_lines.append(f"# thumb_func {address} sub_{func}\n")
print(potential_functions)