Java Code Examples for org.jf.dexlib2.util.AnnotatedBytes#annotate()
The following examples show how to use
org.jf.dexlib2.util.AnnotatedBytes#annotate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtoIdItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "proto_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int shortyIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "shorty_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, shortyIndex)); int returnTypeIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "return_type_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, returnTypeIndex)); int parametersOffset = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "parameters_off = %s", TypeListItem.getReferenceAnnotation(dexFile, parametersOffset)); } }; }
Example 2
Source File: ProtoIdItem.java From HeyGirl with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "proto_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int shortyIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "shorty_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, shortyIndex)); int returnTypeIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "return_type_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, returnTypeIndex)); int parametersOffset = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "parameters_off = %s", TypeListItem.getReferenceAnnotation(dexFile, parametersOffset)); } }; }
Example 3
Source File: FieldIdItem.java From zjdroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "field_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int typeIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "return_type_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, typeIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 4
Source File: FieldIdItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "field_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int typeIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "return_type_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, typeIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 5
Source File: SectionAnnotator.java From ZjDroid with Apache License 2.0 | 6 votes |
protected void annotateSectionInner(@Nonnull AnnotatedBytes out, int itemCount) { String itemName = getItemName(); int itemAlignment = getItemAlignment(); if (itemCount > 0) { out.annotate(0, ""); out.annotate(0, "-----------------------------"); out.annotate(0, "%s section", itemName); out.annotate(0, "-----------------------------"); out.annotate(0, ""); for (int i=0; i<itemCount; i++) { out.moveTo(AlignmentUtils.alignOffset(out.getCursor(), itemAlignment)); String itemIdentity = getItemIdentity(out.getCursor()); if (itemIdentity != null) { out.annotate(0, "[%d] %s: %s", i, itemName, itemIdentity); } else { out.annotate(0, "[%d] %s", i, itemName); } out.indent(); annotateItem(out, i, itemIdentity); out.deindent(); } } }
Example 6
Source File: MethodIdItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "method_id_item"; } @Override public void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int protoIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "proto_idx = %s", ProtoIdItem.getReferenceAnnotation(dexFile, protoIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 7
Source File: FieldIdItem.java From HeyGirl with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "field_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int typeIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "return_type_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, typeIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 8
Source File: AnnotationItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "annotation_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int visibility = dexFile.readUbyte(out.getCursor()); out.annotate(1, "visibility = %d: %s", visibility, getAnnotationVisibility(visibility)); DexReader reader = dexFile.readerAt(out.getCursor()); EncodedValue.annotateEncodedAnnotation(out, reader); } }; }
Example 9
Source File: FieldIdItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "field_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int typeIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "return_type_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, typeIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 10
Source File: SectionAnnotator.java From HeyGirl with Apache License 2.0 | 6 votes |
protected void annotateSectionInner(@Nonnull AnnotatedBytes out, int itemCount) { String itemName = getItemName(); int itemAlignment = getItemAlignment(); if (itemCount > 0) { out.annotate(0, ""); out.annotate(0, "-----------------------------"); out.annotate(0, "%s section", itemName); out.annotate(0, "-----------------------------"); out.annotate(0, ""); for (int i=0; i<itemCount; i++) { out.moveTo(AlignmentUtils.alignOffset(out.getCursor(), itemAlignment)); String itemIdentity = getItemIdentity(out.getCursor()); if (itemIdentity != null) { out.annotate(0, "[%d] %s: %s", i, itemName, itemIdentity); } else { out.annotate(0, "[%d] %s", i, itemName); } out.indent(); annotateItem(out, i, itemIdentity); out.deindent(); } } }
Example 11
Source File: MethodIdItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "method_id_item"; } @Override public void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int protoIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "proto_idx = %s", ProtoIdItem.getReferenceAnnotation(dexFile, protoIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 12
Source File: MethodIdItem.java From HeyGirl with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "method_id_item"; } @Override public void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int classIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "class_idx = %s", TypeIdItem.getReferenceAnnotation(dexFile, classIndex)); int protoIndex = dexFile.readUshort(out.getCursor()); out.annotate(2, "proto_idx = %s", ProtoIdItem.getReferenceAnnotation(dexFile, protoIndex)); int nameIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "name_idx = %s", StringIdItem.getReferenceAnnotation(dexFile, nameIndex)); } }; }
Example 13
Source File: AnnotationSetRefList.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "annotation_set_ref_list"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int size = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "size = %d", size); for (int i=0; i<size; i++) { int annotationSetOffset = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "annotation_set_item[0x%x]", annotationSetOffset); } } @Override public int getItemAlignment() { return 4; } }; }
Example 14
Source File: AnnotationItem.java From HeyGirl with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "annotation_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int visibility = dexFile.readUbyte(out.getCursor()); out.annotate(1, "visibility = %d: %s", visibility, getAnnotationVisibility(visibility)); DexReader reader = dexFile.readerAt(out.getCursor()); EncodedValue.annotateEncodedAnnotation(out, reader); } }; }
Example 15
Source File: AnnotationItem.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "annotation_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int visibility = dexFile.readUbyte(out.getCursor()); out.annotate(1, "visibility = %d: %s", visibility, getAnnotationVisibility(visibility)); DexReader reader = dexFile.readerAt(out.getCursor()); EncodedValue.annotateEncodedAnnotation(out, reader); } }; }
Example 16
Source File: TypeIdItem.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "type_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int stringIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, StringIdItem.getReferenceAnnotation(dexFile, stringIndex)); } }; }
Example 17
Source File: TypeIdItem.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "type_id_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int stringIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, StringIdItem.getReferenceAnnotation(dexFile, stringIndex)); } }; }
Example 18
Source File: EncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public static void annotateEncodedValue(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { int valueArgType = reader.readUbyte(); int valueArg = valueArgType >>> 5; int valueType = valueArgType & 0x1f; switch (valueType) { case 0x00: out.annotate(1, "valueArg = %d, valueType = 0x%x: byte", valueArg, valueType); int intValue = reader.readByte(); out.annotate(1, "value = 0x%x", intValue); break; case 0x02: out.annotate(1, "valueArg = %d, valueType = 0x%x: short", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg + 1, "value = 0x%x", intValue); break; case 0x03: out.annotate(1, "valueArg = %d, valueType = 0x%x: char", valueArg, valueType); intValue = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x04: out.annotate(1, "valueArg = %d, valueType = 0x%x: int", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x06: out.annotate(1, "valueArg = %d, valueType = 0x%x: long", valueArg, valueType); long longValue = reader.readSizedLong(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", longValue); break; case 0x10: out.annotate(1, "valueArg = %d, valueType = 0x%x: float", valueArg, valueType); float floatValue = Float.intBitsToFloat(reader.readSizedRightExtendedInt(valueArg + 1)); out.annotate(valueArg+1, "value = %f", floatValue); break; case 0x11: out.annotate(1, "valueArg = %d, valueType = 0x%x: double", valueArg, valueType); double doubleValue = Double.longBitsToDouble(reader.readSizedRightExtendedLong(valueArg + 1)); out.annotate(valueArg+1, "value = %f", doubleValue); break; case 0x17: out.annotate(1, "valueArg = %d, valueType = 0x%x: string", valueArg, valueType); int stringIndex = reader.readSizedSmallUint(valueArg + 1); out.annotate(valueArg+1, "value = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, stringIndex, true)); break; case 0x18: out.annotate(1, "valueArg = %d, valueType = 0x%x: type", valueArg, valueType); int typeIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); break; case 0x19: out.annotate(1, "valueArg = %d, valueType = 0x%x: field", valueArg, valueType); int fieldIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex)); break; case 0x1a: out.annotate(1, "valueArg = %d, valueType = 0x%x: method", valueArg, valueType); int methodIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", MethodIdItem.getReferenceAnnotation(reader.dexBuf, methodIndex)); break; case 0x1b: out.annotate(1, "valueArg = %d, valueType = 0x%x: enum", valueArg, valueType); fieldIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex)); break; case 0x1c: out.annotate(1, "valueArg = %d, valueType = 0x%x: array", valueArg, valueType); annotateEncodedArray(out, reader); break; case 0x1d: out.annotate(1, "valueArg = %d, valueType = 0x%x: annotation", valueArg, valueType); annotateEncodedAnnotation(out, reader); break; case 0x1e: out.annotate(1, "valueArg = %d, valueType = 0x%x: null", valueArg, valueType); break; case 0x1f: out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1); break; default: throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType, out.getCursor()); } }
Example 19
Source File: EncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public static void annotateEncodedValue(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { int valueArgType = reader.readUbyte(); int valueArg = valueArgType >>> 5; int valueType = valueArgType & 0x1f; switch (valueType) { case 0x00: out.annotate(1, "valueArg = %d, valueType = 0x%x: byte", valueArg, valueType); int intValue = reader.readByte(); out.annotate(1, "value = 0x%x", intValue); break; case 0x02: out.annotate(1, "valueArg = %d, valueType = 0x%x: short", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg + 1, "value = 0x%x", intValue); break; case 0x03: out.annotate(1, "valueArg = %d, valueType = 0x%x: char", valueArg, valueType); intValue = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x04: out.annotate(1, "valueArg = %d, valueType = 0x%x: int", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x06: out.annotate(1, "valueArg = %d, valueType = 0x%x: long", valueArg, valueType); long longValue = reader.readSizedLong(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", longValue); break; case 0x10: out.annotate(1, "valueArg = %d, valueType = 0x%x: float", valueArg, valueType); float floatValue = Float.intBitsToFloat(reader.readSizedRightExtendedInt(valueArg + 1)); out.annotate(valueArg+1, "value = %f", floatValue); break; case 0x11: out.annotate(1, "valueArg = %d, valueType = 0x%x: double", valueArg, valueType); double doubleValue = Double.longBitsToDouble(reader.readSizedRightExtendedLong(valueArg + 1)); out.annotate(valueArg+1, "value = %f", doubleValue); break; case 0x17: out.annotate(1, "valueArg = %d, valueType = 0x%x: string", valueArg, valueType); int stringIndex = reader.readSizedSmallUint(valueArg + 1); out.annotate(valueArg+1, "value = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, stringIndex, true)); break; case 0x18: out.annotate(1, "valueArg = %d, valueType = 0x%x: type", valueArg, valueType); int typeIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); break; case 0x19: out.annotate(1, "valueArg = %d, valueType = 0x%x: field", valueArg, valueType); int fieldIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex)); break; case 0x1a: out.annotate(1, "valueArg = %d, valueType = 0x%x: method", valueArg, valueType); int methodIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", MethodIdItem.getReferenceAnnotation(reader.dexBuf, methodIndex)); break; case 0x1b: out.annotate(1, "valueArg = %d, valueType = 0x%x: enum", valueArg, valueType); fieldIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex)); break; case 0x1c: out.annotate(1, "valueArg = %d, valueType = 0x%x: array", valueArg, valueType); annotateEncodedArray(out, reader); break; case 0x1d: out.annotate(1, "valueArg = %d, valueType = 0x%x: annotation", valueArg, valueType); annotateEncodedAnnotation(out, reader); break; case 0x1e: out.annotate(1, "valueArg = %d, valueType = 0x%x: null", valueArg, valueType); break; case 0x1f: out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1); break; default: throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType, out.getCursor()); } }
Example 20
Source File: HeaderItem.java From zjdroid with Apache License 2.0 | 4 votes |
@Nonnull public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) { return new SectionAnnotator(annotator, mapItem) { @Nonnull @Override public String getItemName() { return "header_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int startOffset = out.getCursor(); int headerSize; StringBuilder magicBuilder = new StringBuilder(); for (int i=0; i<8; i++) { magicBuilder.append((char)dexFile.readUbyte(startOffset + i)); } out.annotate(8, "magic: %s", StringUtils.escapeString(magicBuilder.toString())); out.annotate(4, "checksum"); out.annotate(20, "signature"); out.annotate(4, "file_size: %d", dexFile.readInt(out.getCursor())); headerSize = dexFile.readInt(out.getCursor()); out.annotate(4, "header_size: %d", headerSize); int endianTag = dexFile.readInt(out.getCursor()); out.annotate(4, "endian_tag: 0x%x (%s)", endianTag, getEndianText(endianTag)); out.annotate(4, "link_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "link_offset: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "map_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "string_ids_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "string_ids_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "type_ids_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "type_ids_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "proto_ids_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "proto_ids_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "field_ids_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "field_ids_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "method_ids_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "method_ids_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "class_defs_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "class_defs_off: 0x%x", dexFile.readInt(out.getCursor())); out.annotate(4, "data_size: %d", dexFile.readInt(out.getCursor())); out.annotate(4, "data_off: 0x%x", dexFile.readInt(out.getCursor())); if (headerSize > ITEM_SIZE) { out.annotateTo(headerSize, "header padding"); } } }; }