示例#1
0
        private int GetOffset(IAMemoryPattern pattern)
        {
            switch (pattern.Algorithm)
            {
            case APatternScannerAlgorithm.BoyerMooreHorspool:
                return(Utilities.ABoyerMooreHorspool.IndexOf(Data, pattern.GetBytes().ToArray()));

            case APatternScannerAlgorithm.Naive:
                return(Utilities.ANaive.GetIndexOf(pattern, Data, _module));
            }
            throw new NotImplementedException("GetOffset encountered an unknown PatternScannerAlgorithm: " + pattern.Algorithm + ".");
        }
示例#2
0
        public static int GetIndexOf(IAMemoryPattern pattern, byte[] Data, AProcessSharpModule module)
        {
            var patternData       = Data;
            var patternDataLength = patternData.Length;

            for (var offset = 0; offset < patternDataLength; offset++)
            {
                if (
                    pattern.GetMask()
                    .Where((m, b) => m == 'x' && pattern.GetBytes()[b] != patternData[b + offset])
                    .Any())
                {
                    continue;
                }

                return(offset);
            }
            return(-1);
        }