View previous topic :: View next topic |
Author |
Message |
HyggeAlien How do I cheat? Reputation: 0
Joined: 18 Nov 2021 Posts: 6
|
Posted: Sun Nov 28, 2021 3:10 pm Post subject: Help at code injection |
|
|
Why wont this script run. The script should check if a value is greater than 3, if it is, it should just set the address which the pointer points to, to 3, and if the value is equal or less than 3, it should set the address which the pointer points to the actual value:
Code: |
[Enable]
alloc(newmem,2048,02A451A8)
label(returnhere)
label(originalcode)
label(exit)
newmem:
CMP xmm0, 0x3
jg originalcode:
mov [rcx+rbx],3
originalcode:
vmovsd [rcx+rbx],xmm0
exit:
jmp returnhere
02A451A8:
jmp newmem
returnhere:
[Disable]
dealloc(newmem)
02A451A8:
vmovsd [rcx+rbx],xmm0
//Alt: db C5 FB 11 04 19
|
I get an error: Quote: | Error in line 9 (CMP xmm0, 0x3):This instruction can't be compiled |
Basically I want to check if xmm0 is greater than the decimal number 3 (hexadecimal 3).
Thanks in advance.
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Sun Nov 28, 2021 4:31 pm Post subject: |
|
|
You're trying to compare a float register with a hexadecimal value. It would be better to see the instructions of the disassembly window to give better advice on how to resolve your script; although, it wouldn't be such a bad idea to do some reading on ASM x86/x64. It is crucial to understand at least the basics before embarking on your journey hacking games.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4297
|
Posted: Sun Nov 28, 2021 4:36 pm Post subject: |
|
|
There is no instruction that compares an xmm register with an immediate value.
Integers and doubles are two different data types. You can't just do this:
(I guess you could, but the double value would be really small and not 3.0)
This will work:
Code: | alloc(mynumber,8)
mynumber:
dq (double)3.0
newmem:
vmaxsd xmm0,xmm0,[mynumber]
vmovsd [rcx+rbx],xmm0 |
You might want to use an aobscan instead since the address of the injection point looks like it will change when the game is restarted.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
HyggeAlien How do I cheat? Reputation: 0
Joined: 18 Nov 2021 Posts: 6
|
Posted: Tue Nov 30, 2021 3:22 pm Post subject: |
|
|
ParkourPenguin wrote: | There is no instruction that compares an xmm register with an immediate value.
Integers and doubles are two different data types. You can't just do this:
(I guess you could, but the double value would be really small and not 3.0)
This will work:
Code: | alloc(mynumber,8)
mynumber:
dq (double)3.0
newmem:
vmaxsd xmm0,xmm0,[mynumber]
vmovsd [rcx+rbx],xmm0 |
You might want to use an aobscan instead since the address of the injection point looks like it will change when the game is restarted. |
Where would all this code go? Where would cmp be?
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4297
|
Posted: Tue Nov 30, 2021 3:34 pm Post subject: |
|
|
You don't need the cmp. vmaxsd writes the max of the two source operands to the destination operand.
alloc goes with the other alloc (don't forget the dealloc in the disable section), initialization of the alloc's memory can go almost anywhere in the enable section (above newmem is fine), and newmem is just newmem. I did forget the jmp at the end of newmem but that should be obvious.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
HyggeAlien How do I cheat? Reputation: 0
Joined: 18 Nov 2021 Posts: 6
|
Posted: Tue Nov 30, 2021 4:21 pm Post subject: |
|
|
ParkourPenguin wrote: | You don't need the cmp. vmaxsd writes the max of the two source operands to the destination operand.
alloc goes with the other alloc (don't forget the dealloc in the disable section), initialization of the alloc's memory can go almost anywhere in the enable section (above newmem is fine), and newmem is just newmem. I did forget the jmp at the end of newmem but that should be obvious. |
The max value which is ever set is 2.58 for some reason, but that doesn't matter, since I don't want the largest value of the two, I want the smallest. If it's larger than 3, I want to set it to 3. I tried vminsd and minsd instead, both gives an error when trying to compile.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4297
|
Posted: Tue Nov 30, 2021 7:32 pm Post subject: |
|
|
In that case, the correct thing to do is to change vmaxsd to vminsd.
Looks like CE can't assemble vminsd for whatever reason. I guess the easiest workaround is to forego AVX:
Code: | newmem:
minsd xmm0,[mynumber]
movsd [rcx+rbx],xmm0
jmp return |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
|