-
Notifications
You must be signed in to change notification settings - Fork 404
Expand file tree
/
Copy pathBaseHexCommentNode.cs
More file actions
92 lines (82 loc) · 2.97 KB
/
Copy pathBaseHexCommentNode.cs
File metadata and controls
92 lines (82 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using ReClassNET.UI;
using ReClassNET.Util;
namespace ReClassNET.Nodes
{
public abstract class BaseHexCommentNode : BaseHexNode
{
protected int AddComment(ViewInfo view, int x, int y, float fvalue, IntPtr ivalue, UIntPtr uvalue)
{
Contract.Requires(view != null);
if (view.Settings.ShowCommentFloat)
{
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, $"({(fvalue > -99999.0f && fvalue < 99999.0f ? fvalue : 0.0f):0.000})");
}
if (view.Settings.ShowCommentInteger)
{
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, ivalue == IntPtr.Zero ? "(0)" : $"({ivalue.ToInt64()}|0x{uvalue.ToUInt64():X})");
}
var namedAddress = view.Memory.Process.GetNamedAddress(ivalue);
if (!string.IsNullOrEmpty(namedAddress))
{
x += view.Font.Width;
if (view.Settings.ShowCommentPointer)
{
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.NoneId, "->") + view.Font.Width;
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, namedAddress) + view.Font.Width;
}
if (view.Settings.ShowCommentRtti)
{
var rtti = view.Memory.Process.ReadRemoteRuntimeTypeInformation(ivalue);
if (!string.IsNullOrEmpty(rtti))
{
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, rtti) + view.Font.Width;
}
}
if (view.Settings.ShowCommentSymbol)
{
var module = view.Memory.Process.GetModuleToPointer(ivalue);
if (module != null)
{
var symbols = view.Memory.Process.Symbols.GetSymbolsForModule(module);
var symbol = symbols?.GetSymbolString(ivalue, module);
if (!string.IsNullOrEmpty(symbol))
{
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, symbol) + view.Font.Width;
}
}
}
if (view.Settings.ShowCommentString)
{
var data = view.Memory.Process.ReadRemoteMemory(ivalue, 64);
// First check if it could be an UTF8 string and if not try UTF16.
if (data.Take(IntPtr.Size).InterpretAsUTF8().IsPrintableData())
{
var text = new string(Encoding.UTF8.GetChars(data).TakeWhile(c => c != 0).ToArray());
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.ReadOnlyId, $"'{text}'") + view.Font.Width;
}
else if(data.Take(IntPtr.Size * 2).InterpretAsUTF16().IsPrintableData())
{
var text = new string(Encoding.Unicode.GetChars(data).TakeWhile(c => c != 0).ToArray());
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.ReadOnlyId, $"L'{text}'") + view.Font.Width;
}
}
if (view.Settings.ShowCommentPluginInfo)
{
foreach (var reader in NodeInfoReader)
{
var info = reader.ReadNodeInfo(this, ivalue, view.Memory);
if (info != null)
{
x = AddText(view, x, y, view.Settings.PluginColor, HotSpot.ReadOnlyId, info) + view.Font.Width;
}
}
}
}
return x;
}
}
}