 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
24quant42 Cheater
Reputation: 0
Joined: 19 Apr 2023 Posts: 34
|
Posted: Sun Dec 28, 2025 9:15 am Post subject: Why does GetModuleHandle return an invalid address? |
|
|
Who can explain why the GetModuleHandleA method returns the correct 8 byte address, and the movsxd line truncates the value by adding FFFFFFFF in front. As if making the number negative.
This is my script in AOB:
newmem:
cmp [isFirstRun],0
jne code
mov [isFirstRun],1
{$ccode}
(unsigned long long)GetModuleHandleA(0);
{$asm}
I should get an address like:
7F****EFCE22D2
but I get
FFFFFFFFEFCE22D2
it's all the fault of movsxd, which for some reason just breaks the RAX register, and it's not clear why it uses EAX and not RAX.
Can someone explain the reason and how to solve this problem?
I built the CE myself from the latest up-to-date sources.
After calling the call instruction through the debugger, I see the address I need in the register, 8 bytes, it is correct.
But after movsxd, it gets truncated and 4 bytes are lost.
I think the reason is {$ccode}, which adds movsxd and everything breaks. These are my assumptions, I may be mistaken about the reason, but the problem is this
| Description: |
|
| Filesize: |
10.35 KB |
| Viewed: |
530 Time(s) |

|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25855 Location: The netherlands
|
Posted: Sun Dec 28, 2025 10:17 am Post subject: |
|
|
GetModuleHandleA is an undefined functions, so the C compiler assumes it returns an int
add this line:
unsigned long long GetModuleHandleA(unsigned long long);
and it'll work better. (replace the param with a char * for an even more accurate description, but for your case that's not needed I guess)
_________________
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 |
|
 |
24quant42 Cheater
Reputation: 0
Joined: 19 Apr 2023 Posts: 34
|
Posted: Sun Dec 28, 2025 11:12 am Post subject: |
|
|
Some kind of magic again.
Thanks, everything is working)
|
|
| 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
|
|