mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 19:04:32 +02:00
Merge DexBuffer functionality into DexBackedDexFile
This commit is contained in:
parent
0acc897cdd
commit
84c1762a62
@ -34,7 +34,6 @@ package org.jf.dexlib2;
|
|||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
|
||||||
import org.jf.dexlib2.iface.DexFile;
|
import org.jf.dexlib2.iface.DexFile;
|
||||||
import org.jf.util.ExceptionWithContext;
|
import org.jf.util.ExceptionWithContext;
|
||||||
|
|
||||||
@ -94,8 +93,7 @@ public final class DexFileFactory {
|
|||||||
dexBytes = Files.toByteArray(dexFile);
|
dexBytes = Files.toByteArray(dexFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
DexBuffer dexBuf = new DexBuffer(dexBytes);
|
return new DexBackedDexFile.Impl(dexBytes);
|
||||||
return new DexBackedDexFile(dexBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeDexFile(String path, DexFile dexFile) throws IOException {
|
public static void writeDexFile(String path, DexFile dexFile) throws IOException {
|
||||||
|
@ -38,32 +38,32 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DexBackedAnnotation extends BaseAnnotation {
|
public class DexBackedAnnotation extends BaseAnnotation {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
|
|
||||||
public final int visibility;
|
public final int visibility;
|
||||||
public final int typeIndex;
|
public final int typeIndex;
|
||||||
private final int elementsOffset;
|
private final int elementsOffset;
|
||||||
|
|
||||||
public DexBackedAnnotation(@Nonnull DexBuffer dexBuf,
|
public DexBackedAnnotation(@Nonnull DexBackedDexFile dexFile,
|
||||||
int annotationOffset) {
|
int annotationOffset) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
|
|
||||||
DexReader reader = dexBuf.readerAt(annotationOffset);
|
DexReader reader = dexFile.readerAt(annotationOffset);
|
||||||
this.visibility = reader.readUbyte();
|
this.visibility = reader.readUbyte();
|
||||||
this.typeIndex = reader.readSmallUleb128();
|
this.typeIndex = reader.readSmallUleb128();
|
||||||
this.elementsOffset = reader.getOffset();
|
this.elementsOffset = reader.getOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getVisibility() { return visibility; }
|
@Override public int getVisibility() { return visibility; }
|
||||||
@Nonnull @Override public String getType() { return dexBuf.getType(typeIndex); }
|
@Nonnull @Override public String getType() { return dexFile.getType(typeIndex); }
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends DexBackedAnnotationElement> getElements() {
|
public Set<? extends DexBackedAnnotationElement> getElements() {
|
||||||
DexReader reader = dexBuf.readerAt(elementsOffset);
|
DexReader reader = dexFile.readerAt(elementsOffset);
|
||||||
final int size = reader.readSmallUleb128();
|
final int size = reader.readSmallUleb128();
|
||||||
|
|
||||||
return new VariableSizeSet<DexBackedAnnotationElement>(dexBuf, reader.getOffset(), size) {
|
return new VariableSizeSet<DexBackedAnnotationElement>(dexFile, reader.getOffset(), size) {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected DexBackedAnnotationElement readNextItem(@Nonnull DexReader reader, int index) {
|
protected DexBackedAnnotationElement readNextItem(@Nonnull DexReader reader, int index) {
|
||||||
|
@ -38,16 +38,16 @@ import org.jf.dexlib2.iface.value.EncodedValue;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedAnnotationElement extends BaseAnnotationElement {
|
public class DexBackedAnnotationElement extends BaseAnnotationElement {
|
||||||
@Nonnull private final DexBuffer dexBuf;
|
@Nonnull private final DexBackedDexFile dexFile;
|
||||||
public final int nameIndex;
|
public final int nameIndex;
|
||||||
@Nonnull public final EncodedValue value;
|
@Nonnull public final EncodedValue value;
|
||||||
|
|
||||||
public DexBackedAnnotationElement(@Nonnull DexReader reader) {
|
public DexBackedAnnotationElement(@Nonnull DexReader reader) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.nameIndex = reader.readSmallUleb128();
|
this.nameIndex = reader.readSmallUleb128();
|
||||||
this.value = DexBackedEncodedValue.readFrom(reader);
|
this.value = DexBackedEncodedValue.readFrom(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull @Override public String getName() { return dexBuf.getString(nameIndex); }
|
@Nonnull @Override public String getName() { return dexFile.getString(nameIndex); }
|
||||||
@Nonnull @Override public EncodedValue getValue() { return value; }
|
@Nonnull @Override public EncodedValue getValue() { return value; }
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int classDefOffset;
|
private final int classDefOffset;
|
||||||
|
|
||||||
private int classDataOffset = -1;
|
private int classDataOffset = -1;
|
||||||
@ -63,46 +63,46 @@ public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
|||||||
private static final int CLASS_DATA_OFFSET = 24;
|
private static final int CLASS_DATA_OFFSET = 24;
|
||||||
private static final int STATIC_INITIAL_VALUES_OFFSET = 28;
|
private static final int STATIC_INITIAL_VALUES_OFFSET = 28;
|
||||||
|
|
||||||
public DexBackedClassDef(@Nonnull DexBuffer dexBuf,
|
public DexBackedClassDef(@Nonnull DexBackedDexFile dexFile,
|
||||||
int classDefOffset) {
|
int classDefOffset) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.classDefOffset = classDefOffset;
|
this.classDefOffset = classDefOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return dexBuf.getType(dexBuf.readSmallUint(classDefOffset + CLASS_NAME_OFFSET));
|
return dexFile.getType(dexFile.readSmallUint(classDefOffset + CLASS_NAME_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String getSuperclass() {
|
public String getSuperclass() {
|
||||||
return dexBuf.getOptionalType(dexBuf.readOptionalUint(classDefOffset + SUPERCLASS_OFFSET));
|
return dexFile.getOptionalType(dexFile.readOptionalUint(classDefOffset + SUPERCLASS_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAccessFlags() {
|
public int getAccessFlags() {
|
||||||
return dexBuf.readSmallUint(classDefOffset + ACCESS_FLAGS_OFFSET);
|
return dexFile.readSmallUint(classDefOffset + ACCESS_FLAGS_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String getSourceFile() {
|
public String getSourceFile() {
|
||||||
return dexBuf.getOptionalString(dexBuf.readOptionalUint(classDefOffset + SOURCE_FILE_OFFSET));
|
return dexFile.getOptionalString(dexFile.readOptionalUint(classDefOffset + SOURCE_FILE_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getInterfaces() {
|
public Set<String> getInterfaces() {
|
||||||
final int interfacesOffset = dexBuf.readSmallUint(classDefOffset + INTERFACES_OFFSET);
|
final int interfacesOffset = dexFile.readSmallUint(classDefOffset + INTERFACES_OFFSET);
|
||||||
if (interfacesOffset > 0) {
|
if (interfacesOffset > 0) {
|
||||||
final int size = dexBuf.readSmallUint(interfacesOffset);
|
final int size = dexFile.readSmallUint(interfacesOffset);
|
||||||
return new FixedSizeSet<String>() {
|
return new FixedSizeSet<String>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String readItem(int index) {
|
public String readItem(int index) {
|
||||||
return dexBuf.getType(dexBuf.readUshort(interfacesOffset + 4 + (2*index)));
|
return dexFile.getType(dexFile.readUshort(interfacesOffset + 4 + (2*index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int size() { return size; }
|
@Override public int size() { return size; }
|
||||||
@ -122,7 +122,7 @@ public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
|||||||
public Set<? extends DexBackedField> getFields() {
|
public Set<? extends DexBackedField> getFields() {
|
||||||
int classDataOffset = getClassDataOffset();
|
int classDataOffset = getClassDataOffset();
|
||||||
if (getClassDataOffset() != 0) {
|
if (getClassDataOffset() != 0) {
|
||||||
DexReader reader = dexBuf.readerAt(classDataOffset);
|
DexReader reader = dexFile.readerAt(classDataOffset);
|
||||||
final int staticFieldCount = reader.readSmallUleb128();
|
final int staticFieldCount = reader.readSmallUleb128();
|
||||||
int instanceFieldCount = reader.readSmallUleb128();
|
int instanceFieldCount = reader.readSmallUleb128();
|
||||||
final int fieldCount = staticFieldCount + instanceFieldCount;
|
final int fieldCount = staticFieldCount + instanceFieldCount;
|
||||||
@ -132,19 +132,19 @@ public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
|||||||
|
|
||||||
final AnnotationsDirectory annotationsDirectory = getAnnotationsDirectory();
|
final AnnotationsDirectory annotationsDirectory = getAnnotationsDirectory();
|
||||||
final int staticInitialValuesOffset =
|
final int staticInitialValuesOffset =
|
||||||
dexBuf.readSmallUint(classDefOffset + STATIC_INITIAL_VALUES_OFFSET);
|
dexFile.readSmallUint(classDefOffset + STATIC_INITIAL_VALUES_OFFSET);
|
||||||
final int fieldsStartOffset = reader.getOffset();
|
final int fieldsStartOffset = reader.getOffset();
|
||||||
|
|
||||||
return new AbstractSet<DexBackedField>() {
|
return new AbstractSet<DexBackedField>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<DexBackedField> iterator() {
|
public Iterator<DexBackedField> iterator() {
|
||||||
return new VariableSizeIterator<DexBackedField>(dexBuf, fieldsStartOffset, fieldCount) {
|
return new VariableSizeIterator<DexBackedField>(dexFile, fieldsStartOffset, fieldCount) {
|
||||||
private int previousFieldIndex = 0;
|
private int previousFieldIndex = 0;
|
||||||
@Nonnull private final AnnotationsDirectory.AnnotationIterator annotationIterator =
|
@Nonnull private final AnnotationsDirectory.AnnotationIterator annotationIterator =
|
||||||
annotationsDirectory.getFieldAnnotationIterator();
|
annotationsDirectory.getFieldAnnotationIterator();
|
||||||
@Nonnull private final StaticInitialValueIterator staticInitialValueIterator =
|
@Nonnull private final StaticInitialValueIterator staticInitialValueIterator =
|
||||||
StaticInitialValueIterator.newOrEmpty(dexBuf, staticInitialValuesOffset);
|
StaticInitialValueIterator.newOrEmpty(dexFile, staticInitialValuesOffset);
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@ -175,7 +175,7 @@ public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
|||||||
public Set<? extends DexBackedMethod> getMethods() {
|
public Set<? extends DexBackedMethod> getMethods() {
|
||||||
int classDataOffset = getClassDataOffset();
|
int classDataOffset = getClassDataOffset();
|
||||||
if (classDataOffset > 0) {
|
if (classDataOffset > 0) {
|
||||||
DexReader reader = dexBuf.readerAt(classDataOffset);
|
DexReader reader = dexFile.readerAt(classDataOffset);
|
||||||
int staticFieldCount = reader.readSmallUleb128();
|
int staticFieldCount = reader.readSmallUleb128();
|
||||||
int instanceFieldCount = reader.readSmallUleb128();
|
int instanceFieldCount = reader.readSmallUleb128();
|
||||||
final int directMethodCount = reader.readSmallUleb128();
|
final int directMethodCount = reader.readSmallUleb128();
|
||||||
@ -191,7 +191,7 @@ public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<DexBackedMethod> iterator() {
|
public Iterator<DexBackedMethod> iterator() {
|
||||||
return new VariableSizeIterator<DexBackedMethod>(dexBuf, methodsStartOffset, methodCount) {
|
return new VariableSizeIterator<DexBackedMethod>(dexFile, methodsStartOffset, methodCount) {
|
||||||
private int previousMethodIndex = 0;
|
private int previousMethodIndex = 0;
|
||||||
@Nonnull private final AnnotationsDirectory.AnnotationIterator methodAnnotationIterator =
|
@Nonnull private final AnnotationsDirectory.AnnotationIterator methodAnnotationIterator =
|
||||||
annotationsDirectory.getMethodAnnotationIterator();
|
annotationsDirectory.getMethodAnnotationIterator();
|
||||||
@ -225,15 +225,15 @@ public class DexBackedClassDef extends BaseTypeReference implements ClassDef {
|
|||||||
|
|
||||||
private int getClassDataOffset() {
|
private int getClassDataOffset() {
|
||||||
if (classDataOffset == -1) {
|
if (classDataOffset == -1) {
|
||||||
classDataOffset = dexBuf.readSmallUint(classDefOffset + CLASS_DATA_OFFSET);
|
classDataOffset = dexFile.readSmallUint(classDefOffset + CLASS_DATA_OFFSET);
|
||||||
}
|
}
|
||||||
return classDataOffset;
|
return classDataOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnnotationsDirectory getAnnotationsDirectory() {
|
private AnnotationsDirectory getAnnotationsDirectory() {
|
||||||
if (annotationsDirectory == null) {
|
if (annotationsDirectory == null) {
|
||||||
int annotationsDirectoryOffset = dexBuf.readSmallUint(classDefOffset + ANNOTATIONS_OFFSET);
|
int annotationsDirectoryOffset = dexFile.readSmallUint(classDefOffset + ANNOTATIONS_OFFSET);
|
||||||
annotationsDirectory = AnnotationsDirectory.newOrEmpty(dexBuf, annotationsDirectoryOffset);
|
annotationsDirectory = AnnotationsDirectory.newOrEmpty(dexFile, annotationsDirectoryOffset);
|
||||||
}
|
}
|
||||||
return annotationsDirectory;
|
return annotationsDirectory;
|
||||||
}
|
}
|
||||||
|
@ -33,28 +33,119 @@ package org.jf.dexlib2.dexbacked;
|
|||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.util.FixedSizeSet;
|
import org.jf.dexlib2.dexbacked.util.FixedSizeSet;
|
||||||
import org.jf.dexlib2.iface.DexFile;
|
import org.jf.dexlib2.iface.DexFile;
|
||||||
|
import org.jf.util.ExceptionWithContext;
|
||||||
|
import org.jf.util.Utf8Utils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DexBackedDexFile implements DexFile {
|
public abstract class DexBackedDexFile extends BaseDexBuffer implements DexFile {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
public DexBackedDexFile(@Nonnull byte[] buf) {
|
||||||
|
super(buf);
|
||||||
|
}
|
||||||
|
|
||||||
public DexBackedDexFile(@Nonnull DexBuffer dexBuf) {
|
@Nonnull public abstract String getString(int stringIndex);
|
||||||
this.dexBuf = dexBuf;
|
@Nullable public abstract String getOptionalString(int stringIndex);
|
||||||
|
@Nonnull public abstract String getType(int typeIndex);
|
||||||
|
@Nullable public abstract String getOptionalType(int typeIndex);
|
||||||
|
|
||||||
|
// TODO: refactor how dex items are read
|
||||||
|
public abstract int getMethodIdItemOffset(int methodIndex);
|
||||||
|
public abstract int getProtoIdItemOffset(int protoIndex);
|
||||||
|
public abstract int getFieldIdItemOffset(int fieldIndex);
|
||||||
|
|
||||||
|
@Override @Nonnull public abstract DexReader readerAt(int offset);
|
||||||
|
|
||||||
|
public static class Impl extends DexBackedDexFile {
|
||||||
|
private final int stringCount;
|
||||||
|
private final int stringStartOffset;
|
||||||
|
private final int typeCount;
|
||||||
|
private final int typeStartOffset;
|
||||||
|
private final int protoCount;
|
||||||
|
private final int protoStartOffset;
|
||||||
|
private final int fieldCount;
|
||||||
|
private final int fieldStartOffset;
|
||||||
|
private final int methodCount;
|
||||||
|
private final int methodStartOffset;
|
||||||
|
private final int classCount;
|
||||||
|
private final int classStartOffset;
|
||||||
|
|
||||||
|
private static final byte[][] MAGIC_VALUES= new byte[][] {
|
||||||
|
new byte[]{0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x35, 0x00},
|
||||||
|
new byte[]{0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x36, 0x00}};
|
||||||
|
|
||||||
|
private static final int LITTLE_ENDIAN_TAG = 0x12345678;
|
||||||
|
private static final int BIG_ENDIAN_TAG = 0x78563412;
|
||||||
|
|
||||||
|
private static final int CHECKSUM_OFFSET = 8;
|
||||||
|
private static final int SIGNATURE_OFFSET = 12;
|
||||||
|
private static final int ENDIAN_TAG_OFFSET = 40;
|
||||||
|
private static final int MAP_OFFSET = 52;
|
||||||
|
private static final int STRING_COUNT_OFFSET = 56;
|
||||||
|
private static final int STRING_START_OFFSET = 60;
|
||||||
|
private static final int TYPE_COUNT_OFFSET = 64;
|
||||||
|
private static final int TYPE_START_OFFSET = 68;
|
||||||
|
private static final int PROTO_COUNT_OFFSET = 72;
|
||||||
|
private static final int PROTO_START_OFFSET = 76;
|
||||||
|
private static final int FIELD_COUNT_OFFSET = 80;
|
||||||
|
private static final int FIELD_START_OFFSET = 84;
|
||||||
|
private static final int METHOD_COUNT_OFFSET = 88;
|
||||||
|
private static final int METHOD_START_OFFSET = 92;
|
||||||
|
private static final int CLASS_COUNT_OFFSET = 96;
|
||||||
|
private static final int CLASS_START_OFFSET = 100;
|
||||||
|
|
||||||
|
private static final int SIGNATURE_SIZE = 20;
|
||||||
|
|
||||||
|
private static final int STRING_ID_ITEM_SIZE = 4;
|
||||||
|
private static final int TYPE_ID_ITEM_SIZE = 4;
|
||||||
|
private static final int PROTO_ID_ITEM_SIZE = 12;
|
||||||
|
private static final int FIELD_ID_ITEM_SIZE = 8;
|
||||||
|
private static final int METHOD_ID_ITEM_SIZE = 8;
|
||||||
|
private static final int CLASS_DEF_ITEM_SIZE = 32;
|
||||||
|
public static final int MAP_ITEM_SIZE = 12;
|
||||||
|
|
||||||
|
public static final int FIELD_CLASS_IDX_OFFSET = 0;
|
||||||
|
public static final int FIELD_TYPE_IDX_OFFSET = 2;
|
||||||
|
public static final int FIELD_NAME_IDX_OFFSET = 4;
|
||||||
|
|
||||||
|
public static final int METHOD_CLASS_IDX_OFFSET = 0;
|
||||||
|
public static final int METHOD_PROTO_IDX_OFFSET = 2;
|
||||||
|
public static final int METHOD_NAME_IDX_OFFSET = 4;
|
||||||
|
|
||||||
|
public static final int PROTO_RETURN_TYPE_IDX_OFFSET = 4;
|
||||||
|
public static final int PROTO_PARAM_LIST_OFF_OFFSET = 8;
|
||||||
|
|
||||||
|
public static final int TYPE_LIST_SIZE_OFFSET = 0;
|
||||||
|
public static final int TYPE_LIST_LIST_OFFSET = 4;
|
||||||
|
|
||||||
|
public Impl(@Nonnull byte[] buf) {
|
||||||
|
super(buf);
|
||||||
|
|
||||||
|
verifyMagic();
|
||||||
|
verifyEndian();
|
||||||
|
stringCount = readSmallUint(STRING_COUNT_OFFSET);
|
||||||
|
stringStartOffset = readSmallUint(STRING_START_OFFSET);
|
||||||
|
typeCount = readSmallUint(TYPE_COUNT_OFFSET);
|
||||||
|
typeStartOffset = readSmallUint(TYPE_START_OFFSET);
|
||||||
|
protoCount = readSmallUint(PROTO_COUNT_OFFSET);
|
||||||
|
protoStartOffset = readSmallUint(PROTO_START_OFFSET);
|
||||||
|
fieldCount = readSmallUint(FIELD_COUNT_OFFSET);
|
||||||
|
fieldStartOffset = readSmallUint(FIELD_START_OFFSET);
|
||||||
|
methodCount = readSmallUint(METHOD_COUNT_OFFSET);
|
||||||
|
methodStartOffset = readSmallUint(METHOD_START_OFFSET);
|
||||||
|
classCount = readSmallUint(CLASS_COUNT_OFFSET);
|
||||||
|
classStartOffset = readSmallUint(CLASS_START_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends DexBackedClassDef> getClasses() {
|
public Set<? extends DexBackedClassDef> getClasses() {
|
||||||
final int classCount = dexBuf.getClassCount();
|
|
||||||
|
|
||||||
return new FixedSizeSet<DexBackedClassDef>() {
|
return new FixedSizeSet<DexBackedClassDef>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public DexBackedClassDef readItem(int index) {
|
public DexBackedClassDef readItem(int index) {
|
||||||
int classOffset = dexBuf.getClassDefItemOffset(index);
|
return new DexBackedClassDef(Impl.this, getClassDefItemOffset(index));
|
||||||
return new DexBackedClassDef(dexBuf, classOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,4 +154,125 @@ public class DexBackedDexFile implements DexFile {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void verifyMagic() {
|
||||||
|
outer: for (byte[] magic: MAGIC_VALUES) {
|
||||||
|
for (int i=0; i<magic.length; i++) {
|
||||||
|
if (buf[i] != magic[i]) {
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder("Invalid magic value:");
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
sb.append(String.format(" %02x", buf[i]));
|
||||||
|
}
|
||||||
|
throw new ExceptionWithContext(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyEndian() {
|
||||||
|
int endian = readInt(ENDIAN_TAG_OFFSET);
|
||||||
|
if (endian == BIG_ENDIAN_TAG) {
|
||||||
|
throw new ExceptionWithContext("dexlib does not currently support big endian dex files.");
|
||||||
|
} else if (endian != LITTLE_ENDIAN_TAG) {
|
||||||
|
StringBuilder sb = new StringBuilder("Invalid endian tag:");
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
sb.append(String.format(" %02x", buf[ENDIAN_TAG_OFFSET+i]));
|
||||||
|
}
|
||||||
|
throw new ExceptionWithContext(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStringIdItemOffset(int stringIndex) {
|
||||||
|
if (stringIndex < 0 || stringIndex >= stringCount) {
|
||||||
|
throw new ExceptionWithContext("String index out of bounds: %d", stringIndex);
|
||||||
|
}
|
||||||
|
return stringStartOffset + stringIndex*STRING_ID_ITEM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTypeIdItemOffset(int typeIndex) {
|
||||||
|
if (typeIndex < 0 || typeIndex >= typeCount) {
|
||||||
|
throw new ExceptionWithContext("Type index out of bounds: %d", typeIndex);
|
||||||
|
}
|
||||||
|
return typeStartOffset + typeIndex*TYPE_ID_ITEM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFieldIdItemOffset(int fieldIndex) {
|
||||||
|
if (fieldIndex < 0 || fieldIndex >= fieldCount) {
|
||||||
|
throw new ExceptionWithContext("Field index out of bounds: %d", fieldIndex);
|
||||||
|
}
|
||||||
|
return fieldStartOffset + fieldIndex*FIELD_ID_ITEM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMethodIdItemOffset(int methodIndex) {
|
||||||
|
if (methodIndex < 0 || methodIndex >= methodCount) {
|
||||||
|
throw new ExceptionWithContext("Method index out of bounds: %d", methodIndex);
|
||||||
|
}
|
||||||
|
return methodStartOffset + methodIndex*METHOD_ID_ITEM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getProtoIdItemOffset(int protoIndex) {
|
||||||
|
if (protoIndex < 0 || protoIndex >= protoCount) {
|
||||||
|
throw new ExceptionWithContext("Proto index out of bounds: %d", protoIndex);
|
||||||
|
}
|
||||||
|
return protoStartOffset + protoIndex*PROTO_ID_ITEM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClassDefItemOffset(int classIndex) {
|
||||||
|
if (classIndex < 0 || classIndex >= classCount) {
|
||||||
|
throw new ExceptionWithContext("Class index out of bounds: %d", classIndex);
|
||||||
|
}
|
||||||
|
return classStartOffset + classIndex*CLASS_DEF_ITEM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClassCount() {
|
||||||
|
return classCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public String getString(int stringIndex) {
|
||||||
|
int stringOffset = getStringIdItemOffset(stringIndex);
|
||||||
|
int stringDataOffset = readSmallUint(stringOffset);
|
||||||
|
DexReader reader = readerAt(stringDataOffset);
|
||||||
|
int utf16Length = reader.readSmallUleb128();
|
||||||
|
return Utf8Utils.utf8BytesWithUtf16LengthToString(buf, reader.getOffset(), utf16Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public String getOptionalString(int stringIndex) {
|
||||||
|
if (stringIndex == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getString(stringIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public String getType(int typeIndex) {
|
||||||
|
int typeOffset = getTypeIdItemOffset(typeIndex);
|
||||||
|
int stringIndex = readSmallUint(typeOffset);
|
||||||
|
return getString(stringIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public String getOptionalType(int typeIndex) {
|
||||||
|
if (typeIndex == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getType(typeIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public DexReader readerAt(int offset) {
|
||||||
|
return new DexReader(this, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,17 +37,17 @@ import org.jf.dexlib2.iface.ExceptionHandler;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedExceptionHandler extends BaseExceptionHandler implements ExceptionHandler {
|
public class DexBackedExceptionHandler extends BaseExceptionHandler implements ExceptionHandler {
|
||||||
@Nonnull private final DexBuffer dexBuf;
|
@Nonnull private final DexBackedDexFile dexFile;
|
||||||
private final int typeId;
|
private final int typeId;
|
||||||
private final int handlerCodeAddress;
|
private final int handlerCodeAddress;
|
||||||
|
|
||||||
public DexBackedExceptionHandler(@Nonnull DexReader reader) {
|
public DexBackedExceptionHandler(@Nonnull DexReader reader) {
|
||||||
// TODO: verify dalvik doesn't accept an exception handler that points in the middle of an instruction
|
// TODO: verify dalvik doesn't accept an exception handler that points in the middle of an instruction
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.typeId = reader.readSmallUleb128();
|
this.typeId = reader.readSmallUleb128();
|
||||||
this.handlerCodeAddress = reader.readSmallUleb128();
|
this.handlerCodeAddress = reader.readSmallUleb128();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull @Override public String getExceptionType() { return dexBuf.getType(typeId); }
|
@Nonnull @Override public String getExceptionType() { return dexFile.getType(typeId); }
|
||||||
@Override public int getHandlerCodeAddress() { return handlerCodeAddress; }
|
@Override public int getHandlerCodeAddress() { return handlerCodeAddress; }
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DexBackedField extends BaseFieldReference implements Field {
|
public class DexBackedField extends BaseFieldReference implements Field {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
@Nonnull public final ClassDef classDef;
|
@Nonnull public final ClassDef classDef;
|
||||||
|
|
||||||
public final int accessFlags;
|
public final int accessFlags;
|
||||||
@ -63,7 +63,7 @@ public class DexBackedField extends BaseFieldReference implements Field {
|
|||||||
int previousFieldIndex,
|
int previousFieldIndex,
|
||||||
@Nonnull StaticInitialValueIterator staticInitialValueIterator,
|
@Nonnull StaticInitialValueIterator staticInitialValueIterator,
|
||||||
@Nonnull AnnotationsDirectory.AnnotationIterator annotationIterator) {
|
@Nonnull AnnotationsDirectory.AnnotationIterator annotationIterator) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.classDef = classDef;
|
this.classDef = classDef;
|
||||||
|
|
||||||
int fieldIndexDiff = reader.readSmallUleb128();
|
int fieldIndexDiff = reader.readSmallUleb128();
|
||||||
@ -77,13 +77,13 @@ public class DexBackedField extends BaseFieldReference implements Field {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return dexBuf.getString(dexBuf.readSmallUint(getFieldIdItemOffset() + NAME_OFFSET));
|
return dexFile.getString(dexFile.readSmallUint(getFieldIdItemOffset() + NAME_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return dexBuf.getType(dexBuf.readUshort(getFieldIdItemOffset() + TYPE_OFFSET));
|
return dexFile.getType(dexFile.readUshort(getFieldIdItemOffset() + TYPE_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull @Override public String getDefiningClass() { return classDef.getType(); }
|
@Nonnull @Override public String getDefiningClass() { return classDef.getType(); }
|
||||||
@ -93,7 +93,7 @@ public class DexBackedField extends BaseFieldReference implements Field {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends DexBackedAnnotation> getAnnotations() {
|
public Set<? extends DexBackedAnnotation> getAnnotations() {
|
||||||
return AnnotationsDirectory.getAnnotations(dexBuf, annotationSetOffset);
|
return AnnotationsDirectory.getAnnotations(dexFile, annotationSetOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +111,7 @@ public class DexBackedField extends BaseFieldReference implements Field {
|
|||||||
|
|
||||||
private int getFieldIdItemOffset() {
|
private int getFieldIdItemOffset() {
|
||||||
if (fieldIdItemOffset == 0) {
|
if (fieldIdItemOffset == 0) {
|
||||||
fieldIdItemOffset = dexBuf.getFieldIdItemOffset(fieldIndex);
|
fieldIdItemOffset = dexFile.getFieldIdItemOffset(fieldIndex);
|
||||||
}
|
}
|
||||||
return fieldIdItemOffset;
|
return fieldIdItemOffset;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DexBackedMethod extends BaseMethodReference implements Method {
|
public class DexBackedMethod extends BaseMethodReference implements Method {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
@Nonnull public final DexBackedClassDef classDef;
|
@Nonnull public final DexBackedClassDef classDef;
|
||||||
|
|
||||||
public final int accessFlags;
|
public final int accessFlags;
|
||||||
@ -75,7 +75,7 @@ public class DexBackedMethod extends BaseMethodReference implements Method {
|
|||||||
public DexBackedMethod(@Nonnull DexReader reader,
|
public DexBackedMethod(@Nonnull DexReader reader,
|
||||||
@Nonnull DexBackedClassDef classDef,
|
@Nonnull DexBackedClassDef classDef,
|
||||||
int previousMethodIndex) {
|
int previousMethodIndex) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.classDef = classDef;
|
this.classDef = classDef;
|
||||||
|
|
||||||
int methodIndexDiff = reader.readSmallUleb128();
|
int methodIndexDiff = reader.readSmallUleb128();
|
||||||
@ -92,7 +92,7 @@ public class DexBackedMethod extends BaseMethodReference implements Method {
|
|||||||
int previousMethodIndex,
|
int previousMethodIndex,
|
||||||
@Nonnull AnnotationsDirectory.AnnotationIterator methodAnnotationIterator,
|
@Nonnull AnnotationsDirectory.AnnotationIterator methodAnnotationIterator,
|
||||||
@Nonnull AnnotationsDirectory.AnnotationIterator paramaterAnnotationIterator) {
|
@Nonnull AnnotationsDirectory.AnnotationIterator paramaterAnnotationIterator) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.classDef = classDef;
|
this.classDef = classDef;
|
||||||
|
|
||||||
int methodIndexDiff = reader.readSmallUleb128();
|
int methodIndexDiff = reader.readSmallUleb128();
|
||||||
@ -111,13 +111,13 @@ public class DexBackedMethod extends BaseMethodReference implements Method {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return dexBuf.getString(dexBuf.readSmallUint(getMethodIdItemOffset() + NAME_OFFSET));
|
return dexFile.getString(dexFile.readSmallUint(getMethodIdItemOffset() + NAME_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getReturnType() {
|
public String getReturnType() {
|
||||||
return dexBuf.getType(dexBuf.readSmallUint(getProtoIdItemOffset() + RETURN_TYPE_OFFSET));
|
return dexFile.getType(dexFile.readSmallUint(getProtoIdItemOffset() + RETURN_TYPE_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -144,7 +144,7 @@ public class DexBackedMethod extends BaseMethodReference implements Method {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<? extends Set<? extends DexBackedAnnotation>> getParameterAnnotations() {
|
public List<? extends Set<? extends DexBackedAnnotation>> getParameterAnnotations() {
|
||||||
return AnnotationsDirectory.getParameterAnnotations(dexBuf, parameterAnnotationSetListOffset);
|
return AnnotationsDirectory.getParameterAnnotations(dexFile, parameterAnnotationSetListOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -161,13 +161,14 @@ public class DexBackedMethod extends BaseMethodReference implements Method {
|
|||||||
public List<String> getParameterTypes() {
|
public List<String> getParameterTypes() {
|
||||||
final int parametersOffset = getParametersOffset();
|
final int parametersOffset = getParametersOffset();
|
||||||
if (parametersOffset > 0) {
|
if (parametersOffset > 0) {
|
||||||
final int parameterCount = dexBuf.readSmallUint(parametersOffset + DexBuffer.TYPE_LIST_SIZE_OFFSET);
|
final int parameterCount = dexFile.readSmallUint(parametersOffset +
|
||||||
final int paramListStart = parametersOffset + DexBuffer.TYPE_LIST_LIST_OFFSET;
|
DexBackedDexFile.Impl.TYPE_LIST_SIZE_OFFSET);
|
||||||
|
final int paramListStart = parametersOffset + DexBackedDexFile.Impl.TYPE_LIST_LIST_OFFSET;
|
||||||
return new FixedSizeList<String>() {
|
return new FixedSizeList<String>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String readItem(final int index) {
|
public String readItem(final int index) {
|
||||||
return dexBuf.getType(dexBuf.readUshort(paramListStart + 2*index));
|
return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
|
||||||
}
|
}
|
||||||
@Override public int size() { return parameterCount; }
|
@Override public int size() { return parameterCount; }
|
||||||
};
|
};
|
||||||
@ -178,36 +179,36 @@ public class DexBackedMethod extends BaseMethodReference implements Method {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Annotation> getAnnotations() {
|
public Set<? extends Annotation> getAnnotations() {
|
||||||
return AnnotationsDirectory.getAnnotations(dexBuf, methodAnnotationSetOffset);
|
return AnnotationsDirectory.getAnnotations(dexFile, methodAnnotationSetOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public DexBackedMethodImplementation getImplementation() {
|
public DexBackedMethodImplementation getImplementation() {
|
||||||
if (codeOffset > 0) {
|
if (codeOffset > 0) {
|
||||||
return new DexBackedMethodImplementation(dexBuf, this, codeOffset);
|
return new DexBackedMethodImplementation(dexFile, this, codeOffset);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMethodIdItemOffset() {
|
private int getMethodIdItemOffset() {
|
||||||
if (methodIdItemOffset == 0) {
|
if (methodIdItemOffset == 0) {
|
||||||
methodIdItemOffset = dexBuf.getMethodIdItemOffset(methodIndex);
|
methodIdItemOffset = dexFile.getMethodIdItemOffset(methodIndex);
|
||||||
}
|
}
|
||||||
return methodIdItemOffset;
|
return methodIdItemOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getProtoIdItemOffset() {
|
private int getProtoIdItemOffset() {
|
||||||
if (protoIdItemOffset == 0) {
|
if (protoIdItemOffset == 0) {
|
||||||
int protoIndex = dexBuf.readUshort(getMethodIdItemOffset() + PROTO_OFFSET);
|
int protoIndex = dexFile.readUshort(getMethodIdItemOffset() + PROTO_OFFSET);
|
||||||
protoIdItemOffset = dexBuf.getProtoIdItemOffset(protoIndex);
|
protoIdItemOffset = dexFile.getProtoIdItemOffset(protoIndex);
|
||||||
}
|
}
|
||||||
return protoIdItemOffset;
|
return protoIdItemOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getParametersOffset() {
|
private int getParametersOffset() {
|
||||||
if (parametersOffset == -1) {
|
if (parametersOffset == -1) {
|
||||||
parametersOffset = dexBuf.readSmallUint(getProtoIdItemOffset() + PARAMETERS_OFFSET);
|
parametersOffset = dexFile.readSmallUint(getProtoIdItemOffset() + PARAMETERS_OFFSET);
|
||||||
}
|
}
|
||||||
return parametersOffset;
|
return parametersOffset;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedMethodImplementation implements MethodImplementation {
|
public class DexBackedMethodImplementation implements MethodImplementation {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
@Nonnull public final DexBackedMethod method;
|
@Nonnull public final DexBackedMethod method;
|
||||||
private final int codeOffset;
|
private final int codeOffset;
|
||||||
|
|
||||||
@ -60,26 +60,26 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
|
|
||||||
private static final int TRY_ITEM_SIZE = 8;
|
private static final int TRY_ITEM_SIZE = 8;
|
||||||
|
|
||||||
public DexBackedMethodImplementation(@Nonnull DexBuffer dexBuf,
|
public DexBackedMethodImplementation(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull DexBackedMethod method,
|
@Nonnull DexBackedMethod method,
|
||||||
int codeOffset) {
|
int codeOffset) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.codeOffset = codeOffset;
|
this.codeOffset = codeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterCount() { return dexBuf.readUshort(codeOffset); }
|
@Override public int getRegisterCount() { return dexFile.readUshort(codeOffset); }
|
||||||
|
|
||||||
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
|
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
|
||||||
// instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
|
// instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
|
||||||
int instructionsSize = dexBuf.readSmallUint(codeOffset + INSTRUCTIONS_SIZE_OFFSET);
|
int instructionsSize = dexFile.readSmallUint(codeOffset + INSTRUCTIONS_SIZE_OFFSET);
|
||||||
|
|
||||||
final int instructionsStartOffset = codeOffset + INSTRUCTIONS_START_OFFSET;
|
final int instructionsStartOffset = codeOffset + INSTRUCTIONS_START_OFFSET;
|
||||||
final int endOffset = instructionsStartOffset + (instructionsSize*2);
|
final int endOffset = instructionsStartOffset + (instructionsSize*2);
|
||||||
return new Iterable<Instruction>() {
|
return new Iterable<Instruction>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Instruction> iterator() {
|
public Iterator<Instruction> iterator() {
|
||||||
return new VariableSizeLookaheadIterator<Instruction>(dexBuf, instructionsStartOffset) {
|
return new VariableSizeLookaheadIterator<Instruction>(dexFile, instructionsStartOffset) {
|
||||||
@Override
|
@Override
|
||||||
protected Instruction readNextItem(@Nonnull DexReader reader) {
|
protected Instruction readNextItem(@Nonnull DexReader reader) {
|
||||||
if (reader.getOffset() >= endOffset) {
|
if (reader.getOffset() >= endOffset) {
|
||||||
@ -96,9 +96,9 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
@Override
|
@Override
|
||||||
public List<? extends TryBlock> getTryBlocks() {
|
public List<? extends TryBlock> getTryBlocks() {
|
||||||
// TODO: provide utility to put try blocks into a "canonical", easy to use format, which more closely matches java's try blocks
|
// TODO: provide utility to put try blocks into a "canonical", easy to use format, which more closely matches java's try blocks
|
||||||
final int triesSize = dexBuf.readUshort(codeOffset + TRIES_SIZE_OFFSET);
|
final int triesSize = dexFile.readUshort(codeOffset + TRIES_SIZE_OFFSET);
|
||||||
if (triesSize > 0) {
|
if (triesSize > 0) {
|
||||||
int instructionsSize = dexBuf.readSmallUint(codeOffset + INSTRUCTIONS_SIZE_OFFSET);
|
int instructionsSize = dexFile.readSmallUint(codeOffset + INSTRUCTIONS_SIZE_OFFSET);
|
||||||
final int triesStartOffset = AlignmentUtils.alignOffset(
|
final int triesStartOffset = AlignmentUtils.alignOffset(
|
||||||
codeOffset + INSTRUCTIONS_START_OFFSET + (instructionsSize*2), 4);
|
codeOffset + INSTRUCTIONS_START_OFFSET + (instructionsSize*2), 4);
|
||||||
final int handlersStartOffset = triesStartOffset + triesSize*TRY_ITEM_SIZE;
|
final int handlersStartOffset = triesStartOffset + triesSize*TRY_ITEM_SIZE;
|
||||||
@ -107,7 +107,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public TryBlock readItem(int index) {
|
public TryBlock readItem(int index) {
|
||||||
return new DexBackedTryBlock(dexBuf,
|
return new DexBackedTryBlock(dexFile,
|
||||||
triesStartOffset + index*TRY_ITEM_SIZE,
|
triesStartOffset + index*TRY_ITEM_SIZE,
|
||||||
handlersStartOffset);
|
handlersStartOffset);
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private DebugInfo getDebugInfo() {
|
private DebugInfo getDebugInfo() {
|
||||||
return DebugInfo.newOrEmpty(dexBuf, dexBuf.readSmallUint(codeOffset + DEBUG_OFFSET_OFFSET), this);
|
return DebugInfo.newOrEmpty(dexFile, dexFile.readSmallUint(codeOffset + DEBUG_OFFSET_OFFSET), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull @Override
|
@Nonnull @Override
|
||||||
|
@ -39,7 +39,7 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedTryBlock implements TryBlock {
|
public class DexBackedTryBlock implements TryBlock {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int tryItemOffset;
|
private final int tryItemOffset;
|
||||||
private final int handlersStartOffset;
|
private final int handlersStartOffset;
|
||||||
|
|
||||||
@ -47,27 +47,27 @@ public class DexBackedTryBlock implements TryBlock {
|
|||||||
private static final int CODE_UNIT_COUNT_OFFSET = 4;
|
private static final int CODE_UNIT_COUNT_OFFSET = 4;
|
||||||
private static final int HANDLER_OFFSET_OFFSET = 6;
|
private static final int HANDLER_OFFSET_OFFSET = 6;
|
||||||
|
|
||||||
public DexBackedTryBlock(@Nonnull DexBuffer dexBuf,
|
public DexBackedTryBlock(@Nonnull DexBackedDexFile dexFile,
|
||||||
int tryItemOffset,
|
int tryItemOffset,
|
||||||
int handlersStartOffset) {
|
int handlersStartOffset) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.tryItemOffset = tryItemOffset;
|
this.tryItemOffset = tryItemOffset;
|
||||||
this.handlersStartOffset = handlersStartOffset;
|
this.handlersStartOffset = handlersStartOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getStartCodeAddress() { return dexBuf.readSmallUint(tryItemOffset + START_ADDRESS_OFFSET); }
|
@Override public int getStartCodeAddress() { return dexFile.readSmallUint(tryItemOffset + START_ADDRESS_OFFSET); }
|
||||||
@Override public int getCodeUnitCount() { return dexBuf.readUshort(tryItemOffset + CODE_UNIT_COUNT_OFFSET); }
|
@Override public int getCodeUnitCount() { return dexFile.readUshort(tryItemOffset + CODE_UNIT_COUNT_OFFSET); }
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<? extends ExceptionHandler> getExceptionHandlers() {
|
public List<? extends ExceptionHandler> getExceptionHandlers() {
|
||||||
DexReader reader =
|
DexReader reader =
|
||||||
dexBuf.readerAt(handlersStartOffset + dexBuf.readUshort(tryItemOffset + HANDLER_OFFSET_OFFSET));
|
dexFile.readerAt(handlersStartOffset + dexFile.readUshort(tryItemOffset + HANDLER_OFFSET_OFFSET));
|
||||||
final int encodedSize = reader.readSleb128();
|
final int encodedSize = reader.readSleb128();
|
||||||
|
|
||||||
if (encodedSize > 0) {
|
if (encodedSize > 0) {
|
||||||
//no catch-all
|
//no catch-all
|
||||||
return new VariableSizeList<ExceptionHandler>(dexBuf, reader.getOffset(), encodedSize) {
|
return new VariableSizeList<ExceptionHandler>(dexFile, reader.getOffset(), encodedSize) {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected ExceptionHandler readNextItem(@Nonnull DexReader reader, int index) {
|
protected ExceptionHandler readNextItem(@Nonnull DexReader reader, int index) {
|
||||||
@ -77,7 +77,7 @@ public class DexBackedTryBlock implements TryBlock {
|
|||||||
} else {
|
} else {
|
||||||
//with catch-all
|
//with catch-all
|
||||||
final int sizeWithCatchAll = (-1 * encodedSize) + 1;
|
final int sizeWithCatchAll = (-1 * encodedSize) + 1;
|
||||||
return new VariableSizeList<ExceptionHandler>(dexBuf, reader.getOffset(), sizeWithCatchAll) {
|
return new VariableSizeList<ExceptionHandler>(dexFile, reader.getOffset(), sizeWithCatchAll) {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected ExceptionHandler readNextItem(@Nonnull DexReader dexReader, int index) {
|
protected ExceptionHandler readNextItem(@Nonnull DexReader dexReader, int index) {
|
||||||
|
@ -1,255 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013, Google Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Google Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jf.dexlib2.dexbacked;
|
|
||||||
|
|
||||||
import org.jf.util.ExceptionWithContext;
|
|
||||||
import org.jf.util.Utf8Utils;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class DexBuffer extends BaseDexBuffer {
|
|
||||||
public final int stringCount;
|
|
||||||
public final int stringStartOffset;
|
|
||||||
public final int typeCount;
|
|
||||||
public final int typeStartOffset;
|
|
||||||
public final int protoCount;
|
|
||||||
public final int protoStartOffset;
|
|
||||||
public final int fieldCount;
|
|
||||||
public final int fieldStartOffset;
|
|
||||||
public final int methodCount;
|
|
||||||
public final int methodStartOffset;
|
|
||||||
public final int classCount;
|
|
||||||
public final int classStartOffset;
|
|
||||||
|
|
||||||
@Nonnull private final String[] stringCache;
|
|
||||||
|
|
||||||
private static final byte[][] MAGIC_VALUES= new byte[][] {
|
|
||||||
new byte[]{0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x35, 0x00},
|
|
||||||
new byte[]{0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x36, 0x00}};
|
|
||||||
|
|
||||||
private static final int LITTLE_ENDIAN_TAG = 0x12345678;
|
|
||||||
private static final int BIG_ENDIAN_TAG = 0x78563412;
|
|
||||||
|
|
||||||
private static final int CHECKSUM_OFFSET = 8;
|
|
||||||
private static final int SIGNATURE_OFFSET = 12;
|
|
||||||
private static final int ENDIAN_TAG_OFFSET = 40;
|
|
||||||
private static final int MAP_OFFSET = 52;
|
|
||||||
private static final int STRING_COUNT_OFFSET = 56;
|
|
||||||
private static final int STRING_START_OFFSET = 60;
|
|
||||||
private static final int TYPE_COUNT_OFFSET = 64;
|
|
||||||
private static final int TYPE_START_OFFSET = 68;
|
|
||||||
private static final int PROTO_COUNT_OFFSET = 72;
|
|
||||||
private static final int PROTO_START_OFFSET = 76;
|
|
||||||
private static final int FIELD_COUNT_OFFSET = 80;
|
|
||||||
private static final int FIELD_START_OFFSET = 84;
|
|
||||||
private static final int METHOD_COUNT_OFFSET = 88;
|
|
||||||
private static final int METHOD_START_OFFSET = 92;
|
|
||||||
private static final int CLASS_COUNT_OFFSET = 96;
|
|
||||||
private static final int CLASS_START_OFFSET = 100;
|
|
||||||
|
|
||||||
private static final int SIGNATURE_SIZE = 20;
|
|
||||||
|
|
||||||
private static final int STRING_ID_ITEM_SIZE = 4;
|
|
||||||
private static final int TYPE_ID_ITEM_SIZE = 4;
|
|
||||||
private static final int PROTO_ID_ITEM_SIZE = 12;
|
|
||||||
private static final int FIELD_ID_ITEM_SIZE = 8;
|
|
||||||
private static final int METHOD_ID_ITEM_SIZE = 8;
|
|
||||||
private static final int CLASS_DEF_ITEM_SIZE = 32;
|
|
||||||
public static final int MAP_ITEM_SIZE = 12;
|
|
||||||
|
|
||||||
public static final int FIELD_CLASS_IDX_OFFSET = 0;
|
|
||||||
public static final int FIELD_TYPE_IDX_OFFSET = 2;
|
|
||||||
public static final int FIELD_NAME_IDX_OFFSET = 4;
|
|
||||||
|
|
||||||
public static final int METHOD_CLASS_IDX_OFFSET = 0;
|
|
||||||
public static final int METHOD_PROTO_IDX_OFFSET = 2;
|
|
||||||
public static final int METHOD_NAME_IDX_OFFSET = 4;
|
|
||||||
|
|
||||||
public static final int PROTO_RETURN_TYPE_IDX_OFFSET = 4;
|
|
||||||
public static final int PROTO_PARAM_LIST_OFF_OFFSET = 8;
|
|
||||||
|
|
||||||
public static final int TYPE_LIST_SIZE_OFFSET = 0;
|
|
||||||
public static final int TYPE_LIST_LIST_OFFSET = 4;
|
|
||||||
|
|
||||||
public DexBuffer(@Nonnull byte[] buf) {
|
|
||||||
super(buf);
|
|
||||||
|
|
||||||
verifyMagic();
|
|
||||||
verifyEndian();
|
|
||||||
stringCount = readSmallUint(STRING_COUNT_OFFSET);
|
|
||||||
stringStartOffset = readSmallUint(STRING_START_OFFSET);
|
|
||||||
typeCount = readSmallUint(TYPE_COUNT_OFFSET);
|
|
||||||
typeStartOffset = readSmallUint(TYPE_START_OFFSET);
|
|
||||||
protoCount = readSmallUint(PROTO_COUNT_OFFSET);
|
|
||||||
protoStartOffset = readSmallUint(PROTO_START_OFFSET);
|
|
||||||
fieldCount = readSmallUint(FIELD_COUNT_OFFSET);
|
|
||||||
fieldStartOffset = readSmallUint(FIELD_START_OFFSET);
|
|
||||||
methodCount = readSmallUint(METHOD_COUNT_OFFSET);
|
|
||||||
methodStartOffset = readSmallUint(METHOD_START_OFFSET);
|
|
||||||
classCount = readSmallUint(CLASS_COUNT_OFFSET);
|
|
||||||
classStartOffset = readSmallUint(CLASS_START_OFFSET);
|
|
||||||
|
|
||||||
stringCache = new String[stringCount];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyMagic() {
|
|
||||||
outer: for (byte[] magic: MAGIC_VALUES) {
|
|
||||||
for (int i=0; i<magic.length; i++) {
|
|
||||||
if (buf[i] != magic[i]) {
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder("Invalid magic value:");
|
|
||||||
for (int i=0; i<8; i++) {
|
|
||||||
sb.append(String.format(" %02x", buf[i]));
|
|
||||||
}
|
|
||||||
throw new ExceptionWithContext(sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyEndian() {
|
|
||||||
int endian = readInt(ENDIAN_TAG_OFFSET);
|
|
||||||
if (endian == BIG_ENDIAN_TAG) {
|
|
||||||
throw new ExceptionWithContext("dexlib does not currently support big endian dex files.");
|
|
||||||
} else if (endian != LITTLE_ENDIAN_TAG) {
|
|
||||||
StringBuilder sb = new StringBuilder("Invalid endian tag:");
|
|
||||||
for (int i=0; i<4; i++) {
|
|
||||||
sb.append(String.format(" %02x", buf[ENDIAN_TAG_OFFSET+i]));
|
|
||||||
}
|
|
||||||
throw new ExceptionWithContext(sb.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChecksum() {
|
|
||||||
return readInt(CHECKSUM_OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getSignature() {
|
|
||||||
return Arrays.copyOfRange(this.buf, SIGNATURE_OFFSET, SIGNATURE_OFFSET + SIGNATURE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMapOffset() {
|
|
||||||
return readSmallUint(MAP_OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStringIdItemOffset(int stringIndex) {
|
|
||||||
if (stringIndex < 0 || stringIndex >= stringCount) {
|
|
||||||
throw new ExceptionWithContext("String index out of bounds: %d", stringIndex);
|
|
||||||
}
|
|
||||||
return stringStartOffset + stringIndex*STRING_ID_ITEM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTypeIdItemOffset(int typeIndex) {
|
|
||||||
if (typeIndex < 0 || typeIndex >= typeCount) {
|
|
||||||
throw new ExceptionWithContext("Type index out of bounds: %d", typeIndex);
|
|
||||||
}
|
|
||||||
return typeStartOffset + typeIndex*TYPE_ID_ITEM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFieldIdItemOffset(int fieldIndex) {
|
|
||||||
if (fieldIndex < 0 || fieldIndex >= fieldCount) {
|
|
||||||
throw new ExceptionWithContext("Field index out of bounds: %d", fieldIndex);
|
|
||||||
}
|
|
||||||
return fieldStartOffset + fieldIndex*FIELD_ID_ITEM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMethodIdItemOffset(int methodIndex) {
|
|
||||||
if (methodIndex < 0 || methodIndex >= methodCount) {
|
|
||||||
throw new ExceptionWithContext("Method index out of bounds: %d", methodIndex);
|
|
||||||
}
|
|
||||||
return methodStartOffset + methodIndex*METHOD_ID_ITEM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProtoIdItemOffset(int protoIndex) {
|
|
||||||
if (protoIndex < 0 || protoIndex >= protoCount) {
|
|
||||||
throw new ExceptionWithContext("Proto index out of bounds: %d", protoIndex);
|
|
||||||
}
|
|
||||||
return protoStartOffset + protoIndex*PROTO_ID_ITEM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getClassDefItemOffset(int classIndex) {
|
|
||||||
if (classIndex < 0 || classIndex >= classCount) {
|
|
||||||
throw new ExceptionWithContext("Class index out of bounds: %d", classIndex);
|
|
||||||
}
|
|
||||||
return classStartOffset + classIndex*CLASS_DEF_ITEM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getClassCount() {
|
|
||||||
return classCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public String getString(int stringIndex) {
|
|
||||||
String ret = stringCache[stringIndex];
|
|
||||||
if (ret == null) {
|
|
||||||
int stringOffset = getStringIdItemOffset(stringIndex);
|
|
||||||
int stringDataOffset = readSmallUint(stringOffset);
|
|
||||||
DexReader reader = readerAt(stringDataOffset);
|
|
||||||
int utf16Length = reader.readSmallUleb128();
|
|
||||||
ret = Utf8Utils.utf8BytesWithUtf16LengthToString(buf, reader.getOffset(), utf16Length);
|
|
||||||
stringCache[stringIndex] = ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public String getOptionalType(int typeIndex) {
|
|
||||||
if (typeIndex == -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getType(typeIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public String getOptionalString(int stringIndex) {
|
|
||||||
if (stringIndex == -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getString(stringIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public String getType(int typeIndex) {
|
|
||||||
int typeOffset = getTypeIdItemOffset(typeIndex);
|
|
||||||
int stringIndex = readSmallUint(typeOffset);
|
|
||||||
return getString(stringIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
|
||||||
public DexReader readerAt(int offset) {
|
|
||||||
return new DexReader(this, offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -33,8 +33,8 @@ package org.jf.dexlib2.dexbacked;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexReader extends BaseDexReader<DexBuffer> {
|
public class DexReader extends BaseDexReader<DexBackedDexFile> {
|
||||||
public DexReader(@Nonnull DexBuffer dexBuf, int offset) {
|
public DexReader(@Nonnull DexBackedDexFile dexFile, int offset) {
|
||||||
super(dexBuf, offset);
|
super(dexFile, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.ArrayPayload;
|
import org.jf.dexlib2.iface.instruction.formats.ArrayPayload;
|
||||||
import org.jf.util.ExceptionWithContext;
|
import org.jf.util.ExceptionWithContext;
|
||||||
@ -50,12 +50,12 @@ public class DexBackedArrayPayload extends DexBackedInstruction implements Array
|
|||||||
private static final int ELEMENT_COUNT_OFFSET = 4;
|
private static final int ELEMENT_COUNT_OFFSET = 4;
|
||||||
private static final int ELEMENTS_OFFSET = 8;
|
private static final int ELEMENTS_OFFSET = 8;
|
||||||
|
|
||||||
public DexBackedArrayPayload(@Nonnull DexBuffer dexBuf,
|
public DexBackedArrayPayload(@Nonnull DexBackedDexFile dexFile,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, OPCODE, instructionStart);
|
super(dexFile, OPCODE, instructionStart);
|
||||||
|
|
||||||
elementWidth = dexBuf.readUshort(instructionStart + ELEMENT_WIDTH_OFFSET);
|
elementWidth = dexFile.readUshort(instructionStart + ELEMENT_WIDTH_OFFSET);
|
||||||
elementCount = dexBuf.readSmallUint(instructionStart + ELEMENT_COUNT_OFFSET);
|
elementCount = dexFile.readSmallUint(instructionStart + ELEMENT_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getElementWidth() { return elementWidth; }
|
@Override public int getElementWidth() { return elementWidth; }
|
||||||
@ -75,7 +75,7 @@ public class DexBackedArrayPayload extends DexBackedInstruction implements Array
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Number readItem(int index) {
|
public Number readItem(int index) {
|
||||||
return dexBuf.readByte(elementsStart + index);
|
return dexFile.readByte(elementsStart + index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
case 2:
|
case 2:
|
||||||
@ -83,7 +83,7 @@ public class DexBackedArrayPayload extends DexBackedInstruction implements Array
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Number readItem(int index) {
|
public Number readItem(int index) {
|
||||||
return dexBuf.readShort(elementsStart + index*2);
|
return dexFile.readShort(elementsStart + index*2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
case 4:
|
case 4:
|
||||||
@ -91,7 +91,7 @@ public class DexBackedArrayPayload extends DexBackedInstruction implements Array
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Number readItem(int index) {
|
public Number readItem(int index) {
|
||||||
return dexBuf.readInt(elementsStart + index*4);
|
return dexFile.readInt(elementsStart + index*4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
case 8:
|
case 8:
|
||||||
@ -99,7 +99,7 @@ public class DexBackedArrayPayload extends DexBackedInstruction implements Array
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Number readItem(int index) {
|
public Number readItem(int index) {
|
||||||
return dexBuf.readLong(elementsStart + index*8);
|
return dexFile.readLong(elementsStart + index*8);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||||
import org.jf.util.ExceptionWithContext;
|
import org.jf.util.ExceptionWithContext;
|
||||||
@ -40,14 +40,14 @@ import org.jf.util.ExceptionWithContext;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public abstract class DexBackedInstruction implements Instruction {
|
public abstract class DexBackedInstruction implements Instruction {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
@Nonnull public final Opcode opcode;
|
@Nonnull public final Opcode opcode;
|
||||||
public final int instructionStart;
|
public final int instructionStart;
|
||||||
|
|
||||||
public DexBackedInstruction(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.opcode = opcode;
|
this.opcode = opcode;
|
||||||
this.instructionStart = instructionStart;
|
this.instructionStart = instructionStart;
|
||||||
}
|
}
|
||||||
@ -71,65 +71,65 @@ public abstract class DexBackedInstruction implements Instruction {
|
|||||||
return instruction;
|
return instruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DexBackedInstruction buildInstruction(@Nonnull DexBuffer dexBuf, Opcode opcode,
|
private static DexBackedInstruction buildInstruction(@Nonnull DexBackedDexFile dexFile, Opcode opcode,
|
||||||
int instructionStartOffset) {
|
int instructionStartOffset) {
|
||||||
switch (opcode.format) {
|
switch (opcode.format) {
|
||||||
case Format10t:
|
case Format10t:
|
||||||
return new DexBackedInstruction10t(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction10t(dexFile, opcode, instructionStartOffset);
|
||||||
case Format10x:
|
case Format10x:
|
||||||
return new DexBackedInstruction10x(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction10x(dexFile, opcode, instructionStartOffset);
|
||||||
case Format11n:
|
case Format11n:
|
||||||
return new DexBackedInstruction11n(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction11n(dexFile, opcode, instructionStartOffset);
|
||||||
case Format11x:
|
case Format11x:
|
||||||
return new DexBackedInstruction11x(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction11x(dexFile, opcode, instructionStartOffset);
|
||||||
case Format12x:
|
case Format12x:
|
||||||
return new DexBackedInstruction12x(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction12x(dexFile, opcode, instructionStartOffset);
|
||||||
case Format20t:
|
case Format20t:
|
||||||
return new DexBackedInstruction20t(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction20t(dexFile, opcode, instructionStartOffset);
|
||||||
case Format21c:
|
case Format21c:
|
||||||
return new DexBackedInstruction21c(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction21c(dexFile, opcode, instructionStartOffset);
|
||||||
case Format21ih:
|
case Format21ih:
|
||||||
return new DexBackedInstruction21ih(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction21ih(dexFile, opcode, instructionStartOffset);
|
||||||
case Format21lh:
|
case Format21lh:
|
||||||
return new DexBackedInstruction21lh(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction21lh(dexFile, opcode, instructionStartOffset);
|
||||||
case Format21s:
|
case Format21s:
|
||||||
return new DexBackedInstruction21s(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction21s(dexFile, opcode, instructionStartOffset);
|
||||||
case Format21t:
|
case Format21t:
|
||||||
return new DexBackedInstruction21t(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction21t(dexFile, opcode, instructionStartOffset);
|
||||||
case Format22b:
|
case Format22b:
|
||||||
return new DexBackedInstruction22b(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction22b(dexFile, opcode, instructionStartOffset);
|
||||||
case Format22c:
|
case Format22c:
|
||||||
return new DexBackedInstruction22c(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction22c(dexFile, opcode, instructionStartOffset);
|
||||||
case Format22s:
|
case Format22s:
|
||||||
return new DexBackedInstruction22s(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction22s(dexFile, opcode, instructionStartOffset);
|
||||||
case Format22t:
|
case Format22t:
|
||||||
return new DexBackedInstruction22t(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction22t(dexFile, opcode, instructionStartOffset);
|
||||||
case Format22x:
|
case Format22x:
|
||||||
return new DexBackedInstruction22x(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction22x(dexFile, opcode, instructionStartOffset);
|
||||||
case Format23x:
|
case Format23x:
|
||||||
return new DexBackedInstruction23x(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction23x(dexFile, opcode, instructionStartOffset);
|
||||||
case Format30t:
|
case Format30t:
|
||||||
return new DexBackedInstruction30t(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction30t(dexFile, opcode, instructionStartOffset);
|
||||||
case Format31c:
|
case Format31c:
|
||||||
return new DexBackedInstruction31c(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction31c(dexFile, opcode, instructionStartOffset);
|
||||||
case Format31i:
|
case Format31i:
|
||||||
return new DexBackedInstruction31i(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction31i(dexFile, opcode, instructionStartOffset);
|
||||||
case Format31t:
|
case Format31t:
|
||||||
return new DexBackedInstruction31t(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction31t(dexFile, opcode, instructionStartOffset);
|
||||||
case Format32x:
|
case Format32x:
|
||||||
return new DexBackedInstruction32x(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction32x(dexFile, opcode, instructionStartOffset);
|
||||||
case Format35c:
|
case Format35c:
|
||||||
return new DexBackedInstruction35c(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction35c(dexFile, opcode, instructionStartOffset);
|
||||||
case Format3rc:
|
case Format3rc:
|
||||||
return new DexBackedInstruction3rc(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction3rc(dexFile, opcode, instructionStartOffset);
|
||||||
case Format51l:
|
case Format51l:
|
||||||
return new DexBackedInstruction51l(dexBuf, opcode, instructionStartOffset);
|
return new DexBackedInstruction51l(dexFile, opcode, instructionStartOffset);
|
||||||
case PackedSwitchPayload:
|
case PackedSwitchPayload:
|
||||||
return new DexBackedPackedSwitchPayload(dexBuf, instructionStartOffset);
|
return new DexBackedPackedSwitchPayload(dexFile, instructionStartOffset);
|
||||||
case SparseSwitchPayload:
|
case SparseSwitchPayload:
|
||||||
return new DexBackedSparseSwitchPayload(dexBuf, instructionStartOffset);
|
return new DexBackedSparseSwitchPayload(dexFile, instructionStartOffset);
|
||||||
case ArrayPayload:
|
case ArrayPayload:
|
||||||
return new DexBackedArrayPayload(dexBuf, instructionStartOffset);
|
return new DexBackedArrayPayload(dexFile, instructionStartOffset);
|
||||||
//TODO: temporary, until we get all instructions implemented
|
//TODO: temporary, until we get all instructions implemented
|
||||||
default:
|
default:
|
||||||
throw new ExceptionWithContext("Unexpected opcode format: %s", opcode.format.toString());
|
throw new ExceptionWithContext("Unexpected opcode format: %s", opcode.format.toString());
|
||||||
|
@ -32,17 +32,17 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction10t;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction10t;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction10t extends DexBackedInstruction implements Instruction10t {
|
public class DexBackedInstruction10t extends DexBackedInstruction implements Instruction10t {
|
||||||
public DexBackedInstruction10t(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction10t(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getCodeOffset() { return dexBuf.readByte(instructionStart + 1); }
|
@Override public int getCodeOffset() { return dexFile.readByte(instructionStart + 1); }
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,15 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction10x;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction10x;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction10x extends DexBackedInstruction implements Instruction10x {
|
public class DexBackedInstruction10x extends DexBackedInstruction implements Instruction10x {
|
||||||
public DexBackedInstruction10x(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction10x(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,27 +32,27 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11n;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction11n;
|
||||||
import org.jf.util.NibbleUtils;
|
import org.jf.util.NibbleUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction11n extends DexBackedInstruction implements Instruction11n {
|
public class DexBackedInstruction11n extends DexBackedInstruction implements Instruction11n {
|
||||||
public DexBackedInstruction11n(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction11n(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterA() {
|
public int getRegisterA() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNarrowLiteral() {
|
public int getNarrowLiteral() {
|
||||||
return NibbleUtils.extractHighSignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractHighSignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
||||||
|
@ -32,17 +32,17 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction11x;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction11x extends DexBackedInstruction implements Instruction11x {
|
public class DexBackedInstruction11x extends DexBackedInstruction implements Instruction11x {
|
||||||
public DexBackedInstruction11x(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction11x(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
}
|
}
|
||||||
|
@ -32,26 +32,26 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction12x;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction12x;
|
||||||
import org.jf.util.NibbleUtils;
|
import org.jf.util.NibbleUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction12x extends DexBackedInstruction implements Instruction12x {
|
public class DexBackedInstruction12x extends DexBackedInstruction implements Instruction12x {
|
||||||
public DexBackedInstruction12x(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction12x(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterA() {
|
public int getRegisterA() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterB() {
|
public int getRegisterB() {
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,17 +32,17 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction20t;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction20t;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction20t extends DexBackedInstruction implements Instruction20t {
|
public class DexBackedInstruction20t extends DexBackedInstruction implements Instruction20t {
|
||||||
public DexBackedInstruction20t(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction20t(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getCodeOffset() { return dexBuf.readShort(instructionStart + 2); }
|
@Override public int getCodeOffset() { return dexFile.readShort(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21c;
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
@ -40,17 +40,17 @@ import org.jf.dexlib2.iface.reference.Reference;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction21c extends DexBackedInstruction implements Instruction21c {
|
public class DexBackedInstruction21c extends DexBackedInstruction implements Instruction21c {
|
||||||
public DexBackedInstruction21c(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction21c(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Reference getReference() {
|
public Reference getReference() {
|
||||||
return DexBackedReference.makeReference(dexBuf, opcode.referenceType, dexBuf.readUshort(instructionStart + 2));
|
return DexBackedReference.makeReference(dexFile, opcode.referenceType, dexFile.readUshort(instructionStart + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,20 +32,20 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21ih;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21ih;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction21ih extends DexBackedInstruction implements Instruction21ih {
|
public class DexBackedInstruction21ih extends DexBackedInstruction implements Instruction21ih {
|
||||||
public DexBackedInstruction21ih(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction21ih(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getNarrowLiteral() { return getHatLiteral() << 16; }
|
@Override public int getNarrowLiteral() { return getHatLiteral() << 16; }
|
||||||
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
||||||
@Override public short getHatLiteral() { return (short)dexBuf.readShort(instructionStart + 2); }
|
@Override public short getHatLiteral() { return (short)dexFile.readShort(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,19 +32,19 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21lh;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21lh;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction21lh extends DexBackedInstruction implements Instruction21lh {
|
public class DexBackedInstruction21lh extends DexBackedInstruction implements Instruction21lh {
|
||||||
public DexBackedInstruction21lh(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction21lh(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public long getWideLiteral() { return ((long)getHatLiteral()) << 48; }
|
@Override public long getWideLiteral() { return ((long)getHatLiteral()) << 48; }
|
||||||
@Override public short getHatLiteral() { return (short)dexBuf.readShort(instructionStart + 2); }
|
@Override public short getHatLiteral() { return (short)dexFile.readShort(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,19 +32,19 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21s;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21s;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction21s extends DexBackedInstruction implements Instruction21s {
|
public class DexBackedInstruction21s extends DexBackedInstruction implements Instruction21s {
|
||||||
public DexBackedInstruction21s(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction21s(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getNarrowLiteral() { return dexBuf.readShort(instructionStart + 2); }
|
@Override public int getNarrowLiteral() { return dexFile.readShort(instructionStart + 2); }
|
||||||
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21t;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21t;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction21t extends DexBackedInstruction implements Instruction21t {
|
public class DexBackedInstruction21t extends DexBackedInstruction implements Instruction21t {
|
||||||
public DexBackedInstruction21t(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction21t(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getCodeOffset() { return dexBuf.readShort(instructionStart + 2); }
|
@Override public int getCodeOffset() { return dexFile.readShort(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,20 +32,20 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22b;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22b;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction22b extends DexBackedInstruction implements Instruction22b {
|
public class DexBackedInstruction22b extends DexBackedInstruction implements Instruction22b {
|
||||||
public DexBackedInstruction22b(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction22b(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getRegisterB() { return dexBuf.readUbyte(instructionStart + 2); }
|
@Override public int getRegisterB() { return dexFile.readUbyte(instructionStart + 2); }
|
||||||
@Override public int getNarrowLiteral() { return dexBuf.readByte(instructionStart + 3); }
|
@Override public int getNarrowLiteral() { return dexFile.readByte(instructionStart + 3); }
|
||||||
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22c;
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
@ -41,25 +41,25 @@ import org.jf.util.NibbleUtils;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction22c extends DexBackedInstruction implements Instruction22c {
|
public class DexBackedInstruction22c extends DexBackedInstruction implements Instruction22c {
|
||||||
public DexBackedInstruction22c(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction22c(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterA() {
|
public int getRegisterA() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterB() {
|
public int getRegisterB() {
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Reference getReference() {
|
public Reference getReference() {
|
||||||
return DexBackedReference.makeReference(dexBuf, opcode.referenceType, dexBuf.readUshort(instructionStart + 2));
|
return DexBackedReference.makeReference(dexFile, opcode.referenceType, dexFile.readUshort(instructionStart + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,29 +32,29 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22s;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22s;
|
||||||
import org.jf.util.NibbleUtils;
|
import org.jf.util.NibbleUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction22s extends DexBackedInstruction implements Instruction22s {
|
public class DexBackedInstruction22s extends DexBackedInstruction implements Instruction22s {
|
||||||
public DexBackedInstruction22s(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction22s(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterA() {
|
public int getRegisterA() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterB() {
|
public int getRegisterB() {
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getNarrowLiteral() { return dexBuf.readShort(instructionStart + 2); }
|
@Override public int getNarrowLiteral() { return dexFile.readShort(instructionStart + 2); }
|
||||||
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
||||||
}
|
}
|
||||||
|
@ -32,28 +32,28 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22t;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22t;
|
||||||
import org.jf.util.NibbleUtils;
|
import org.jf.util.NibbleUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction22t extends DexBackedInstruction implements Instruction22t {
|
public class DexBackedInstruction22t extends DexBackedInstruction implements Instruction22t {
|
||||||
public DexBackedInstruction22t(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction22t(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterA() {
|
public int getRegisterA() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterB() {
|
public int getRegisterB() {
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readByte(instructionStart + 1));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readByte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getCodeOffset() { return dexBuf.readShort(instructionStart + 2); }
|
@Override public int getCodeOffset() { return dexFile.readShort(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22x;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22x;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction22x extends DexBackedInstruction implements Instruction22x {
|
public class DexBackedInstruction22x extends DexBackedInstruction implements Instruction22x {
|
||||||
public DexBackedInstruction22x(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction22x(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getRegisterB() { return dexBuf.readUshort(instructionStart + 2); }
|
@Override public int getRegisterB() { return dexFile.readUshort(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,19 +32,19 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction23x;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction23x;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction23x extends DexBackedInstruction implements Instruction23x {
|
public class DexBackedInstruction23x extends DexBackedInstruction implements Instruction23x {
|
||||||
public DexBackedInstruction23x(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction23x(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getRegisterB() { return dexBuf.readUbyte(instructionStart + 2); }
|
@Override public int getRegisterB() { return dexFile.readUbyte(instructionStart + 2); }
|
||||||
@Override public int getRegisterC() { return dexBuf.readUbyte(instructionStart + 3); }
|
@Override public int getRegisterC() { return dexFile.readUbyte(instructionStart + 3); }
|
||||||
}
|
}
|
||||||
|
@ -32,17 +32,17 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction30t;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction30t;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction30t extends DexBackedInstruction implements Instruction30t {
|
public class DexBackedInstruction30t extends DexBackedInstruction implements Instruction30t {
|
||||||
public DexBackedInstruction30t(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction30t(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getCodeOffset() { return dexBuf.readInt(instructionStart + 2); }
|
@Override public int getCodeOffset() { return dexFile.readInt(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31c;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31c;
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
@ -40,18 +40,18 @@ import org.jf.dexlib2.iface.reference.Reference;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction31c extends DexBackedInstruction implements Instruction31c {
|
public class DexBackedInstruction31c extends DexBackedInstruction implements Instruction31c {
|
||||||
public DexBackedInstruction31c(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction31c(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Reference getReference() {
|
public Reference getReference() {
|
||||||
return DexBackedReference.makeReference(dexBuf, opcode.referenceType,
|
return DexBackedReference.makeReference(dexFile, opcode.referenceType,
|
||||||
dexBuf.readSmallUint(instructionStart + 2));
|
dexFile.readSmallUint(instructionStart + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,19 +32,19 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31i;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction31i extends DexBackedInstruction implements Instruction31i {
|
public class DexBackedInstruction31i extends DexBackedInstruction implements Instruction31i {
|
||||||
public DexBackedInstruction31i(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction31i(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getNarrowLiteral() { return dexBuf.readInt(instructionStart + 2); }
|
@Override public int getNarrowLiteral() { return dexFile.readInt(instructionStart + 2); }
|
||||||
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
@Override public long getWideLiteral() { return getNarrowLiteral(); }
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31t;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31t;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction31t extends DexBackedInstruction implements Instruction31t {
|
public class DexBackedInstruction31t extends DexBackedInstruction implements Instruction31t {
|
||||||
public DexBackedInstruction31t(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction31t(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public int getCodeOffset() { return dexBuf.readInt(instructionStart + 2); }
|
@Override public int getCodeOffset() { return dexFile.readInt(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction32x;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction32x;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction32x extends DexBackedInstruction implements Instruction32x {
|
public class DexBackedInstruction32x extends DexBackedInstruction implements Instruction32x {
|
||||||
public DexBackedInstruction32x(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction32x(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUshort(instructionStart + 2); }
|
@Override public int getRegisterA() { return dexFile.readUshort(instructionStart + 2); }
|
||||||
@Override public int getRegisterB() { return dexBuf.readUshort(instructionStart + 4); }
|
@Override public int getRegisterB() { return dexFile.readUshort(instructionStart + 4); }
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c;
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
@ -41,46 +41,46 @@ import org.jf.util.NibbleUtils;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction35c extends DexBackedInstruction implements Instruction35c {
|
public class DexBackedInstruction35c extends DexBackedInstruction implements Instruction35c {
|
||||||
public DexBackedInstruction35c(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction35c(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterCount() {
|
@Override public int getRegisterCount() {
|
||||||
//TODO: make sure dalvik verifies that this is in the correct range
|
//TODO: make sure dalvik verifies that this is in the correct range
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readUbyte(instructionStart + 1));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readUbyte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterC() {
|
public int getRegisterC() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readUbyte(instructionStart + 4));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readUbyte(instructionStart + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterD() {
|
public int getRegisterD() {
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readUbyte(instructionStart + 4));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readUbyte(instructionStart + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterE() {
|
public int getRegisterE() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readUbyte(instructionStart + 5));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readUbyte(instructionStart + 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterF() {
|
public int getRegisterF() {
|
||||||
return NibbleUtils.extractHighUnsignedNibble(dexBuf.readUbyte(instructionStart + 5));
|
return NibbleUtils.extractHighUnsignedNibble(dexFile.readUbyte(instructionStart + 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRegisterG() {
|
public int getRegisterG() {
|
||||||
return NibbleUtils.extractLowUnsignedNibble(dexBuf.readUbyte(instructionStart + 1));
|
return NibbleUtils.extractLowUnsignedNibble(dexFile.readUbyte(instructionStart + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Reference getReference() {
|
public Reference getReference() {
|
||||||
return DexBackedReference.makeReference(dexBuf, opcode.referenceType,
|
return DexBackedReference.makeReference(dexFile, opcode.referenceType,
|
||||||
dexBuf.readUshort(instructionStart + 2));
|
dexFile.readUshort(instructionStart + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction3rc;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rc;
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
@ -40,25 +40,25 @@ import org.jf.dexlib2.iface.reference.Reference;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction3rc extends DexBackedInstruction implements Instruction3rc {
|
public class DexBackedInstruction3rc extends DexBackedInstruction implements Instruction3rc {
|
||||||
public DexBackedInstruction3rc(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction3rc(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterCount() {
|
@Override public int getRegisterCount() {
|
||||||
return dexBuf.readUbyte(instructionStart + 1);
|
return dexFile.readUbyte(instructionStart + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStartRegister() {
|
public int getStartRegister() {
|
||||||
return dexBuf.readUshort(instructionStart + 4);
|
return dexFile.readUshort(instructionStart + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Reference getReference() {
|
public Reference getReference() {
|
||||||
return DexBackedReference.makeReference(dexBuf, opcode.referenceType,
|
return DexBackedReference.makeReference(dexFile, opcode.referenceType,
|
||||||
dexBuf.readUshort(instructionStart + 2));
|
dexFile.readUshort(instructionStart + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction51l;
|
import org.jf.dexlib2.iface.instruction.formats.Instruction51l;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedInstruction51l extends DexBackedInstruction implements Instruction51l {
|
public class DexBackedInstruction51l extends DexBackedInstruction implements Instruction51l {
|
||||||
public DexBackedInstruction51l(@Nonnull DexBuffer dexBuf,
|
public DexBackedInstruction51l(@Nonnull DexBackedDexFile dexFile,
|
||||||
@Nonnull Opcode opcode,
|
@Nonnull Opcode opcode,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, opcode, instructionStart);
|
super(dexFile, opcode, instructionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getRegisterA() { return dexBuf.readUbyte(instructionStart + 1); }
|
@Override public int getRegisterA() { return dexFile.readUbyte(instructionStart + 1); }
|
||||||
@Override public long getWideLiteral() { return dexBuf.readLong(instructionStart + 2); }
|
@Override public long getWideLiteral() { return dexFile.readLong(instructionStart + 2); }
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
||||||
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload;
|
import org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload;
|
||||||
@ -47,17 +47,17 @@ public class DexBackedPackedSwitchPayload extends DexBackedInstruction implement
|
|||||||
private static final int FIRST_KEY_OFFSET = 4;
|
private static final int FIRST_KEY_OFFSET = 4;
|
||||||
private static final int TARGETS_OFFSET = 8;
|
private static final int TARGETS_OFFSET = 8;
|
||||||
|
|
||||||
public DexBackedPackedSwitchPayload(@Nonnull DexBuffer dexBuf,
|
public DexBackedPackedSwitchPayload(@Nonnull DexBackedDexFile dexFile,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, Opcode.PACKED_SWITCH_PAYLOAD, instructionStart);
|
super(dexFile, Opcode.PACKED_SWITCH_PAYLOAD, instructionStart);
|
||||||
|
|
||||||
elementCount = dexBuf.readUshort(instructionStart + ELEMENT_COUNT_OFFSET);
|
elementCount = dexFile.readUshort(instructionStart + ELEMENT_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<? extends SwitchElement> getSwitchElements() {
|
public List<? extends SwitchElement> getSwitchElements() {
|
||||||
final int firstKey = dexBuf.readInt(instructionStart + FIRST_KEY_OFFSET);
|
final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
|
||||||
return new FixedSizeList<SwitchElement>() {
|
return new FixedSizeList<SwitchElement>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +70,7 @@ public class DexBackedPackedSwitchPayload extends DexBackedInstruction implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
return dexBuf.readInt(instructionStart + TARGETS_OFFSET + index*4);
|
return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.instruction;
|
package org.jf.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcode;
|
import org.jf.dexlib2.Opcode;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
||||||
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
import org.jf.dexlib2.iface.instruction.SwitchElement;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload;
|
import org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload;
|
||||||
@ -46,11 +46,11 @@ public class DexBackedSparseSwitchPayload extends DexBackedInstruction implement
|
|||||||
private static final int ELEMENT_COUNT_OFFSET = 2;
|
private static final int ELEMENT_COUNT_OFFSET = 2;
|
||||||
private static final int KEYS_OFFSET = 4;
|
private static final int KEYS_OFFSET = 4;
|
||||||
|
|
||||||
public DexBackedSparseSwitchPayload(@Nonnull DexBuffer dexBuf,
|
public DexBackedSparseSwitchPayload(@Nonnull DexBackedDexFile dexFile,
|
||||||
int instructionStart) {
|
int instructionStart) {
|
||||||
super(dexBuf, Opcode.SPARSE_SWITCH_PAYLOAD, instructionStart);
|
super(dexFile, Opcode.SPARSE_SWITCH_PAYLOAD, instructionStart);
|
||||||
|
|
||||||
elementCount = dexBuf.readUshort(instructionStart + ELEMENT_COUNT_OFFSET);
|
elementCount = dexFile.readUshort(instructionStart + ELEMENT_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -63,12 +63,12 @@ public class DexBackedSparseSwitchPayload extends DexBackedInstruction implement
|
|||||||
return new SwitchElement() {
|
return new SwitchElement() {
|
||||||
@Override
|
@Override
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
return dexBuf.readInt(instructionStart + KEYS_OFFSET + index*4);
|
return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
return dexBuf.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
|
return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -32,34 +32,34 @@
|
|||||||
package org.jf.dexlib2.dexbacked.reference;
|
package org.jf.dexlib2.dexbacked.reference;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.reference.BaseFieldReference;
|
import org.jf.dexlib2.base.reference.BaseFieldReference;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedFieldReference extends BaseFieldReference {
|
public class DexBackedFieldReference extends BaseFieldReference {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
public final int fieldIdItemOffset;
|
public final int fieldIdItemOffset;
|
||||||
|
|
||||||
public DexBackedFieldReference(@Nonnull DexBuffer dexBuf, int fieldIndex) {
|
public DexBackedFieldReference(@Nonnull DexBackedDexFile dexFile, int fieldIndex) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.fieldIdItemOffset = dexBuf.getFieldIdItemOffset(fieldIndex);
|
this.fieldIdItemOffset = dexFile.getFieldIdItemOffset(fieldIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getDefiningClass() {
|
public String getDefiningClass() {
|
||||||
return dexBuf.getType(dexBuf.readUshort(fieldIdItemOffset + DexBuffer.FIELD_CLASS_IDX_OFFSET));
|
return dexFile.getType(dexFile.readUshort(fieldIdItemOffset + DexBackedDexFile.Impl.FIELD_CLASS_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return dexBuf.getString(dexBuf.readSmallUint(fieldIdItemOffset + DexBuffer.FIELD_NAME_IDX_OFFSET));
|
return dexFile.getString(dexFile.readSmallUint(fieldIdItemOffset + DexBackedDexFile.Impl.FIELD_NAME_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return dexBuf.getType(dexBuf.readUshort(fieldIdItemOffset + DexBuffer.FIELD_TYPE_IDX_OFFSET));
|
return dexFile.getType(dexFile.readUshort(fieldIdItemOffset + DexBackedDexFile.Impl.FIELD_TYPE_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,47 +33,50 @@ package org.jf.dexlib2.dexbacked.reference;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.jf.dexlib2.base.reference.BaseMethodReference;
|
import org.jf.dexlib2.base.reference.BaseMethodReference;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedMethodReference extends BaseMethodReference {
|
public class DexBackedMethodReference extends BaseMethodReference {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
public final int methodIdItemOffset;
|
public final int methodIdItemOffset;
|
||||||
private int protoIdItemOffset;
|
private int protoIdItemOffset;
|
||||||
|
|
||||||
public DexBackedMethodReference(@Nonnull DexBuffer dexBuf, int methodIndex) {
|
public DexBackedMethodReference(@Nonnull DexBackedDexFile dexFile, int methodIndex) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.methodIdItemOffset = dexBuf.getMethodIdItemOffset(methodIndex);
|
this.methodIdItemOffset = dexFile.getMethodIdItemOffset(methodIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getDefiningClass() {
|
public String getDefiningClass() {
|
||||||
return dexBuf.getType(dexBuf.readUshort(methodIdItemOffset + DexBuffer.METHOD_CLASS_IDX_OFFSET));
|
return dexFile.getType(dexFile.readUshort(methodIdItemOffset + DexBackedDexFile.Impl.METHOD_CLASS_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return dexBuf.getString(dexBuf.readSmallUint(methodIdItemOffset + DexBuffer.METHOD_NAME_IDX_OFFSET));
|
return dexFile.getString(dexFile.readSmallUint(methodIdItemOffset +
|
||||||
|
DexBackedDexFile.Impl.METHOD_NAME_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<String> getParameterTypes() {
|
public List<String> getParameterTypes() {
|
||||||
int protoIdItemOffset = getProtoIdItemOffset();
|
int protoIdItemOffset = getProtoIdItemOffset();
|
||||||
final int parametersOffset = dexBuf.readSmallUint(protoIdItemOffset + DexBuffer.PROTO_PARAM_LIST_OFF_OFFSET);
|
final int parametersOffset = dexFile.readSmallUint(protoIdItemOffset +
|
||||||
|
DexBackedDexFile.Impl.PROTO_PARAM_LIST_OFF_OFFSET);
|
||||||
if (parametersOffset > 0) {
|
if (parametersOffset > 0) {
|
||||||
final int parameterCount = dexBuf.readSmallUint(parametersOffset + DexBuffer.TYPE_LIST_SIZE_OFFSET);
|
final int parameterCount = dexFile.readSmallUint(parametersOffset +
|
||||||
final int paramListStart = parametersOffset + DexBuffer.TYPE_LIST_LIST_OFFSET;
|
DexBackedDexFile.Impl.TYPE_LIST_SIZE_OFFSET);
|
||||||
|
final int paramListStart = parametersOffset + DexBackedDexFile.Impl.TYPE_LIST_LIST_OFFSET;
|
||||||
return new FixedSizeList<String>() {
|
return new FixedSizeList<String>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String readItem(final int index) {
|
public String readItem(final int index) {
|
||||||
return dexBuf.getType(dexBuf.readUshort(paramListStart + 2*index));
|
return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
|
||||||
}
|
}
|
||||||
@Override public int size() { return parameterCount; }
|
@Override public int size() { return parameterCount; }
|
||||||
};
|
};
|
||||||
@ -85,13 +88,14 @@ public class DexBackedMethodReference extends BaseMethodReference {
|
|||||||
@Override
|
@Override
|
||||||
public String getReturnType() {
|
public String getReturnType() {
|
||||||
int protoIdItemOffset = getProtoIdItemOffset();
|
int protoIdItemOffset = getProtoIdItemOffset();
|
||||||
return dexBuf.getType(dexBuf.readSmallUint(protoIdItemOffset + DexBuffer.PROTO_RETURN_TYPE_IDX_OFFSET));
|
return dexFile.getType(dexFile.readSmallUint(protoIdItemOffset +
|
||||||
|
DexBackedDexFile.Impl.PROTO_RETURN_TYPE_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getProtoIdItemOffset() {
|
private int getProtoIdItemOffset() {
|
||||||
if (protoIdItemOffset == 0) {
|
if (protoIdItemOffset == 0) {
|
||||||
protoIdItemOffset = dexBuf.getProtoIdItemOffset(
|
protoIdItemOffset = dexFile.getProtoIdItemOffset(
|
||||||
dexBuf.readUshort(methodIdItemOffset + DexBuffer.METHOD_PROTO_IDX_OFFSET));
|
dexFile.readUshort(methodIdItemOffset + DexBackedDexFile.Impl.METHOD_PROTO_IDX_OFFSET));
|
||||||
}
|
}
|
||||||
return protoIdItemOffset;
|
return protoIdItemOffset;
|
||||||
}
|
}
|
||||||
|
@ -32,23 +32,23 @@
|
|||||||
package org.jf.dexlib2.dexbacked.reference;
|
package org.jf.dexlib2.dexbacked.reference;
|
||||||
|
|
||||||
import org.jf.dexlib2.ReferenceType;
|
import org.jf.dexlib2.ReferenceType;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.iface.reference.Reference;
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
import org.jf.util.ExceptionWithContext;
|
import org.jf.util.ExceptionWithContext;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public abstract class DexBackedReference {
|
public abstract class DexBackedReference {
|
||||||
public static Reference makeReference(@Nonnull DexBuffer dexBuf, int referenceType, int referenceIndex) {
|
public static Reference makeReference(@Nonnull DexBackedDexFile dexFile, int referenceType, int referenceIndex) {
|
||||||
switch (referenceType) {
|
switch (referenceType) {
|
||||||
case ReferenceType.STRING:
|
case ReferenceType.STRING:
|
||||||
return new DexBackedStringReference(dexBuf, referenceIndex);
|
return new DexBackedStringReference(dexFile, referenceIndex);
|
||||||
case ReferenceType.TYPE:
|
case ReferenceType.TYPE:
|
||||||
return new DexBackedTypeReference(dexBuf, referenceIndex);
|
return new DexBackedTypeReference(dexFile, referenceIndex);
|
||||||
case ReferenceType.METHOD:
|
case ReferenceType.METHOD:
|
||||||
return new DexBackedMethodReference(dexBuf, referenceIndex);
|
return new DexBackedMethodReference(dexFile, referenceIndex);
|
||||||
case ReferenceType.FIELD:
|
case ReferenceType.FIELD:
|
||||||
return new DexBackedFieldReference(dexBuf, referenceIndex);
|
return new DexBackedFieldReference(dexFile, referenceIndex);
|
||||||
default:
|
default:
|
||||||
throw new ExceptionWithContext("Invalid reference type: %d", referenceType);
|
throw new ExceptionWithContext("Invalid reference type: %d", referenceType);
|
||||||
}
|
}
|
||||||
|
@ -32,22 +32,22 @@
|
|||||||
package org.jf.dexlib2.dexbacked.reference;
|
package org.jf.dexlib2.dexbacked.reference;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.reference.BaseStringReference;
|
import org.jf.dexlib2.base.reference.BaseStringReference;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedStringReference extends BaseStringReference {
|
public class DexBackedStringReference extends BaseStringReference {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
public final int stringIndex;
|
public final int stringIndex;
|
||||||
|
|
||||||
public DexBackedStringReference(@Nonnull DexBuffer dexBuf,
|
public DexBackedStringReference(@Nonnull DexBackedDexFile dexBuf,
|
||||||
int stringIndex) {
|
int stringIndex) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexBuf;
|
||||||
this.stringIndex = stringIndex;
|
this.stringIndex = stringIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getString() {
|
public String getString() {
|
||||||
return dexBuf.getString(stringIndex);
|
return dexFile.getString(stringIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,21 +32,21 @@
|
|||||||
package org.jf.dexlib2.dexbacked.reference;
|
package org.jf.dexlib2.dexbacked.reference;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.reference.BaseTypeReference;
|
import org.jf.dexlib2.base.reference.BaseTypeReference;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedTypeReference extends BaseTypeReference {
|
public class DexBackedTypeReference extends BaseTypeReference {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
public final int typeIndex;
|
public final int typeIndex;
|
||||||
|
|
||||||
public DexBackedTypeReference(@Nonnull DexBuffer dexBuf,
|
public DexBackedTypeReference(@Nonnull DexBackedDexFile dexFile,
|
||||||
int typeIndex) {
|
int typeIndex) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.typeIndex = typeIndex;
|
this.typeIndex = typeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull public String getType() {
|
@Nonnull public String getType() {
|
||||||
return dexBuf.getType(typeIndex);
|
return dexFile.getType(typeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ package org.jf.dexlib2.dexbacked.util;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedAnnotation;
|
import org.jf.dexlib2.dexbacked.DexBackedAnnotation;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -56,12 +56,12 @@ public abstract class AnnotationsDirectory {
|
|||||||
@Nonnull public abstract AnnotationIterator getParameterAnnotationIterator();
|
@Nonnull public abstract AnnotationIterator getParameterAnnotationIterator();
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static AnnotationsDirectory newOrEmpty(@Nonnull DexBuffer dexBuf,
|
public static AnnotationsDirectory newOrEmpty(@Nonnull DexBackedDexFile dexFile,
|
||||||
int directoryAnnotationsOffset) {
|
int directoryAnnotationsOffset) {
|
||||||
if (directoryAnnotationsOffset == 0) {
|
if (directoryAnnotationsOffset == 0) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
return new AnnotationsDirectoryImpl(dexBuf, directoryAnnotationsOffset);
|
return new AnnotationsDirectoryImpl(dexFile, directoryAnnotationsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,16 +76,16 @@ public abstract class AnnotationsDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Set<? extends DexBackedAnnotation> getAnnotations(@Nonnull final DexBuffer dexBuf,
|
public static Set<? extends DexBackedAnnotation> getAnnotations(@Nonnull final DexBackedDexFile dexFile,
|
||||||
final int annotationSetOffset) {
|
final int annotationSetOffset) {
|
||||||
if (annotationSetOffset != 0) {
|
if (annotationSetOffset != 0) {
|
||||||
final int size = dexBuf.readSmallUint(annotationSetOffset);
|
final int size = dexFile.readSmallUint(annotationSetOffset);
|
||||||
return new FixedSizeSet<DexBackedAnnotation>() {
|
return new FixedSizeSet<DexBackedAnnotation>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public DexBackedAnnotation readItem(int index) {
|
public DexBackedAnnotation readItem(int index) {
|
||||||
int annotationOffset = dexBuf.readSmallUint(annotationSetOffset + 4 + (4*index));
|
int annotationOffset = dexFile.readSmallUint(annotationSetOffset + 4 + (4*index));
|
||||||
return new DexBackedAnnotation(dexBuf, annotationOffset);
|
return new DexBackedAnnotation(dexFile, annotationOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int size() { return size; }
|
@Override public int size() { return size; }
|
||||||
@ -96,17 +96,17 @@ public abstract class AnnotationsDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static List<Set<? extends DexBackedAnnotation>> getParameterAnnotations(@Nonnull final DexBuffer dexBuf,
|
public static List<Set<? extends DexBackedAnnotation>> getParameterAnnotations(
|
||||||
final int annotationSetListOffset) {
|
@Nonnull final DexBackedDexFile dexFile, final int annotationSetListOffset) {
|
||||||
if (annotationSetListOffset > 0) {
|
if (annotationSetListOffset > 0) {
|
||||||
final int size = dexBuf.readSmallUint(annotationSetListOffset);
|
final int size = dexFile.readSmallUint(annotationSetListOffset);
|
||||||
|
|
||||||
return new FixedSizeList<Set<? extends DexBackedAnnotation>>() {
|
return new FixedSizeList<Set<? extends DexBackedAnnotation>>() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends DexBackedAnnotation> readItem(int index) {
|
public Set<? extends DexBackedAnnotation> readItem(int index) {
|
||||||
int annotationSetOffset = dexBuf.readSmallUint(annotationSetListOffset + 4 + index * 4);
|
int annotationSetOffset = dexFile.readSmallUint(annotationSetListOffset + 4 + index * 4);
|
||||||
return getAnnotations(dexBuf, annotationSetOffset);
|
return getAnnotations(dexFile, annotationSetOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int size() { return size; }
|
@Override public int size() { return size; }
|
||||||
@ -116,7 +116,7 @@ public abstract class AnnotationsDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class AnnotationsDirectoryImpl extends AnnotationsDirectory {
|
private static class AnnotationsDirectoryImpl extends AnnotationsDirectory {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int directoryOffset;
|
private final int directoryOffset;
|
||||||
|
|
||||||
private static final int FIELD_COUNT_OFFSET = 4;
|
private static final int FIELD_COUNT_OFFSET = 4;
|
||||||
@ -129,27 +129,27 @@ public abstract class AnnotationsDirectory {
|
|||||||
/** The size of a method_annotation structure */
|
/** The size of a method_annotation structure */
|
||||||
private static final int METHOD_ANNOTATION_SIZE = 8;
|
private static final int METHOD_ANNOTATION_SIZE = 8;
|
||||||
|
|
||||||
public AnnotationsDirectoryImpl(@Nonnull DexBuffer dexBuf,
|
public AnnotationsDirectoryImpl(@Nonnull DexBackedDexFile dexFile,
|
||||||
int directoryOffset) {
|
int directoryOffset) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.directoryOffset = directoryOffset;
|
this.directoryOffset = directoryOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFieldAnnotationCount() {
|
public int getFieldAnnotationCount() {
|
||||||
return dexBuf.readSmallUint(directoryOffset + FIELD_COUNT_OFFSET);
|
return dexFile.readSmallUint(directoryOffset + FIELD_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMethodAnnotationCount() {
|
public int getMethodAnnotationCount() {
|
||||||
return dexBuf.readSmallUint(directoryOffset + METHOD_COUNT_OFFSET);
|
return dexFile.readSmallUint(directoryOffset + METHOD_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParameterAnnotationCount() {
|
public int getParameterAnnotationCount() {
|
||||||
return dexBuf.readSmallUint(directoryOffset + PARAMETER_COUNT_OFFSET);
|
return dexFile.readSmallUint(directoryOffset + PARAMETER_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public Set<? extends DexBackedAnnotation> getClassAnnotations() {
|
public Set<? extends DexBackedAnnotation> getClassAnnotations() {
|
||||||
return getAnnotations(dexBuf, dexBuf.readSmallUint(directoryOffset));
|
return getAnnotations(dexFile, dexFile.readSmallUint(directoryOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -196,24 +196,24 @@ public abstract class AnnotationsDirectory {
|
|||||||
public AnnotationIteratorImpl(int startOffset, int size) {
|
public AnnotationIteratorImpl(int startOffset, int size) {
|
||||||
this.startOffset = startOffset;
|
this.startOffset = startOffset;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.currentItemIndex = dexBuf.readSmallUint(startOffset);
|
this.currentItemIndex = dexFile.readSmallUint(startOffset);
|
||||||
this.currentIndex = 0;
|
this.currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int seekTo(int itemIndex) {
|
public int seekTo(int itemIndex) {
|
||||||
while (currentItemIndex < itemIndex && (currentIndex+1) < size) {
|
while (currentItemIndex < itemIndex && (currentIndex+1) < size) {
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
currentItemIndex = dexBuf.readSmallUint(startOffset + (currentIndex*8));
|
currentItemIndex = dexFile.readSmallUint(startOffset + (currentIndex*8));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentItemIndex == itemIndex) {
|
if (currentItemIndex == itemIndex) {
|
||||||
return dexBuf.readSmallUint(startOffset + (currentIndex*8)+4);
|
return dexFile.readSmallUint(startOffset + (currentIndex*8)+4);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.currentItemIndex = dexBuf.readSmallUint(startOffset);
|
this.currentItemIndex = dexFile.readSmallUint(startOffset);
|
||||||
this.currentIndex = 0;
|
this.currentIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ import org.jf.dexlib2.AccessFlags;
|
|||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedMethod;
|
import org.jf.dexlib2.dexbacked.DexBackedMethod;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedMethodImplementation;
|
import org.jf.dexlib2.dexbacked.DexBackedMethodImplementation;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.iface.MethodParameter;
|
import org.jf.dexlib2.iface.MethodParameter;
|
||||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||||
@ -59,12 +59,12 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
*/
|
*/
|
||||||
@Nonnull public abstract Iterator<String> getParameterNames(@Nullable DexReader reader);
|
@Nonnull public abstract Iterator<String> getParameterNames(@Nullable DexReader reader);
|
||||||
|
|
||||||
public static DebugInfo newOrEmpty(@Nonnull DexBuffer dexBuf, int debugInfoOffset,
|
public static DebugInfo newOrEmpty(@Nonnull DexBackedDexFile dexFile, int debugInfoOffset,
|
||||||
@Nonnull DexBackedMethodImplementation methodImpl) {
|
@Nonnull DexBackedMethodImplementation methodImpl) {
|
||||||
if (debugInfoOffset == 0) {
|
if (debugInfoOffset == 0) {
|
||||||
return EmptyDebugInfo.INSTANCE;
|
return EmptyDebugInfo.INSTANCE;
|
||||||
}
|
}
|
||||||
return new DebugInfoImpl(dexBuf, debugInfoOffset, methodImpl);
|
return new DebugInfoImpl(dexFile, debugInfoOffset, methodImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmptyDebugInfo extends DebugInfo {
|
private static class EmptyDebugInfo extends DebugInfo {
|
||||||
@ -77,14 +77,14 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class DebugInfoImpl extends DebugInfo {
|
private static class DebugInfoImpl extends DebugInfo {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int debugInfoOffset;
|
private final int debugInfoOffset;
|
||||||
@Nonnull private final DexBackedMethodImplementation methodImpl;
|
@Nonnull private final DexBackedMethodImplementation methodImpl;
|
||||||
|
|
||||||
public DebugInfoImpl(@Nonnull DexBuffer dexBuf,
|
public DebugInfoImpl(@Nonnull DexBackedDexFile dexFile,
|
||||||
int debugInfoOffset,
|
int debugInfoOffset,
|
||||||
@Nonnull DexBackedMethodImplementation methodImpl) {
|
@Nonnull DexBackedMethodImplementation methodImpl) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.debugInfoOffset = debugInfoOffset;
|
this.debugInfoOffset = debugInfoOffset;
|
||||||
this.methodImpl = methodImpl;
|
this.methodImpl = methodImpl;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<DebugItem> iterator() {
|
public Iterator<DebugItem> iterator() {
|
||||||
DexReader reader = dexBuf.readerAt(debugInfoOffset);
|
DexReader reader = dexFile.readerAt(debugInfoOffset);
|
||||||
// TODO: this unsigned value could legitimally be > MAX_INT
|
// TODO: this unsigned value could legitimally be > MAX_INT
|
||||||
final int lineNumberStart = reader.readSmallUleb128();
|
final int lineNumberStart = reader.readSmallUleb128();
|
||||||
int registerCount = methodImpl.getRegisterCount();
|
int registerCount = methodImpl.getRegisterCount();
|
||||||
@ -151,7 +151,7 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new VariableSizeLookaheadIterator<DebugItem>(dexBuf, reader.getOffset()) {
|
return new VariableSizeLookaheadIterator<DebugItem>(dexFile, reader.getOffset()) {
|
||||||
private int codeAddress = 0;
|
private int codeAddress = 0;
|
||||||
private int lineNumber = lineNumberStart;
|
private int lineNumber = lineNumberStart;
|
||||||
|
|
||||||
@ -175,8 +175,8 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
}
|
}
|
||||||
case DebugItemType.START_LOCAL: {
|
case DebugItemType.START_LOCAL: {
|
||||||
int register = reader.readSmallUleb128();
|
int register = reader.readSmallUleb128();
|
||||||
String name = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
String name = dexFile.getOptionalString(reader.readSmallUleb128() - 1);
|
||||||
String type = dexBuf.getOptionalType(reader.readSmallUleb128() - 1);
|
String type = dexFile.getOptionalType(reader.readSmallUleb128() - 1);
|
||||||
ImmutableStartLocal startLocal =
|
ImmutableStartLocal startLocal =
|
||||||
new ImmutableStartLocal(codeAddress, register, name, type, null);
|
new ImmutableStartLocal(codeAddress, register, name, type, null);
|
||||||
locals[register] = startLocal;
|
locals[register] = startLocal;
|
||||||
@ -184,9 +184,9 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
}
|
}
|
||||||
case DebugItemType.START_LOCAL_EXTENDED: {
|
case DebugItemType.START_LOCAL_EXTENDED: {
|
||||||
int register = reader.readSmallUleb128();
|
int register = reader.readSmallUleb128();
|
||||||
String name = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
String name = dexFile.getOptionalString(reader.readSmallUleb128() - 1);
|
||||||
String type = dexBuf.getOptionalType(reader.readSmallUleb128() - 1);
|
String type = dexFile.getOptionalType(reader.readSmallUleb128() - 1);
|
||||||
String signature = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
String signature = dexFile.getOptionalString(reader.readSmallUleb128() - 1);
|
||||||
ImmutableStartLocal startLocal =
|
ImmutableStartLocal startLocal =
|
||||||
new ImmutableStartLocal(codeAddress, register, name, type, signature);
|
new ImmutableStartLocal(codeAddress, register, name, type, signature);
|
||||||
locals[register] = startLocal;
|
locals[register] = startLocal;
|
||||||
@ -227,7 +227,7 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
return new ImmutableEpilogueBegin(codeAddress);
|
return new ImmutableEpilogueBegin(codeAddress);
|
||||||
}
|
}
|
||||||
case DebugItemType.SET_SOURCE_FILE: {
|
case DebugItemType.SET_SOURCE_FILE: {
|
||||||
String sourceFile = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
String sourceFile = dexFile.getOptionalString(reader.readSmallUleb128() - 1);
|
||||||
return new ImmutableSetSourceFile(codeAddress, sourceFile);
|
return new ImmutableSetSourceFile(codeAddress, sourceFile);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -246,14 +246,14 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
@Override
|
@Override
|
||||||
public VariableSizeIterator<String> getParameterNames(@Nullable DexReader reader) {
|
public VariableSizeIterator<String> getParameterNames(@Nullable DexReader reader) {
|
||||||
if (reader == null) {
|
if (reader == null) {
|
||||||
reader = dexBuf.readerAt(debugInfoOffset);
|
reader = dexFile.readerAt(debugInfoOffset);
|
||||||
reader.skipUleb128();
|
reader.skipUleb128();
|
||||||
}
|
}
|
||||||
//TODO: make sure dalvik doesn't allow more parameter names than we have parameters
|
//TODO: make sure dalvik doesn't allow more parameter names than we have parameters
|
||||||
final int parameterNameCount = reader.readSmallUleb128();
|
final int parameterNameCount = reader.readSmallUleb128();
|
||||||
return new VariableSizeIterator<String>(reader, parameterNameCount) {
|
return new VariableSizeIterator<String>(reader, parameterNameCount) {
|
||||||
@Override protected String readNextItem(@Nonnull DexReader reader, int index) {
|
@Override protected String readNextItem(@Nonnull DexReader reader, int index) {
|
||||||
return dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
return dexFile.getOptionalString(reader.readSmallUleb128() - 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.dexbacked.value.DexBackedEncodedValue;
|
import org.jf.dexlib2.dexbacked.value.DexBackedEncodedValue;
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||||
@ -49,11 +49,11 @@ public abstract class StaticInitialValueIterator {
|
|||||||
public abstract void skipNext();
|
public abstract void skipNext();
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static StaticInitialValueIterator newOrEmpty(@Nonnull DexBuffer dexBuf, int offset) {
|
public static StaticInitialValueIterator newOrEmpty(@Nonnull DexBackedDexFile dexFile, int offset) {
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
return new StaticInitialValueIteratorImpl(dexBuf, offset);
|
return new StaticInitialValueIteratorImpl(dexFile, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StaticInitialValueIteratorImpl extends StaticInitialValueIterator {
|
private static class StaticInitialValueIteratorImpl extends StaticInitialValueIterator {
|
||||||
@ -61,8 +61,8 @@ public abstract class StaticInitialValueIterator {
|
|||||||
private final int size;
|
private final int size;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public StaticInitialValueIteratorImpl(@Nonnull DexBuffer dexBuf, int offset) {
|
public StaticInitialValueIteratorImpl(@Nonnull DexBackedDexFile dexFile, int offset) {
|
||||||
this.reader = dexBuf.readerAt(offset);
|
this.reader = dexFile.readerAt(offset);
|
||||||
this.size = reader.readSmallUleb128();
|
this.size = reader.readSmallUleb128();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,19 +31,19 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.AbstractCollection;
|
import java.util.AbstractCollection;
|
||||||
|
|
||||||
public abstract class VariableSizeCollection<T> extends AbstractCollection<T> {
|
public abstract class VariableSizeCollection<T> extends AbstractCollection<T> {
|
||||||
@Nonnull private final DexBuffer dexBuf;
|
@Nonnull private final DexBackedDexFile dexFile;
|
||||||
private final int offset;
|
private final int offset;
|
||||||
private final int size;
|
private final int size;
|
||||||
|
|
||||||
public VariableSizeCollection(@Nonnull DexBuffer dexBuf, int offset, int size) {
|
public VariableSizeCollection(@Nonnull DexBackedDexFile dexFile, int offset, int size) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
@ -51,8 +51,9 @@ public abstract class VariableSizeCollection<T> extends AbstractCollection<T> {
|
|||||||
protected abstract T readNextItem(@Nonnull DexReader reader, int index);
|
protected abstract T readNextItem(@Nonnull DexReader reader, int index);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public VariableSizeIterator<T> iterator() {
|
public VariableSizeIterator<T> iterator() {
|
||||||
return new VariableSizeIterator<T>(dexBuf, offset, size) {
|
return new VariableSizeIterator<T>(dexFile, offset, size) {
|
||||||
@Override
|
@Override
|
||||||
protected T readNextItem(@Nonnull DexReader reader, int index) {
|
protected T readNextItem(@Nonnull DexReader reader, int index) {
|
||||||
return VariableSizeCollection.this.readNextItem(reader, index);
|
return VariableSizeCollection.this.readNextItem(reader, index);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -44,8 +44,8 @@ public abstract class VariableSizeIterator<T> implements Iterator<T> {
|
|||||||
|
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
protected VariableSizeIterator(@Nonnull DexBuffer dexBuf, int offset, int size) {
|
protected VariableSizeIterator(@Nonnull DexBackedDexFile dexFile, int offset, int size) {
|
||||||
this.reader = dexBuf.readerAt(offset);
|
this.reader = dexFile.readerAt(offset);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,19 +31,19 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.AbstractSequentialList;
|
import java.util.AbstractSequentialList;
|
||||||
|
|
||||||
public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
||||||
@Nonnull private final DexBuffer dexBuf;
|
@Nonnull private final DexBackedDexFile dexFile;
|
||||||
private final int offset;
|
private final int offset;
|
||||||
private final int size;
|
private final int size;
|
||||||
|
|
||||||
public VariableSizeList(@Nonnull DexBuffer dexBuf, int offset, int size) {
|
public VariableSizeList(@Nonnull DexBackedDexFile dexFile, int offset, int size) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public VariableSizeListIterator<T> listIterator(int index) {
|
public VariableSizeListIterator<T> listIterator(int index) {
|
||||||
VariableSizeListIterator<T> iterator = new VariableSizeListIterator<T>(dexBuf, offset, size) {
|
VariableSizeListIterator<T> iterator = new VariableSizeListIterator<T>(dexFile, offset, size) {
|
||||||
@Override
|
@Override
|
||||||
protected T readNextItem(@Nonnull DexReader reader, int index) {
|
protected T readNextItem(@Nonnull DexReader reader, int index) {
|
||||||
return VariableSizeList.this.readNextItem(reader, index);
|
return VariableSizeList.this.readNextItem(reader, index);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -45,8 +45,8 @@ public abstract class VariableSizeListIterator<T> implements ListIterator<T> {
|
|||||||
|
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
protected VariableSizeListIterator(@Nonnull DexBuffer dexBuf, int offset, int size) {
|
protected VariableSizeListIterator(@Nonnull DexBackedDexFile dexFile, int offset, int size) {
|
||||||
this.reader = dexBuf.readerAt(offset);
|
this.reader = dexFile.readerAt(offset);
|
||||||
this.startOffset = offset;
|
this.startOffset = offset;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -44,8 +44,8 @@ public abstract class VariableSizeLookaheadIterator<T> implements Iterator<T> {
|
|||||||
|
|
||||||
private T cachedItem = null;
|
private T cachedItem = null;
|
||||||
|
|
||||||
protected VariableSizeLookaheadIterator(@Nonnull DexBuffer dexBuf, int offset) {
|
protected VariableSizeLookaheadIterator(@Nonnull DexBackedDexFile dexFile, int offset) {
|
||||||
this.reader = dexBuf.readerAt(offset);
|
this.reader = dexFile.readerAt(offset);
|
||||||
cachedItem = readNextItem(reader);
|
cachedItem = readNextItem(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,19 +31,19 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.AbstractSet;
|
import java.util.AbstractSet;
|
||||||
|
|
||||||
public abstract class VariableSizeSet<T> extends AbstractSet<T> {
|
public abstract class VariableSizeSet<T> extends AbstractSet<T> {
|
||||||
@Nonnull private final DexBuffer dexBuf;
|
@Nonnull private final DexBackedDexFile dexFile;
|
||||||
private final int offset;
|
private final int offset;
|
||||||
private final int size;
|
private final int size;
|
||||||
|
|
||||||
public VariableSizeSet(@Nonnull DexBuffer dexBuf, int offset, int size) {
|
public VariableSizeSet(@Nonnull DexBackedDexFile dexFile, int offset, int size) {
|
||||||
this.dexBuf = dexBuf;
|
this.dexFile = dexFile;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
@ -51,8 +51,9 @@ public abstract class VariableSizeSet<T> extends AbstractSet<T> {
|
|||||||
protected abstract T readNextItem(@Nonnull DexReader reader, int index);
|
protected abstract T readNextItem(@Nonnull DexReader reader, int index);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public VariableSizeIterator<T> iterator() {
|
public VariableSizeIterator<T> iterator() {
|
||||||
return new VariableSizeIterator<T>(dexBuf, offset, size) {
|
return new VariableSizeIterator<T>(dexFile, offset, size) {
|
||||||
@Override
|
@Override
|
||||||
protected T readNextItem(@Nonnull DexReader reader, int index) {
|
protected T readNextItem(@Nonnull DexReader reader, int index) {
|
||||||
return VariableSizeSet.this.readNextItem(reader, index);
|
return VariableSizeSet.this.readNextItem(reader, index);
|
||||||
|
@ -33,7 +33,7 @@ package org.jf.dexlib2.dexbacked.value;
|
|||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue;
|
import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedAnnotationElement;
|
import org.jf.dexlib2.dexbacked.DexBackedAnnotationElement;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.dexbacked.util.VariableSizeSet;
|
import org.jf.dexlib2.dexbacked.util.VariableSizeSet;
|
||||||
import org.jf.dexlib2.iface.value.AnnotationEncodedValue;
|
import org.jf.dexlib2.iface.value.AnnotationEncodedValue;
|
||||||
@ -42,14 +42,14 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DexBackedAnnotationEncodedValue extends BaseAnnotationEncodedValue implements AnnotationEncodedValue {
|
public class DexBackedAnnotationEncodedValue extends BaseAnnotationEncodedValue implements AnnotationEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
@Nonnull public final String type;
|
@Nonnull public final String type;
|
||||||
private final int elementCount;
|
private final int elementCount;
|
||||||
private final int elementsOffset;
|
private final int elementsOffset;
|
||||||
|
|
||||||
public DexBackedAnnotationEncodedValue(@Nonnull DexReader reader) {
|
public DexBackedAnnotationEncodedValue(@Nonnull DexReader reader) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.type = dexBuf.getType(reader.readSmallUleb128());
|
this.type = dexFile.getType(reader.readSmallUleb128());
|
||||||
this.elementCount = reader.readSmallUleb128();
|
this.elementCount = reader.readSmallUleb128();
|
||||||
this.elementsOffset = reader.getOffset();
|
this.elementsOffset = reader.getOffset();
|
||||||
skipElements(reader, elementCount);
|
skipElements(reader, elementCount);
|
||||||
@ -73,7 +73,7 @@ public class DexBackedAnnotationEncodedValue extends BaseAnnotationEncodedValue
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends DexBackedAnnotationElement> getElements() {
|
public Set<? extends DexBackedAnnotationElement> getElements() {
|
||||||
return new VariableSizeSet<DexBackedAnnotationElement>(dexBuf, elementsOffset, elementCount) {
|
return new VariableSizeSet<DexBackedAnnotationElement>(dexFile, elementsOffset, elementCount) {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected DexBackedAnnotationElement readNextItem(@Nonnull DexReader dexReader, int index) {
|
protected DexBackedAnnotationElement readNextItem(@Nonnull DexReader dexReader, int index) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseArrayEncodedValue;
|
import org.jf.dexlib2.base.value.BaseArrayEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
|
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
|
||||||
import org.jf.dexlib2.iface.value.ArrayEncodedValue;
|
import org.jf.dexlib2.iface.value.ArrayEncodedValue;
|
||||||
@ -42,12 +42,12 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedArrayEncodedValue extends BaseArrayEncodedValue implements ArrayEncodedValue {
|
public class DexBackedArrayEncodedValue extends BaseArrayEncodedValue implements ArrayEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int elementCount;
|
private final int elementCount;
|
||||||
private final int encodedArrayOffset;
|
private final int encodedArrayOffset;
|
||||||
|
|
||||||
public DexBackedArrayEncodedValue(@Nonnull DexReader reader) {
|
public DexBackedArrayEncodedValue(@Nonnull DexReader reader) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
this.elementCount = reader.readSmallUleb128();
|
this.elementCount = reader.readSmallUleb128();
|
||||||
this.encodedArrayOffset = reader.getOffset();
|
this.encodedArrayOffset = reader.getOffset();
|
||||||
skipElementsFrom(reader, elementCount);
|
skipElementsFrom(reader, elementCount);
|
||||||
@ -67,7 +67,7 @@ public class DexBackedArrayEncodedValue extends BaseArrayEncodedValue implements
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<? extends EncodedValue> getValue() {
|
public List<? extends EncodedValue> getValue() {
|
||||||
return new VariableSizeList<EncodedValue>(dexBuf, encodedArrayOffset, elementCount) {
|
return new VariableSizeList<EncodedValue>(dexFile, encodedArrayOffset, elementCount) {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected EncodedValue readNextItem(@Nonnull DexReader dexReader, int index) {
|
protected EncodedValue readNextItem(@Nonnull DexReader dexReader, int index) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseEnumEncodedValue;
|
import org.jf.dexlib2.base.value.BaseEnumEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference;
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference;
|
import org.jf.dexlib2.iface.reference.FieldReference;
|
||||||
@ -40,15 +40,15 @@ import org.jf.dexlib2.iface.reference.FieldReference;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedEnumEncodedValue extends BaseEnumEncodedValue {
|
public class DexBackedEnumEncodedValue extends BaseEnumEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int fieldIndex;
|
private final int fieldIndex;
|
||||||
|
|
||||||
public DexBackedEnumEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
public DexBackedEnumEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
fieldIndex = reader.readSizedSmallUint(valueArg + 1);
|
fieldIndex = reader.readSizedSmallUint(valueArg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public FieldReference getValue() {
|
@Override public FieldReference getValue() {
|
||||||
return new DexBackedFieldReference(dexBuf, fieldIndex);
|
return new DexBackedFieldReference(dexFile, fieldIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseFieldEncodedValue;
|
import org.jf.dexlib2.base.value.BaseFieldEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference;
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference;
|
import org.jf.dexlib2.iface.reference.FieldReference;
|
||||||
@ -40,15 +40,15 @@ import org.jf.dexlib2.iface.reference.FieldReference;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedFieldEncodedValue extends BaseFieldEncodedValue {
|
public class DexBackedFieldEncodedValue extends BaseFieldEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int fieldIndex;
|
private final int fieldIndex;
|
||||||
|
|
||||||
public DexBackedFieldEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
public DexBackedFieldEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
fieldIndex = reader.readSizedSmallUint(valueArg + 1);
|
fieldIndex = reader.readSizedSmallUint(valueArg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public FieldReference getValue() {
|
@Override public FieldReference getValue() {
|
||||||
return new DexBackedFieldReference(dexBuf, fieldIndex);
|
return new DexBackedFieldReference(dexFile, fieldIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodEncodedValue;
|
import org.jf.dexlib2.base.value.BaseMethodEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference;
|
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference;
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference;
|
import org.jf.dexlib2.iface.reference.MethodReference;
|
||||||
@ -40,15 +40,15 @@ import org.jf.dexlib2.iface.reference.MethodReference;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedMethodEncodedValue extends BaseMethodEncodedValue {
|
public class DexBackedMethodEncodedValue extends BaseMethodEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int MethodIndex;
|
private final int MethodIndex;
|
||||||
|
|
||||||
public DexBackedMethodEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
public DexBackedMethodEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
MethodIndex = reader.readSizedSmallUint(valueArg + 1);
|
MethodIndex = reader.readSizedSmallUint(valueArg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public MethodReference getValue() {
|
@Override public MethodReference getValue() {
|
||||||
return new DexBackedMethodReference(dexBuf, MethodIndex);
|
return new DexBackedMethodReference(dexFile, MethodIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,21 +32,21 @@
|
|||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseStringEncodedValue;
|
import org.jf.dexlib2.base.value.BaseStringEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedStringEncodedValue extends BaseStringEncodedValue {
|
public class DexBackedStringEncodedValue extends BaseStringEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int stringIndex;
|
private final int stringIndex;
|
||||||
|
|
||||||
public DexBackedStringEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
public DexBackedStringEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
stringIndex = reader.readSizedSmallUint(valueArg + 1);
|
stringIndex = reader.readSizedSmallUint(valueArg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getValue() {
|
@Override public String getValue() {
|
||||||
return dexBuf.getString(stringIndex);
|
return dexFile.getString(stringIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,21 +32,21 @@
|
|||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseTypeEncodedValue;
|
import org.jf.dexlib2.base.value.BaseTypeEncodedValue;
|
||||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
import org.jf.dexlib2.dexbacked.DexReader;
|
import org.jf.dexlib2.dexbacked.DexReader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexBackedTypeEncodedValue extends BaseTypeEncodedValue {
|
public class DexBackedTypeEncodedValue extends BaseTypeEncodedValue {
|
||||||
@Nonnull public final DexBuffer dexBuf;
|
@Nonnull public final DexBackedDexFile dexFile;
|
||||||
private final int typeIndex;
|
private final int typeIndex;
|
||||||
|
|
||||||
public DexBackedTypeEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
public DexBackedTypeEncodedValue(@Nonnull DexReader reader, int valueArg) {
|
||||||
this.dexBuf = reader.dexBuf;
|
this.dexFile = reader.dexBuf;
|
||||||
typeIndex = reader.readSizedSmallUint(valueArg + 1);
|
typeIndex = reader.readSizedSmallUint(valueArg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getValue() {
|
@Override public String getValue() {
|
||||||
return dexBuf.getType(typeIndex);
|
return dexFile.getType(typeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user