Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Removed 2nd empty lines when introduced, added 32bit version of ReadF…
…romBuffer to MemoryBuffer, have refactored Hex32Node to use this method instead, have removed unnecessary braces and brackets.
  • Loading branch information
FransBouma committed Jul 4, 2023
commit aa8a85788a1410ab7ef5dfdf529fa596552b2a43
3 changes: 1 addition & 2 deletions ReClass.NET/Controls/MemoryViewControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,7 @@ public void Reset()

VerticalScroll.Value = VerticalScroll.Minimum;
}



public void InitCurrentClassFromRTTI(ClassNode classNode)
{
var args = new DrawContextRequestEventArgs { Node = classNode };
Expand Down
3 changes: 1 addition & 2 deletions ReClass.NET/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,7 @@ private void memoryViewControl_DrawContextRequested(object sender, DrawContextRe
args.BaseAddress = address;
}
}



private void initClassToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectedNodes = memoryViewControl.GetSelectedNodes();
Expand Down
11 changes: 8 additions & 3 deletions ReClass.NET/Memory/MemoryBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,17 @@ public bool HasChanged(int offset, int length)

return false;
}


public UInt64FloatDoubleData ReadFromBuffer(int offset) => new UInt64FloatDoubleData

public UInt64FloatDoubleData InterpretData64(int offset) => new UInt64FloatDoubleData
{
Raw1 = ReadInt32(offset),
Raw2 = ReadInt32(offset + sizeof(int))
};


public UInt32FloatData InterpretData32(int offset) => new UInt32FloatData
{
Raw = ReadInt32(offset)
};
}
}
1 change: 0 additions & 1 deletion ReClass.NET/Nodes/BaseHexCommentNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ protected int AddComment(DrawContext view, int x, int y, float fvalue, IntPtr iv
return x;
}


public string GetAssociatedRemoteRuntimeTypeInformation(DrawContext context, IntPtr ivalue)
{
return context.Process.ReadRemoteRuntimeTypeInformation(ivalue);
Expand Down
4 changes: 2 additions & 2 deletions ReClass.NET/Nodes/BaseNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public abstract class BaseNode
public BaseNode ParentNode { get; internal set; }

/// <summary>Gets a value indicating whether this node is wrapped into an other node. </summary>
public bool IsWrapped => (ParentNode is BaseWrapperNode);
public bool IsWrapped => ParentNode is BaseWrapperNode;

/// <summary>All nodes that are wrapped can't be selected except classnodes because they have a context menu</summary>
public bool CanBeSelected => (!IsWrapped || (this is ClassNode));
public bool CanBeSelected => !IsWrapped || (this is ClassNode);

/// <summary>Gets or sets a value indicating whether this node is hidden.</summary>
public bool IsHidden { get; set; }
Expand Down
25 changes: 10 additions & 15 deletions ReClass.NET/Nodes/ClassNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public static ClassNode Create()

return new ClassNode(true);
}



/// <summary>
/// Initializes the class' name and vtable node from RTTI information, if it's not set already
/// </summary>
Expand All @@ -72,20 +71,17 @@ public void InitFromRTTI(DrawContext context)
{
rttiInfoFromFirstNode = vtableNode.GetAssociatedRemoteRuntimeTypeInformation(context);
}
else
else if (firstNode is BaseHexCommentNode baseHexCommentNode)
{
if (firstNode is BaseHexCommentNode baseHexCommentNode)
// ask it as if it might point to a vtable
var value = context.Memory.InterpretData64(Offset);
rttiInfoFromFirstNode = baseHexCommentNode.GetAssociatedRemoteRuntimeTypeInformation(context, value.IntPtr);
if (!string.IsNullOrEmpty(rttiInfoFromFirstNode))
{
// ask it as if it might point to a vtable
var value = context.Memory.ReadFromBuffer(Offset);
rttiInfoFromFirstNode = baseHexCommentNode.GetAssociatedRemoteRuntimeTypeInformation(context, value.IntPtr);
if (!string.IsNullOrEmpty(rttiInfoFromFirstNode))
{
// convert first node to vtable node
var newVTableNode = BaseNode.CreateInstanceFromType(typeof(VirtualMethodTableNode));
var createdNodes = new List<BaseNode>();
this.ReplaceChildNode(firstNode, newVTableNode, ref createdNodes);
}
// convert first node to vtable node
var newVTableNode = BaseNode.CreateInstanceFromType(typeof(VirtualMethodTableNode));
var createdNodes = new List<BaseNode>();
this.ReplaceChildNode(firstNode, newVTableNode, ref createdNodes);
}
}

Expand All @@ -98,7 +94,6 @@ public void InitFromRTTI(DrawContext context)
this.Name = fragments[0];
}


