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 


Proper way to end/disable createthread()

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Kyokyonos
Newbie cheater
Reputation: 0

Joined: 14 Apr 2009
Posts: 19

PostPosted: Sun Dec 22, 2013 8:21 pm    Post subject: Proper way to end/disable createthread() Reply with quote

So...

I recently noticed this "createthread()" function which seems way more efficient as opposed to 'hijacking' some ingame functionality to make a jump to a potentially long and time consuming (2-4 second) AA script.

I saw the 2009 thread on "createthread understanding", but still not sure how to 'safely' undo createthread().

I've made some simple AA scripts using createthread() that do some math, change values, check some conditions, or store values from addresses into some allocated addresses and it seems to work fine when I just put 'ret' at the end to return to the calling function that supposedly terminates the created thread. When I have longer scripts that involve searching/looping and a few of jumps... I try making a conditional jump to a label with 'ret' (and have tried having the conditional jump point to the main content of the script instead), but it seems to crash more often then not when the debugger gets to 'ret'. As a way around the crashing, I sometime make it loop through a long (10hr+) sleep cycle when it's done and lately have been omitting 'ret' entirely. But the concern arises if I need to re-enable the script... I assume multiple threads are created.

Is 'ret' necessary for createthread() to terminate itself? Perhaps this has something to do with my understanding of assembly ]:
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Dec 22, 2013 9:17 pm    Post subject: Reply with quote

When a thread starts [esp] contains the address of ExitThread. So when the thread executes ret with a proper stack, it will call ExitThread and exit

The reason you crash is most likely a broken stack (e.g wrong parameter count when calling a function, or the wrong calling convention (cdecl requires the caller to undo the parameter pushes)

You could of course call ExitThread yourself, but this indicates that there's something wrong in 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
Kyokyonos
Newbie cheater
Reputation: 0

Joined: 14 Apr 2009
Posts: 19

PostPosted: Sun Dec 22, 2013 10:19 pm    Post subject: Reply with quote

You were right! After closer inspection, there were a few inconsistencies with a few registers being pushed/popped on the stack in the code. Oops! No more crashes. Thanks!

Now I know how important the state of registers are before and after calling subroutines.
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 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