mirror of
https://github.com/grp/Wii.py.git
synced 2025-06-18 23:05:48 -04:00
Fixed some little things
This commit is contained in:
parent
2b65473b78
commit
ec7d9fc776
18
disc.py
18
disc.py
@ -155,7 +155,7 @@ class WOD: #WiiOpticalDisc
|
|||||||
rootFiles = struct.unpack('>I', buffer[8:12])[0]
|
rootFiles = struct.unpack('>I', buffer[8:12])[0]
|
||||||
namesTable = buffer[12 * (rootFiles):]
|
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):
|
for i in range(1, rootFiles):
|
||||||
fstTableEntry = buffer[12 * i:12 * (i + 1)]
|
fstTableEntry = buffer[12 * i:12 * (i + 1)]
|
||||||
@ -167,8 +167,9 @@ class WOD: #WiiOpticalDisc
|
|||||||
|
|
||||||
temp = struct.unpack('>I', fstTableEntry[0x0:0x4])[0]
|
temp = struct.unpack('>I', fstTableEntry[0x0:0x4])[0]
|
||||||
nameOffset = struct.unpack('>I', fstTableEntry[0x0:0x4])[0] & 0xffffff
|
nameOffset = struct.unpack('>I', fstTableEntry[0x0:0x4])[0] & 0xffffff
|
||||||
fileName = namesTable[nameOffset:nameOffset + 256].split('\x00')[0]
|
fileName = namesTable[nameOffset:].split('\x00')[0]
|
||||||
print '%s %s\n' % (namesTable[nameOffset:nameOffset + 256].split('\x00')[0], namesTable[nameOffset:nameOffset + 256].split('\x00')[1])
|
#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])
|
fileOffset = 4 * (struct.unpack('>I', fstTableEntry[0x4:0x8])[0])
|
||||||
fileLenght = struct.unpack('>I', fstTableEntry[0x8:0x0c])[0]
|
fileLenght = struct.unpack('>I', fstTableEntry[0x8:0x0c])[0]
|
||||||
if fileName == '':
|
if fileName == '':
|
||||||
@ -195,11 +196,6 @@ class WOD: #WiiOpticalDisc
|
|||||||
|
|
||||||
self.tikData = self.fp.read(0x2A4)
|
self.tikData = self.fp.read(0x2A4)
|
||||||
self.partitionKey = Ticket(self.tikData).getTitleKey()
|
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.tmdSize = struct.unpack(">I", self.fp.read(4))[0]
|
||||||
self.tmdOffset = struct.unpack(">I", self.fp.read(4))[0] >> 2
|
self.tmdOffset = struct.unpack(">I", self.fp.read(4))[0] >> 2
|
||||||
@ -217,6 +213,9 @@ class WOD: #WiiOpticalDisc
|
|||||||
|
|
||||||
self.dolOffset = 4 * struct.unpack(">I", self.readPartition (0x420, 4))[0]
|
self.dolOffset = 4 * struct.unpack(">I", self.readPartition (0x420, 4))[0]
|
||||||
self.dolSize = self.fstOffset - self.dolOffset
|
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):
|
def getFst(self):
|
||||||
fstBuf = self.readPartition(self.fstOffset, self.fstSize)
|
fstBuf = self.readPartition(self.fstOffset, self.fstSize)
|
||||||
@ -259,6 +258,9 @@ class WOD: #WiiOpticalDisc
|
|||||||
|
|
||||||
def getPartitionApploader(self):
|
def getPartitionApploader(self):
|
||||||
return self.readPartition (0x2440, self.appLdr.size + self.appLdr.trailingSize + 32)
|
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 = ""):
|
def extractPartition(self, index, fn = ""):
|
||||||
|
|
||||||
|
32
savedata.py
32
savedata.py
@ -15,7 +15,7 @@ class Savegame():
|
|||||||
self.bannerSize = Struct.uint32
|
self.bannerSize = Struct.uint32
|
||||||
self.permissions = Struct.uint8
|
self.permissions = Struct.uint8
|
||||||
self.unknown1 = Struct.uint8
|
self.unknown1 = Struct.uint8
|
||||||
self.md5hash = Struct.uint32[4]
|
self.md5hash = Struct.string(16)
|
||||||
self.unknown2 = Struct.uint16
|
self.unknown2 = Struct.uint16
|
||||||
|
|
||||||
class savegameBanner(Struct):
|
class savegameBanner(Struct):
|
||||||
@ -27,15 +27,15 @@ class Savegame():
|
|||||||
self.reserved = Struct.uint32[5]
|
self.reserved = Struct.uint32[5]
|
||||||
self.gameTitle = Struct.string(64)
|
self.gameTitle = Struct.string(64)
|
||||||
self.gameSubTitle = Struct.string(64)
|
self.gameSubTitle = Struct.string(64)
|
||||||
self.banner = Struct.uint8[24576]
|
self.banner = Struct.string(24576)
|
||||||
self.icon0 = Struct.uint8[4608]
|
self.icon0 = Struct.string(4608)
|
||||||
self.icon1 = Struct.uint8[4608]
|
self.icon1 = Struct.string(4608)
|
||||||
self.icon2 = Struct.uint8[4608]
|
self.icon2 = Struct.string(4608)
|
||||||
self.icon3 = Struct.uint8[4608]
|
self.icon3 = Struct.string(4608)
|
||||||
self.icon4 = Struct.uint8[4608]
|
self.icon4 = Struct.string(4608)
|
||||||
self.icon5 = Struct.uint8[4608]
|
self.icon5 = Struct.string(4608)
|
||||||
self.icon6 = Struct.uint8[4608]
|
self.icon6 = Struct.string(4608)
|
||||||
self.icon7 = Struct.uint8[4608]
|
self.icon7 = Struct.string(4608)
|
||||||
|
|
||||||
class backupHeader(Struct):
|
class backupHeader(Struct):
|
||||||
__endian__ = Struct.BE
|
__endian__ = Struct.BE
|
||||||
@ -86,7 +86,7 @@ class Savegame():
|
|||||||
ret += 'Banner size : 0x%x\n' % self.hdr.bannerSize
|
ret += 'Banner size : 0x%x\n' % self.hdr.bannerSize
|
||||||
ret += 'Permissions : 0x%x\n' % self.hdr.permissions
|
ret += 'Permissions : 0x%x\n' % self.hdr.permissions
|
||||||
ret += 'Unknown : 0x%x\n' % self.hdr.unknown1
|
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 += 'Unknown : 0x%x\n' % self.hdr.unknown2
|
||||||
|
|
||||||
ret += '\nBanner header \n'
|
ret += '\nBanner header \n'
|
||||||
@ -94,6 +94,7 @@ class Savegame():
|
|||||||
ret += 'Flags : 0x%x\n' % self.bnr.flags
|
ret += 'Flags : 0x%x\n' % self.bnr.flags
|
||||||
ret += 'Game title : %s\n' % self.bnr.gameTitle
|
ret += 'Game title : %s\n' % self.bnr.gameTitle
|
||||||
ret += 'Game subtitle : %s\n' % self.bnr.gameSubTitle
|
ret += 'Game subtitle : %s\n' % self.bnr.gameSubTitle
|
||||||
|
ret += 'Icons found : %i\n' % self.iconCount
|
||||||
|
|
||||||
ret += '\nBackup header \n'
|
ret += '\nBackup header \n'
|
||||||
|
|
||||||
@ -178,16 +179,15 @@ class Savegame():
|
|||||||
|
|
||||||
self.hdr = self.savegameHeader().unpack(headerBuffer[:0x20])
|
self.hdr = self.savegameHeader().unpack(headerBuffer[:0x20])
|
||||||
|
|
||||||
#MD5 check fail always ...
|
#headerBuffer.replace(self.hdr.md5hash, '\x0e\x65\x37\x81\x99\xbe\x45\x17\xab\x06\xec\x22\x45\x1a\x57\x93')
|
||||||
#list(headerBuffer)[0x000E:0x001E] = '\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())
|
||||||
#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())
|
|
||||||
|
|
||||||
self.bnr = self.savegameBanner().unpack(headerBuffer[0x20:])
|
self.bnr = self.savegameBanner().unpack(headerBuffer[0x20:])
|
||||||
|
|
||||||
if self.bnr.magic != 'WIBN':
|
if self.bnr.magic != 'WIBN':
|
||||||
raise Exception ('Wrong magic, should be WIBN')
|
raise Exception ('Wrong magic, should be WIBN')
|
||||||
|
|
||||||
if self.hdr.bannerSize == 0xF0C0:
|
if self.hdr.bannerSize != 0x72A0:
|
||||||
self.iconCount += 7
|
self.iconCount += 7
|
||||||
|
|
||||||
bkHdrBuffer = self.fd.read(0x80)
|
bkHdrBuffer = self.fd.read(0x80)
|
||||||
@ -199,7 +199,7 @@ class Savegame():
|
|||||||
self.fileStartOffset = self.fd.tell()
|
self.fileStartOffset = self.fd.tell()
|
||||||
|
|
||||||
def getBanner(self):
|
def getBanner(self):
|
||||||
return struct.pack('24576I', *self.bnr.banner)
|
return self.bnr.banner
|
||||||
|
|
||||||
def getIcon(self, index):
|
def getIcon(self, index):
|
||||||
if index < 0 or index > 7 or index > self.iconCount:
|
if index < 0 or index > 7 or index > self.iconCount:
|
||||||
|
Loading…
Reference in New Issue
Block a user