forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassPtrNode.cs
More file actions
119 lines (92 loc) · 2.78 KB
/
Copy pathClassPtrNode.cs
File metadata and controls
119 lines (92 loc) · 2.78 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Drawing;
using System.Globalization;
using ReClassNET.Extensions;
using ReClassNET.Memory;
using ReClassNET.UI;
using ReClassNET.Util;
namespace ReClassNET.Nodes
{
public class ClassPtrNode : BaseReferenceNode
{
private readonly MemoryBuffer memory = new MemoryBuffer();
public override int MemorySize => IntPtr.Size;
public override bool PerformCycleCheck => false;
public override void Intialize()
{
var node = ClassNode.Create();
node.Intialize();
node.AddBytes(64);
InnerNode = node;
}
public override Size Draw(ViewInfo view, int x, int y)
{
if (IsHidden)
{
return DrawHidden(view, x, y);
}
DrawInvalidMemoryIndicator(view, y);
var origX = x;
var origY = y;
AddSelection(view, x, y, view.Font.Height);
x = AddOpenClose(view, x, y);
x = AddIcon(view, x, y, Icons.Pointer, -1, HotSpotType.None);
var tx = x;
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, "Ptr") + view.Font.Width;
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.NoneId, $"<{InnerNode.Name}>") + view.Font.Width;
x = AddIcon(view, x, y, Icons.Change, 4, HotSpotType.ChangeType) + view.Font.Width;
var ptr = view.Memory.ReadIntPtr(Offset);
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.NoneId, "->") + view.Font.Width;
x = AddText(view, x, y, view.Settings.ValueColor, 0, "0x" + ptr.ToString(Constants.AddressHexFormat)) + view.Font.Width;
x = AddComment(view, x, y);
AddTypeDrop(view, y);
AddDelete(view, y);
y += view.Font.Height;
var size = new Size(x - origX, y - origY);
if (levelsOpen[view.Level])
{
memory.Size = InnerNode.MemorySize;
memory.Process = view.Memory.Process;
memory.Update(ptr);
var v = view.Clone();
v.Address = ptr;
v.Memory = memory;
var innerSize = InnerNode.Draw(v, tx, y);
size.Width = Math.Max(size.Width, innerSize.Width + tx - origX);
size.Height += innerSize.Height;
}
return size;
}
public override int CalculateDrawnHeight(ViewInfo view)
{
if (IsHidden)
{
return HiddenHeight;
}
var height = view.Font.Height;
if (levelsOpen[view.Level])
{
height += InnerNode.CalculateDrawnHeight(view);
}
return height;
}
public override void Update(HotSpot spot)
{
base.Update(spot);
if (spot.Id == 0)
{
if (spot.Text.TryGetHexString(out var hexValue) && long.TryParse(hexValue, NumberStyles.HexNumber, null, out var val))
{
#if RECLASSNET64
var address = (IntPtr)val;
#else
var address = (IntPtr)unchecked((int)val);
#endif
spot.Memory.Process.WriteRemoteMemory(spot.Address, address);
}
}
}
}
}