-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathNUIntNode.cs
More file actions
57 lines (51 loc) · 1.43 KB
/
NUIntNode.cs
File metadata and controls
57 lines (51 loc) · 1.43 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
using System;
using System.Drawing;
using System.Globalization;
using ReClassNET.Controls;
using ReClassNET.Extensions;
using ReClassNET.Memory;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public class NUIntNode : BaseNumericNode
{
public override int MemorySize => UIntPtr.Size;
public override void GetUserInterfaceInfo(out string name, out Image icon)
{
name = "NUInt";
icon = Properties.Resources.B16x16_Button_NUInt;
}
public override Size Draw(DrawContext context, int x, int y)
{
var value = ReadValueFromMemory(context.Memory)
#if RECLASSNET64
.ToUInt64();
#else
.ToUInt32();
#endif
return DrawNumeric(context, x, y, context.IconProvider.Unsigned, "NUInt", value.ToString(), $"0x{value:X}");
}
public override void Update(HotSpot spot)
{
base.Update(spot);
if (spot.Id == 0 || spot.Id == 1)
{
#if RECLASSNET64
if (ulong.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && ulong.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
{
spot.Process.WriteRemoteMemory(spot.Address, val);
}
#else
if (uint.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && uint.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
{
spot.Process.WriteRemoteMemory(spot.Address, val);
}
#endif
}
}
public UIntPtr ReadValueFromMemory(MemoryBuffer memory)
{
return memory.ReadUIntPtr(Offset);
}
}
}