1
0
mirror of synced 2025-01-18 17:14:13 +01:00

fix: Multiple file provider resize issues

This commit is contained in:
WerWolv 2023-06-03 23:57:41 +02:00
parent 6d19b33e32
commit de76c37ffb
2 changed files with 9 additions and 5 deletions

View File

@ -62,6 +62,11 @@ namespace hex::prv {
file.writeBuffer(buffer.data(), bufferSize); file.writeBuffer(buffer.data(), bufferSize);
} }
for (auto &[patchAddress, patch] : getPatches()) {
file.seek(patchAddress - this->getBaseAddress());
file.writeBuffer(&patch, 1);
}
EventManager::post<EventProviderSaved>(this); EventManager::post<EventProviderSaved>(this);
} }
} }
@ -130,13 +135,13 @@ namespace hex::prv {
} }
void Provider::applyPatches() { void Provider::applyPatches() {
if (!this->isWritable())
return;
for (auto &[patchAddress, patch] : getPatches()) { for (auto &[patchAddress, patch] : getPatches()) {
this->writeRaw(patchAddress - this->getBaseAddress(), &patch, 1); this->writeRaw(patchAddress - this->getBaseAddress(), &patch, 1);
} }
if (!this->isWritable())
return;
this->markDirty(); this->markDirty();
this->m_patches.emplace_back(); this->m_patches.emplace_back();

View File

@ -116,7 +116,6 @@ namespace hex::plugin::builtin {
void FileProvider::remove(u64 offset, size_t size) { void FileProvider::remove(u64 offset, size_t size) {
auto oldSize = this->getActualSize(); auto oldSize = this->getActualSize();
this->resize(oldSize + size);
std::vector<u8> buffer(0x1000); std::vector<u8> buffer(0x1000);
@ -230,7 +229,7 @@ namespace hex::plugin::builtin {
} }
void FileProvider::close() { void FileProvider::close() {
this->m_file.unmap();
} }
void FileProvider::loadSettings(const nlohmann::json &settings) { void FileProvider::loadSettings(const nlohmann::json &settings) {