我正在尝试访问在Dolphin中运行的Smash Bros Melee仿真存储器中的某些值。 Dolphin调试模式表示我想要的值的地址为0x80C6BA10(我假设它的意思是0x00C6BA10,因为0x80C6BA10超出了整数限制,并且以前已将同一地址称为0x00C6BA10)。但是,当我将其传递给ReadProcessMemory函数时,我得到的字节数组仅为[0,0,0,0](我使用4个字节,因为我尝试获取的值是8位十六进制数) 。
我尝试使用OllyDbg检查地址是否正确,但是由于某种原因,Dolphin无法与OllyDbg一起使用,也许是因为它不是64位?我还尝试使用unchecked()方法来传递0x80C6BA10而不是0x00C6BA10。
public class Program
{
//Constant that says we want to just read memory
const int PROCESS_WM_READ = 0x0010;
// **** Imports the functions used to get memory data ****
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool
bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess, int
lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
static void Main(string[] args)
{
//Gets process by finding the first process with the name dolphin
Process melee = Process.GetProcessesByName("Dolphin")[0];
IntPtr processHandle = OpenProcess(PROCESS_WM_READ, false,
melee.Id);
int bytesRead = 0;
//The list that will be populated by the data we find in the
memory
byte[] buffer = new byte[4];
//Reads the memory at the specified location
ReadProcessMemory((int)processHandle, 0x00C6BA10, buffer,
buffer.Length, ref bytesRead);
//Converts byte array into floating point number -- not currently
being used
float memoryValue = BitConverter.ToSingle(buffer, 0);
foreach (byte b in buffer)
{
Console.WriteLine(b);
}
Console.ReadLine();
}
}
我期望输出为0以外的任何值,但是我得到的是0的数组。我认为部分问题可能是我试图从作为Dolphin子进程运行的进程中获取内存值。