本帖最后由 myoldid 于 2015-1-31 15:54 编辑
前言
这款游戏是在和游戏下载的,看下载量和评论都还不错,就搞下来研究一下。游戏名称就不明说了,大家自己去发掘吧
正文
1. 因为是和游戏的游戏,所以直接搜索onresult,大爷的,好多一堆啊。但仔细一看,还是简单,属于facebook和google的应该都和我们要找的无关,直接展开com/glu/plugins/glucn/AGlucnTools/IAP路径下对应的搜索结果,戳开onresult方法(图1)。又一看,也不对啊,没明示到底哪个是成功,那再看看java源码,猜测0该是成功,所以在smail里跳向0对应的代码。
图1
onresult对应的smail代码
[Java] 纯文本查看 复制代码 .method public onResult(ILjava/lang/String;Ljava/lang/Object;)V
.locals 3
.param p1, "resultCode" # I
.param p2, "arg1" # Ljava/lang/String;
.param p3, "arg2" # Ljava/lang/Object;
.prologue
.line 78
new-instance v0, Ljava/lang/StringBuilder;
#v0=(UninitRef,Ljava/lang/StringBuilder;);
const-string v1, "Dobilling="
#v1=(Reference,Ljava/lang/String;);
invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
#v0=(Reference,Ljava/lang/StringBuilder;);
invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Lcom/glu/plugins/glucn/AGlucnTools/Utils/Debug;->d(Ljava/lang/String;)V
.line 79
packed-switch p1, :pswitch_data_0
goto :pswitch_0 #结合java源码看,猜测0是成功,所以这里直接跳向:pswitch_0
.line 88
iget-object v0, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;->this$0:Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;
const/4 v1, -0x1
#v1=(Byte);
iget-object v2, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;->val$strId:Ljava/lang/String;
#v2=(Reference,Ljava/lang/String;);
invoke-static {v0, v1, v2}, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;->access$1(Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;ILjava/lang/String;)V
.line 92
:goto_0
return-void
.line 81
:pswitch_0
#v1=(Reference,Ljava/lang/String;);v2=(Uninit);
iget-object v0, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;->this$0:Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;
const/4 v1, 0x0
#v1=(Null);
iget-object v2, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;->val$strId:Ljava/lang/String;
#v2=(Reference,Ljava/lang/String;);
invoke-static {v0, v1, v2}, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;->access$1(Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;ILjava/lang/String;)V
goto :goto_0
.line 84
:pswitch_1
#v1=(Reference,Ljava/lang/String;);v2=(Uninit);
iget-object v0, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;->this$0:Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;
const/4 v1, -0x2
#v1=(Byte);
iget-object v2, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;->val$strId:Ljava/lang/String;
#v2=(Reference,Ljava/lang/String;);
invoke-static {v0, v1, v2}, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;->access$1(Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;ILjava/lang/String;)V
goto :goto_0
.line 79
:pswitch_data_0
.packed-switch 0x1
:pswitch_0
:pswitch_1
.end packed-switch.end method
对应的java源码
[Java] 纯文本查看 复制代码
public void onResult(int paramInt, String paramString, Object paramObject)
{
Debug.d("Dobilling=" + String.valueOf(paramInt));
switch (paramInt)
{
default:
GlucnIap_CM.access$1(this.this$0, -1, this.val$strId);
return;
case 1:
GlucnIap_CM.access$1(this.this$0, 0, this.val$strId); //这句该是成功
return;
}
GlucnIap_CM.access$1(this.this$0, -2, this.val$strId);
}
}
2. 修改后,直接打包安装,正常运行,点支付的时候,弹出确认框后,直接返回,哇哦,购买成功了,那说明我们改的地方是对的。
3. 为了找到判断-2,-1和0是怎么定义的,那再来到onresult所在的smail文件夹,一个一个的看。当看到GlucnIap_CM.smail时,眼睛一亮,发现了“Product already purchased. Return with success.”的字符,哇,这意思就是已经付费,告诉商店老板它付费了,你发货吧。那可以在这里动下手脚哦,就像淡然文章中的方法一样。
smail代码如下
[Java] 纯文本查看 复制代码
.method BuyProduct_imp()V
.locals 8
##################此处略去很多字###################
.line 66
.local v3, "indexStr":Ljava/lang/String;
#v3=(Null);
const-string v0, "GlucnIap_CM.BuyProduct: onlyPayOneTime = \'%s\', indexStr = \'%s\'"
new-array v4, v4, [Ljava/lang/Object;
#v4=(Reference,[Ljava/lang/Object;);
invoke-static {v6}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v5
#v5=(Reference,Ljava/lang/Boolean;);
aput-object v5, v4, v2
aput-object v3, v4, v1
invoke-static {v0, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Lcom/glu/plugins/glucn/AGlucnTools/Utils/Debug;->w(Ljava/lang/String;)V
.line 68
#if-eqz v6, :cond_2 #注释掉这个跳转,让程序执行已经支付的代码
invoke-static {v3}, Lcn/cmgame/billing/api/GameInterface;->getActivateFlag(Ljava/lang/String;)Z
move-result v0
#v0=(Boolean);
#if-eqz v0, :cond_2 #注释掉这个跳转,让程序执行已经支付的代码
.line 69
const-string v0, "GlucnIap_CM.BuyProduct: Product already purchased. Return with success." #这个字面意思就是已经付费了,让老板发货
#v0=(Reference,Ljava/lang/String;);
invoke-static {v0}, Lcom/glu/plugins/glucn/AGlucnTools/Utils/Debug;->w(Ljava/lang/String;)V
.line 70
invoke-virtual {p0, v2, v7}, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;->BuyComplete(ILjava/lang/String;)V
goto :goto_0
.line 74
:cond_2
#v0=(Conflicted);
iget-object v0, p0, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;->mgameActivity:Landroid/app/Activity;
#v0=(Reference,Landroid/app/Activity;);
if-eqz v6, :cond_3
:goto_1
#v2=(Boolean);
const/4 v4, 0x0
.line 75
#v4=(Null);
new-instance v5, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;
#v5=(UninitRef,Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;);
invoke-direct {v5, p0, v7}, Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;-><init>(Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM;Ljava/lang/String;)V
.line 74
#v5=(Reference,Lcom/glu/plugins/glucn/AGlucnTools/IAP/SDKs/CM/GlucnIap_CM$2;);
invoke-static/range {v0 .. v5}, Lcn/cmgame/billing/api/GameInterface;->doBilling(Landroid/content/Context;ZZLjava/lang/String;Ljava/lang/String;Lcn/cmgame/billing/api/GameInterface$IPayCallback;)V
goto :goto_0
:cond_3
#v2=(Null);v4=(Reference,[Ljava/lang/Object;);
move v2, v1
#v2=(One);
goto :goto_1
.end method
.method public GetSdkName()Ljava/lang/String;
.locals 1
.prologue
.line 26
const-string v0, "cm"
#v0=(Reference,Ljava/lang/String;);
return-object v0
.end method
|