From 64c2ffbf06ba34c337afd52178ae8eeb99fb62d4 Mon Sep 17 00:00:00 2001 From: Glitchgod Date: Tue, 20 May 2025 22:50:52 +0100 Subject: [PATCH 1/2] initial breakpoint/exception work --- EmDbg.ImGui/Program.cs | 1 + EmDbg.ImGui/StatusWindow.cs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/EmDbg.ImGui/Program.cs b/EmDbg.ImGui/Program.cs index 8c20841..35b63f6 100644 --- a/EmDbg.ImGui/Program.cs +++ b/EmDbg.ImGui/Program.cs @@ -119,6 +119,7 @@ private static void SubmitUI() { StatusWindow.ShowWindow(_debugger); ConsoleWindow.ShowWindow(); + ExceptorBreakWindow.RenderWindow(); } } } diff --git a/EmDbg.ImGui/StatusWindow.cs b/EmDbg.ImGui/StatusWindow.cs index eeca0ea..b5e78bc 100644 --- a/EmDbg.ImGui/StatusWindow.cs +++ b/EmDbg.ImGui/StatusWindow.cs @@ -5,6 +5,7 @@ using System.Numerics; using System.Text; using System.Threading.Tasks; +using EmDbg.Types; namespace EmDbg.ImGuiUI { @@ -20,9 +21,11 @@ public static void HandleExecutionState(bool running) _is_running = running; _pending_change = true; } - public static bool ShowWindow(XboxDebugger debugger) { + debugger.cbExceptionHit += ex => ExceptorBreakWindow.ShowExceptionWindow(ex); + debugger.cbBreakpointHit += bp => ExceptorBreakWindow.ShowBreakpointWindow(bp); + ImGui.SetNextWindowPos(new Vector2(5, 5), ImGuiCond.Always); ImGui.SetNextWindowBgAlpha(0.35f); ImGui.Begin("Status", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize); From d749d6a82be33cbb9111346102b056759e081df8 Mon Sep 17 00:00:00 2001 From: Glitchgod Date: Tue, 20 May 2025 22:52:34 +0100 Subject: [PATCH 2/2] pt2 --- EmDbg.ImGui/ExceptorBreakWindow.cs | 90 ++++++++++++++++++++++++++++++ EmDbg.ImGui/imgui.ini | 32 +++++++++++ 2 files changed, 122 insertions(+) create mode 100644 EmDbg.ImGui/ExceptorBreakWindow.cs create mode 100644 EmDbg.ImGui/imgui.ini diff --git a/EmDbg.ImGui/ExceptorBreakWindow.cs b/EmDbg.ImGui/ExceptorBreakWindow.cs new file mode 100644 index 0000000..dfa770c --- /dev/null +++ b/EmDbg.ImGui/ExceptorBreakWindow.cs @@ -0,0 +1,90 @@ +using ImGuiNET; +using NeighborSharp.Types; +using NeighborSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; +using EmDbg.Types; + +namespace EmDbg.ImGuiUI +{ + internal class ExceptorBreakWindow + { + + private static bool _show_ui = false; + private static bool _is_breakpoint = false; + private static ExceptionInfo _exception_info; + private static Breakpoint _breakpoint_info; + + private static uint threadID; + private static uint address; + + public static void ShowExceptionWindow(ExceptionInfo ex) + { + _show_ui = true; + _exception_info = ex; + } + + public static void ShowBreakpointWindow(Breakpoint bp) + { + _show_ui = true; + _breakpoint_info = bp; + _is_breakpoint = true; + } + + public static bool RenderWindow() + { + // set the window data + ImGui.SetNextWindowPos(ImGui.GetMainViewport().GetCenter(), ImGuiCond.Once, new Vector2(0.5f, 0.5f)); + ImGui.SetNextWindowSize(new Vector2(300, 150)); + + if (_show_ui) + { + if (_is_breakpoint) + { + if (ImGui.Begin("Breakpoint Hit", ref _show_ui, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar )) + { + address = _breakpoint_info.breakAddr; + threadID = _breakpoint_info.thread; + + ImGui.Text("A breakpoint has been hit at:"); + ImGui.Text($"0x{address:X8}"); + ImGui.Text($"Thread/Module: 0x{threadID:X8}/TODO"); + ImGui.Text("Code Module: TODO"); + + if (ImGui.Button("Close")) + _show_ui = false; + } + // end displaying the window + ImGui.End(); + } + else + { + if (ImGui.Begin("Exception Thrown", ref _show_ui, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar )) + { + address = _exception_info.exceptAddress; + threadID = _exception_info.thread; + + ImGui.Text("An exception has been thrown at:"); + ImGui.Text($"0x{address:X8}"); + ImGui.Text($"Exception Code: 0x{address:X8}"); + ImGui.Text($"Exception Data: 0x{_exception_info.exceptType:X8}"); + ImGui.Text($"Thread/Module: 0x{threadID:X8}/TODO"); + ImGui.Text("Code Module: TODO"); + + if (ImGui.Button("Close")) + _show_ui = false; + } + // end displaying the window + ImGui.End(); + } + + } + return false; + } + } +} diff --git a/EmDbg.ImGui/imgui.ini b/EmDbg.ImGui/imgui.ini new file mode 100644 index 0000000..4380c15 --- /dev/null +++ b/EmDbg.ImGui/imgui.ini @@ -0,0 +1,32 @@ +[Window][Debug##Default] +Pos=440,160 +Size=400,400 +Collapsed=0 + +[Window][Select Console] +Pos=535,220 +Size=210,280 +Collapsed=0 + +[Window][Status] +Pos=5,5 +Size=219,86 +Collapsed=0 + +[Window][Debug Console] +Pos=657,72 +Size=600,400 +Collapsed=0 + +[Window][Exception Thrown] +Pos=490,285 +Size=300,150 +Collapsed=0 + +[Window][Dear ImGui Demo] +Pos=650,20 +Size=550,680 +Collapsed=0 + +[Docking][Data] +