我正在尝试从 C# 中的进程读取内存。我发现了如何从特定地址读取:
public static byte[] ReadMemory(Process process, int address, int numOfBytes, out int bytesRead)
{
IntPtr hProc = OpenProcess(ProcessAccessFlags.All, false, process.Id);
byte[] buffer = new byte[numOfBytes];
ReadProcessMemory(hProc, new IntPtr(address), buffer, numOfBytes, out bytesRead);
return buffer;
}
private int getVal(Process proc, int address)
{
int bytesRead;
byte[] value = ReadMemory(proc, address, 4, out bytesRead);
int am = BitConverter.ToInt32(value, 0);
return am;
}
public void threadFunction()
{
Process[] processes = Process.GetProcessesByName("gta_sa");
foreach (Process process in processes)
{
int ServerPointer = getVal(process, 0xB6F5F0);//Its about this line
MessageBox.Show(ServerPointer.ToString());
}
}
但是当我在网上寻找时,我不断发现:
但是我实际上需要读取地址 samp.dll+2071C0 而不是 0xB6F5F0 (我在网上找到的这个地址)
有谁知道我该怎么做?
提前致谢