diff --git a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp index 0a91d79c..5a308822 100644 --- a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp +++ b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp @@ -4,14 +4,20 @@ namespace Bloom { ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem( const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, const Widgets::HexViewerSharedState& hexViewerState ) : focusedMemoryRegions(focusedMemoryRegions) + , excludedMemoryRegions(excludedMemoryRegions) , hexViewerState(hexViewerState) {} void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) { - auto* item = new Widgets::TopLevelGroupItem(this->focusedMemoryRegions, this->hexViewerState); + auto* item = new Widgets::TopLevelGroupItem( + this->focusedMemoryRegions, + this->excludedMemoryRegions, + this->hexViewerState + ); item->rebuildItemHierarchy(); emit this->topLevelGroupItem(item); diff --git a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp index 556923a0..43c083e7 100644 --- a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp +++ b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp @@ -17,6 +17,7 @@ namespace Bloom public: ConstructHexViewerTopLevelGroupItem( const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, const Widgets::HexViewerSharedState& hexViewerState ); @@ -37,5 +38,6 @@ namespace Bloom private: const Widgets::HexViewerSharedState& hexViewerState; const std::vector& focusedMemoryRegions; + const std::vector& excludedMemoryRegions; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp index e744e1ec..2471ccf4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp @@ -20,11 +20,16 @@ namespace Bloom::Widgets ) const { const auto boundingRect = QRect(0, 0, ByteItem::WIDTH, ByteItem::HEIGHT); - if (!graphicsItem->isEnabled()) { + if (!graphicsItem->isEnabled() || (this->excluded && !this->selected)) { painter->setOpacity(0.6); } if (this->excluded || !hexViewerState->data.has_value()) { + if (this->selected) { + painter->drawPixmap(boundingRect, ByteItem::selectedMissingDataPixmap.value()); + return; + } + painter->drawPixmap(boundingRect, ByteItem::missingDataPixmap.value()); return; } @@ -284,6 +289,14 @@ namespace Bloom::Widgets painter.drawText(byteItemRect, Qt::AlignCenter, "??"); } + { + ByteItem::selectedMissingDataPixmap = selectedTemplatePixmap; + auto painter = QPainter(&ByteItem::selectedMissingDataPixmap.value()); + painter.setFont(font); + painter.setPen(standardFontColor); + painter.drawText(byteItemRect, Qt::AlignCenter, "??"); + } + ByteItem::pixmapCachesGenerated = true; } } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp index 3adc27da..f88fe0fb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp @@ -52,6 +52,7 @@ namespace Bloom::Widgets static inline std::vector hoveredPrimaryPixmapsByValue = {}; static inline std::vector hoveredPrimaryAsciiPixmapsByValue = {}; static inline std::optional missingDataPixmap = {}; + static inline std::optional selectedMissingDataPixmap = {}; static void generatePixmapCaches(); }; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp index 53a1a73b..d227ccf7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp @@ -136,7 +136,11 @@ namespace Bloom::Widgets void ItemGraphicsScene::init() { const auto constructHexViewerTopLevelGroupItem = QSharedPointer( - new ConstructHexViewerTopLevelGroupItem(this->focusedMemoryRegions, this->state), + new ConstructHexViewerTopLevelGroupItem( + this->focusedMemoryRegions, + this->excludedMemoryRegions, + this->state + ), &QObject::deleteLater ); @@ -731,8 +735,10 @@ namespace Bloom::Widgets auto data = QString(); for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) { - const auto byteIndex = byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress; - data.append("0x" + QString::number((*this->state.data)[byteIndex], 16).rightJustified(2, '0').toUpper() + "\n"); + const unsigned char byteValue = byteItem->excluded + ? 0x00 + : (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress]; + data.append("0x" + QString::number(byteValue, 16).rightJustified(2, '0').toUpper() + "\n"); } QApplication::clipboard()->setText(std::move(data)); @@ -746,8 +752,10 @@ namespace Bloom::Widgets auto data = QString(); for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) { - const auto byteIndex = byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress; - data.append(QString::number((*this->state.data)[byteIndex], 10) + "\n"); + const unsigned char byteValue = byteItem->excluded + ? 0x00 + : (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress]; + data.append(QString::number(byteValue, 10) + "\n"); } QApplication::clipboard()->setText(std::move(data)); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp index f200a669..47d8e86f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp @@ -4,10 +4,12 @@ namespace Bloom::Widgets { TopLevelGroupItem::TopLevelGroupItem( const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, const HexViewerSharedState& hexViewerState ) : GroupItem(0, nullptr) , focusedMemoryRegions(focusedMemoryRegions) + , excludedMemoryRegions(excludedMemoryRegions) , hexViewerState(hexViewerState) { const auto memorySize = this->hexViewerState.memoryDescriptor.size(); @@ -64,6 +66,8 @@ namespace Bloom::Widgets } for (auto& [address, byteItem] : this->byteItemsByAddress) { + byteItem.excluded = false; + if (byteItem.parent != nullptr && byteItem.parent != this) { // This ByteItem is managed by another group continue; @@ -73,6 +77,19 @@ namespace Bloom::Widgets this->items.push_back(&byteItem); } + for (const auto& excludedRegion : this->excludedMemoryRegions) { + const auto& startAddress = excludedRegion.addressRange.startAddress; + const auto& endAddress = excludedRegion.addressRange.endAddress; + + // Sanity check + assert(byteItemsByAddress.contains(startAddress) && byteItemsByAddress.contains(endAddress)); + + for (auto address = startAddress; address <= endAddress; ++address) { + auto& byteItem = byteItemsByAddress.at(address); + byteItem.excluded = true; + } + } + this->sortItems(); this->refreshValues(); } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp index 8ba9fc71..df4a35f8 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp @@ -13,6 +13,7 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp" namespace Bloom::Widgets { @@ -23,6 +24,7 @@ namespace Bloom::Widgets TopLevelGroupItem( const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, const HexViewerSharedState& hexViewerState ); @@ -40,6 +42,7 @@ namespace Bloom::Widgets private: const std::vector& focusedMemoryRegions; + const std::vector& excludedMemoryRegions; const HexViewerSharedState& hexViewerState; std::list focusedRegionGroupItems;