public override void GetUserInterfaceInfo(out string name, out Image icon)
{
throw new InvalidOperationException($"The '{nameof(ClassNode)}' node should not be accessible from the ui.");
Expand Down
11 changes: 3 additions & 8 deletions ReClass.NET/Nodes/Hex32Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void GetUserInterfaceInfo(out string name, out Image icon)

public override bool UseMemoryPreviewToolTip(HotSpot spot, out IntPtr address)
{
var value = ReadFromBuffer(spot.Memory, Offset);
var value = spot.Memory.InterpretData32(Offset);

address = value.IntPtr;

Expand All @@ -27,7 +27,7 @@ public override bool UseMemoryPreviewToolTip(HotSpot spot, out IntPtr address)

public override string GetToolTipText(HotSpot spot)
{
var value = ReadFromBuffer(spot.Memory, Offset);
var value = spot.Memory.InterpretData32(Offset);

return $"Int32: {value.IntValue}\nUInt32: 0x{value.UIntValue:X08}\nFloat: {value.FloatValue:0.000}";
}
Expand All @@ -46,16 +46,11 @@ protected override int AddComment(DrawContext context, int x, int y)
{
x = base.AddComment(context, x, y);

var value = ReadFromBuffer(context.Memory, Offset);
var value = context.Memory.InterpretData32(Offset);

x = AddComment(context, x, y, value.FloatValue, value.IntPtr, value.UIntPtr);

return x;
}

private static UInt32FloatData ReadFromBuffer(MemoryBuffer memory, int offset) => new UInt32FloatData
{
Raw = memory.ReadInt32(offset)
};
}
}
6 changes: 3 additions & 3 deletions ReClass.NET/Nodes/Hex64Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void GetUserInterfaceInfo(out string name, out Image icon)

public override bool UseMemoryPreviewToolTip(HotSpot spot, out IntPtr address)
{
var value = spot.Memory.ReadFromBuffer(Offset);
var value = spot.Memory.InterpretData64(Offset);

address = value.IntPtr;

Expand All @@ -27,7 +27,7 @@ public override bool UseMemoryPreviewToolTip(HotSpot spot, out IntPtr address)

public override string GetToolTipText(HotSpot spot)
{
var value = spot.Memory.ReadFromBuffer(Offset);
var value = spot.Memory.InterpretData64(Offset);

return $"Int64: {value.LongValue}\nUInt64: 0x{value.ULongValue:X016}\nFloat: {value.FloatValue:0.000}\nDouble: {value.DoubleValue:0.000}";
}
Expand All @@ -46,7 +46,7 @@ protected override int AddComment(DrawContext context, int x, int y)
{
x = base.AddComment(context, x, y);

var value = context.Memory.ReadFromBuffer(Offset);
var value = context.Memory.InterpretData64(Offset);

x = AddComment(context, x, y, value.FloatValue, value.IntPtr, value.UIntPtr);

Expand Down
3 changes: 1 addition & 2 deletions ReClass.NET/Nodes/PointerNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ public override int CalculateDrawnHeight(DrawContext context)
}
return height;
}



public override void PerformPostInitWork()
{
base.PerformPostInitWork();
Expand Down
11 changes: 4 additions & 7 deletions ReClass.NET/Nodes/VirtualMethodTableNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public override void Initialize()
AddNode(CreateDefaultNodeForSize(IntPtr.Size));
}
}



protected override int AddComment(DrawContext context, int x, int y)
{
x = base.AddComment(context, x, y);
Expand All @@ -49,20 +48,18 @@ protected override int AddComment(DrawContext context, int x, int y)
}
return x;
}



public string GetAssociatedRemoteRuntimeTypeInformation(DrawContext context)
{
var addressFirstVTableFunction = context.Memory.ReadFromBuffer(Offset).IntPtr;
var addressFirstVTableFunction = context.Memory.InterpretData64(Offset).IntPtr;
if (addressFirstVTableFunction != IntPtr.Zero)
{
return context.Process.ReadRemoteRuntimeTypeInformation(addressFirstVTableFunction);
}

return string.Empty;
}



public override Size Draw(DrawContext context, int x, int y)
{
if (IsHidden && !IsWrapped)
Expand Down
6 changes: 1 addition & 5 deletions ReClass.NET/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public Settings()
{ typeof(EnumNode), Keys.Control | Keys.Shift | Keys.E },
{ typeof(Int32Node), Keys.Control | Keys.Shift | Keys.I }
};

// Define more here.
}


// Application Settings

Expand Down Expand Up @@ -103,8 +100,7 @@ public Settings()
public Color PluginColor { get; set; } = Color.FromArgb(255, 0, 255);

public CustomDataMap CustomData { get; } = new CustomDataMap();



public Keys GetShortcutKeyForNodeType(Type nodeType)
{
return !_shortcutKeyPerNode.TryGetValue(nodeType, out var shortcutKeys) ? Keys.None : shortcutKeys;
Expand Down