Ejemplo n.º 1
0
        public long PatternScan(IMemoryPattern pattern, long startAddress, int scanBufferSize, long scanSize, int ms)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            long address = -1;

            do
            {
                // long startAddress = (long)process.MainModule.EntryPointAddress;
                long endAddress = startAddress + scanSize;

                long currentAddress = startAddress;

                byte[] buffer = new byte[scanBufferSize];

                while (currentAddress < endAddress && stopwatch.ElapsedMilliseconds < ms)
                {
                    ReadMemory(currentAddress, buffer, scanBufferSize);
                    long index = pattern.FindMatch(buffer, buffer.Length);
                    if (index != -1)
                    {
                        // return currentAddress + index;
                        address = currentAddress + index;
                        break;
                    }
                    currentAddress += scanBufferSize;
                }
            } while (address == -1 && stopwatch.ElapsedMilliseconds < ms);

            stopwatch.Stop();

            return(address);
        }
Ejemplo n.º 2
0
        public long PatternScan(IMemoryPattern pattern, int scanBufferSize, long scanSize)
        {
            long startAddress = (long)process.MainModule.EntryPointAddress;
            long endAddress   = startAddress + scanSize;

            long currentAddress = startAddress;

            byte[] buffer = new byte[scanBufferSize];

            while (currentAddress < endAddress)
            {
                ReadMemory(currentAddress, buffer, scanBufferSize);
                long index = pattern.FindMatch(buffer, buffer.Length);
                if (index != -1)
                {
                    return(currentAddress + index);
                }
                currentAddress += scanBufferSize;
            }

            return(-1);
        }