Returns the offset of the found pattern else -1
var offset = PatternFinder.Find_B(buffer, 8, pattern); // offset: 2
Source
static int Find_B(List<int> data, int length, List<_Byte> pattern) { int offsetFound = -1; if (data == null || pattern.isEmpty) return offsetFound; int patternSize = pattern.length; if (length == 0 || patternSize == 0) return offsetFound; int i = 0, pos = 0; while (i < length) { if (PatternFinder._MatchByte(data.elementAt(i), pattern[pos])) { // check if the current data byte matches the current pattern byte pos++; if (pos == patternSize) // everything matched { offsetFound = i - patternSize + 1; return offsetFound; } // end if } // end if else // fix by Computer_Angel { i -= pos; pos = 0; // reset current pattern position } // end else i++; } // end while return offsetFound; }