這裏有一段代碼是做主要工作的 - 附加到一個活躍的過程。儘管看起來子進程沒有在交換機中被捕獲爲CREATE_PROCESS_DEBUG_EVENT。 只有CREATE(EXIT)_THREAD_DEBUG_EVENT和LOAD_DLL_DEBUG_EVENT打印在stderr中,儘管我確切地知道創建了子進程(不是線程)。請指教。DebugActiveProcess是否也跟蹤子進程?
DebugActiveProcess(processId);
DebugSetProcessKillOnExit(false);
while (!done) {
DWORD status = DBG_CONTINUE;
DEBUG_EVENT debugEvent;
WaitForDebugEvent(&debugEvent, INFINITE);
switch (debugEvent.dwDebugEventCode) {
cerr << "Got event " << debugEvent.dwDebugEventCode << endl;
case CREATE_PROCESS_DEBUG_EVENT:
{
CREATE_PROCESS_DEBUG_INFO &info = debugEvent.u.CreateProcessInfo;
cerr << "process created " << debugEvent.dwProcessId << endl;
break;
}
case EXIT_PROCESS_DEBUG_EVENT:
{
EXIT_PROCESS_DEBUG_INFO &info = debugEvent.u.ExitProcess;
cerr << "process exited" << endl;
break;
}
case LOAD_DLL_DEBUG_EVENT:
{
CloseHandle(debugEvent.u.LoadDll.hFile);
break;
}
}
ContinueDebugEvent(debugEvent.dwProcessId, debugEvent.dwThreadId, status);
}
您是不是要說「子流程*是*創建的」? – arx
謝謝,這裏的錯字 – Nelly