解析Smali代码入门
# Java Code
#public class HelloWorld {
# push static void main(String[] args){
# System.out.println("Hello World!");
# }
#}
#
# int -> I
# String -> Ljava/lang/String;
# smali Code
.class public LHelloWorld;
#相当于 public class HelloWorld
#这里告诉你如何反编译smali格式成dex格式,并运行它,会在控制台输出helloworld字符串。
#Ye olde hello world application
#To assemble and run this on a phone or emulator:
#
#java -jar smali.jar -o classes.dex HelloWorld.smali
#zip HelloWorld.zip classes.dex
#
#adb push HelloWorld.zip /data/local
#adb shell dalvikvm -cp /data/local/HelloWorld.zip HelloWorld
#
#if you get out of memory type errors when running smali.jar, try
#
#java -Xmx512m -jar smali.jar HelloWorld.smali
#instead
.super Ljava/lang/Object;
# 继承自父类 Object extends Object
.method public static main([Ljava/lang/String;)V
#方法 static void main();
#registers 说明了用到2个寄存器
.registers 2
# System.out
# 用sget-object指令把System里面类型为PrintStream的out放到了v0
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
# 字符串放到v1
const-string v1, "Hello World!"
#System.out.println("");
# 把v1当成参数调用v0的void println(str)方法;
invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
# 返回
return-void
.end method