WriteProcessMemory带有int值

时间:2010-11-24 20:34:55

标签: c# winapi

我如何使用WriteProcessMemoryint

2 个答案:

答案 0 :(得分:1)

根据你的说明,我假设你试图将游戏中的int(端口?)设置为某个值。您需要知道游戏的句柄以及您想要更改的值的地址。

public class Cheat
{
    [DllImport("kernel32.dll",SetLastError = true)]
    static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte [] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);

    public static void SetPort(IntPtr GameHandle, IntPtr WriteAddress, int i)
    {
        var array = BitConverter.GetBytes(i);
        int bytesWritten;
        WriteProcessMemory(GameHandle, WriteAddress, array, (uint)array.Length, out bytesWritten);
    }
{

答案 1 :(得分:0)

我认为您需要扩展您的问题。您在寻找该方法的P / Invoke签名吗?如果是这样的话:

http://www.pinvoke.net/default.aspx/kernel32.writeprocessmemory