1
0
mirror of synced 2024-11-28 17:40:51 +01:00

impr: Don't try to apply patches if there are none

This commit is contained in:
WerWolv 2023-03-26 12:48:18 +02:00
parent 245c56ba8a
commit 6a9f79628e

View File

@ -37,15 +37,14 @@ namespace hex::plugin::builtin {
void FileProvider::read(u64 offset, void *buffer, size_t size, bool overlays) { void FileProvider::read(u64 offset, void *buffer, size_t size, bool overlays) {
if ((offset - this->getBaseAddress()) > (this->getActualSize() - size) || buffer == nullptr || size == 0)
return;
this->readRaw(offset - this->getBaseAddress(), buffer, size); this->readRaw(offset - this->getBaseAddress(), buffer, size);
if (overlays) { if (overlays) {
if (auto &patches = this->getPatches(); !patches.empty()) {
for (u64 i = 0; i < size; i++) for (u64 i = 0; i < size; i++)
if (getPatches().contains(offset + i)) if (patches.contains(offset + i))
reinterpret_cast<u8 *>(buffer)[i] = getPatches()[offset + i]; reinterpret_cast<u8 *>(buffer)[i] = patches[offset + i];
}
this->applyOverlays(offset, buffer, size); this->applyOverlays(offset, buffer, size);
} }