private static void AddResult(int level, SpiderResult parentResult, ConcurrentBag <SpiderResult> results, string match, int offset, long addressFoundAt) { if (match != null) { var newResult = new SpiderResult(parentResult); newResult.Level = level; newResult.SetOffset(level, offset, addressFoundAt); newResult.Value = match; results.Add(newResult); } }
private void CheckNextLevel(int level, long startAddress, SpiderResult parentResult, SpiderSearch search, ConcurrentBag <SpiderResult> results, Memory memory) { var allData = memory.ReadBytes(startAddress, search.Length + search.ExtraRead); for (int index = 0; index < search.EndIncrement; index++) { var offset = index * search.Alignment; var addressToCheck = startAddress + offset; var match = CheckForMatchValue(allData, offset, search); if (match != null) { AddResult(level, parentResult, results, match, offset, addressToCheck); } if (!(level >= search.Levels)) { var nextResult = new SpiderResult(parentResult); nextResult.SetOffset(level, index * search.Alignment, addressToCheck); var nextLevel = level + 1; if (search.Is64Bit) { var pointer = BitConverter.ToInt64(allData, offset); if (pointer > 50000) { CheckNextLevel(nextLevel, pointer, nextResult, search, results, memory); } } else { var pointer = BitConverter.ToInt32(allData, offset); if (pointer > 50000) { CheckNextLevel(nextLevel, pointer, nextResult, search, results, memory); } } } } }