baksmali的使用:
java -jar baksmali.jar -o baksmali_out smali.dex
//生成smali.smali文件
.class public Lsmali;
.super Ljava/lang/Object;
.source "smali.java"
# direct methods
.method public constructor <init>()V
.registers 1
.prologue
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static main([Ljava/lang/String;)V
.registers 5
.prologue
.line 7
new-instance v0, Lsmali;
invoke-direct {v0}, Lsmali;-><init>()V
.line 8
sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
const/4 v2, 0x3
const/4 v3, 0x5
invoke-virtual {v0, v2, v3}, Lsmali;->foo(II)I
move-result v0
invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(I)V
.line 9
return-void
.end method
# virtual methods
.method public foo(II)I
.registers 5
.prologue
.line 3
add-int v0, p1, p2
sub-int v1, p1, p2
mul-int/2addr v0, v1
return v0
.end method
dedexer的使用:
java -jar ddx.jar -d ddxout smali.dex
//结果(smali.ddx)
.class public smali
.super java/lang/Object
.source smali.java
.method public <init>()V
.limit registers 1
; this: v0 (Lsmali;)
.line 1
invoke-direct {v0},java/lang/Object/<init> ; <init>()V
return-void
.end method
.method public static main([Ljava/lang/String;)V
.limit registers 5
; parameter[0] : v4 ([Ljava/lang/String;)
.line 7
new-instance v0,smali
invoke-direct {v0},smali/<init> ; <init>()V
.line 8
sget-object v1,java/lang/System.out Ljava/io/PrintStream;
const/4 v2,3
const/4 v3,5
invoke-virtual {v0,v2,v3},smali/foo ; foo(II)I
move-result v0
invoke-virtual {v1,v0},java/io/PrintStream/println ; println(I)V
.line 9
return-void
.end method
.method public foo(II)I
.limit registers 5
; this: v2 (Lsmali;)
; parameter[0] : v3 (I)
; parameter[1] : v4 (I)
.line 3
add-int v0,v3,v4
sub-int v1,v3,v4
mul-int/2addr v0,v1
return v0
.end method