Reloaded-Project/Reloaded.Memory.SigScan

Get Multiple Results

Closed this issue · 2 comments

Is it possible to get all founds results using this [in a specified address range], and not just the first one?

There's actually a branch with this feature https://github.com/Reloaded-Project/Reloaded.Memory.SigScan/tree/skyth , based off of a fork that has now been deleted but the issue was that the commit wasn't reaching the performance numbers that I would have liked, even after tweaking.

It just seems I never got around with playing with it a bit more since my initial look back then.

If you need to find all patterns using the current published version of the library however, you should be able to do as such:

private static List<PatternScanResult> FindAllPatterns(byte[] data, string pattern)
{
    using var scanner = new Scanner(data);
    var results = new List<PatternScanResult>();
    var result  = new PatternScanResult(-1);
    var scanPattern = new CompiledScanPattern(pattern);

    do
    {
        result = scanner.CompiledFindPattern(scanPattern, result.Offset + 1);
        if (result.Found)
            results.Add(result);
    }
    while (result.Found);

    return results;
}

Or a variation of this code based off of your needs.

Makes sense, thank you.