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 


Understanding Assembly

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

Joined: 07 May 2015
Posts: 3

PostPosted: Sat May 09, 2015 3:45 pm    Post subject: Understanding Assembly Reply with quote

I've been studying ASM, and i'm having a hard time understanding this.

Code:
MOV EBX, [EBP+08]
MOV [EBX], 110
ADD EBX, 2
MOV [EBX], 123

would the results be ebp+8 = 110 and ebp+10 = 123.

if so, this code bellow sets ebp-04 to 0 then tests if its lower than 100, which doesnt make any sense
Code:
push ebp
mov ebp,esp
sub esp,08
mov [ebp-04],00000000
cmp dword ptr [ebp-04],64
jnl 182394


also, a "mov ebp,esp" sets esp's value to ebp, or its memory address?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat May 09, 2015 5:13 pm    Post subject: Reply with quote

EBP+08 equals a pointer address.
EBX now equals that address.
So the value at that address is changed to 110.
Adding 2 to EBX then moves that pointer up 2 bytes.
This means you are overwriting the last 2 bytes of the previous 4-byte '110' value you just moved.

So, whatever address that was, you just wrote the following 6-bytes:
6E 00 7B 00 00 00

You should also note that "ebp+10" is a hex 10, decimal 16.
So by adding 2, you should have expected "ebp+a".
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 11, 2015 7:41 am    Post subject: Reply with quote

If we take a look at the second code snippet you posted (the one which sets ebp-4 to zero and than check its value against 100).
you're having problem to understand it because it's not the whole code that you're looking at.
the compiler usually does that kind of thing when a loop is about to happen, if you think about it, the ebp-4 is a local variable that represent the loop counter (for example the variable i in high level language), it starts from 0 and than immediately compared to 100 to see if it passed that value.
what you cannot see which is further that code, is the rest of the code that happen inside the loop (you can notice the jnl <some address> line which jump if it is lower than 100)

the part of
Code:

mov ebp,esp

is a prologue of functions that basically saves the last stack frame of the caller (but that's more advanced)

Hope you understand that Smile

_________________
Stylo
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 programming 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