Skip to content
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] Documentation: explain conversion from Smali to Java #1485

Open
eGit opened this issue May 17, 2022 · 3 comments
Open

[feature] Documentation: explain conversion from Smali to Java #1485

eGit opened this issue May 17, 2022 · 3 comments

Comments

@eGit
Copy link

eGit commented May 17, 2022

Describe your idea:

It would be nice for people who want to understand it at a low level (maybe even use the jadx libraries directly), how .smali is converted to .java by jadx?

Is there an intermediate step where .class files are created? And if yes, is it possible to write out these .class files?
Does jadx use its own code to do the smali to java conversion or is it some 3rd party library?
What alternatives exist to use to go from smali to .class or .java files? Maybe do the first step with jadx to get smali and then the next step with some other tool, to compare the .java generated by jadx with some other output?

@jpstotz
Copy link
Collaborator

jpstotz commented May 17, 2022

@eGit Jadx does not use smali or class files as intermediate for decompiling Android apps. It directly reads the DEX code (the classes*.dex files inside the APK file) by it's jadx-dex-input.

Jadx-gui is also capable of displaying the smali code but that happens independently of the decompilation. That part uses dexlib2 (the library that is developed as part of apktool).

@skylot
Copy link
Owner

skylot commented May 17, 2022

It would be nice for people who want to understand it at a low level

Sure. I plan to write a short overview of how jadx works.

explain conversion from Smali to Java

Jadx input IR (intermediate representation) is very close to dex format, so dex is "native" for jadx. And smali input support implemented using internal conversion to dex. Next, actual decompilation consist of many steps of transforming from input IR to the "output" IR which is close to Java AST and ends with java code generation.

Is there an intermediate step where .class files are created? ... Is it possible to write out these .class files?

No. Conversion from dex to java code is direct.

Does jadx use its own code to do the smali to java conversion or is it some 3rd party library?

To compile smali files to dex format, smali library is used. Next used only own jadx code.

What alternatives exist to use to go from smali to .class or .java files?

To convert .dex to .class you can use dex2jar or enjarify
To decompile .class to .java there are many java decompilers like: cfr, procyon, jd-gui, bytecode-viewer

@Mino260806
Copy link
Contributor

Sure. I plan to write a short overview of how jadx works.

I'm also interested! I'd like to contribute to jadx-core but I can't really grasp how it works.
@skylot maybe you can point us in the right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants