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 


onExitProcess?

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

Joined: 26 Mar 2020
Posts: 9
Location: Lithuania.

PostPosted: Mon Mar 30, 2020 10:21 am    Post subject: onExitProcess? Reply with quote

Does something like that exist?
If so could you tell me please?
Thank you in advance!

_________________
Just a newbie trying to hack
Smile
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Mon Mar 30, 2020 9:19 pm    Post subject: Reply with quote

ExitProcess is for ending the process itself (much like ExitThread ends a thread). This is used to end a process (program or DLL), though Microsoft doesn't recommend it for ending a DLL.

If you are trying to stop yourself (you are the process), you can use ExisProcess, though I would recommend a cleaner shutdown, to make sure everything is cleanly stopped. ExitProcess, like ExitThread, stops without unwinding the stack, so no destructors are called.

From within a service, you stop based on an external signal. You could respond to that by calling ExitProcess, but it would probably be better to have some form of the shutdown that closes anything necessary and logs this.

Lua has os.exit(), but this use to the end of the process itself. Similar to closeCE().


Test:

Code:
function onExitProcess()
 local id = getOpenedProcessID()
 local name = getProcessNameFromID(id)
 if tostring(name) == "" then
 showMessage("Process not found...")
 return
 end
 os.execute("taskkill -im "..id)
 
 --- do something on exit process here

end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Tue Mar 31, 2020 11:36 pm    Post subject: Reply with quote

If you are referring to an event fired for when the process closes that CE attached to, you can do something like this:

- Add a 'onOpenProcess' event handler in your Lua code.
- Store the process id it passes as its argument.
- Create a timer that loops the process list of the system and checks for the process id you stored to ensure it still exists.
- If the process id is missing, kill the timer and call your own onExitProcess function.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Apr 01, 2020 12:16 am    Post subject: Reply with quote

atom0s, how if CE has open as multi-instances with the same process attached. It is possible to use the method as multithreading especially in CE Lua?.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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