Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions EmDbg.ImGui/ExceptorBreakWindow.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
1 change: 1 addition & 0 deletions EmDbg.ImGui/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static void SubmitUI()
{
StatusWindow.ShowWindow(_debugger);
ConsoleWindow.ShowWindow();
ExceptorBreakWindow.RenderWindow();
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion EmDbg.ImGui/StatusWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using EmDbg.Types;

namespace EmDbg.ImGuiUI
{
Expand All @@ -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);
Expand Down
32 changes: 32 additions & 0 deletions EmDbg.ImGui/imgui.ini
Original file line number Diff line number Diff line change
@@ -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]