You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cheat Engine脚本开发:CMP、DIV、MUL指令使用问题求助

Cheat Engine脚本编写疑问:攻防增益功能实现问题

我上个月零基础开始学习使用Cheat Engine编写脚本,目标是实现攻防增益功能:让玩家受到的伤害除以某个值,敌人受到的伤害乘以某个值。

在实践中,我对乘法、除法和比较指令的使用存在困惑,具体情况如下:

  • 比较操作:最初使用cmp esi+B4,0无效,尽管扫描到的是4字节值,但改用cmp byte ptr [esi+B4],0后生效
  • 乘法操作:首次尝试使用imul指令就成功了,按4字节逻辑处理
  • 除法操作:使用idiv、fdiv、div均无效,按逻辑idiv应与imul一样正常工作

我有以下三个问题:

  1. 应使用什么指令来对edi或eax执行除法操作以实现功能?
  2. 为何扫描显示是4字节值,但cmp byte ptr [esi+B4],0能生效?
  3. 此场景下是否有更合适的指令可用?

附相关代码及细节

当前注入代码(部分生效)

[ENABLE]

//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here
cmp byte ptr [esi+B4],0
jne originalcode
idiv edi,#3
mov eax,edi
neg eax
cmp ebp,eax
jmp exit
originalcode:
imul edi,#3
mov eax,edi
neg eax
cmp ebp,eax

exit:
jmp returnhere

"koa.exe"+B8FF87:
jmp newmem
nop
returnhere:

[DISABLE]

//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"koa.exe"+B8FF87:
db 8B C7 F7 D8 3B E8
//mov eax,edi
//neg eax
//cmp ebp,eax

其他细节

我先找到了生命值,发现玩家与敌人的生命值是共享的。指令lea ecx,[edi+ebp]用于从ebp(生命值)中减去edi(伤害,负数),结果存入ecx,之后ecx会被赋值为当前生命值。在lea处注入代码无效,于是我移到neg指令前修改edi,功能部分生效,但除法操作仍无法正常工作。

无效的注入代码(lea处注入)

[ENABLE]

//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
lea ecx,[edi+ebp]
mov [esi+48],ecx

exit:
jmp returnhere

"koa.exe"+B8FF8F:
jmp newmem
nop
returnhere:

[DISABLE]

//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"koa.exe"+B8FF8F:
db 8D 0C 2F 89 4E 48
//lea ecx,[edi+ebp]
//mov [esi+48],ecx

内容的提问来源于stack exchange,提问作者cosmin_kzyahoocom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 12:03:19