Esempio n. 1
0
        public DebugException(EXCEPTION_RECORD32 ex, bool firstChance)
        {
            this.IsFirstChance = firstChance;
            Message            = GetCodeMessage(Code = ex.Code, out Title);
            this.Address       = ex.ExceptionAddress;
            this.IsContinuable = ex.ExceptionFlags == 0;

            if (ex.ExceptionRecord != IntPtr.Zero)
            {
                var innerExt = new EXCEPTION_RECORD32();
                Marshal.PtrToStructure(ex.ExceptionRecord, innerExt);
                InnerException = new DebugException(innerExt, firstChance);
            }
        }
Esempio n. 2
0
        public DebugException(EXCEPTION_RECORD32 ex, bool firstChance)
        {
            this.IsFirstChance = firstChance;
            Message = GetCodeMessage(Code = ex.Code, out Title);
            this.Address = ex.ExceptionAddress;
            this.IsContinuable = ex.ExceptionFlags == 0;

            if (ex.ExceptionRecord != IntPtr.Zero)
            {
                var innerExt = new EXCEPTION_RECORD32();
                Marshal.PtrToStructure(ex.ExceptionRecord, innerExt);
                InnerException = new DebugException(innerExt, firstChance);
            }
        }
Esempio n. 3
0
        void HandleException(DebugThread th, EXCEPTION_DEBUG_INFO e)
        {
            th.Context.Update();

            var code = e.ExceptionRecord.Code;
            // The instruction
            var targetSiteAddress = e.ExceptionRecord.ExceptionAddress;

            if (code == ExceptionCode.Breakpoint)
            {
                if (CodeStepping.lastUnhandledBreakpoint != null)
                {
                    CodeStepping.postBreakpointResetStepCompleted = true;
                }

                var bp = Breakpoints.ByAddress(targetSiteAddress);
                if (bp == null)
                {
                    return;
                }
                //APIIntermediate.GetCallStack_x86(th.OwnerProcess.Handle, (uint)th.StartAddress.ToInt32(), th.Context["ebp"], th.Context["eip"]);

                /*
                 * var sf = new STACKFRAME64();
                 * sf.AddrPC.Offset = th.Context["eip"];
                 * sf.AddrFrame.Offset = th.Context["ebp"];
                 * sf.AddrStack.Offset = th.Context["esp"];
                 * sf.AddrReturn.Mode = sf.AddrStack.Mode = sf.AddrPC.Mode = sf.AddrFrame.Mode = ADDRESS_MODE.AddrModeFlat;
                 *
                 * if(!API.StackWalk64(MachineType.i386, th.OwnerProcess.Handle, th.Handle, ref sf, ref th.Context.lastReadCtxt))
                 *      throw new Win32Exception(Marshal.GetLastWin32Error());
                 */
                th.CurrentInstruction = targetSiteAddress;
                bp.Disable();
                bp.temporarilyDisabled = true;
                CodeStepping.lastUnhandledBreakpoint       = bp;
                CodeStepping.lastUnhandledBreakpointThread = th;

                bp.WasHit();

                foreach (var l in DDebugger.EventListeners)
                {
                    l.OnBreakpoint(th, bp);
                }
            }
            else if (code == ExceptionCode.SingleStep)
            {
                if (CodeStepping.lastUnhandledBreakpoint != null)
                {
                    CodeStepping.postBreakpointResetStepCompleted = true;
                }
                else
                {
                    foreach (var l in DDebugger.EventListeners)
                    {
                        l.OnStepComplete(th);
                    }
                }
            }
            else
            {
                var ex = new DebugException(e.ExceptionRecord, e.dwFirstChance != 0);

                foreach (var l in DDebugger.EventListeners)
                {
                    l.OnException(th, ex);
                }

                LastException = ex;
            }
        }
Esempio n. 4
0
 public override void OnException(DebugThread thread, DebugException exception)
 {
     form.HighlightCurrentInstruction(thread);
 }
Esempio n. 5
0
        void HandleException(DebugThread th, EXCEPTION_DEBUG_INFO e)
        {
            th.Context.Update();

            var code = e.ExceptionRecord.Code;
            // The instruction
            var targetSiteAddress = e.ExceptionRecord.ExceptionAddress;
            if (code == ExceptionCode.Breakpoint)
            {
                if (CodeStepping.lastUnhandledBreakpoint != null)
                    CodeStepping.postBreakpointResetStepCompleted = true;

                var bp = Breakpoints.ByAddress(targetSiteAddress);
                if (bp == null)
                    return;
                //APIIntermediate.GetCallStack_x86(th.OwnerProcess.Handle, (uint)th.StartAddress.ToInt32(), th.Context["ebp"], th.Context["eip"]);
                /*
                var sf = new STACKFRAME64();
                sf.AddrPC.Offset = th.Context["eip"];
                sf.AddrFrame.Offset = th.Context["ebp"];
                sf.AddrStack.Offset = th.Context["esp"];
                sf.AddrReturn.Mode = sf.AddrStack.Mode = sf.AddrPC.Mode = sf.AddrFrame.Mode = ADDRESS_MODE.AddrModeFlat;

                if(!API.StackWalk64(MachineType.i386, th.OwnerProcess.Handle, th.Handle, ref sf, ref th.Context.lastReadCtxt))
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                */
                th.CurrentInstruction = targetSiteAddress;
                bp.Disable();
                bp.temporarilyDisabled = true;
                CodeStepping.lastUnhandledBreakpoint = bp;
                CodeStepping.lastUnhandledBreakpointThread = th;

                bp.WasHit();

                foreach (var l in DDebugger.EventListeners)
                    l.OnBreakpoint(th, bp);
            }
            else if (code == ExceptionCode.SingleStep)
            {
                if (CodeStepping.lastUnhandledBreakpoint != null)
                    CodeStepping.postBreakpointResetStepCompleted = true;
                else
                    foreach (var l in DDebugger.EventListeners)
                        l.OnStepComplete(th);
            }
            else
            {
                var ex = new DebugException(e.ExceptionRecord, e.dwFirstChance != 0);

                foreach (var l in DDebugger.EventListeners)
                    l.OnException(th, ex);

                LastException = ex;
            }
        }
Esempio n. 6
0
 public virtual void OnException(DebugThread thread, DebugException exception)
 {
 }
Esempio n. 7
0
 public virtual void OnException(DebugThread thread, DebugException exception)
 {
 }