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 


How to divide a variable by 10 in assembly?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
martinezz123
Newbie cheater
Reputation: 0

Joined: 17 Jun 2018
Posts: 12

PostPosted: Thu Aug 23, 2018 7:38 am    Post subject: How to divide a variable by 10 in assembly? Reply with quote

Hi.
I'm new in assembly.
I understand general structure and basic functions: mov, test, sub...

While trying to cheat Absolver health loss I've come to an Idea to divide the amount of health that's being substracted while being hit, by a value (let's say by 10).
I've found an exact code which executes while being hit. It's like this:

Code:
subss xmm0,xmm6
movss [rbx+000000F4],xmm0

I'm trying to exchange this code by mine own. I've used code injection template and it looks like this:

Code:
alloc(newmem,2048,"Absolver-Win64-Shipping.exe"+25EBCA)
label(returnhere)
label(originalcode)
label(exit)

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

originalcode:
subss xmm0,xmm6
movss [rbx+000000F4],xmm0

exit:
jmp returnhere

"Absolver-Win64-Shipping.exe"+25EBCA:
jmp newmem
[ENABLE]
subss xmm0,xmm6/10
movss [rbx+000000F4],xmm0
returnhere:

[DISABLE]
subss xmm0,xmm6
movss [rbx+000000F4],xmm0


The cheat engine says it's wrong.
Ok, I know.
I did it this way because I've seen other arithmetic operations in the code like for example:

Code:
mov [rbp+rcx*2+08],ax


So. The question is. How to divide the amount of health loss by a number (for ex. 10)?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 23, 2018 8:47 am    Post subject: Reply with quote

https://www.google.com/search?q=divide+number+by+10+x86+assembly
https://www.tutorialspoint.com/assembly_programming/assembly_arithmetic_instructions.htm

https://www.youtube.com/results?search_query=x86+asm+divide
https://www.youtube.com/watch?v=iuN7Tf0Q1Uw

edit: well, looking at the code it looks like you have to deal with floats, and surprisingly much like with integer, mov, sub, mul and div, the SSE float equivalents are movss, subss, mulss, and divss. And just like movss and subss, divss can take either two xmm registers or a register and a memory address with another float. so divss xmm0, [some address with float 10]

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
martinezz123
Newbie cheater
Reputation: 0

Joined: 17 Jun 2018
Posts: 12

PostPosted: Thu Aug 23, 2018 10:30 am    Post subject: Reply with quote

SO I have to div by an adress which contains 10.
But how to set this adress to be 10?

Would you mind fixing my code??
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 23, 2018 10:39 am    Post subject: Reply with quote

Code:
[ENABLE]
alloc(newmem,2048,"Absolver-Win64-Shipping.exe"+25EBCA)
label(returnhere)
label(originalcode)
label(exit)
label(somedata)

newmem:
  // assuming xmm0 is current health and xmm6 is amount of damage
  divss xmm6, [somedata] // divide damage by 10
originalcode:
  subss xmm0,xmm6
  movss [rbx+000000F4],xmm0
exit:
  jmp returnhere
somedata:
  dd (float)10
// still in newmem so can add arbitrary data which won't be executed as code since
// code flow would always lead to the jmp returnhere, and thus back to the main code

"Absolver-Win64-Shipping.exe"+25EBCA:
  jmp newmem
  // nop rest of movss bytes not overwritten by jmp newmem
  db 90 90 90 90 90 90 90
returnhere:

[DISABLE]
"Absolver-Win64-Shipping.exe"+25EBCA:
  subss xmm0,xmm6
  movss [rbx+000000F4],xmm0
dealloc(newmem)

_________________
https://github.com/FreeER/ has a few CE related repos


Last edited by FreeER on Thu Aug 23, 2018 1:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
martinezz123
Newbie cheater
Reputation: 0

Joined: 17 Jun 2018
Posts: 12

PostPosted: Thu Aug 23, 2018 12:56 pm    Post subject: Reply with quote

thank you!

---edit---
Shit. It divides the aomount of damage for everyoune: me and the opponents.
The same was when I fixed the amount of health - it fixed it for all the characters in the game.

How to split it?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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