Decompile JAVA DLL

2019-06-12 10:32发布

问题:

I've received a java dll file with an app I've downloaded. This DLL file was written in Java and now I want to decompile it.

Here is how I call this dll that contains a jar:

new JarInputStream(getClass().getResourceAsStream("jarjava.dll"));

Is there a way to decompile it?

回答1:

Java source files are compiled to .class files. As far as I know, there is no standard way to compile java code to a DLL.

What could have happened here:

  • This is C code written against the JNI API, to be used to interact with (or from) Java code;
  • This is Java code that was (automatically) converted to C code by some tool, and then compiled to a DLL.
  • This is a JAR file that someone renamed to a DLL. In that case, rename it back, unzip the JAR, and decompile the JAR with a Java decompiler.

Without knowing something about the origin of this DLL, there's not much you can do. Try a C decompiler, but probably won't get very far.



回答2:

You can read the machine code and translate it back into C yourself. Its not easy as the the whole point (possibly only point) of compiling the code to native is to make it harder to decompile.



回答3:

Problem solved.

Here it how I did it:

Read the file:

JarInputStream input = new JarInputStream(getClass().getResourceAsStream("/myjar.dll"));

Write a new file for each entry:

JarEntry entry;
while ((entry = input.getNextJarEntry()) != null)
{
    // Write file
}