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 


Compare value in assembly

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
kagato1980
Cheater
Reputation: 0

Joined: 30 Oct 2020
Posts: 30
Location: The netherlands

PostPosted: Tue Nov 03, 2020 3:41 pm    Post subject: Compare value in assembly Reply with quote

I have the following script:

Code:

[ENABLE]

aobscan(INJECT,89 87 A0 00 00 00 8B 47 64) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  push ebx
  mov ebx,[edi+000000A4]
  sub ebx, 50
  mov [edi+000000A0],ebx
  pop ebx
  jmp return

oldcode:
  db 89 87 A0 00 00 00

INJECT:
  jmp newmem
  nop
return:
registersymbol(INJECT)

[DISABLE]

INJECT:
  db 89 87 A0 00 00 00

unregistersymbol(INJECT)
dealloc(newmem)


This script finds a max value, then replaces the input value to the max value minus 50 (hex).

But for each input, I want to check if our current value is 50 hex away from the end value, and if it is, skip the replacement. Otherwise, the input will always be set to max-50, and the max will never be reached.

So, I think something like this needs to be added at the top inside code:
Code:

cmp [edi+000000A0], [edi+000000A4]-50
jle oldcode


I suppose that comparison needs to happen through some temp values in registers, can anyone help?
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Wed Nov 04, 2020 3:39 am    Post subject: Reply with quote

Code:
[ENABLE]
aobscan(INJECT,89 87 A0 00 00 00 8B 47 64) // should be unique
registersymbol(INJECT)

alloc(newmem,$1000)
label(originalcode)
label(return)

newmem:
push ebx
mov ebx,[edi+a4]
sub ebx,50
cmp [edi+a0],ebx
jle originalcode
   mov eax,ebx

originalcode:
pop ebx // clean up
mov [edi+A0],eax
jmp return

INJECT:
  jmp newmem
  nop
return:

[DISABLE]

INJECT:
  db 89 87 A0 00 00 00

unregistersymbol(INJECT)
dealloc(newmem)

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
kagato1980
Cheater
Reputation: 0

Joined: 30 Oct 2020
Posts: 30
Location: The netherlands

PostPosted: Thu Nov 05, 2020 3:45 am    Post subject: Reply with quote

Thanks, I managed to get it to work with a little change:
Code:

code:
  push ebx
  mov ebx,[edi+A4]
  sub ebx, 50
  cmp eax,ebx
  jge originalcode
  mov eax,ebx

originalcode:
  pop ebx
  mov [edi+A0],eax
  jmp return
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