提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
记录smali使用,个人入门记录
一、怎么打印日志?
const-string v2, "一个TAG"
const-string v3, "你好"
invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
v2和v3是寄存器,大概需要留意所在方法的寄存器数量,如果寄存器数量不多,则使用v0、v1。多试试
等价于
Log.d("一个TAG", "你好");
二、变量赋值
假设Mainactivity有一个变量是int类型trashType:
const/4 v0, 0x1 #表示声明int 1
iput v0, p0, Lcom/xxx/example/MainActivity;->trashType:I #设定垃圾类型为 大件
等价于
this.trashType = 1;
三、调用方法、函数
1、调用普通方法funA():
invoke-direct {p0}, Lcom/xxx/example/MainActivity;->funA()V
等价于
this.funA();
2、调用有参方法OnViewClick(View view):
const v0, 0x7f07012e
invoke-virtual {p0, v0}, Lcom/xxx/example/MainActivity;->findViewById(I)Landroid/view/View;
move-result-object v0
.local v0, "view":Landroid/view/View;
invoke-virtual {v0}, Landroid/view/View;->callOnClick()Z
等价于
View view = this.findViewById((int) 0x7f07012e);
OnViewClicked(view);