Use cmdRaw and cmdRawAt in DisassemblyContextMenu

This commit is contained in:
itayc0hen 2020-03-20 20:13:04 +02:00 committed by Itay Cohen
parent 1f41983923
commit 34e2cdf960
2 changed files with 8 additions and 5 deletions

View File

@ -460,10 +460,11 @@ void DisassemblyContextMenu::aboutToShowSlot()
actionAnalyzeFunction.setVisible(true); actionAnalyzeFunction.setVisible(true);
// Show the option to remove a defined string only if a string is defined in this address // 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()); actionSetAsStringRemove.setVisible(!stringDefinition.isEmpty());
QString comment = Core()->cmd("CC." + RAddressString(offset)); QString comment = Core()->cmdRawAt("CC.", offset);
if (comment.isNull() || comment.isEmpty()) { if (comment.isNull() || comment.isEmpty()) {
actionDeleteComment.setVisible(false); actionDeleteComment.setVisible(false);
actionAddComment.setText(tr("Add Comment")); actionAddComment.setText(tr("Add Comment"));
@ -841,7 +842,7 @@ void DisassemblyContextMenu::on_actionRenameUsedHere_triggered()
if (dialog.exec()) { if (dialog.exec()) {
QString newName = dialog.getName().trimmed(); QString newName = dialog.getName().trimmed();
if (!newName.isEmpty()) { 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) { if (type == ThingUsedHere::Type::Address || type == ThingUsedHere::Type::Flag) {
Core()->triggerFlagsChanged(); Core()->triggerFlagsChanged();
@ -1006,7 +1007,7 @@ void DisassemblyContextMenu::on_actionEditFunction_triggered()
stackSizeText.sprintf("%d", fcn->stack); stackSizeText.sprintf("%d", fcn->stack);
dialog.setStackSizeText(stackSizeText); dialog.setStackSizeText(stackSizeText);
QStringList callConList = Core()->cmd("afcl").split("\n"); QStringList callConList = Core()->cmdRaw("afcl").split("\n");
callConList.removeLast(); callConList.removeLast();
dialog.setCallConList(callConList); dialog.setCallConList(callConList);
dialog.setCallConSelected(fcn->cc); dialog.setCallConSelected(fcn->cc);
@ -1019,7 +1020,7 @@ void DisassemblyContextMenu::on_actionEditFunction_triggered()
fcn->addr = Core()->math(new_start_addr); fcn->addr = Core()->math(new_start_addr);
QString new_stack_size = dialog.getStackSizeText(); QString new_stack_size = dialog.getStackSizeText();
fcn->stack = int(Core()->math(new_stack_size)); fcn->stack = int(Core()->math(new_stack_size));
Core()->cmd("afc " + dialog.getCallConSelected()); Core()->cmdRaw("afc " + dialog.getCallConSelected());
emit Core()->functionsChanged(); emit Core()->functionsChanged();
} }
} }

View File

@ -62,6 +62,8 @@ void CutterSamplePluginWidget::on_seekChanged(RVA addr)
void CutterSamplePluginWidget::on_buttonClicked() void CutterSamplePluginWidget::on_buttonClicked()
{ {
QString fortune = Core()->cmd("fo").replace("\n", ""); 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); QString res = Core()->cmdRaw("?E " + fortune);
text->setText(res); text->setText(res);
} }