Example #1
0
 def _read_header(self):
     offset = Bit.u32_from(self._fp.read(4))
     self._fp.seek(offset)
     # 读取秘钥
     keylen = self._fp.read(1)[0]
     if keylen > 0:
         self._parser = self.Parser(keylen)
         self._parser.load(self._fp.read(keylen + 4))
     # 读取hash种子和文件数量
     buffer = self._fp.read(4)
     self._hseed = Bit.u16_from(buffer)
     filenum = Bit.u16_from(buffer[2:])
     # 读取文件表
     buffer = self._fp.read(filenum * 12)  # tag+pos+len=12
     offset = 0
     self._hashmap = {}
     for i in range(filenum):
         tag = Bit.u32_from(buffer[offset:offset + 4])
         offset += 4
         pos = Bit.u32_from(buffer[offset:offset + 4])
         offset += 4
         size = Bit.u32_from(buffer[offset:offset + 4])
         offset += 4
         self._hashmap[tag] = (pos, size)
     log.d('unpack bale files:', filenum)
Example #2
0
 def split_res(self):
     # with open(os.path.join(self.idir, 'package.was'), 'rb') as fp:
     with open(os.path.join(self.idir, 'patch.was'), 'rb') as fp:
         buffer = fp.read()
         buffer = buffer[32:]
     e = len(buffer)
     p = 0
     while p < e:
         p += 4
         b = buffer[p:p+4]
         fs = Bit.u32_from(b)
         p += 24
         b = buffer[p:p+4]
         ns = Bit.u32_from(b)
         p += 4
         fn = Text.unicodes2str(buffer[p:p+ns])
         p += ns + 1
         if fn.endswith('.luac'):
             fn = 'src/' + fn
         else:
             fn = 'res/' + fn
         print(p, fs, fn)
         fb = buffer[p:p+fs]
         p += fs
         fp = os.path.join(self.odir, fn)
         FS.make_parent(fp)
         with open(fp, 'wb') as fp:
             fp.write(fb)
     print(p, e)
Example #3
0
 def load(self, buffer):
     self._key = buffer[:self._keylen]
     self._let = Bit.u32_from(buffer[self._keylen:])