def from_bytes(b, little=True): header, b = ResChunk_header.from_bytes(b) id, b = uint8.from_bytes(b) res0, b = uint8.from_bytes(b) res1, b = uint16.from_bytes(b, True) entryCount, b = uint32.from_bytes(b, True) return ResTable_typeSpec_header(header, id, res0, res1, entryCount), b
def from_bytes(b, little=True): header, b = ResChunk_header.from_bytes(b) stringCount, b = uint32.from_bytes(b, little=True) styleCount, b = uint32.from_bytes(b, little=True) flags, b = ResStringPool_header.Flags.from_bytes(b, little=True) stringsStart, b = uint32.from_bytes(b, little=True) stylesStart, b = uint32.from_bytes(b, little=True) return ResStringPool_header(header, stringCount, styleCount, flags, stringsStart, stylesStart), b
def from_bytes(b, little=True): header, b = ResChunk_header.from_bytes(b) id, b = uint8.from_bytes(b) res0, b = uint8.from_bytes(b) res1, b = uint16.from_bytes(b, True) entryCount, b = uint32.from_bytes(b, True) entriesStart, b = uint32.from_bytes(b, True) config, b = ResTable_config.from_bytes(b) return ResTable_type_header(header, id, res0, res1, entryCount, entriesStart, config), b
def from_bytes(b): header, b = ResChunk_header.from_bytes(b) id, b = uint32.from_bytes(b, little=True) name, b = b[:256], b[256:] typeStrings, b = uint32.from_bytes(b, little=True) lastPublicType, b = uint32.from_bytes(b, little=True) keyStrings, b = uint32.from_bytes(b, little=True) lastPublicKey, b = uint32.from_bytes(b, little=True) return ResTable_package_header(header, id, name, typeStrings, lastPublicType, keyStrings, lastPublicKey), b[4:]
def from_bytes(b, little=True): content = b header, b = ResTable_package_header.from_bytes(b) content_size = header.header.size.integer content, b = content[:content_size], content[content_size:] typeStrings, at = ResStringPool.from_bytes( content[header.typeStrings.integer:]) keyStrings, ak = ResStringPool.from_bytes( content[header.keyStrings.integer:]) if len(ak) < len(at): rest = ak else: rest = at types = [] spec = None ret_b = b b = rest # Deserialize typeSpec and type till end of package. Final structure # would be list of lists, where inner list always starts with typeSpec # and contains all related type structures while len(b) > 0: hdr, _ = ResChunk_header.from_bytes(b) if hdr.type == ResourceType.RES_TABLE_TYPE_SPEC_TYPE: if spec is not None: types.append(spec) spec = [] typeSpec, b = ResTable_typeSpec.from_bytes(b) spec.append(typeSpec) elif hdr.type == ResourceType.RES_TABLE_TYPE_TYPE: typ, b = ResTable_type.from_bytes(b) spec.append(typ) else: raise ChunkHeaderWrongTypeException([ ResourceType.RES_TABLE_TYPE_SPEC_TYPE, ResourceType.RES_TABLE_TYPE_TYPE ], hdr.type) types.append(spec) return ResTable_package(header, typeStrings, keyStrings, types), ret_b
def from_bytes(b, little=True): header, b = ResChunk_header.from_bytes(b) packageCount, b = uint32.from_bytes(b, little=True) return ResTable_header(header, packageCount), b