From d41da727a123afdf881b5a09d0605433857c8dc9 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Thu, 15 Oct 2020 15:45:25 +0200 Subject: [PATCH] feat: add debug view for scanned addresses --- Dalamud/Game/Internal/BaseAddressResolver.cs | 13 ++++++++++++- Dalamud/Interface/DalamudDataWindow.cs | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Dalamud/Game/Internal/BaseAddressResolver.cs b/Dalamud/Game/Internal/BaseAddressResolver.cs index 6c465b931..6adac49f9 100644 --- a/Dalamud/Game/Internal/BaseAddressResolver.cs +++ b/Dalamud/Game/Internal/BaseAddressResolver.cs @@ -1,9 +1,13 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; namespace Dalamud.Game.Internal { public abstract class BaseAddressResolver { protected bool IsResolved { get; set; } + + public static Dictionary> DebugScannedValues = new Dictionary>(); public void Setup(SigScanner scanner) { // Because C# don't allow to call virtual function while in ctor @@ -19,7 +23,14 @@ namespace Dalamud.Game.Internal { Setup64Bit(scanner); } SetupInternal(scanner); - + + var className = GetType().Name; + DebugScannedValues[className] = new List<(string, IntPtr)>(); + + foreach (var property in GetType().GetProperties().Where(x => x.PropertyType == typeof(IntPtr))) { + DebugScannedValues[className].Add((property.Name, (IntPtr) property.GetValue(this))); + } + IsResolved = true; } diff --git a/Dalamud/Interface/DalamudDataWindow.cs b/Dalamud/Interface/DalamudDataWindow.cs index d7d867a6e..a489e5d52 100644 --- a/Dalamud/Interface/DalamudDataWindow.cs +++ b/Dalamud/Interface/DalamudDataWindow.cs @@ -8,6 +8,7 @@ using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Actors.Types; using Dalamud.Game.ClientState.Actors.Types.NonPlayer; using Dalamud.Game.ClientState.Structs.JobGauge; +using Dalamud.Game.Internal; using Dalamud.Plugin; using ImGuiNET; using JetBrains.Annotations; @@ -22,7 +23,6 @@ namespace Dalamud.Interface private bool wasReady; private string serverOpString; - private string cfcString = "N/A"; private int currentKind; @@ -59,7 +59,7 @@ namespace Dalamud.Interface ImGui.SameLine(); var copy = ImGui.Button("Copy all"); ImGui.SameLine(); - ImGui.Combo("Data kind", ref this.currentKind, new[] {"ServerOpCode", "ContentFinderCondition", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition", "Gauge", "Command"}, + ImGui.Combo("Data kind", ref this.currentKind, new[] {"ServerOpCode", "Address", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition", "Gauge", "Command"}, 9); ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar); @@ -75,7 +75,19 @@ namespace Dalamud.Interface ImGui.TextUnformatted(this.serverOpString); break; case 1: - ImGui.TextUnformatted(this.cfcString); + + foreach (var debugScannedValue in BaseAddressResolver.DebugScannedValues) { + ImGui.TextUnformatted($"{debugScannedValue.Key}"); + foreach (var valueTuple in debugScannedValue.Value) { + ImGui.TextUnformatted($" {valueTuple.Item1} - 0x{valueTuple.Item2.ToInt64():x}"); + ImGui.SameLine(); + + if (ImGui.Button("C")) { + ImGui.SetClipboardText(valueTuple.Item2.ToInt64().ToString("x")); + } + } + } + break; // AT