private NativeDbgProcess CreateNew(int processId) { var process = new NativeDbgProcess(processId); m_processes[processId] = process; return(process); }
public NativeDbgModule(NativeDbgProcess process, string name, IntPtr baseAddress, IntPtr fileHandle) { m_name = name; m_baseAddress = baseAddress; m_hFile = fileHandle; m_FileSize = -1; m_process = process; }
/// <summary> /// Stop debugging the specified process (detach) /// </summary> /// <param name="process">process to detach from</param> /// <remarks>After detaching, the process is removed from the caches and can not be accessed. If detaching at a debug /// event, do not call Continue on the event. </remarks> public void Detach(NativeDbgProcess process) { if (process == null) { throw new ArgumentNullException("process"); } int pid = process.Id; bool fDetachOk = NativeMethods.DebugActiveProcessStop((uint)pid); if (!fDetachOk) { int err = Marshal.GetLastWin32Error(); throw new InvalidOperationException("Failed to detach to process " + pid + "error=" + err); } RemoveProcess(pid); }
internal static NativeEvent Build( NativePipeline pipeline, ref DebugEventHeader header, ref DebugEventUnion union ) { NativeDbgProcess process = pipeline.GetOrCreateProcess((int)header.dwProcessId); switch (header.dwDebugEventCode) { case NativeDebugEventCode.CREATE_PROCESS_DEBUG_EVENT: return(new CreateProcessDebugEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.EXIT_PROCESS_DEBUG_EVENT: return(new ExitProcessDebugEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.EXCEPTION_DEBUG_EVENT: return(new ExceptionNativeEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.LOAD_DLL_DEBUG_EVENT: return(new LoadDllNativeEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.UNLOAD_DLL_DEBUG_EVENT: return(new UnloadDllNativeEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.OUTPUT_DEBUG_STRING_EVENT: return(new OutputDebugStringNativeEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.CREATE_THREAD_DEBUG_EVENT: return(new CreateThreadNativeEvent(pipeline, ref header, ref union)); case NativeDebugEventCode.EXIT_THREAD_DEBUG_EVENT: return(new ExitThreadNativeEvent(pipeline, ref header, ref union)); default: return(new NativeEvent(pipeline, ref header, ref union)); } }
/// <summary> /// Continue a debug event previously gotten by WaitForDebugEvent /// </summary> /// <param name="nativeEvent"></param> /// <remarks>Can't continue a debug event if we just detached from the process</remarks> public void ContinueEvent(NativeEvent nativeEvent) { if (nativeEvent == null) { throw new ArgumentNullException("nativeEvent"); } if (nativeEvent.ContinueStatus == NativeMethods.ContinueStatus.CONTINUED) { throw new ArgumentException("event was already continued", "nativeEvent"); } if (nativeEvent.Pipeline != this) { throw new ArgumentException("event does not belong to this pipeline"); } // Verify that the process for this event is still connected to our pipeline. // The lookup will throw if the process detached or was terminated. NativeDbgProcess proc = nativeEvent.Process; Debug.Assert(proc.Id == nativeEvent.ProcessId); nativeEvent.DoCleanupForContinue(); bool fContinueOk = NativeMethods.ContinueDebugEvent((uint)nativeEvent.ProcessId, (uint)nativeEvent.ThreadId, nativeEvent.ContinueStatus); if (!fContinueOk) { int err = Marshal.GetLastWin32Error(); throw new InvalidOperationException("Continue failed on process " + nativeEvent.ProcessId + " error=" + err); } // Mark as continued so that we don't accidentally continue again. nativeEvent.ContinueStatus = NativeMethods.ContinueStatus.CONTINUED; }
private NativeDbgProcess CreateNew(int processId) { var process = new NativeDbgProcess(processId); m_processes[processId] = process; return process; }
/// <summary> /// Stop debugging the specified process (detach) /// </summary> /// <param name="process">process to detach from</param> /// <remarks>After detaching, the process is removed from the caches and can not be accessed. If detaching at a debug /// event, do not call Continue on the event. </remarks> public void Detach(NativeDbgProcess process) { if (process == null) { throw new ArgumentNullException("process"); } int pid = process.Id; bool fDetachOk = NativeMethods.DebugActiveProcessStop((uint) pid); if (!fDetachOk) { int err = Marshal.GetLastWin32Error(); throw new InvalidOperationException("Failed to detach to process " + pid + "error=" + err); } RemoveProcess(pid); }