繼續搜索互聯網,無法弄清楚這一點,ReadProcessMemory
返回就好,因此它的執行。但輸出總是空的。陣列的長度也是0
。RPM工作,我不知道爲什麼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace MemEd
{
class Program
{
static void Main(string[] args)
{
Process proc = Process.GetProcessesByName("client")[0];
byte[] buff = new byte[]{};
IntPtr bread;
IntPtr pHandle = OpenProcess(0x0010, false, proc.Id);
bool check = ReadProcessMemory(pHandle, (IntPtr)0x5EFF75B8, buff, 10, out bread);
if (!check)
Console.WriteLine("RPM Fail");
Console.WriteLine(buff.Length); //ALWAYS returns 0, Even the value is a string "xyle"
Console.WriteLine(Encoding.Unicode.GetString(buff));//Always empty, tryed most of Encoding types to check still a blank result.
Console.ReadKey();
}
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[Out] byte[] lpBuffer,
int dwSize,
out IntPtr lpNumberOfBytesRead);
}
}
並確保傳遞dwSize(本例中爲1024)的緩衝區大小,而不是您當前擁有的10個緩衝區大小。 –