diff --git a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java index 88285b81..440c52a4 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java @@ -259,9 +259,11 @@ public abstract class DexBackedDexFile extends BaseDexBuffer implements DexFile AnnotatedBytes annotatedBytes = new AnnotatedBytes(width); HeaderItem.getAnnotator().annotateSection(annotatedBytes, this, 1); + annotatedBytes.skipTo(getStringIdItemOffset(0)); annotatedBytes.annotate(0, " "); StringIdItem.getAnnotator().annotateSection(annotatedBytes, this, stringCount); + annotatedBytes.skipTo(getTypeIdItemOffset(0)); annotatedBytes.annotate(0, " "); TypeIdItem.getAnnotator().annotateSection(annotatedBytes, this, typeCount); diff --git a/dexlib2/src/main/java/org/jf/dexlib2/util/AnnotatedBytes.java b/dexlib2/src/main/java/org/jf/dexlib2/util/AnnotatedBytes.java index e942c3ff..53066f81 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/util/AnnotatedBytes.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/util/AnnotatedBytes.java @@ -61,6 +61,22 @@ public class AnnotatedBytes { this.outputWidth = width; } + /** + * Skips a portion of the binary output. This is equivalent to calling + * annotate(offset-cursor, ""); + * + * @param offset The offset to skip to + */ + public void skipTo(int offset) { + if (offset < cursor) { + throw new IllegalArgumentException("skipTo can only skip forward"); + } + int delta = offset - cursor; + if (delta != 0) { + annotate(delta, ""); + } + } + /** * Add an annotation of the given length at the current location. *