From e5d664bc07e41a05b8b8e99799dc3f56d8d2b320 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 17 Feb 2021 14:57:32 +0100 Subject: [PATCH] Fixed bookmark creation in huge files --- source/views/view_hexeditor.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index 483f05e23..8573574b0 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -54,6 +54,8 @@ namespace hex { std::optional currColor, prevColor; + off += SharedData::currentProvider->getBaseAddress(); + for (const auto &[region, name, comment, color] : ImHexApi::Bookmarks::getEntries()) { if (off >= region.address && off < (region.address + region.size)) currColor = (color & 0x00FFFFFF) | 0x80000000; @@ -83,11 +85,13 @@ namespace hex { return false; }; - this->m_memoryEditor.HoverFn = [](const ImU8 *data, size_t addr) { + this->m_memoryEditor.HoverFn = [](const ImU8 *data, size_t off) { bool tooltipShown = false; + off += SharedData::currentProvider->getBaseAddress(); + for (const auto &[region, name, comment, color] : ImHexApi::Bookmarks::getEntries()) { - if (addr >= region.address && addr < (region.address + region.size)) { + if (off >= region.address && off < (region.address + region.size)) { if (!tooltipShown) { ImGui::BeginTooltip(); tooltipShown = true; @@ -1098,8 +1102,10 @@ R"( } if (ImGui::MenuItem("hex.view.hexeditor.menu.edit.bookmark"_lang, nullptr, false, this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) { - size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd); - size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd); + auto base = SharedData::currentProvider->getBaseAddress(); + + size_t start = base + std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd); + size_t end = base + std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd); ImHexApi::Bookmarks::add(start, end - start + 1, { }, { }); }