diff --git a/plugins/builtin/include/content/providers/memory_file_provider.hpp b/plugins/builtin/include/content/providers/memory_file_provider.hpp index 82bbd3537..6553e0f60 100644 --- a/plugins/builtin/include/content/providers/memory_file_provider.hpp +++ b/plugins/builtin/include/content/providers/memory_file_provider.hpp @@ -38,8 +38,8 @@ namespace hex::plugin::builtin { [[nodiscard]] std::pair 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; } diff --git a/plugins/builtin/source/content/providers/memory_file_provider.cpp b/plugins/builtin/source/content/providers/memory_file_provider.cpp index 5a2672ccd..c32b0fcd1 100644 --- a/plugins/builtin/source/content/providers/memory_file_provider.cpp +++ b/plugins/builtin/source/content/providers/memory_file_provider.cpp @@ -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>(); + } + + [[nodiscard]] nlohmann::json MemoryFileProvider::storeSettings(nlohmann::json settings) const { + settings["data"] = this->m_data; + + return Provider::storeSettings(settings); + } + }