Fixed some little things

This commit is contained in:
Giuseppe (LemonBoy) 2009-06-22 10:44:45 +02:00
parent 2b65473b78
commit ec7d9fc776
2 changed files with 26 additions and 24 deletions

18
disc.py
View File

@ -155,7 +155,7 @@ class WOD: #WiiOpticalDisc
rootFiles = struct.unpack('>I', buffer[8:12])[0]
namesTable = buffer[12 * (rootFiles):]
open('tbl.bin', 'w+b').write(str(buffer[12 * (rootFiles):].split('\x00')))
open('fst.bin', 'w+b').write(buffer)
for i in range(1, rootFiles):
fstTableEntry = buffer[12 * i:12 * (i + 1)]
@ -167,8 +167,9 @@ class WOD: #WiiOpticalDisc
temp = struct.unpack('>I', fstTableEntry[0x0:0x4])[0]
nameOffset = struct.unpack('>I', fstTableEntry[0x0:0x4])[0] & 0xffffff
fileName = namesTable[nameOffset:nameOffset + 256].split('\x00')[0]
print '%s %s\n' % (namesTable[nameOffset:nameOffset + 256].split('\x00')[0], namesTable[nameOffset:nameOffset + 256].split('\x00')[1])
fileName = namesTable[nameOffset:].split('\x00')[0]
#print '%s' % namesTable[nameOffset:]
#print '%s %s\n' % (namesTable[nameOffset:].split('\x00')[0], namesTable[nameOffset:].split('\x00')[1])
fileOffset = 4 * (struct.unpack('>I', fstTableEntry[0x4:0x8])[0])
fileLenght = struct.unpack('>I', fstTableEntry[0x8:0x0c])[0]
if fileName == '':
@ -196,11 +197,6 @@ class WOD: #WiiOpticalDisc
self.tikData = self.fp.read(0x2A4)
self.partitionKey = Ticket(self.tikData).getTitleKey()
self.appLdr = self.Apploader().unpack(self.readPartition (0x2440, 32))
self.partitionHdr = self.discHeader().unpack(self.readPartition (0x0, 0x400))
self.fp.seek(self.partitionOffset + 0x2a4)
self.tmdSize = struct.unpack(">I", self.fp.read(4))[0]
self.tmdOffset = struct.unpack(">I", self.fp.read(4))[0] >> 2
@ -218,6 +214,9 @@ class WOD: #WiiOpticalDisc
self.dolOffset = 4 * struct.unpack(">I", self.readPartition (0x420, 4))[0]
self.dolSize = self.fstOffset - self.dolOffset
self.appLdr = self.Apploader().unpack(self.readPartition (0x2440, 32))
self.partitionHdr = self.discHeader().unpack(self.readPartition (0x0, 0x400))
def getFst(self):
fstBuf = self.readPartition(self.fstOffset, self.fstSize)
self.parseFst(fstBuf)
@ -260,6 +259,9 @@ class WOD: #WiiOpticalDisc
def getPartitionApploader(self):
return self.readPartition (0x2440, self.appLdr.size + self.appLdr.trailingSize + 32)
def getPartitionMainDol(self):
return self.readPartition (self.dolOffset, self.dolSize)
def extractPartition(self, index, fn = ""):
if(fn == ""):

View File

@ -15,7 +15,7 @@ class Savegame():
self.bannerSize = Struct.uint32
self.permissions = Struct.uint8
self.unknown1 = Struct.uint8
self.md5hash = Struct.uint32[4]
self.md5hash = Struct.string(16)
self.unknown2 = Struct.uint16
class savegameBanner(Struct):
@ -27,15 +27,15 @@ class Savegame():
self.reserved = Struct.uint32[5]
self.gameTitle = Struct.string(64)
self.gameSubTitle = Struct.string(64)
self.banner = Struct.uint8[24576]
self.icon0 = Struct.uint8[4608]
self.icon1 = Struct.uint8[4608]
self.icon2 = Struct.uint8[4608]
self.icon3 = Struct.uint8[4608]
self.icon4 = Struct.uint8[4608]
self.icon5 = Struct.uint8[4608]
self.icon6 = Struct.uint8[4608]
self.icon7 = Struct.uint8[4608]
self.banner = Struct.string(24576)
self.icon0 = Struct.string(4608)
self.icon1 = Struct.string(4608)
self.icon2 = Struct.string(4608)
self.icon3 = Struct.string(4608)
self.icon4 = Struct.string(4608)
self.icon5 = Struct.string(4608)
self.icon6 = Struct.string(4608)
self.icon7 = Struct.string(4608)
class backupHeader(Struct):
__endian__ = Struct.BE
@ -86,7 +86,7 @@ class Savegame():
ret += 'Banner size : 0x%x\n' % self.hdr.bannerSize
ret += 'Permissions : 0x%x\n' % self.hdr.permissions
ret += 'Unknown : 0x%x\n' % self.hdr.unknown1
ret += 'MD5 hash : 0x%x%x%x%x\n' % (self.hdr.md5hash[0], self.hdr.md5hash[1], self.hdr.md5hash[2], self.hdr.md5hash[3])
ret += 'MD5 hash : %s\n' % hexdump(self.hdr.md5hash)
ret += 'Unknown : 0x%x\n' % self.hdr.unknown2
ret += '\nBanner header \n'
@ -94,6 +94,7 @@ class Savegame():
ret += 'Flags : 0x%x\n' % self.bnr.flags
ret += 'Game title : %s\n' % self.bnr.gameTitle
ret += 'Game subtitle : %s\n' % self.bnr.gameSubTitle
ret += 'Icons found : %i\n' % self.iconCount
ret += '\nBackup header \n'
@ -178,16 +179,15 @@ class Savegame():
self.hdr = self.savegameHeader().unpack(headerBuffer[:0x20])
#MD5 check fail always ...
#list(headerBuffer)[0x000E:0x001E] = '\x0e\x65\x37\x81\x99\xbe\x45\x17\xab\x06\xec\x22\x45\x1a\x57\x93'
#print '0x%x%x%x%x %s' % (self.hdr.md5hash[0], self.hdr.md5hash[1], self.hdr.md5hash[2], self.hdr.md5hash[3], hashlib.md5(headerBuffer[:0x20]).hexdigest())
#headerBuffer.replace(self.hdr.md5hash, '\x0e\x65\x37\x81\x99\xbe\x45\x17\xab\x06\xec\x22\x45\x1a\x57\x93')
#print 'Reashed md5 : %s' % hexdump(hashlib.md5(headerBuffer).digest())
self.bnr = self.savegameBanner().unpack(headerBuffer[0x20:])
if self.bnr.magic != 'WIBN':
raise Exception ('Wrong magic, should be WIBN')
if self.hdr.bannerSize == 0xF0C0:
if self.hdr.bannerSize != 0x72A0:
self.iconCount += 7
bkHdrBuffer = self.fd.read(0x80)
@ -199,7 +199,7 @@ class Savegame():
self.fileStartOffset = self.fd.tell()
def getBanner(self):
return struct.pack('24576I', *self.bnr.banner)
return self.bnr.banner
def getIcon(self, index):
if index < 0 or index > 7 or index > self.iconCount: