前言有时候我们破解一款软件,为了表明是自己修改的作品或者说明一些使用应注意的事项,一般会在程序开启时,自定义添加点东西,比如常见的Splash、Toast,不带按钮的Alertdialog等,今天我们就试试添加自定义的带按钮、按钮带链接的Alertdialog。
对比反编译具有该形式的DEMO,可以发现在主Activity的onCreate()方法中,增加了以下的代码:
- new-instance v0, Landroid/app/AlertDialog$Builder;
- invoke-direct {v0, p0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V
- const-string v1, "CSDN博客"
- invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
- move-result-object v0
- const-string v1, "欢迎访问我的博客"
- invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
- move-result-object v0
- const-string v1, "我的主页"
- //需要注意的地方,如果原程序有$1会出现冲突
- new-instance v2, Lcom/changba/activity/HomePageFragmentActivity$1;
- invoke-direct {v2, p0}, Lcom/changba/activity/HomePageFragmentActivity$1;-><init>(Lcom/changba/activity/HomePageFragmentActivity;)V
- invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
- move-result-object v0
- const-string v1, "确定"
- const/4 v2, 0x0
- invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
- move-result-object v0
- invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->show()Landroid/app/AlertDialog;
复制代码 同时,也会多反编译一个带$1的主Activity的内部类,代码如下面:
- //需要注意的地方,如果原程序有$1会出现冲突
- .class Lcom/example/testtoast/MainActivity$1;
- .super Ljava/lang/Object;
- //这个也要注意,看准主Activity的名称
- .source "MainActivity.java"
- # interfaces
- .implements Landroid/content/DialogInterface$OnClickListener;
- # annotations
- .annotation system Ldalvik/annotation/EnclosingMethod;
- value = Lcom/example/testtoast/MainActivity;->onCreate(Landroid/os/Bundle;)V
- .end annotation
- .annotation system Ldalvik/annotation/InnerClass;
- accessFlags = 0x0
- name = null
- .end annotation
- # instance fields
- .field final synthetic this$0:Lcom/example/testtoast/MainActivity;
- # direct methods
- .method constructor <init>(Lcom/example/testtoast/MainActivity;)V
- .locals 0
- .prologue
- .line 1
- //需要注意的地方,如果原程序有$1会出现冲突
- iput-object p1, p0, Lcom/example/testtoast/MainActivity$1;->this$0:Lcom/example/testtoast/MainActivity;
- .line 29
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
- .end method
- # virtual methods
- .method public onClick(Landroid/content/DialogInterface;I)V
- .locals 3
- .param p1, "dialog" # Landroid/content/DialogInterface;
- .param p2, "which" # I
- .prologue
- .line 34
- const-string v2, "http://blog.csdn.net/zihao2012"
- invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
- move-result-object v1
- .line 35
- .local v1, "uri":Landroid/net/Uri;
- new-instance v0, Landroid/content/Intent;
- const-string v2, "android.intent.action.VIEW"
- invoke-direct {v0, v2, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V
- .line 36
- .local v0, "it":Landroid/content/Intent;
- //需要注意的地方,如果原程序有$1会出现冲突
- iget-object v2, p0, Lcom/example/testtoast/MainActivity$1;->this$0:Lcom/example/testtoast/MainActivity;
- invoke-virtual {v2, v0}, Lcom/example/testtoast/MainActivity;->startActivity(Landroid/content/Intent;)V
- .line 39
- return-void
- .end method
复制代码 操作今天我们仍然沿用原来的操作对象SuperChm,反编译之后,定位到主Activity:Lcom/jrzheng/superchm/Activity/MainActivity;浏览一下周边的目录,会发现原程序已经有内部类$1,为了避免冲突,我们就需要将需要添加的内部类,修改为$111,onCreate()中如下图:
http://img.blog.csdn.net/20141009105121840
最近将总类名Lcom/changba/activity/HomePageFragmentActivity全部替换成:Lcom/jrzheng/superchm/Activity/MainActivity。
完成图
http://img.blog.csdn.net/20141009105317515http://img.blog.csdn.net/20141009105101203
小菜不会编程..全程只因Allen大神的DEMO,谢谢~帮了我很多:-D下载地址
|