Skip to content

Commit

Permalink
fix pattern scan
Browse files Browse the repository at this point in the history
  • Loading branch information
34736384 committed Mar 13, 2024
1 parent d6b6a25 commit 05a5ee3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions unlockfps_nc/Utility/ProcessUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ public static unsafe IntPtr PatternScan(IntPtr module, string signature)
{
var tokens = signature.Split(' ');
var patternBytes = tokens
.ToList()
.Select(x => x == "?" ? (byte)0xFF : Convert.ToByte(x, 16))
.ToArray();
var maskBytes = tokens
.Select(x => x == "?")
.ToArray();

var dosHeader = Marshal.PtrToStructure<IMAGE_DOS_HEADER>(module);
var ntHeader = Marshal.PtrToStructure<IMAGE_NT_HEADERS>((IntPtr)(module.ToInt64() + dosHeader.e_lfanew));
Expand All @@ -90,7 +92,7 @@ public static unsafe IntPtr PatternScan(IntPtr module, string signature)
var found = true;
for (var j = 0; j < s; j++)
{
if (d[j] != scanBytes[i + j] && d[j] != 0xFF)
if (d[j] != scanBytes[i + j] && !maskBytes[j])
{
found = false;
break;
Expand Down

0 comments on commit 05a5ee3

Please sign in to comment.