Skip to content

Commit

Permalink
Added: API for scanning from an offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Jul 8, 2022
1 parent 80f5963 commit 4ba2bbb
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 7 deletions.
13 changes: 13 additions & 0 deletions Reloaded.Memory.Sigscan.Definitions/IScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ public interface IScanner : IDisposable
/// <returns>A result indicating an offset (if found) of the pattern.</returns>
PatternScanResult FindPattern(string pattern);

/// <summary>
/// Attempts to find a given pattern inside the memory region this class was created with.
/// The method used depends on the available hardware; will use vectorized instructions if available.
/// </summary>
/// <param name="pattern">
/// The pattern to look for inside the given region.
/// Example: "11 22 33 ?? 55".
/// Key: ?? represents a byte that should be ignored, anything else if a hex byte. i.e. 11 represents 0x11, 1F represents 0x1F
/// </param>
/// <param name="offset">Offset (in bytes) from which the pattern scan should begin from.</param>
/// <returns>A result indicating an offset (if found) of the pattern.</returns>
public PatternScanResult FindPattern(string pattern, int offset);

/// <summary>
/// Finds multiple patterns within a given scan range, in multithreaded fashion.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Reloaded.Memory.Sigscan.Definitions.IScanner.FindPatternsCached(System.Collections.Generic.IReadOnlyList<string> patterns, bool loadBalance = false) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult[]
Reloaded.Memory.Sigscan.Definitions.IScanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
Reloaded.Memory.Sigscan.Definitions.IScanner.FindPatternsCached(System.Collections.Generic.IReadOnlyList<string> patterns, bool loadBalance = false) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult[]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Reloaded.Memory.Sigscan.Definitions.IScanner.FindPatternsCached(System.Collections.Generic.IReadOnlyList<string> patterns, bool loadBalance = false) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult[]
Reloaded.Memory.Sigscan.Definitions.IScanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
Reloaded.Memory.Sigscan.Definitions.IScanner.FindPatternsCached(System.Collections.Generic.IReadOnlyList<string> patterns, bool loadBalance = false) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult[]
Original file line number Diff line number Diff line change
@@ -1 +1 @@

Reloaded.Memory.Sigscan.Scanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
Original file line number Diff line number Diff line change
@@ -1 +1 @@

Reloaded.Memory.Sigscan.Scanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
Original file line number Diff line number Diff line change
@@ -1 +1 @@

Reloaded.Memory.Sigscan.Scanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
Original file line number Diff line number Diff line change
@@ -1 +1 @@

Reloaded.Memory.Sigscan.Scanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
Original file line number Diff line number Diff line change
@@ -1 +1 @@

Reloaded.Memory.Sigscan.Scanner.FindPattern(string pattern, int offset) -> Reloaded.Memory.Sigscan.Definitions.Structs.PatternScanResult
14 changes: 14 additions & 0 deletions Reloaded.Memory.Sigscan/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ public PatternScanResult FindPattern(string pattern)
return FindPatternCompiled(_dataPtr, _dataLength, pattern);
}

/// <inheritdoc/>
public PatternScanResult FindPattern(string pattern, int offset)
{
#if SIMD_INTRINSICS
if (Avx2.IsSupported)
return FindPatternAvx2(_dataPtr + offset, _dataLength - offset, pattern);

if (Sse2.IsSupported)
return FindPatternSse2(_dataPtr + offset, _dataLength - offset, pattern);
#endif

return FindPatternCompiled(_dataPtr + offset, _dataLength - offset, pattern);
}

/// <inheritdoc/>
public PatternScanResult[] FindPatterns(IReadOnlyList<string> patterns, bool loadBalance = false)
{
Expand Down

0 comments on commit 4ba2bbb

Please sign in to comment.