The first thing we need to know is:
The Java virtual machine runs Java bytecode, and the Dalvik virtual machine runs Dalvik bytecode. The traditional Java program is compiled to generate Java bytecode and stored in the class file. The Java VIRTUAL machine runs the program by decoding the content of the class file, while the Dalvik VIRTUAL machine runs dalvik bytecode. All Dalvik bytecode is converted from Java bytecode. It is packaged into a DEX executable, and the Dalvik VM executes the bytecode by interpreting the DEX file.Copy the code
Download address:
Link: https://pan.baidu.com/s/1mHOl9y-LXnETUg3oDAKNvA extraction code: 3 ygdCopy the code
Tools:
Conversion tool: J2S2JCopy the code
Let’s start with a piece of JAVA code
Foo (a+b)*(a-b), called in main, passed in 5 and 3, and printed out.
Next, we convert to SMALI via J2S2J
Let’s take a look at smALI code compared to JAVA code. If you’re not familiar with SmALI at all, take a look at this article. It’s very well written.
https://blog.csdn.net/rozol/article/details/88368358Copy the code
Let’s take a look at the SMALI code
The code in the head
Create a Hello class. Class public LHello; This class inherits from Object. super Ljava/lang/ object; The original file name is hello.java.source"Hello.java"Copy the code
Constructor, which is not shown in Java code. Java has a hidden, parameterless constructor by default
The main method
Custom foo method
As shown above, we parsed a simple piece of JAVA code into SmALI.
Now, we can make it a little harder and write a for loop
Instead of using J2S2J to convert to SMALI, we’ll just examine the for_test_method method this time
Code reference:
https://github.com/freedom-wy/reverse_android smali notesCopy the code
Welcome to exchange, learn together and make progress together.Copy the code