传统修改阳光值的核心是找到 基址 + 偏移 的固定组合,但是往往基值不一定好找.
方法: 我们可以仅查询一层, 通过查询到谁修改了这个内存,然后使用hook跳转到我们的自定义代码域上, 然后把寄存器动态的值存到指定内存上, 最终读取这里值就是阳光的地址了

在游戏读取阳光值的关键指令处注入自定义汇编代码;
借助寄存器ESI + 已知偏移(0x5560)动态计算阳光值的实际内存地址;
将计算出的指针存入我们手动申请的内存区域,后续可直接调用该指针操作阳光值。
[ENABLE]
alloc(newmem, 2048)
alloc(sunptr, 128)
label(returnhere)
newmem:
pushad // 保护寄存器
mov eax, esi
add eax, 005560
mov [sunptr],eax
popad // 恢复寄存器
mov eax,[esi+00005560]
jmp returnhere
// 注入核心:修改原地址指令
"PlantsVsZombies.exe"+89825:
jmp newmem
nop //90
returnhere:
// 注册符号
registersymbol(newmem)
registersymbol(sunptr)
[DISABLE]
"PlantsVsZombies.exe"+89825:
mov eax,[esi+00005560]
unregistersymbol(newmem)
unregistersymbol(sunptr)
dealloc(newmem)
dealloc(sunptr)
种植call
[ENABLE]
alloc(g_thread,10)
createthread(g_thread)
g_thread:
pushad //压入全部寄存器
mov ecx, [6a9ec0] //ecx 32位通用寄存器
mov ecx, [ecx+768]
push -1
push 12 //植物id
mov eax,4 //y
push 0 //x
push ecx//ebp 会变,ecx
call 0040d120
popad
retn
[DISABLE]
//code from here till the end of the code will be used to disable the cheat