简体   繁体   English

需要帮助在 apk 文件中禁用 smali 中的方法

[英]Need help disabling a method in smali in an apk file

I need to disable the following method, but I have no idea what to do or what to change.我需要禁用以下方法,但我不知道该做什么或更改什么。 I've tried deleting it completely, but that just crashed the app.我试过完全删除它,但这只是让应用程序崩溃了。

The code:代码:

.method private c()V
    .registers 4

    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v1, p0, Lcom/blah/blah/er;->c:Lcom/blah/blah/AlphaActivity;

    invoke-direct {v0, v1}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setCancelable(Z)Landroid/app/AlertDialog$Builder;

    const-string v1, "Random text"

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    const v1, 0x1080027

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setIcon(I)Landroid/app/AlertDialog$Builder;

    const-string v1, "Other random text"

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    const v1, 0x104000a

    new-instance v2, Lcom/blah/blah/es;

    invoke-direct {v2, p0}, Lcom/blah/blah/es;-><init>(Lcom/blah/blah/er;)V

    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v0

    iput-object v0, p0, Lcom/blah/blah/er;->d:Landroid/app/AlertDialog;

    iget-object v0, p0, Lcom/blah/blah/er;->d:Landroid/app/AlertDialog;

    invoke-virtual {v0}, Landroid/app/AlertDialog;->show()V

    return-void
.end method

If you want to disable the method you can't simply delete the method because what should Android do if some other method wants to call a non-existing method?如果您想禁用该方法,您不能简单地删除该方法,因为如果其他方法想要调用不存在的方法,Android 应该怎么办? This is not possible and therefore the app crashes.这是不可能的,因此应用程序会崩溃。

If you want to disable the method you can simply delete all the instructions inside.如果你想禁用该方法,你可以简单地删除里面的所有指令。 The shown method luckily does not has a return value (you can see that on the last instruction return-void which means "exit method and return nothing".所显示的方法幸运地没有返回值(您可以在最后一条指令return-void中看到,这意味着“退出方法并且不返回任何内容”。

So you can strip down the method to the bare minimum:因此,您可以将方法精简到最低限度:

.method private c()V
    return-void
.end method

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM