|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
buyx86 Advanced Cheater Reputation: 0
Joined: 10 May 2011 Posts: 82 Location: Philippines
|
Posted: Sun Apr 28, 2024 9:27 am Post subject: Cannot save address |
|
|
I want to save the value of an eax to use as a base address. But I can't get it to work with alloc. If I use globalalloc, it will work, but my problem is that I won't be able to deactivate my main AOB script. Unless I unregister it, I think. But that would not deallocate the used memory. This is a part of my code related to my issue.
Code: |
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
//AOB Scans
aobscanmodule(INJECT1,Sys43VM.DLL,89 34 88 8B 87 10 02 00 00)
aobscanmodule(INJECT2,Sys43VM.DLL,03 C8 13 FA 85 FF)
aobscanmodule(INJECT3,Sys43VM.DLL,89 01 B0 01 5F 5E 83 C4 0C C3 68 F0)
aobscanmodule(INJECT4,Sys43VM.DLL,89 14 98 8B 81 10 02 00 00)
//==============================================================================
//Allocating memory
....
alloc(newmem4,$1000)
alloc(pBase,4)
alloc(enableMinGold,4)
alloc(setMinGold,4)
//==============================================================================
//Declaration
....
label(checkMinGold)
label(code4)
label(return4)
//==============================================================================
//Variables
....
pBase:
dd 0
enableMinGold:
dd 0
setMinGold:
dd (int)50000
//==============================================================================
....
//Code4
newmem4:
cmp [rsp+34],F8D8F28
je checkMinGold
mov [pBase],eax <<===this is to save the EAX to pBase
jmp checkMinGold
checkMinGold:
cmp [enableMinGold],0
jz code4
cmp ebx,41
jne code4
cmp [eax+24],6A4
jne code4
cmp edx,[setMinGold]
jg code4
mov edx,[setMinGold]
jmp code4
code4:
mov [eax+ebx*4],edx
mov eax,[ecx+00000210]
jmp return4
INJECT4:
jmp newmem4
nop 4
return4:
registersymbol(INJECT4)
//==============================================================================
//Registering
....
//INJECT4
registersymbol(pBase)
registersymbol(enableMinGold)
registersymbol(setMinGold)
//==============================================================================
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
//Restoring original code
....
INJECT4:
db 89 14 98 8B 81 10 02 00 00
//==============================================================================
//Unregistering
....
unregistersymbol(pBase)
unregistersymbol(enableMinGold)
unregistersymbol(setMinGold)
unregistersymbol(INJECT4)
//==============================================================================
//Deallocating memory
....
dealloc(pBase)
dealloc(enableMinGold)
dealloc(setMinGold)
dealloc(newmem4) |
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 147
Joined: 06 Jul 2014 Posts: 4518
|
Posted: Sun Apr 28, 2024 11:38 am Post subject: |
|
|
`globalalloc` allocates memory once and registers the symbol. That memory will never be deallocated. Since the memory leak only happens a single time, it isn't really a problem.
Is that process 64-bit or 32-bit? You're using both when addressing memory locations. If it's 64-bit, then use 64-bit registers and make the allocs 8 bytes. There would also be other problems like the allocs not being near the injection points (14-byte jumps).
buyx86 wrote: | Code: | jmp checkMinGold
checkMinGold:
...
jmp code4
code4: |
| Useless `jmp`s
I don't see anything else wrong in the code you posted. What specifically do you mean by you "can't get it to work"? Maybe it's something simple like you forgot to do whatever you need to do in-game to make the game run the code, or the symbol was already registered to a globalalloc and you forgot to restart CE. Maybe it's something in the code you omitted. Hard to say.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
buyx86 Advanced Cheater Reputation: 0
Joined: 10 May 2011 Posts: 82 Location: Philippines
|
Posted: Sun Apr 28, 2024 11:47 am Post subject: |
|
|
It's a 32-bit process. I forgot to change that RSP to ESP. But I've also changed it to ESP and also moved that code around like here:
Code: |
checkMinGold:
cmp [enableMinGold],0
jz code4
cmp ebx,41
jne code4
cmp [eax+24],6A4
jne code4
mov [pBase],eax <<===moved it here
cmp edx,[setMinGold]
jg code4
mov edx,[setMinGold]
jmp code4
|
so that it gets fired up when gold changes its value but it always returns zero. That's not the case when I use globalalloc though.
edit: that extra jump is just preparation for when I need to add another set of codes that uses the same AOBscan.
edit2: I got an idea from what you said and tried to restart CE and the game. I think I almost got this.
|
|
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
|
|