Example #1
0
        private IEnumerable <IntPtr> General(Signature aobString)
        {
            string pattern = aobString;

            if (!aobString.IsWildCard)
            {
                return(General(aobString.ToBytes()));
            }

            ProcessHandler.CheckAccess();

            Stopwatch benchmark = null;

            if (SearchResult != null)
            {
                benchmark = Stopwatch.StartNew();
            }

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Pause();
            }

            IEnumerable <IntPtr> addresses = new IntPtr[] { };

            var regions = GetRegions();

            _tasks = new Task <IEnumerable
                               <IntPtr> > [regions.Length];

            for (int i = 0; i < _tasks.Length; i++)
            {
                _tasks[i] = WildCardScan(regions[i], aobString);
            }

            Task.WaitAll(_tasks);

            foreach (var task in _tasks)
            {
                addresses = addresses.Concat(task.Result);
            }

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Resume();
            }

            if (SearchResult != null)
            {
                benchmark.Stop();
                SearchResult.Invoke(this,
                                    new SearchResultEventArgs(addresses.ToArray(),
                                                              benchmark.Elapsed.TotalMilliseconds, _access));
            }

            return(addresses);
        }
Example #2
0
        private void WriteByteArray(IntPtr address, byte[] buff)
        {
            ProcessHandler.CheckAccess();

            if (!TryWrite(address, buff))
            {
                throw new UnwritableMemoryException(address, _access);
            }
        }
Example #3
0
        private IEnumerable <IntPtr> General(ObjectSearch obj, bool caseSensitive = true)
        {
            ProcessHandler.CheckAccess();

            Stopwatch benchmark = null;

            if (SearchResult != null)
            {
                benchmark = Stopwatch.StartNew();
            }

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Pause();
            }

            IEnumerable <IntPtr> addresses = new IntPtr[] { };

            var regions = GetRegions();

            _tasks = new Task <IEnumerable
                               <IntPtr> > [regions.Length];

            for (int i = 0; i < _tasks.Length; i++)
            {
                _tasks[i] = Scan(regions[i], obj, caseSensitive);
            }

            Task.WaitAll(_tasks);

            foreach (var task in _tasks)
            {
                addresses = addresses.Concat(task.Result);
            }

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Resume();
            }

            if (SearchResult != null)
            {
                benchmark.Stop();
                SearchResult.Invoke(this,
                                    new SearchResultEventArgs(addresses.ToArray(),
                                                              benchmark.Elapsed.TotalMilliseconds, _access));
            }

            return(addresses);
        }
Example #4
0
        private byte[] GetByteArray(IntPtr address, int length = 16)
        {
            ProcessHandler.CheckAccess();

            var buff = new byte[length];

            uint read = 0;

            if (!Pinvoke.ReadProcessMemory(_access.Handle, address, buff,
                                           (uint)length, ref read) || read != length)
            {
                throw new UnreadableMemoryException(address, _access);
            }

            return(buff);
        }
Example #5
0
        private IEnumerable <IntPtr> General(IntPtr[] addresses, Signature signature, bool caseSensitive = true)
        {
            Collection <IntPtr> nextAddresses
                = new Collection <IntPtr>();

            ProcessHandler.CheckAccess();

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Pause();
            }

            Stopwatch benchmark = null;

            if (SearchResult != null)
            {
                benchmark = Stopwatch.StartNew();
            }

            if (!signature.IsWildCard)
            {
                var bytes = signature.ToBytes();
                for (int i = 0; i < addresses.Length; i++)
                {
                    var current =
                        _dumper.Read <byte[]>(addresses[i], bytes.Length);

                    if (bytes[0] != current[0])
                    {
                        continue;
                    }

                    for (int x = 0; x < bytes.Length; x++)
                    {
                        if (bytes[x] == current[x])
                        {
                            if (x == bytes.Length - 1)
                            {
                                nextAddresses.Add(addresses[i]);
                            }
                        }
                    }
                }
            }
            else
            {
                var bytes = signature.ToWildCardBytes();

                if (signature.IsUniqueWildCard)
                {
                    return(addresses);
                }

                for (int i = 0; i < addresses.Length; i++)
                {
                    var current =
                        _dumper.Read <byte[]>(addresses[i], bytes.Length);

                    for (int x = 0; x < bytes.Length; x++)
                    {
                        if (bytes[x] == null)
                        {
                            if (x == bytes.Length - 1)
                            {
                                nextAddresses.Add(addresses[i]);
                                break;
                            }
                            continue;
                        }

                        if (bytes[x] == current[x])
                        {
                            if (x == bytes.Length - 1)
                            {
                                nextAddresses.Add(addresses[i]);
                            }
                        }
                    }
                }
            }

            if (SearchResult != null)
            {
                benchmark.Stop();
                SearchResult.Invoke(this,
                                    new SearchResultEventArgs(nextAddresses.ToArray(),
                                                              benchmark.Elapsed.TotalMilliseconds, _access));
            }

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Resume();
            }

            return(nextAddresses);
        }
Example #6
0
        private IEnumerable <IntPtr> General(IntPtr[] addresses, byte[] buff, bool caseSensitive = true)
        {
            Collection <IntPtr> nextAddresses
                = new Collection <IntPtr>();

            ProcessHandler.CheckAccess();

            Stopwatch benchmark = null;

            if (SearchResult != null)
            {
                benchmark = Stopwatch.StartNew();
            }

            if (Settings.PauseWhileScanning)
            {
                _access.Process.Pause();
            }

            if (!caseSensitive)
            {
                for (int i = 0; i < addresses.Length; i++)
                {
                    var current      = _dumper.Read <string>(addresses[i], buff.Length).ToLower();
                    var fixedCurrent = Encoding.ASCII.GetBytes(current);

                    var buffStr   = Encoding.ASCII.GetString(buff).ToLower();
                    var fixedBuff = Encoding.ASCII.GetBytes(buffStr);

                    if (fixedBuff[0] != fixedCurrent[0])
                    {
                        continue;
                    }

                    for (int x = 1; x < fixedCurrent.Length; x++)
                    {
                        if (fixedBuff[x] != fixedCurrent[x])
                        {
                            continue;
                        }
                    }

                    nextAddresses.Add(addresses[i]);
                }
            }
            else
            {
                for (int i = 0; i < addresses.Length; i++)
                {
                    var current =
                        _dumper.Read <byte[]>(addresses[i], buff.Length);

                    if (buff[0] != current[0])
                    {
                        continue;
                    }

                    for (int x = 1; x < current.Length; x++)
                    {
                        if (buff[x] != current[x])
                        {
                            continue;
                        }
                    }

                    nextAddresses.Add(addresses[i]);
                }
            }


            if (Settings.PauseWhileScanning)
            {
                _access.Process.Resume();
            }

            if (SearchResult != null)
            {
                benchmark.Stop();
                SearchResult.Invoke(this,
                                    new SearchResultEventArgs(nextAddresses.ToArray(),
                                                              benchmark.Elapsed.TotalMilliseconds, _access));
            }

            return(nextAddresses);
        }