1
0
mirror of synced 2024-11-15 19:43:23 +01:00
ImHex/plugins/builtin/include/content/providers/disk_provider.hpp
WerWolv 966f3b8597
sys: Replace existing bad project system with a much better one (#663)
* sys: Initial effort to replace existing project files with a better system

* sys: Added back marking provider as dirty

* sys: Remove git commit information from project files

* sys: Format data processor save file nicely

* fix: Automatic pattern loading not working correctly

* ui: Added warning popup when closing a provider with modifications

Closes #604

* sys: Fixed build issues

* tests: Removed useless debug logs

* patterns: Updated pattern language

* sys: Added log message when crashing with a signal

* sys: Make sure abnormal termination handlers are being called more reliably
2022-08-08 21:23:52 +02:00

71 lines
2.0 KiB
C++

#pragma once
#include <hex/providers/provider.hpp>
#include <set>
#include <string>
#include <vector>
#if defined(OS_WINDOWS)
#include <windows.h>
#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::fs::path &path);
[[nodiscard]] bool open() override;
void close() override;
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
void drawLoadInterface() override;
void loadSettings(const nlohmann::json &settings) override;
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings = { }) const override;
[[nodiscard]] std::string getTypeName() const override {
return "hex.builtin.provider.disk";
}
protected:
void reloadDrives();
std::set<std::string> m_availableDrives;
std::fs::path m_path;
#if defined(OS_WINDOWS)
HANDLE m_diskHandle = INVALID_HANDLE_VALUE;
#else
std::string m_pathBuffer;
int m_diskHandle = -1;
#endif
size_t m_diskSize = 0;
size_t m_sectorSize = 0;
u64 m_sectorBufferAddress = 0;
std::vector<u8> m_sectorBuffer;
bool m_readable = false;
bool m_writable = false;
};
}