Package proguard.dexfile.reader
Class DexFileReader
- java.lang.Object
-
- proguard.dexfile.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 intIGNORE_READ_EXCEPTIONingore 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_BROKEN_DEBUG_INFODo not throw an exception if debug info is not validstatic intSKIP_CODEskip code info in dex file, this indicateSKIP_DEBUGstatic intSKIP_DEBUGskip debug infos in dex file.static intSKIP_EXCEPTIONkeep clinit method whenSKIP_DEBUGstatic intSKIP_FIELD_CONSTANTskip field constant in dex file.
-
Constructor Summary
Constructors Constructor Description DexFileReader(byte[] data)DexFileReader(java.nio.ByteBuffer in)read dex from aByteBuffer.DexFileReader(java.nio.ByteBuffer in, int position)read dex from aByteBuffer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(java.util.function.Consumer<java.lang.String> stringConsumer)Provides the given consumer with all strings in the dex file.voidaccept(DexFileVisitor dv)equals toaccept(DexFileVisitor, int)with 0 as configvoidaccept(DexFileVisitor dv, int config)Makes the given visitor visit the dex file.voidaccept(DexFileVisitor dv, int classIdx, int config)Makes the given visitor visit the dex file.java.util.List<java.lang.String>getClassNames()intgetClassSize()the size of class in dex fileintgetDexVersion()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
ingore 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
keep clinit method whenSKIP_DEBUG- See Also:
- Constant Field Values
-
SKIP_BROKEN_DEBUG_INFO
public static final int SKIP_BROKEN_DEBUG_INFO
Do not throw an exception if debug info is not valid- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DexFileReader
public DexFileReader(java.nio.ByteBuffer in)
read dex from aByteBuffer.- Parameters:
in-
-
DexFileReader
public DexFileReader(java.nio.ByteBuffer in, int position)read dex from aByteBuffer.- Parameters:
in-position- start of the dexfile in the buffer
-
DexFileReader
public DexFileReader(byte[] data)
- Parameters:
data- the byte array of dex
-
-
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(DexFileVisitor dv)
equals toaccept(DexFileVisitor, int)with 0 as config- Specified by:
acceptin interfaceBaseDexFileReader- Parameters:
dv-
-
getClassNames
public java.util.List<java.lang.String> getClassNames()
- Specified by:
getClassNamesin interfaceBaseDexFileReader
-
accept
public void accept(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(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
-
accept
public void accept(java.util.function.Consumer<java.lang.String> stringConsumer)
Provides the given consumer with all strings in the dex file.- Specified by:
acceptin interfaceBaseDexFileReader
-
ignoreClass
public java.lang.Boolean ignoreClass(java.lang.String className)
-
getClassSize
public final int getClassSize()
the size of class in dex file- Returns:
- class_defs_size
-
-