"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/menus/DisassemblyContextMenu.cpp" between
cutter-1.10.2.tar.gz and cutter-1.10.3.tar.gz

About: cutter is a Qt and C++ GUI for radare2 reverse engineering framework.

DisassemblyContextMenu.cpp  (cutter-1.10.2):DisassemblyContextMenu.cpp  (cutter-1.10.3)
skipping to change at line 460 skipping to change at line 460
structureOffsetMenu->addAction("[" + memBaseReg + " + " + val + "]") ->setData(val); structureOffsetMenu->addAction("[" + memBaseReg + " + " + val + "]") ->setData(val);
} }
if (structureOffsetMenu->isEmpty()) { if (structureOffsetMenu->isEmpty()) {
// No possible offset was found so hide the menu // No possible offset was found so hide the menu
structureOffsetMenu->menuAction()->setVisible(false); structureOffsetMenu->menuAction()->setVisible(false);
} }
} }
actionAnalyzeFunction.setVisible(true); actionAnalyzeFunction.setVisible(true);
QString comment = Core()->cmd("CC." + RAddressString(offset)); // Show the option to remove a defined string only if a string is defined in
this address
QString stringDefinition = Core()->cmdRawAt("Cs.", offset);
actionSetAsStringRemove.setVisible(!stringDefinition.isEmpty());
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"));
} else { } else {
actionDeleteComment.setVisible(true); actionDeleteComment.setVisible(true);
actionAddComment.setText(tr("Edit Comment")); actionAddComment.setText(tr("Edit Comment"));
} }
actionCopy.setVisible(canCopy); actionCopy.setVisible(canCopy);
copySeparator->setVisible(canCopy); copySeparator->setVisible(canCopy);
skipping to change at line 647 skipping to change at line 652
return {Qt::SHIFT + Qt::Key_P}; return {Qt::SHIFT + Qt::Key_P};
} }
QKeySequence DisassemblyContextMenu::getUndefineFunctionSequence() const QKeySequence DisassemblyContextMenu::getUndefineFunctionSequence() const
{ {
return {Qt::Key_U}; return {Qt::Key_U};
} }
void DisassemblyContextMenu::on_actionEditInstruction_triggered() void DisassemblyContextMenu::on_actionEditInstruction_triggered()
{ {
if (!ioModesController.prepareForWriting()) {
return;
}
EditInstructionDialog e(EDIT_TEXT, this); EditInstructionDialog e(EDIT_TEXT, this);
e.setWindowTitle(tr("Edit Instruction at %1").arg(RAddressString(offset))); e.setWindowTitle(tr("Edit Instruction at %1").arg(RAddressString(offset)));
QString oldInstructionOpcode = Core()->getInstructionOpcode(offset); QString oldInstructionOpcode = Core()->getInstructionOpcode(offset);
QString oldInstructionBytes = Core()->getInstructionBytes(offset); QString oldInstructionBytes = Core()->getInstructionBytes(offset);
e.setInstruction(oldInstructionOpcode); e.setInstruction(oldInstructionOpcode);
if (e.exec()) { if (e.exec()) {
QString userInstructionOpcode = e.getInstruction(); QString userInstructionOpcode = e.getInstruction();
if (userInstructionOpcode != oldInstructionOpcode) { if (userInstructionOpcode != oldInstructionOpcode) {
Core()->editInstruction(offset, userInstructionOpcode); Core()->editInstruction(offset, userInstructionOpcode);
// Check if the write failed
auto newInstructionBytes = Core()->getInstructionBytes(offset);
if (newInstructionBytes == oldInstructionBytes) {
if (!writeFailed()) {
Core()->editInstruction(offset, userInstructionOpcode);
}
}
} }
} }
} }
void DisassemblyContextMenu::on_actionNopInstruction_triggered() void DisassemblyContextMenu::on_actionNopInstruction_triggered()
{ {
QString oldBytes = Core()->getInstructionBytes(offset); if (!ioModesController.prepareForWriting()) {
return;
Core()->nopInstruction(offset);
QString newBytes = Core()->getInstructionBytes(offset);
if (oldBytes == newBytes) {
if (!writeFailed()) {
Core()->nopInstruction(offset);
}
} }
Core()->nopInstruction(offset);
} }
void DisassemblyContextMenu::showReverseJmpQuery() void DisassemblyContextMenu::showReverseJmpQuery()
{ {
QString type; QString type;
QJsonArray array = Core()->cmdj("pdj 1 @ " + RAddressString(offset)).array() ; QJsonArray array = Core()->cmdj("pdj 1 @ " + RAddressString(offset)).array() ;
if (array.isEmpty()) { if (array.isEmpty()) {
return; return;
} }
skipping to change at line 704 skipping to change at line 698
type = array.first().toObject()["type"].toString(); type = array.first().toObject()["type"].toString();
if (type == "cjmp") { if (type == "cjmp") {
actionJmpReverse.setVisible(true); actionJmpReverse.setVisible(true);
} else { } else {
actionJmpReverse.setVisible(false); actionJmpReverse.setVisible(false);
} }
} }
void DisassemblyContextMenu::on_actionJmpReverse_triggered() void DisassemblyContextMenu::on_actionJmpReverse_triggered()
{ {
QString oldBytes = Core()->getInstructionBytes(offset); if (!ioModesController.prepareForWriting()) {
return;
Core()->jmpReverse(offset);
QString newBytes = Core()->getInstructionBytes(offset);
if (oldBytes == newBytes) {
if (!writeFailed()) {
Core()->jmpReverse(offset);
}
} }
Core()->jmpReverse(offset);
} }
void DisassemblyContextMenu::on_actionEditBytes_triggered() void DisassemblyContextMenu::on_actionEditBytes_triggered()
{ {
if (!ioModesController.prepareForWriting()) {
return;
}
EditInstructionDialog e(EDIT_BYTES, this); EditInstructionDialog e(EDIT_BYTES, this);
e.setWindowTitle(tr("Edit Bytes at %1").arg(RAddressString(offset))); e.setWindowTitle(tr("Edit Bytes at %1").arg(RAddressString(offset)));
QString oldBytes = Core()->getInstructionBytes(offset); QString oldBytes = Core()->getInstructionBytes(offset);
e.setInstruction(oldBytes); e.setInstruction(oldBytes);
if (e.exec()) { if (e.exec()) {
QString bytes = e.getInstruction(); QString bytes = e.getInstruction();
if (bytes != oldBytes) { if (bytes != oldBytes) {
Core()->editBytes(offset, bytes); Core()->editBytes(offset, bytes);
QString newBytes = Core()->getInstructionBytes(offset);
if (oldBytes == newBytes) {
if (!writeFailed()) {
Core()->editBytes(offset, bytes);
}
}
} }
} }
} }
bool DisassemblyContextMenu::writeFailed()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Icon::Critical);
msgBox.setWindowTitle(tr("Write error"));
msgBox.setText(
tr("Unable to complete write operation. Consider opening in write mode.
\n\nWARNING: In write mode any changes will be committed to disk"));
msgBox.addButton(tr("OK"), QMessageBox::NoRole);
QAbstractButton *reopenButton = msgBox.addButton(tr("Reopen in write mode an
d try again"),
QMessageBox::YesRole);
msgBox.exec();
if (msgBox.clickedButton() == reopenButton) {
Core()->cmd("oo+");
return false;
}
return true;
}
void DisassemblyContextMenu::on_actionCopy_triggered() void DisassemblyContextMenu::on_actionCopy_triggered()
{ {
emit copy(); emit copy();
} }
void DisassemblyContextMenu::on_actionCopyAddr_triggered() void DisassemblyContextMenu::on_actionCopyAddr_triggered()
{ {
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(RAddressString(offset)); clipboard->setText(RAddressString(offset));
} }
skipping to change at line 875 skipping to change at line 838
dialog.setName("label." + QString::number(offset, 16)); dialog.setName("label." + QString::number(offset, 16));
} else { } else {
oldName = thingUsedHere.name; oldName = thingUsedHere.name;
dialog.setWindowTitle(tr("Rename %1").arg(oldName)); dialog.setWindowTitle(tr("Rename %1").arg(oldName));
dialog.setName(oldName); dialog.setName(oldName);
} }
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::T ype::Flag) { if (type == ThingUsedHere::Type::Address || type == ThingUsedHere::T ype::Flag) {
Core()->triggerFlagsChanged(); Core()->triggerFlagsChanged();
} else if (type == ThingUsedHere::Type::Var) { } else if (type == ThingUsedHere::Type::Var) {
Core()->triggerVarsChanged(); Core()->triggerVarsChanged();
} else if (type == ThingUsedHere::Type::Function) { } else if (type == ThingUsedHere::Type::Function) {
Core()->triggerFunctionRenamed(oldName, newName); Core()->triggerFunctionRenamed(oldName, newName);
} }
} }
} }
skipping to change at line 1040 skipping to change at line 1003
dialog.setWindowTitle(tr("Edit function %1").arg(fcn->name)); dialog.setWindowTitle(tr("Edit function %1").arg(fcn->name));
dialog.setNameText(fcn->name); dialog.setNameText(fcn->name);
QString startAddrText = "0x" + QString::number(fcn->addr, 16); QString startAddrText = "0x" + QString::number(fcn->addr, 16);
dialog.setStartAddrText(startAddrText); dialog.setStartAddrText(startAddrText);
QString stackSizeText; QString stackSizeText;
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);
if (dialog.exec()) { if (dialog.exec()) {
QString new_name = dialog.getNameText(); QString new_name = dialog.getNameText();
Core()->renameFunction(fcn->name, new_name); Core()->renameFunction(fcn->name, new_name);
QString new_start_addr = dialog.getStartAddrText(); QString new_start_addr = dialog.getStartAddrText();
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();
} }
} }
} }
void DisassemblyContextMenu::setBase(QString base) void DisassemblyContextMenu::setBase(QString base)
{ {
Core()->setImmediateBase(base, offset); Core()->setImmediateBase(base, offset);
} }
 End of changes. 13 change blocks. 
60 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)