-
Notifications
You must be signed in to change notification settings - Fork 388
Add uintptr_t and intptr_t data types (#134) #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8877c9d
1ff91d1
e457183
c340aaa
009be2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Globalization; | ||
using ReClassNET.Extensions; | ||
using ReClassNET.Memory; | ||
using ReClassNET.UI; | ||
|
||
namespace ReClassNET.Nodes | ||
{ | ||
public class IntPtrNode : BaseNumericNode | ||
{ | ||
public override int MemorySize => IntPtr.Size; | ||
|
||
public override void GetUserInterfaceInfo(out string name, out Image icon) | ||
{ | ||
name = "IntPtr"; | ||
icon = Properties.Resources.B16x16_Button_Int_Ptr; | ||
} | ||
|
||
public override Size Draw(ViewInfo view, int x, int y) | ||
{ | ||
var value = ReadValueFromMemory(view.Memory); | ||
return DrawNumeric(view, x, y, Icons.Signed, "IntPtr", value.ToString(), $"0x{value.ToString("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, (IntPtr)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, (UIntPtr)val); | ||
} | ||
#endif | ||
} | ||
} | ||
|
||
public IntPtr ReadValueFromMemory(MemoryBuffer memory) | ||
{ | ||
return memory.ReadIntPtr(Offset); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Globalization; | ||
using ReClassNET.Extensions; | ||
using ReClassNET.Memory; | ||
using ReClassNET.UI; | ||
|
||
namespace ReClassNET.Nodes | ||
{ | ||
public class UIntPtrNode : BaseNumericNode | ||
{ | ||
public override int MemorySize => UIntPtr.Size; | ||
|
||
public override void GetUserInterfaceInfo(out string name, out Image icon) | ||
{ | ||
name = "UIntPtr"; | ||
icon = Properties.Resources.B16x16_Button_UInt_Ptr; | ||
} | ||
|
||
public override Size Draw(ViewInfo view, int x, int y) | ||
{ | ||
var value = ReadValueFromMemory(view.Memory); | ||
#if RECLASSNET64 | ||
return DrawNumeric(view, x, y, Icons.Unsigned, "UIntPtr", value.ToString(), $"0x{value.ToUInt64():X}"); | ||
#else | ||
return DrawNumeric(view, x, y, Icons.Unsigned, "UIntPtr", value.ToString(), $"0x{value.ToUInt32():X}"); | ||
#endif | ||
} | ||
|
||
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, (UIntPtr)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, (UIntPtr)val); | ||
} | ||
#endif | ||
} | ||
} | ||
|
||
public UIntPtr ReadValueFromMemory(MemoryBuffer memory) | ||
{ | ||
return memory.ReadUIntPtr(Offset); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,19 @@ namespace ReClassNET.Project | |
public class CppTypeMapping | ||
{ | ||
public string TypeBool { get; set; } = "bool"; | ||
public string TypeSize { get; set; } = "size_t"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type is never used. |
||
|
||
public string TypeInt8 { get; set; } = "int8_t"; | ||
public string TypeInt16 { get; set; } = "int16_t"; | ||
public string TypeInt32 { get; set; } = "int32_t"; | ||
public string TypeInt64 { get; set; } = "int64_t"; | ||
public string TypeIntPtr { get; set; } = "intptr_t"; | ||
|
||
public string TypeUInt8 { get; set; } = "uint8_t"; | ||
public string TypeUInt16 { get; set; } = "uint16_t"; | ||
public string TypeUInt32 { get; set; } = "uint32_t"; | ||
public string TypeUInt64 { get; set; } = "uint64_t"; | ||
public string TypeUIntPtr { get; set; } = "uintptr_t"; | ||
|
||
public string TypeFloat { get; set; } = "float"; | ||
public string TypeDouble { get; set; } = "double"; | ||
|
@@ -43,10 +46,12 @@ internal XElement Serialize(string name) | |
XElementSerializer.ToXml(nameof(TypeInt16), TypeInt16), | ||
XElementSerializer.ToXml(nameof(TypeInt32), TypeInt32), | ||
XElementSerializer.ToXml(nameof(TypeInt64), TypeInt64), | ||
XElementSerializer.ToXml(nameof(TypeIntPtr), TypeIntPtr), | ||
XElementSerializer.ToXml(nameof(TypeUInt8), TypeUInt8), | ||
XElementSerializer.ToXml(nameof(TypeUInt16), TypeUInt16), | ||
XElementSerializer.ToXml(nameof(TypeUInt32), TypeUInt32), | ||
XElementSerializer.ToXml(nameof(TypeUInt64), TypeUInt64), | ||
XElementSerializer.ToXml(nameof(TypeUIntPtr), TypeUIntPtr), | ||
XElementSerializer.ToXml(nameof(TypeFloat), TypeFloat), | ||
XElementSerializer.ToXml(nameof(TypeDouble), TypeDouble), | ||
XElementSerializer.ToXml(nameof(TypeVector2), TypeVector2), | ||
|
@@ -69,10 +74,12 @@ internal void Deserialize(XElement element) | |
XElementSerializer.TryRead(element, nameof(TypeInt16), e => TypeInt16 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeInt32), e => TypeInt32 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeInt64), e => TypeInt64 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeIntPtr), e => TypeIntPtr = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeUInt8), e => TypeUInt8 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeUInt16), e => TypeUInt16 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeUInt32), e => TypeUInt32 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeUInt64), e => TypeUInt64 = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeUIntPtr), e => TypeUIntPtr = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeFloat), e => TypeFloat = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeDouble), e => TypeDouble = XElementSerializer.ToString(e)); | ||
XElementSerializer.TryRead(element, nameof(TypeVector2), e => TypeVector2 = XElementSerializer.ToString(e)); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not correct? If you have a x86 process it should be an
IntegerMemoryComparer
and not the 64bitLongMemoryComparer
.