diff --git a/lib/libimhex/source/providers/provider.cpp b/lib/libimhex/source/providers/provider.cpp index fa7109f94..189e4a301 100644 --- a/lib/libimhex/source/providers/provider.cpp +++ b/lib/libimhex/source/providers/provider.cpp @@ -154,8 +154,16 @@ namespace hex::prv { if (createUndo) createUndoPoint(); - for (u64 i = 0; i < size; i++) - getPatches()[offset + i] = reinterpret_cast(buffer)[i]; + for (u64 i = 0; i < size; i++) { + u8 patch = reinterpret_cast(buffer)[i]; + u8 originalValue = 0x00; + this->readRaw(offset + i, &originalValue, sizeof(u8)); + + if (patch == originalValue) + getPatches().erase(offset + i); + else + getPatches()[offset + i] = patch; + } } void Provider::createUndoPoint() {