ufrisk/MemProcFS

Can not read memory at some address sometimes until triggering loading memory there

Closed this issue · 1 comments

Sometimes an address (while other addresses works fine) becomes unreadable suddenly (VMMDLL_MemReadEx returns OK but the dwRead is 0).
But if I use Cheat Engine to access that address in the Memory View panel, then that address will be readable again since then.
Please have a look at the recorded video attached.

The source code of main.exe is:

#include <iostream>
#include "D:\\MemProcFS_files_and_binaries_v5.13.0-win_x64-20241126\\vmmdll.h"
#pragma comment(lib, "D:\\MemProcFS_files_and_binaries_v5.13.0-win_x64-20241126\\vmm.lib")

void main() {
  LPCSTR args[] = { (LPCSTR)"", (LPCSTR)"-device", (LPCSTR)"FPGA" };
  VMM_HANDLE h = VMMDLL_Initialize(3, args);

  if (!h) {
    std::cerr << "init failed" << std::endl;
    system("pause");
    return;
  }

  std::cout << "init success" << std::endl;

  DWORD dwPID = 0x8E4;
  ULONG64 qwA = 0x7ffbfb5cd694;
  unsigned long dwRead;
  ULONG64 value = 0x99;
  BOOL ok = VMMDLL_MemReadEx(h, dwPID, qwA, (PBYTE)&value, 8, &dwRead, VMMDLL_FLAG_NOCACHE | VMMDLL_FLAG_NOCACHEPUT | VMMDLL_FLAG_NO_PREDICTIVE_READ);

  if (ok) {
    if (dwRead == 8) {
      std::cout << "read success: 0x" << std::hex << value << std::endl;
    }
    else {
      std::cerr << "dwRead incorrect: " << dwRead << " value=" << std::hex << value << std::endl;
    }
  }
  else {
    std::cerr << "read failed" << std::endl;
  }

  system("pause");
}
ccc.mp4
ufrisk commented

Memory may be "paged out" or may not have been accessed by the target system so it's not yet loaded into physical memory by the target system memory manager.

It's normal behavior and a limitation of fpga based dma.

It's not a bug I can fix.