#pragma once #include #include #include #include #if defined(OS_WINDOWS) #include #endif namespace hex::plugin::builtin::prv { class DiskProvider : public hex::prv::Provider { public: DiskProvider(); ~DiskProvider() override; [[nodiscard]] bool isAvailable() const override; [[nodiscard]] bool isReadable() const override; [[nodiscard]] bool isWritable() const override; [[nodiscard]] bool isResizable() const override; [[nodiscard]] bool isSavable() const override; 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; void setPath(const std::string &path); [[nodiscard]] bool open() override; void close() override; [[nodiscard]] virtual std::string getName() const; [[nodiscard]] virtual std::vector> getDataInformation() const; [[nodiscard]] bool hasLoadInterface() const override { return true; } void drawLoadInterface() override; protected: std::set m_availableDrives; std::string m_path; #if defined(OS_WINDOWS) HANDLE m_diskHandle = INVALID_HANDLE_VALUE; #else int m_diskHandle = -1; #endif size_t m_diskSize; size_t m_sectorSize; u64 m_sectorBufferAddress; std::vector m_sectorBuffer; bool m_readable = false; bool m_writable = false; }; }