2020-12-22 18:10:01 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/helpers/shared_data.hpp>
|
2021-01-30 22:39:06 +01:00
|
|
|
#include <hex/providers/overlay.hpp>
|
2021-01-04 00:19:56 +01:00
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
namespace hex::prv {
|
|
|
|
|
|
|
|
class Provider {
|
|
|
|
public:
|
|
|
|
constexpr static size_t PageSize = 0x1000'0000;
|
|
|
|
|
|
|
|
Provider();
|
2021-02-04 01:14:05 +01:00
|
|
|
virtual ~Provider();
|
2020-12-22 18:10:01 +01:00
|
|
|
|
|
|
|
virtual bool isAvailable() = 0;
|
|
|
|
virtual bool isReadable() = 0;
|
|
|
|
virtual bool isWritable() = 0;
|
|
|
|
|
2021-03-21 14:50:47 +01:00
|
|
|
virtual void read(u64 offset, void *buffer, size_t size, bool overlays = true);
|
2020-12-22 18:10:01 +01:00
|
|
|
virtual void write(u64 offset, const void *buffer, size_t size);
|
|
|
|
|
|
|
|
virtual void readRaw(u64 offset, void *buffer, size_t size) = 0;
|
|
|
|
virtual void writeRaw(u64 offset, const void *buffer, size_t size) = 0;
|
|
|
|
virtual size_t getActualSize() = 0;
|
|
|
|
|
2021-03-21 14:50:47 +01:00
|
|
|
void applyOverlays(u64 offset, void *buffer, size_t size);
|
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
std::map<u64, u8>& getPatches();
|
|
|
|
void applyPatches();
|
|
|
|
|
2021-01-30 22:39:06 +01:00
|
|
|
[[nodiscard]] Overlay* newOverlay();
|
|
|
|
void deleteOverlay(Overlay *overlay);
|
|
|
|
[[nodiscard]] const std::list<Overlay*>& getOverlays();
|
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
u32 getPageCount();
|
|
|
|
u32 getCurrentPage() const;
|
|
|
|
void setCurrentPage(u32 page);
|
|
|
|
|
2021-01-11 13:50:04 +01:00
|
|
|
virtual void setBaseAddress(u64 address);
|
|
|
|
virtual u64 getBaseAddress();
|
2020-12-22 18:10:01 +01:00
|
|
|
virtual size_t getSize();
|
|
|
|
virtual std::optional<u32> getPageOfAddress(u64 address);
|
|
|
|
|
|
|
|
virtual std::vector<std::pair<std::string, std::string>> getDataInformation() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
u32 m_currPage = 0;
|
2021-01-11 13:50:04 +01:00
|
|
|
u64 m_baseAddress = 0;
|
2020-12-22 18:10:01 +01:00
|
|
|
|
|
|
|
std::vector<std::map<u64, u8>> m_patches;
|
2021-01-30 22:39:06 +01:00
|
|
|
std::list<Overlay*> m_overlays;
|
2020-12-22 18:10:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|