Page 1 of 1

Can't compile code

Posted: Tue Jan 25, 2022 9:17 pm
by Stagnant
I was trying to hack my first game, and i chose a game called recettear and i wanted to create an xp multiplier code but i couldn't do that because CE would throw an error in the lines that i edited and i don't know why. Here's the original code:

Code: Select all

originalcode:
add dword ptr [edi+44],0A
push 02
And here's how it turned out after i added my multiplier:

Code: Select all

[ENABLE]
alloc(newmem,2048)
alloc(Multiplier)
label(returnhere)
label(originalcode)
label(exit)
registersymbol(Multiplier)

Multiplier:
dd #1

newmem:
imul [Multiplier], 0A

originalcode:
add dword ptr [edi+44],[Multiplier]
push 02

exit:
jmp returnhere

"recettear.exe"+8CD61:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
dealloc(newmem)
dealloc(Multiplier)
unregistersymbol(Multiplier)
"recettear.exe"+8CD61:
add dword ptr [edi+44],0A
push 02
When i try to save to current cheat table it gives me the Can't compile error, now i checked what dword ptr means since it was something i've never seen in the tutorial series that i watched i think i understood what it means and i think it was the problem so i removed it and it still didn't work, how do i fix this?

Re: Can't compile code

Posted: Tue Jan 25, 2022 10:14 pm
by LeFiXER
Can't guarantee it will work, but I made some changes which technically should work although I don't know how you've come to select this location.

Code: Select all

[ENABLE]
// Ideally, you'll want to use an AOB injection so that the location can be found with subsequent restarts of the game.
alloc(newmem,2048)
alloc(Multiplier,4) // You didn't allocate any bytes for your stored value
label(returnhere)
label(originalcode)
label(exit)
registersymbol(Multiplier)

Multiplier:
dd 0

newmem:
push ebx 
mov ebx,[Multiplier]
imul ebx, 0A
pop ebx

originalcode:
add dword ptr [edi+44],ebx
push 02

exit:
jmp returnhere

"recettear.exe"+8CD61:
jmp newmem
nop
returnhere:

[DISABLE]

dealloc(Multiplier)  // Important to deallocate the allocated memory
dealloc(newmem)
If you add an address manually to the table with the address: Multiplier, you should be able to set the value to one of your choosing.

Re: Can't compile code

Posted: Tue Jan 25, 2022 10:36 pm
by Stagnant
LeFiXER wrote:
Tue Jan 25, 2022 10:14 pm
Can't guarantee it will work, but I made some changes which technically should work although I don't know how you've come to select this location.

Code: Select all

[ENABLE]
// Ideally, you'll want to use an AOB injection so that the location can be found with subsequent restarts of the game.
alloc(newmem,2048)
alloc(Multiplier,4) // You didn't allocate any bytes for your stored value
label(returnhere)
label(originalcode)
label(exit)
registersymbol(Multiplier)

Multiplier:
dd 0

newmem:
push ebx 
mov ebx,[Multiplier]
imul ebx, 0A
pop ebx

originalcode:
add dword ptr [edi+44],ebx
push 02

exit:
jmp returnhere

"recettear.exe"+8CD61:
jmp newmem
nop
returnhere:

[DISABLE]

dealloc(Multiplier)  // Important to deallocate the allocated memory
dealloc(newmem)
If you add an address manually to the table with the address: Multiplier, you should be able to set the value to one of your choosing.
That worked as intended thanks, i perfectly understand what you did there it makes sense but why didn't my version of the code not work do you have any clue?
Note: When i first wrote the code i didn't forget to allocate the 4 bytes so it has nothing to do with that.

Re: Can't compile code

Posted: Tue Jan 25, 2022 11:10 pm
by LeFiXER
Stagnant wrote:
Tue Jan 25, 2022 10:36 pm
That worked as intended thanks, i perfectly understand what you did there it makes sense but why didn't my version of the code not work do you have any clue?
Note: When i first wrote the code i didn't forget to allocate the 4 bytes so it has nothing to do with that.
You're welcome :). It's to my understanding that the imul instruction requires more instructions than a single line to actually compute the arithmetic, so we use a register to hold the calculated sum and then move that value to the intended place.