由于手游挂机需要充值月卡,手头比较紧,没有钱充值,所以研究了下月卡相关的内存特征代码,用按键精灵写了个开启的脚本,目前还是存在开启失败的情况,大概成功率在90%左右,如果开启失败就重启模拟器以后再开启进入游戏进行再次开启尝试,基本重启再开启成功率基本100%,这个开启月卡功能不包含月卡设置功能,具体代码片段如下:
Dim packageName = sys.GetFront() //获取当前进程包名 Dim monthFeature = {{"lv": 257},{"lv":11776, "offset":23}} //月卡特征 Function modifyMemory(feature, offset, dataType, targetDataType, defaultValue, targetValue) //TracePrint feature, offset, dataType, targetDataType, defaultValue, targetValue Dim result, result2 Dim featureAddr = False Dim t = TickCount() Dim targetBaseAddr = Sys.MemorySearch(packageName, True, addr, feature, dataType, 0, 100) TracePrint "总共搜索到"&UBound(targetBaseAddr)&"条内存数据,耗时:"&(TickCount()-t) If UBOUND(targetBaseAddr) > -1 Then For i = 0 To UBOUND(targetBaseAddr) Dim d2 = CInt(targetBaseAddr(i)) + offset Dim d3 = Hex(d2) result = Sys.MemoryRead(packageName, "0x"&d3, targetDataType) TracePrint "当前内存地址: 0x"&d3&", 内存中的值为: "&result If result = defaultValue Then TracePrint "找到特征地址,准备修改默认值..." featureAddr = "0x"&d3 result2 = Sys.MemoryWrite(packageName, featureAddr, targetValue, targetDataType) If result2 Then Exit For Else TracePrint "内存数据修改失败,请重启游戏或者稍后再次尝试!" End If End If Next Else TracePrint "未在内存中找到相关特征,请稍后重试!" End If modifyMemory = featureAddr End Function If ReadUIConfig("openMonthCard") Then TracePrint "开始开启月卡功能..." Dim curMonthStatus = Sys.MemoryRead(packageName, cfgTable["monthAddr"], "i32") If CInt(curMonthStatus) = 1 Or CInt(curMonthStatus) = 2 Then dialog_msg = dialog_msg & "月卡已开启," Else Dim monthAddr = modifyMemory(monthFeature, -4, "i32", "i32", "-1", "2") If monthAddr Then dialog_msg = dialog_msg & "月卡开启成功," TracePrint "月卡开启成功, 内存地址:" &monthAddr Else TracePrint "月卡开启失败, 清重启游戏或者稍后再试! " dialog_msg = dialog_msg & "月卡开启失败," End If End If End If
上述就是开启月卡的关键代码,了解的朋友肯定知道代码这块可以根据自己的想法来写,主要是特征比较难找,下面是我开启的一些截图可参考,后续看情况再分享一些其他功能内存特征代码。