1
0
mirror of synced 2025-01-18 00:56:49 +01:00

fix: Overlays not being applied properly

This commit is contained in:
WerWolv 2023-12-02 18:42:57 +01:00
parent 768982b67a
commit e6ad54b53b
5 changed files with 12 additions and 33 deletions

View File

@ -108,7 +108,7 @@ namespace hex::prv {
* @param size number of bytes to read
* @param overlays apply overlays and patches is true. Same as readRaw() if false
*/
virtual void read(u64 offset, void *buffer, size_t size, bool overlays = true);
void read(u64 offset, void *buffer, size_t size, bool overlays = true);
/**
* @brief Write data to the patches of this provider. Will not directly modify provider.
@ -116,7 +116,7 @@ namespace hex::prv {
* @param buffer buffer to take data to write from
* @param size number of bytes to write
*/
virtual void write(u64 offset, const void *buffer, size_t size);
void write(u64 offset, const void *buffer, size_t size);
/**
* @brief Read data from this provider, without applying overlays and patches

View File

@ -36,6 +36,9 @@ namespace hex::prv {
hex::unused(overlays);
this->readRaw(offset - this->getBaseAddress(), buffer, size);
if (overlays)
this->applyOverlays(offset, buffer, size);
}
void Provider::write(u64 offset, const void *buffer, size_t size) {

View File

@ -22,9 +22,6 @@ namespace hex::plugin::builtin {
[[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;
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;

View File

@ -146,8 +146,7 @@ namespace hex::plugin::builtin {
return false;
}
void GDBProvider::read(u64 offset, void *buffer, size_t size, bool overlays) {
void GDBProvider::readRaw(u64 offset, void *buffer, size_t size) {
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
return;
@ -176,40 +175,23 @@ namespace hex::plugin::builtin {
} else {
while (size > 0) {
size_t readSize = std::min(size, CacheLineSize);
this->readRaw(offset, buffer, readSize);
auto data = gdb::readMemory(this->m_socket, offset, size);
if (!data.empty())
std::memcpy(buffer, &data[0], data.size());
size -= readSize;
offset += readSize;
}
}
if (overlays) {
this->applyOverlays(offset, buffer, size);
}
}
void GDBProvider::write(u64 offset, const void *buffer, size_t size) {
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
return;
offset -= this->getBaseAddress();
gdb::writeMemory(this->m_socket, offset, buffer, size);
}
void GDBProvider::readRaw(u64 offset, void *buffer, size_t size) {
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
return;
auto data = gdb::readMemory(this->m_socket, offset, size);
if (!data.empty())
std::memcpy(buffer, &data[0], data.size());
}
void GDBProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
return;
offset -= this->getBaseAddress();
gdb::writeMemory(this->m_socket, offset, buffer, size);
}

View File

@ -23,9 +23,6 @@ namespace hex::plugin::windows {
[[nodiscard]] bool isSavable() const override { return false; }
[[nodiscard]] bool isDumpable() const override { return false; }
void read(u64 address, void *buffer, size_t size, bool) override { this->readRaw(address, buffer, size); }
void write(u64 address, const void *buffer, size_t size) override { this->writeRaw(address, buffer, size); }
void readRaw(u64 address, void *buffer, size_t size) override;
void writeRaw(u64 address, const void *buffer, size_t size) override;
[[nodiscard]] size_t getActualSize() const override { return 0xFFFF'FFFF'FFFF; }