8000 [pull] master from radareorg:master by pull[bot] · Pull Request #27 · Superoldman96/iaito · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[pull] master from radareorg:master #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Iaito.pro
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ SOURCES += \
dialogs/NewFileDialog.cpp \
widgets/CommentsWidget.cpp \
widgets/ConsoleWidget.cpp \
widgets/CustomCommandWidget.cpp \
widgets/Dashboard.cpp \
widgets/EntrypointWidget.cpp \
widgets/ExportsWidget.cpp \
Expand Down Expand Up @@ -511,6 +512,7 @@ HEADERS += \
dialogs/NewFileDialog.h \
widgets/CommentsWidget.h \
widgets/ConsoleWidget.h \
widgets/CustomCommandWidget.h \
widgets/Dashboard.h \
widgets/EntrypointWidget.h \
widgets/ExportsWidget.h \
Expand Down Expand Up @@ -719,6 +721,7 @@ FORMS += \
widgets/ListDockWidget.ui \
dialogs/LayoutManager.ui \
widgets/R2GraphWidget.ui \
widgets/CustomCommandWidget.ui \
dialogs/preferences/AnalOptionsWidget.ui

RESOURCES += \
Expand Down
4 changes: 4 additions & 0 deletions src/core/Iaito.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,11 @@ RefDescription IaitoCore::formatRefDesc(QJsonObject refItem)
} else if (type == "library") {
desc.refColor = ConfigColor("floc");
} else if (type == "stack") {
#if R2_VERSION_NUMBER >= 50909
desc.refColor = ConfigColor("addr");
#else
desc.refColor = ConfigColor("offset");
#endif
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/core/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "widgets/ClassesWidget.h"
#include "widgets/CommentsWidget.h"
#include "widgets/ConsoleWidget.h"
#include "widgets/CustomCommandWidget.h"
#include "widgets/Dashboard.h"
#include "widgets/DebugActions.h"
#include "widgets/DecompilerWidget.h"
Expand Down Expand Up @@ -158,6 +159,7 @@ void MainWindow::initUI()
connect(ui->actionExtraGraph, &QAction::triggered, this, &MainWindow::addExtraGraph);
connect(ui->actionExtraDisassembly, &QAction::triggered, this, &MainWindow::addExtraDisassembly);
connect(ui->actionExtraHexdump, &QAction::triggered, this, &MainWindow::addExtraHexdump);
connect(ui->actionAddCustomCommand, &QAction::triggered, this, &MainWindow::addExtraCustomCommand);
connect(ui->actionCommitChanges, &QAction::triggered, this, []() {
Core()->commitWriteCache();
});
Expand Down Expand Up @@ -525,6 +527,12 @@ void MainWindow::addExtraDecompiler()
addExtraWidget(extraDock);
}

void MainWindow::addExtraCustomCommand()
{
auto *extraDock = new CustomCommandWidget(this);
addExtraWidget(extraDock);
}

void MainWindow::addExtraWidget(IaitoDockWidget *extraDock)
{
extraDock->setTransient(true);
Expand Down
1 change: 1 addition & 0 deletions src/core/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private slots:
void addExtraHexdump();
void addExtraDisassembly();
void addExtraDecompiler();
void addExtraCustomCommand();

void on_actionRefresh_Panels_triggered();

Expand Down
6 changes: 6 additions & 0 deletions src/core/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<addaction name="menuAddDebugWidgets"/>
<addaction name="menuPlugins"/>
<addaction name="separator"/>
<addaction name="actionAddCustomCommand"/>
</widget>
<widget class="QMenu" name="menu 8000 Debug">
<property name="title">
Expand Down Expand Up @@ -799,6 +800,11 @@
<string>Add Graph</string>
</property>
</action>
<action name="actionAddCustomCommand">
<property name="text">
<string>Add Custom Command</string>
</property>
</action>
<action name="actionGrouped_dock_dragging">
<property name="checkable">
<bool>true</bool>
Expand Down
16 changes: 11 additions & 5 deletions src/dialogs/preferences/AsmOptionsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog *dialog)
}
ui->relToComboBox->blockSignals(false);
// Connect combobox changes to config update
connect(ui->relToComboBox,
static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &AsmOptionsWidget::on_relToComboBox_currentIndexChanged);
connect(ui->relToComboBox, &QComboBox::editTextChanged,
this, &AsmOptionsWidget::on_relToComboBox_currentIndexChanged);
// Connect combobox text changes to config update
connect(
ui->relToComboBox,
&QComboBox::currentTextChanged,
this,
&AsmOptionsWidget::on_relToComboBox_currentIndexChanged);
connect(
ui->relToComboBox,
&QComboBox::editTextChanged,
this,
&AsmOptionsWidget::on_relToComboBox_currentIndexChanged);

