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 


alloc doesn't work with assembler code

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

Joined: 17 Mar 2010
Posts: 4

PostPosted: Wed Mar 17, 2010 11:56 am    Post subject: alloc doesn't work with assembler code Reply with quote

I've got a code which should create [numArray+04] Lifepoints.
but it doesn't work, because of this error: "Error in line 25 (mov [eax+edi*4+0c],[00000000+04]): This instruction can't be compiled"
Why are there eight 0 instead of the pointer of numArray?

Here's the code:
Code:
registersymbol(numArray) // doesn't matter if this lines there or not
alloc(numArray,8)
alloc(newmem,512)
label(returnhere)
label(originalcode)
label(exit)

02732E37:
jmp newmem
nop
nop
nop
nop
nop
nop
nop
nop
nop
returnhere:

newmem:
cmp edi, [numArray]
jae 027341f2
mov [eax+edi*4+0c],[numArray+04]

originalcode:
//cmp edi,[eax+08]
//jae 027341f2
//mov [eax+edi*4+0c],edx

exit:
jmp returnhere


if it won't work, I could use the 9 nops for the two ints.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25814
Location: The netherlands

PostPosted: Wed Mar 17, 2010 12:33 pm    Post subject: Reply with quote

replace
Code:

mov [eax+edi*4+0c],[numArray+04]

with
Code:

push ebx
mov ebx,[numArray+4]
mov [eax+edi*4+0c],ebx
pop ebx

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Casmer
How do I cheat?
Reputation: 0

Joined: 17 Mar 2010
Posts: 4

PostPosted: Wed Mar 17, 2010 1:07 pm    Post subject: Reply with quote

Why does this work?

edit: the code compiles but although I've set it's value to 5000 my players lp have been set to 0

Code:
globalAlloc(lifePoints,4)
alloc(newmem,512)
label(returnhere)
label(exit)

mov [lifePoints], 1388 // this line doesn't work, if I set it later in the CE the code works as thought

02836D37:
jmp newmem
nop
nop
nop
nop
returnhere:

newmem:
mov edx, [lifePoints]
//cmp edi,[eax+08]
//jae 028380f2


Last edited by Casmer on Wed Mar 17, 2010 1:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
Aqua Regia
Advanced Cheater
Reputation: 0

Joined: 12 May 2009
Posts: 51
Location: Sweden

PostPosted: Wed Mar 17, 2010 1:32 pm    Post subject: Reply with quote

Casmer wrote:
Why does this work?

Code:
globalAlloc(lifePoints,4)
alloc(newmem,512)
label(returnhere)
label(exit)

mov [lifePoints], 1388

02836D37:
jmp newmem
nop
nop
nop
nop
returnhere:

newmem:
mov edx, [lifePoints]
//cmp edi,[eax+08]
//jae 028380f2


You push the current value of ebx to the stack, you change the value of ebx to [numArray+4], then you set [eax+edi*4+0c] to ebx, and then you pop ebx to get the original value back from the stack.

And about your code, you change edx to 5000, not the address that edx points to.


Last edited by Aqua Regia on Wed Mar 17, 2010 1:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
Casmer
How do I cheat?
Reputation: 0

Joined: 17 Mar 2010
Posts: 4

PostPosted: Wed Mar 17, 2010 1:35 pm    Post subject: Reply with quote

yes, that is easy.

but what is the difference?
can a mov only get one pointer parameter with offset?

Quote:
And about your code, you change edx to 5000, not the address that edx points to

the lower code works only the mov where the lifePoints should be set don't work.

So, what's wrong with: mov [lifePoints], 1388
it doesn't mov 5000 into lifePoints, so lp doesn't get set.


Last edited by Casmer on Wed Mar 17, 2010 2:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25814
Location: The netherlands

PostPosted: Wed Mar 17, 2010 2:13 pm    Post subject: Reply with quote

Quote:

Why does this work?


Originally you had
Code:

02732E37:
jmp newmem
nop
nop
nop
nop
nop
nop
nop
nop
nop

so 14 bytes where replaced, including the original code of "mov [eax+edi*4+0c],edx"

the new code:
Code:

02836D37:
jmp newmem
nop
nop
nop
nop
returnhere:

doesn't overwrite "mov [eax+edi*4+0c],edx" so when you return it will write the value stroed in edx into that address

as for:
Code:

mov [lifePoints], 1388

not working that is because you're writing it to an unspecified address and thus is never executed by the game

If you want to initialize it, you must use
Code:

lifePoints:
dd 1388


Quote:

can a mov only get one pointer parameter with offset?

Yes, the cpu can only handle instructions with one address and one offset, 2 offsets, 1 offset or 1 address , not 2 addresses

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Casmer
How do I cheat?
Reputation: 0

Joined: 17 Mar 2010
Posts: 4

PostPosted: Wed Mar 17, 2010 2:19 pm    Post subject: Reply with quote

thanks, it works =)
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