/// <summary> /// Gets the process that has the module loaded. /// </summary> /// <returns>The process that hosts the module.</returns> public CorProcess GetProcess() { ICorDebugProcess coproc; comodule.GetProcess(out coproc); return(CorProcess.GetOrCreateCorProcess(coproc, options)); }
/// <summary> /// Attaches to the process with the given pid. /// </summary> /// <param name="pid">active process id</param> /// <param name="win32Attach"></param> /// <returns></returns> public CorProcess DebugActiveProcess(Int32 pid, Boolean win32Attach = false) { codebugger.DebugActiveProcess(Convert.ToUInt32(pid), win32Attach ? 1 : 0, out var coproc); options.IsAttaching = true; return(CorProcess.GetOrCreateCorProcess(coproc, options)); }
/// <summary> /// Creates a new managed process. /// </summary> /// <param name="exepath">application executable file</param> /// <param name="currdir">starting directory</param> /// <returns></returns> public CorProcess CreateProcess(String exepath, String currdir = ".") { STARTUPINFO si = new STARTUPINFO(); si.cb = Marshal.SizeOf(si); // initialize safe handles si.hStdInput = new Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0), false); si.hStdOutput = new Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0), false); si.hStdError = new Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0), false); PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); ICorDebugProcess proc; codebugger.CreateProcess( exepath, exepath, null, null, 1, // inherit handles (UInt32)CreateProcessFlags.CREATE_NEW_CONSOLE, new IntPtr(0), ".", si, pi, CorDebugCreateProcessFlags.DEBUG_NO_SPECIAL_OPTIONS, out proc); // FIXME close handles (why?) options.IsAttaching = false; return(CorProcess.GetOrCreateCorProcess(proc, options)); }
void ICorDebugManagedCallback.ControlCTrap(ICorDebugProcess pProcess) { var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options)); GetOwner(ev.Controller).DispatchEvent(ev); FinishEvent(ev); }
void ICorDebugManagedCallback.DebuggerError(ICorDebugProcess pProcess, int errorHR, uint errorCode) { var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options)); GetOwner(ev.Controller).DispatchEvent(ev); FinishEvent(ev); }
/// <summary> /// Gets the process. /// </summary> /// <returns></returns> public CorProcess GetProcess() { ICorDebugProcess proc; ComAppDomain.GetProcess(out proc); return(proc != null?CorProcess.GetOrCreateCorProcess(proc, options) : null); }
void ICorDebugManagedCallback.ExitProcess(ICorDebugProcess pProcess) { var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options), "ExitProcess"); GetOwner(ev.Controller).DispatchEvent(ev); ev.Continue = false; FinishEvent(ev); }
void ICorDebugManagedCallback.CreateAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain) { // attach to the appdomain pAppDomain.Attach(); var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options)); GetOwner(ev.Controller).DispatchEvent(ev); FinishEvent(ev); }
void ICorDebugManagedCallback.ExitAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain) { var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options), "ExitAppDomain"); GetOwner(ev.Controller).DispatchEvent(ev); FinishEvent(ev); if (appDomainCache.TryRemove(pAppDomain, out _) == false) { Console.WriteLine("Unable to remove AppDomain from cache during ExitAppDomain callback?!"); } }
void ICorDebugManagedCallback.CreateAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain) { // attach to the appdomain pAppDomain.Attach(); if (appDomainCache.TryAdd(pAppDomain, new CorAppDomain(pAppDomain, p_options)) == false) { Console.WriteLine("Unable to add AppDomain to cache during CreateAppDomain callback?!"); } var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options), "CreateAppDomain"); GetOwner(ev.Controller).DispatchEvent(ev); FinishEvent(ev); }
/// <summary> /// Gets the process that has the module loaded. /// </summary> /// <returns>The process that hosts the module.</returns> public CorProcess GetProcess() { comodule.GetProcess(out var coproc); return(CorProcess.GetOrCreateCorProcess(coproc, options)); }
/// <summary> /// Gets the process. /// </summary> /// <returns></returns> public CorProcess GetProcess() { ComAppDomain.GetProcess(out var proc); return(proc != null?CorProcess.GetOrCreateCorProcess(proc, options) : null); }