public IntPtr Scan(SigScanTarget target)
        {
            if (_memory == null || _memory.Length != _size)
            {
                _memory = new byte[_size];

                byte[] bytes;

                if (!_process.ReadBytes(_address, _size, out bytes))
                {
                    _memory = null;
                    return(IntPtr.Zero);
                }

                _memory = bytes;
            }

            foreach (SigScanTarget.Signature sig in target.Signatures)
            {
                IntPtr ptr = FindPattern(sig.Pattern, sig.Mask, sig.Offset);
                if (ptr != IntPtr.Zero)
                {
                    if (target.OnFound != null)
                    {
                        ptr = target.OnFound(_process, this, ptr);
                    }
                    return(ptr);
                }
            }

            return(IntPtr.Zero);
        }
        public IntPtr Scan(SigScanTarget target)
        {
            if (_memory == null || _memory.Length != _size)
            {
                _memory = new byte[_size];

                byte[] bytes;

                if (!_process.ReadBytes(_address, _size, out bytes))
                {
                    _memory = null;
                    return IntPtr.Zero;
                }

                _memory = bytes;
            }

            foreach (SigScanTarget.Signature sig in target.Signatures)
            {
                IntPtr ptr = this.FindPattern(sig.Pattern, sig.Mask, sig.Offset);
                if (ptr != IntPtr.Zero)
                {
                    if (target.OnFound != null)
                        ptr = target.OnFound(_process, this, ptr);
                    return ptr;
                }
            }

            return IntPtr.Zero;
        }
Beispiel #3
0
        IEnumerable <IntPtr> ScanInternal(SigScanTarget target, int align)
        {
            if (_memory == null || _memory.Length != _size)
            {
                byte[] bytes;

                if (!_process.ReadBytes(_address, _size, out bytes))
                {
                    _memory = null;
                    yield break;
                }

                _memory = bytes;
            }

            foreach (SigScanTarget.Signature sig in target.Signatures)
            {
                // have to implement IEnumerator manually because you can't yield in an unsafe block...
                foreach (int off in new ScanEnumerator(_memory, align, sig))
                {
                    var ptr = _address + off + sig.Offset;
                    if (target.OnFound != null)
                    {
                        ptr = target.OnFound(_process, this, ptr);
                    }
                    yield return(ptr);
                }
            }
        }
Beispiel #4
0
        public IntPtr Scan(SigScanTarget target, int align)
        {
            if ((long)_address % align != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(align), "start address must be aligned");
            }

            return(ScanAll(target, align).FirstOrDefault());
        }
Beispiel #5
0
        public IEnumerable <IntPtr> ScanAll(SigScanTarget target, int align = 1)
        {
            if ((long)_address % align != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(align), "start address must be aligned");
            }

            return(ScanInternal(target, align));
        }
Beispiel #6
0
 // backwards compat method signature
 public IntPtr Scan(SigScanTarget target)
 {
     return(Scan(target, 1));
 }