diff --git a/Reloaded.Memory.Sigscan/Scanner_AVX2.cs b/Reloaded.Memory.Sigscan/Scanner_AVX2.cs index 9a21045..22ed21f 100644 --- a/Reloaded.Memory.Sigscan/Scanner_AVX2.cs +++ b/Reloaded.Memory.Sigscan/Scanner_AVX2.cs @@ -55,7 +55,7 @@ public static PatternScanResult FindPatternAvx2(byte* data, int dataLength, stri int matchTableLength = matchTable.Length; var firstByteVec = Vector256.Create(patternData.Bytes[patternData.LeadingIgnoreCount]); - int searchLength = dataLength - Math.Max(patternData.Bytes.Length >> 5 << 5, AvxRegisterLength); // bitshift rounds down + int searchLength = dataLength - Math.Max((patternData.Bytes.Length + 31) >> 5 << 5, AvxRegisterLength); // shift by 5 == 32 int leadingIgnoreCount = patternData.LeadingIgnoreCount; ref var pVec = ref patternVectors[0]; diff --git a/Reloaded.Memory.Sigscan/Scanner_SSE2.cs b/Reloaded.Memory.Sigscan/Scanner_SSE2.cs index 0d89509..a15b1d0 100644 --- a/Reloaded.Memory.Sigscan/Scanner_SSE2.cs +++ b/Reloaded.Memory.Sigscan/Scanner_SSE2.cs @@ -54,7 +54,7 @@ public static PatternScanResult FindPatternSse2(byte* data, int dataLength, stri int matchTableLength = matchTable.Length; var firstByteVec = Vector128.Create(patternData.Bytes[patternData.LeadingIgnoreCount]); - int searchLength = dataLength - Math.Max(patternData.Bytes.Length >> 4 << 4, SseRegisterLength); // bitshift rounds down + int searchLength = dataLength - Math.Max((patternData.Bytes.Length + 15) >> 4 << 4, SseRegisterLength); // shift by 4 == 16 int leadingIgnoreCount = patternData.LeadingIgnoreCount; ref var pVec = ref patternVectors[0];