Posted: Thu Dec 11, 2025 1:39 am Post subject: Call a function through cheat engine
Hey everyone,
I’m trying to understand the proper way to call an in-game function safely from an AA script without corrupting registers or crashing the game.
In my case (Motor Town), I want to call the function that opens the vehicle menu even when I’m not standing inside the interactive zone. I already found the function address and I can see what it does when the game calls it normally, but when I try to manually call it (for example: call MotorTown-Win64-Shipping.exe+214xxxx), the game crashes or nothing happens because the function expects certain registers/arguments to be set correctly.
What I need help with:
How do I trace the function back to see what arguments or registers need to be prepared before calling it?
How do I check which registers the function preserves vs. which ones I must manually save?
Is there a recommended method in CE to call such functions safely inside an AA script, without corrupting the state?
Any general tips for calling Unity/Mono C++ functions directly from assembly?
Basically, I want to make a simple AA script that triggers the vehicle spawn/shop menu by calling the function directly, but I’m unsure how to set up the registers properly so the call behaves the same as when the game triggers it.
Any guidance or examples would be greatly appreciated!
Calling a function in the context of mono's runtime is very different from calling a native function. Mono needs to attach the thread to the runtime so that the thread can run CLR code. Use `mono_thread_attach` to do that and `mono_get_root_domain` to get the argument it needs. Invoke methods using `mono_runtime_invoke`. Types, arguments, and even the reference to the function being called need to be retrieved from other methods in the mono API.
CE exposes a monoscript Lua API that handles much of this for you. I'd suggest using that, or at least referencing it when trying to invoke mono code yourself. See the file `monoscript.lua` in the `autorun` folder and the `MonoDataCollector` project in CE's source. _________________
I don't know where I'm going, but I'll figure it out when I get there.
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