#! /usr/bin/env python from __future__ import with_statement from util import from_b64 import sys import struct def fguid(s): a, b, c, d, e = struct.unpack("" % self.type) small, large = self.TI[self.type] if callable(large): large = large(self) return small, large def showinfo(self, ts=''): if self.type == 0x02: print ts + "GUID-defined section" if self.sections: print ts + " CRC32 subsection container:" for i, s in enumerate(self.sections): print ts + " Subsection %d: type 0x%02x, size 0x%x" % ( i, s.type, s.size) s.showinfo(ts + " ") else: print ts + self.get_type_info()[1] def dump(self, base): if self.sections: for i, s in enumerate(self.sections): s.dump("%s.sub%d" % (base, i)) return name = "%s.%s" % (base, self.get_type_info()[0]) with open(name, "wb") as fd: fd.write(self.data) print name def __repr__(self): return "" % (self.name, self.get_type_info()[0], self.size) class FFSFile(object): def __repr__(self): return "" % (self.size - 0x18, len(self.data), self.type, self.state, fguid(self.guid)) def __init__(self, data): hdr = data[:0x18] self.guid, self.checksum, self.type, self.attributes, self.size, self.state = struct.unpack("<16sHBB3sB", hdr) self.size = struct.unpack("