forked from grimdoomer/IDAPy-PS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenIOPTable.py
65 lines (48 loc) · 1.28 KB
/
GenIOPTable.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
import json
import sys
import os
from collections import defaultdict
def parse_modname(name):
s = name.split(" ")
return s[1].strip()
def parse_version(vers):
s = vers.split(" ")
v = int(s[1], 16)
major = v >> 8
minor = v & 0xff
return str(major) + "." + str(minor)
def parse_export(exp):
s = exp.split(" ")
return (int(s[1].strip()), s[2].strip())
def parse_ilb(ilb, exports):
modname = ""
version = ""
for line in ilb:
if line[0] == '#':
continue
if line[0] == 'L':
modname = parse_modname(line)
print("adding module", modname)
continue
if line[0] == 'V':
version = parse_version(line)
continue
if line[0] == 'F':
continue
if line[0] == 'E':
exp = parse_export(line)
exports[modname][version][exp[0]] = exp[1]
continue
def main():
exports = defaultdict(lambda: defaultdict(dict))
for arg in sys.argv[1:]:
print("parsing", arg)
f = open(arg, 'r')
parse_ilb(f, exports)
f.close()
for mod in exports:
print("writing", mod)
out = open(mod + ".json", "w")
json.dump(exports[mod], out, indent = 4)
out.close()
main()