Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static byte[] _file;
- public static int FindPattern(byte[] btPattern, string strMask)
- {
- try
- {
- if (strMask.Length != btPattern.Length)
- return -1;
- for (int x = 0; x < _file.Length; x++)
- {
- if (MaskCheck(x, btPattern, strMask))
- {
- return x;
- }
- }
- return -1;
- }
- catch (Exception ex)
- {
- return -1;
- }
- }
- private static bool MaskCheck(int nOffset, byte[] btPattern, string strMask)
- {
- for (int x = 0; x < btPattern.Length; x++)
- {
- if (strMask[x] == '?')
- continue;
- if ((strMask[x] == 'x') && (btPattern[x] != _file[nOffset + x]))
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment