Esempio n. 1
0
        public Debugger(IDebugClient5 client, IDebugControl control)
        {
            _client  = client;
            _control = control;

            client.SetOutputCallbacks(this);
        }
Esempio n. 2
0
        public UserDebugger()
        {
            Guid   guid = new Guid("27fe5639-8407-4f47-8364-ee118fb08ac8");
            object obj  = null;

            int hr = DebugCreate(ref guid, out obj);

            if (hr < 0)
            {
                Console.WriteLine("SourceFix: Unable to acquire client interface");
                return;
            }

            _client         = obj as IDebugClient5;
            _control        = _client as IDebugControl4;
            _debugDataSpace = _client as IDebugDataSpaces;
            _client.SetOutputCallbacks(this);
            _client.SetEventCallbacksWide(this);
        }
        public WindowsDebugEngine(string winDbgPath)
        {
            logger.Debug("WindowsDebugEngine");

            object obj   = null;
            Guid   clsid = CLSID(typeof(IDebugClient5));

            this.winDbgPath = winDbgPath;

            hDll  = LoadWin32Library(Path.Combine(winDbgPath, "dbgeng.dll"));
            hProc = GetProcAddress(hDll, "DebugCreate");
            DebugCreate debugCreate = (DebugCreate)Marshal.GetDelegateForFunctionPointer(hProc, typeof(DebugCreate));

            if (debugCreate(ref clsid, out obj) != 0)
            {
                Debugger.Break();
            }

            dbgClient        = (IDebugClient5)obj;
            dbgControl       = (IDebugControl4)obj;
            dbgSymbols       = (IDebugSymbols3)obj;
            dbgSystemObjects = (IDebugSystemObjects)obj;

            // Reset events
            loadModules.Reset();
            exitProcess.Reset();
            handlingException.Reset();
            handledException.Reset();
            exitDebugger.Reset();

            // Reset output
            output = new StringBuilder();

            dbgSymbols.SetSymbolPath(@"SRV*http://msdl.microsoft.com/download/symbols");

            dbgClient.SetOutputCallbacks(new OutputCallbacks(this));
            dbgClient.SetEventCallbacks(new EventCallbacks(this));
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public void Dispose()
 {
     _client.SetEventCallbacks(null);
     _client.SetOutputCallbacks(null);
 }
Esempio n. 6
0
        public Debugger(IDebugClient5 client, IDebugControl control)
        {
            _client = client;
            _control = control;

            client.SetOutputCallbacks(this);
        }