2

我正在尝试写入进程内存,所以我从视频中复制了代码。但是这个视频没有显示功能“ReadInt32”,有人可以发给我最终能够运行这个应用程序吗?

ReadInt32(进程,(IntPtr)地址)

public static long GetRealAddress(IntPtr process, IntPtr baseAddress, int[] offsets)
    {
        var address = baseAddress.ToInt64();
        foreach (var offset in offsets)
        {
            address = ReadInt32(process, (IntPtr)address) + offset;

        }
        return address;
    }

代码中突出显示的错误:

错误打印屏幕

指针:( 类型为浮点型)

此处指点

4

1 回答 1

2
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(IntPtr handle, IntPtr baseAddress,
    byte[] buffer, int size, out IntPtr lpNumberOfBytesRead);


public static int ReadInt32(IntPtr processHandle, IntPtr address)
{
    byte[] buffer = new byte[4];

    ReadProcessMemory(processHandle, address,
       buffer, buffer.Length, out IntPtr bytesRead);

    // if this gives the wrong value:
    // Array.Reverse(buffer);
    var myInt = BitConverter.ToInt32(buffer, 0);
    return myInt;
}
于 2019-12-25T02:37:09.887 回答