-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Direct API Input / dexlib2 compatibility. #1457
Comments
@GraxCode sure! @Test
public void testDirectDexInput() throws IOException {
try (JadxDecompiler jadx = new JadxDecompiler();
InputStream in = new FileInputStream(getFileFromSampleDir("hello.dex"))) {
jadx.addCustomLoad(new DexInputPlugin().loadDexFromInputStream(in, "input"));
jadx.load();
for (JavaClass cls : jadx.getClasses()) {
System.out.println(cls.getCode());
}
assertThat(jadx.getClasses(), Matchers.hasSize(1));
}
}
If this approach and implementation is fine for you, I will merge it into master.
It is possible to implement |
This will definitely make it easier to use and spare me having to create temp files. Does it work for .smali input too? I will need that because it's the best way of inputting dexlib2 data into jadx (dexlib2 -> smali -> jadx) |
No, only for dex. I thought you will be using |
Because I want to decompile single classes, and not all classes at the same time, while also considering changes i make to the dexlib2 stuff. I am writing an editor for dalvik code / apk files and need a dynamic decompiler that reflects changes. |
@GraxCode I see. I can write code for input smali using InputStream, but internally it will use temp files anyway, because I don't see a good way to hack into smali lib and convert smali to dex without temp files. So it looks like your issue should address smali lib in the first place. |
No, I don't think that's necessary then. It will be better to stick to the current way. Also I just noticed that the .smali file loader also converts it to a temporary .dex file, so I am doing unneeded steps there. Current way: I will change it to: So, therefore, the commit you made will be useful for me. Thank you. |
@NebelNidas done. Added methods for load from input stream or byte array. BTW, I notice these lines in your code: if (fullClassName.contains("$")) {
errorMessage = "JADX doesn't support decompiling inner classes!"; But jadx do support decompile of inner classes, do you encounter any issue? |
Nice, thank you very much :)
In my initial implementation, it failed because of these lines: jadx/jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java Lines 369 to 372 in 4230cd5
Now it seems to work fine though 😄 |
I see. Jadx mark class as inner if parent class is found, so inner class moved and code for it generated in that parent class, as a result inner class doesn't have own code. Anyway, inner class move can be unexpected (related to #1814), so adding option to disable such move can be a good improvement. I will create an issue for that 🙂 |
Describe your idea:
It would be great if the API could also get input directly, without providing a file (maybe an InputStream e.g.), or even better would be making the API work directly with dexlib2 (smali) tree structure.
The text was updated successfully, but these errors were encountered: