Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def tableNUNO(filedata,tablestart):
- tablelen = struct.unpack('>I',filedata[tablestart+0x8:tablestart+0xc])[0]
- table = ''
- for i in range(tablestart,tablestart+0x8,0x4):
- table += filedata[i+0x3:i+0x4] + filedata[i+0x2:i+0x3] + filedata[i+0x1:i+0x2] + filedata[i:i+0x1]
- #table += 'ONUN4200'
- table += struct.pack('<I',tablelen)
- tablecount = struct.unpack('>I',filedata[tablestart+0xc:tablestart+0x10])[0]
- table += struct.pack('<I',tablecount)
- pos = tablestart+0x10
- cntr = 0
- for i in range(0,tablecount):
- tabletype = struct.unpack('>H',filedata[pos+0x2:pos+0x4])[0]
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- subtablelen = struct.unpack('>I',filedata[pos+0x4:pos+0x8])[0]
- table += struct.pack('<I',subtablelen)
- subentrycount = struct.unpack('>I',filedata[pos+0x8:pos+0xc])[0]
- table += struct.pack('<I',subentrycount)
- pos += 0xc
- for a in range(0,subentrycount):
- if tabletype == 0x1:
- for b in range(0x0,0x19): #0x64 bytes
- if b == 0x1:
- subsubentrycount = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- subsubentrycount1 = subsubentrycount
- subsubentrycount *= 0x10
- subsubentrycount /= 0x4
- elif b == 0x2:
- subsubentrycount2 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- subsubentrycount2 = (subsubentrycount2*0x2)+subsubentrycount2
- subsubentrycount2 *= 0x10
- subsubentrycount2 /= 0x4
- elif b == 0x3:
- subsubentrycount3 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- subsubentrycount3 += struct.unpack('>I',filedata[pos+0x4:pos+0x8])[0]
- subsubentrycount3 += subsubentrycount3
- subsubentrycount3 += subsubentrycount3
- subsubentrycount3 /= 0x4
- elif b == 0x5:
- subsubentrycount4 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- subsubentrycount4 += subsubentrycount4
- subsubentrycount4 += subsubentrycount4
- subsubentrycount4 /= 0x4
- if b == 0x12:
- table += struct.pack('<H',struct.unpack('>H',filedata[pos:pos+0x2])[0])
- table += struct.pack('<B',struct.unpack('>B',filedata[pos+0x2:pos+0x3])[0])
- table += struct.pack('<B',struct.unpack('>B',filedata[pos+0x3:pos+0x4])[0])
- else:
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- for b in range(0,subsubentrycount):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- subsubentrycount1 = (subsubentrycount1*0x2)+subsubentrycount1
- subsubentrycount1 += subsubentrycount1
- subsubentrycount1 += subsubentrycount1
- subsubentrycount1 += subsubentrycount1
- subsubentrycount1 /= 0x4
- for b in range(0,subsubentrycount1):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- for b in range(0,subsubentrycount2):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- for b in range(0,subsubentrycount3):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- for b in range(0,subsubentrycount4):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- elif tabletype == 0x2:
- for b in range(0x0,0x14): #0x50 bytes
- if b == 0x2:
- subsubentrycount = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- subsubentrycount *= 0x20
- subsubentrycount /= 0x4
- elif b == 0x3:
- subsubentrycount1 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- subsubentrycount1 += subsubentrycount1
- subsubentrycount1 += subsubentrycount1
- subsubentrycount1 /= 0x4
- if b == 0xd:
- table += struct.pack('>B',struct.unpack('>B',filedata[pos:pos+0x1])[0])
- table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x1:pos+0x2])[0])
- table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x2:pos+0x3])[0])
- table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x3:pos+0x4])[0])
- else:
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- for b in range(0,subsubentrycount):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- for b in range(0,subsubentrycount1):
- table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
- pos += 0x4
- return table
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement