use of org.jf.dexlib2.dexbacked.DexReader in project smali by JesusFreke.
the class DexBackedInstruction method readFrom.
@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;
}
use of org.jf.dexlib2.dexbacked.DexReader in project android-classyshark by google.
the class DexReader method main.
public static void main(String[] args) {
DexReader dxr = new DexReader(new File("//Users//bfarber//Desktop//classes.dex"));
dxr.read();
System.out.println(dxr.getClassNames());
}
use of org.jf.dexlib2.dexbacked.DexReader in project smali by JesusFreke.
the class DexBackedInstruction method readFrom.
@Nonnull
public static Instruction readFrom(DexBackedDexFile dexFile, @Nonnull DexReader reader) {
int opcodeValue = reader.peekUbyte();
if (opcodeValue == 0) {
opcodeValue = reader.peekUshort();
}
Opcode opcode = dexFile.getOpcodes().getOpcodeByValue(opcodeValue);
Instruction instruction = buildInstruction(dexFile, opcode, reader.getOffset() + reader.dexBuf.getBaseOffset() - dexFile.getBuffer().getBaseOffset() - dexFile.getBaseDataOffset());
reader.moveRelative(instruction.getCodeUnits() * 2);
return instruction;
}
use of org.jf.dexlib2.dexbacked.DexReader in project smali by JesusFreke.
the class DexBackedClassDef method getInstanceFields.
@Nonnull
public Iterable<? extends DexBackedField> getInstanceFields(final boolean skipDuplicates) {
if (instanceFieldCount > 0) {
DexReader reader = dexFile.getDataBuffer().readerAt(getInstanceFieldsOffset());
final AnnotationsDirectory annotationsDirectory = getAnnotationsDirectory();
final int fieldsStartOffset = reader.getOffset();
Iterator<Integer> hiddenApiRestrictionIterator = hiddenApiRestrictionsReader == null ? null : hiddenApiRestrictionsReader.getRestrictionsForInstanceFields();
return new Iterable<DexBackedField>() {
@Nonnull
@Override
public Iterator<DexBackedField> iterator() {
final AnnotationsDirectory.AnnotationIterator annotationIterator = annotationsDirectory.getFieldAnnotationIterator();
return new VariableSizeLookaheadIterator<DexBackedField>(dexFile.getDataBuffer(), fieldsStartOffset) {
private int count;
@Nullable
private FieldReference previousField;
private int previousIndex;
@Nullable
@Override
protected DexBackedField readNextItem(@Nonnull DexReader reader) {
while (true) {
if (++count > instanceFieldCount) {
directMethodsOffset = reader.getOffset();
return endOfData();
}
int hiddenApiRestrictions = NO_HIDDEN_API_RESTRICTIONS;
if (hiddenApiRestrictionIterator != null) {
hiddenApiRestrictions = hiddenApiRestrictionIterator.next();
}
DexBackedField item = new DexBackedField(dexFile, reader, DexBackedClassDef.this, previousIndex, annotationIterator, hiddenApiRestrictions);
FieldReference currentField = previousField;
FieldReference nextField = ImmutableFieldReference.of(item);
previousField = nextField;
previousIndex = item.fieldIndex;
if (skipDuplicates && currentField != null && currentField.equals(nextField)) {
continue;
}
return item;
}
}
};
}
};
} else {
if (instanceFieldsOffset > 0) {
directMethodsOffset = instanceFieldsOffset;
}
return ImmutableSet.of();
}
}
use of org.jf.dexlib2.dexbacked.DexReader in project smali by JesusFreke.
the class DexBackedMethod method getSize.
/**
* Calculate and return the private size of a method definition.
*
* Calculated as: method_idx_diff + access_flags + code_off +
* implementation size + reference size
*
* @return size in bytes
*/
public int getSize() {
int size = 0;
DexReader reader = dexFile.getDataBuffer().readerAt(startOffset);
// method_idx_diff
reader.readLargeUleb128();
// access_flags
reader.readSmallUleb128();
// code_off
reader.readSmallUleb128();
size += reader.getOffset() - startOffset;
DexBackedMethodImplementation impl = getImplementation();
if (impl != null) {
size += impl.getSize();
}
DexBackedMethodReference methodRef = new DexBackedMethodReference(dexFile, methodIndex);
size += methodRef.getSize();
return size;
}
Aggregations