From 34e2cdf960f286924d654dc0622ebcc15f9ef2bd Mon Sep 17 00:00:00 2001 From: itayc0hen Date: Fri, 20 Mar 2020 20:13:04 +0200 Subject: [PATCH] Use cmdRaw and cmdRawAt in DisassemblyContextMenu --- src/menus/DisassemblyContextMenu.cpp | 11 ++++++----- src/plugins/sample-cpp/CutterSamplePlugin.cpp | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index d1aa1e3f..2298475a 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -460,10 +460,11 @@ void DisassemblyContextMenu::aboutToShowSlot() actionAnalyzeFunction.setVisible(true); // Show the option to remove a defined string only if a string is defined in this address - QString stringDefinition = Core()->cmd("Cs. @ " + RAddressString(offset)); + QString stringDefinition = Core()->cmdRawAt("Cs.", offset); actionSetAsStringRemove.setVisible(!stringDefinition.isEmpty()); - QString comment = Core()->cmd("CC." + RAddressString(offset)); + QString comment = Core()->cmdRawAt("CC.", offset); + if (comment.isNull() || comment.isEmpty()) { actionDeleteComment.setVisible(false); actionAddComment.setText(tr("Add Comment")); @@ -841,7 +842,7 @@ void DisassemblyContextMenu::on_actionRenameUsedHere_triggered() if (dialog.exec()) { QString newName = dialog.getName().trimmed(); if (!newName.isEmpty()) { - Core()->cmd("an " + newName + " @ " + QString::number(offset)); + Core()->cmdRawAt(QString("an %1").arg(newName), offset); if (type == ThingUsedHere::Type::Address || type == ThingUsedHere::Type::Flag) { Core()->triggerFlagsChanged(); @@ -1006,7 +1007,7 @@ void DisassemblyContextMenu::on_actionEditFunction_triggered() stackSizeText.sprintf("%d", fcn->stack); dialog.setStackSizeText(stackSizeText); - QStringList callConList = Core()->cmd("afcl").split("\n"); + QStringList callConList = Core()->cmdRaw("afcl").split("\n"); callConList.removeLast(); dialog.setCallConList(callConList); dialog.setCallConSelected(fcn->cc); @@ -1019,7 +1020,7 @@ void DisassemblyContextMenu::on_actionEditFunction_triggered() fcn->addr = Core()->math(new_start_addr); QString new_stack_size = dialog.getStackSizeText(); fcn->stack = int(Core()->math(new_stack_size)); - Core()->cmd("afc " + dialog.getCallConSelected()); + Core()->cmdRaw("afc " + dialog.getCallConSelected()); emit Core()->functionsChanged(); } } diff --git a/src/plugins/sample-cpp/CutterSamplePlugin.cpp b/src/plugins/sample-cpp/CutterSamplePlugin.cpp index 497777ae..e514611c 100644 --- a/src/plugins/sample-cpp/CutterSamplePlugin.cpp +++ b/src/plugins/sample-cpp/CutterSamplePlugin.cpp @@ -62,6 +62,8 @@ void CutterSamplePluginWidget::on_seekChanged(RVA addr) void CutterSamplePluginWidget::on_buttonClicked() { QString fortune = Core()->cmd("fo").replace("\n", ""); + // cmdRaw can be used to execute single raw commands + // this is especially good for user-controlled input QString res = Core()->cmdRaw("?E " + fortune); text->setText(res); }