Skip to content

Commit 8773c39

Browse files
committed
Added nodes for native integer sizes.
1 parent 062cced commit 8773c39

File tree

4 files changed

+122
-1
lines changed

4 files changed

+122
-1
lines changed

ReClass.NET/Memory/MemoryBuffer.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Diagnostics.Contracts;
33
using System.Runtime.InteropServices;
44
using System.Text;
@@ -326,6 +326,20 @@ public IntPtr ReadIntPtr(int offset)
326326
#endif
327327
}
328328

329+
/// <summary>Reads a <see cref="UIntPtr"/> from the specific offset.</summary>
330+
/// <param name="offset">The offset into the data.</param>
331+
/// <returns>The data read as <see cref="UIntPtr"/> or 0 if the offset is outside the data.</returns>
332+
public UIntPtr ReadUIntPtr(int offset)
333+
{
334+
Contract.Requires(offset >= 0);
335+
336+
#if RECLASSNET64
337+
return (UIntPtr)ReadUInt64(offset);
338+
#else
339+
return (UIntPtr)ReadUInt32(offset);
340+
#endif
341+
}
342+
329343
#endregion
330344

331345
public string ReadString(Encoding encoding, int offset, int length)

ReClass.NET/Nodes/IntNativeNode.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Drawing;
3+
using System.Globalization;
4+
using ReClassNET.Controls;
5+
using ReClassNET.Extensions;
6+
using ReClassNET.Memory;
7+
using ReClassNET.UI;
8+
9+
namespace ReClassNET.Nodes
10+
{
11+
public class IntNativeNode : BaseNumericNode
12+
{
13+
public override int MemorySize => 8;
14+
15+
public override void GetUserInterfaceInfo(out string name, out Image icon)
16+
{
17+
name = "NInt";
18+
icon = Properties.Resources.B16x16_Button_Int_64;
19+
}
20+
21+
public override Size Draw(DrawContext context, int x, int y)
22+
{
23+
var value = ReadValueFromMemory(context.Memory);
24+
return DrawNumeric(context, x, y, context.IconProvider.Signed, "NInt", value.ToInt64().ToString(), "0x" + value.ToString(Constants.AddressHexFormat));
25+
}
26+
27+
public override void Update(HotSpot spot)
28+
{
29+
base.Update(spot);
30+
31+
if (spot.Id == 0 || spot.Id == 1)
32+
{
33+
#if RECLASSNET64
34+
if (long.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && long.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
35+
{
36+
spot.Process.WriteRemoteMemory(spot.Address, val);
37+
}
38+
#else
39+
if (int.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && int.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
40+
{
41+
spot.Process.WriteRemoteMemory(spot.Address, val);
42+
}
43+
#endif
44+
}
45+
}
46+
47+
public IntPtr ReadValueFromMemory(MemoryBuffer memory)
48+
{
49+
return memory.ReadIntPtr(Offset);
50+
}
51+
}
52+
}

ReClass.NET/Nodes/UIntNativeNode.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Drawing;
3+
using System.Globalization;
4+
using ReClassNET.Controls;
5+
using ReClassNET.Extensions;
6+
using ReClassNET.Memory;
7+
using ReClassNET.UI;
8+
9+
namespace ReClassNET.Nodes
10+
{
11+
public class UIntNativeNode : BaseNumericNode
12+
{
13+
public override int MemorySize => 8;
14+
15+
public override void GetUserInterfaceInfo(out string name, out Image icon)
16+
{
17+
name = "NUInt";
18+
icon = Properties.Resources.B16x16_Button_UInt_64;
19+
}
20+
21+
public override Size Draw(DrawContext context, int x, int y)
22+
{
23+
var value = ReadValueFromMemory(context.Memory);
24+
var uvalue = value.ToUInt64();
25+
return DrawNumeric(context, x, y, context.IconProvider.Unsigned, "NUInt", uvalue.ToString(), "0x" + uvalue.ToString(Constants.AddressHexFormat));
26+
}
27+
28+
public override void Update(HotSpot spot)
29+
{
30+
base.Update(spot);
31+
32+
if (spot.Id == 0 || spot.Id == 1)
33+
{
34+
#if RECLASSNET64
35+
if (ulong.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && ulong.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
36+
{
37+
spot.Process.WriteRemoteMemory(spot.Address, val);
38+
}
39+
#else
40+
if (uint.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && uint.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
41+
{
42+
spot.Process.WriteRemoteMemory(spot.Address, val);
43+
}
44+
#endif
45+
}
46+
}
47+
48+
public UIntPtr ReadValueFromMemory(MemoryBuffer memory)
49+
{
50+
return memory.ReadUIntPtr(Offset);
51+
}
52+
}
53+
}

ReClass.NET/ReClass.NET.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@
289289
<Compile Include="Nodes\ClassUtil.cs" />
290290
<Compile Include="Nodes\EnumNode.cs" />
291291
<Compile Include="Nodes\FunctionNode.cs" />
292+
<Compile Include="Nodes\IntNativeNode.cs" />
292293
<Compile Include="Nodes\NodeUuid.cs" />
293294
<Compile Include="Nodes\PointerNode.cs" />
295+
<Compile Include="Nodes\UIntNativeNode.cs" />
294296
<Compile Include="Nodes\UnionNode.cs" />
295297
<Compile Include="Project\CppTypeMapping.cs" />
296298
<Compile Include="Project\EnumDescription.cs" />

0 commit comments

Comments
 (0)