public void firstScan(byte[] buffer, Action callback = null) { if (_handle == IntPtr.Zero) { throw new InvalidOperationException("Cannot scan process memory regions. No process loaded."); } if (buffer.Length == 0) { throw new ArgumentOutOfRangeException("Buffer cannot be of length 0."); } _results.Clear(); dumpRegions(); updateProgress(0); int count = 0; foreach (IntPtr address in _regions.Keys) { foreach (int i in ByteSearch.allIndexOf(_regions[address], buffer)) { _results.Add(new SearchResult(IntPtr.Add(address, i), buffer)); } count++; updateProgress((int)(count / _regions.Count * 100)); } updateProgress(100); if (callback != null) { callback(); } }
public void nextScan(byte[] buffer, Action callback = null) { if (_handle == IntPtr.Zero) { throw new InvalidOperationException("Cannot scan process memory regions. No process loaded."); } if (buffer.Length == 0) { throw new ArgumentOutOfRangeException("Buffer cannot be of length 0."); } dumpRegions(); updateProgress(0); int count = 0; foreach (SearchResult sr in _results.ToArray()) { if (_regions.ContainsKey(sr.Address)) { if (!ByteSearch.matchAtOffset(_regions[sr.Address], buffer, 0)) { _results.Remove(sr); } else { sr.Buffer = buffer; } } else { foreach (IntPtr regionAddress in _regions.Keys) { int lowerBound = (int)regionAddress; int upperBound = lowerBound + _regions[regionAddress].Length; int cAddress = (int)sr.Address; if (cAddress >= lowerBound && cAddress <= upperBound) { if (!ByteSearch.matchAtOffset(_regions[regionAddress], buffer, cAddress - lowerBound)) { _results.Remove(sr); } else { sr.Buffer = buffer; } break; } } } count++; updateProgress((int)(count / _regions.Count * 100)); } updateProgress(100); if (callback != null) { callback(); } }