Package com.googlecode.d2j.reader
Class DexFileReader
- java.lang.Object
-
- com.googlecode.d2j.reader.DexFileReader
-
- All Implemented Interfaces:
BaseDexFileReader
public class DexFileReader extends java.lang.Object implements BaseDexFileReader
Open and read a dex file.this is the entrance of dex-reader. to read a dex/odex, use the following code:DexFileVisitor visitor = new xxxFileVisitor(); DexFileReader reader = new DexFileReader(dexFile); reader.accept(visitor);
-
-
Field Summary
Fields Modifier and Type Field Description static intCOMPUTE_FRAMESInstruct ASM to compute frames when generating class files, usingClassWriter.COMPUTE_FRAMES**EXPERIMENTAL CODE**static intDONT_SANITIZE_NAMESstatic intIGNORE_READ_EXCEPTIONignore read exceptionstatic intKEEP_ALL_METHODSread all methods, even if they are glitchstatic intKEEP_CLINITkeep clinit method whenSKIP_DEBUGstatic intSKIP_ANNOTATIONskip annotation info in dex file.static intSKIP_CODEskip code info in dex file, this indicateSKIP_DEBUGstatic intSKIP_DEBUGskip debug infos in dex file.static intSKIP_EXCEPTIONstatic intSKIP_FIELD_CONSTANTskip field constant in dex file.
-
Constructor Summary
Constructors Constructor Description DexFileReader(byte[] data)DexFileReader(java.io.File file)DexFileReader(java.io.InputStream is)DexFileReader(java.nio.ByteBuffer in)read dex from aByteBuffer.DexFileReader(java.nio.file.Path file)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(com.googlecode.d2j.visitors.DexFileVisitor dv)equals toaccept(DexFileVisitor, int)with 0 as configvoidaccept(com.googlecode.d2j.visitors.DexFileVisitor dv, int config)Makes the given visitor visit the dex file.voidaccept(com.googlecode.d2j.visitors.DexFileVisitor dv, int classIdx, int config)Makes the given visitor visit the dex file.java.util.List<java.lang.String>getClassNames()intgetClassSize()intgetDexVersion()java.lang.BooleanignoreClass(java.lang.String className)static voidniceExceptionMessage(java.lang.Throwable t, int deep)static intreadLeb128i(java.nio.ByteBuffer in)static intreadULeb128i(java.nio.ByteBuffer in)
-
-
-
Field Detail
-
SKIP_DEBUG
public static final int SKIP_DEBUG
skip debug infos in dex file.- See Also:
- Constant Field Values
-
SKIP_CODE
public static final int SKIP_CODE
skip code info in dex file, this indicateSKIP_DEBUG- See Also:
- Constant Field Values
-
SKIP_ANNOTATION
public static final int SKIP_ANNOTATION
skip annotation info in dex file.- See Also:
- Constant Field Values
-
SKIP_FIELD_CONSTANT
public static final int SKIP_FIELD_CONSTANT
skip field constant in dex file.- See Also:
- Constant Field Values
-
IGNORE_READ_EXCEPTION
public static final int IGNORE_READ_EXCEPTION
ignore read exception- See Also:
- Constant Field Values
-
KEEP_ALL_METHODS
public static final int KEEP_ALL_METHODS
read all methods, even if they are glitch- See Also:
- Constant Field Values
-
KEEP_CLINIT
public static final int KEEP_CLINIT
keep clinit method whenSKIP_DEBUG- See Also:
- Constant Field Values
-
SKIP_EXCEPTION
public static final int SKIP_EXCEPTION
- See Also:
- Constant Field Values
-
DONT_SANITIZE_NAMES
public static final int DONT_SANITIZE_NAMES
- See Also:
- Constant Field Values
-
COMPUTE_FRAMES
public static final int COMPUTE_FRAMES
Instruct ASM to compute frames when generating class files, usingClassWriter.COMPUTE_FRAMES**EXPERIMENTAL CODE**- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DexFileReader
public DexFileReader(java.nio.ByteBuffer in)
read dex from aByteBuffer.
-
DexFileReader
public DexFileReader(byte[] data)
- Parameters:
data- the byte array of dex
-
DexFileReader
public DexFileReader(java.io.File file) throws java.io.IOException- Parameters:
file- the dex file- Throws:
java.io.IOException
-
DexFileReader
public DexFileReader(java.nio.file.Path file) throws java.io.IOException- Throws:
java.io.IOException
-
DexFileReader
public DexFileReader(java.io.InputStream is) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
niceExceptionMessage
public static void niceExceptionMessage(java.lang.Throwable t, int deep)
-
readULeb128i
public static int readULeb128i(java.nio.ByteBuffer in)
-
readLeb128i
public static int readLeb128i(java.nio.ByteBuffer in)
-
getDexVersion
public int getDexVersion()
- Specified by:
getDexVersionin interfaceBaseDexFileReader
-
accept
public void accept(com.googlecode.d2j.visitors.DexFileVisitor dv)
equals toaccept(DexFileVisitor, int)with 0 as config- Specified by:
acceptin interfaceBaseDexFileReader
-
getClassNames
public java.util.List<java.lang.String> getClassNames()
- Specified by:
getClassNamesin interfaceBaseDexFileReader
-
accept
public void accept(com.googlecode.d2j.visitors.DexFileVisitor dv, int config)Makes the given visitor visit the dex file.- Specified by:
acceptin interfaceBaseDexFileReader- Parameters:
dv- visitorconfig- config flags,SKIP_CODE,SKIP_DEBUG,SKIP_ANNOTATION,SKIP_FIELD_CONSTANT
-
accept
public void accept(com.googlecode.d2j.visitors.DexFileVisitor dv, int classIdx, int config)Makes the given visitor visit the dex file. Notice theDexFileVisitor.visitEnd()is not called- Specified by:
acceptin interfaceBaseDexFileReader- Parameters:
dv- visitorclassIdx- index of class_defconfig- config flags,SKIP_CODE,SKIP_DEBUG,SKIP_ANNOTATION,SKIP_FIELD_CONSTANT
-
ignoreClass
public java.lang.Boolean ignoreClass(java.lang.String className)
-
getClassSize
public final int getClassSize()
-
-