Skip to content

Commit b61edca

Browse files
committed
Changed 'Auto-name' into 'Init from RTTI' and it now also inits the vtable pointer automatically.
1 parent 208454e commit b61edca

File tree

5 files changed

+57
-47
lines changed

5 files changed

+57
-47
lines changed

ReClass.NET/Controls/MemoryViewControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ public void Reset()
706706
}
707707

708708

709-
public void AutoNameCurrentClassFromRTTI(ClassNode classNode)
709+
public void InitCurrentClassFromRTTI(ClassNode classNode)
710710
{
711711
var args = new DrawContextRequestEventArgs { Node = classNode };
712712

@@ -721,7 +721,7 @@ public void AutoNameCurrentClassFromRTTI(ClassNode classNode)
721721
Address = args.BaseAddress,
722722
Level = 0,
723723
};
724-
classNode.AutoNameFromRTTI(view);
724+
classNode.InitFromRTTI(view);
725725
}
726726
}
727727
}

ReClass.NET/Forms/MainForm.Designer.cs

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReClass.NET/Forms/MainForm.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ private void memoryViewControl_SelectionChanged(object sender, EventArgs e)
835835

836836
addBytesToolStripDropDownButton.Enabled = parentContainer != null || isContainerNode;
837837
insertBytesToolStripDropDownButton.Enabled = selectedNodes.Count == 1 && parentContainer != null && !isContainerNode;
838-
autoNameClassToolStripMenuItem.Enabled = nodeIsClass;
838+
initClassToolStripMenuItem.Enabled = nodeIsClass;
839839

840840
var enabled = selectedNodes.Count > 0 && !nodeIsClass;
841841
toolStrip.Items.OfType<TypeToolStripButton>().ForEach(b => b.Enabled = enabled);
@@ -1054,15 +1054,15 @@ private void memoryViewControl_DrawContextRequested(object sender, DrawContextRe
10541054
}
10551055

10561056

1057-
private void autoNameClassToolStripMenuItem_Click(object sender, EventArgs e)
1057+
private void initClassToolStripMenuItem_Click(object sender, EventArgs e)
10581058
{
10591059
var selectedNodes = memoryViewControl.GetSelectedNodes();
10601060
var node = selectedNodes.FirstOrDefault()?.Node;
10611061
if (node == null || !(node is ClassNode))
10621062
{
10631063
return;
10641064
}
1065-
memoryViewControl.AutoNameCurrentClassFromRTTI(node as ClassNode);
1065+
memoryViewControl.InitCurrentClassFromRTTI(node as ClassNode);
10661066
}
10671067
}
10681068
}

ReClass.NET/Nodes/BaseNode.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ public abstract class BaseNode
3939
/// <summary>Gets or sets the parent node.</summary>
4040
public BaseNode ParentNode { get; internal set; }
4141

42-
/// <summary>Gets a value indicating whether this node is wrapped into an other node. We see classnodes never as wrapped.</summary>
43-
public bool IsWrapped => (ParentNode is BaseWrapperNode && !(this is ClassNode));
42+
/// <summary>Gets a value indicating whether this node is wrapped into an other node. </summary>
43+
public bool IsWrapped => (ParentNode is BaseWrapperNode);
44+
45+
/// <summary>All nodes that are wrapped can't be selected except classnodes because they have a context menu</summary>
46+
public bool CanBeSelected => (!IsWrapped || (this is ClassNode));
4447

4548
/// <summary>Gets or sets a value indicating whether this node is hidden.</summary>
4649
public bool IsHidden { get; set; }
@@ -376,7 +379,7 @@ protected void AddSelection(DrawContext context, int x, int y, int height)
376379
Contract.Requires(context != null);
377380
Contract.Requires(context.Graphics != null);
378381

379-
if (y > context.ClientArea.Bottom || y + height < 0 || IsWrapped)
382+
if (y > context.ClientArea.Bottom || y + height < 0 || !CanBeSelected)
380383
{
381384
return;
382385
}

ReClass.NET/Nodes/ClassNode.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics.Contracts;
34
using System.Drawing;
45
using System.Linq;
@@ -52,8 +53,12 @@ public static ClassNode Create()
5253
return new ClassNode(true);
5354
}
5455

55-
56-
public void AutoNameFromRTTI(DrawContext context)
56+
57+
/// <summary>
58+
/// Initializes the class' name and vtable node from RTTI information, if it's not set already
59+
/// </summary>
60+
/// <param name="context"></param>
61+
public void InitFromRTTI(DrawContext context)
5762
{
5863
// first node should be a VTable node or a hex64/32 node
5964
if (Nodes.Count <= 0)
@@ -77,7 +82,9 @@ public void AutoNameFromRTTI(DrawContext context)
7782
if (!string.IsNullOrEmpty(rttiInfoFromFirstNode))
7883
{
7984
// convert first node to vtable node
80-
#warning IMPLEMENT: CONVERT NODE TO VTABLE NODE
85+
var newVTableNode = BaseNode.CreateInstanceFromType(typeof(VirtualMethodTableNode));
86+
var createdNodes = new List<BaseNode>();
87+
this.ReplaceChildNode(firstNode, newVTableNode, ref createdNodes);
8188
}
8289
}
8390
}

0 commit comments

Comments
 (0)