mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-01 09:07:26 +00:00
Added hex flag
This commit is contained in:
parent
f97ab44072
commit
330803db99
@ -1,12 +1,13 @@
|
|||||||
#include "CommentsDialog.h"
|
#include "CommentsDialog.h"
|
||||||
#include "ui_CommentsDialog.h"
|
#include "ui_CommentsDialog.h"
|
||||||
|
#include <iostream>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
|
|
||||||
#include "core/Cutter.h"
|
#include "core/Cutter.h"
|
||||||
|
|
||||||
CommentsDialog::CommentsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CommentsDialog)
|
CommentsDialog::CommentsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CommentsDialog)
|
||||||
{
|
{
|
||||||
|
std::cout << "Comments dialog parent object name" << " " << parent->objectName().toStdString() << std::endl;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||||
|
|
||||||
|
@ -2,15 +2,20 @@
|
|||||||
#include "ui_FlagDialog.h"
|
#include "ui_FlagDialog.h"
|
||||||
|
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
|
#include <iostream>
|
||||||
#include "core/Cutter.h"
|
#include "core/Cutter.h"
|
||||||
|
|
||||||
FlagDialog::FlagDialog(RVA offset, QWidget *parent)
|
FlagDialog::FlagDialog(RVA offset, QWidget *parent)
|
||||||
: QDialog(parent), ui(new Ui::FlagDialog), offset(offset), flagName(""), flagOffset(RVA_INVALID)
|
: QDialog(parent), ui(new Ui::FlagDialog), offset(offset), flagName(""), flagOffset(RVA_INVALID)
|
||||||
{
|
{
|
||||||
|
std::cout << "offset" << " " << offset << std::endl;
|
||||||
|
std::cout << "parent" << " " << parent << std::endl;
|
||||||
|
std::cout << "parentObjectName" << " " << parent->objectName().toStdString() << std::endl;
|
||||||
// Setup UI
|
// Setup UI
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||||
RzFlagItem *flag = rz_flag_get_i(Core()->core()->flags, offset);
|
RzFlagItem *flag = rz_flag_get_i(Core()->core()->flags, offset);
|
||||||
|
std::cout << "flag" << " " << flag << std::endl;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
flagName = QString(flag->name);
|
flagName = QString(flag->name);
|
||||||
flagOffset = flag->offset;
|
flagOffset = flag->offset;
|
||||||
@ -23,6 +28,7 @@ FlagDialog::FlagDialog(RVA offset, QWidget *parent)
|
|||||||
ui->nameEdit->setText(flag->name);
|
ui->nameEdit->setText(flag->name);
|
||||||
ui->labelAction->setText(tr("Edit flag at %1").arg(RzAddressString(offset)));
|
ui->labelAction->setText(tr("Edit flag at %1").arg(RzAddressString(offset)));
|
||||||
} else {
|
} else {
|
||||||
|
std::cout << "offset in if condition" << " " << offset << std::endl;
|
||||||
ui->labelAction->setText(tr("Add flag at %1").arg(RzAddressString(offset)));
|
ui->labelAction->setText(tr("Add flag at %1").arg(RzAddressString(offset)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +43,7 @@ void FlagDialog::buttonBoxAccepted()
|
|||||||
{
|
{
|
||||||
RVA size = ui->sizeEdit->text().toULongLong();
|
RVA size = ui->sizeEdit->text().toULongLong();
|
||||||
QString name = ui->nameEdit->text();
|
QString name = ui->nameEdit->text();
|
||||||
|
std::cout << "name" << " " << name.toStdString() << std::endl;
|
||||||
|
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
if (flagOffset != RVA_INVALID) {
|
if (flagOffset != RVA_INVALID) {
|
||||||
@ -52,6 +59,7 @@ void FlagDialog::buttonBoxAccepted()
|
|||||||
} else {
|
} else {
|
||||||
// Name provided and flag does not exist -> create the flag
|
// Name provided and flag does not exist -> create the flag
|
||||||
Core()->addFlag(offset, name, size);
|
Core()->addFlag(offset, name, size);
|
||||||
|
std::cout << "Adding flag" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "dialogs/EditStringDialog.h"
|
#include "dialogs/EditStringDialog.h"
|
||||||
#include "dialogs/BreakpointsDialog.h"
|
#include "dialogs/BreakpointsDialog.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include <iostream>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include "Configuration.h"
|
#include "Configuration.h"
|
||||||
#include "dialogs/WriteCommandsDialogs.h"
|
#include "dialogs/WriteCommandsDialogs.h"
|
||||||
#include "dialogs/CommentsDialog.h"
|
#include "dialogs/CommentsDialog.h"
|
||||||
|
#include "dialogs/FlagDialog.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
@ -50,7 +52,6 @@ HexWidget::HexWidget(QWidget *parent)
|
|||||||
setFocusPolicy(Qt::FocusPolicy::StrongFocus);
|
setFocusPolicy(Qt::FocusPolicy::StrongFocus);
|
||||||
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this,
|
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this,
|
||||||
[this]() { viewport()->update(); });
|
[this]() { viewport()->update(); });
|
||||||
|
|
||||||
connect(Config(), &Configuration::colorsUpdated, this, &HexWidget::updateColors);
|
connect(Config(), &Configuration::colorsUpdated, this, &HexWidget::updateColors);
|
||||||
connect(Config(), &Configuration::fontsUpdated, this,
|
connect(Config(), &Configuration::fontsUpdated, this,
|
||||||
[this]() { setMonospaceFont(Config()->getFont()); });
|
[this]() { setMonospaceFont(Config()->getFont()); });
|
||||||
@ -137,6 +138,21 @@ HexWidget::HexWidget(QWidget *parent)
|
|||||||
&HexWidget::onActionDeleteCommentTriggered);
|
&HexWidget::onActionDeleteCommentTriggered);
|
||||||
addAction(actionDeleteComment);
|
addAction(actionDeleteComment);
|
||||||
|
|
||||||
|
// Flag Option - Rohan
|
||||||
|
// Add flag option
|
||||||
|
actionFlag = new QAction(tr("Add Flag"), this);
|
||||||
|
actionFlag->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||||
|
actionFlag->setShortcut(Qt::Key_N);
|
||||||
|
connect(actionFlag, &QAction::triggered, this, &HexWidget::onActionAddFlagTriggered);
|
||||||
|
addAction(actionFlag);
|
||||||
|
|
||||||
|
// Delete flag option
|
||||||
|
actionDeleteFlag = new QAction(tr("Delete Flag"), this);
|
||||||
|
actionDeleteFlag->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||||
|
connect(actionDeleteFlag, &QAction::triggered, this,
|
||||||
|
&HexWidget::onActionDeleteFlagTriggered);
|
||||||
|
addAction(actionDeleteFlag);
|
||||||
|
|
||||||
actionSelectRange = new QAction(tr("Select range"), this);
|
actionSelectRange = new QAction(tr("Select range"), this);
|
||||||
connect(actionSelectRange, &QAction::triggered, this,
|
connect(actionSelectRange, &QAction::triggered, this,
|
||||||
[this]() { rangeDialog.open(cursor.address); });
|
[this]() { rangeDialog.open(cursor.address); });
|
||||||
@ -214,6 +230,11 @@ HexWidget::HexWidget(QWidget *parent)
|
|||||||
connect(&warningTimer, &QTimer::timeout, this, &HexWidget::hideWarningRect);
|
connect(&warningTimer, &QTimer::timeout, this, &HexWidget::hideWarningRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *HexWidget::parentForDialog()
|
||||||
|
{
|
||||||
|
return parentWidget();
|
||||||
|
}
|
||||||
|
|
||||||
void HexWidget::setMonospaceFont(const QFont &font)
|
void HexWidget::setMonospaceFont(const QFont &font)
|
||||||
{
|
{
|
||||||
if (!(font.styleHint() & QFont::Monospace)) {
|
if (!(font.styleHint() & QFont::Monospace)) {
|
||||||
@ -1160,6 +1181,17 @@ void HexWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
actionComment->setText(tr("Edit Comment"));
|
actionComment->setText(tr("Edit Comment"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString flag = Core()->flagAt(cursor.address);
|
||||||
|
std::cout << "Flag at " << std::hex << cursor.address << " is " << flag.toStdString() << std::endl;
|
||||||
|
|
||||||
|
if (flag.isNull() || flag.isEmpty()) {
|
||||||
|
actionDeleteFlag->setVisible(false);
|
||||||
|
actionFlag->setText(tr("Add Flag"));
|
||||||
|
} else {
|
||||||
|
actionDeleteFlag->setVisible(true);
|
||||||
|
actionFlag->setText(tr("Edit Flag"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!ioModesController.canWrite()) {
|
if (!ioModesController.canWrite()) {
|
||||||
actionKeyboardEdit->setChecked(false);
|
actionKeyboardEdit->setChecked(false);
|
||||||
}
|
}
|
||||||
@ -1233,6 +1265,21 @@ void HexWidget::onActionAddCommentTriggered()
|
|||||||
CommentsDialog::addOrEditComment(addr, this);
|
CommentsDialog::addOrEditComment(addr, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HexWidget::onActionAddFlagTriggered()
|
||||||
|
{
|
||||||
|
uint64_t addr = cursor.address;
|
||||||
|
std::cout << "Add flag at " << std::hex << addr << std::endl;
|
||||||
|
FlagDialog dialog(addr, this);
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
// slot for deleting flag action
|
||||||
|
void HexWidget::onActionDeleteFlagTriggered()
|
||||||
|
{
|
||||||
|
uint64_t addr = cursor.address;
|
||||||
|
Core()->delFlag(addr);
|
||||||
|
}
|
||||||
|
|
||||||
// slot for deleting comment action
|
// slot for deleting comment action
|
||||||
void HexWidget::onActionDeleteCommentTriggered()
|
void HexWidget::onActionDeleteCommentTriggered()
|
||||||
{
|
{
|
||||||
|
@ -382,6 +382,8 @@ private slots:
|
|||||||
void copyAddress();
|
void copyAddress();
|
||||||
void onRangeDialogAccepted();
|
void onRangeDialogAccepted();
|
||||||
void onActionAddCommentTriggered();
|
void onActionAddCommentTriggered();
|
||||||
|
void onActionAddFlagTriggered();
|
||||||
|
void onActionDeleteFlagTriggered();
|
||||||
void onActionDeleteCommentTriggered();
|
void onActionDeleteCommentTriggered();
|
||||||
|
|
||||||
// Write command slots
|
// Write command slots
|
||||||
@ -424,6 +426,7 @@ private:
|
|||||||
QString renderItem(int offset, QColor *color = nullptr);
|
QString renderItem(int offset, QColor *color = nullptr);
|
||||||
QChar renderAscii(int offset, QColor *color = nullptr);
|
QChar renderAscii(int offset, QColor *color = nullptr);
|
||||||
QString getFlagsAndComment(uint64_t address);
|
QString getFlagsAndComment(uint64_t address);
|
||||||
|
QWidget *parentForDialog();
|
||||||
/**
|
/**
|
||||||
* @brief Get the location on which operations such as Writing should apply.
|
* @brief Get the location on which operations such as Writing should apply.
|
||||||
* @return Start of selection if multiple bytes are selected. Otherwise, the curren seek of the
|
* @return Start of selection if multiple bytes are selected. Otherwise, the curren seek of the
|
||||||
@ -576,6 +579,8 @@ private:
|
|||||||
QAction *actionCopy;
|
QAction *actionCopy;
|
||||||
QAction *actionCopyAddress;
|
QAction *actionCopyAddress;
|
||||||
QAction *actionComment;
|
QAction *actionComment;
|
||||||
|
QAction *actionFlag;
|
||||||
|
QAction *actionDeleteFlag;
|
||||||
QAction *actionDeleteComment;
|
QAction *actionDeleteComment;
|
||||||
QAction *actionSelectRange;
|
QAction *actionSelectRange;
|
||||||
QAction *actionKeyboardEdit;
|
QAction *actionKeyboardEdit;
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
Highlighter *highlighter;
|
Highlighter *highlighter;
|
||||||
|
|
||||||
static QString getWidgetType();
|
static QString getWidgetType();
|
||||||
|
QWidget *parentForDialog();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void initParsing();
|
void initParsing();
|
||||||
|
Loading…
Reference in New Issue
Block a user