static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill) { if (pcs == dbg_curr_process) { /* remove all set breakpoints in debuggee code */ break_set_xpoints(FALSE); /* needed for single stepping (ugly). * should this be handled inside the server ??? */ be_cpu->single_step(&dbg_context, FALSE); if (dbg_curr_thread->in_exception) { SetThreadContext(dbg_curr_thread->handle, &dbg_context); ContinueDebugEvent(dbg_curr_pid, dbg_curr_tid, DBG_CONTINUE); } } if (kill) { TerminateProcess(pcs->handle, 0); } else { if (!DebugActiveProcessStop(pcs->pid)) return FALSE; } SymCleanup(pcs->handle); dbg_del_process(pcs); return TRUE; }
/****************************************************************** * dbg_attach_debuggee * * Sets the debuggee to <pid> * cofe instructs winedbg what to do when first exception is received * (break=FALSE, continue=TRUE) * wfe is set to TRUE if dbg_attach_debuggee should also proceed with all debug events * until the first exception is received (aka: attach to an already running process) */ BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe) { if (!(dbg_curr_process = dbg_add_process(&be_process_active_io, pid, 0))) return FALSE; if (!DebugActiveProcess(pid)) { dbg_printf("Can't attach process %04x: error %u\n", pid, GetLastError()); dbg_del_process(dbg_curr_process); return FALSE; } dbg_curr_process->continue_on_first_exception = cofe; SetEnvironmentVariableA("DBGHELP_NOLIVE", NULL); dbg_curr_process->active_debuggee = TRUE; return TRUE; }
static BOOL tgt_process_module_close_process(struct dbg_process* pcs, BOOL kill) { SymCleanup(pcs->handle); dbg_del_process(pcs); return TRUE; }