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; }
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); } } }
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()); }
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)); }
// backwards compat method signature public IntPtr Scan(SigScanTarget target) { return(Scan(target, 1)); }