Skip to content

Commit

Permalink
Merge pull request #3108 from shocoman/stackview-copy-dword
Browse files Browse the repository at this point in the history
Add actions to copy DWord/QWord and Comments in the Stack view
  • Loading branch information
mrexodia committed Jun 8, 2023
2 parents 4e96002 + 3ed1dab commit 7b1e56b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/gui/Src/Gui/CPUStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ void CPUStack::setupContextMenu()
{
return DbgFunctions()->ModBaseFromAddr(rvaToVa(getInitialSelection())) != 0;
});

//Copy->DWORD/QWORD
QString ptrName = ArchValue(tr("&DWORD"), tr("&QWORD"));
copyMenu->addAction(makeAction(ptrName, SLOT(copyPtrColumnSlot())));

//Copy->Comments
copyMenu->addAction(makeAction(tr("&Comments"), SLOT(copyCommentsColumnSlot())));

mMenuBuilder->addMenu(makeMenu(DIcon("copy"), tr("&Copy")), copyMenu);

//Breakpoint (hardware access) menu
Expand Down Expand Up @@ -925,3 +933,49 @@ void CPUStack::dbgStateChangedSlot(DBGSTATE state)
updateFreezeStackAction();
}
}

void CPUStack::copyPtrColumnSlot()
{
const duint wordSize = sizeof(duint);
dsint selStart = getSelectionStart();
dsint selLen = getSelectionEnd() - selStart + 1;
duint wordCount = selLen / wordSize;

duint* data = new duint[wordCount];
mMemPage->read((byte_t*)data, selStart, wordCount * wordSize);

QString clipboard;
for(duint i = 0; i < wordCount; i++)
{
if(i > 0)
clipboard += "\r\n";
clipboard += ToPtrString(data[i]);
}
delete [] data;

Bridge::CopyToClipboard(clipboard);
}

void CPUStack::copyCommentsColumnSlot()
{
int commentsColumn = 2;
const duint wordSize = sizeof(duint);
dsint selStart = getSelectionStart();
dsint selLen = getSelectionEnd() - selStart + 1;

QString clipboard;
for(dsint i = 0; i < selLen; i += wordSize)
{
RichTextPainter::List richText;
getColumnRichText(commentsColumn, selStart + i, richText);
QString colText;
for(auto & r : richText)
colText += r.text;

if(i > 0)
clipboard += "\r\n";
clipboard += colText;
}

Bridge::CopyToClipboard(clipboard);
}
2 changes: 2 additions & 0 deletions src/gui/Src/Gui/CPUStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public slots:
void dbgStateChangedSlot(DBGSTATE state);
void disasmSelectionChanged(dsint parVA);
void updateSlot();
void copyPtrColumnSlot();
void copyCommentsColumnSlot();

private:
duint mCsp = 0;
Expand Down

0 comments on commit 7b1e56b

Please sign in to comment.