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 


Why does my hack crash? Calling game functions.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
LongBeardedLion
Expert Cheater
Reputation: 0

Joined: 10 Apr 2020
Posts: 174

PostPosted: Fri Nov 07, 2025 4:56 pm    Post subject: Why does my hack crash? Calling game functions. Reply with quote

So its really hard to find what im doing wrong.
Im doing an automation hack, where my units shoot and run for an RTS.
Its really cool.
But sometimes and for no apparent reason the game crashes, especially if there is lag.
The sad thing is that it works 90% of the times.
So its hard to even tell what is going on.
At first i thought it must be the units im sending to the function are no longer alive, or valid (could be dead).
So i made a function that checks the health of the unit, as well as the ID, to make sure the unit is valid.
But it still crashed.
I then started speculating it must be something unconventional. So i looked for what it looks like the game loop using x32dbg.
Detoured the function and call my movement function from inside that game loop. Kind of weird.
But this never crashes. Never.
But on the other hand it lags like crazy on bigger games.
So I realized this is something beyond my technical knowledge, and wonder if anyone can help me with this? Or suggest what could possibly be the problem...
Im calling the game functions this way:

Code:
struct _moveUnitsTarget2
{
    typedef void(__thiscall* _moveUnits2)(void* pThis, int a2, int a3, int a4, float a5, float a6);
    _moveUnits2 moveUnits2;
    //its the same as _moveUnitsTarget but with floats
}moveUnitsTarget2;

if (moveUnitsTarget2.moveUnits2 == nullptr)
moveUnitsTarget2.moveUnits2 = (_moveUnitsTarget2::_moveUnits2)(baseGlobal + 0x3D830);

moveUnitsTarget2.moveUnits2(ECX2, reinterpret_cast<int>(&curUnit), 1, 0x0, curSquad->SquadCheckpoints[0].X, curSquad->SquadCheckpoints[0].Y);
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Nov 08, 2025 4:31 am    Post subject: Reply with quote

Maybe the character has died after you checked it was alive (can happen between 2 cpu instructions on multithreaded games)

Alternatively, it may be a threading issue, and calling moveUnits2 at the same time as another function can cause an issue (e.g when a character dies and it's memory is being deleted)

It's best to have it inside the main the game loop thread. Just add some code so it doesn't execute every single time (e.g keep a timestamp of the last execution and only every half a second call your code)

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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