public bool WriteByte(IntPtr address, byte value) { if (Handle == IntPtr.Zero || !_processUnlocked) { throw new InvalidHandle(); } Logger.Debug($"attempt to write byte to {address.ToString("X8")}"); byte[] bytesToWrite = { value }; bool success = Pinvokes.WriteProcessMemory(Handle, address, bytesToWrite, 1, out _); if (success) { Logger.Debug("OK.. write byte"); } else { int errCode = Marshal.GetLastWin32Error(); Logger.Error($"ER.. write byte. code: {errCode}"); } return(success); }
public bool WriteBytes(Process proc, IntPtr address, byte [] buffer) { return(Pinvokes.WriteProcessMemory( GetHandle(proc, PFlags.VirtualMemoryOperation | PFlags.VirtualMemoryWrite), address, buffer, buffer.Length, out _)); }