public int Read(uint address, byte[] buffer, int size) { int readed = 0; RKernel32.ReadProcessMemory(_handle, address, buffer, size, out readed); return(readed); }
public static int ReadMemory(IntPtr process, uint address, byte[] memory, int length) { int read = 0; RKernel32.ReadProcessMemory(process, address, memory, length, out read); return(read); }
public static T PtrToStructure <T>(IntPtr hProcess, IntPtr hAddress) { Type type = typeof(T); int size = Marshal.SizeOf(type); byte[] buffer = new byte[size]; int readed = 0; RKernel32.ReadProcessMemory(hProcess, (uint)hAddress.ToInt32(), buffer, size, out readed); if (readed != size) { throw new FFatalException("Read process memory error. (size={0} readed={1})", size, readed); } IntPtr ptr = Marshal.AllocHGlobal(size); try { Marshal.Copy(buffer, 0, ptr, size); return((T)Marshal.PtrToStructure(ptr, type)); } finally { Marshal.FreeHGlobal(ptr); } }