feat: add debug view for scanned addresses

This commit is contained in:
goat 2020-10-15 15:45:25 +02:00
parent 078fdff766
commit d41da727a1
2 changed files with 27 additions and 4 deletions

View file

@ -1,9 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Dalamud.Game.Internal { namespace Dalamud.Game.Internal {
public abstract class BaseAddressResolver { public abstract class BaseAddressResolver {
protected bool IsResolved { get; set; } protected bool IsResolved { get; set; }
public static Dictionary<string, List<(string, IntPtr)>> DebugScannedValues = new Dictionary<string, List<(string, IntPtr)>>();
public void Setup(SigScanner scanner) { public void Setup(SigScanner scanner) {
// Because C# don't allow to call virtual function while in ctor // Because C# don't allow to call virtual function while in ctor
@ -19,7 +23,14 @@ namespace Dalamud.Game.Internal {
Setup64Bit(scanner); Setup64Bit(scanner);
} }
SetupInternal(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; IsResolved = true;
} }

View file

@ -8,6 +8,7 @@ using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Actors.Types; using Dalamud.Game.ClientState.Actors.Types;
using Dalamud.Game.ClientState.Actors.Types.NonPlayer; using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
using Dalamud.Game.ClientState.Structs.JobGauge; using Dalamud.Game.ClientState.Structs.JobGauge;
using Dalamud.Game.Internal;
using Dalamud.Plugin; using Dalamud.Plugin;
using ImGuiNET; using ImGuiNET;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -22,7 +23,6 @@ namespace Dalamud.Interface
private bool wasReady; private bool wasReady;
private string serverOpString; private string serverOpString;
private string cfcString = "N/A";
private int currentKind; private int currentKind;
@ -59,7 +59,7 @@ namespace Dalamud.Interface
ImGui.SameLine(); ImGui.SameLine();
var copy = ImGui.Button("Copy all"); var copy = ImGui.Button("Copy all");
ImGui.SameLine(); 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); 9);
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar); ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
@ -75,7 +75,19 @@ namespace Dalamud.Interface
ImGui.TextUnformatted(this.serverOpString); ImGui.TextUnformatted(this.serverOpString);
break; break;
case 1: 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; break;
// AT // AT