【Android 逆向】switch 的smail特征
阅读原文时间:2023年07月10日阅读:1

JAVA 源码

...
String str1 = packedSwitch(1);
...

private String packedSwitch(int i) {
        String str = null;
        switch (i) {
            case 0:
                str = "she is a baby";
                break;
            case 1:
                str = "she is a girl";
                break;
            case 2:
                str = "she is a woman";
                break;
            case 3:
                str = "she is an obasan";
                break;
            default:
                str = "she is a person";
                break;
        }
        return str;
    }

反编译后的smali源码为

...
.line 14
const/4 v2, 0x1

invoke-direct {p0, v2}, Lcom/droider/switchcase/MainActivity;->packedSwitch(I)Ljava/lang/String;

move-result-object v0
...

.method private packedSwitch(I)Ljava/lang/String;
    .locals 1
    .parameter "i"

    .prologue
    .line 21
    const/4 v0, 0x0

    .line 22
    .local v0, str:Ljava/lang/String;
    packed-switch p1, :pswitch_data_0

    .line 36
    const-string v0, "she is a person"

    .line 39
    :goto_0
    return-object v0

    .line 24
    :pswitch_0
    const-string v0, "she is a baby"

    .line 25
    goto :goto_0

    .line 27
    :pswitch_1
    const-string v0, "she is a girl"

    .line 28
    goto :goto_0

    .line 30
    :pswitch_2
    const-string v0, "she is a woman"

    .line 31
    goto :goto_0

    .line 33
    :pswitch_3
    const-string v0, "she is an obasan"

    .line 34
    goto :goto_0

    .line 22
    nop

    :pswitch_data_0
    .packed-switch 0x0   //默认值为0,下面每每加一
        :pswitch_0
        :pswitch_1
        :pswitch_2
        :pswitch_3
    .end packed-switch
.end method

从这里看出 p0 为方法的第零个入参即this, p1为方法的第一个入参

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章