示例#1
0
        public List <SearchInstruction> Create(string[] lines)
        {
            List <SearchInstruction> list = new List <SearchInstruction>();

            for (int i = 0; i < lines.Length; ++i)
            {
                SearchInstruction inst = CreateInstruction(lines[i], i);
                if (inst == null)
                {
                    continue;
                }
                list.Add(inst);
            }

            return(list);
        }
示例#2
0
        static private void ProcessInstructions(List <SearchInstruction> instructions, byte[] bytes)
        {
            int instrIndex = 0;
            int byteIndex  = 0;

            while (instrIndex < instructions.Count)
            {
                SearchInstruction current = instructions[instrIndex];
                Console.WriteLine(current.ToString());
                int newIndex = current.FindMatch(bytes, byteIndex);
                if (newIndex < 0)
                {
                    Console.WriteLine("Failed to find match for instruction " + instrIndex);
                    return;
                }
                if (current is ReplaceInstruction)
                {
                    ReplaceInstruction r = (current as ReplaceInstruction);
                    r.ReplaceAt(bytes, newIndex);
                }
                byteIndex = newIndex + current.MatchLength;
                instrIndex++;
            }
        }
示例#3
0
        private SearchInstruction CreateSearchInstruction(string[] tokens, int lineNumber)
        {
            SearchInstruction s = new SearchInstruction(tokens[1]);

            return(s);
        }