private static byte[] ReadBytes(Process process, IntPtr address, int count) { using (var reader = new ExternalProcessReader(process)) { return(reader.ReadBytes(address, count)); } }
private static unsafe void PerfTestReadBytesDirect(ExternalProcessReader reader) { fixed(byte *ptr = reader.ReadBytes(LocalPlayerNumKnownSpells, MarshalCache <int> .Size, true)) { int val = *(int *)ptr; } }
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); } }
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)); }
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)); }
private static unsafe void PerfTestReadBytesDirect(ExternalProcessReader reader) { fixed (byte* ptr = reader.ReadBytes(LocalPlayerNumKnownSpells, MarshalCache<int>.Size, true)) { int val = *(int*) ptr; } }