Fix process memory provider base address sync and live refresh

Provider base address now stays in sync with tree base address when
changed via ChangeBase command, fixing reads from arbitrary memory
regions like KUSER_SHARED_DATA at 0x7FFE0000. ReadProcessMemory
handles partial reads gracefully. Snapshot extent uses tree-based
calculation instead of provider size to avoid oversized reads.
MCP source.switch gains pid parameter for programmatic process attach.
MCP server starts by default with logging and slow mode support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
IChooseYou
2026-02-10 13:04:28 -07:00
committed by sysadmin
parent 6bd61a6b78
commit 5f1fd56171
9 changed files with 88 additions and 22 deletions

View File

@@ -62,9 +62,10 @@ bool ProcessMemoryProvider::read(uint64_t addr, void* buf, int len) const
if (!m_handle || len <= 0) return false;
SIZE_T bytesRead = 0;
if (ReadProcessMemory(m_handle, (LPCVOID)(m_base + addr), buf, (SIZE_T)len, &bytesRead))
return bytesRead == (SIZE_T)len;
return false;
ReadProcessMemory(m_handle, (LPCVOID)(m_base + addr), buf, (SIZE_T)len, &bytesRead);
if ((int)bytesRead < len)
memset((char*)buf + bytesRead, 0, len - bytesRead);
return bytesRead > 0;
}
bool ProcessMemoryProvider::write(uint64_t addr, const void* buf, int len)
@@ -298,9 +299,9 @@ ProcessMemoryProvider::~ProcessMemoryProvider()
int ProcessMemoryProvider::size() const
{
#ifdef _WIN32
return m_handle ? INT_MAX : 0;
return m_handle ? 0x10000 : 0;
#elif defined(__linux__)
return m_fd ? INT_MAX : 0;
return (m_fd >= 0) ? 0x10000 : 0;
#endif
}

View File

@@ -25,6 +25,10 @@ public:
QString kind() const override { return QStringLiteral("LocalProcess"); }
QString getSymbol(uint64_t addr) const override;
bool isLive() const override { return true; }
uint64_t base() const override { return m_base; }
void setBase(uint64_t b) override { m_base = b; }
// Process-specific helpers
uint32_t pid() const { return m_pid; }
uint64_t baseAddress() const { return m_base; }