常用的Smali代码

每次都去网上找,太麻烦了。

所以把最常用的做个记录,省的以后到处找。

java代码:

    private void log(){
        Log.e("my_tag", "log-test");
    }
    
    private void logCallStack(){
        Log.e("call stack:",Log.getStackTraceString(new Exception()));
    }
    
    private void toast(){
        Toast.makeText(this, "toast test...", Toast.LENGTH_LONG).show();
    }

 
  

对应的smali代码:

.method private log()V
    .locals 2

    .prologue
    .line 36
    const-string v0, "my_tag"

    const-string v1, "log-test"

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 37
    return-void
.end method

.method private logCallStack()V
    .locals 2

    .prologue
    .line 44
    const-string v0, "call stack:"

    new-instance v1, Ljava/lang/Exception;

    invoke-direct {v1}, Ljava/lang/Exception;->()V

    invoke-static {v1}, Landroid/util/Log;->getStackTraceString(Ljava/lang/Throwable;)Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 45
    return-void
.end method

.method private toast()V
    .locals 2

    .prologue
    .line 40
    const-string v0, "toast test..."

    const/4 v1, 0x1

    invoke-static {p0, v0, v1}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v0

    invoke-virtual {v0}, Landroid/widget/Toast;->show()V

    .line 41
    return-void
.end method


如何debug smali文件:

http://bbs.pediy.com/showthread.php?t=189610



你可能感兴趣的:(Android逆向)