C++ game trainer process monitoring
I am going to open game process from my trainer app and write some values to memory. I have no problems with opening a process and writing a value to memory. But I can't realize how to monitor the game process availability. For example I opened a running process, user closed it and opened again. How can I trac开发者_如何学编程k this in my code? OpenProcess handle is valid even after the process is closed (until CloseHandle called). Thank you.
You can use the GetExitCodeProcess
function to see if the handle you have points to a running process.
DWORD exitCode=0;
::GetExitCodeProcess(hProcess, &exitCode);
if (exitCode==STILL_ACTIVE)
; //process is alive
MSDN link
Or else, if it's more suitable for your application to have the process termination event signalled to you (process is a waitable object):
::WaitForSingleObject(hProcess, dwTimeout);
精彩评论