diff --git a/src/gui/Src/Gui/DisassemblerGraphView.cpp b/src/gui/Src/Gui/DisassemblerGraphView.cpp index 79fe9e75..fb098dc0 100644 --- a/src/gui/Src/Gui/DisassemblerGraphView.cpp +++ b/src/gui/Src/Gui/DisassemblerGraphView.cpp @@ -218,7 +218,7 @@ void DisassemblerGraphView::resizeEvent(QResizeEvent* event) adjustSize(event->size().width(), event->size().height()); } -duint DisassemblerGraphView::get_cursor_pos() +duint DisassemblerGraphView::get_cursor_pos() const { if(this->cur_instr == 0) return this->function; @@ -934,7 +934,7 @@ void DisassemblerGraphView::wheelEvent(QWheelEvent* event) } } -bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event) +bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event) const { //Convert coordinates to system used in blocks int xofs = this->horizontalScrollBar()->value(); @@ -945,7 +945,7 @@ bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event) // Check each block for hits for(auto & blockIt : this->blocks) { - DisassemblerBlock & block = blockIt.second; + auto & block = blockIt.second; //Compute coordinate relative to text area in block int blockx = x - (block.x + (2 * this->charWidth)); int blocky = y - (block.y + (2 * this->charWidth)); @@ -959,7 +959,7 @@ bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event) return false; } -duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) +duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) const { //Convert coordinates to system used in blocks int xofs = this->horizontalScrollBar()->value(); @@ -970,7 +970,7 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) //Check each block for hits for(auto & blockIt : this->blocks) { - DisassemblerBlock & block = blockIt.second; + auto & block = blockIt.second; //Compute coordinate relative to text area in block int blockx = x - (block.x + (2 * this->charWidth)); int blocky = y - (block.y + (2 * this->charWidth)); @@ -985,7 +985,7 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) int cur_row = int(block.block.header_text.lines.size()); if(row < cur_row) return block.block.entry; - for(Instr & instr : block.block.instrs) + for(auto & instr : block.block.instrs) { if(row < cur_row + int(instr.text.lines.size())) return instr.addr; @@ -995,7 +995,7 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) return 0; } -bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & tokenOut) +bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & tokenOut) const { //Convert coordinates to system used in blocks int xofs = this->horizontalScrollBar()->value(); @@ -1006,7 +1006,7 @@ bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisToken //Check each block for hits for(auto & blockIt : this->blocks) { - DisassemblerBlock & block = blockIt.second; + auto & block = blockIt.second; //Compute coordinate relative to text area in block int blockx = x - (block.x + (2 * this->charWidth)); int blocky = y - (block.y + (2 * this->charWidth)); @@ -1064,12 +1064,16 @@ bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisToken bool DisassemblerGraphView::find_instr(duint addr, Instr & instrOut) { for(auto & blockIt : this->blocks) + { for(Instr & instr : blockIt.second.block.instrs) + { if(instr.addr == addr) { instrOut = instr; return true; } + } + } return false; } @@ -1358,7 +1362,7 @@ void DisassemblerGraphView::computeGraphLayout(DisassemblerBlock & block) block.row_count = row_count; } -bool DisassemblerGraphView::isEdgeMarked(EdgesVector & edges, int row, int col, int index) +bool DisassemblerGraphView::isEdgeMarked(EdgesVector & edges, int row, int col, int index) const { if(index >= int(edges[row][col].size())) return false; @@ -2692,7 +2696,7 @@ void DisassemblerGraphView::copyHighlightedTokenValueSlot() Bridge::CopyToClipboard(text); } -bool DisassemblerGraphView::getHighlightedTokenValueText(QString & text) +bool DisassemblerGraphView::getHighlightedTokenValueText(QString & text) const { if(mHighlightToken.type <= ZydisTokenizer::TokenType::MnemonicUnusual) return false; diff --git a/src/gui/Src/Gui/DisassemblerGraphView.h b/src/gui/Src/Gui/DisassemblerGraphView.h index 1e07715a..1a140dbf 100644 --- a/src/gui/Src/Gui/DisassemblerGraphView.h +++ b/src/gui/Src/Gui/DisassemblerGraphView.h @@ -212,7 +212,7 @@ public: void initFont(); void adjustSize(int viewportWidth, int viewportHeight, QPoint mousePosition = QPoint(0, 0), bool fitToWindow = false); void resizeEvent(QResizeEvent* event); - duint get_cursor_pos(); + duint get_cursor_pos() const; void set_cursor_pos(duint addr); std::tuple get_selection_range(); void set_selection_range(std::tuple range); @@ -220,9 +220,9 @@ public: void paintNormal(QPainter & p, QRect & viewportRect, int xofs, int yofs); void paintOverview(QPainter & p, QRect & viewportRect, int xofs, int yofs); void paintEvent(QPaintEvent* event); - bool isMouseEventInBlock(QMouseEvent* event); - duint getInstrForMouseEvent(QMouseEvent* event); - bool getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & token); + bool isMouseEventInBlock(QMouseEvent* event) const; + duint getInstrForMouseEvent(QMouseEvent* event) const; + bool getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & token) const; bool find_instr(duint addr, Instr & instr); void mousePressEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); @@ -236,7 +236,7 @@ public: template using Matrix = std::vector>; using EdgesVector = Matrix>; - bool isEdgeMarked(EdgesVector & edges, int row, int col, int index); + bool isEdgeMarked(EdgesVector & edges, int row, int col, int index) const; void markEdge(EdgesVector & edges, int row, int col, int index, bool used = true); int findHorizEdgeIndex(EdgesVector & edges, int row, int min_col, int max_col); int findVertEdgeIndex(EdgesVector & edges, int col, int min_row, int max_row); @@ -257,7 +257,7 @@ public: VaHistory mHistory; signals: - void selectionChanged(dsint parVA); + void selectionChanged(duint parVA); void displayLogWidget(); void detachGraph(); @@ -392,5 +392,5 @@ private: XrefBrowseDialog* mXrefDlg = nullptr; void addReferenceAction(QMenu* menu, duint addr, const QString & description); - bool getHighlightedTokenValueText(QString & text); + bool getHighlightedTokenValueText(QString & text) const; };