Skip to content
convert dex to java class/jar by dx and asm
Kotlin Groovy Java
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
buildSrc
config
error-case
gradle/wrapper
lib
resource
src
.editorconfig
.gitignore
LICENSE
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle
version

README.md

dedx

This is a tool to convert dex file to class file which similar to dex2jar

Description

dx is the home of Dalvik eXchange, the thing that takes in class files and reformulates them for consumption in the dalvik VM.

Compared to dex2jar, with the help of dx.jar eliminate the trouble of instruction synchronization.

And through the high version of the asm package, can produce a higher version of jvm bytecode.

Current progress

Parse Dex File

Parse Class

Parse Method

Parse Debug Info For Every Method

Instruction Generation

Create class field writer

line number table

--> Rewrite stack frame map

--> Optmization

Test

gradle -q runTest

Example

dedx -o /path/to/output /project_path/resource/Base.dex

Will create Base.class in output directory

And then, you can load this class and invoke method with the following code

import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Paths;

public class ExampleLoader extends ClassLoader {
    public Class<?> defineClass(String name, byte[] bytes) {
        return defineClass(name, bytes, 0, bytes.length);
    }

    public static void main(String[] args) {
        ExampleLoader loader = new ExampleLoader();
        try {
            byte[] bytes = Files.readAllBytes(Paths.get("/path/to/Base.class"));
            Class baseClass = loader.defineClass("com.test.Base", bytes);
            Method addInt = baseClass.getMethod("addInt", int.class, int.class);
            assert (Integer) addInt.invoke(null, 1, 1) == 2;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Note

Master branch not ensure build and run success.

If you want to use, please checkout tag.

You can’t perform that action at this time.