1
0
mirror of synced 2025-02-17 18:59:21 +01:00

feat: Properly save memory provider data

This commit is contained in:
WerWolv 2023-08-06 21:48:08 +02:00
parent e77f138514
commit ba9227c1e0
2 changed files with 19 additions and 4 deletions

View File

@ -38,8 +38,8 @@ namespace hex::plugin::builtin {
[[nodiscard]] std::pair<Region, bool> getRegionValidity(u64 address) const override;
void loadSettings(const nlohmann::json &settings) override { hex::unused(settings); }
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override { return settings; }
void loadSettings(const nlohmann::json &settings) override;
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override;
void setReadOnly(bool readOnly) { this->m_readOnly = readOnly; }

View File

@ -12,8 +12,11 @@
namespace hex::plugin::builtin {
bool MemoryFileProvider::open() {
this->m_data.resize(1);
this->markDirty();
if (this->m_data.empty()) {
this->m_data.resize(1);
this->markDirty();
}
return true;
}
@ -109,4 +112,16 @@ namespace hex::plugin::builtin {
return { Region::Invalid(), false };
}
void MemoryFileProvider::loadSettings(const nlohmann::json &settings) {
Provider::loadSettings(settings);
this->m_data = settings["data"].get<std::vector<u8>>();
}
[[nodiscard]] nlohmann::json MemoryFileProvider::storeSettings(nlohmann::json settings) const {
settings["data"] = this->m_data;
return Provider::storeSettings(settings);
}
}