示例#1
0
        static int Main(string[] args)
        {
            DebugClient  cli  = null;
            DebugControl ctrl = null;

            try
            {
                cli  = new DebugClient();
                ctrl = new DebugControl(cli);

                // ctrl.Execute(OutputControl.ToAllClients, "sxe ibp", ExecuteOptions.Default);
                ctrl.EngineOptions |= EngineOptions.InitialBreak;

                //cli.OnExceptionDebugEvent += new ExceptionEventHandler(HandleException);
                //cli.OnExitProcessDebugEvent += new ExitProcessEventHandler(HandleExitProcess);
                //cli.OnBreakpointDebugEvent += new BreakpointEventHandler(HandleBp);
                //cli.CreateProcess(0, "notepad.exe", CreateProcessOptions.DebugOnlyThisProcess);

                cli.CreateProcessAndAttach(0,
                                           @"notepad.exe",
                                           CreateProcessOptions.DebugOnlyThisProcess,
                                           0,
                                           ProcessAttachMode.InvasiveResumeProcess);

                Console.WriteLine(cli.ToString());      //Identity.ToString());

                Console.WriteLine(ctrl.WaitForEvent()); // <-- BREAKS HERE!!!

                DebugEventInfo lastEvent = ctrl.GetLastEventInformation();

                Console.WriteLine("Last event: {0}", lastEvent.Description);

                /*for (int i = 0; i < 200; i++)
                 *  Console.WriteLine(cli.ToString()); */
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Exception thrown: {0}", e);
                return(1);
            }
            finally
            {
                if (cli != null)
                {
                    cli.Dispose();
                }
                if (ctrl != null)
                {
                    ctrl.Dispose();
                }
            }

            return(0);
        }
示例#2
0
 public void Dispose()
 {
     Debugger.Dispose();
 }
示例#3
0
文件: mformatting.cs 项目: heruix/Rx
    static int Main(string[] args)
    {
        DebugClient    cli  = null;
        DebugControl   ctrl = null;
        DebugSymbols   sym  = null;
        DebugRegisters reg  = null;

        try
        {
            cli  = new DebugClient();
            ctrl = new DebugControl(cli);
            sym  = new DebugSymbols(cli);
            reg  = new DebugRegisters(cli);

            ctrl.Execute(OutputControl.ToAllClients, "sxe ibp", ExecuteOptions.Default);

            cli.CreateProcessAndAttach(
                "notepad.exe",
                CreateProcessOptions.DebugOnlyThisProcess,
                0,
                ProcessAttachMode.InvasiveResumeProcess);

            ctrl.WaitForEvent();

            UInt64 currentAddress = reg.InstructionOffset;

            sym.SymbolOptions |= SymbolOptions.LoadLines;
            sym.SetSymbolPath("srv*"); // Make sure that symsrv.dll is in the path!
            sym.Reload();

            DebugFormatter formatter = new DebugFormatter(cli);

            string addrInfo1 = String.Format(formatter, "Current address {0:x} \"{0:y}\"", currentAddress);

            Console.Out.WriteLine(addrInfo1);

            string addrInfo2 = String.Format(formatter, "Current address +0n16 is {0:x} \"{0:ys}\"", currentAddress + 16);

            Console.Out.WriteLine(addrInfo2);

            Console.Out.WriteLine(String.Format(formatter, "Zero address is {0} \"{0:ys}\"", 0));

            cli.DebugOutput += new EventHandler <DebugOutputEventArgs>(HandleOutput);

            ctrl.Output(OutputModes.Normal, "Debugger output: Current address is {0:x} \"{0:ys}\"", currentAddress);

            Console.Out.WriteLine("Current address (32-bit formatted) is {0}",
                                  DebugFormatter.FormatAddress(currentAddress, AddressFormatOptions.Force32Bit));
            Console.Out.WriteLine("Current address (64-bit formatted) is {0}",
                                  DebugFormatter.FormatAddress(currentAddress, AddressFormatOptions.Force64Bit));
        }
        catch (Exception e)
        {
            Console.Error.WriteLine("Exception thrown: {0}", e);
            return(1);
        }
        finally
        {
            if (cli != null)
            {
                cli.Dispose();
            }
            if (ctrl != null)
            {
                ctrl.Dispose();
            }
            if (sym != null)
            {
                sym.Dispose();
            }
            if (reg != null)
            {
                reg.Dispose();
            }
        }

        return(0);
    }