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 int
IGNORE_READ_EXCEPTION
ingore read exceptionstatic int
KEEP_ALL_METHODS
read all methods, even if they are glitchstatic int
KEEP_CLINIT
keep clinit method whenSKIP_DEBUG
static int
SKIP_ANNOTATION
skip annotation info in dex file.static int
SKIP_BROKEN_DEBUG_INFO
Do not throw an exception if debug info is not validstatic int
SKIP_CODE
skip code info in dex file, this indicateSKIP_DEBUG
static int
SKIP_DEBUG
skip debug infos in dex file.static int
SKIP_EXCEPTION
keep clinit method whenSKIP_DEBUG
static int
SKIP_FIELD_CONSTANT
skip 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 void
accept(java.util.function.Consumer<java.lang.String> stringConsumer)
Provides the given consumer with all strings in the dex file.void
accept(DexFileVisitor dv)
equals toaccept(DexFileVisitor, int)
with 0 as configvoid
accept(DexFileVisitor dv, int config)
Makes the given visitor visit the dex file.void
accept(DexFileVisitor dv, int classIdx, int config)
Makes the given visitor visit the dex file.java.util.List<java.lang.String>
getClassNames()
int
getClassSize()
the size of class in dex fileint
getDexVersion()
java.lang.Boolean
ignoreClass(java.lang.String className)
static void
niceExceptionMessage(java.lang.Throwable t, int deep)
static int
readLeb128i(java.nio.ByteBuffer in)
static int
readULeb128i(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:
getDexVersion
in interfaceBaseDexFileReader
-
accept
public void accept(DexFileVisitor dv)
equals toaccept(DexFileVisitor, int)
with 0 as config- Specified by:
accept
in interfaceBaseDexFileReader
- Parameters:
dv
-
-
getClassNames
public java.util.List<java.lang.String> getClassNames()
- Specified by:
getClassNames
in interfaceBaseDexFileReader
-
accept
public void accept(DexFileVisitor dv, int config)
Makes the given visitor visit the dex file.- Specified by:
accept
in 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:
accept
in 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:
accept
in 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
-
-