forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNIntNode.cs
More file actions
57 lines (51 loc) · 1.42 KB
/
NIntNode.cs
File metadata and controls
57 lines (51 loc) · 1.42 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 NIntNode : BaseNumericNode
{
public override int MemorySize => IntPtr.Size;
public override void GetUserInterfaceInfo(out string name, out Image icon)
{
name = "NInt";
icon = Properties.Resources.B16x16_Button_NInt;
}
public override Size Draw(DrawContext context, int x, int y)
{
var value = ReadValueFromMemory(context.Memory)
#if RECLASSNET64
.ToInt64();
#else
.ToInt32();
#endif
return DrawNumeric(context, x, y, context.IconProvider.Signed, "NInt", value.ToString(), $"0x{value:X}");
}
public override void Update(HotSpot spot)
{
base.Update(spot);
if (spot.Id == 0 || spot.Id == 1)
{
#if RECLASSNET64
if (long.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && long.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
{
spot.Process.WriteRemoteMemory(spot.Address, val);
}
#else
if (int.TryParse(spot.Text, out var val) || spot.Text.TryGetHexString(out var hexValue) && int.TryParse(hexValue, NumberStyles.HexNumber, null, out val))
{
spot.Process.WriteRemoteMemory(spot.Address, val);
}
#endif
}
}
public IntPtr ReadValueFromMemory(MemoryBuffer memory)
{
return memory.ReadIntPtr(Offset);
}
}
}