api: Refactored providers to allow for loading interfaces and config views

This commit is contained in:
WerWolv
2021-12-12 00:41:44 +01:00
parent 2e90abd2c5
commit 3e736b36b6
23 changed files with 272 additions and 145 deletions

View File

@@ -21,11 +21,11 @@ namespace hex::plugin::builtin::prv {
explicit FileProvider();
~FileProvider() override;
bool isAvailable() const override;
bool isReadable() const override;
bool isWritable() const override;
bool isResizable() const override;
bool isSavable() const 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 read(u64 offset, void *buffer, size_t size, bool overlays) override;
void write(u64 offset, const void *buffer, size_t size) override;
@@ -33,7 +33,7 @@ namespace hex::plugin::builtin::prv {
void readRaw(u64 offset, void *buffer, size_t size) override;
void writeRaw(u64 offset, const void *buffer, size_t size) override;
size_t getActualSize() const override;
[[nodiscard]] size_t getActualSize() const override;
void save() override;
void saveAs(const std::string &path) override;
@@ -41,10 +41,12 @@ namespace hex::plugin::builtin::prv {
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
void open(const std::string &path);
void close();
void setPath(const std::string &path);
private:
[[nodiscard]] bool open() override;
void close() override;
protected:
#if defined(OS_WINDOWS)
HANDLE m_file = INVALID_HANDLE_VALUE;
HANDLE m_mapping = INVALID_HANDLE_VALUE;

View File

@@ -14,11 +14,11 @@ class GDBProvider : public hex::prv::Provider {
explicit GDBProvider();
~GDBProvider() override;
bool isAvailable() const override;
bool isReadable() const override;
bool isWritable() const override;
bool isResizable() const override;
bool isSavable() const 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 read(u64 offset, void *buffer, size_t size, bool overlays) override;
void write(u64 offset, const void *buffer, size_t size) override;
@@ -26,7 +26,7 @@ class GDBProvider : public hex::prv::Provider {
void readRaw(u64 offset, void *buffer, size_t size) override;
void writeRaw(u64 offset, const void *buffer, size_t size) override;
size_t getActualSize() const override;
[[nodiscard]] size_t getActualSize() const override;
void save() override;
void saveAs(const std::string &path) override;
@@ -34,20 +34,26 @@ class GDBProvider : public hex::prv::Provider {
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
void connect(const std::string &address, u16 port);
void disconnect();
bool isConnected();
[[nodiscard]] bool open() override;
void close() override;
private:
[[nodiscard]] bool isConnected() const;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
void drawLoadInterface() override;
protected:
hex::Socket m_socket;
std::string m_ipAddress;
u16 m_port;
int m_port;
constexpr static size_t CacheLineSize = 0x1000;
struct CacheLine {
u64 address;
std::array<u8, 0x1000> data;
std::array<u8, CacheLineSize> data;
};
std::list<CacheLine> m_cache;

View File

@@ -3,6 +3,7 @@
#include <hex/views/view.hpp>
#include <array>
#include <atomic>
#include <cstdio>
#include <string>
#include <vector>
@@ -30,6 +31,7 @@ namespace hex::plugin::builtin {
std::array<ImU64, 256> m_valueCounts = { 0 };
bool m_analyzing = false;
std::atomic<u64> m_bytesAnalyzed;
std::pair<u64, u64> m_analyzedRegion = { 0, 0 };

View File

@@ -10,19 +10,17 @@
namespace hex::plugin::builtin {
class ViewGDB : public hex::View {
class ViewProviderSettings : public hex::View {
public:
ViewGDB();
ViewProviderSettings();
~ViewProviderSettings();
void drawContent() override;
void drawAlwaysVisible() override;
bool hasViewMenuItemEntry() override;
bool isAvailable();
private:
std::string m_address;
int m_port = 0;
};
}