Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


The executeCode function always crashes the x86 target proce

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
ajanuw
How do I cheat?
Reputation: 0

Joined: 14 Jul 2020
Posts: 5

PostPosted: Fri Aug 28, 2020 6:40 am    Post subject: The executeCode function always crashes the x86 target proce Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Fri Aug 28, 2020 6:51 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
ajanuw
How do I cheat?
Reputation: 0

Joined: 14 Jul 2020
Posts: 5

PostPosted: Fri Aug 28, 2020 7:10 am    Post subject: It's working fine now, thanks Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites