Esempio n. 1
0
        /// <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));
        }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
0
        /// <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));
        }
Esempio n. 4
0
            void ICorDebugManagedCallback.ControlCTrap(ICorDebugProcess pProcess)
            {
                var ev = new CorEventArgs(CorProcess.GetOrCreateCorProcess(pProcess, p_options));

                GetOwner(ev.Controller).DispatchEvent(ev);

                FinishEvent(ev);
            }
Esempio n. 5
0
            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);
            }
Esempio n. 6
0
        /// <summary>
        /// Gets the process.
        /// </summary>
        /// <returns></returns>
        public CorProcess GetProcess()
        {
            ICorDebugProcess proc;

            ComAppDomain.GetProcess(out proc);

            return(proc != null?CorProcess.GetOrCreateCorProcess(proc, options) : null);
        }
Esempio n. 7
0
            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);
            }
Esempio n. 8
0
            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);
            }
Esempio n. 9
0
            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?!");
                }
            }
Esempio n. 10
0
            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);
            }
Esempio n. 11
0
 /// <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));
 }
Esempio n. 12
0
        /// <summary>
        /// Gets the process.
        /// </summary>
        /// <returns></returns>
        public CorProcess GetProcess()
        {
            ComAppDomain.GetProcess(out var proc);

            return(proc != null?CorProcess.GetOrCreateCorProcess(proc, options) : null);
        }