(1) Basic grammar of Smali series learning

1. What is Smali?
Smali and Baksmali respectively refer to the assembler and disassembler of a dex format file used by the Java virtual machine (Dalvik) in the Android system. Its syntax is a loose Jasmin/dedexer syntax, and it implements all the functions of the .dex format (annotations, debugging information, line information, etc.)

2. Grammar of smali
1. Primitive type
B---byte
C---char
D---double
F---float
I---int
J---long
S---short
V---void
Z ---boolean
[XXX---array
Lxxx/yyy---object

Parsing the last two items, the representation of the array is:

Add the square brackets "[" before the basic type. For example, the int array and the float array are represented as: [I, [F;
the representation of the object starts with L, and the format is LpackageName/objectName ; ( note that there must be a semicolon Followed at the end ), for example, the String object in smali is: Ljava/lang/String;, where java/lang corresponds to the java.lang package, and String is an object defined in the package.

2. Method definition
Format: Func-Name ( Para-Type1 Para-Type2 Para-Type3 ...) Return-Type

Note: There is no separator between parameters and parameters,

1.hello()v
 is void hello()

2.hello(lll)Z
 就是boolean hello(int,int,int)

3.hello(Z[l[lLjava/lang/String;J)Ljava/lang/String
 就是String hello(boolean,int[],int[],String,long)

3. Basic
syntax.field private isFlag:z define variables.method method.parameter method parameters.prologue
method start.line 123 This method is located on line 123 invoke-super calls the parent function const/high16 v0, 0x7fo3 assigns 0x7fo3 to v0 invoke -direct call function return-void function return void .end method function end new-instance create instance iput-object object assignment iget-object call object invoke-static call static function











4. Conditional jump branch:
"if-eq vA, vB, :cond_**" If vA is equal to vB, jump to: cond_**
"if-ne vA, vB, :cond_**" If vA is not equal to vB Then jump to: cond_**
"if-lt vA, vB, :cond_**" If vA is less than vB then 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 then jump to: cond_**
"if-le vA, vB, :cond_**" If vA is less than Equal to vB then jump to: cond_**
"if-eqz vA, :cond_**" If vA is equal to 0 then jump to: cond_**
"if-nez vA, :cond_**" If vA is not equal to 0 then 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, 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, jump to :cond_* *

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325274217&siteId=291194637