Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help at code injection

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
HyggeAlien
How do I cheat?
Reputation: 0

Joined: 18 Nov 2021
Posts: 6

PostPosted: Sun Nov 28, 2021 3:10 pm    Post subject: Help at code injection Reply with quote

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
View user's profile Send private message
LeFiXER
Grandmaster Cheater
Reputation: 4

Joined: 02 Sep 2011
Posts: 511
Location: 0x90

PostPosted: Sun Nov 28, 2021 4:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 100

Joined: 06 Jul 2014
Posts: 3174

PostPosted: Sun Nov 28, 2021 4:36 pm    Post subject: Reply with quote

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:
Code:
mov [rcx+rbx],3
(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
View user's profile Send private message
HyggeAlien
How do I cheat?
Reputation: 0

Joined: 18 Nov 2021
Posts: 6

PostPosted: Tue Nov 30, 2021 3:22 pm    Post subject: Reply with quote

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:
Code:
mov [rcx+rbx],3
(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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 100

Joined: 06 Jul 2014
Posts: 3174

PostPosted: Tue Nov 30, 2021 3:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
HyggeAlien
How do I cheat?
Reputation: 0

Joined: 18 Nov 2021
Posts: 6

PostPosted: Tue Nov 30, 2021 4:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 100

Joined: 06 Jul 2014
Posts: 3174

PostPosted: Tue Nov 30, 2021 7:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites