I want to find out whether or not a certain process is sleeping or not (C++/Windows).
I’m trying to use the suspend count to do so and suspending to process before the check for
profiling processes.
I’m doing something like this:
SuspendThread(threadHandle);
... Do Some Stuff ...
int suspended = ResumeThread(threadHandle);
if (suspended > 1)
m_isSleeping = true;
According to MSDN: http://msdn.microsoft.com/en-us/library/ms685086%28v=vs.85%29.aspx
If a process is suspended, “ResumeThread” returns a value > 0.
In my case, the process is a sleeping process, so I’d expect that the suspend count would be [My Call To SuspendThread] + [The “Sleep” method within the process] = 2
but I keep getting: ResumeThread(threadHandle) == 1
Does anybody know why it happens?
thanks 🙂
You’re confusing threads and processes.
ResumeThreadandSuspendThreaddo not operate on process handles, they operate on thread handles. Also,Sleepdoes not change the suspend count of a process, onlyResumeThreadandSuspendThreadchange that. If you’re trying to detect if a thread is currently in aSleepcall, you’re doing it wrong.