static int WriteRawMemory(IntPtr hProcess, uint dwAddress, IntPtr lpBuffer, int nSize) { IntPtr iBytesWritten = IntPtr.Zero; if (!Imports.WriteProcessMemory(hProcess, dwAddress, lpBuffer, nSize, out iBytesWritten)) { return(0); } return((int)iBytesWritten); }