Implement Set As String (#940)

This commit is contained in:
Itay Cohen 2018-11-16 23:27:07 +02:00 committed by GitHub
parent 1dc636a325
commit b17656632c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 1 deletions

View File

@ -399,6 +399,12 @@ void CutterCore::setToCode(RVA addr)
emit instructionChanged(addr);
}
void CutterCore::setAsString(RVA addr)
{
cmd("Cs @ " + RAddressString(addr));
emit instructionChanged(addr);
}
void CutterCore::setToData(RVA addr, int size, int repeat)
{
if (size <= 0 || repeat <= 0) {

View File

@ -423,6 +423,7 @@ public:
/* Code/Data */
void setToCode(RVA addr);
void setAsString(RVA addr);
void setToData(RVA addr, int size, int repeat = 1);
int sizeofDataMeta(RVA addr);

View File

@ -70,10 +70,14 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent)
addSetBitsMenu();
initAction(&actionSetToCode, tr("Set to Code"),
initAction(&actionSetToCode, tr("Set as Code"),
SLOT(on_actionSetToCode_triggered()), getSetToCodeSequence());
addAction(&actionSetToCode);
initAction(&actionSetAsString, tr("Set as String"),
SLOT(on_actionSetAsString_triggered()), getSetAsStringSequence());
addAction(&actionSetAsString);
addSetToDataMenu();
addSeparator();
@ -330,6 +334,12 @@ QKeySequence DisassemblyContextMenu::getSetToCodeSequence() const
return {Qt::Key_C};
}
QKeySequence DisassemblyContextMenu::getSetAsStringSequence() const
{
return {Qt::Key_A};
}
QKeySequence DisassemblyContextMenu::getSetToDataSequence() const
{
return {Qt::Key_D};
@ -664,6 +674,12 @@ void DisassemblyContextMenu::on_actionSetToCode_triggered()
Core()->setToCode(offset);
}
void DisassemblyContextMenu::on_actionSetAsString_triggered()
{
Core()->setAsString(offset);
}
void DisassemblyContextMenu::on_actionSetToData_triggered()
{
int size = Core()->sizeofDataMeta(offset);

View File

@ -51,6 +51,7 @@ private slots:
void on_actionSetPC_triggered();
void on_actionSetToCode_triggered();
void on_actionSetAsString_triggered();
void on_actionSetToData_triggered();
void on_actionSetToDataEx_triggered();
@ -58,6 +59,7 @@ private:
QKeySequence getCopySequence() const;
QKeySequence getCommentSequence() const;
QKeySequence getSetToCodeSequence() const;
QKeySequence getSetAsStringSequence() const;
QKeySequence getSetToDataSequence() const;
QKeySequence getSetToDataExSequence() const;
QKeySequence getAddFlagSequence() const;
@ -119,6 +121,7 @@ private:
QAction actionSetPC;
QAction actionSetToCode;
QAction actionSetAsString;
QMenu *setToDataMenu;
QAction actionSetToDataEx;