static int SearchBytes(byte[] haystack, byte[] needle)
{
int len = needle.Length;
int limit = haystack.Length - len;
for (int i = 0; i <= limit; i++)
{
int k = 0;
for (; k < len; k++)
if (needle[k] != haystack[i + k])
break;
if (k == len) return i;
}
return -1;
}