You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
754 B
32 lines
754 B
2 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
from client import translate_rev
|
||
|
from struct import unpack_from
|
||
|
|
||
|
class Map:
|
||
|
def __init__(self, fname):
|
||
|
self.map = open(fname, "rb").read()
|
||
|
self.baseaddr = 0x02018000
|
||
|
|
||
|
def getoffs(self, pos):
|
||
|
return unpack_from("<I", self.map, pos)[0] - self.baseaddr
|
||
|
|
||
|
def readstr(self, pos):
|
||
|
b = bytearray()
|
||
|
while self.map[pos] != 0xff:
|
||
|
b.append(self.map[pos])
|
||
|
pos += 1
|
||
|
return translate_rev(b)
|
||
|
|
||
|
def getname(self):
|
||
|
ptr = self.getoffs(0x28)
|
||
|
return self.readstr(ptr)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
from sys import argv
|
||
|
|
||
|
if argv[1] == "name":
|
||
|
for file in argv[2:]:
|
||
|
m = Map(file)
|
||
|
print(file + ":", m.getname())
|