#include #include "content/providers/gdb_provider.hpp" #include "content/providers/file_provider.hpp" #include "content/providers/null_provider.hpp" #include "content/providers/disk_provider.hpp" #include "content/providers/intel_hex_provider.hpp" #include "content/providers/motorola_srec_provider.hpp" #include #include #include namespace hex::plugin::builtin { void registerProviders() { ContentRegistry::Provider::add(false); ContentRegistry::Provider::add(false); ContentRegistry::Provider::add(); ContentRegistry::Provider::add(); ContentRegistry::Provider::add(); ContentRegistry::Provider::add(); ProjectFile::registerHandler({ .basePath = "providers", .load = [](const std::fs::path &basePath, Tar &tar) { auto json = nlohmann::json::parse(tar.readString(basePath / "providers.json")); auto providerIds = json["providers"].get>(); bool success = true; for (const auto &id : providerIds) { auto providerSettings = nlohmann::json::parse(tar.readString(basePath / hex::format("{}.json", id))); auto provider = ImHexApi::Provider::createProvider(providerSettings["type"].get(), true); if (provider == nullptr) { success = false; continue; } provider->loadSettings(providerSettings["settings"]); if (!provider->open()) success = false; } return success; }, .store = [](const std::fs::path &basePath, Tar &tar) { std::vector providerIds; for (const auto &provider : ImHexApi::Provider::getProviders()) { auto id = provider->getID(); providerIds.push_back(id); nlohmann::json json; json["type"] = provider->getTypeName(); json["settings"] = provider->storeSettings(); tar.write(basePath / hex::format("{}.json", id), json.dump(4)); } tar.write(basePath / "providers.json", nlohmann::json({ {"providers", providerIds } }).dump(4) ); return true; } }); } }