/// <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); }
/// <summary> /// Opens the specified dump file. /// </summary> /// <param name="dumpFile">The dump file.</param> /// <param name="symbolPath">The symbol path.</param> public static IDebugClient OpenDumpFile(string dumpFile, string symbolPath) { IDebugClient client = DebugCreate(); IDebugSymbols5 symbols = (IDebugSymbols5)client; IDebugControl7 control = (IDebugControl7)client; symbols.SetSymbolPathWide(symbolPath); client.OpenDumpFile(dumpFile); control.WaitForEvent(0, uint.MaxValue); symbols.SetSymbolPathWide(symbolPath); control.Execute(0, ".reload -f", 0); return(client); }
/// <summary> /// Starts a new process. /// </summary> /// <param name="processPath">Process path.</param> /// <param name="processArguments">Process arguments.</param> /// <param name="symbolPath">Symbol path.</param> /// <param name="debugEngineOptions">Debug engine options.</param> /// <returns></returns> public static IDebugClient OpenProcess(string processPath, string processArguments, string symbolPath, uint debugEngineOptions) { string processCommandLine = processPath + " " + processArguments; IDebugClient client = DebugCreate(); IDebugSymbols5 symbols = (IDebugSymbols5)client; IDebugControl7 control = (IDebugControl7)client; symbols.SetSymbolPathWide(symbolPath); control.SetEngineOptions(debugEngineOptions); client.CreateProcessAndAttach(0, processCommandLine, DebugCreateProcess.DebugOnlyThisProcess, 0, 0); control.WaitForEvent(0, uint.MaxValue); return(client); }
private DebugClient(object client, TaskScheduler scheduler) { _scheduler = scheduler; Client = (IDebugClient5)client; Control = (IDebugControl7)client; DataSpaces = (IDebugDataSpaces4)client; SystemObjects = (IDebugSystemObjects2)client; Symbols = (IDebugSymbols5)client; Advanced = (IDebugAdvanced3)client; Client.SetEventCallbacksWide(this).ThrowIfFailed(); Client.SetOutputCallbacksWide(this).ThrowIfFailed(); Control.AddEngineOptions(DEBUG_ENGOPT.INITIAL_BREAK); }
/// <summary> /// Initializes the API. /// </summary> /// <param name="log">The log.</param> internal static void InitApi(ILog log = null) { LastHR = HRESULT.S_OK; if (client != null) { return; } try { log?.Debug("Client did not exist. Creating a new client and associated interfaces."); client = (IDebugClient5)CreateIDebugClient(); control = (IDebugControl6)client; registers = (IDebugRegisters2)client; symbols = (IDebugSymbols5)client; systemObjects = (IDebugSystemObjects)client; debugDataSpaces = (IDebugDataSpaces)client; } catch (Exception e) { log?.Fatal("Unable to create debug client. Are you missing DLLs?"); log?.Fatal(e); LastHR = HRESULT.E_UNEXPECTED; } }
public static void Clear() { modules = null; symbol = null; }