开发者

C++ game trainer process monitoring

开发者 https://www.devze.com 2023-01-14 15:52 出处:网络
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 ga

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消