-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvools_unpack.py
More file actions
33 lines (31 loc) · 1.13 KB
/
Copy pathvools_unpack.py
File metadata and controls
33 lines (31 loc) · 1.13 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
import sys
import os
import zlib
size_cfg = 0x50
fname = sys.argv[1]
with open(fname, 'rb') as bin_file:
buf = bin_file.read()
pos_zdata = 0
pos_cfg = 0
while pos_cfg < len(buf):
pos_zdata += size_cfg
if buf[pos_zdata : pos_zdata + 2] != b'\x78\x9c':
pos_cfg += 1
pos_zdata = pos_cfg
continue
cfg = buf[pos_cfg : pos_zdata]
size_unzip = int.from_bytes(cfg[0xC : 0xC + 4], sys.byteorder)
if pos_cfg + size_unzip > len(buf):
exit(-1)
name = cfg[0x14 : 0x14 + 0x20].decode('windows-1252')
size_all = size_unzip + int.from_bytes(cfg[0x38 : 0x38 + 4], sys.byteorder)
if not os.path.exists(name):
zfile = buf[pos_zdata : pos_zdata + size_unzip]
head, tail = os.path.split(fname)
with open(os.path.join(os.path.dirname(fname), '.'.join((tail, name))), 'wb') as fw:
try:
fw.write(zlib.decompress(zfile))
except:
pass
pos_cfg += size_cfg + size_all
pos_zdata = pos_cfg