forked from sevsnine/CoronaUnpackTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunpack.py
79 lines (40 loc) · 1.18 KB
/
unpack.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#PYTHON 2.7
import os
from struct import unpack,pack
def size(fn):
length=os.path.getsize(fn)
return length
fn = 'resource.car'
f=open(fn,'rb')
magic = f.read(4)
fsize=size(fn)
if magic == '\x72\x61\x63\x01':
namelst=[]
offsetlst=[]
f.seek(0x8)
p=open('resource.car.txt','wb')
index_size = unpack('I',f.read(4))[0]
num = unpack('I',f.read(4))[0]
for i in xrange(num):
(mark,offset,name_size)=unpack('3I',f.read(0xc))
name=f.read(name_size)
if name_size%4==0:
blank_size=0x4
else:
blank_size=4-name_size%4
blank = f.read(blank_size)
print('%d|%08x|%08x|%d\r\n'%(mark,offset,name_size,blank_size))
namelst.append(name)
offsetlst.append(offset)
offsetlst.append(fsize)
for i in xrange(num):
dsize = offsetlst[i+1]-offsetlst[i]
f.seek(offsetlst[i])
(unk2,asize,size) = unpack('3I',f.read(0xc))
p.write('%08x|%08x|%s|\r\n'%(offsetlst[i]+0xc,size,namelst[i]))
dat = f.read(size)
dest = open('resource//%s'%namelst[i],'wb')
dest.write(dat)
dest.close()
p.close()
f.close()