Esempio n. 1
0
 private static byte[] ReadBytes(Process process, IntPtr address, int count)
 {
     using (var reader = new ExternalProcessReader(process))
     {
         return(reader.ReadBytes(address, count));
     }
 }
Esempio n. 2
0
 private static unsafe void PerfTestReadBytesDirect(ExternalProcessReader reader)
 {
     fixed(byte *ptr = reader.ReadBytes(LocalPlayerNumKnownSpells, MarshalCache <int> .Size, true))
     {
         int val = *(int *)ptr;
     }
 }
Esempio n. 3
0
 private static bool IsValidTypePtr(ExternalProcessReader memory, IntPtr ptr)
 {
     if (ptr == IntPtr.Zero)
     {
         return(false);
     }
     try
     {
         var bytes = memory.ReadBytes(ptr, 6);
         return(bytes[0] == 0xA1 /* mov */ && bytes[5] == 0xC3 /* retn */);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 4
0
        private IntPtr FindStart(ExternalProcessReader bm)
        {
            var mainModule = bm.Process.MainModule;
            var start = mainModule.BaseAddress;
            var size = mainModule.ModuleMemorySize;
            var patternLength = Bytes.Length;

            for (uint i = 0; i < size - patternLength; i += (uint)(CacheSize - patternLength))
            {
                byte[] cache = bm.ReadBytes(start + (int)i, CacheSize > size - i ? size - (int)i : CacheSize);
                for (uint i2 = 0; i2 < (cache.Length - patternLength); i2++)
                {
                    if (DataCompare(cache, i2))
                        return start + (int)(i + i2);
                }
            }
            throw new InvalidDataException(string.Format("Pattern {0} not found",Name));
        }
Esempio n. 5
0
        private IntPtr FindStart(ExternalProcessReader bm)
        {
            var mainModule    = bm.Process.MainModule;
            var start         = mainModule.BaseAddress;
            var size          = mainModule.ModuleMemorySize;
            var patternLength = Bytes.Length;

            for (uint i = 0; i < size - patternLength; i += (uint)(CacheSize - patternLength))
            {
                byte[] cache = bm.ReadBytes(start + (int)i, CacheSize > size - i ? size - (int)i : CacheSize);
                for (uint i2 = 0; i2 < (cache.Length - patternLength); i2++)
                {
                    if (DataCompare(cache, i2))
                    {
                        return(start + (int)(i + i2));
                    }
                }
            }
            throw new InvalidDataException(string.Format("Pattern {0} not found", Name));
        }
Esempio n. 6
0
 private static unsafe void PerfTestReadBytesDirect(ExternalProcessReader reader)
 {
     fixed (byte* ptr = reader.ReadBytes(LocalPlayerNumKnownSpells, MarshalCache<int>.Size, true))
     {
         int val = *(int*) ptr;
     }
 }