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 


Whats wrong with this code?

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

Joined: 28 Jan 2014
Posts: 160

PostPosted: Tue Dec 09, 2014 1:58 pm    Post subject: Whats wrong with this code? Reply with quote

hi i really cant figure out that what is wrong with this code:
any idea?
Code:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
mov eax,[ebx+00000480]
mov ecx,#2
div ecx
add [ebx+00000480],eax

originalcode:
//sub [ebx+00000480],eax

exit:
jmp returnhere

"Tutorial-i386.exe"+24FFB:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"Tutorial-i386.exe"+24FFB:
sub [ebx+00000480],eax
//Alt: db 29 83 80 04 00 00

_________________
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue Dec 09, 2014 5:54 pm    Post subject: This post has 1 review(s) Reply with quote

Probably because you altered value of ECX and EDX registers - info.

Anyway, why DIV? This would be better

Code:
[ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here
mov eax,[ebx+00000480]
sar eax,1
add [ebx+00000480],eax

originalcode:
//sub [ebx+00000480],eax

exit:
jmp returnhere

"Tutorial-i386.exe"+24FFB:
jmp newmem
nop
returnhere:




[DISABLE]
dealloc(newmem)
"Tutorial-i386.exe"+24FFB:
sub [ebx+00000480],eax
//Alt: db 29 83 80 04 00 00

_________________
Back to top
View user's profile Send private message MSN Messenger
Nemexia55
Expert Cheater
Reputation: 0

Joined: 28 Jan 2014
Posts: 160

PostPosted: Wed Dec 10, 2014 10:27 am    Post subject: Reply with quote

Oh Thanks for answering:
i had to do this:

Code:
newmem:
access
mov eax,[ebx+00000480]
mov edx,#00
mov ecx,#2
div ecx
add [ebx+00000480],eax

And what is this code's function?

Code:
mov eax,[ebx+00000480]
sar eax,1
add [ebx+00000480],eax

_________________
Back to top
View user's profile Send private message
zm0d
Master Cheater
Reputation: 7

Joined: 06 Nov 2013
Posts: 423

PostPosted: Wed Dec 10, 2014 10:50 am    Post subject: Reply with quote

sar stands for Shift Arithmetic Right , which simply moves the bits of the value in EAX by 1 to the right (the number after the comma)... this is a fast way to divide a value by 2^x, where x stands for the right operand.

sal is the opponent to sar. It multiplies a value in a register with 2^x.
Back to top
View user's profile Send private message
Nemexia55
Expert Cheater
Reputation: 0

Joined: 28 Jan 2014
Posts: 160

PostPosted: Wed Dec 10, 2014 1:21 pm    Post subject: Reply with quote

mgr.inz.Player wrote:

Anyway, why DIV? This would be better


because i can divide it by other numbers Smile

_________________
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Dec 10, 2014 5:50 pm    Post subject: Reply with quote

For that, you should use something like this:

Code:
push eax
push ecx
push edx



mov eax,[ebx+00000480]
mov ecx,#2

cdq
idiv ecx

add [ebx+00000480],eax



pop edx
pop ecx
pop eax

_________________
Back to top
View user's profile Send private message MSN Messenger
Nemexia55
Expert Cheater
Reputation: 0

Joined: 28 Jan 2014
Posts: 160

PostPosted: Thu Dec 11, 2014 2:59 am    Post subject: sorry Reply with quote

sorry i ask again but what are these?
i'm somehow beginner in assembly...
i understand the whole code except this part:


Code:
cdq
idiv ecx


i mean what is
Code:
cdq


and what's the difference between
Code:
idiv

and
Code:
div

_________________
Back to top
View user's profile Send private message
zm0d
Master Cheater
Reputation: 7

Joined: 06 Nov 2013
Posts: 423

PostPosted: Thu Dec 11, 2014 4:55 am    Post subject: Reply with quote

www.cs.virginia.edu/~evans/cs216/guides/x86.html

Explains it pretty good IMO.
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