RynthCore/tools/HookResolver.UI/DiscoveryCandidateRow.cs
Tom Bohar 68c301dac8 RynthCore as of 2026-09-05 (internal f9abab9)
A snapshot of the working tree for aelrynth.com/git/: the code, build files
and public docs. Internal review notes and agent instructions are left out.
MIT licensed; see LICENSE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 21:22:59 -04:00

49 lines
1.6 KiB
C#

using System.Linq;
using System.Text;
using Avalonia.Media;
using RynthCore.HookManifest.Schema;
using RynthCore.HookResolver.Core.Discovery;
namespace RynthCore.HookResolver.UI;
public sealed class DiscoveryCandidateRow
{
public DiscoveryCandidateRow(StringDiscoveryCandidate candidate)
{
Candidate = candidate;
Va = $"0x{candidate.Va:X8}";
PushSiteVa = $"push @ 0x{candidate.PushSiteVa:X8}";
var s = candidate.Snapshot;
Summary = $"{s.LengthBytes} bytes • {s.InstructionCount} instr • " +
(s.EndsAtReturn ? "ends RET" : "no RET");
PrologueDisplay = FormatHex(s.PrologueHex);
CallTargetsDisplay = s.CallTargets.Count == 0
? "(none)"
: string.Join(" ", s.CallTargets.Take(5).Select(ct => $"+0x{ct.Offset:X3}→0x{ct.Va:X8}"));
AccentBrush = s.EndsAtReturn && s.LengthBytes > 16
? new SolidColorBrush(Color.Parse("#26C1A6"))
: new SolidColorBrush(Color.Parse("#E0B040"));
}
public StringDiscoveryCandidate Candidate { get; }
public FunctionSnapshot Snapshot => Candidate.Snapshot;
public string Va { get; }
public string PushSiteVa { get; }
public string Summary { get; }
public string PrologueDisplay { get; }
public string CallTargetsDisplay { get; }
public IBrush AccentBrush { get; }
private static string FormatHex(string raw)
{
var sb = new StringBuilder(raw.Length + raw.Length / 2);
for (int i = 0; i < raw.Length; i += 2)
{
if (i > 0) sb.Append(' ');
sb.Append(raw, i, 2);
}
return sb.ToString();
}
}