2022-08-12 15:11:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex/providers/provider.hpp>
|
|
|
|
|
|
|
|
#include <IntervalTree.h>
|
|
|
|
|
2022-11-07 00:04:47 +01:00
|
|
|
namespace hex::plugin::builtin {
|
2022-08-12 15:11:27 +02:00
|
|
|
|
|
|
|
class IntelHexProvider : public hex::prv::Provider {
|
|
|
|
public:
|
|
|
|
IntelHexProvider() = default;
|
|
|
|
~IntelHexProvider() override = default;
|
|
|
|
|
|
|
|
[[nodiscard]] bool isAvailable() const override { return this->m_dataValid; }
|
|
|
|
[[nodiscard]] bool isReadable() const override { return true; }
|
|
|
|
[[nodiscard]] bool isWritable() const override { return false; }
|
|
|
|
[[nodiscard]] bool isResizable() const override { return false; }
|
|
|
|
[[nodiscard]] bool isSavable() const override { return false; }
|
|
|
|
|
2022-08-17 16:28:44 +02:00
|
|
|
void setBaseAddress(u64 address) override;
|
|
|
|
|
2022-08-12 15:11:27 +02:00
|
|
|
void readRaw(u64 offset, void *buffer, size_t size) override;
|
|
|
|
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
|
|
|
[[nodiscard]] size_t getActualSize() const override;
|
|
|
|
|
|
|
|
bool open() override;
|
|
|
|
void close() override;
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getName() const override;
|
2023-01-24 09:07:11 +01:00
|
|
|
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataDescription() const override { return { }; }
|
2022-08-12 15:11:27 +02:00
|
|
|
|
2022-08-14 10:07:45 +02:00
|
|
|
void loadSettings(const nlohmann::json &settings) override;
|
|
|
|
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override;
|
2022-08-12 15:11:27 +02:00
|
|
|
|
|
|
|
[[nodiscard]] std::string getTypeName() const override {
|
|
|
|
return "hex.builtin.provider.intel_hex";
|
|
|
|
}
|
|
|
|
|
2022-10-02 17:30:26 +02:00
|
|
|
[[nodiscard]] bool hasFilePicker() const override { return true; }
|
|
|
|
[[nodiscard]] bool handleFilePicker() override;
|
2022-08-12 15:11:27 +02:00
|
|
|
|
|
|
|
std::pair<Region, bool> getRegionValidity(u64 address) const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_dataValid = false;
|
|
|
|
size_t m_dataSize = 0x00;
|
|
|
|
interval_tree::IntervalTree<u64, std::vector<u8>> m_data;
|
|
|
|
|
|
|
|
std::fs::path m_sourceFilePath;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|