[英]C# memory address value cannot be modified?
我的问题:为什么不能修改Q1部分图片中的值? (任何地址都不能。)
但是可以在第二部分进行修改吗?
我的C#代码:
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool WriteProcessMemory(int hProcess, int lpBaseAddress,byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess,int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
static void Main(string[] args)
{
Process process = Process.GetProcessesByName("Defiance")[0];
IntPtr processHandle = OpenProcess(0x1F0FFF, false, process.Id);
int bytesWritten = 0;
byte[] buffer = Encoding.Unicode.GetBytes("test");
WriteProcessMemory((int)processHandle, 0x022AE000, buffer, buffer.Length, ref bytesWritten);
Console.ReadLine();
}
您的问题是为什么您不能修改只读数据部分中的数据。
根据定义,只读数据段只能读取,不能修改或执行。 这就是为什么将其简称为“只读数据段”或“ rdata”的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.