-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathVTableNode.cs
More file actions
163 lines (125 loc) · 3.07 KB
/
VTableNode.cs
File metadata and controls
163 lines (125 loc) · 3.07 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
153
154
155
156
157
158
159
160
161
162
163
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using ReClassNET.Memory;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public class VTableNode : BaseContainerNode
{
private readonly MemoryBuffer memory = new MemoryBuffer();
public override int MemorySize => IntPtr.Size;
public override void Intialize()
{
AddBytes(10 * IntPtr.Size);
}
public override void ClearSelection()
{
base.ClearSelection();
foreach (var node in nodes)
{
node.ClearSelection();
}
}
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.VTable, -1, HotSpotType.None);
var tx = x;
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, view.Settings.VTableColor, HotSpot.NoneId, $"VTable[{nodes.Count}]") + view.Font.Width;
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + 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])
{
var ptr = view.Memory.ReadIntPtr(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)
{
var innerSize = node.Draw(v, tx, y);
size.Width = Math.Max(size.Width, innerSize.Width + tx - origX);
size.Height += innerSize.Height;
y += innerSize.Height;
}
}
return size;
}
public override int CalculateDrawnHeight(ViewInfo view)
{
if (IsHidden)
{
return HiddenHeight;
}
var height = view.Font.Height;
if (levelsOpen[view.Level])
{
height += nodes.Sum(n => n.CalculateDrawnHeight(view));
}
return height;
}
public override bool ReplaceChildNode(int index, Type nodeType, ref List<BaseNode> createdNodes) => false;
public override void InsertBytes(int index, int size, ref List<BaseNode> createdNodes)
{
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);
createdNodes?.Add(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;
}
}
}