Files
archived-Reclass/src/providers/buffer_provider.h
sysadmin 44e4d88f58 Provider refactor: 2-method base class, ProcessProvider, ProcessPicker
Collapse Provider interface from 9 virtual methods to 2 (read + size),
move providers to src/providers/, add name()/kind()/getSymbol() virtuals.
Replace FileProvider with BufferProvider, add ProcessProvider (Win32)
with module-based symbol resolution, wire ProcessPicker dialog, and
integrate getSymbol into pointer display and command row.

- Fix isReadable overflow for large addresses
- Guard deferred showSourcePicker/showTypeAutocomplete against stale edits
- 7/7 tests pass including 3 new provider test suites

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 06:52:44 -07:00

48 lines
1.3 KiB
C++

#pragma once
#include "provider.h"
#include <QFile>
#include <QFileInfo>
namespace rcx {
class BufferProvider : public Provider {
QByteArray m_data;
QString m_name;
public:
explicit BufferProvider(QByteArray data, const QString& name = {})
: m_data(std::move(data))
, m_name(name) {}
static BufferProvider fromFile(const QString& path) {
QFile f(path);
if (f.open(QIODevice::ReadOnly))
return BufferProvider(f.readAll(), QFileInfo(path).fileName());
return BufferProvider({});
}
int size() const override { return m_data.size(); }
bool read(uint64_t addr, void* buf, int len) const override {
if (!isReadable(addr, len)) return false;
std::memcpy(buf, m_data.constData() + addr, len);
return true;
}
bool isWritable() const override { return true; }
bool write(uint64_t addr, const void* buf, int len) override {
if (!isReadable(addr, len)) return false;
std::memcpy(m_data.data() + addr, buf, len);
return true;
}
QString name() const override { return m_name; }
QString kind() const override { return QStringLiteral("File"); }
const QByteArray& data() const { return m_data; }
QByteArray& data() { return m_data; }
};
} // namespace rcx