Android Reverse Basics Smali

Source: Internet
Author: User

What is Smali:

When we use tools to decompile some apps, we see a Smali folder, which is actually the Smali file for each Java class. Android Virtual Machine Dalvik is not the Java Virtual machine JVM compiled after the generation of the class file, but to perform and re-consolidate the packaging generated after the Dex file, Dex file after the Smali code, you can say, Smali language is Dalvik anti-assembly

Comparison of Java and Smali data types:

   JAVA                    Smali
V void Z boolean B byte S short C char I int J Long F float D double reference type L object [ array

Grammar:

. field defines a variable. Method methods. Parameter method parameter. The Prologue method starts. Line 12 This method is located on row 12th Invoke-super Call the parent function const/high16  V0, 0x7fo3 0x7fo3 assignment to V0invoke-direct call function Return-void function returns Void.end method function End New-instance Create instance Iput-object object Assignment Iget-object Call object in Voke-static calling a static function
Smali Jump Statement "If-eq VA, vb,: cond_**" If VA equals vb jump to: cond_** "If-ne va, vb,: cond_**" If VA is not equal to VB jump to: cond_** "If-lt va, vb,: Cond_ * * "If VA is less than VB jump to: cond_**" If-ge va, vb,: cond_** "If VA is greater than or equal to VB jump to: cond_**" If-gt VA, VB,: cond_** "If VA is greater than VB jump to: cond_**" If-le va, VB,: cond_** "If VA is less than or equal to VB then jump to: cond_**" If-eqz va,: cond_** "If VA equals 0 jump to: cond_**" If-nez VA,: cond_** " If VA is not equal to 0 jump to: cond_** "If-ltz va,: cond_**" If VA is less than 0 jump to: cond_** "If-gez va,: cond_**" If VA is greater than or equal to 0 then jump to: cond_** "If-gtz va,: cond_** "If VA is greater than 0 jump to: cond_**" If-lez va,: cond_** "If VA is less than or equal to 0 then jump to: cond_**

DEMO:

Java Code        Private Boolean show () {                Boolean tempflag = ((3-2) ==1)? True:false;                if (tempflag) {                    return true;                } else{                    return false;                }            } Convert Smali code. Method Private Show () Z    . Locals 2    . Prologue           //Methods start    . Line:    const/4 v0, 0x1     // V0 is assigned a value of 1    .    line. Local V0, tempflag:z    if-eqz v0,: cond_0            //Determine if V0 equals 0, does not meet the criteria to go down, eligible to execute COND_0 branch    .    line CONST/4 v1, 0x1            //Meet the Conditional branch    .    : goto_0    return v1    : cond_0    const /4 V1, 0x0            //Cond_0 branch    Goto:goto_0.end method

Reference:

http://blog.csdn.net/lostinai/article/details/48975661

http://blog.csdn.net/sjim_/article/details/50443860

Android Reverse Basics Smali

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.