diff --git a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/MapItem.java b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/MapItem.java index 2dd27ea6..dc91c4ef 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/MapItem.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/MapItem.java @@ -32,6 +32,7 @@ package org.jf.dexlib2.dexbacked.raw; import org.jf.dexlib2.dexbacked.DexBackedDexFile; +import org.jf.dexlib2.util.AnnotatedBytes; import javax.annotation.Nonnull; @@ -66,4 +67,35 @@ public class MapItem { public int getOffset() { return dexFile.readSmallUint(offset + OFFSET_OFFSET); } + + @Nonnull + public static SectionAnnotator getAnnotator() { + return new SectionAnnotator() { + @Nonnull @Override public String getItemName() { + return "map_item"; + } + + @Override + protected void annotateItem(@Nonnull AnnotatedBytes out, @Nonnull DexBackedDexFile dexFile, int itemIndex) { + int itemType = dexFile.readUshort(out.getCursor()); + out.annotate(2, "type = 0x%x: %s", itemType, ItemType.getItemTypeName(itemType)); + + out.annotate(2, "unused"); + + int size = dexFile.readSmallUint(out.getCursor()); + out.annotate(4, "size = %d", size); + + int offset = dexFile.readSmallUint(out.getCursor()); + out.annotate(4, "offset = 0x%x", offset); + } + + @Override + public void annotateSection(@Nonnull AnnotatedBytes out, @Nonnull DexBackedDexFile dexFile, int itemCount) { + int mapItemCount = dexFile.readSmallUint(out.getCursor()); + out.annotate(4, "size = %d", mapItemCount); + + super.annotateSection(out, dexFile, mapItemCount); + } + }; + } } diff --git a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/RawDexFile.java b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/RawDexFile.java index 104cbd41..36904d37 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/RawDexFile.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/raw/RawDexFile.java @@ -78,7 +78,8 @@ public class RawDexFile { static { annotators = ImmutableMap.of( ItemType.TYPE_LIST, TypeListItem.getAnnotator(), - ItemType.ANNOTATION_SET_REF_LIST, AnnotationSetRefList.getAnnotator()); + ItemType.ANNOTATION_SET_REF_LIST, AnnotationSetRefList.getAnnotator(), + ItemType.MAP_LIST, MapItem.getAnnotator()); } public void dumpTo(Writer out, int width) throws IOException {