示例#1
0
        private PatternScanResult FindDataPattern(IMemoryPattern pattern)
        {
            var patternData  = Data;
            var patternBytes = pattern.GetBytes();
            var patternMask  = pattern.GetMask();

            var result = new PatternScanResult();

            for (var offset = 0; offset < patternData.Length; offset++)
            {
                if (patternMask.Where((m, b) => m == 'x' && patternBytes[b] != patternData[b + offset]).Any())
                {
                    continue;
                }
                // If this area is reached, the pattern has been found.
                result.Found       = true;
                result.ReadAddress = _module.Read <IntPtr>(offset + pattern.Offset);
                result.BaseAddress = new IntPtr(result.ReadAddress.ToInt64() - _module.BaseAddress.ToInt64());
                result.Offset      = offset;
                return(result);
            }
            // If this is reached, the pattern was not found.
            result.Found       = false;
            result.Offset      = 0;
            result.ReadAddress = IntPtr.Zero;
            result.BaseAddress = IntPtr.Zero;
            return(result);
        }
示例#2
0
        private PatternScanResult FindDataPattern(IMemoryPattern pattern)
        {
            var result = new PatternScanResult();
            var offset = GetOffset(pattern);

            if (offset != -1)
            {
                // If this area is reached, the pattern has been found.
                result.Found       = true;
                result.ReadAddress = _module.Read <IntPtr>(offset + pattern.Offset);
                result.BaseAddress = new IntPtr(result.ReadAddress.ToInt64() - _module.BaseAddress.ToInt64());
                result.Offset      = offset;
                return(result);
            }
            // If this is reached, the pattern was not found.
            return(EmptyPatternScanResult);
        }
示例#3
0
        private PatternScanResult FindCallPattern(IMemoryPattern pattern, int hintAddr = 0)
        {
            var patternData  = Data;
            var patternBytes = pattern.GetBytes();
            var patternMask  = pattern.GetMask();

            if (hintAddr > 0)
            {
                if (hintAddr + patternBytes.Count > patternData.Length ||
                    patternMask.AnyEx((m,
                                       // ReSharper disable once AccessToModifiedClosure
                                       b) => m == 'x' && patternBytes[b] != patternData[b + hintAddr]))
                {
                    hintAddr = 0;
                }
            }

            var result = new PatternScanResult();

            for (var offset = hintAddr; offset < patternData.Length; offset++)
            {
                if (patternMask.AnyEx((m,
                                       // ReSharper disable once AccessToModifiedClosure
                                       b) => m == 'x' && patternBytes[b] != patternData[b + offset]))
                {
                    continue;
                }

                // If this area is reached, the pattern has been found.
                result.Found       = true;
                result.ReadAddress = _module.Read <IntPtr>(offset + pattern.Offset);
                result.BaseAddress = new IntPtr(result.ReadAddress.ToInt64() + pattern.Offset + MarshalType <IntPtr> .Size + offset + _module.BaseAddress.ToInt64());
                result.Offset      = offset;
                return(result);
            }

            // If this is reached, the pattern was not found.
            result.Found       = false;
            result.Offset      = 0;
            result.ReadAddress = IntPtr.Zero;
            result.BaseAddress = IntPtr.Zero;
            return(result);
        }