public void parse() { // read magic string magic = Encoding.UTF8.GetString(Buffers.readBytes(buffer, 8)); //new string(Buffers.readBytes(buffer, 8)); if (!magic.StartsWith("dex\n")) { return; } int version = int.Parse(magic.Substring(4, 7)); // now the version is 035 if (version < 35) { // version 009 was used for the M3 releases of the Android platform (November–December 2007), // and version 013 was used for the M5 releases of the Android platform (February–March 2008) throw new Exception("Dex file version: " + version + " is not supported"); } // read header DexHeader header = readDexHeader(); header.setVersion(version); // read string pool long[] stringOffsets = readStringPool(header.getStringIdsOff(), header.getStringIdsSize()); // read types int[] typeIds = readTypes(header.getTypeIdsOff(), header.getTypeIdsSize()); // read classes DexClassStruct[] dexClassStructs = readClass(header.getClassDefsOff(), header.getClassDefsSize()); StringPool stringpool = readStrings(stringOffsets); string[] types = new string[typeIds.Length]; for (int i = 0; i < typeIds.Length; i++) { types[i] = stringpool.get(typeIds[i]); } dexClasses = new DexClass[dexClassStructs.Length]; for (int i = 0; i < dexClasses.Length; i++) { dexClasses[i] = new DexClass(); } for (int i = 0; i < dexClassStructs.Length; i++) { DexClassStruct dexClassStruct = dexClassStructs[i]; DexClass dexClass = dexClasses[i]; dexClass.setClassType(types[dexClassStruct.getClassIdx()]); if (dexClassStruct.getSuperclassIdx() != NO_INDEX) { dexClass.setSuperClass(types[dexClassStruct.getSuperclassIdx()]); } dexClass.setAccessFlags(dexClassStruct.getAccessFlags()); } }
public override void rsc(int i, int h, MappedInStream @in) { restrictionsCore.Properties[] d = ((P0)owner.basePool).Data; StringPool t = (StringPool)owner.Owner.Strings(); for (; i != h; i++) { ((restrictionsCore.ZSystem)d[i]).name = t.get(@in.v32()); } }
public override void rsc(int i, int h, MappedInStream @in) { unicode.Unicode[] d = ((P0)owner).Data; StringPool t = (StringPool)owner.Owner.Strings(); for (; i != h; i++) { d[i].two = t.get(@in.v32()); } }
public override void rsc(int i, int h, MappedInStream @in) { escaping.Z2200[] d = ((P3)owner).Data; StringPool t = (StringPool)owner.Owner.Strings(); for (; i != h; i++) { d[i].Z2622 = t.get(@in.v32()); } }
private async Task <ResourceEntry> readResourceEntry() { long beginPos = buffer.position(); ResourceEntry resourceEntry = new ResourceEntry(); // size is always 8(simple), or 16(complex) resourceEntry.setSize(await Buffers.readUShort(buffer)); resourceEntry.setFlags(await Buffers.readUShort(buffer)); long keyRef = buffer.getInt(); string key = keyStringPool.get((int)keyRef); resourceEntry.setKey(key); if ((resourceEntry.getFlags() & ResourceEntry.FLAG_COMPLEX) != 0) { ResourceMapEntry resourceMapEntry = new ResourceMapEntry(resourceEntry); // Resource identifier of the parent mapping, or 0 if there is none. resourceMapEntry.setParent(Buffers.readUInt(buffer)); resourceMapEntry.setCount(Buffers.readUInt(buffer)); buffer.position((int)(beginPos + resourceEntry.getSize())); //An individual complex Resource entry comprises an entry immediately followed by one or more fields. ResourceTableMap[] resourceTableMaps = new ResourceTableMap[(int)resourceMapEntry.getCount()]; for (int i = 0; i < resourceMapEntry.getCount(); i++) { resourceTableMaps[i] = await readResourceTableMap(); } resourceMapEntry.setResourceTableMaps(resourceTableMaps); return(resourceMapEntry); } else { buffer.position((int)(beginPos + resourceEntry.getSize())); resourceEntry.setValue(await ParseUtils.readResValue(buffer, stringPool)); return(resourceEntry); } }
private async Task <XmlCData> readXmlCData() { XmlCData xmlCData = new XmlCData(); int dataRef = buffer.getInt(); if (dataRef > 0) { xmlCData.setData(stringPool.get(dataRef)); } xmlCData.setTypedData(await ParseUtils.readResValue(buffer, stringPool)); if (xmlStreamer != null) { //TODO: to know more about cdata. some cdata appears buffer xml tags // String value = xmlCData.toStringValue(resourceTable, locale); // xmlCData.setValue(value); // xmlStreamer.onCData(xmlCData); } return(xmlCData); }