org.jf.dexlib2.dexbacked.DexReader Java Examples
The following examples show how to use
org.jf.dexlib2.dexbacked.DexReader.
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: EncodedValue.java From ZjDroid with Apache License 2.0 | 6 votes |
public static void annotateEncodedAnnotation(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { assert out.getCursor() == reader.getOffset(); int typeIndex = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); int size = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "size: %d", size); for (int i=0; i<size; i++) { out.annotate(0, "element[%d]", i); out.indent(); int nameIndex = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "name = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, nameIndex)); annotateEncodedValue(out, reader); out.deindent(); } }
Example #2
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 #3
Source File: StringDataItem.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 "string_data_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { DexReader reader = dexFile.readerAt(out.getCursor()); int utf16Length = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "utf16_size = %d", utf16Length); String value = reader.readString(utf16Length); out.annotateTo(reader.getOffset() + 1, "data = \"%s\"", StringUtils.escapeString(value)); } }; }
Example #4
Source File: EncodedValue.java From ZjDroid with Apache License 2.0 | 6 votes |
public static void annotateEncodedAnnotation(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { assert out.getCursor() == reader.getOffset(); int typeIndex = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); int size = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "size: %d", size); for (int i=0; i<size; i++) { out.annotate(0, "element[%d]", i); out.indent(); int nameIndex = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "name = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, nameIndex)); annotateEncodedValue(out, reader); out.deindent(); } }
Example #5
Source File: StringDataItem.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 "string_data_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { DexReader reader = dexFile.readerAt(out.getCursor()); int utf16Length = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "utf16_size = %d", utf16Length); String value = reader.readString(utf16Length); out.annotateTo(reader.getOffset() + 1, "data = \"%s\"", StringUtils.escapeString(value)); } }; }
Example #6
Source File: EncodedValue.java From HeyGirl with Apache License 2.0 | 6 votes |
public static void annotateEncodedAnnotation(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { assert out.getCursor() == reader.getOffset(); int typeIndex = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); int size = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "size: %d", size); for (int i=0; i<size; i++) { out.annotate(0, "element[%d]", i); out.indent(); int nameIndex = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "name = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, nameIndex)); annotateEncodedValue(out, reader); out.deindent(); } }
Example #7
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 #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: DexBackedAnnotationEncodedValue.java From ZjDroid with Apache License 2.0 | 5 votes |
public DexBackedAnnotationEncodedValue(@Nonnull DexReader reader) { this.dexFile = reader.dexBuf; this.type = dexFile.getType(reader.readSmallUleb128()); this.elementCount = reader.readSmallUleb128(); this.elementsOffset = reader.getOffset(); skipElements(reader, elementCount); }
Example #10
Source File: DexBackedAnnotationEncodedValue.java From zjdroid with Apache License 2.0 | 5 votes |
public DexBackedAnnotationEncodedValue(@Nonnull DexReader reader) { this.dexFile = reader.dexBuf; this.type = dexFile.getType(reader.readSmallUleb128()); this.elementCount = reader.readSmallUleb128(); this.elementsOffset = reader.getOffset(); skipElements(reader, elementCount); }
Example #11
Source File: DexBackedArrayEncodedValue.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends EncodedValue> getValue() { return new VariableSizeList<EncodedValue>(dexFile, encodedArrayOffset, elementCount) { @Nonnull @Override protected EncodedValue readNextItem(@Nonnull DexReader dexReader, int index) { return DexBackedEncodedValue.readFrom(dexReader); } }; }
Example #12
Source File: VariableSizeSet.java From ZjDroid with Apache License 2.0 | 5 votes |
@Override @Nonnull public VariableSizeIterator<T> iterator() { return new VariableSizeIterator<T>(dexFile, offset, size) { @Override protected T readNextItem(@Nonnull DexReader reader, int index) { return VariableSizeSet.this.readNextItem(reader, index); } }; }
Example #13
Source File: EncodedArrayItem.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 "encoded_array_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { DexReader reader = dexFile.readerAt(out.getCursor()); EncodedValue.annotateEncodedArray(out, reader); } }; }
Example #14
Source File: DexBackedInstruction.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull public static Instruction readFrom(@Nonnull DexReader reader) { int opcodeValue = reader.peekUbyte(); if (opcodeValue == 0) { opcodeValue = reader.peekUshort(); } Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue); Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset()); reader.moveRelative(instruction.getCodeUnits()*2); return instruction; }
Example #15
Source File: DexBackedAnnotationEncodedValue.java From HeyGirl with Apache License 2.0 | 5 votes |
public DexBackedAnnotationEncodedValue(@Nonnull DexReader reader) { this.dexFile = reader.dexBuf; this.type = dexFile.getType(reader.readSmallUleb128()); this.elementCount = reader.readSmallUleb128(); this.elementsOffset = reader.getOffset(); skipElements(reader, elementCount); }
Example #16
Source File: EncodedValue.java From HeyGirl with Apache License 2.0 | 5 votes |
public static void annotateEncodedArray(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { assert out.getCursor() == reader.getOffset(); int size = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "size: %d", size); for (int i=0; i<size; i++) { out.annotate(0, "element[%d]", i); out.indent(); annotateEncodedValue(out, reader); out.deindent(); } }
Example #17
Source File: VariableSizeCollection.java From ZjDroid with Apache License 2.0 | 5 votes |
@Override @Nonnull public VariableSizeIterator<T> iterator() { return new VariableSizeIterator<T>(dexFile, offset, size) { @Override protected T readNextItem(@Nonnull DexReader reader, int index) { return VariableSizeCollection.this.readNextItem(reader, index); } }; }
Example #18
Source File: VariableSizeSet.java From HeyGirl with Apache License 2.0 | 5 votes |
@Override @Nonnull public VariableSizeIterator<T> iterator() { return new VariableSizeIterator<T>(dexFile, offset, size) { @Override protected T readNextItem(@Nonnull DexReader reader, int index) { return VariableSizeSet.this.readNextItem(reader, index); } }; }
Example #19
Source File: EncodedArrayItem.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 "encoded_array_item"; } @Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { DexReader reader = dexFile.readerAt(out.getCursor()); EncodedValue.annotateEncodedArray(out, reader); } }; }
Example #20
Source File: EncodedValue.java From zjdroid with Apache License 2.0 | 5 votes |
public static void annotateEncodedArray(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { assert out.getCursor() == reader.getOffset(); int size = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "size: %d", size); for (int i=0; i<size; i++) { out.annotate(0, "element[%d]", i); out.indent(); annotateEncodedValue(out, reader); out.deindent(); } }
Example #21
Source File: DexBackedArrayEncodedValue.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends EncodedValue> getValue() { return new VariableSizeList<EncodedValue>(dexFile, encodedArrayOffset, elementCount) { @Nonnull @Override protected EncodedValue readNextItem(@Nonnull DexReader dexReader, int index) { return DexBackedEncodedValue.readFrom(dexReader); } }; }
Example #22
Source File: DexBackedAnnotationEncodedValue.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public Set<? extends DexBackedAnnotationElement> getElements() { return new VariableSizeSet<DexBackedAnnotationElement>(dexFile, elementsOffset, elementCount) { @Nonnull @Override protected DexBackedAnnotationElement readNextItem(@Nonnull DexReader dexReader, int index) { return new DexBackedAnnotationElement(dexReader); } }; }
Example #23
Source File: VariableSizeCollection.java From zjdroid with Apache License 2.0 | 5 votes |
@Override @Nonnull public VariableSizeIterator<T> iterator() { return new VariableSizeIterator<T>(dexFile, offset, size) { @Override protected T readNextItem(@Nonnull DexReader reader, int index) { return VariableSizeCollection.this.readNextItem(reader, index); } }; }
Example #24
Source File: VariableSizeSet.java From zjdroid with Apache License 2.0 | 5 votes |
@Override @Nonnull public VariableSizeIterator<T> iterator() { return new VariableSizeIterator<T>(dexFile, offset, size) { @Override protected T readNextItem(@Nonnull DexReader reader, int index) { return VariableSizeSet.this.readNextItem(reader, index); } }; }
Example #25
Source File: DexBackedArrayEncodedValue.java From zjdroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends EncodedValue> getValue() { return new VariableSizeList<EncodedValue>(dexFile, encodedArrayOffset, elementCount) { @Nonnull @Override protected EncodedValue readNextItem(@Nonnull DexReader dexReader, int index) { return DexBackedEncodedValue.readFrom(dexReader); } }; }
Example #26
Source File: DexBackedAnnotationEncodedValue.java From zjdroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public Set<? extends DexBackedAnnotationElement> getElements() { return new VariableSizeSet<DexBackedAnnotationElement>(dexFile, elementsOffset, elementCount) { @Nonnull @Override protected DexBackedAnnotationElement readNextItem(@Nonnull DexReader dexReader, int index) { return new DexBackedAnnotationElement(dexReader); } }; }
Example #27
Source File: DexBackedAnnotationEncodedValue.java From ZjDroid with Apache License 2.0 | 5 votes |
public DexBackedAnnotationEncodedValue(@Nonnull DexReader reader) { this.dexFile = reader.dexBuf; this.type = dexFile.getType(reader.readSmallUleb128()); this.elementCount = reader.readSmallUleb128(); this.elementsOffset = reader.getOffset(); skipElements(reader, elementCount); }
Example #28
Source File: EncodedValue.java From ZjDroid with Apache License 2.0 | 5 votes |
public static void annotateEncodedArray(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { assert out.getCursor() == reader.getOffset(); int size = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "size: %d", size); for (int i=0; i<size; i++) { out.annotate(0, "element[%d]", i); out.indent(); annotateEncodedValue(out, reader); out.deindent(); } }
Example #29
Source File: VariableSizeCollection.java From ZjDroid with Apache License 2.0 | 5 votes |
@Override @Nonnull public VariableSizeIterator<T> iterator() { return new VariableSizeIterator<T>(dexFile, offset, size) { @Override protected T readNextItem(@Nonnull DexReader reader, int index) { return VariableSizeCollection.this.readNextItem(reader, index); } }; }
Example #30
Source File: DexBackedEncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public static void skipFrom(@Nonnull DexReader reader) { int startOffset = reader.getOffset(); try { int b = reader.readUbyte(); int valueType = b & 0x1f; switch (valueType) { case ValueType.BYTE: reader.skipByte(); break; case ValueType.SHORT: case ValueType.CHAR: case ValueType.INT: case ValueType.LONG: case ValueType.FLOAT: case ValueType.DOUBLE: case ValueType.STRING: case ValueType.TYPE: case ValueType.FIELD: case ValueType.METHOD: case ValueType.ENUM: int valueArg = b >>> 5; reader.moveRelative(valueArg+1); break; case ValueType.ARRAY: DexBackedArrayEncodedValue.skipFrom(reader); break; case ValueType.ANNOTATION: DexBackedAnnotationEncodedValue.skipFrom(reader); break; case ValueType.NULL: case ValueType.BOOLEAN: break; default: throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType); } } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x", startOffset); } }