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; }
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); }
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); } } }