changed the logic that reads in the sections to read them in a specific order, because some sections depend on others being read in first (i.e. several things depend on the string data)

git-svn-id: https://smali.googlecode.com/svn/trunk@178 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com
2009-06-20 20:23:12 +00:00
parent 4ec387882d
commit 1af01ba107

View File

@ -107,11 +107,41 @@ public class DexFile
MapSection.readFrom(1, in);
for (MapField mapField: MapSection.items.get(0).getMapEntries()) {
Section section = sectionsByType.get(mapField.getSectionItemType());
if (section != null) {
in.setCursor(mapField.getSectionOffset());
section.readFrom(mapField.getSectionSize(), in);
MapField[] mapEntries = MapSection.items.get(0).getMapEntries();
HashMap<Integer, MapField> mapMap = new HashMap<Integer, MapField>();
for (MapField mapField: mapEntries) {
mapMap.put(mapField.getSectionItemType().getMapValue(), mapField);
}
int[] sectionTypes = new int[] {
ItemType.TYPE_HEADER_ITEM.getMapValue(),
ItemType.TYPE_STRING_ID_ITEM.getMapValue(),
ItemType.TYPE_TYPE_ID_ITEM.getMapValue(),
ItemType.TYPE_PROTO_ID_ITEM.getMapValue(),
ItemType.TYPE_FIELD_ID_ITEM.getMapValue(),
ItemType.TYPE_METHOD_ID_ITEM.getMapValue(),
ItemType.TYPE_CLASS_DEF_ITEM.getMapValue(),
ItemType.TYPE_STRING_DATA_ITEM.getMapValue(),
ItemType.TYPE_ENCODED_ARRAY_ITEM.getMapValue(),
ItemType.TYPE_ANNOTATION_ITEM.getMapValue(),
ItemType.TYPE_ANNOTATION_SET_ITEM.getMapValue(),
ItemType.TYPE_ANNOTATION_SET_REF_LIST.getMapValue(),
ItemType.TYPE_ANNOTATIONS_DIRECTORY_ITEM.getMapValue(),
ItemType.TYPE_TYPE_LIST.getMapValue(),
ItemType.TYPE_DEBUG_INFO_ITEM.getMapValue(),
ItemType.TYPE_CODE_ITEM.getMapValue(),
ItemType.TYPE_CLASS_DATA_ITEM.getMapValue(),
ItemType.TYPE_MAP_LIST.getMapValue()
};
for (int sectionType: sectionTypes) {
MapField mapField = mapMap.get(sectionType);
if (mapField != null) {
Section section = sectionsByType.get(mapField.getSectionItemType());
if (section != null) {
in.setCursor(mapField.getSectionOffset());
section.readFrom(mapField.getSectionSize(), in);
}
}
}
}