 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Casmer How do I cheat?
Reputation: 0
Joined: 17 Mar 2010 Posts: 4
|
Posted: Wed Mar 17, 2010 11:56 am Post subject: alloc doesn't work with assembler code |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25814 Location: The netherlands
|
Posted: Wed Mar 17, 2010 12:33 pm Post subject: |
|
|
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 |
|
 |
Casmer How do I cheat?
Reputation: 0
Joined: 17 Mar 2010 Posts: 4
|
Posted: Wed Mar 17, 2010 1:07 pm Post subject: |
|
|
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 |
|
 |
Aqua Regia Advanced Cheater
Reputation: 0
Joined: 12 May 2009 Posts: 51 Location: Sweden
|
Posted: Wed Mar 17, 2010 1:32 pm Post subject: |
|
|
| 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 |
|
 |
Casmer How do I cheat?
Reputation: 0
Joined: 17 Mar 2010 Posts: 4
|
Posted: Wed Mar 17, 2010 1:35 pm Post subject: |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25814 Location: The netherlands
|
Posted: Wed Mar 17, 2010 2:13 pm Post subject: |
|
|
| 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 |
|
 |
Casmer How do I cheat?
Reputation: 0
Joined: 17 Mar 2010 Posts: 4
|
Posted: Wed Mar 17, 2010 2:19 pm Post subject: |
|
|
| thanks, it works =)
|
|
| Back to top |
|
 |
|
|
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
|
|