I'm trying to make a small tool that makes use of the Debugger Engine API, but I'm having very limited success.
I can get my IDebugClient and IDebugControl instances, and from there I am able to attach into an already running user process. I then enter a main loop where I call WaitForEvent, OutputStackTrace, SetExecutionStatus(DEBUG_STATUS_GO
), and repeat. In essence this will be a very crude sampling based profiler.
Good so far..
My loop runs for one full iteration, I can see a stack trace being displayed and then the target process going back into a running state.
The problem I have is that on my 2nd iteration the call to WaitForEvent
returns E_HANDLE
("The handle is invalid"). I cannot see in the documentation why this error should be returned. Does anyone know why this might be happening?