2
我正在讀取內存中進程的數據。按預期工作。現在我只是在計時器中運行代碼來檢查更改。讀取進程內存事件
我想知道是否有任何方法來創建一個事件,只要內存發生變化就會觸發某個地址(我明顯知道)。我不是整個計時器解決方案的忠實粉絲。
private static extern bool ReadProcessMemory(IntPtr hProcess,
UIntPtr lpBaseaddress, [Out] byte[] lpBuffer,
UIntPtr nSize, IntPtr lpNumberOfBytesRead);
public static int ReadInt(long address)
{
byte[] buffer = new byte[sizeof(int)];
ReadProcessMemory(PHandle, (UIntPtr)address, buffer, (UIntPtr)4,
IntPtr.Zero);
return BitConverter.ToInt32(buffer, 0);
}
我覺得'unsafe'關鍵字來了! –