 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
vergilganesh Expert Cheater
Reputation: 0
Joined: 01 Jul 2013 Posts: 134 Location: India
|
Posted: Sun Sep 01, 2013 10:02 am Post subject: Problem with a code |
|
|
I have a problem with a code which controls value of increasing and decreasing in the same code..
the written code is-----------------
| Code: |
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048) //2kb should be enough
alloc(val,12)
label(returnhere)
label(originalcode)
label(exit)
val:
dd (float)0.0
dd (float)25.0
newmem:
push eax
movss [val+8],xmm0
cmp [val+8],00000
fnstsw ax
sahf
jb originalcode
//mulss xmm0,[val+4]
addss xmm1,xmm0
originalcode:
movss [esi+00014DAC],xmm1
exit:
pop eax
jmp returnhere
"DevilMayCry4_DX9.exe"+3BB973:
jmp newmem
nop
nop
nop
nop
nop
nop
nop
returnhere:
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"DevilMayCry4_DX9.exe"+3BB973:
addss xmm1,xmm0
movss [esi+00014DAC],xmm1
//Alt: db F3 0F 58 C8 F3 0F 11 8E AC 4D 01 00
|
But this is not works. What was the problem in my code----
|
|
| Back to top |
|
 |
Gniarf Grandmaster Cheater Supreme
Reputation: 43
Joined: 12 Mar 2012 Posts: 1285
|
Posted: Sun Sep 01, 2013 7:23 pm Post subject: Re: Problem with a code |
|
|
The main problem was that fnstsw is only meaningful after a fcomp, not a regular cmp. If you wanted to use fcomp you'd do something like:
| Code: | fld dword [val+8]
fldz //loads zero
fcompp //compares and pops zero & [val+8] out of the float stack
//you could say this line does FloatCompare 0.0,dword [val+8]
fnstsw ax
sahf
jb originalcode | But when you're dealing with xmm registers there is a much easier way (see code below).
Other remarks concerning your script:
-dword [val] is not used.
-dealloc(val) is missing.
-When you do alloc(Whatever,SomeSize), you always get at least 1024 bytes that's how windows works, so if you do alloc(val,12) and get another buffer for your code you're wasting quite some memory. I suggest only using one alloc per script.
-I recommend putting a label per variable instead of using [val+0/4/8/...] because the day you have like [val+20] and you decide to remove [val+4], updating your script is going to be tedious.
Partly rewritten script: | Code: | [ENABLE]
alloc(newmem,2048) //2kb should be enough
//code
label(returnhere)
label(originalcode)
//data
label(Zero)
label(Multiplier)
"DevilMayCry4_DX9.exe"+3BB973:
jmp newmem
nop
nop
nop
nop
nop
nop
nop
returnhere:
newmem:
comiss xmm0,dword [Zero] //compare xmm register with a float constant
jb short originalcode //prefer short jump when the target is less than 128 bytes away
//use ja/jb after a comiss, not jg/jl.
//mulss xmm0,[Multiplier]
addss xmm1,xmm0
originalcode:
movss [esi+00014DAC],xmm1
jmp returnhere
Zero:
dd (float)0.0
Multiplier:
dd (float)25.0
[DISABLE]
dealloc(newmem)
"DevilMayCry4_DX9.exe"+3BB973:
addss xmm1,xmm0
movss [esi+00014DAC],xmm1
//Alt: db F3 0F 58 C8 F3 0F 11 8E AC 4D 01 00 |
_________________
DO NOT PM me if you want help on making/fixing/using a hack. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|