/// <summary>
        /// Scans a memory section for a pattern, only looking in valid memory regions.
        /// </summary>
        /// <param name="abs">A <see cref="MemoryAbstraction"/> instance of the process to scan</param>
        /// <param name="pattern">The pattern array to scan for</param>
        /// <param name="result">The address, or <see cref="IntPtr.Zero"/> on failure</param>
        /// <returns>Whether the scan was successful or not</returns>
        public static bool Scan(MemoryAbstraction abs, PatternByte[] pattern, out IntPtr result)
        {
            result = IntPtr.Zero;
            var handle = abs.Handle;

            foreach (var mbi in NativeHelper.EnumerateMemoryRegions(handle).Where(a => a.State == Native.MemoryState.MemCommit))
            {
                if (Scan(handle, pattern, new IntPtr((long)mbi.BaseAddress), (int)mbi.RegionSize, out result))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
 public StructureBase(MemoryAbstraction mem, IntPtr addr)
 {
     Memory = mem;
     Addr   = addr;
 }