Class 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 Detail

      • SKIP_DEBUG

        public static final int SKIP_DEBUG
        skip debug infos in dex file.
        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
      • COMPUTE_FRAMES

        public static final int COMPUTE_FRAMES
        Instruct ASM to compute frames when generating class files, using ClassWriter.COMPUTE_FRAMES **EXPERIMENTAL CODE**
        See Also:
        Constant Field Values
    • Constructor Detail

      • DexFileReader

        public DexFileReader​(java.nio.ByteBuffer in)
        read dex from a ByteBuffer.
      • 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)
      • accept

        public void accept​(com.googlecode.d2j.visitors.DexFileVisitor dv,
                           int classIdx,
                           int config)
        Makes the given visitor visit the dex file. Notice the DexFileVisitor.visitEnd() is not called
        Specified by:
        accept in interface BaseDexFileReader
        Parameters:
        dv - visitor
        classIdx - index of class_def
        config - 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()