I come from console modding and now that I have some knowledge I want to modify dead games.
So whilst attempting to send bytes to the program, I receive the the following error "System.OverflowException: 'Value was either too large or too small for a UInt32.'"
So I need to use something like ulong or long but I've no idea on how to implement it.
I would also like to use bytes instead, for example:
pc.writeMemory("0x140B1CE16", //byte 0x44);
example code 1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using ReadWriteMemory;
namespace AW
{
public partial class Form1 : Form
{
Process[] processname;
public static UInt64
TamperProtection = 0x140B1CE16;
public Form1()
{
InitializeComponent();
}
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(UInt64 dwDesiredAccess, bool bInheritHandle, Int64 dwProcessId);
[DllImport("kernel32.dll")]
private static unsafe extern Boolean WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int nSize, void* lpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
static extern Int64 CloseHandle(IntPtr hObject);
static public IntPtr MemoryOpen(Int64 ProcessID)
{
IntPtr hProcess = OpenProcess(0x1F0FFF, false, ProcessID);
return hProcess;
}
unsafe public void Write(UInt64 mAddress, byte[] Buffer, Int64 ProcessID)
{
if (MemoryOpen(ProcessID) == (IntPtr)0x00000000)
{
return;
}
if (!WriteProcessMemory(MemoryOpen(ProcessID), (IntPtr)mAddress, Buffer, Buffer.Length, null))
{
return;
}
}
private void button1_Click(object sender, EventArgs e)
{
processname = Process.GetProcessesByName("s1_mp64_ship");
if (processname.Length == 0)
{
MessageBox.Show("The game process was not detected!\nPlease open the game.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("Connected!", "Connection Sucessfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
processname = Process.GetProcessesByName("s1_mp64_ship");
int Value = 0;
byte[] Buffer = BitConverter.GetBytes(Convert.ToInt32(Value));
Write(5380360708U, Buffer, processname[0].Id);
CloseHandle(MemoryOpen(processname[0].Id));
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
and here is example code 2:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using Memory;
namespace Anubis
{
public partial class Form1 : Form
{
Mem pc = new Mem();
public Form1()
{
InitializeComponent();
}
private void button11_Click(object sender, EventArgs e)
{
CallingCard f2 = new CallingCard();
f2.ShowDialog(); // Shows Form2
}
private void Form1_Load(object sender, EventArgs e)
{
pc.OpenProcess("s1_mp64_ship");
}
private void button12_Click(object sender, EventArgs e)
{
PublicMatchClasses f3 = new PublicMatchClasses();
f3.ShowDialog(); // Shows Form2
}
private void button13_Click(object sender, EventArgs e)
{
PrivateMatchEditor f4 = new PrivateMatchEditor();
f4.ShowDialog(); // Shows Form2
}
private void button1_Click(object sender, EventArgs e)
{
pc.writeMemory("0x140B1CE16", "int", "2");
}
}
}
User contributions licensed under CC BY-SA 3.0