Advertisement
Guest User

Untitled

a guest
Jun 11th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.59 KB | None | 0 0
  1. def tableNUNV(filedata,tablestart):
  2.     tablelen = struct.unpack('>I',filedata[tablestart+0x8:tablestart+0xc])[0]
  3.     table = ''
  4.  
  5.     for i in range(tablestart,tablestart+0x8,0x4):
  6.         table += filedata[i+0x3:i+0x4] + filedata[i+0x2:i+0x3] + filedata[i+0x1:i+0x2] + filedata[i:i+0x1]
  7.     #table += 'VNUN0100'
  8.  
  9.     table += struct.pack('<I',tablelen)
  10.     entrycount = struct.unpack('>I',filedata[tablestart+0xc:tablestart+0x10])[0]
  11.     table += struct.pack('<I',entrycount)
  12.  
  13.     pos = tablestart+0x10
  14.     for i in range(0,entrycount):
  15.         table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
  16.         table += struct.pack('<I',struct.unpack('>I',filedata[pos+0x4:pos+0x8])[0])
  17.         entrycount2 = struct.unpack('>I',filedata[pos+0x8:pos+0xc])[0]
  18.         table += struct.pack('<I',entrycount2)
  19.         pos += 0xc
  20.  
  21.         for a in range(0,entrycount2):
  22.             for b in range(0,25): #64 bytes in total
  23.                 if b == 0x1:
  24.                     entrycount3 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
  25.                 elif b == 0x2:
  26.                     entrycount4 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
  27.                 elif b == 0x3:
  28.                     entrycount5 = struct.unpack('>I',filedata[pos:pos+0x4])[0]
  29.                    
  30.                 if b == 24:
  31.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos:pos+0x1])[0])
  32.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x1:pos+0x2])[0])
  33.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x2:pos+0x3])[0])
  34.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x3:pos+0x4])[0])
  35.                 else:
  36.                     table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
  37.                 pos += 0x4
  38.  
  39.             tmpcount1 = entrycount3 * 0x10
  40.             tmpcount1 /= 0x4
  41.             for b in range(0,tmpcount1):
  42.                 table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
  43.                 pos += 0x4
  44.                
  45.             tmpcount1 = (entrycount3*0x2)+entrycount3
  46.             tmpcount1 += tmpcount1
  47.             tmpcount1 += tmpcount1
  48.             tmpcount1 += tmpcount1
  49.             tmpcount1 /= 0x4
  50.             for b in range(0,tmpcount1):
  51.                 table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
  52.                 pos += 0x4
  53.            
  54.             tmpcount1 = (entrycount4*0x2)+entrycount4
  55.             tmpcount1 *= 0x10
  56.             tmpcount1 /= 0x4
  57.             lenmoved = 0
  58.             for b in range(0,tmpcount1):
  59.                 if lenmoved == 0x24:
  60.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos:pos+0x1])[0])
  61.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x1:pos+0x2])[0])
  62.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x2:pos+0x3])[0])
  63.                     table += struct.pack('>B',struct.unpack('>B',filedata[pos+0x3:pos+0x4])[0])
  64.                 else:
  65.                     table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
  66.                 pos += 0x4
  67.                 lenmoved += 0x4
  68.                 if lenmoved == 0x30:
  69.                     lenmoved = 0
  70.                
  71.  
  72.             tmpcount1 = entrycount5
  73.             tmpcount1 += tmpcount1
  74.             tmpcount1 += tmpcount1
  75.             tmpcount1 /= 0x4
  76.             for b in range(0,tmpcount1):
  77.                 table += struct.pack('<I',struct.unpack('>I',filedata[pos:pos+0x4])[0])
  78.                 pos += 0x4
  79.  
  80.     return table
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement