So I have a code that lets me write to a process' memory, but I would like to add an offset to the address that I want to write to. I have a base pointer from a game called 'IGI' but it has an offset and i'm stuck on adding an offset to what I have so far.

Here is how I write to memory:

public static void WriteMem(Process p, int address, long v)
    {
        var hProc = OpenProcess(ProcessAccessFlags.All, false, (int)p.Id);
        var val = new byte[] { (byte)v };
        int wtf = 0;
        WriteProcessMemory(hProc, new IntPtr(address), val, (UInt32)val.LongLength, out wtf);
        CloseHandle(hProc);
    }

I'm stuck at adding an offset of '144' here:

private void button1_Click(object sender, EventArgs e)
      {
          var p = Process.GetProcessesByName("IGI").FirstOrDefault();
          WriteMem(p, 0xD85878, 99);
      }
有帮助吗?

解决方案

you can use the memorySharp library

// address to edit
var address = new IntPtr(0x001D7AB4);

// Open process with MemorySharp
using (var m = new MemorySharp(Process.GetCurrentProcess()))
{
    // Edit address
    m[address].WriteString("write something in hex offset of memory location");
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top