fix: Overlays not being applied properly
This commit is contained in:
parent
768982b67a
commit
e6ad54b53b
@ -108,7 +108,7 @@ namespace hex::prv {
|
|||||||
* @param size number of bytes to read
|
* @param size number of bytes to read
|
||||||
* @param overlays apply overlays and patches is true. Same as readRaw() if false
|
* @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.
|
* @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 buffer buffer to take data to write from
|
||||||
* @param size number of bytes to write
|
* @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
|
* @brief Read data from this provider, without applying overlays and patches
|
||||||
|
@ -36,6 +36,9 @@ namespace hex::prv {
|
|||||||
hex::unused(overlays);
|
hex::unused(overlays);
|
||||||
|
|
||||||
this->readRaw(offset - this->getBaseAddress(), buffer, size);
|
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) {
|
void Provider::write(u64 offset, const void *buffer, size_t size) {
|
||||||
|
@ -22,9 +22,6 @@ namespace hex::plugin::builtin {
|
|||||||
[[nodiscard]] bool isResizable() const override;
|
[[nodiscard]] bool isResizable() const override;
|
||||||
[[nodiscard]] bool isSavable() 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 readRaw(u64 offset, void *buffer, size_t size) override;
|
||||||
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
||||||
[[nodiscard]] size_t getActualSize() const override;
|
[[nodiscard]] size_t getActualSize() const override;
|
||||||
|
@ -146,8 +146,7 @@ namespace hex::plugin::builtin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GDBProvider::readRaw(u64 offset, void *buffer, size_t size) {
|
||||||
void GDBProvider::read(u64 offset, void *buffer, size_t size, bool overlays) {
|
|
||||||
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
|
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -176,40 +175,23 @@ namespace hex::plugin::builtin {
|
|||||||
} else {
|
} else {
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
size_t readSize = std::min(size, CacheLineSize);
|
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;
|
size -= readSize;
|
||||||
offset += 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) {
|
void GDBProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
|
||||||
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
|
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
offset -= this->getBaseAddress();
|
||||||
|
|
||||||
gdb::writeMemory(this->m_socket, offset, buffer, size);
|
gdb::writeMemory(this->m_socket, offset, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,6 @@ namespace hex::plugin::windows {
|
|||||||
[[nodiscard]] bool isSavable() const override { return false; }
|
[[nodiscard]] bool isSavable() const override { return false; }
|
||||||
[[nodiscard]] bool isDumpable() 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 readRaw(u64 address, void *buffer, size_t size) override;
|
||||||
void writeRaw(u64 address, const 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; }
|
[[nodiscard]] size_t getActualSize() const override { return 0xFFFF'FFFF'FFFF; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user