public final class Dex extends Object
Modifier and Type | Class and Description |
---|---|
class |
Dex.Section |
Constructor and Description |
---|
Dex(byte[] data)
Creates a new dex that reads from
data . |
Dex(File file)
Creates a new dex buffer from the dex file
file . |
Dex(InputStream in)
Creates a new dex buffer of the dex in
in , and closes in . |
Dex(int byteCount)
Creates a new empty dex of the specified size.
|
Modifier and Type | Method and Description |
---|---|
int |
annotationDirectoryOffsetFromClassDefIndex(int classDefIndex)
Look up an annotation directory offset from a class def index.
|
Dex.Section |
appendSection(int maxByteCount,
String name) |
Iterable<ClassDef> |
classDefs() |
int |
computeChecksum()
Returns the checksum of all but the first 12 bytes of
dex . |
byte[] |
computeSignature()
Returns the signature of all but the first 32 bytes of this dex.
|
static Dex |
create(ByteBuffer data)
Creates a new dex from the contents of
bytes . |
int |
declaringClassIndexFromMethodIndex(int methodIndex)
Look up a method id declaring class index from a method index.
|
int |
descriptorIndexFromTypeIndex(int typeIndex)
Look up a descriptor index from a type index.
|
List<FieldId> |
fieldIds() |
int |
findClassDefIndexFromTypeIndex(int typeIndex) |
int |
findFieldIndex(FieldId fieldId) |
int |
findMethodIndex(MethodId methodId) |
int |
findStringIndex(String s) |
int |
findTypeIndex(String descriptor) |
byte[] |
getBytes()
Returns a copy of the the bytes of this dex.
|
int |
getLength() |
int |
getNextSectionStart() |
TableOfContents |
getTableOfContents() |
short[] |
interfaceTypeIndicesFromClassDefIndex(int classDefIndex)
Look up interface types indices from a return type index from a method index.
|
List<MethodId> |
methodIds() |
int |
nameIndexFromFieldIndex(int fieldIndex)
Look up a field id name index from a field index.
|
int |
nameIndexFromMethodIndex(int methodIndex)
Look up a method id name index from a method index.
|
Dex.Section |
open(int position) |
short[] |
parameterTypeIndicesFromMethodIndex(int methodIndex)
Look up a parameter type ids from a method index.
|
List<ProtoId> |
protoIds() |
ClassData |
readClassData(ClassDef classDef) |
Code |
readCode(ClassData.Method method) |
TypeList |
readTypeList(int offset) |
int |
returnTypeIndexFromMethodIndex(int methodIndex)
Look up a method id return type index from a method index.
|
List<String> |
strings() |
List<Integer> |
typeIds() |
int |
typeIndexFromClassDefIndex(int classDefIndex)
Look up a type index index from a class def index.
|
int |
typeIndexFromFieldIndex(int fieldIndex)
Look up a field id type index from a field index.
|
List<String> |
typeNames() |
void |
writeHashes()
Generates the signature and checksum of the dex file
out and
writes them to the file. |
void |
writeTo(File dexOut) |
void |
writeTo(OutputStream out) |
public Dex(byte[] data) throws IOException
data
. It is an error to modify
data
after using it to create a dex buffer.IOException
public Dex(int byteCount) throws IOException
IOException
public Dex(InputStream in) throws IOException
in
, and closes in
.IOException
public Dex(File file) throws IOException
file
.IOException
public static Dex create(ByteBuffer data) throws IOException
bytes
. This API supports
both .dex
and .odex
input. Calling this constructor
transfers ownership of bytes
to the returned Dex: it is an error
to access the buffer after calling this method.IOException
public void writeTo(OutputStream out) throws IOException
IOException
public void writeTo(File dexOut) throws IOException
IOException
public TableOfContents getTableOfContents()
public Dex.Section open(int position)
public Dex.Section appendSection(int maxByteCount, String name)
public int getLength()
public int getNextSectionStart()
public byte[] getBytes()
public TypeList readTypeList(int offset)
public Code readCode(ClassData.Method method)
public byte[] computeSignature() throws IOException
IOException
public int computeChecksum() throws IOException
dex
.IOException
public void writeHashes() throws IOException
out
and
writes them to the file.IOException
public int nameIndexFromFieldIndex(int fieldIndex)
fieldIds().get(fieldDexIndex).getNameIndex();
public int findStringIndex(String s)
public int findTypeIndex(String descriptor)
public int findFieldIndex(FieldId fieldId)
public int findMethodIndex(MethodId methodId)
public int findClassDefIndexFromTypeIndex(int typeIndex)
public int typeIndexFromFieldIndex(int fieldIndex)
fieldIds().get(fieldDexIndex).getTypeIndex();
public int declaringClassIndexFromMethodIndex(int methodIndex)
methodIds().get(methodIndex).getDeclaringClassIndex();
public int nameIndexFromMethodIndex(int methodIndex)
methodIds().get(methodIndex).getNameIndex();
public short[] parameterTypeIndicesFromMethodIndex(int methodIndex)
readTypeList(protoIds.get(methodIds().get(methodDexIndex).getProtoIndex()).getParametersOffset()).getTypes();
public int returnTypeIndexFromMethodIndex(int methodIndex)
protoIds().get(methodIds().get(methodDexIndex).getProtoIndex()).getReturnTypeIndex();
public int descriptorIndexFromTypeIndex(int typeIndex)
open(tableOfContents.typeIds.off + (index * SizeOf.TYPE_ID_ITEM)).readInt();
public int typeIndexFromClassDefIndex(int classDefIndex)
public int annotationDirectoryOffsetFromClassDefIndex(int classDefIndex)
public short[] interfaceTypeIndicesFromClassDefIndex(int classDefIndex)
...getClassDef(classDefIndex).getInterfaces();
Copyright © 2016. All Rights Reserved.