ui->syntaxComboBox->blockSignals(true);
for (const auto &syntax : Core()->cmdList("e asm.syntax=?"))
Expand Down
7 changes: 5 additions & 2 deletions src/menus/DisassemblyContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main
getDisplayOptionsSequence());
// Add "Relative to" submenu to select asm.addr.relto values at runtime
relativeToMenu = addMenu(tr("Relative to"));
connect(relativeToMenu, &QMenu::triggered,
this, &DisassemblyContextMenu::on_actionRelativeTo_triggered);
connect(
relativeToMenu,
&QMenu::triggered,
this,
&DisassemblyContextMenu::on_actionRelativeTo_triggered);

addSeparator();

Expand Down
68 changes: 68 additions & 0 deletions src/widgets/CustomCommandWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "widgets/CustomCommandWidget.h"
#include "common/CommandTask.h"
#include "core/MainWindow.h"
#include "ui_CustomCommandWidget.h"
#include <QPlainTextEdit>
#include <QSettings>
#include <QTextCursor>

CustomCommandWidget::CustomCommandWidget(MainWindow *main)
: IaitoDockWidget(main)
, ui(new Ui::CustomCommandWidget)
{
ui->setupUi(this);
setWindowTitle(tr("Custom Command"));

connect(ui->runButton, &QPushButton::clicked, this, &CustomCommandWidget::runCommand);
connect(ui->commandLineEdit, &QLineEdit::returnPressed, this, &CustomCommandWidget::runCommand);
connect(ui->wrapCheckBox, &QCheckBox::toggled, this, &CustomCommandWidget::setWrap);
setWrap(ui->wrapCheckBox->isChecked());

refreshDeferrer = createRefreshDeferrer([this]() {
if (!ui->commandLineEdit->text().isEmpty()) {
runCommand();
}
});
}

CustomCommandWidget::~CustomCommandWidget() = default;

void CustomCommandWidget::runCommand()
{
if (!commandTask.isNull()) {
return;
}
const QString cmd = ui->commandLineEdit->text().trimmed();
if (cmd.isEmpty()) {
return;
}
// Clear previous output when running a new command
ui->outputTextEdit->clear();
ui->runButton->setEnabled(false);
ui->commandLineEdit->setEnabled(false);

// ui->outputTextEdit->appendPlainText(QString("> %1").arg(cmd));
ui->outputTextEdit->moveCursor(QTextCursor::End);
ui->outputTextEdit->ensureCursorVisible();

commandTask = QSharedPointer<CommandTask>(new CommandTask(cmd, CommandTask::MODE_256, true));
connect(commandTask.data(), &CommandTask::finished, this, &CustomCommandWidget::onCommandFinished);
Core()->getAsyncTaskManager()->start(commandTask);
}

void CustomCommandWidget::onCommandFinished(const QString &result)
{
ui->outputTextEdit->appendHtml(result);
ui->outputTextEdit->moveCursor(QTextCursor::End);
ui->outputTextEdit->ensureCursorVisible();

ui->runButton->setEnabled(true);
ui->commandLineEdit->setEnabled(true);
// Clear the current task so the user can run another command
commandTask.reset();
}

void CustomCommandWidget::setWrap(bool wrap)
{
ui->outputTextEdit->setLineWrapMode(wrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
}
35 changes: 35 additions & 0 deletions src/widgets/CustomCommandWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef CUSTOMCOMMANDWIDGET_H
#define CUSTOMCOMMANDWIDGET_H

#include "common/CommandTask.h"
#include "widgets/IaitoDockWidget.h"
#include <memory>
#include <QSharedPointer>
#include <QString>

namespace Ui {
class CustomCommandWidget;
}
class RefreshDeferrer;
class MainWindow;

class CustomCommandWidget : public IaitoDockWidget
{
Q_OBJECT

public:
explicit CustomCommandWidget(MainWindow *main);
~CustomCommandWidget() override;

private slots:
void runCommand();
void onCommandFinished(const QString &result);
void setWrap(bool wrap);

private:
std::unique_ptr<Ui::CustomCommandWidget> ui;
QSharedPointer<CommandTask> commandTask;
RefreshDeferrer *refreshDeferrer;
};

#endif // CUSTOMCOMMANDWIDGET_H
72 changes: 72 additions & 0 deletions src/widgets/CustomCommandWidget.ui
C83B
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomCommandWidget</class>
<widget class="QDockWidget" name="CustomCommandWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Custom Command</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
</property>
<item>
<layout class="QHBoxLayout" name="hLayoutInput">
<item>
<widget class="QLineEdit" name="commandLineEdit">
<property name="placeholderText">
<string>Enter command</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="runButton">
<property name="text">
<string>Run</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="wrapCheckBox">
<property name="text">
<string>Wrap Lines</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="outputTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="font">
<font>
<family>Monospace</family>
</font>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
0