[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UIntPtr nSize, out IntPtr lpNumberOfBytesWritten);
[DllImport("Kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesRead);
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UIntPtr nSize, out IntPtr lpNumberOfBytesWritten);
| hProcess | The process handle value |
| lpBaseAddress | The location within the memory to access |
| lpBuffer | The byte array we're writing to the process memory |
| nSize | The size/length of the data we're writing (ipBuffer.Length) |
| lpNumberOfBytesWritten | Informs about how many bytes that got written to the memory |
Process.GetProcessesByName("process name")[0].Handle
Write(uint address, byte[] bytes, uint length)
{
IntPtr bytesWritten;
WriteProcessMemory(Process.GetProcessesByName("process name")[0].Handle, new IntPtr(address), bytes, length, out bytesWritten);
}


