GeezerVison is showing github.com — Refactored IsLikelyPrintableData. · ReClassNET/ReClass.NET@f377de9
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: ReClass.NET/Extensions/StringExtensions.cs +11-5Lines changed: 11 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,17 +40,23 @@ public static bool IsPrintableData(this IEnumerable<char> source) |
40 | 40 | { |
41 | 41 | Contract.Requires(source != null); |
42 | 42 |
|
43 | | - return IsLikelyPrintableData(source) >= 1.0f; |
| 43 | + return CalculatePrintableDataThreshold(source) >= 1.0f; |
44 | 44 | } |
45 | 45 |
|
46 | 46 | [DebuggerStepThrough] |
47 | | - public static float IsLikelyPrintableData(this IEnumerable<char> source) |
| 47 | + public static bool IsLikelyPrintableData(this IEnumerable<char> source) |
48 | 48 | { |
49 | 49 | Contract.Requires(source != null); |
50 | 50 |
|
51 | | - bool doCountValid = true; |
52 | | - int countValid = 0; |
53 | | - int countAll = 0; |
| 51 | + return CalculatePrintableDataThreshold(source) >= 0.75f; |
| 52 | + } |
| 53 | + |
| 54 | + [DebuggerStepThrough] |
| 55 | + public static float CalculatePrintableDataThreshold(this IEnumerable<char> source) |
| 56 | + { |
| 57 | + var doCountValid = true; |
| 58 | + var countValid = 0; |
| 59 | + var countAll = 0; |
54 | 60 |
|
55 | 61 | foreach (var c in source) |
56 | 62 | { |
|
Collapse file
Copy file name to clipboardExpand all lines: ReClass.NET/Memory/NodeDissector.cs +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,13 +45,13 @@ public static bool GuessNode(BaseHexNode node, MemoryBuffer memory, out BaseNode |
45 | 45 | var data32 = memory.ReadObject<UInt32FloatData>(offset); |
46 | 46 |
|
47 | 47 | var raw = memory.ReadBytes(offset, node.MemorySize); |
48 | | - if (raw.InterpretAsUtf8().IsLikelyPrintableData() >= 0.75f) |
| 48 | + if (raw.InterpretAsUtf8().IsLikelyPrintableData()) |
49 | 49 | { |
50 | 50 | guessedNode = new Utf8TextNode(); |
51 | 51 |
|
52 | 52 | return true; |
53 | 53 | } |
54 | | - if (raw.InterpretAsUtf16().IsLikelyPrintableData() >= 0.75f) |
| 54 | + if (raw.InterpretAsUtf16().IsLikelyPrintableData()) |
55 | 55 | { |
56 | 56 | guessedNode = new Utf16TextNode(); |
57 | 57 |
|
@@ -147,13 +147,13 @@ private static bool GuessPointerNode(IntPtr address, IProcessReader process, out |
147 | 147 |
|
148 | 148 | // Check if it is a string. |
149 | 149 | var data = process.ReadRemoteMemory(address, IntPtr.Size * 2); |
150 | | - if (data.Take(IntPtr.Size).InterpretAsUtf8().IsLikelyPrintableData() >= 07.5f) |
| 150 | + if (data.Take(IntPtr.Size).InterpretAsUtf8().IsLikelyPrintableData()) |
151 | 151 | { |
152 | 152 | node = new Utf8TextPtrNode(); |
153 | 153 |
|
154 | 154 | return true; |
155 | 155 | } |
156 | | - if (data.InterpretAsUtf16().IsLikelyPrintableData() >= 0.75f) |
| 156 | + if (data.InterpretAsUtf16().IsLikelyPrintableData()) |
157 | 157 | { |
158 | 158 | node = new Utf16TextPtrNode(); |
159 | 159 |
|
|