Skip to content

Commit ecd68b4

Browse files
committed
Fixed IsPrintableData.
1 parent 86a2b7b commit ecd68b4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Memory/NodeDissector.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics.Contracts;
4+
using System.Linq;
45
using ReClassNET.Nodes;
56
using ReClassNET.Util;
67

@@ -42,11 +43,11 @@ public static Type GuessType(BaseHexNode node, MemoryBuffer memory)
4243
var data32 = memory.ReadObject<UInt32FloatData>(offset);
4344

4445
var raw = memory.ReadBytes(offset, node.MemorySize);
45-
if (raw.InterpretAsUTF8().IsPrintableData())
46+
if (raw.InterpretAsUTF8().IsLikelyPrintableData() >= 0.5f)
4647
{
4748
return typeof(UTF8TextNode);
4849
}
49-
else if (raw.InterpretAsUTF16().IsPrintableData())
50+
else if (raw.InterpretAsUTF16().IsLikelyPrintableData() >= 0.5f)
5051
{
5152
return typeof(UTF16TextNode);
5253
}
@@ -138,12 +139,12 @@ private static Type GuessPointerType(IntPtr address, MemoryBuffer memory)
138139
}
139140

140141
// Check if it is a string.
141-
var data = memory.Process.ReadRemoteMemory(address, IntPtr.Size);
142-
if (data.InterpretAsUTF8().IsPrintableData())
142+
var data = memory.Process.ReadRemoteMemory(address, IntPtr.Size * 2);
143+
if (data.Take(IntPtr.Size).InterpretAsUTF8().IsLikelyPrintableData() >= 0.5f)
143144
{
144145
return typeof(UTF8TextPtrNode);
145146
}
146-
else if (data.InterpretAsUTF16().IsPrintableData())
147+
else if (data.InterpretAsUTF16().IsLikelyPrintableData() >= 0.5f)
147148
{
148149
return typeof(UTF16TextPtrNode);
149150
}

Util/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public static bool IsPrintableData(this IEnumerable<char> source)
160160
{
161161
Contract.Requires(source != null);
162162

163-
return IsLikelyPrintableData(source) >= 0.5f;
163+
return IsLikelyPrintableData(source) >= 1.0f;
164164
}
165165

166166
public static float IsLikelyPrintableData(this IEnumerable<char> source)

0 commit comments

Comments
 (0)