sys: Added support for providers with unreadable regions

This commit is contained in:
WerWolv
2022-08-10 09:26:48 +02:00
parent 19a0dc80db
commit 5c13cf9dbf
8 changed files with 111 additions and 18 deletions

View File

@@ -21,11 +21,11 @@ namespace hex {
size_t size;
[[nodiscard]] constexpr bool isWithin(const Region &other) const {
return (this->getStartAddress() >= other.getStartAddress()) && (this->getEndAddress() <= other.getEndAddress());
return (this->getStartAddress() >= other.getStartAddress()) && (this->getEndAddress() <= other.getEndAddress()) && *this != Invalid() && other != Invalid();
}
[[nodiscard]] constexpr bool overlaps(const Region &other) const {
return (this->getEndAddress() >= other.getStartAddress()) && (this->getStartAddress() < other.getEndAddress());
return (this->getEndAddress() >= other.getStartAddress()) && (this->getStartAddress() < other.getEndAddress()) && *this != Invalid() && other != Invalid();
}
[[nodiscard]] constexpr u64 getStartAddress() const {
@@ -39,6 +39,14 @@ namespace hex {
[[nodiscard]] constexpr size_t getSize() const {
return this->size;
}
constexpr bool operator==(const Region &other) const {
return this->address == other.address && this->size == other.size;
}
constexpr static Region Invalid() {
return { 0, 0 };
}
};
}

View File

@@ -99,6 +99,8 @@ namespace hex::prv {
void markDirty(bool dirty = true) { this->m_dirty = dirty; }
[[nodiscard]] bool isDirty() const { return this->m_dirty; }
virtual std::pair<Region, bool> getRegionValidity(u64 address) const;
protected:
u32 m_currPage = 0;
u64 m_baseAddress = 0;