/// <summary> /// Attaches debugger to the already running specified process. /// </summary> /// <param name="processId">The process identifier.</param> /// <param name="attachFlags">The attaching flags.</param> /// <param name="symbolPaths">Array of paths where debugger will look for symbols.</param> public static void AttachToProcess(uint processId, DebugAttach attachFlags = DebugAttach.Noninvasive, params string[] symbolPaths) { IDebugClient debugClient = DebugClient.DebugCreate(); IDebugSymbols5 symbols = (IDebugSymbols5)debugClient; IDebugControl7 control = (IDebugControl7)debugClient; symbols.SetSymbolPathWide(string.Join(";", symbolPaths)); debugClient.AttachProcess(0, processId, attachFlags); control.WaitForEvent(0, uint.MaxValue); InitializeDbgEng(debugClient); }
private Dumper(string applicationPath, string dumpPath, bool miniDump) { this.dumpPath = dumpPath; this.miniDump = miniDump; // Create debugging client IDebugClient clientBase = DebugClient.DebugCreate(); // Cast to upper clients client = (IDebugClient7)clientBase; control = (IDebugControl7)client; client.SetEventCallbacks(this); client.CreateProcessAndAttach(0, applicationPath, 0x00000002); }
public void Attach() { Task.Run(() => { this.Client = DebugClient.DebugCreate(); IDebugClient7 client = this.Client as IDebugClient7; IDebugControl6 control = this.Client as IDebugControl6; client.SetOutputCallbacksWide(new OutputCallBacks()); client.SetEventCallbacksWide(new EventCallBacks(control)); this.Client.AttachProcess(0, unchecked ((UInt32)this.SystemProcess.Id), DebugAttach.InvasiveNoInitialBreak); while (true) { control.WaitForEvent(0, UInt32.MaxValue); } }); }