-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Globals widget - Add global variable add/modify dialog - Add "Add at" context submenu in Disassembly widget
- Loading branch information
Showing
13 changed files
with
607 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "GlobalVariableDialog.h" | ||
#include "ui_GlobalVariableDialog.h" | ||
|
||
#include <QIntValidator> | ||
#include "core/Cutter.h" | ||
|
||
GlobalVariableDialog::GlobalVariableDialog(RVA offset, QWidget *parent) | ||
: QDialog(parent), ui(new Ui::GlobalVariableDialog), offset(offset), globalVariableName("") | ||
{ | ||
// Setup UI | ||
ui->setupUi(this); | ||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); | ||
RzAnalysisVarGlobal *globalVariable = rz_analysis_var_global_get_byaddr_at(Core()->core()->analysis, offset); | ||
if (globalVariable) { | ||
globalVariableName = QString(globalVariable->name); | ||
globalVariableOffset = globalVariable->addr; | ||
} | ||
|
||
if (globalVariable) { | ||
ui->nameEdit->setText(globalVariable->name); | ||
QString globalVarType = Core()->getGlobalVariableType(globalVariable->name); | ||
ui->typeEdit->setText(globalVarType); | ||
ui->labelAction->setText(tr("Edit global variable at %1").arg(RzAddressString(offset))); | ||
} else { | ||
ui->labelAction->setText(tr("Add global variable at %1").arg(RzAddressString(offset))); | ||
} | ||
|
||
// Connect slots | ||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &GlobalVariableDialog::buttonBoxAccepted); | ||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &GlobalVariableDialog::buttonBoxRejected); | ||
} | ||
|
||
GlobalVariableDialog::~GlobalVariableDialog() {} | ||
|
||
void GlobalVariableDialog::buttonBoxAccepted() | ||
{ | ||
QString name = ui->nameEdit->text(); | ||
QString typ = ui->typeEdit->text(); | ||
|
||
if (name.isEmpty()) { | ||
if (globalVariableOffset != RVA_INVALID) { | ||
// Empty name and global variable exists -> delete the global variable | ||
Core()->delGlobalVariable(globalVariableOffset); | ||
} else { | ||
// GlobalVariable was not existing and we gave an empty name, do nothing | ||
} | ||
} else { | ||
if (globalVariableOffset != RVA_INVALID) { | ||
// Name provided and global variable exists -> rename the global variable | ||
Core()->modifyGlobalVariable(globalVariableOffset, name, typ); | ||
} else { | ||
// Name provided and global variable does not exist -> create the global variable | ||
Core()->addGlobalVariable(globalVariableOffset, name, typ); | ||
} | ||
} | ||
close(); | ||
this->setResult(QDialog::Accepted); | ||
} | ||
|
||
void GlobalVariableDialog::buttonBoxRejected() | ||
{ | ||
close(); | ||
this->setResult(QDialog::Rejected); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef GLOBALVARIABLEDIALOG_H | ||
#define GLOBALVARIABLEDIALOG_H | ||
|
||
#include <QDialog> | ||
#include <memory> | ||
#include "core/CutterCommon.h" | ||
|
||
namespace Ui { | ||
class GlobalVariableDialog; | ||
} | ||
|
||
class GlobalVariableDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit GlobalVariableDialog(RVA offset, QWidget *parent = nullptr); | ||
~GlobalVariableDialog(); | ||
|
||
private slots: | ||
void buttonBoxAccepted(); | ||
void buttonBoxRejected(); | ||
|
||
private: | ||
std::unique_ptr<Ui::GlobalVariableDialog> ui; | ||
RVA offset; | ||
QString globalVariableName; | ||
ut64 globalVariableOffset; | ||
QString typ; | ||
}; | ||
|
||
#endif // GLOBALVARIABLEDIALOG_H |
Oops, something went wrong.