View previous topic :: View next topic |
Author |
Message |
Horse4Horse Newbie cheater Reputation: 1
Joined: 17 May 2015 Posts: 22
|
Posted: Wed Aug 21, 2024 6:16 am Post subject: Cheat Engine {$CCODE} imports |
|
|
I'm making a simple C section for matrix multiplications for object rotation in 3d. It works in lua as a PoC.
The problem is, what I'm already encountered every time I worked with C code sections in CE - for some reason CE prefers to use "ntoskrnl' over "ucrtbase" for functions like "memset", "memove", etc.
I already had to deal with it in the pervious cheat in this way:
Code: | {$c}
#define NO_OLDNAMES
#include <windows.h>
typedef HWND(WINAPI *GETFOREGROUNDWINDOW)(void);
GETFOREGROUNDWINDOW pfnGetForegroundWindow;
{$asm}
{$ccode}
HMODULE hModuleUser32 = LoadLibrary("User32.dll");
pfnGetForegroundWindow = (GETFOREGROUNDWINDOW)GetProcAddress(hModuleUser32, "GetForegroundWindow");
{$asm}
|
So it won't compile to call "win32kbase.GetForegroundWindow".
I also tried:
Code: | extern __declspec(dllimport) HWND __stdcall GetForegroundWindow(); |
And it worked, but when I tried the same thing with:
Code: | extern __declspec(dllimport) SHORT __stdcall GetKeyState(); |
It still called win32kbase.
And now, when I'm dealing with matrixes, compiler automatically uses memset's and memmove's and I can't control where it gets them from.
So the main question is - how to deal with imports in a proper way?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 466
Joined: 09 May 2003 Posts: 25577 Location: The netherlands
|
Posted: Wed Aug 21, 2024 10:00 am Post subject: |
|
|
registersymbol the correct symbol with a different name first (different script, or lua block)
e.g registerSymbol('ucrtbase_memset', getAddress('ucrtbase.memset'))
and then in your ccode you can call ucrtbase_memset
_________________
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 |
|
|
Horse4Horse Newbie cheater Reputation: 1
Joined: 17 May 2015 Posts: 22
|
Posted: Wed Aug 21, 2024 11:14 am Post subject: |
|
|
Dark Byte wrote: | registersymbol the correct symbol with a different name first (different script, or lua block)
e.g registerSymbol('ucrtbase_memset', getAddress('ucrtbase.memset'))
and then in your ccode you can call ucrtbase_memset |
Many thanks, Dark Byte, you are genius. It is such a simple solution but it never came to me.
Eeyup, I'm already using script on a higher call level to start a C code injection. So I ended up redefining to:
Code: | registerSymbol('memset', getAddress('ucrtbase.memset')) |
Because I never specified memset myself in the code, compiler did it. And now it points to the right function.
|
|
Back to top |
|
|
|