forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVTableNode.cs
More file actions
152 lines (121 loc) · 2.94 KB
/
VTableNode.cs
File metadata and controls
152 lines (121 loc) · 2.94 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Linq;
using ReClassNET.Memory;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public class VTableNode : BaseContainerNode
{
private readonly MemoryBuffer memory = new MemoryBuffer();
/// <summary>Size of the node in bytes.</summary>
public override int MemorySize => IntPtr.Size;
public override void Intialize()
{
InsertBytes(0, 10 * IntPtr.Size);
}
public override void ClearSelection()
{
base.ClearSelection();
foreach (var node in nodes)
{
node.ClearSelection();
}
}
/// <summary>Draws this node.</summary>
/// <param name="view">The view information.</param>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <returns>The height the node occupies.</returns>
public override int Draw(ViewInfo view, int x, int y)
{
if (IsHidden)
{
return DrawHidden(view, x, y);
}
AddSelection(view, x, y, view.Font.Height);
AddDelete(view, x, y);
AddTypeDrop(view, x, y);
x = AddOpenClose(view, x, y);
x = AddIcon(view, x, y, Icons.VTable, -1, HotSpotType.None);
var tx = x;
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, Program.Settings.VTableColor, HotSpot.NoneId, $"VTable[{nodes.Count}]") + view.Font.Width;
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
AddComment(view, x, y);
y += view.Font.Height;
if (levelsOpen[view.Level])
{
var ptr = view.Memory.ReadObject<IntPtr>(Offset);
memory.Size = nodes.Count * IntPtr.Size;
memory.Process = view.Memory.Process;
memory.Update(ptr);
var v = view.Clone();
v.Address = ptr;
v.Memory = memory;
foreach (var node in nodes)
{
y = node.Draw(v, tx, y);
}
}
return y;
}
public override int CalculateHeight(ViewInfo view)
{
if (IsHidden)
{
return HiddenHeight;
}
var h = view.Font.Height;
if (levelsOpen[view.Level])
{
h += nodes.Sum(n => n.CalculateHeight(view));
}
return h;
}
public override bool ReplaceChildNode(int index, BaseNode node) => false;
public override void InsertBytes(int index, int size)
{
if (index < 0 || index > nodes.Count || size == 0)
{
return;
}
var offset = IntPtr.Zero;
if (index > 0)
{
var node = nodes[index - 1];
offset = node.Offset + node.MemorySize;
}
while (size > 0)
{
var node = new VMethodNode
{
Offset = offset,
ParentNode = this
};
nodes.Insert(index, node);
offset += node.MemorySize;
size -= node.MemorySize;
index++;
}
UpdateOffsets();
}
public override void InsertNode(int index, BaseNode node)
{
if (!(node is VMethodNode))
{
return;
}
base.InsertNode(index, node);
UpdateOffsets();
}
public override bool RemoveNode(BaseNode node)
{
var removed = base.RemoveNode(node);
if (removed)
{
UpdateOffsets();
}
return removed;
}
}
}