function MyAobScan(Bytes)
local StartAddress=0;
local EndAddress=0x00007fffffffffff;
local Scan = createMemScan();
Scan.OnlyOneResult=true;
Scan.firstScan(soExactValue, vtByteArray, rtTruncated, Bytes, "", StartAddress, EndAddress, "", fsmNotAligned, "", true, false, false, false);
Scan.waitTillDone();
jishu = jishu + 1
return Scan.getOnlyResult();
end
jishu = 1
以上为遍历模板,里面具体的函数用法未知,摸清楚了再优化试试。
jishu是计算修改次数。
local function yihuo(a,k)
local d5=0
local i = 31
local b = 2^i
while i>=0 do
d1 = math.modf(a/b)
d2 = math.modf(k/b)
d3 = math.abs(d1-d2)
d4 = d3*b
d5 = d4+d5
if d1 == 1 then
a=a-b
end
if d2 == 1 then
k=k-b
end
i=i-1
b=2^i
end
return d5
end
jishu = 1
--此上异或算法自定义写法
function xiugai(r1,r2,r3)
if f == nill then
print("这个值已经修改过了")
print("修改次数",jishu)
else
ym1 = string.format("%X",f)
writeFloat(ym1,r1)
ym2 = string.format("%X",f+4)
writeFloat(ym2,r2)
ym3 = string.format("%X",f+8)
writeFloat(ym3,r3)
t1 = readInteger(f)
t2 = readInteger(f+4)
t3 = readInteger(f+8)
ymfs1 = string.format("%X",f-88)
writeInteger(ymfs1,yihuo(t1,yhyz))
ymfs2 = string.format("%X",f-84)
writeInteger(ymfs2,yihuo(t2,yhyz))
ymfs3 = string.format("%X",f-80)
writeInteger(ymfs3,yihuo(t3,yhyz))
print("成功")
print("修改次数",jishu)
end
end
--定义修改脚本,方便多次修改。
f = MyAobScan("00 00 40 40 0A D7 23 3C 00 00")
xiugai(1,1,1)
--使用示范
单纯官网的函数写法,某些命名可能不规范或者使用局部变量会更好一点。不过对于我这个初学者来说就不必了。
下一步考虑将其优化为zzer的库函数写法,速度或者简便度都会好很多。也能防止抄袭。
接下来是GG修改器的部分成品
GG修改的lua适应性好像比CE的低不少,特别容易报错。无论是函数的设置还是变量的设置。
function xiugai(k1,k2,k3,t1,t2,t3)
gg.clearResults()
gg.searchNumber(tonumber(k1)..';'..tonumber(k2)..';'..tonumber(k3)..'::9',16)
aa = gg.getResults(10)
if #aa > 2 then
a3 = {{address = aa[1].address - 0X58,flags = 4}}
a2 = {{address = aa[1].address,flags = 16,value = t1}}
gg.setValues(a2)
a4 = {{address = a2[1].address,flags = 4}}
a3[1].value = tonumber(gg.getValues(a1)[1].value) ~ tonumber(gg.getValues(a4)[1].value)
gg.setValues(a3)
a3 = {{address = aa[2].address - 0X58,flags = 4}}
a2 = {{address = aa[2].address,flags = 16,value = t2}}
gg.setValues(a2)
a4 = {{address = a2[1].address,flags = 4}}
a3[1].value = tonumber(gg.getValues(a1)[1].value) ~ tonumber(gg.getValues(a4)[1].value)
gg.setValues(a3)
a3 = {{address = aa[3].address - 0X58,flags = 4}}
a2 = {{address = aa[3].address,flags = 16,value = t3}}
gg.setValues(a2)
a4 = {{address = a2[1].address,flags = 4}}
a3[1].value = tonumber(gg.getValues(a1)[1].value) ~ tonumber(gg.getValues(a4)[1].value)
gg.setValues(a3)
gg.toast('修改完成,无效请重试')
gg.clearResults()
else
gg.toast('搜不到数值')
gg.clearResults()
end
gg.clearResults()
end
主要是set getvalues,tonumber转化字符串,string.format 格式化进制防止乱码,…为连接码,异或~的用法等等等等。
gg.clearResults()
gg.setRanges(gg.REGION_C_ALLOC)
gg.searchNumber("0.1;0.8;1.5::16", gg.TYPE_FLOAT,false,gg.SIGN_EQUAL,0, -1)
gg.searchNumber("1.5", gg.TYPE_FLOAT,false,gg.SIGN_EQUAL,0,-1)
gg.sleep(100)
my=gg.getResults(1)
a1={{address=my[1].address+0x24,flags=16}}
q1=gg.getValues(a1)
gg.sleep(200)
gg.clearResults()
gg.setRanges(gg.REGION_C_ALLOC)
gg.searchNumber("0.1;1.2;1.5::16", gg.TYPE_FLOAT,false,gg.SIGN_EQUAL,0, -1)
gg.searchNumber("1.5", gg.TYPE_FLOAT,false,gg.SIGN_EQUAL,0,-1)
mys = gg.getResults(5)
b1={{address=mys[1].address+0x24,flags=16,freeze = true}}
--可以锁值的哟 用的比较少 备份一下
z1=gg.getValues(b1)
gg.copyMemory(q1[1].address, z1[1].address, 16)