static void cleanUp(bool terminate) { if (_thread != null) { _thread.Close(); _thread = null; } if (_process != null) { if (terminate) { _process.Terminate(NtStatus.DBG_CONTROL_C, false); } else { _process.Close(); } _process = null; } if (_waitHandle != IntPtr.Zero) { CloseHandle(_waitHandle); _waitHandle = IntPtr.Zero; } }
static bool FilterProcess(NtProcess process) { if (process.IsDeleting) { return(true); } process.Close(); return(false); }