コード例 #1
0
        static void Main()
        {
            var signature = ParseHelper.BytesFromPattern(Pattern, out var unknownByte);

            Console.WriteLine($"Signature generated: {string.Join(" ", signature)}");

            while (true)
            {
                var data             = StartBench(() => GenerateData(DataLength), "Generating data.. ");
                var generatedOffsets = StartBench(() => InjectSignaturesToData(data, signature, unknownByte, 60).OrderBy(x => x),
                                                  "Generating offsets.. ");
                var offsets = StartBench(() => SignatureScanner.Scan(data, signature, unknownByte), "Scanning offsets.. ");

                if (!Compare(generatedOffsets, offsets))
                {
                    throw new Exception("Invalid scan.");
                }
                Console.WriteLine();
            }

            Console.ReadKey(true);
        }
コード例 #2
0
 public long FindPattern(string strPattern, int patternOffset, int addressOffset, bool read, bool subtract)
 {
     byte[] pattern = ParseHelper.BytesFromPattern(strPattern, out byte dByte);
     for (long i = 0; i < _length; i++)
     {
         if (_buffer[i] == pattern[0])
         {
             if (CheckMask(ref pattern, dByte, i))
             {
                 i += patternOffset + _address.ToInt64();
                 if (read)
                 {
                     i = LocalMemory.Read <IntPtr>((IntPtr)i).ToInt64();
                 }
                 if (subtract)
                 {
                     i -= _address.ToInt64();
                 }
                 return(i + addressOffset);
             }
         }
     }
     return(0);
 }