From 7c2e060a5f3bd58682f51fdd33fc9396c70cb587 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 23 Dec 2021 15:57:22 +0100 Subject: [PATCH] fix: Provider reading from invalid addresses on later pages This fixes #384 --- plugins/builtin/source/content/providers/file_provider.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 02a266004..53d06b9c7 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -68,14 +68,14 @@ namespace hex::plugin::builtin::prv { if ((offset + size) > this->getActualSize() || buffer == nullptr || size == 0) return; - std::memcpy(buffer, reinterpret_cast(this->m_mappedFile) + PageSize * this->m_currPage + offset, size); + std::memcpy(buffer, reinterpret_cast(this->m_mappedFile) + offset, size); } void FileProvider::writeRaw(u64 offset, const void *buffer, size_t size) { if ((offset + size) > this->getActualSize() || buffer == nullptr || size == 0) return; - std::memcpy(reinterpret_cast(this->m_mappedFile) + PageSize * this->m_currPage + offset, buffer, size); + std::memcpy(reinterpret_cast(this->m_mappedFile) + offset, buffer, size); } void FileProvider::save() { @@ -201,7 +201,7 @@ namespace hex::plugin::builtin::prv { } if (this->m_fileSize > 0) { - this->m_mapping = CreateFileMapping(this->m_file, nullptr, PAGE_READWRITE, fileSize.HighPart, fileSize.LowPart, nullptr); + this->m_mapping = CreateFileMapping(this->m_file, nullptr, PAGE_READWRITE, 0, 0, nullptr); if (this->m_mapping == nullptr || this->m_mapping == INVALID_HANDLE_VALUE) { return false; }