public BindingList <Types.SearchResults> SearchHexString(byte[] pattern, uint startDumpOffset) { byte[] buffer = ReadBytes((int)Length, _isBigEndian); var positions = new BindingList <Types.SearchResults>(); var i = Array.IndexOf(buffer, pattern[0], 0); int x = 1; while (i >= 0 && i <= buffer.Length - pattern.Length) { if (_stopSearch) { return(positions); } ReportProgress(0, buffer.Length, i, "Searching..."); var segment = new byte[pattern.Length]; Buffer.BlockCopy(buffer, i, segment, 0, pattern.Length); if (segment.SequenceEqual(pattern)) { var results = new Types.SearchResults(); results.Offset = Functions.Functions.ToHexString(Functions.Functions.UInt32ToBytes(startDumpOffset + (uint)i)); results.Value = Functions.Functions.ByteArrayToString(segment); results.ID = x.ToString(); positions.Add(results); if (_stopSearch) { return(positions); } i = Array.IndexOf(buffer, pattern[0], i + pattern.Length); x++; } else { if (_stopSearch) { return(positions); } i = Array.IndexOf(buffer, pattern[0], i + 1); } if (_stopSearch) { return(positions); } } return(positions); }
public BindingList<Types.SearchResults> SearchHexString(byte[] pattern, uint startDumpOffset) { byte[] buffer = ReadBytes((int)Length, _isBigEndian); var positions = new BindingList<Types.SearchResults>(); var i = Array.IndexOf(buffer, pattern[0], 0); int x = 1; while (i >= 0 && i <= buffer.Length - pattern.Length) { if (_stopSearch) return positions; ReportProgress(0, buffer.Length, i, "Searching..."); var segment = new byte[pattern.Length]; Buffer.BlockCopy(buffer, i, segment, 0, pattern.Length); if (segment.SequenceEqual(pattern)) { var results = new Types.SearchResults(); results.Offset = Functions.Functions.ToHexString(Functions.Functions.UInt32ToBytes(startDumpOffset + (uint)i)); results.Value = Functions.Functions.ByteArrayToString(segment); results.ID = x.ToString(); positions.Add(results); if (_stopSearch) return positions; i = Array.IndexOf(buffer, pattern[0], i + pattern.Length); x++; } else { if (_stopSearch) return positions; i = Array.IndexOf(buffer, pattern[0], i + 1); } if (_stopSearch) return positions; } return positions; }