|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ajanuw How do I cheat? Reputation: 0
Joined: 14 Jul 2020 Posts: 5
|
Posted: Fri Aug 28, 2020 6:40 am Post subject: The executeCode function always crashes the x86 target proce |
|
|
I wrote a Lua function to call some functions exported in the DLL, which works well in the target process of x64, but if it is the target process of x86, it will crash
```
function getTargetWindow()
return executeCode("getTargetWindow")
end
```
Does it mean that executeCode can only be used in x64 target processes? If I want to call the function exported by DLL in the target process of x86, how can I do it, thanks
I injected the DLL while attaching the process
```
local function initDLL()
local dllpath =
getCheatEngineDir() ..
(targetIs64Bit() and "autorun\\CE_Plugin\\x64\\Release\\CE_Plugin.dll" or
"autorun\\CE_Plugin\\Release\\CE_Plugin.dll")
-- print(dllpath)
injectDLL(dllpath)
end
function onOpenProcess(openprocess_id)
setTimeout(initDLL, 1000)
end
```
Functions exported in DLL
```
extern "C" {
__declspec(dllexport) HWND __stdcall getTargetWindow()
{
if (targetWindow) return targetWindow;
EnumWindows(EnumWindowsProc, 0);
return targetWindow;
}
}
```
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Fri Aug 28, 2020 6:51 am Post subject: |
|
|
executeCode calls a function that is declared as:
Code: |
int name(int parameter);
|
In x86, if the function does not take 1 parameter, it will mess up the stack, as it will not do a ret 4, so the parameter will still be pushed on the stack on return
You may want to use
Code: |
executeCodeEx(0,nil,'getTargetWindow')
stdcall, no timeout
|
or change getTargetWindow to take a parameter
_________________
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 |
|
|
ajanuw How do I cheat? Reputation: 0
Joined: 14 Jul 2020 Posts: 5
|
Posted: Fri Aug 28, 2020 7:10 am Post subject: It's working fine now, thanks |
|
|
Dark Byte wrote: | executeCode calls a function that is declared as:
Code: |
int name(int parameter);
|
In x86, if the function does not take 1 parameter, it will mess up the stack, as it will not do a ret 4, so the parameter will still be pushed on the stack on return
You may want to use
Code: |
executeCodeEx(0,nil,'getTargetWindow')
stdcall, no timeout
|
or change getTargetWindow to take a parameter |
|
|
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
|
|