예제 #1
0
        public Debugger LaunchProcess(string commandLine, string workingDirectory)
        {
            IDebugClient5 client = CreateIDebugClient();
            IDebugControl control = (IDebugControl)client;

            if (string.IsNullOrEmpty(workingDirectory))
                workingDirectory = Environment.CurrentDirectory;

            string env = GetEnvironment();
            DEBUG_CREATE_PROCESS_OPTIONS options = new DEBUG_CREATE_PROCESS_OPTIONS();
            options.CreateFlags = (DEBUG_CREATE_PROCESS)1;
            int hr = client.CreateProcessAndAttach2(0, commandLine, ref options, (uint)Marshal.SizeOf(typeof(DEBUG_CREATE_PROCESS_OPTIONS)), workingDirectory, env, 0, DEBUG_ATTACH.DEFAULT);

            if (hr < 0)
                throw new Exception(Debugger.GetExceptionString("IDebugClient::CreateProcessAndAttach2", hr));

            Debugger debugger = new Debugger(client, control);
            hr = client.SetEventCallbacks(debugger);
            if (hr < 0)
                throw new Exception(Debugger.GetExceptionString("IDebugClient::SetEventCallbacks", hr));

            hr = client.SetOutputCallbacks(debugger);
            if (hr < 0)
                throw new Exception(Debugger.GetExceptionString("IDebugClient::SetOutputCallbacks", hr));

            return debugger;
        }
예제 #2
0
        private void WriteDumps(Debugger dbg, string exe)
        {
            string dump = GetMiniDumpName(exe);
            dbg.WriteDumpFile(dump, DEBUG_DUMP.SMALL);
            _miniDumpPath = dump;

            dump = GetFullDumpName(exe);
            dbg.WriteDumpFile(dump, DEBUG_DUMP.DEFAULT);
            _fullDumpPath = dump;

            dbg.TerminateProcess();
        }