VAGSuite.Tools.findSequence C# (CSharp) Method

findSequence() public method

public findSequence ( byte fileData, int offset, byte sequence, byte mask ) : int
fileData byte
offset int
sequence byte
mask byte
return int
        public int findSequence(byte[] fileData, int offset, byte[] sequence, byte[] mask)
        {
            byte data;
            int i, max;
            i = 0;
            max = 0;
            int position = offset;
            while (position < fileData.Length)
            {
                data = (byte)fileData[position++];
                if (data == sequence[i] || mask[i] == 0)
                {
                    i++;

                }
                else
                {
                    if (i > max) max = i;
                    position -= i;
                    i = 0;
                }
                if (i == sequence.Length) break;
            }
            if (i == sequence.Length)
            {
                return ((int)position - sequence.Length);
            }
            else
            {
                return -1;
            }
        }