smali语法-创新互联
一、类型
V | void 空类型,仅用做返回类型 |
Z | boolean布尔型 |
B | byte字节型 |
S | short短整型 16位 |
C | char字符型 |
I | int整型 |
J | long 长整型 64位 |
F | float浮点型 |
D | double双精度型 64位 |
(2)对象 Lpackage/name/ObjectName L表明这是一个对象类型 e.g. "Ljava/lang/String"等同于java.lang.String
(3)数组(数组维度最多255)
[I | 等同于int[ ] |
[[I | 等同于int[ ][ ] |
v1 第二个local register
v2 p0 第一个parameter register
v3 p1 第二个parameter register
v4 p2 第三个parameter register e.g. 对于非静态方法 LMyObject;->MyMethod(IJZ)V, 参数分别是LMyObject,int,long(64位),bool,需要5个寄存器来存储参数 p0 this
p1 I
p2,p3 J
p4 Z 五、例子 e.g.1 const v0, 0
invoke-virtual {v0}, Ljava/lang/Object;->toString();相当于 Object blah = null;
blah.toString(); e.g.2 sget-object v5, Lcom/google/youngandroid/runtime;->Lit227:Lgnu/mapping/SimpleSymbol;相当于 gnu.mapping.SimpleSymbol localVariable = com.google.youngandroid.runtime.Lit227;即获取com.google.youngandroid.runtime中的Lit227字段存入v5寄存器 e.g.3 sput-object v0, Lcom/google/youngandroid/runtime;->Lit78:Lkawa/lang/SyntaxTemplate;相当于 com.google.youngandroid.runtime.Lit78 = kawa.lang.SyntaxTemplate localVariable;即将v0寄存器中存放的kawa.lang.SyntaxTemplate类型变量的值赋给com.google.youngandroid.runtime.Lit78 六、smali语法高亮 editplus 上smali语法高亮文件 http://www.editplus.com/dn.php?n=smali.rar (来自非虫,非常欣赏这位大牛,技术厉害不用说,还乐于分享,在看雪上发布了很多android逆向的教程)
![](/upload/otherpic3/6597887803307694882.jpg)
![](/upload/otherpic3/6597656905865854788.jpg)
publicclass example{
privatestaticintCounter;
public example(){Counter=16;}
![](/upload/otherpic3/6597200608541687353.jpg)
publicstaticvoidLoopExample()
{
for(int i=0; i
}
![](/upload/otherpic3/6598090113447100531.jpg)
publicstaticvoidSwitchExample()
{
int val=42;
switch(val){
case1:System.out.println("val 1");break;
case2:System.out.println("val 2");break;
case42:System.out.println("val 42");break;
case5:System.out.println("val 5");break;
default:System.out.println("invalid value");break;
}
}
![](/upload/otherpic3/1306606841908785472.jpg)
![](/upload/otherpic3/6598288025540101366.jpg)
publicstaticvoidTryCatchExample()
{
String urlStr="google.com";
try{
// Get the image
URL url=new URL(urlStr);
InputStreamis= url.openStream();
is.close();
}catch(MalformedURLException e){
// Print out the exception that occurred
System.out.println("Invalid_URL"+ urlStr+" :"+ e.getMessage());
}catch(IOException e){
// Print out the exception that occurred
System.out.println("Unable?to?execute"+ urlStr+":"+ e.getMessage());
}
}
![](/upload/otherpic3/6597539258121749036.jpg)
publicstaticvoidArrayExample()
{
String someArray[]=newString[5];
someArray[0]="set value at index 0";
someArray[1]="index 1 has this value";
if( someArray[0].equals(someArray[1]))
{
System.out.println("array at index 0 = 1 (wont?happen)");
}
}
![](/upload/otherpic3/6598132994400581365.jpg)
Android恶意代码分析 claud
分享标题:smali语法-创新互联
URL链接:http://azwzsj.com/article/dishjh.html