mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
format ****(seed)
This commit is contained in:
parent
b91ea94543
commit
b12f665668
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
# The final executable after `make clean`
|
||||
|
||||
iaito
|
||||
AStyle*
|
||||
|
||||
# C++ objects and libs
|
||||
|
||||
|
10
README.md
10
README.md
@ -18,6 +18,16 @@ Iaitō is not aimed at existing radare2 users, it is focused on those whose are
|
||||
|
||||
Yes, the code sucks. Hopefully we will be able to remove this statement from the README one day, but I had never coded Qt nor C++ until I started Iaitō, so obviously the code is ugly and not well designed.
|
||||
|
||||
### Code formatting
|
||||
|
||||
We use [AStyle 2.06](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.06/) to format the code. The command line for formatting the code according to the style is:
|
||||
|
||||
```bash
|
||||
AStyle --style=allman --convert-tabs --align-pointer=name --align-reference=name --indent=spaces --indent-namespaces --indent-col1-comments --pad-oper --pad-header --unpad-paren --keep-one-line-blocks --close-templates $(git ls-files *.cpp *.h *.c *.hpp)
|
||||
```
|
||||
|
||||
**If in doubt, check the source around you and follow that style!**
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Radare2**: Make sure that, when cloning the project, you use `git clone --recurse-submodules` or run `git submodule init` and `git submodule update` to clone the correct radare2 version. Then execute the following command in the radare2 folder:
|
||||
|
@ -11,7 +11,8 @@ AnalThread::AnalThread(QWidget *parent) :
|
||||
|
||||
AnalThread::~AnalThread()
|
||||
{
|
||||
if (isRunning()) {
|
||||
if (isRunning())
|
||||
{
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class QRCore;
|
||||
|
||||
class AnalThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AnalThread(QWidget *parent = 0);
|
||||
~AnalThread();
|
||||
|
@ -22,7 +22,7 @@ void createNewDialog::on_pushButton_2_clicked()
|
||||
{
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
NewFileDialog* n = new NewFileDialog(nullptr);
|
||||
NewFileDialog *n = new NewFileDialog(nullptr);
|
||||
n->show();
|
||||
}
|
||||
|
||||
@ -35,25 +35,37 @@ void createNewDialog::on_exampleButton_clicked()
|
||||
{
|
||||
QString type = ui->comboType->currentText();
|
||||
QString str;
|
||||
if (type == "Assembler") {
|
||||
if (type == "Assembler")
|
||||
{
|
||||
str = "; Sample program code\nmov eax, 1\nint 0x80";
|
||||
} else if (type == "Text") {
|
||||
}
|
||||
else if (type == "Text")
|
||||
{
|
||||
str = "Hello World";
|
||||
} else if (type == "Rapatch") {
|
||||
}
|
||||
else if (type == "Rapatch")
|
||||
{
|
||||
str = "; Sample rapatch script\n"
|
||||
"0x0 \"Hello World\n"
|
||||
"0x10 909090";
|
||||
} else if (type == "C Code") {
|
||||
"0x0 \"Hello World\n"
|
||||
"0x10 909090";
|
||||
}
|
||||
else if (type == "C Code")
|
||||
{
|
||||
str = "int main() {\n"
|
||||
" write (1, \"Hello World\", 12);\n"
|
||||
" exit (0);\n"
|
||||
"}";
|
||||
} else if (type == "Radare2 script") {
|
||||
" write (1, \"Hello World\", 12);\n"
|
||||
" exit (0);\n"
|
||||
"}";
|
||||
}
|
||||
else if (type == "Radare2 script")
|
||||
{
|
||||
str = "w Hello\ns+5\nw World";
|
||||
} else if (type == "Hexpairs") {
|
||||
}
|
||||
else if (type == "Hexpairs")
|
||||
{
|
||||
str = "48656c6c6f20576f726c6400";
|
||||
} else fprintf (stderr, "Unknown combo value selected");
|
||||
if (str.length()>0)
|
||||
}
|
||||
else fprintf(stderr, "Unknown combo value selected");
|
||||
if (str.length() > 0)
|
||||
ui->plainTextEdit->setPlainText(str);
|
||||
// }
|
||||
}
|
||||
@ -66,105 +78,151 @@ void createNewDialog::on_buttonCreate_clicked()
|
||||
bool created = false;
|
||||
|
||||
QString arch = ui->comboArch->currentText();
|
||||
int fsize = r_num_math (NULL, ui->entrySize->text().toUtf8().constData());
|
||||
int fsize = r_num_math(NULL, ui->entrySize->text().toUtf8().constData());
|
||||
QString format = ui->comboFormat->currentText();
|
||||
|
||||
if (type == "Assembler") {
|
||||
RAsmCode *code = r_asm_massemble (lcore->assembler, ui->plainTextEdit->toPlainText().toUtf8().constData());
|
||||
if (code && code->len>0) {
|
||||
if (type == "Assembler")
|
||||
{
|
||||
RAsmCode *code = r_asm_massemble(lcore->assembler, ui->plainTextEdit->toPlainText().toUtf8().constData());
|
||||
if (code && code->len > 0)
|
||||
{
|
||||
char file[32];
|
||||
snprintf (file, sizeof(file)-1, "malloc://%d", code->len);
|
||||
if (w->core->loadFile(file,0,0,1,0,0,false)) {
|
||||
snprintf(file, sizeof(file) - 1, "malloc://%d", code->len);
|
||||
if (w->core->loadFile(file, 0, 0, 1, 0, 0, false))
|
||||
{
|
||||
created = true;
|
||||
r_core_write_at(lcore,0, code->buf, code->len);
|
||||
} else {
|
||||
__alert ("Failed to create file");
|
||||
r_core_write_at(lcore, 0, code->buf, code->len);
|
||||
}
|
||||
else
|
||||
{
|
||||
__alert("Failed to create file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Invalid assembler code");
|
||||
}
|
||||
r_asm_code_free (code);
|
||||
} else if (type == "Rapatch") {
|
||||
if (fsize>0) {
|
||||
else
|
||||
{
|
||||
__alert("Invalid assembler code");
|
||||
}
|
||||
r_asm_code_free(code);
|
||||
}
|
||||
else if (type == "Rapatch")
|
||||
{
|
||||
if (fsize > 0)
|
||||
{
|
||||
char file[32];
|
||||
created = true;
|
||||
snprintf (file, sizeof(file)-1, "malloc://%d", fsize);
|
||||
if (w->core->loadFile(file,0,0,1,0,0,false)) {
|
||||
r_core_patch (lcore, ui->plainTextEdit->toPlainText().toUtf8().constData());
|
||||
snprintf(file, sizeof(file) - 1, "malloc://%d", fsize);
|
||||
if (w->core->loadFile(file, 0, 0, 1, 0, 0, false))
|
||||
{
|
||||
r_core_patch(lcore, ui->plainTextEdit->toPlainText().toUtf8().constData());
|
||||
r_core_seek(lcore, 0, 1);
|
||||
created = true;
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Invalid file size");
|
||||
else
|
||||
{
|
||||
__alert("failed to open file");
|
||||
}
|
||||
}
|
||||
} else if (type == "C Code") {
|
||||
else
|
||||
{
|
||||
__alert("Invalid file size");
|
||||
}
|
||||
}
|
||||
else if (type == "C Code")
|
||||
{
|
||||
__alert("C Code: TODO");
|
||||
// ragg2-cc -x
|
||||
} else if (type == "Radare2 script") {
|
||||
if (fsize>0) {
|
||||
}
|
||||
else if (type == "Radare2 script")
|
||||
{
|
||||
if (fsize > 0)
|
||||
{
|
||||
char file[32];
|
||||
created = true;
|
||||
snprintf (file, sizeof(file)-1, "malloc://%d", fsize);
|
||||
if (w->core->loadFile(file,0,0,1,0,0,false)) {
|
||||
snprintf(file, sizeof(file) - 1, "malloc://%d", fsize);
|
||||
if (w->core->loadFile(file, 0, 0, 1, 0, 0, false))
|
||||
{
|
||||
created = true;
|
||||
QString str = ui->plainTextEdit->toPlainText();
|
||||
QList <QString> lines = str.split("\n");
|
||||
foreach (QString str, lines) {
|
||||
foreach (QString str, lines)
|
||||
{
|
||||
w->core->cmd(str);
|
||||
}
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Invalid file size");
|
||||
else
|
||||
{
|
||||
__alert("failed to open file");
|
||||
}
|
||||
}
|
||||
} else if (type == "Text") {
|
||||
else
|
||||
{
|
||||
__alert("Invalid file size");
|
||||
}
|
||||
}
|
||||
else if (type == "Text")
|
||||
{
|
||||
char file[32];
|
||||
QByteArray hexpairs = ui->plainTextEdit->toPlainText().toUtf8();
|
||||
int sz = strlen (hexpairs.constData());
|
||||
if (sz>0) {
|
||||
snprintf (file, sizeof(file)-1, "malloc://%d", sz);
|
||||
if (w->core->loadFile(file,0,0,1,0,0,false)) {
|
||||
int sz = strlen(hexpairs.constData());
|
||||
if (sz > 0)
|
||||
{
|
||||
snprintf(file, sizeof(file) - 1, "malloc://%d", sz);
|
||||
if (w->core->loadFile(file, 0, 0, 1, 0, 0, false))
|
||||
{
|
||||
created = true;
|
||||
r_core_write_at(lcore,0, (const ut8*)hexpairs.constData(), sz);
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
r_core_write_at(lcore, 0, (const ut8 *)hexpairs.constData(), sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
__alert("failed to open file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Empty string?");
|
||||
}
|
||||
} else if (type == "Hexpairs") {
|
||||
else
|
||||
{
|
||||
__alert("Empty string?");
|
||||
}
|
||||
}
|
||||
else if (type == "Hexpairs")
|
||||
{
|
||||
char file[32];
|
||||
int sz;
|
||||
QByteArray hexpairs = ui->plainTextEdit->toPlainText().toUtf8();
|
||||
ut8 *buf = (ut8*)malloc (strlen (hexpairs.constData()) + 1);
|
||||
sz = r_hex_str2bin (hexpairs.constData(), buf);
|
||||
if (sz>0) {
|
||||
snprintf (file, sizeof(file)-1, "malloc://%d", sz);
|
||||
if (w->core->loadFile(file,0,0,1,0,0,false)) {
|
||||
ut8 *buf = (ut8 *)malloc(strlen(hexpairs.constData()) + 1);
|
||||
sz = r_hex_str2bin(hexpairs.constData(), buf);
|
||||
if (sz > 0)
|
||||
{
|
||||
snprintf(file, sizeof(file) - 1, "malloc://%d", sz);
|
||||
if (w->core->loadFile(file, 0, 0, 1, 0, 0, false))
|
||||
{
|
||||
created = true;
|
||||
r_core_write_at(lcore,0, buf, sz);
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
r_core_write_at(lcore, 0, buf, sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
__alert("failed to open file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Invalid hexpair string");
|
||||
}
|
||||
free (buf);
|
||||
} else {
|
||||
__alert ("Unknown combo value selected");
|
||||
else
|
||||
{
|
||||
__alert("Invalid hexpair string");
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
__alert("Unknown combo value selected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (format != "Raw") {
|
||||
__alert ("TODO: non-raw fileformat is not yet supported");
|
||||
if (format != "Raw")
|
||||
{
|
||||
__alert("TODO: non-raw fileformat is not yet supported");
|
||||
created = false;
|
||||
delete w->core;
|
||||
}
|
||||
|
||||
if (created) {
|
||||
if (created)
|
||||
{
|
||||
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
@ -174,8 +232,10 @@ void createNewDialog::on_buttonCreate_clicked()
|
||||
w->setFilename("-");
|
||||
w->add_output("Finished, check its contents");
|
||||
w->showMaximized();
|
||||
} else {
|
||||
__alert ("No file created.");
|
||||
}
|
||||
else
|
||||
{
|
||||
__alert("No file created.");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@
|
||||
#include <QDialog>
|
||||
#include "mainwindow.h"
|
||||
|
||||
namespace Ui {
|
||||
class createNewDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class createNewDialog;
|
||||
}
|
||||
|
||||
class createNewDialog : public QDialog
|
||||
@ -27,7 +28,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::createNewDialog *ui;
|
||||
MainWindow* w;
|
||||
MainWindow *w;
|
||||
};
|
||||
|
||||
#endif // CREATENEWDIALOG_H
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class AboutDialog;
|
||||
}
|
||||
|
||||
class AboutDialog : public QDialog
|
||||
|
@ -24,7 +24,8 @@ void CommentsDialog::on_buttonBox_rejected()
|
||||
close();
|
||||
}
|
||||
|
||||
QString CommentsDialog::getComment() {
|
||||
QString CommentsDialog::getComment()
|
||||
{
|
||||
QString ret = ui->lineEdit->text();
|
||||
return ret;
|
||||
}
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class CommentsDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class CommentsDialog;
|
||||
}
|
||||
|
||||
class CommentsDialog : public QDialog
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class RenameDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class RenameDialog;
|
||||
}
|
||||
|
||||
class RenameDialog : public QDialog
|
||||
|
@ -27,9 +27,11 @@ XrefsDialog::~XrefsDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void XrefsDialog::fillRefs(QList<QStringList> refs, QList<QStringList> xrefs) {
|
||||
void XrefsDialog::fillRefs(QList<QStringList> refs, QList<QStringList> xrefs)
|
||||
{
|
||||
ui->fromTreeWidget->clear();
|
||||
for (int i = 0; i < refs.size(); ++i) {
|
||||
for (int i = 0; i < refs.size(); ++i)
|
||||
{
|
||||
//this->add_debug_output(refs.at(i).at(0) + " " + refs.at(i).at(1));
|
||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, refs.at(i).at(0));
|
||||
@ -40,12 +42,14 @@ void XrefsDialog::fillRefs(QList<QStringList> refs, QList<QStringList> xrefs) {
|
||||
}
|
||||
// Adjust columns to content
|
||||
int count = ui->fromTreeWidget->columnCount();
|
||||
for (int i = 0; i != count; ++i) {
|
||||
for (int i = 0; i != count; ++i)
|
||||
{
|
||||
ui->fromTreeWidget->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
ui->toTreeWidget->clear();
|
||||
for (int i = 0; i < xrefs.size(); ++i) {
|
||||
for (int i = 0; i < xrefs.size(); ++i)
|
||||
{
|
||||
//this->add_debug_output(xrefs.at(i).at(0) + " " + xrefs.at(i).at(1));
|
||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, xrefs.at(i).at(0));
|
||||
@ -56,7 +60,8 @@ void XrefsDialog::fillRefs(QList<QStringList> refs, QList<QStringList> xrefs) {
|
||||
}
|
||||
// Adjust columns to content
|
||||
int count2 = ui->toTreeWidget->columnCount();
|
||||
for (int i = 0; i != count2; ++i) {
|
||||
for (int i = 0; i != count2; ++i)
|
||||
{
|
||||
ui->toTreeWidget->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
@ -84,24 +89,30 @@ void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int c
|
||||
this->close();
|
||||
}
|
||||
|
||||
QString XrefsDialog::normalizeAddr(QString addr) {
|
||||
QString XrefsDialog::normalizeAddr(QString addr)
|
||||
{
|
||||
QString base = addr.split("0x")[1].trimmed();
|
||||
int len = base.length();
|
||||
if (len < 8) {
|
||||
if (len < 8)
|
||||
{
|
||||
int padding = 8 - len;
|
||||
QString zero = "0";
|
||||
QString zeroes = zero.repeated(padding);
|
||||
QString s = "0x" + zeroes + base;
|
||||
return s;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
void XrefsDialog::highlightCurrentLine() {
|
||||
void XrefsDialog::highlightCurrentLine()
|
||||
{
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
|
||||
if (ui->previewTextEdit->isReadOnly()) {
|
||||
if (ui->previewTextEdit->isReadOnly())
|
||||
{
|
||||
QTextEdit::ExtraSelection selection;
|
||||
|
||||
QColor lineColor = QColor(190, 144, 212);
|
||||
@ -120,10 +131,10 @@ void XrefsDialog::on_fromTreeWidget_itemSelectionChanged()
|
||||
{
|
||||
QTreeWidgetItem *item = ui->fromTreeWidget->currentItem();
|
||||
QString offset = item->text(0);
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd("pdf @ " + offset).trimmed() );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("pdf @ " + offset).trimmed());
|
||||
ui->previewTextEdit->moveCursor(QTextCursor::End);
|
||||
// Does it make any sense?
|
||||
ui->previewTextEdit->find( this->normalizeAddr(offset), QTextDocument::FindBackward);
|
||||
ui->previewTextEdit->find(this->normalizeAddr(offset), QTextDocument::FindBackward);
|
||||
ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
|
||||
}
|
||||
|
||||
@ -131,15 +142,16 @@ void XrefsDialog::on_toTreeWidget_itemSelectionChanged()
|
||||
{
|
||||
QTreeWidgetItem *item = ui->toTreeWidget->currentItem();
|
||||
QString offset = item->text(0);
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd("pdf @ " + offset).trimmed() );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("pdf @ " + offset).trimmed());
|
||||
ui->previewTextEdit->moveCursor(QTextCursor::End);
|
||||
// Again, does it make any sense?
|
||||
// Also, this code should be refactored and shared instead of copied & pasted
|
||||
ui->previewTextEdit->find( this->normalizeAddr(offset), QTextDocument::FindBackward);
|
||||
ui->previewTextEdit->find(this->normalizeAddr(offset), QTextDocument::FindBackward);
|
||||
ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
|
||||
}
|
||||
|
||||
void XrefsDialog::updateLabels(QString name) {
|
||||
void XrefsDialog::updateLabels(QString name)
|
||||
{
|
||||
ui->label_2->setText(ui->label_2->text() + name);
|
||||
ui->label_3->setText(ui->label_3->text() + name);
|
||||
}
|
||||
|
@ -8,8 +8,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class XrefsDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class XrefsDialog;
|
||||
}
|
||||
|
||||
class XrefsDialog : public QDialog
|
||||
|
@ -6,22 +6,24 @@
|
||||
namespace qhelpers
|
||||
{
|
||||
|
||||
// TODO: wouldn't it be enough to setFont on the QWidget?
|
||||
// TODO: wouldn't it be enough to setFont on the QWidget?
|
||||
|
||||
void normalizeFont(QPlainTextEdit *edit) {
|
||||
#ifdef Q_OS_LINUX
|
||||
void normalizeFont(QPlainTextEdit *edit)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
QFont anonFont("Inconsolata", 12);
|
||||
QTextDocument *out_doc = edit->document();
|
||||
out_doc->setDefaultFont(anonFont);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void normalizeEditFont(QTextEdit *edit) {
|
||||
#ifdef Q_OS_LINUX
|
||||
void normalizeEditFont(QTextEdit *edit)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
QFont anonFont("Inconsolata", 12);
|
||||
QTextDocument *out_doc = edit->document();
|
||||
out_doc->setDefaultFont(anonFont);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
@ -18,10 +18,12 @@ AsciiHighlighter::AsciiHighlighter(QTextDocument *parent)
|
||||
|
||||
void AsciiHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
foreach (const HighlightingRule &rule, highlightingRules)
|
||||
{
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
while (index >= 0)
|
||||
{
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
@ -33,13 +35,17 @@ void AsciiHighlighter::highlightBlock(const QString &text)
|
||||
if (previousBlockState() != 1)
|
||||
startIndex = commentStartExpression.indexIn(text);
|
||||
|
||||
while (startIndex >= 0) {
|
||||
while (startIndex >= 0)
|
||||
{
|
||||
int endIndex = commentEndExpression.indexIn(text, startIndex);
|
||||
int commentLength;
|
||||
if (endIndex == -1) {
|
||||
if (endIndex == -1)
|
||||
{
|
||||
setCurrentBlockState(1);
|
||||
commentLength = text.length() - startIndex;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
commentLength = endIndex - startIndex
|
||||
+ commentEndExpression.matchedLength();
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ HexHighlighter::HexHighlighter(QTextDocument *parent)
|
||||
<< "\\b6e\\b" << "\\b6f\\b" << "\\b70\\b" << "\\b71\\b" << "\\b72\\b" << "\\b73\\b" << "\\b74\\b"
|
||||
<< "\\b75\\b" << "\\b76\\b" << "\\b77\\b" << "\\b78\\b" << "\\b79\\b" << "\\b7a\\b" << "\\b7b\\b"
|
||||
<< "\\b7c\\b" << "\\b7d\\b" << "\\b7e\\b" << "\\b7f\\b";
|
||||
foreach (const QString &pattern, keywordPatterns) {
|
||||
foreach (const QString &pattern, keywordPatterns)
|
||||
{
|
||||
rule.pattern = QRegExp(pattern);
|
||||
rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
rule.format = keywordFormat;
|
||||
@ -44,10 +45,12 @@ HexHighlighter::HexHighlighter(QTextDocument *parent)
|
||||
|
||||
void HexHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
foreach (const HighlightingRule &rule, highlightingRules)
|
||||
{
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
while (index >= 0)
|
||||
{
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
@ -59,13 +62,17 @@ void HexHighlighter::highlightBlock(const QString &text)
|
||||
if (previousBlockState() != 1)
|
||||
startIndex = commentStartExpression.indexIn(text);
|
||||
|
||||
while (startIndex >= 0) {
|
||||
while (startIndex >= 0)
|
||||
{
|
||||
int endIndex = commentEndExpression.indexIn(text, startIndex);
|
||||
int commentLength;
|
||||
if (endIndex == -1) {
|
||||
if (endIndex == -1)
|
||||
{
|
||||
setCurrentBlockState(1);
|
||||
commentLength = text.length() - startIndex;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
commentLength = endIndex - startIndex
|
||||
+ commentEndExpression.matchedLength();
|
||||
}
|
||||
|
@ -14,17 +14,19 @@ Highlighter::Highlighter(MainWindow *main, QTextDocument *parent) :
|
||||
keywordFormat.setForeground(QColor(65, 131, 215));
|
||||
keywordFormat.setFontWeight(QFont::Bold);
|
||||
|
||||
foreach (const QString &pattern, this->main->core->opcodes) {
|
||||
foreach (const QString &pattern, this->main->core->opcodes)
|
||||
{
|
||||
rule.pattern = QRegExp("\\b" + pattern + "\\b");
|
||||
rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
rule.format = keywordFormat;
|
||||
highlightingRules.append(rule);
|
||||
}
|
||||
|
||||
regFormat.setForeground(QColor(236,100,75));
|
||||
regFormat.setForeground(QColor(236, 100, 75));
|
||||
regFormat.setFontWeight(QFont::Bold);
|
||||
|
||||
foreach (const QString &pattern, this->main->core->regs) {
|
||||
foreach (const QString &pattern, this->main->core->regs)
|
||||
{
|
||||
rule.pattern = QRegExp("\\b" + pattern + "\\b");
|
||||
rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
rule.format = regFormat;
|
||||
@ -44,10 +46,12 @@ Highlighter::Highlighter(MainWindow *main, QTextDocument *parent) :
|
||||
|
||||
void Highlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
foreach (const HighlightingRule &rule, highlightingRules)
|
||||
{
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
while (index >= 0)
|
||||
{
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
@ -59,13 +63,17 @@ void Highlighter::highlightBlock(const QString &text)
|
||||
if (previousBlockState() != 1)
|
||||
startIndex = commentStartExpression.indexIn(text);
|
||||
|
||||
while (startIndex >= 0) {
|
||||
while (startIndex >= 0)
|
||||
{
|
||||
int endIndex = commentEndExpression.indexIn(text, startIndex);
|
||||
int commentLength;
|
||||
if (endIndex == -1) {
|
||||
if (endIndex == -1)
|
||||
{
|
||||
setCurrentBlockState(1);
|
||||
commentLength = text.length() - startIndex;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
commentLength = endIndex - startIndex
|
||||
+ commentEndExpression.matchedLength();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char *argv[])
|
||||
// Check r2 version
|
||||
QString r2version = r_core_version();
|
||||
QString localVersion = "" R2_GITTAP;
|
||||
if(r2version != localVersion)
|
||||
if (r2version != localVersion)
|
||||
{
|
||||
QMessageBox msg;
|
||||
msg.setIcon(QMessageBox::Critical);
|
||||
@ -43,11 +43,11 @@ int main(int argc, char *argv[])
|
||||
msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msg.setWindowTitle("Version mismatch!");
|
||||
msg.setText(QString("The version used to compile iaito (%1) does not match the binary version of radare2 (%2). This could result in unexpected behaviour. Are you sure you want to continue?").arg(localVersion, r2version));
|
||||
if(msg.exec() == QMessageBox::No)
|
||||
if (msg.exec() == QMessageBox::No)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(args.empty())
|
||||
if (args.empty())
|
||||
{
|
||||
NewFileDialog *n = new NewFileDialog();
|
||||
n->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -81,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
||||
console_docu->setDocumentMargin(10);
|
||||
|
||||
// Sepparator between back/forward and undo/redo buttons
|
||||
QWidget* spacer4 = new QWidget();
|
||||
QWidget *spacer4 = new QWidget();
|
||||
spacer4->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
spacer4->setMinimumSize(10, 10);
|
||||
ui->mainToolBar->insertWidget(ui->actionForward, spacer4);
|
||||
@ -94,7 +94,7 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
||||
connect(backButton, SIGNAL(clicked()), this, SLOT(on_backButton_clicked()));
|
||||
|
||||
// Sepparator between undo/redo and goto lineEdit
|
||||
QWidget* spacer3 = new QWidget();
|
||||
QWidget *spacer3 = new QWidget();
|
||||
spacer3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
spacer3->setMinimumSize(20, 20);
|
||||
spacer3->setMaximumWidth(300);
|
||||
@ -105,14 +105,14 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
||||
ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, this->omnibar);
|
||||
|
||||
// Add special sepparators to the toolbar that expand to separate groups of elements
|
||||
QWidget* spacer2 = new QWidget();
|
||||
QWidget *spacer2 = new QWidget();
|
||||
spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
spacer2->setMinimumSize(10, 10);
|
||||
spacer2->setMaximumWidth(300);
|
||||
ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, spacer2);
|
||||
|
||||
// Sepparator between back/forward and undo/redo buttons
|
||||
QWidget* spacer = new QWidget();
|
||||
QWidget *spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
spacer->setMinimumSize(20, 20);
|
||||
ui->mainToolBar->addWidget(spacer);
|
||||
@ -143,7 +143,7 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
||||
this->sectionsDock->setObjectName("sectionsDock");
|
||||
this->sectionsDock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||
this->sectionsDock->setWidget(this->sectionsWidget);
|
||||
this->sectionsWidget->setContentsMargins(0,0,0,5);
|
||||
this->sectionsWidget->setContentsMargins(0, 0, 0, 5);
|
||||
this->sectionsDock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
this->sectionsDock->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this->sectionsDock, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
@ -185,9 +185,9 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
||||
this->readSettings();
|
||||
// TODO: Allow the user to select this option visually in the GUI settings
|
||||
// Adjust the DockWidget areas
|
||||
setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
|
||||
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
||||
//setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
|
||||
setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
|
||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
//setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
||||
|
||||
this->flagsDock->flagsTreeWidget->clear();
|
||||
@ -216,28 +216,30 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
||||
* Some global shortcuts
|
||||
*/
|
||||
// Period goes to command entry
|
||||
QShortcut* cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
|
||||
QShortcut *cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
|
||||
connect(cmd_shortcut, SIGNAL(activated()), ui->consoleInputLineEdit, SLOT(setFocus()));
|
||||
|
||||
// G and S goes to goto entry
|
||||
QShortcut* goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this);
|
||||
QShortcut *goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this);
|
||||
connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
||||
QShortcut* seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
|
||||
QShortcut *seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
|
||||
connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
||||
|
||||
// : goes to goto entry
|
||||
QShortcut* commands_shortcut = new QShortcut(QKeySequence(Qt::Key_Colon), this);
|
||||
QShortcut *commands_shortcut = new QShortcut(QKeySequence(Qt::Key_Colon), this);
|
||||
connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands()));
|
||||
|
||||
connect(&webserverThread, SIGNAL(finished()), this, SLOT(webserverThreadFinished()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
delete core;
|
||||
}
|
||||
|
||||
void MainWindow::start_web_server() {
|
||||
void MainWindow::start_web_server()
|
||||
{
|
||||
// Start web server
|
||||
webserverThread.startServer();
|
||||
}
|
||||
@ -252,45 +254,52 @@ void MainWindow::webserverThreadFinished()
|
||||
//}
|
||||
}
|
||||
|
||||
void MainWindow::adjustColumns(QTreeWidget *tw) {
|
||||
void MainWindow::adjustColumns(QTreeWidget *tw)
|
||||
{
|
||||
int count = tw->columnCount();
|
||||
for (int i = 0; i != count; ++i) {
|
||||
for (int i = 0; i != count; ++i)
|
||||
{
|
||||
tw->resizeColumnToContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::appendRow(QTreeWidget *tw, const QString &str, const QString &str2,
|
||||
const QString &str3, const QString &str4, const QString &str5) {
|
||||
const QString &str3, const QString &str4, const QString &str5)
|
||||
{
|
||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||
// Fill dummy hidden column
|
||||
tempItem->setText(0,"0");
|
||||
tempItem->setText(1,str);
|
||||
if (str2!=NULL)
|
||||
tempItem->setText(0, "0");
|
||||
tempItem->setText(1, str);
|
||||
if (str2 != NULL)
|
||||
tempItem->setText(2, str2);
|
||||
if (str3!=NULL)
|
||||
if (str3 != NULL)
|
||||
tempItem->setText(3, str3);
|
||||
if (str4!=NULL)
|
||||
if (str4 != NULL)
|
||||
tempItem->setText(4, str4);
|
||||
if (str5!=NULL)
|
||||
if (str5 != NULL)
|
||||
tempItem->setText(5, str5);
|
||||
tw->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
|
||||
void MainWindow::setWebServerState(bool start)
|
||||
{
|
||||
if (start) {
|
||||
if (start)
|
||||
{
|
||||
webserverThread.startServer();
|
||||
|
||||
// Open web interface on default browser
|
||||
// ballessay: well isn't this possible with =H&
|
||||
//QString link = "http://localhost:9090/";
|
||||
//QDesktopServices::openUrl(QUrl(link));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
webserverThread.stopServer();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::hideDummyColumns() {
|
||||
void MainWindow::hideDummyColumns()
|
||||
{
|
||||
// UGLY, should be a loop over all treewidgets...
|
||||
this->functionsDock->functionsTreeWidget->setColumnHidden(0, true);
|
||||
this->importsDock->importsTreeWidget->setColumnHidden(0, true);
|
||||
@ -301,7 +310,8 @@ void MainWindow::hideDummyColumns() {
|
||||
this->commentsDock->commentsTreeWidget->setColumnHidden(0, true);
|
||||
}
|
||||
|
||||
void MainWindow::setFilename(QString fn) {
|
||||
void MainWindow::setFilename(QString fn)
|
||||
{
|
||||
|
||||
// Add file name to window title
|
||||
this->filename = fn;
|
||||
@ -325,10 +335,11 @@ void MainWindow::showConsoleContextMenu(const QPoint &pt)
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito",
|
||||
"Do you really want to exit?\nSave your project before closing!",
|
||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
"Do you really want to exit?\nSave your project before closing!",
|
||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
//qDebug() << ret;
|
||||
if (ret == QMessageBox::Save) {
|
||||
if (ret == QMessageBox::Save)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.setValue("size", size());
|
||||
@ -339,13 +350,17 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
//this->add_debug_output(notes);
|
||||
this->core->cmd("Pnj " + notes);
|
||||
QMainWindow::closeEvent(event);
|
||||
} else if (ret == QMessageBox::Discard) {
|
||||
}
|
||||
else if (ret == QMessageBox::Discard)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.setValue("size", size());
|
||||
settings.setValue("pos", pos());
|
||||
settings.setValue("state", saveState());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
@ -357,20 +372,23 @@ void MainWindow::readSettings()
|
||||
restoreGeometry(geo);
|
||||
QByteArray state = settings.value("state", QByteArray()).toByteArray();
|
||||
restoreState(state);
|
||||
if (settings.value("dark").toBool()) {
|
||||
if (settings.value("dark").toBool())
|
||||
{
|
||||
this->dark();
|
||||
}
|
||||
this->responsive = settings.value("responsive").toBool();
|
||||
}
|
||||
|
||||
void MainWindow::dark() {
|
||||
void MainWindow::dark()
|
||||
{
|
||||
qApp->setStyleSheet("QPlainTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} QTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} ");
|
||||
this->memoryDock->switchTheme(true);
|
||||
QSettings settings;
|
||||
settings.setValue("dark", true);
|
||||
}
|
||||
|
||||
void MainWindow::def_theme() {
|
||||
void MainWindow::def_theme()
|
||||
{
|
||||
qApp->setStyleSheet("");
|
||||
this->memoryDock->switchTheme(false);
|
||||
QSettings settings;
|
||||
@ -381,28 +399,33 @@ void MainWindow::def_theme() {
|
||||
* Refresh widget functions
|
||||
*/
|
||||
|
||||
void MainWindow::refreshFunctions() {
|
||||
void MainWindow::refreshFunctions()
|
||||
{
|
||||
this->functionsDock->refreshTree();
|
||||
}
|
||||
|
||||
void MainWindow::refreshComments() {
|
||||
void MainWindow::refreshComments()
|
||||
{
|
||||
this->commentsDock->refreshTree();
|
||||
}
|
||||
|
||||
void MainWindow::refreshFlagspaces() {
|
||||
void MainWindow::refreshFlagspaces()
|
||||
{
|
||||
int cur_idx = this->flagsDock->flagspaceCombo->currentIndex();
|
||||
if (cur_idx<0)cur_idx = 0;
|
||||
if (cur_idx < 0)cur_idx = 0;
|
||||
this->flagsDock->flagspaceCombo->clear();
|
||||
this->flagsDock->flagspaceCombo->addItem("(all)");
|
||||
for (auto i : core->getList("flagspaces")) {
|
||||
for (auto i : core->getList("flagspaces"))
|
||||
{
|
||||
this->flagsDock->flagspaceCombo->addItem(i);
|
||||
}
|
||||
if (cur_idx>0)
|
||||
if (cur_idx > 0)
|
||||
this->flagsDock->flagspaceCombo->setCurrentIndex(cur_idx);
|
||||
refreshFlags();
|
||||
}
|
||||
|
||||
void MainWindow::refreshFlags() {
|
||||
void MainWindow::refreshFlags()
|
||||
{
|
||||
QString flagspace = this->flagsDock->flagspaceCombo->currentText();
|
||||
this->omnibar->clearFlags();
|
||||
if (flagspace == "(all)")
|
||||
@ -410,13 +433,16 @@ void MainWindow::refreshFlags() {
|
||||
|
||||
this->flagsDock->flagsTreeWidget->clear();
|
||||
|
||||
for (auto i: core->getList("flags", flagspace)) {
|
||||
QStringList a = i.split (",");
|
||||
if (a.length()>3) {
|
||||
for (auto i : core->getList("flags", flagspace))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
if (a.length() > 3)
|
||||
{
|
||||
appendRow(this->flagsDock->flagsTreeWidget, a[1], a[2], a[0], a[3]);
|
||||
this->omnibar->fillFlags(a[0]);
|
||||
}
|
||||
else if (a.length()>2) {
|
||||
else if (a.length() > 2)
|
||||
{
|
||||
appendRow(this->flagsDock->flagsTreeWidget, a[1], a[2], a[0], "");
|
||||
this->omnibar->fillFlags(a[0]);
|
||||
}
|
||||
@ -426,18 +452,22 @@ void MainWindow::refreshFlags() {
|
||||
this->omnibar->setupCompleter();
|
||||
}
|
||||
|
||||
void MainWindow::updateFrames() {
|
||||
void MainWindow::updateFrames()
|
||||
{
|
||||
if (core == NULL)
|
||||
return;
|
||||
|
||||
static bool first_time = true;
|
||||
if (first_time) {
|
||||
if (first_time)
|
||||
{
|
||||
setup_mem();
|
||||
this->add_output(" > Adding binary information to notepad");
|
||||
notepadDock->setText("# Binary information\n\n" + core->cmd("i") +
|
||||
"\n" + core->cmd("ie") + "\n" + core->cmd("iM") + "\n");
|
||||
//first_time = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshMem("");
|
||||
}
|
||||
|
||||
@ -448,7 +478,8 @@ void MainWindow::updateFrames() {
|
||||
|
||||
// TODO: make this configurable by the user?
|
||||
const bool use_scrollperpixel = true;
|
||||
if (use_scrollperpixel) {
|
||||
if (use_scrollperpixel)
|
||||
{
|
||||
this->flagsDock->flagsTreeWidget->setVerticalScrollMode(spp);
|
||||
this->symbolsDock->symbolsTreeWidget->setVerticalScrollMode(spp);
|
||||
this->importsDock->importsTreeWidget->setVerticalScrollMode(spp);
|
||||
@ -457,7 +488,9 @@ void MainWindow::updateFrames() {
|
||||
this->relocsDock->relocsTreeWidget->setVerticalScrollMode(spp);
|
||||
this->memoryDock->xreFromTreeWidget_2->setVerticalScrollMode(spp);
|
||||
this->memoryDock->xrefToTreeWidget_2->setVerticalScrollMode(spp);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->flagsDock->flagsTreeWidget->setVerticalScrollMode(spi);
|
||||
this->symbolsDock->symbolsTreeWidget->setVerticalScrollMode(spi);
|
||||
this->importsDock->importsTreeWidget->setVerticalScrollMode(spi);
|
||||
@ -485,9 +518,10 @@ void MainWindow::updateFrames() {
|
||||
adjustColumns(this->importsDock->importsTreeWidget);
|
||||
|
||||
this->relocsDock->relocsTreeWidget->clear();
|
||||
for (auto i: core->getList ("bin","relocs")) {
|
||||
QStringList pieces = i.split (",");
|
||||
if (pieces.length()==3)
|
||||
for (auto i : core->getList("bin", "relocs"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 3)
|
||||
appendRow(this->relocsDock->relocsTreeWidget, pieces[0], pieces[1], pieces[2]);
|
||||
}
|
||||
adjustColumns(this->relocsDock->relocsTreeWidget);
|
||||
@ -495,16 +529,18 @@ void MainWindow::updateFrames() {
|
||||
this->symbolsDock->fillSymbols();
|
||||
|
||||
this->stringsDock->stringsTreeWidget->clear();
|
||||
for (auto i : core->getList ("bin", "strings")) {
|
||||
QStringList pieces = i.split (",");
|
||||
if (pieces.length () == 2)
|
||||
for (auto i : core->getList("bin", "strings"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 2)
|
||||
appendRow(this->stringsDock->stringsTreeWidget, pieces[0], pieces[1]);
|
||||
}
|
||||
adjustColumns(this->stringsDock->stringsTreeWidget);
|
||||
|
||||
this->commentsDock->commentsTreeWidget->clear();
|
||||
QList<QList<QString>> comments = this->core->getComments();
|
||||
for (QList<QString> comment: comments) {
|
||||
for (QList<QString> comment : comments)
|
||||
{
|
||||
/*
|
||||
QString name;
|
||||
//this->add_debug_output("Comment: " + comment[1] + ": " + comment[0]);
|
||||
@ -522,11 +558,13 @@ void MainWindow::updateFrames() {
|
||||
|
||||
// Add nested comments
|
||||
QMap<QString, QList<QList<QString>>> cmts = this->core->getNestedComments();
|
||||
for(auto cmt : cmts.keys()) {
|
||||
for (auto cmt : cmts.keys())
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(this->commentsDock->nestedCommentsTreeWidget);
|
||||
item->setText(0, cmt);
|
||||
QList<QList<QString>> meow = cmts.value(cmt);
|
||||
for (int i = 0; i < meow.size(); ++i) {
|
||||
for (int i = 0; i < meow.size(); ++i)
|
||||
{
|
||||
QList<QString> tmp = meow.at(i);
|
||||
QTreeWidgetItem *it = new QTreeWidgetItem();
|
||||
it->setText(0, tmp[1]);
|
||||
@ -538,25 +576,32 @@ void MainWindow::updateFrames() {
|
||||
adjustColumns(this->commentsDock->nestedCommentsTreeWidget);
|
||||
|
||||
// TODO: FIXME: Remove the check for first_time;
|
||||
if (first_time) {
|
||||
if (first_time)
|
||||
{
|
||||
sectionsWidget->tree->clear();
|
||||
int row = 0;
|
||||
for (auto i: core->getList("bin","sections")) {
|
||||
QStringList a = i.split (",");
|
||||
if (a.length()>2) {
|
||||
for (auto i : core->getList("bin", "sections"))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
if (a.length() > 2)
|
||||
{
|
||||
// Fix to work with ARM bins
|
||||
//if (a[4].startsWith(".")) {
|
||||
if (a[4].contains(".")) {
|
||||
if (a[4].contains("."))
|
||||
{
|
||||
QString addr = a[1];
|
||||
QString addr_end = "0x0"+core->itoa(core->math(a[1]+"+"+a[2]));
|
||||
QString addr_end = "0x0" + core->itoa(core->math(a[1] + "+" + a[2]));
|
||||
QString size = QString::number(core->math(a[2]));
|
||||
QString name = a[4];
|
||||
this->sectionsWidget->fillSections(row, name, size, addr, addr_end);
|
||||
|
||||
// Used to select a color for the sections graph
|
||||
if (row == 10) {
|
||||
if (row == 10)
|
||||
{
|
||||
row = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
row++;
|
||||
}
|
||||
}
|
||||
@ -578,25 +623,35 @@ void MainWindow::updateFrames() {
|
||||
void MainWindow::on_actionLock_triggered()
|
||||
{
|
||||
doLock = !doLock;
|
||||
if (doLock) {
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>()) {
|
||||
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
} else {
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>()) {
|
||||
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
if (doLock)
|
||||
{
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
||||
{
|
||||
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
||||
{
|
||||
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::lockUnlock_Docks(bool what)
|
||||
{
|
||||
if(what) {
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>()) {
|
||||
if (what)
|
||||
{
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
||||
{
|
||||
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
} else {
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>()) {
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
||||
{
|
||||
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
}
|
||||
}
|
||||
@ -605,27 +660,34 @@ void MainWindow::lockUnlock_Docks(bool what)
|
||||
|
||||
void MainWindow::on_actionLockUnlock_triggered()
|
||||
{
|
||||
if(ui->actionLockUnlock->isChecked())
|
||||
if (ui->actionLockUnlock->isChecked())
|
||||
{
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>()) {
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
||||
{
|
||||
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
ui->actionLockUnlock->setIcon( QIcon(":/new/prefix1/lock") );
|
||||
} else {
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>()) {
|
||||
ui->actionLockUnlock->setIcon(QIcon(":/new/prefix1/lock"));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
||||
{
|
||||
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
}
|
||||
ui->actionLockUnlock->setIcon( QIcon(":/new/prefix1/unlock") );
|
||||
ui->actionLockUnlock->setIcon(QIcon(":/new/prefix1/unlock"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionTabs_triggered()
|
||||
{
|
||||
if (ui->centralTabWidget->tabPosition() == QTabWidget::South) {
|
||||
if (ui->centralTabWidget->tabPosition() == QTabWidget::South)
|
||||
{
|
||||
ui->centralTabWidget->setTabPosition(QTabWidget::North);
|
||||
this->memoryDock->memTabWidget->setTabPosition(QTabWidget::North);
|
||||
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->centralTabWidget->setTabPosition(QTabWidget::South);
|
||||
this->memoryDock->memTabWidget->setTabPosition(QTabWidget::South);
|
||||
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South);
|
||||
@ -636,7 +698,7 @@ void MainWindow::on_actionMem_triggered()
|
||||
{
|
||||
//this->memoryDock->show();
|
||||
//this->memoryDock->raise();
|
||||
MemoryWidget* newMemDock = new MemoryWidget(this);
|
||||
MemoryWidget *newMemDock = new MemoryWidget(this);
|
||||
this->dockList << newMemDock;
|
||||
newMemDock->setAttribute(Qt::WA_DeleteOnClose);
|
||||
this->tabifyDockWidget(this->memoryDock, newMemDock);
|
||||
@ -646,9 +708,12 @@ void MainWindow::on_actionMem_triggered()
|
||||
|
||||
void MainWindow::on_actionFunctions_triggered()
|
||||
{
|
||||
if (this->functionsDock->isVisible()) {
|
||||
if (this->functionsDock->isVisible())
|
||||
{
|
||||
this->functionsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->functionsDock->show();
|
||||
this->functionsDock->raise();
|
||||
}
|
||||
@ -656,9 +721,12 @@ void MainWindow::on_actionFunctions_triggered()
|
||||
|
||||
void MainWindow::on_actionImports_triggered()
|
||||
{
|
||||
if (this->importsDock->isVisible()) {
|
||||
if (this->importsDock->isVisible())
|
||||
{
|
||||
this->importsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->importsDock->show();
|
||||
this->importsDock->raise();
|
||||
}
|
||||
@ -666,9 +734,12 @@ void MainWindow::on_actionImports_triggered()
|
||||
|
||||
void MainWindow::on_actionSymbols_triggered()
|
||||
{
|
||||
if (this->symbolsDock->isVisible()) {
|
||||
if (this->symbolsDock->isVisible())
|
||||
{
|
||||
this->symbolsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->symbolsDock->show();
|
||||
this->symbolsDock->raise();
|
||||
}
|
||||
@ -676,9 +747,12 @@ void MainWindow::on_actionSymbols_triggered()
|
||||
|
||||
void MainWindow::on_actionReloc_triggered()
|
||||
{
|
||||
if (this->relocsDock->isVisible()) {
|
||||
if (this->relocsDock->isVisible())
|
||||
{
|
||||
this->relocsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->relocsDock->show();
|
||||
this->relocsDock->raise();
|
||||
}
|
||||
@ -686,9 +760,12 @@ void MainWindow::on_actionReloc_triggered()
|
||||
|
||||
void MainWindow::on_actionStrings_triggered()
|
||||
{
|
||||
if (this->stringsDock->isVisible()) {
|
||||
if (this->stringsDock->isVisible())
|
||||
{
|
||||
this->stringsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->stringsDock->show();
|
||||
this->stringsDock->raise();
|
||||
}
|
||||
@ -696,9 +773,12 @@ void MainWindow::on_actionStrings_triggered()
|
||||
|
||||
void MainWindow::on_actionSections_triggered()
|
||||
{
|
||||
if (this->sectionsDock->isVisible()) {
|
||||
if (this->sectionsDock->isVisible())
|
||||
{
|
||||
this->sectionsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sectionsDock->show();
|
||||
this->sectionsDock->raise();
|
||||
}
|
||||
@ -706,9 +786,12 @@ void MainWindow::on_actionSections_triggered()
|
||||
|
||||
void MainWindow::on_actionFlags_triggered()
|
||||
{
|
||||
if (this->flagsDock->isVisible()) {
|
||||
if (this->flagsDock->isVisible())
|
||||
{
|
||||
this->flagsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->flagsDock->show();
|
||||
this->flagsDock->raise();
|
||||
}
|
||||
@ -716,9 +799,12 @@ void MainWindow::on_actionFlags_triggered()
|
||||
|
||||
void MainWindow::on_actionComents_triggered()
|
||||
{
|
||||
if (this->commentsDock->isVisible()) {
|
||||
if (this->commentsDock->isVisible())
|
||||
{
|
||||
this->commentsDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->commentsDock->show();
|
||||
this->commentsDock->raise();
|
||||
}
|
||||
@ -726,9 +812,12 @@ void MainWindow::on_actionComents_triggered()
|
||||
|
||||
void MainWindow::on_actionNotepad_triggered()
|
||||
{
|
||||
if (this->notepadDock->isVisible()) {
|
||||
if (this->notepadDock->isVisible())
|
||||
{
|
||||
this->notepadDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->notepadDock->show();
|
||||
this->notepadDock->raise();
|
||||
}
|
||||
@ -736,22 +825,24 @@ void MainWindow::on_actionNotepad_triggered()
|
||||
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
{
|
||||
AboutDialog* a = new AboutDialog(this);
|
||||
AboutDialog *a = new AboutDialog(this);
|
||||
a->open();
|
||||
}
|
||||
|
||||
void MainWindow::on_consoleInputLineEdit_returnPressed()
|
||||
{
|
||||
if (this->core) {
|
||||
if (this->core)
|
||||
{
|
||||
QString input = ui->consoleInputLineEdit->text();
|
||||
ui->consoleOutputTextEdit->appendPlainText(this->core->cmd(input));
|
||||
ui->consoleOutputTextEdit->verticalScrollBar()->setValue(ui->consoleOutputTextEdit->verticalScrollBar()->maximum());
|
||||
// Add new command to history
|
||||
QCompleter *completer = ui->consoleInputLineEdit->completer();
|
||||
if ( completer != NULL ) {
|
||||
QStringListModel *completerModel = (QStringListModel*)(completer->model());
|
||||
if ( completerModel != NULL )
|
||||
completerModel->setStringList(completerModel->stringList() << input);
|
||||
if (completer != NULL)
|
||||
{
|
||||
QStringListModel *completerModel = (QStringListModel *)(completer->model());
|
||||
if (completerModel != NULL)
|
||||
completerModel->setStringList(completerModel->stringList() << input);
|
||||
}
|
||||
|
||||
ui->consoleInputLineEdit->setText("");
|
||||
@ -762,13 +853,16 @@ void MainWindow::on_showHistoToolButton_clicked()
|
||||
{
|
||||
QCompleter *completer = ui->consoleInputLineEdit->completer();
|
||||
if (completer == NULL)
|
||||
return;
|
||||
return;
|
||||
|
||||
if (ui->showHistoToolButton->isChecked()) {
|
||||
if (ui->showHistoToolButton->isChecked())
|
||||
{
|
||||
completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
|
||||
// Uhm... shouldn't it be called always?
|
||||
completer->complete();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
completer->setCompletionMode(QCompleter::PopupCompletion);
|
||||
}
|
||||
}
|
||||
@ -783,20 +877,22 @@ void MainWindow::on_actionRefresh_Panels_triggered()
|
||||
this->updateFrames();
|
||||
}
|
||||
|
||||
void MainWindow::seek(const QString& offset, const QString& name) {
|
||||
if (offset.length()==0)
|
||||
void MainWindow::seek(const QString &offset, const QString &name)
|
||||
{
|
||||
if (offset.length() == 0)
|
||||
return;
|
||||
if (name != NULL)
|
||||
this->memoryDock->setWindowTitle(name);
|
||||
this->hexdumpTopOffset = 0;
|
||||
this->hexdumpBottomOffset = 0;
|
||||
core->seek (offset);
|
||||
core->seek(offset);
|
||||
|
||||
refreshMem(offset);
|
||||
this->memoryDock->disasTextEdit->setFocus();
|
||||
}
|
||||
|
||||
void MainWindow::setup_mem() {
|
||||
void MainWindow::setup_mem()
|
||||
{
|
||||
QString off = this->core->cmd("afo entry0").trimmed();
|
||||
//graphicsBar->refreshColorBar();
|
||||
graphicsBar->fillData();
|
||||
@ -807,7 +903,8 @@ void MainWindow::setup_mem() {
|
||||
this->memoryDock->setFcnName(off);
|
||||
}
|
||||
|
||||
void MainWindow::refreshMem(QString off) {
|
||||
void MainWindow::refreshMem(QString off)
|
||||
{
|
||||
//add_debug_output("Refreshing to: " + off);
|
||||
//graphicsBar->refreshColorBar();
|
||||
this->memoryDock->refreshDisasm(off);
|
||||
@ -821,7 +918,8 @@ void MainWindow::on_backButton_clicked()
|
||||
{
|
||||
this->core->cmd("s-");
|
||||
QString back_offset = this->core->cmd("s=").split(" > ").last().trimmed();
|
||||
if (back_offset != "") {
|
||||
if (back_offset != "")
|
||||
{
|
||||
QString fcn = this->core->cmdFunctionAt(back_offset);
|
||||
this->seek(this->memoryDock->normalizeAddr(back_offset), fcn);
|
||||
}
|
||||
@ -829,20 +927,22 @@ void MainWindow::on_backButton_clicked()
|
||||
|
||||
void MainWindow::on_actionCalculator_triggered()
|
||||
{
|
||||
if (!this->sideBar->isVisible()) {
|
||||
if (!this->sideBar->isVisible())
|
||||
{
|
||||
this->on_actionShow_Hide_mainsidebar_triggered();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCreate_File_triggered()
|
||||
{
|
||||
createNewDialog* n = new createNewDialog(this);
|
||||
createNewDialog *n = new createNewDialog(this);
|
||||
n->exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAssembler_triggered()
|
||||
{
|
||||
if (!this->sideBar->isVisible()) {
|
||||
if (!this->sideBar->isVisible())
|
||||
{
|
||||
this->on_actionShow_Hide_mainsidebar_triggered();
|
||||
}
|
||||
}
|
||||
@ -859,16 +959,19 @@ void MainWindow::on_actionStart_Web_Server_triggered()
|
||||
|
||||
void MainWindow::on_actionConsoleSync_with_core_triggered()
|
||||
{
|
||||
if (ui->actionConsoleSync_with_core->isChecked()) {
|
||||
if (ui->actionConsoleSync_with_core->isChecked())
|
||||
{
|
||||
//Enable core syncronization
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable core sync
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDisasAdd_comment_triggered()
|
||||
{
|
||||
CommentsDialog* c = new CommentsDialog(this);
|
||||
CommentsDialog *c = new CommentsDialog(this);
|
||||
c->exec();
|
||||
}
|
||||
|
||||
@ -928,9 +1031,12 @@ void MainWindow::showDefaultDocks()
|
||||
|
||||
void MainWindow::on_actionhide_bottomPannel_triggered()
|
||||
{
|
||||
if (ui->centralWidget->isVisible()) {
|
||||
if (ui->centralWidget->isVisible())
|
||||
{
|
||||
ui->centralWidget->hide();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->centralWidget->show();
|
||||
}
|
||||
}
|
||||
@ -942,13 +1048,13 @@ void MainWindow::send_to_notepad(QString txt)
|
||||
|
||||
void MainWindow::on_actionFunctionsRename_triggered()
|
||||
{
|
||||
RenameDialog* r = new RenameDialog(this);
|
||||
RenameDialog *r = new RenameDialog(this);
|
||||
// Get function based on click position
|
||||
//r->setFunctionName(fcn_name);
|
||||
r->open();
|
||||
}
|
||||
|
||||
void MainWindow::get_refs(const QString& offset)
|
||||
void MainWindow::get_refs(const QString &offset)
|
||||
{
|
||||
this->memoryDock->get_refs_data(offset);
|
||||
}
|
||||
@ -1022,18 +1128,24 @@ void MainWindow::on_actionLoad_triggered()
|
||||
|
||||
void MainWindow::on_actionShow_Hide_mainsidebar_triggered()
|
||||
{
|
||||
if (ui->sideToolBar->isVisible()) {
|
||||
if (ui->sideToolBar->isVisible())
|
||||
{
|
||||
ui->sideToolBar->hide();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->sideToolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDashboard_triggered()
|
||||
{
|
||||
if (this->dashboardDock->isVisible()) {
|
||||
if (this->dashboardDock->isVisible())
|
||||
{
|
||||
this->dashboardDock->close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->dashboardDock->show();
|
||||
this->dashboardDock->raise();
|
||||
}
|
||||
@ -1047,10 +1159,13 @@ void MainWindow::showSectionsContextMenu(const QPoint &pt)
|
||||
menu->addAction(ui->actionSectionsHorizontal);
|
||||
menu->addAction(ui->actionSectionsVertical);
|
||||
|
||||
if (this->sectionsWidget->orientation() == 1) {
|
||||
if (this->sectionsWidget->orientation() == 1)
|
||||
{
|
||||
ui->actionSectionsHorizontal->setChecked(true);
|
||||
ui->actionSectionsVertical->setChecked(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->actionSectionsVertical->setChecked(true);
|
||||
ui->actionSectionsHorizontal->setChecked(false);
|
||||
}
|
||||
@ -1074,13 +1189,15 @@ void MainWindow::on_actionForward_triggered()
|
||||
{
|
||||
this->core->cmd("s+");
|
||||
QString offset = this->core->cmd("s=").split(" > ").last().trimmed();
|
||||
if (offset != "") {
|
||||
if (offset != "")
|
||||
{
|
||||
this->add_debug_output(offset);
|
||||
this->seek(offset);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleResponsive(bool maybe) {
|
||||
void MainWindow::toggleResponsive(bool maybe)
|
||||
{
|
||||
this->responsive = maybe;
|
||||
// Save options in settings
|
||||
QSettings settings;
|
||||
@ -1095,9 +1212,10 @@ void MainWindow::on_actionTabs_on_Top_triggered()
|
||||
void MainWindow::on_actionReset_settings_triggered()
|
||||
{
|
||||
QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito",
|
||||
"Do you really want to clear all settings?",
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok) {
|
||||
"Do you really want to clear all settings?",
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok)
|
||||
{
|
||||
// Save options in settings
|
||||
QSettings settings;
|
||||
settings.clear();
|
||||
|
@ -35,8 +35,9 @@
|
||||
#include "newfiledialog.h"
|
||||
#include "helpers.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
|
||||
@ -64,18 +65,18 @@ public:
|
||||
void readSettings();
|
||||
void setFilename(QString fn);
|
||||
void setCore(QRCore *core);
|
||||
void seek(const QString& offset, const QString& name=NULL);
|
||||
void seek(const QString &offset, const QString &name = NULL);
|
||||
void updateFrames();
|
||||
void refreshFunctions();
|
||||
void refreshComments();
|
||||
void refreshFlags();
|
||||
void get_refs(const QString& offset);
|
||||
void get_refs(const QString &offset);
|
||||
void add_output(QString msg);
|
||||
void add_debug_output(QString msg);
|
||||
void send_to_notepad(QString txt);
|
||||
void adjustColumns(QTreeWidget *tw);
|
||||
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2=NULL,
|
||||
const QString &str3=NULL, const QString &str4=NULL, const QString &str5=NULL);
|
||||
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = NULL,
|
||||
const QString &str3 = NULL, const QString &str4 = NULL, const QString &str5 = NULL);
|
||||
|
||||
void setWebServerState(bool start);
|
||||
|
||||
@ -201,7 +202,7 @@ private:
|
||||
ut64 hexdumpTopOffset;
|
||||
ut64 hexdumpBottomOffset;
|
||||
QString filename;
|
||||
QList<QDockWidget*> dockList;
|
||||
QList<QDockWidget *> dockList;
|
||||
QLabel *logo;
|
||||
Ui::MainWindow *ui;
|
||||
Highlighter *highlighter;
|
||||
|
@ -15,7 +15,8 @@ MdHighlighter::MdHighlighter(QTextDocument *parent)
|
||||
<< "\\*([^\\\\]+)\\*" << "\\_([^\\\\]+)\\_"
|
||||
<< "\\_\\_([^\\\\]+)\\_\\_";
|
||||
|
||||
foreach (const QString &pattern, keywordPatterns) {
|
||||
foreach (const QString &pattern, keywordPatterns)
|
||||
{
|
||||
rule.pattern = QRegExp(pattern);
|
||||
rule.format = keywordFormat;
|
||||
highlightingRules.append(rule);
|
||||
@ -30,10 +31,12 @@ MdHighlighter::MdHighlighter(QTextDocument *parent)
|
||||
|
||||
void MdHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
foreach (const HighlightingRule &rule, highlightingRules)
|
||||
{
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
while (index >= 0)
|
||||
{
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
const int NewFileDialog::MaxRecentFiles;
|
||||
|
||||
static QColor getColorFor(QString str, int pos) {
|
||||
static QColor getColorFor(QString str, int pos)
|
||||
{
|
||||
QNOTUSED(str);
|
||||
|
||||
QList<QColor> Colors;
|
||||
@ -25,22 +26,23 @@ static QColor getColorFor(QString str, int pos) {
|
||||
|
||||
}
|
||||
|
||||
static QIcon getIconFor(QString str, int pos) {
|
||||
static QIcon getIconFor(QString str, int pos)
|
||||
{
|
||||
// Add to the icon list
|
||||
int w = 64;
|
||||
int h = 64;
|
||||
|
||||
QPixmap pixmap(w,h);
|
||||
QPixmap pixmap(w, h);
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter pixPaint(&pixmap);
|
||||
pixPaint.setPen(Qt::NoPen);
|
||||
pixPaint.setRenderHint(QPainter::Antialiasing);
|
||||
pixPaint.setBrush(QBrush(QBrush(getColorFor(str, pos))));
|
||||
pixPaint.drawEllipse(1,1,w-2,h-2);
|
||||
pixPaint.drawEllipse(1, 1, w - 2, h - 2);
|
||||
pixPaint.setPen(Qt::white);
|
||||
pixPaint.setFont(QFont("Verdana",24,1));
|
||||
pixPaint.drawText(0, 0, w, h-2, Qt::AlignCenter, QString(str).toUpper().mid(0,2));
|
||||
pixPaint.setFont(QFont("Verdana", 24, 1));
|
||||
pixPaint.drawText(0, 0, w, h - 2, Qt::AlignCenter, QString(str).toUpper().mid(0, 2));
|
||||
return QIcon(pixmap);
|
||||
}
|
||||
NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
@ -60,19 +62,20 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
|
||||
int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
|
||||
|
||||
for (int i = 0; i < numRecentFiles; ++i) {
|
||||
for (int i = 0; i < numRecentFiles; ++i)
|
||||
{
|
||||
// Get stored files
|
||||
//QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
|
||||
|
||||
// Remove all but the file name
|
||||
QString sep = QDir::separator();
|
||||
QStringList name_list = files[i].split( sep );
|
||||
QStringList name_list = files[i].split(sep);
|
||||
QString name = name_list.last();
|
||||
|
||||
// Get file info
|
||||
QFileInfo info(files[i]);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(getIconFor(name, i),files[i] + "\nCreated: " + info.created().toString() + "\nSize: " + QString::number(info.size()));
|
||||
QListWidgetItem *item = new QListWidgetItem(getIconFor(name, i), files[i] + "\nCreated: " + info.created().toString() + "\nSize: " + QString::number(info.size()));
|
||||
//":/new/prefix1/img/icons/target.png"), name );
|
||||
item->setData(Qt::UserRole, files[i]);
|
||||
ui->recentsList->addItem(item);
|
||||
@ -93,11 +96,14 @@ void NewFileDialog::on_loadFileButton_clicked()
|
||||
// Check that there is a file selected
|
||||
QString fname = ui->newFileEdit->text();
|
||||
QFileInfo checkfile(fname);
|
||||
if (!checkfile.exists() || !checkfile.isFile()) {
|
||||
if (!checkfile.exists() || !checkfile.isFile())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Select a new program or a previous one\nbefore continue");
|
||||
msgBox.exec();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add file to recent file list
|
||||
QSettings settings;
|
||||
QStringList files = settings.value("recentFileList").toStringList();
|
||||
@ -110,7 +116,7 @@ void NewFileDialog::on_loadFileButton_clicked()
|
||||
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
OptionsDialog* o = new OptionsDialog(fname);
|
||||
OptionsDialog *o = new OptionsDialog(fname);
|
||||
o->exec();
|
||||
}
|
||||
}
|
||||
@ -125,7 +131,8 @@ void NewFileDialog::on_newFileButton_clicked()
|
||||
QString fileName;
|
||||
fileName = dialog.getOpenFileName(this, "Select file");
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
ui->newFileEdit->setText(fileName);
|
||||
ui->loadFileButton->setFocus();
|
||||
}
|
||||
@ -133,7 +140,7 @@ void NewFileDialog::on_newFileButton_clicked()
|
||||
|
||||
void NewFileDialog::on_recentsList_itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
QVariant data = item->data( Qt::UserRole );
|
||||
QVariant data = item->data(Qt::UserRole);
|
||||
QString sitem = data.toString();
|
||||
ui->newFileEdit->setText(sitem);
|
||||
}
|
||||
@ -141,11 +148,11 @@ void NewFileDialog::on_recentsList_itemClicked(QListWidgetItem *item)
|
||||
void NewFileDialog::on_recentsList_itemDoubleClicked(QListWidgetItem *item)
|
||||
{
|
||||
// Get selected item to send to options dialog
|
||||
QVariant data = item->data( Qt::UserRole );
|
||||
QVariant data = item->data(Qt::UserRole);
|
||||
QString sitem = data.toString();
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
OptionsDialog* o = new OptionsDialog(sitem);
|
||||
OptionsDialog *o = new OptionsDialog(sitem);
|
||||
o->exec();
|
||||
}
|
||||
|
||||
@ -157,9 +164,9 @@ void NewFileDialog::on_cancelButton_clicked()
|
||||
void NewFileDialog::on_actionRemove_item_triggered()
|
||||
{
|
||||
// Remove selected item from recents list
|
||||
QListWidgetItem* item = ui->recentsList->currentItem();
|
||||
QListWidgetItem *item = ui->recentsList->currentItem();
|
||||
|
||||
QVariant data = item->data( Qt::UserRole );
|
||||
QVariant data = item->data(Qt::UserRole);
|
||||
QString sitem = data.toString();
|
||||
|
||||
QSettings settings;
|
||||
@ -167,7 +174,7 @@ void NewFileDialog::on_actionRemove_item_triggered()
|
||||
files.removeAll(sitem);
|
||||
settings.setValue("recentFileList", files);
|
||||
|
||||
ui->recentsList->takeItem( ui->recentsList->currentRow() );
|
||||
ui->recentsList->takeItem(ui->recentsList->currentRow());
|
||||
|
||||
ui->newFileEdit->clear();
|
||||
}
|
||||
@ -176,7 +183,7 @@ void NewFileDialog::on_createButton_clicked()
|
||||
{
|
||||
// Close dialog and open create new file dialog
|
||||
close();
|
||||
createNewDialog* n = new createNewDialog(this);
|
||||
createNewDialog *n = new createNewDialog(this);
|
||||
n->exec();
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,9 @@
|
||||
#include <QDialog>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
namespace Ui {
|
||||
class NewFileDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class NewFileDialog;
|
||||
}
|
||||
|
||||
class NewFileDialog : public QDialog
|
||||
|
@ -21,7 +21,8 @@ OptionsDialog::OptionsDialog(QString filename, QWidget *parent):
|
||||
|
||||
// Fill the plugins combo
|
||||
QStringList plugins;
|
||||
for (auto i: this->core->getList ("asm", "plugins")) {
|
||||
for (auto i : this->core->getList("asm", "plugins"))
|
||||
{
|
||||
this->asm_plugins.append(i);
|
||||
plugins.append(i);
|
||||
}
|
||||
@ -51,12 +52,13 @@ OptionsDialog::~OptionsDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OptionsDialog::setFilename(QString fn, QString shortfn) {
|
||||
void OptionsDialog::setFilename(QString fn, QString shortfn)
|
||||
{
|
||||
this->filename = fn;
|
||||
this->shortfn = shortfn;
|
||||
//qDebug() << QFileInfo(fn).fileName();
|
||||
ui->programLineEdit->setText(fn);
|
||||
this->core->tryFile (fn, 1);
|
||||
this->core->tryFile(fn, 1);
|
||||
}
|
||||
|
||||
void OptionsDialog::setFilename(QString fn)
|
||||
@ -94,7 +96,8 @@ void OptionsDialog::on_okButton_clicked()
|
||||
ut64 mapaddr = 0LL;
|
||||
int bits = 0;
|
||||
QString sel_bits = ui->bitsComboBox->currentText();
|
||||
if (sel_bits != "Auto") {
|
||||
if (sel_bits != "Auto")
|
||||
{
|
||||
bits = sel_bits.toInt();
|
||||
}
|
||||
|
||||
@ -102,51 +105,69 @@ void OptionsDialog::on_okButton_clicked()
|
||||
QSettings settings;
|
||||
|
||||
// Show asm bytes
|
||||
if (ui->bytesCheckBox->isChecked()) {
|
||||
if (ui->bytesCheckBox->isChecked())
|
||||
{
|
||||
this->w->core->config("asm.bytes", "true");
|
||||
this->w->core->config("asm.cmtcol", "100");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->config("asm.bytes", "false");
|
||||
this->w->core->config("asm.cmtcol", "70");
|
||||
}
|
||||
settings.setValue("bytes", ui->bytesCheckBox->isChecked());
|
||||
|
||||
// Show AT&T syntax
|
||||
if (ui->attCheckBox->isChecked()) {
|
||||
if (ui->attCheckBox->isChecked())
|
||||
{
|
||||
this->w->core->config("asm.syntax", "att");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->config("asm.syntax", "intel");
|
||||
}
|
||||
settings.setValue("syntax", ui->attCheckBox->isChecked());
|
||||
|
||||
// Show opcode description
|
||||
if (ui->descriptionCheckBox->isChecked()) {
|
||||
if (ui->descriptionCheckBox->isChecked())
|
||||
{
|
||||
this->w->core->config("asm.describe", "true");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->config("asm.describe", "false");
|
||||
}
|
||||
settings.setValue("describe", ui->descriptionCheckBox->isChecked());
|
||||
|
||||
// Show stack pointer
|
||||
if (ui->stackCheckBox->isChecked()) {
|
||||
if (ui->stackCheckBox->isChecked())
|
||||
{
|
||||
this->w->core->config("asm.stackptr", "true");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->config("asm.stackptr", "false");
|
||||
}
|
||||
settings.setValue("stackptr", ui->stackCheckBox->isChecked());
|
||||
|
||||
// Show uppercase dasm
|
||||
if (ui->ucaseCheckBox->isChecked()) {
|
||||
if (ui->ucaseCheckBox->isChecked())
|
||||
{
|
||||
this->w->core->config("asm.ucase", "true");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->config("asm.ucase", "false");
|
||||
}
|
||||
settings.setValue("ucase", ui->ucaseCheckBox->isChecked());
|
||||
|
||||
// Show spaces in dasm
|
||||
if (ui->spacyCheckBox->isChecked()) {
|
||||
if (ui->spacyCheckBox->isChecked())
|
||||
{
|
||||
this->w->core->config("asm.spacy", "true");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->config("asm.spacy", "false");
|
||||
}
|
||||
settings.setValue("spacy", ui->spacyCheckBox->isChecked());
|
||||
@ -154,14 +175,18 @@ void OptionsDialog::on_okButton_clicked()
|
||||
bool rw = false;
|
||||
bool load_bininfo = ui->binCheckBox->isChecked();
|
||||
|
||||
if (load_bininfo) {
|
||||
if (!va) {
|
||||
if (load_bininfo)
|
||||
{
|
||||
if (!va)
|
||||
{
|
||||
va = 2;
|
||||
loadaddr = UT64_MAX;
|
||||
r_config_set_i (this->core->core()->config, "bin.laddr", loadaddr);
|
||||
r_config_set_i(this->core->core()->config, "bin.laddr", loadaddr);
|
||||
mapaddr = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
va = false;
|
||||
loadaddr = mapaddr = 0;
|
||||
}
|
||||
@ -181,7 +206,8 @@ void OptionsDialog::on_okButton_clicked()
|
||||
// connect signal/slot
|
||||
|
||||
int level = 0;
|
||||
if (anal_level == true) {
|
||||
if (anal_level == true)
|
||||
{
|
||||
level = ui->analSlider->value();
|
||||
}
|
||||
|
||||
@ -201,21 +227,25 @@ void OptionsDialog::anal_finished()
|
||||
ui->statusLabel->setText("Loading interface");
|
||||
this->w->add_output(" > Analysis finished");
|
||||
QString initial_seek = ui->entry_initialSeek->text();
|
||||
if (initial_seek.length()>0) {
|
||||
if (initial_seek.length() > 0)
|
||||
{
|
||||
this->w->core->seek(initial_seek);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->w->core->seek("entry0");
|
||||
}
|
||||
this->w->add_output(" > Populating UI");
|
||||
this->w->updateFrames();
|
||||
this->w->setFilename(this->filename);
|
||||
this->w->get_refs( this->w->core->cmd("?v entry0") );
|
||||
this->w->get_refs(this->w->core->cmd("?v entry0"));
|
||||
this->w->memoryDock->selectHexPreview();
|
||||
|
||||
// Restore project notes
|
||||
QString notes = this->core->cmd("Pn");
|
||||
//qDebug() << "Notes:" << notes;
|
||||
if (notes != "") {
|
||||
if (notes != "")
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.append(notes);
|
||||
this->w->notepadDock->notesTextEdit->setPlainText(QByteArray::fromBase64(ba));
|
||||
@ -227,7 +257,7 @@ void OptionsDialog::anal_finished()
|
||||
|
||||
this->w->add_output(" > Finished, happy reversing :)");
|
||||
// Add fortune message
|
||||
this->w->add_output( "\n" + this->w->core->cmd("fo") );
|
||||
this->w->add_output("\n" + this->w->core->cmd("fo"));
|
||||
this->w->memoryDock->setWindowTitle("entry0");
|
||||
this->w->start_web_server();
|
||||
close();
|
||||
@ -243,27 +273,32 @@ void OptionsDialog::on_cancelButton_clicked()
|
||||
this->core = NULL;
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
NewFileDialog* n = new NewFileDialog(this);
|
||||
NewFileDialog *n = new NewFileDialog(this);
|
||||
n->show();
|
||||
}
|
||||
|
||||
void OptionsDialog::on_analSlider_valueChanged(int value)
|
||||
{
|
||||
ui->analLevel->setText(QString::number(value));
|
||||
if (value == 0) {
|
||||
if (value == 0)
|
||||
{
|
||||
ui->analCheckBox->setChecked(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->analCheckBox->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::on_AdvOptButton_clicked()
|
||||
{
|
||||
if(ui->AdvOptButton->isChecked())
|
||||
if (ui->AdvOptButton->isChecked())
|
||||
{
|
||||
ui->hideFrame->setVisible(true);
|
||||
ui->AdvOptButton->setArrowType(Qt::DownArrow);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->hideFrame->setVisible(false);
|
||||
ui->AdvOptButton->setArrowType(Qt::RightArrow);
|
||||
|
||||
|
@ -9,8 +9,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class OptionsDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class OptionsDialog;
|
||||
}
|
||||
|
||||
class OptionsDialog : public QDialog
|
||||
|
629
src/qrcore.cpp
629
src/qrcore.cpp
File diff suppressed because it is too large
Load Diff
26
src/qrcore.h
26
src/qrcore.h
@ -29,16 +29,16 @@
|
||||
|
||||
class RCoreLocked
|
||||
{
|
||||
RCore* core;
|
||||
RCore *core;
|
||||
|
||||
public:
|
||||
explicit RCoreLocked(RCore* core);
|
||||
RCoreLocked(const RCoreLocked&) = delete;
|
||||
RCoreLocked& operator=(const RCoreLocked&) = delete;
|
||||
RCoreLocked(RCoreLocked&&);
|
||||
explicit RCoreLocked(RCore *core);
|
||||
RCoreLocked(const RCoreLocked &) = delete;
|
||||
RCoreLocked &operator=(const RCoreLocked &) = delete;
|
||||
RCoreLocked(RCoreLocked &&);
|
||||
~RCoreLocked();
|
||||
operator RCore*() const;
|
||||
RCore* operator->() const;
|
||||
operator RCore *() const;
|
||||
RCore *operator->() const;
|
||||
};
|
||||
|
||||
#define QNOTUSED(x) do { (void)(x); } while ( 0 );
|
||||
@ -62,23 +62,23 @@ public:
|
||||
void setComment(QString addr, QString cmt);
|
||||
void delComment(ut64 addr);
|
||||
QList<QList<QString>> getComments();
|
||||
QMap<QString, QList<QList<QString> > > getNestedComments();
|
||||
QMap<QString, QList<QList<QString>>> getNestedComments();
|
||||
void setOptions(QString key);
|
||||
bool loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int bits, int idx=0, bool loadbin=false);
|
||||
bool loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int bits, int idx = 0, bool loadbin = false);
|
||||
bool tryFile(QString path, bool rw);
|
||||
void analyze(int level);
|
||||
void seek(QString addr);
|
||||
void seek(ut64 addr);
|
||||
ut64 math(const QString &expr);
|
||||
QString itoa(ut64 num, int rdx=16);
|
||||
QString config(const QString &k, const QString &v=NULL);
|
||||
QString itoa(ut64 num, int rdx = 16);
|
||||
QString config(const QString &k, const QString &v = NULL);
|
||||
int config(const QString &k, int v);
|
||||
QList<QString> getList(const QString & type, const QString & subtype="");
|
||||
QList<QString> getList(const QString &type, const QString &subtype = "");
|
||||
QString assemble(const QString &code);
|
||||
QString disassemble(const QString &code);
|
||||
void setDefaultCPU();
|
||||
void setCPU(QString arch, QString cpu, int bits, bool temporary);
|
||||
RAnalFunction* functionAt(ut64 addr);
|
||||
RAnalFunction *functionAt(ut64 addr);
|
||||
QString cmdFunctionAt(QString addr);
|
||||
/* sdb */
|
||||
QList<QString> sdbList(QString path);
|
||||
|
@ -8,11 +8,12 @@ QRDisasm::QRDisasm(QRCore *core)
|
||||
this->core = core;
|
||||
}
|
||||
|
||||
bool QRDisasm::disassembleAt (ut64 addr, QRDisasmOption opt, QRDisasmRow &dr) {
|
||||
bool QRDisasm::disassembleAt(ut64 addr, QRDisasmOption opt, QRDisasmRow &dr)
|
||||
{
|
||||
QNOTUSED(addr);
|
||||
QNOTUSED(opt);
|
||||
QNOTUSED(dr);
|
||||
|
||||
printf ("FUCK\n");
|
||||
printf("FUCK\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -3,19 +3,21 @@
|
||||
|
||||
#include <qrcore.h>
|
||||
|
||||
enum QRDisasmDataType {
|
||||
enum QRDisasmDataType
|
||||
{
|
||||
STRING = 'z',
|
||||
STRUCT = 's',
|
||||
DATA = 'd',
|
||||
|
||||
};
|
||||
|
||||
enum QRDisasmOption {
|
||||
DWARF = 1<<1,
|
||||
REFS = 1<<2,
|
||||
ESIL = 1<<3,
|
||||
HEXPAIRS = 1<<4,
|
||||
COMMENT = 1<<5,
|
||||
enum QRDisasmOption
|
||||
{
|
||||
DWARF = 1 << 1,
|
||||
REFS = 1 << 2,
|
||||
ESIL = 1 << 3,
|
||||
HEXPAIRS = 1 << 4,
|
||||
COMMENT = 1 << 5,
|
||||
};
|
||||
|
||||
class QRDisasmRow
|
||||
@ -64,7 +66,7 @@ class QRDisasm
|
||||
Sdb *db;
|
||||
public:
|
||||
QRDisasm(QRCore *core);
|
||||
bool disassembleAt (ut64 addr, QRDisasmOption opt, QRDisasmRow &dr);
|
||||
bool disassembleAt(ut64 addr, QRDisasmOption opt, QRDisasmRow &dr);
|
||||
// high level api for the disasm thing to manage comments, xrefs, etc
|
||||
//next();
|
||||
//prev();
|
||||
|
@ -12,7 +12,8 @@ WebServerThread::WebServerThread(QRCore *core, QObject *parent) :
|
||||
|
||||
WebServerThread::~WebServerThread()
|
||||
{
|
||||
if (isRunning()) {
|
||||
if (isRunning())
|
||||
{
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
@ -22,7 +23,8 @@ void WebServerThread::startServer()
|
||||
{
|
||||
assert(nullptr != core);
|
||||
|
||||
if (!isRunning() && !started) {
|
||||
if (!isRunning() && !started)
|
||||
{
|
||||
QThread::start();
|
||||
}
|
||||
}
|
||||
@ -43,7 +45,8 @@ bool WebServerThread::isStarted() const
|
||||
return started;
|
||||
}
|
||||
|
||||
void WebServerThread::run() {
|
||||
void WebServerThread::run()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (core == nullptr)
|
||||
@ -63,13 +66,16 @@ void WebServerThread::toggleWebServer()
|
||||
// "=h*", "", "restart current webserver",
|
||||
// "=h&", " port", "start http server in background)",
|
||||
|
||||
if (started) {
|
||||
if (started)
|
||||
{
|
||||
// after this the only reaction to this commands is:
|
||||
// sandbox: connect disabled
|
||||
// and the webserver is still running
|
||||
// TODO: find out why
|
||||
core->cmd("=h-");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
core->cmd("=h&");
|
||||
}
|
||||
|
||||
|
@ -9,18 +9,18 @@ class Banned : public QObject
|
||||
public:
|
||||
|
||||
QString banned = "[a-zA-Z_.]*(system|strcpy|strcpyA|strcpyW|wcscpy|_tcscpy|_mbscpy|StrCpy|StrCpyA|StrCpyW|lstrcpy|lstrcpyA|lstrcpyW" \
|
||||
"|_tccpy|_mbccpy|_ftcscpy|strcat|strcatA|strcatW|wcscat|_tcscat|_mbscat|StrCat|StrCatA|StrCatW|lstrcat|lstrcatA|" \
|
||||
"lstrcatW|StrCatBuff|StrCatBuffA|StrCatBuffW|StrCatChainW|_tccat|_mbccat|_ftcscat|sprintfW|sprintfA|wsprintf|wsprintfW|" \
|
||||
"wsprintfA|sprintf|swprintf|_stprintf|wvsprintf|wvsprintfA|wvsprintfW|vsprintf|_vstprintf|vswprintf|strncpy|wcsncpy|" \
|
||||
"_tcsncpy|_mbsncpy|_mbsnbcpy|StrCpyN|StrCpyNA|StrCpyNW|StrNCpy|strcpynA|StrNCpyA|StrNCpyW|lstrcpyn|lstrcpynA|lstrcpynW|" \
|
||||
"strncat|wcsncat|_tcsncat|_mbsncat|_mbsnbcat|StrCatN|StrCatNA|StrCatNW|StrNCat|StrNCatA|StrNCatW|lstrncat|lstrcatnA|" \
|
||||
"lstrcatnW|lstrcatn|gets|_getts|_gettws|IsBadWritePtr|IsBadHugeWritePtr|IsBadReadPtr|IsBadHugeReadPtr|IsBadCodePtr|" \
|
||||
"IsBadStringPtr|memcpy|RtlCopyMemory|CopyMemory|wmemcpy|wnsprintf|wnsprintfA|wnsprintfW|_snwprintf|_snprintf|_sntprintf|" \
|
||||
"_vsnprintf|vsnprintf|_vsnwprintf|_vsntprintf|wvnsprintf|wvnsprintfA|wvnsprintfW|strtok|_tcstok|wcstok|_mbstok|makepath|" \
|
||||
"_tmakepath| _makepath|_wmakepath|_splitpath|_tsplitpath|_wsplitpath|scanf|wscanf|_tscanf|sscanf|swscanf|_stscanf|snscanf|" \
|
||||
"snwscanf|_sntscanf|_itoa|_itow|_i64toa|_i64tow|_ui64toa|_ui64tot|_ui64tow|_ultoa|_ultot|_ultow|CharToOem|CharToOemA|CharToOemW|" \
|
||||
"OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|" \
|
||||
"ChangeWindowMessageFilter)";
|
||||
"|_tccpy|_mbccpy|_ftcscpy|strcat|strcatA|strcatW|wcscat|_tcscat|_mbscat|StrCat|StrCatA|StrCatW|lstrcat|lstrcatA|" \
|
||||
"lstrcatW|StrCatBuff|StrCatBuffA|StrCatBuffW|StrCatChainW|_tccat|_mbccat|_ftcscat|sprintfW|sprintfA|wsprintf|wsprintfW|" \
|
||||
"wsprintfA|sprintf|swprintf|_stprintf|wvsprintf|wvsprintfA|wvsprintfW|vsprintf|_vstprintf|vswprintf|strncpy|wcsncpy|" \
|
||||
"_tcsncpy|_mbsncpy|_mbsnbcpy|StrCpyN|StrCpyNA|StrCpyNW|StrNCpy|strcpynA|StrNCpyA|StrNCpyW|lstrcpyn|lstrcpynA|lstrcpynW|" \
|
||||
"strncat|wcsncat|_tcsncat|_mbsncat|_mbsnbcat|StrCatN|StrCatNA|StrCatNW|StrNCat|StrNCatA|StrNCatW|lstrncat|lstrcatnA|" \
|
||||
"lstrcatnW|lstrcatn|gets|_getts|_gettws|IsBadWritePtr|IsBadHugeWritePtr|IsBadReadPtr|IsBadHugeReadPtr|IsBadCodePtr|" \
|
||||
"IsBadStringPtr|memcpy|RtlCopyMemory|CopyMemory|wmemcpy|wnsprintf|wnsprintfA|wnsprintfW|_snwprintf|_snprintf|_sntprintf|" \
|
||||
"_vsnprintf|vsnprintf|_vsnwprintf|_vsntprintf|wvnsprintf|wvnsprintfA|wvnsprintfW|strtok|_tcstok|wcstok|_mbstok|makepath|" \
|
||||
"_tmakepath| _makepath|_wmakepath|_splitpath|_tsplitpath|_wsplitpath|scanf|wscanf|_tscanf|sscanf|swscanf|_stscanf|snscanf|" \
|
||||
"snwscanf|_sntscanf|_itoa|_itow|_i64toa|_i64tow|_ui64toa|_ui64tot|_ui64tow|_ultoa|_ultot|_ultow|CharToOem|CharToOemA|CharToOemW|" \
|
||||
"OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|" \
|
||||
"ChangeWindowMessageFilter)";
|
||||
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,7 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
|
||||
|
||||
setObjectName("codeGraphics");
|
||||
setWindowTitle("Code bar");
|
||||
// setMovable(false);
|
||||
// setMovable(false);
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
// If line below is used, with the dark theme the paintEvent is not called
|
||||
// and the result is wrong. Something to do with overwriting the style sheet :/
|
||||
@ -41,21 +41,23 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
|
||||
//addWidget(addsCombo);
|
||||
}
|
||||
|
||||
void GraphicsBar::paintEvent(QPaintEvent *event) {
|
||||
void GraphicsBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QNOTUSED(event);
|
||||
|
||||
QPainter painter(this);
|
||||
this->fillData();
|
||||
}
|
||||
|
||||
void GraphicsBar::fillData() {
|
||||
void GraphicsBar::fillData()
|
||||
{
|
||||
|
||||
// Prepare the graph scene
|
||||
int w = this->codeGraphic->width();
|
||||
int h = this->codeGraphic->height();
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
|
||||
const QBrush bg = QBrush(QColor(74,74,74));
|
||||
const QBrush bg = QBrush(QColor(74, 74, 74));
|
||||
|
||||
scene->setBackgroundBrush(bg);
|
||||
this->codeGraphic->setRenderHints(0);
|
||||
@ -67,10 +69,12 @@ void GraphicsBar::fillData() {
|
||||
QString jsonData = this->main->core->cmd("p-j");
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonData.toUtf8());
|
||||
|
||||
if (doc.isNull()) {
|
||||
if (doc.isNull())
|
||||
{
|
||||
qDebug() << "Invalid json in p-j command";
|
||||
}
|
||||
else if (doc.isObject()) {
|
||||
else if (doc.isObject())
|
||||
{
|
||||
//get the jsonObject
|
||||
QJsonObject jObject = doc.object();
|
||||
|
||||
@ -82,34 +86,42 @@ void GraphicsBar::fillData() {
|
||||
int block = mainMap["blocksize"].toInt();
|
||||
int size = (to - from);
|
||||
int num = size / block;
|
||||
if (num < 1) {
|
||||
if (num < 1)
|
||||
{
|
||||
num = 1;
|
||||
}
|
||||
int graph_block = w / num;
|
||||
int counter = 0;
|
||||
|
||||
for (auto i : mainMap["blocks"].toList()) {
|
||||
for (auto i : mainMap["blocks"].toList())
|
||||
{
|
||||
QMap<QString, QVariant> map = i.toMap();
|
||||
if (map.empty()) {
|
||||
if (map.empty())
|
||||
{
|
||||
// Fill empty color
|
||||
// addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen = QPen(), const QBrush &brush = QBrush())
|
||||
//scene->addRect(counter * graph_block, 0, graph_block ,h, QPen(Qt::NoPen), QBrush(QColor(252, 249, 190)));
|
||||
QGraphicsRectItem* rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block ,h);
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block, h);
|
||||
rect->setPen(Qt::NoPen);
|
||||
rect->setBrush(QBrush(QColor(252, 249, 190)));
|
||||
rect->setToolTip("Data");
|
||||
scene->addItem(rect);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fill type of color
|
||||
//scene->addRect(counter * graph_block, 0, graph_block ,h, QPen(Qt::NoPen), QBrush(QColor(69, 104, 229)));
|
||||
QGraphicsRectItem* rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block ,h);
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block, h);
|
||||
rect->setPen(Qt::NoPen);
|
||||
if (i.toMap()["functions"].toInt() == 0) {
|
||||
if (i.toMap()["functions"].toInt() == 0)
|
||||
{
|
||||
rect->setBrush(QBrush(QColor(190, 190, 190)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
rect->setBrush(QBrush(QColor(69, 104, 229)));
|
||||
}
|
||||
rect->setToolTip("Offset: 0x" + QString::number(i.toMap()["offset"].toInt(), 16) + "\nFunctions: " + QString::number( i.toMap()["functions"].toInt()) + "\nFlags: " + QString::number( i.toMap()["flags"].toInt()));
|
||||
rect->setToolTip("Offset: 0x" + QString::number(i.toMap()["offset"].toInt(), 16) + "\nFunctions: " + QString::number(i.toMap()["functions"].toInt()) + "\nFlags: " + QString::number(i.toMap()["flags"].toInt()));
|
||||
scene->addItem(rect);
|
||||
}
|
||||
counter += 1;
|
||||
|
@ -45,13 +45,15 @@ void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *it
|
||||
QString offset = item->text(1);
|
||||
QString name = item->text(2);
|
||||
this->main->add_debug_output(offset + ": " + name);
|
||||
this->main->seek (offset, name);
|
||||
this->main->seek(offset, name);
|
||||
}
|
||||
|
||||
void CommentsWidget::refreshTree() {
|
||||
void CommentsWidget::refreshTree()
|
||||
{
|
||||
this->commentsTreeWidget->clear();
|
||||
QList<QList<QString>> comments = this->main->core->getComments();
|
||||
for (QList<QString> comment: comments) {
|
||||
for (QList<QString> comment : comments)
|
||||
{
|
||||
this->main->add_debug_output(comment[1]);
|
||||
QString fcn_name = this->main->core->cmdFunctionAt(comment[1]);
|
||||
this->main->appendRow(this->commentsTreeWidget, comment[1], fcn_name, comment[0].remove('"'));
|
||||
@ -61,11 +63,13 @@ void CommentsWidget::refreshTree() {
|
||||
// Add nested comments
|
||||
this->nestedCommentsTreeWidget->clear();
|
||||
QMap<QString, QList<QList<QString>>> cmts = this->main->core->getNestedComments();
|
||||
for(auto cmt : cmts.keys()) {
|
||||
for (auto cmt : cmts.keys())
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(this->nestedCommentsTreeWidget);
|
||||
item->setText(0, cmt);
|
||||
QList<QList<QString>> meow = cmts.value(cmt);
|
||||
for (int i = 0; i < meow.size(); ++i) {
|
||||
for (int i = 0; i < meow.size(); ++i)
|
||||
{
|
||||
QList<QString> tmp = meow.at(i);
|
||||
QTreeWidgetItem *it = new QTreeWidgetItem();
|
||||
it->setText(0, tmp[1]);
|
||||
@ -95,10 +99,13 @@ void CommentsWidget::showTitleContextMenu(const QPoint &pt)
|
||||
menu->addAction(ui->actionHorizontal);
|
||||
menu->addAction(ui->actionVertical);
|
||||
|
||||
if (ui->tabWidget->currentIndex() == 0) {
|
||||
if (ui->tabWidget->currentIndex() == 0)
|
||||
{
|
||||
ui->actionHorizontal->setChecked(true);
|
||||
ui->actionVertical->setChecked(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->actionVertical->setChecked(true);
|
||||
ui->actionHorizontal->setChecked(false);
|
||||
}
|
||||
@ -119,17 +126,23 @@ void CommentsWidget::on_actionVertical_triggered()
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
bool CommentsWidget::eventFilter(QObject *obj, QEvent *event) {
|
||||
if (this->main->responsive) {
|
||||
if (event->type() == QEvent::Resize && obj == this && this->isVisible()) {
|
||||
QResizeEvent *resizeEvent = static_cast<QResizeEvent*>(event);
|
||||
bool CommentsWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (this->main->responsive)
|
||||
{
|
||||
if (event->type() == QEvent::Resize && obj == this && this->isVisible())
|
||||
{
|
||||
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
|
||||
//qDebug("Dock Resized (New Size) - Width: %d Height: %d",
|
||||
// resizeEvent->size().width(),
|
||||
// resizeEvent->size().height());
|
||||
if (resizeEvent->size().width() >= resizeEvent->size().height()) {
|
||||
if (resizeEvent->size().width() >= resizeEvent->size().height())
|
||||
{
|
||||
// Set horizontal view (list)
|
||||
this->on_actionHorizontal_triggered();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set vertical view (Tree)
|
||||
this->on_actionVertical_triggered();
|
||||
}
|
||||
|
@ -7,8 +7,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class CommentsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class CommentsWidget;
|
||||
}
|
||||
|
||||
class CommentsWidget : public QDockWidget
|
||||
|
@ -26,7 +26,8 @@ Dashboard::~Dashboard()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Dashboard::updateContents() {
|
||||
void Dashboard::updateContents()
|
||||
{
|
||||
|
||||
// Parse and add JSON file info
|
||||
QString info = this->main->core->getFileInfo();
|
||||
@ -46,8 +47,8 @@ void Dashboard::updateContents() {
|
||||
this->ui->formatEdit->setText(item["format"].toString());
|
||||
this->ui->modeEdit->setText(item["mode"].toString());
|
||||
this->ui->typeEdit->setText(item["type"].toString());
|
||||
this->ui->sizeEdit->setText( QString::number(item["size"].toDouble()) );
|
||||
this->ui->fdEdit->setText( QString::number(item["fd"].toDouble()) );
|
||||
this->ui->sizeEdit->setText(QString::number(item["size"].toDouble()));
|
||||
this->ui->fdEdit->setText(QString::number(item["fd"].toDouble()));
|
||||
|
||||
this->ui->archEdit->setText(item2["arch"].toString());
|
||||
this->ui->langEdit->setText(item2["lang"].toString().toUpper());
|
||||
@ -57,51 +58,75 @@ void Dashboard::updateContents() {
|
||||
this->ui->subsysEdit->setText(item2["subsys"].toString());
|
||||
this->ui->endianEdit->setText(item2["endian"].toString());
|
||||
this->ui->compiledEdit->setText(item2["compiled"].toString());
|
||||
this->ui->bitsEdit->setText( QString::number(item2["bits"].toDouble()) );
|
||||
this->ui->bitsEdit->setText(QString::number(item2["bits"].toDouble()));
|
||||
|
||||
this->ui->baddrEdit->setText( QString::number(item2["baddr"].toDouble()) );
|
||||
this->ui->baddrEdit->setText(QString::number(item2["baddr"].toDouble()));
|
||||
|
||||
if ( item2["va"].toBool() == true) {
|
||||
if (item2["va"].toBool() == true)
|
||||
{
|
||||
this->ui->vaEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->vaEdit->setText("False");
|
||||
}
|
||||
if ( item2["canary"].toBool() == true) {
|
||||
if (item2["canary"].toBool() == true)
|
||||
{
|
||||
this->ui->canaryEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->canaryEdit->setText("False");
|
||||
this->ui->canaryEdit->setStyleSheet("color: rgb(255, 0, 0);");
|
||||
}
|
||||
if ( item2["crypto"].toBool() == true) {
|
||||
if (item2["crypto"].toBool() == true)
|
||||
{
|
||||
this->ui->cryptoEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->cryptoEdit->setText("False");
|
||||
}
|
||||
if ( item2["nx"].toBool() == true) {
|
||||
if (item2["nx"].toBool() == true)
|
||||
{
|
||||
this->ui->nxEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->nxEdit->setText("False");
|
||||
this->ui->nxEdit->setStyleSheet("color: rgb(255, 0, 0);");
|
||||
}
|
||||
if ( item2["pic"].toBool() == true) {
|
||||
if (item2["pic"].toBool() == true)
|
||||
{
|
||||
this->ui->picEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->picEdit->setText("False");
|
||||
this->ui->picEdit->setStyleSheet("color: rgb(255, 0, 0);");
|
||||
}
|
||||
if ( item2["static"].toBool() == true) {
|
||||
if (item2["static"].toBool() == true)
|
||||
{
|
||||
this->ui->staticEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->staticEdit->setText("False");
|
||||
}
|
||||
if ( item2["stripped"].toBool() == true) {
|
||||
if (item2["stripped"].toBool() == true)
|
||||
{
|
||||
this->ui->strippedEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->strippedEdit->setText("False");
|
||||
}
|
||||
if ( item2["relocs"].toBool() == true) {
|
||||
if (item2["relocs"].toBool() == true)
|
||||
{
|
||||
this->ui->relocsEdit->setText("True");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->relocsEdit->setText("False");
|
||||
}
|
||||
|
||||
@ -113,17 +138,19 @@ void Dashboard::updateContents() {
|
||||
|
||||
QString libs = this->main->core->cmd("il");
|
||||
QStringList lines = libs.split("\n", QString::SkipEmptyParts);
|
||||
if (! lines.isEmpty()) {
|
||||
if (! lines.isEmpty())
|
||||
{
|
||||
lines.removeFirst();
|
||||
lines.removeLast();
|
||||
}
|
||||
foreach (QString lib, lines) {
|
||||
foreach (QString lib, lines)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(lib);
|
||||
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
ui->verticalLayout_2->addWidget(label);
|
||||
}
|
||||
QSpacerItem *spacer = new QSpacerItem(1,1, QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
QSpacerItem *spacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
ui->verticalLayout_2->addSpacerItem(spacer);
|
||||
|
||||
// Add entropy value
|
||||
@ -135,8 +162,9 @@ void Dashboard::updateContents() {
|
||||
|
||||
// Add data to HTML graphs (stats)
|
||||
QFile html(":/html/stats.html");
|
||||
if(!html.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::information(0,"error",html.errorString());
|
||||
if (!html.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QMessageBox::information(0, "error", html.errorString());
|
||||
}
|
||||
QString code = html.readAll();
|
||||
html.close();
|
||||
@ -147,8 +175,9 @@ void Dashboard::updateContents() {
|
||||
|
||||
// Add data to polar graph
|
||||
QFile html2(":/html/radar.html");
|
||||
if(!html2.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::information(0,"error",html2.errorString());
|
||||
if (!html2.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QMessageBox::information(0, "error", html2.errorString());
|
||||
}
|
||||
QString code2 = html2.readAll();
|
||||
html2.close();
|
||||
|
@ -5,8 +5,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class Dashboard;
|
||||
namespace Ui
|
||||
{
|
||||
class Dashboard;
|
||||
}
|
||||
|
||||
class Dashboard : public QDockWidget
|
||||
|
@ -7,8 +7,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class FlagsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class FlagsWidget;
|
||||
}
|
||||
|
||||
class FlagsWidget : public QDockWidget
|
||||
|
@ -47,17 +47,20 @@ FunctionsWidget::~FunctionsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FunctionsWidget::fillFunctions() {
|
||||
void FunctionsWidget::fillFunctions()
|
||||
{
|
||||
this->functionsTreeWidget->clear();
|
||||
ui->nestedFunctionsTree->clear();
|
||||
for (auto i: this->main->core->getList ("anal", "functions")) {
|
||||
QStringList a = i.split (",");
|
||||
for (auto i : this->main->core->getList("anal", "functions"))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
// off,sz,unk,name
|
||||
// "0x0804ada3,1,13,,fcn.0804ada3"
|
||||
// "0x0804ad4a,6,,1,,fcn.0804ad4a"
|
||||
if (a.length() == 5) {
|
||||
if (a.length() == 5)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget,a[0],a[1],a[4]);
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[4]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[4]);
|
||||
@ -68,9 +71,11 @@ void FunctionsWidget::fillFunctions() {
|
||||
off_it->setText(0, "Size: " + a[1]);
|
||||
item->addChild(off_it);
|
||||
ui->nestedFunctionsTree->addTopLevelItem(item);
|
||||
} else if (a.length() == 6) {
|
||||
}
|
||||
else if (a.length() == 6)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget,a[0],a[1],a[5]);
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[5]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[5]);
|
||||
@ -81,7 +86,9 @@ void FunctionsWidget::fillFunctions() {
|
||||
off_it->setText(0, "Size: " + a[1]);
|
||||
item->addChild(off_it);
|
||||
ui->nestedFunctionsTree->addTopLevelItem(item);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "fillFunctions()" << a;
|
||||
}
|
||||
}
|
||||
@ -113,27 +120,33 @@ void FunctionsWidget::showFunctionsContextMenu(const QPoint &pt)
|
||||
menu->addSeparator();
|
||||
menu->addAction(ui->action_References);
|
||||
|
||||
if(ui->tabWidget->currentIndex() == 0) {
|
||||
if (ui->tabWidget->currentIndex() == 0)
|
||||
{
|
||||
this->functionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
menu->exec(ui->functionsTreeWidget->mapToGlobal(pt));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->nestedFunctionsTree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
menu->exec(ui->nestedFunctionsTree->mapToGlobal(pt));
|
||||
}
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void FunctionsWidget::refreshTree() {
|
||||
void FunctionsWidget::refreshTree()
|
||||
{
|
||||
this->functionsTreeWidget->clear();
|
||||
ui->nestedFunctionsTree->clear();
|
||||
for (auto i: this->main->core->getList ("anal", "functions")) {
|
||||
QStringList a = i.split (",");
|
||||
for (auto i : this->main->core->getList("anal", "functions"))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
// off,sz,unk,name
|
||||
// "0x0804ada3,1,13,,fcn.0804ada3"
|
||||
// "0x0804ad4a,6,,1,,fcn.0804ad4a"
|
||||
if (a.length() == 5) {
|
||||
if (a.length() == 5)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget,a[0],a[1],a[4]);
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[4]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[4]);
|
||||
@ -144,9 +157,11 @@ void FunctionsWidget::refreshTree() {
|
||||
off_it->setText(0, "Size: " + a[1]);
|
||||
item->addChild(off_it);
|
||||
ui->nestedFunctionsTree->addTopLevelItem(item);
|
||||
} else if (a.length() == 6) {
|
||||
}
|
||||
else if (a.length() == 6)
|
||||
{
|
||||
// Add list function
|
||||
this->main->appendRow(this->functionsTreeWidget,a[0],a[1],a[5]);
|
||||
this->main->appendRow(this->functionsTreeWidget, a[0], a[1], a[5]);
|
||||
// Add nested function
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->nestedFunctionsTree);
|
||||
item->setText(0, a[5]);
|
||||
@ -157,7 +172,9 @@ void FunctionsWidget::refreshTree() {
|
||||
off_it->setText(0, "Size: " + a[1]);
|
||||
item->addChild(off_it);
|
||||
ui->nestedFunctionsTree->addTopLevelItem(item);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "fillFunctions()" << a;
|
||||
}
|
||||
}
|
||||
@ -172,18 +189,22 @@ void FunctionsWidget::on_actionDisasAdd_comment_triggered()
|
||||
{
|
||||
QString fcn_name = "";
|
||||
// Create dialog
|
||||
CommentsDialog* c = new CommentsDialog(this);
|
||||
CommentsDialog *c = new CommentsDialog(this);
|
||||
// Get selected item in functions tree widget
|
||||
if(ui->tabWidget->currentIndex() == 0) {
|
||||
if (ui->tabWidget->currentIndex() == 0)
|
||||
{
|
||||
QList<QTreeWidgetItem *> selected_rows = ui->functionsTreeWidget->selectedItems();
|
||||
// Get selected function name
|
||||
fcn_name = selected_rows.first()->text(3);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<QTreeWidgetItem *> selected_rows = ui->nestedFunctionsTree->selectedItems();
|
||||
// Get selected function name
|
||||
fcn_name = selected_rows.first()->text(0);
|
||||
}
|
||||
if (c->exec()) {
|
||||
if (c->exec())
|
||||
{
|
||||
// Get new function name
|
||||
QString comment = c->getComment();
|
||||
this->main->add_debug_output("Comment: " + comment + " at: " + fcn_name);
|
||||
@ -196,15 +217,17 @@ void FunctionsWidget::on_actionDisasAdd_comment_triggered()
|
||||
this->main->refreshComments();
|
||||
}
|
||||
|
||||
void FunctionsWidget::addTooltips() {
|
||||
void FunctionsWidget::addTooltips()
|
||||
{
|
||||
|
||||
// Add comments to list functions
|
||||
QList<QTreeWidgetItem*> clist = this->functionsTreeWidget->findItems("*", Qt::MatchWildcard, 3);
|
||||
foreach(QTreeWidgetItem* item, clist)
|
||||
QList<QTreeWidgetItem *> clist = this->functionsTreeWidget->findItems("*", Qt::MatchWildcard, 3);
|
||||
foreach (QTreeWidgetItem *item, clist)
|
||||
{
|
||||
QString name = item->text(3);
|
||||
QList<QString> info = this->main->core->cmd("afi @ " + name).split("\n");
|
||||
if (info.length() > 2) {
|
||||
if (info.length() > 2)
|
||||
{
|
||||
QString size = info[4].split(" ")[1];
|
||||
QString complex = info[8].split(" ")[1];
|
||||
QString bb = info[11].split(" ")[1];
|
||||
@ -213,17 +236,18 @@ void FunctionsWidget::addTooltips() {
|
||||
"\n Basic blocks: " + bb +
|
||||
"\n\nDisasm preview:\n\n" + this->main->core->cmd("pdi 10 @ " + name) +
|
||||
"\nStrings:\n\n" + this->main->core->cmd("pdsf @ " + name));
|
||||
//"\nStrings:\n\n" + this->main->core->cmd("pds @ " + name + "!$F"));
|
||||
//"\nStrings:\n\n" + this->main->core->cmd("pds @ " + name + "!$F"));
|
||||
}
|
||||
}
|
||||
|
||||
// Add comments to nested functions
|
||||
QList<QTreeWidgetItem*> nlist = ui->nestedFunctionsTree->findItems("*", Qt::MatchWildcard, 0);
|
||||
foreach(QTreeWidgetItem* item, nlist)
|
||||
QList<QTreeWidgetItem *> nlist = ui->nestedFunctionsTree->findItems("*", Qt::MatchWildcard, 0);
|
||||
foreach (QTreeWidgetItem *item, nlist)
|
||||
{
|
||||
QString name = item->text(0);
|
||||
QList<QString> info = this->main->core->cmd("afi @ " + name).split("\n");
|
||||
if (info.length() > 2) {
|
||||
if (info.length() > 2)
|
||||
{
|
||||
QString size = info[4].split(" ")[1];
|
||||
QString complex = info[8].split(" ")[1];
|
||||
QString bb = info[11].split(" ")[1];
|
||||
@ -232,7 +256,7 @@ void FunctionsWidget::addTooltips() {
|
||||
"\n Basic blocks: " + bb +
|
||||
"\n\nDisasm preview:\n\n" + this->main->core->cmd("pdi 10 @ " + name) +
|
||||
"\nStrings:\n\n" + this->main->core->cmd("pdsf @ " + name));
|
||||
//"\nStrings:\n\n" + this->main->core->cmd("pds @ " + name + "!$F"));
|
||||
//"\nStrings:\n\n" + this->main->core->cmd("pds @ " + name + "!$F"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -240,7 +264,7 @@ void FunctionsWidget::addTooltips() {
|
||||
void FunctionsWidget::on_actionFunctionsRename_triggered()
|
||||
{
|
||||
// Create dialog
|
||||
RenameDialog* r = new RenameDialog(this);
|
||||
RenameDialog *r = new RenameDialog(this);
|
||||
// Get selected item in functions tree widget
|
||||
QList<QTreeWidgetItem *> selected_rows = ui->functionsTreeWidget->selectedItems();
|
||||
// Get selected function name
|
||||
@ -248,7 +272,8 @@ void FunctionsWidget::on_actionFunctionsRename_triggered()
|
||||
// Set function name in dialog
|
||||
r->setFunctionName(old_name);
|
||||
// If user accepted
|
||||
if (r->exec()) {
|
||||
if (r->exec())
|
||||
{
|
||||
// Get new function name
|
||||
QString new_name = r->getFunctionName();
|
||||
// Rename function in r2 core
|
||||
@ -279,7 +304,7 @@ void FunctionsWidget::on_action_References_triggered()
|
||||
// Get function for clicked offset
|
||||
RAnalFunction *fcn = this->main->core->functionAt(address.toLongLong(0, 16));
|
||||
|
||||
XrefsDialog* x = new XrefsDialog(this->main, this);
|
||||
XrefsDialog *x = new XrefsDialog(this->main, this);
|
||||
x->setWindowTitle("X-Refs for function " + QString::fromUtf8(fcn->name));
|
||||
|
||||
// Get Refs and Xrefs
|
||||
@ -288,8 +313,10 @@ void FunctionsWidget::on_action_References_triggered()
|
||||
|
||||
// refs = calls q hace esa funcion
|
||||
QList<QString> refs = this->main->core->getFunctionRefs(fcn->addr, 'C');
|
||||
if (refs.size() > 0) {
|
||||
for (int i = 0; i < refs.size(); ++i) {
|
||||
if (refs.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < refs.size(); ++i)
|
||||
{
|
||||
//this->main->add_debug_output(refs.at(i));
|
||||
QStringList retlist = refs.at(i).split(",");
|
||||
QStringList temp;
|
||||
@ -304,8 +331,10 @@ void FunctionsWidget::on_action_References_triggered()
|
||||
// xrefs = calls a esa funcion
|
||||
//qDebug() << this->main->core->getFunctionXrefs(offset.toLong(&ok, 16));
|
||||
QList<QString> xrefs = this->main->core->getFunctionXrefs(fcn->addr);
|
||||
if (xrefs.size() > 0) {
|
||||
for (int i = 0; i < xrefs.size(); ++i) {
|
||||
if (xrefs.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < xrefs.size(); ++i)
|
||||
{
|
||||
//this->main->add_debug_output(xrefs.at(i));
|
||||
QStringList retlist = xrefs.at(i).split(",");
|
||||
QStringList temp;
|
||||
@ -328,10 +357,13 @@ void FunctionsWidget::showTitleContextMenu(const QPoint &pt)
|
||||
menu->addAction(ui->actionHorizontal);
|
||||
menu->addAction(ui->actionVertical);
|
||||
|
||||
if (ui->tabWidget->currentIndex() == 0) {
|
||||
if (ui->tabWidget->currentIndex() == 0)
|
||||
{
|
||||
ui->actionHorizontal->setChecked(true);
|
||||
ui->actionVertical->setChecked(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->actionVertical->setChecked(true);
|
||||
ui->actionHorizontal->setChecked(false);
|
||||
}
|
||||
@ -363,17 +395,23 @@ void FunctionsWidget::on_nestedFunctionsTree_itemDoubleClicked(QTreeWidgetItem *
|
||||
this->main->memoryDock->raise();
|
||||
}
|
||||
|
||||
bool FunctionsWidget::eventFilter(QObject *obj, QEvent *event) {
|
||||
if (this->main->responsive) {
|
||||
if (event->type() == QEvent::Resize && obj == this && this->isVisible() == true) {
|
||||
QResizeEvent *resizeEvent = static_cast<QResizeEvent*>(event);
|
||||
bool FunctionsWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (this->main->responsive)
|
||||
{
|
||||
if (event->type() == QEvent::Resize && obj == this && this->isVisible() == true)
|
||||
{
|
||||
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
|
||||
//qDebug("Dock Resized (New Size) - Width: %d Height: %d",
|
||||
// resizeEvent->size().width(),
|
||||
// resizeEvent->size().height());
|
||||
if (resizeEvent->size().width() >= resizeEvent->size().height()) {
|
||||
if (resizeEvent->size().width() >= resizeEvent->size().height())
|
||||
{
|
||||
// Set horizontal view (list)
|
||||
this->on_actionHorizontal_triggered();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set vertical view (Tree)
|
||||
this->on_actionVertical_triggered();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class FunctionsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class FunctionsWidget;
|
||||
}
|
||||
|
||||
class FunctionsWidget : public QDockWidget
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "widgets/banned.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
void CMyDelegate::paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
void CMyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItemV4 itemOption(option);
|
||||
initStyleOption(&itemOption, index);
|
||||
@ -43,22 +43,25 @@ ImportsWidget::ImportsWidget(MainWindow *main, QWidget *parent) :
|
||||
//ui->importsTreeWidget->setItemDelegate(delegate);
|
||||
}
|
||||
|
||||
void ImportsWidget::fillImports() {
|
||||
void ImportsWidget::fillImports()
|
||||
{
|
||||
this->importsTreeWidget->clear();
|
||||
for (auto i: this->main->core->getList ("bin", "imports")) {
|
||||
QStringList a = i.split (",");
|
||||
for (auto i : this->main->core->getList("bin", "imports"))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
// ord,plt,name
|
||||
if (a.length()==6)
|
||||
this->main->appendRow(this->importsTreeWidget, a[1],a[3], "", a[4]);
|
||||
if (a.length() == 6)
|
||||
this->main->appendRow(this->importsTreeWidget, a[1], a[3], "", a[4]);
|
||||
}
|
||||
highlightUnsafe();
|
||||
this->main->adjustColumns(this->importsTreeWidget);
|
||||
}
|
||||
|
||||
void ImportsWidget::highlightUnsafe() {
|
||||
void ImportsWidget::highlightUnsafe()
|
||||
{
|
||||
Banned *ban = new Banned();
|
||||
QList<QTreeWidgetItem*> clist = this->importsTreeWidget->findItems(ban->banned, Qt::MatchRegExp, 4);
|
||||
foreach(QTreeWidgetItem* item, clist)
|
||||
QList<QTreeWidgetItem *> clist = this->importsTreeWidget->findItems(ban->banned, Qt::MatchRegExp, 4);
|
||||
foreach (QTreeWidgetItem *item, clist)
|
||||
{
|
||||
item->setText(3, "Unsafe");
|
||||
//item->setBackgroundColor(4, QColor(255, 129, 123));
|
||||
@ -68,9 +71,11 @@ void ImportsWidget::highlightUnsafe() {
|
||||
//ui->importsTreeWidget->setStyleSheet("QTreeWidget::item { padding-left:10px; padding-top: 1px; padding-bottom: 1px; border-left: 10px; }");
|
||||
}
|
||||
|
||||
void ImportsWidget::adjustColumns(QTreeWidget *tw) {
|
||||
void ImportsWidget::adjustColumns(QTreeWidget *tw)
|
||||
{
|
||||
int count = tw->columnCount();
|
||||
for (int i = 0; i != count; ++i) {
|
||||
for (int i = 0; i != count; ++i)
|
||||
{
|
||||
ui->importsTreeWidget->resizeColumnToContents(i);
|
||||
int width = ui->importsTreeWidget->columnWidth(i);
|
||||
ui->importsTreeWidget->setColumnWidth(i, width + 10);
|
||||
|
@ -7,8 +7,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class ImportsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class ImportsWidget;
|
||||
}
|
||||
|
||||
class ImportsWidget : public QDockWidget
|
||||
@ -33,9 +34,9 @@ private:
|
||||
class CMyDelegate : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
CMyDelegate(QObject* parent) : QStyledItemDelegate(parent) {}
|
||||
CMyDelegate(QObject *parent) : QStyledItemDelegate(parent) {}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
};
|
||||
|
||||
#endif // IMPORTSWIDGET_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,8 +18,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class MemoryWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class MemoryWidget;
|
||||
}
|
||||
|
||||
class MemoryWidget : public QDockWidget
|
||||
@ -58,13 +59,13 @@ public slots:
|
||||
|
||||
void refreshDisasm(const QString &offset = QString());
|
||||
|
||||
void refreshHexdump(QString where=0);
|
||||
void refreshHexdump(QString where = 0);
|
||||
|
||||
void fill_refs(QList<QStringList> list, QList<QStringList> xrefs, QList<int> graph_data);
|
||||
|
||||
void fillOffsetInfo(QString off);
|
||||
|
||||
void get_refs_data(const QString& offset);
|
||||
void get_refs_data(const QString &offset);
|
||||
|
||||
void seek_to(QString offset);
|
||||
|
||||
|
@ -36,7 +36,8 @@ Notepad::Notepad(MainWindow *main, QWidget *parent) :
|
||||
this, SLOT(showNotepadContextMenu(const QPoint &)));
|
||||
}
|
||||
|
||||
void Notepad::setText(QString str) {
|
||||
void Notepad::setText(QString str)
|
||||
{
|
||||
ui->notepadTextEdit->setPlainText(str);
|
||||
}
|
||||
|
||||
@ -49,8 +50,9 @@ void Notepad::on_fontButton_clicked()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
QFont font = QFontDialog::getFont( &ok, ui->notepadTextEdit->font(), this) ;
|
||||
if (ok) {
|
||||
QFont font = QFontDialog::getFont(&ok, ui->notepadTextEdit->font(), this) ;
|
||||
if (ok)
|
||||
{
|
||||
// the user clicked OK and font is set to the font the user selected
|
||||
//ui->notepadTextEdit->setFont(font);
|
||||
//ui->previewTextEdit->setFont(font);
|
||||
@ -58,7 +60,8 @@ void Notepad::on_fontButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void Notepad::setFonts(QFont font) {
|
||||
void Notepad::setFonts(QFont font)
|
||||
{
|
||||
ui->notepadTextEdit->setFont(font);
|
||||
ui->previewTextEdit->setFont(font);
|
||||
}
|
||||
@ -66,11 +69,14 @@ void Notepad::setFonts(QFont font) {
|
||||
void Notepad::on_boldButton_clicked()
|
||||
{
|
||||
QTextCursor cursor = ui->notepadTextEdit->textCursor();
|
||||
if (cursor.hasSelection()) {
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
QString text = cursor.selectedText();
|
||||
cursor.removeSelectedText();
|
||||
cursor.insertText("**" + text + "**");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.insertText("****");
|
||||
}
|
||||
}
|
||||
@ -78,11 +84,14 @@ void Notepad::on_boldButton_clicked()
|
||||
void Notepad::on_italicsButton_clicked()
|
||||
{
|
||||
QTextCursor cursor = ui->notepadTextEdit->textCursor();
|
||||
if (cursor.hasSelection()) {
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
QString text = cursor.selectedText();
|
||||
cursor.removeSelectedText();
|
||||
cursor.insertText("*" + text + "*");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.insertText("**");
|
||||
}
|
||||
}
|
||||
@ -90,11 +99,14 @@ void Notepad::on_italicsButton_clicked()
|
||||
void Notepad::on_h1Button_clicked()
|
||||
{
|
||||
QTextCursor cursor = ui->notepadTextEdit->textCursor();
|
||||
if (cursor.hasSelection()) {
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
QString text = cursor.selectedText();
|
||||
cursor.removeSelectedText();
|
||||
cursor.insertText("# " + text);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.insertText("# ");
|
||||
}
|
||||
}
|
||||
@ -102,11 +114,14 @@ void Notepad::on_h1Button_clicked()
|
||||
void Notepad::on_h2Button_clicked()
|
||||
{
|
||||
QTextCursor cursor = ui->notepadTextEdit->textCursor();
|
||||
if (cursor.hasSelection()) {
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
QString text = cursor.selectedText();
|
||||
cursor.removeSelectedText();
|
||||
cursor.insertText("## " + text);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.insertText("## ");
|
||||
}
|
||||
}
|
||||
@ -114,11 +129,14 @@ void Notepad::on_h2Button_clicked()
|
||||
void Notepad::on_h3Button_clicked()
|
||||
{
|
||||
QTextCursor cursor = ui->notepadTextEdit->textCursor();
|
||||
if (cursor.hasSelection()) {
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
QString text = cursor.selectedText();
|
||||
cursor.removeSelectedText();
|
||||
cursor.insertText("### " + text);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.insertText("### ");
|
||||
}
|
||||
}
|
||||
@ -139,7 +157,7 @@ void Notepad::on_redoButton_clicked()
|
||||
|
||||
void Notepad::highlightPreview()
|
||||
{
|
||||
disasm_highlighter = new Highlighter(this->main, ui->previewTextEdit->document());
|
||||
disasm_highlighter = new Highlighter(this->main, ui->previewTextEdit->document());
|
||||
}
|
||||
|
||||
void Notepad::on_searchEdit_returnPressed()
|
||||
@ -150,7 +168,8 @@ void Notepad::on_searchEdit_returnPressed()
|
||||
if (isFirstTime == false)
|
||||
document->undo();
|
||||
|
||||
if (!searchString.isEmpty()) {
|
||||
if (!searchString.isEmpty())
|
||||
{
|
||||
|
||||
QTextCursor highlightCursor(document);
|
||||
QTextCursor cursor(document);
|
||||
@ -161,12 +180,14 @@ void Notepad::on_searchEdit_returnPressed()
|
||||
QTextCharFormat colorFormat = plainFormat;
|
||||
colorFormat.setForeground(Qt::red);
|
||||
|
||||
while (!highlightCursor.isNull() && !highlightCursor.atEnd()) {
|
||||
while (!highlightCursor.isNull() && !highlightCursor.atEnd())
|
||||
{
|
||||
highlightCursor = document->find(searchString, highlightCursor, QTextDocument::FindWholeWords);
|
||||
|
||||
if (!highlightCursor.isNull()) {
|
||||
if (!highlightCursor.isNull())
|
||||
{
|
||||
highlightCursor.movePosition(QTextCursor::WordRight,
|
||||
QTextCursor::KeepAnchor);
|
||||
QTextCursor::KeepAnchor);
|
||||
highlightCursor.mergeCharFormat(colorFormat);
|
||||
}
|
||||
}
|
||||
@ -186,7 +207,8 @@ void Notepad::on_searchEdit_textEdited(const QString &arg1)
|
||||
if (isFirstTime == false)
|
||||
document->undo();
|
||||
|
||||
if (!searchString.isEmpty()) {
|
||||
if (!searchString.isEmpty())
|
||||
{
|
||||
|
||||
QTextCursor highlightCursor(document);
|
||||
QTextCursor cursor(document);
|
||||
@ -197,10 +219,12 @@ void Notepad::on_searchEdit_textEdited(const QString &arg1)
|
||||
QTextCharFormat colorFormat = plainFormat;
|
||||
colorFormat.setForeground(Qt::red);
|
||||
|
||||
while (!highlightCursor.isNull() && !highlightCursor.atEnd()) {
|
||||
while (!highlightCursor.isNull() && !highlightCursor.atEnd())
|
||||
{
|
||||
highlightCursor = document->find(searchString, highlightCursor);
|
||||
|
||||
if (!highlightCursor.isNull()) {
|
||||
if (!highlightCursor.isNull())
|
||||
{
|
||||
//highlightCursor.movePosition(QTextCursor::WordRight,
|
||||
// QTextCursor::KeepAnchor);
|
||||
highlightCursor.mergeCharFormat(colorFormat);
|
||||
@ -222,7 +246,8 @@ void Notepad::on_searchEdit_textChanged(const QString &arg1)
|
||||
if (isFirstTime == false)
|
||||
document->undo();
|
||||
|
||||
if (!searchString.isEmpty()) {
|
||||
if (!searchString.isEmpty())
|
||||
{
|
||||
|
||||
QTextCursor highlightCursor(document);
|
||||
QTextCursor cursor(document);
|
||||
@ -233,10 +258,12 @@ void Notepad::on_searchEdit_textChanged(const QString &arg1)
|
||||
QTextCharFormat colorFormat = plainFormat;
|
||||
colorFormat.setForeground(Qt::red);
|
||||
|
||||
while (!highlightCursor.isNull() && !highlightCursor.atEnd()) {
|
||||
while (!highlightCursor.isNull() && !highlightCursor.atEnd())
|
||||
{
|
||||
highlightCursor = document->find(searchString, highlightCursor);
|
||||
|
||||
if (!highlightCursor.isNull()) {
|
||||
if (!highlightCursor.isNull())
|
||||
{
|
||||
//highlightCursor.movePosition(QTextCursor::WordRight,
|
||||
// QTextCursor::KeepAnchor);
|
||||
highlightCursor.mergeCharFormat(colorFormat);
|
||||
@ -253,23 +280,26 @@ void Notepad::showNotepadContextMenu(const QPoint &pt)
|
||||
// Set Notepad popup menu
|
||||
QMenu *menu = ui->notepadTextEdit->createStandardContextMenu();
|
||||
QTextCursor cur = ui->notepadTextEdit->textCursor();
|
||||
QAction* first = menu->actions().at(0);
|
||||
QAction *first = menu->actions().at(0);
|
||||
|
||||
if (cur.hasSelection()) {
|
||||
if (cur.hasSelection())
|
||||
{
|
||||
// Get selected text
|
||||
//this->main->add_debug_output("Selected text: " + cur.selectedText());
|
||||
this->addr = cur.selectedText();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get word under the cursor
|
||||
cur.select( QTextCursor::WordUnderCursor);
|
||||
cur.select(QTextCursor::WordUnderCursor);
|
||||
//this->main->add_debug_output("Word: " + cur.selectedText());
|
||||
this->addr = cur.selectedText();
|
||||
}
|
||||
ui->actionDisassmble_bytes->setText( "Disassemble bytes at: " + this->addr);
|
||||
ui->actionDisassmble_function->setText( "Disassemble function at: " + this->addr);
|
||||
ui->actionHexdump_bytes->setText( "Hexdump bytes at: " + this->addr);
|
||||
ui->actionCompact_Hexdump->setText( "Compact Hexdump at: " + this->addr);
|
||||
ui->actionHexdump_function->setText( "Hexdump function at: " + this->addr);
|
||||
ui->actionDisassmble_bytes->setText("Disassemble bytes at: " + this->addr);
|
||||
ui->actionDisassmble_function->setText("Disassemble function at: " + this->addr);
|
||||
ui->actionHexdump_bytes->setText("Hexdump bytes at: " + this->addr);
|
||||
ui->actionCompact_Hexdump->setText("Compact Hexdump at: " + this->addr);
|
||||
ui->actionHexdump_function->setText("Hexdump function at: " + this->addr);
|
||||
menu->insertAction(first, ui->actionDisassmble_bytes);
|
||||
menu->insertAction(first, ui->actionDisassmble_function);
|
||||
menu->insertAction(first, ui->actionHexdump_bytes);
|
||||
@ -284,25 +314,25 @@ void Notepad::showNotepadContextMenu(const QPoint &pt)
|
||||
|
||||
void Notepad::on_actionDisassmble_bytes_triggered()
|
||||
{
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd("pd 100 @ " + this->addr) );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("pd 100 @ " + this->addr));
|
||||
}
|
||||
|
||||
void Notepad::on_actionDisassmble_function_triggered()
|
||||
{
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd("pdf @ " + this->addr) );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("pdf @ " + this->addr));
|
||||
}
|
||||
|
||||
void Notepad::on_actionHexdump_bytes_triggered()
|
||||
{
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd( "px 1024 @ " + this->addr ) );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("px 1024 @ " + this->addr));
|
||||
}
|
||||
|
||||
void Notepad::on_actionCompact_Hexdump_triggered()
|
||||
{
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd( "pxi 1024 @ " + this->addr ) );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("pxi 1024 @ " + this->addr));
|
||||
}
|
||||
|
||||
void Notepad::on_actionHexdump_function_triggered()
|
||||
{
|
||||
ui->previewTextEdit->setPlainText( this->main->core->cmd( "pxf @ " + this->addr ) );
|
||||
ui->previewTextEdit->setPlainText(this->main->core->cmd("pxf @ " + this->addr));
|
||||
}
|
||||
|
@ -8,8 +8,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class Notepad;
|
||||
namespace Ui
|
||||
{
|
||||
class Notepad;
|
||||
}
|
||||
|
||||
class Notepad : public QDockWidget
|
||||
|
@ -39,12 +39,13 @@ Omnibar::Omnibar(MainWindow *main, QWidget *parent) :
|
||||
connect(this, SIGNAL(returnPressed()), this, SLOT(on_gotoEntry_returnPressed()));
|
||||
|
||||
// Esc clears omnibar
|
||||
QShortcut* clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||
QShortcut *clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||
connect(clear_shortcut, SIGNAL(activated()), this, SLOT(clearContents()));
|
||||
clear_shortcut->setContext(Qt::WidgetShortcut);
|
||||
}
|
||||
|
||||
void Omnibar::setupCompleter() {
|
||||
void Omnibar::setupCompleter()
|
||||
{
|
||||
// Set gotoEntry completer for jump history
|
||||
QStringList flagsList = this->getFlags();
|
||||
QCompleter *completer = new QCompleter(flagsList, this);
|
||||
@ -54,7 +55,7 @@ void Omnibar::setupCompleter() {
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
completer->setFilterMode(Qt::MatchContains);
|
||||
|
||||
QStringListModel *completerModel = (QStringListModel*)(completer->model());
|
||||
QStringListModel *completerModel = (QStringListModel *)(completer->model());
|
||||
completerModel->setStringList(completerModel->stringList() << this->commands);
|
||||
|
||||
this->setCompleter(completer);
|
||||
@ -66,7 +67,8 @@ void Omnibar::restoreCompleter()
|
||||
completer->setFilterMode(Qt::MatchContains);
|
||||
}
|
||||
|
||||
void Omnibar::showCommands() {
|
||||
void Omnibar::showCommands()
|
||||
{
|
||||
this->setFocus();
|
||||
this->setText(": ");
|
||||
|
||||
@ -82,7 +84,8 @@ void Omnibar::showCommands() {
|
||||
completer->complete();
|
||||
}
|
||||
|
||||
void Omnibar::clearContents() {
|
||||
void Omnibar::clearContents()
|
||||
{
|
||||
this->setText("");
|
||||
// Necessary hack to make it work properly
|
||||
this->clearFocus();
|
||||
@ -92,38 +95,69 @@ void Omnibar::clearContents() {
|
||||
void Omnibar::on_gotoEntry_returnPressed()
|
||||
{
|
||||
QString str = this->text();
|
||||
if (str.length()>0) {
|
||||
if (str.contains(": ")) {
|
||||
if (str.contains("Lock")){
|
||||
if (str.length() > 0)
|
||||
{
|
||||
if (str.contains(": "))
|
||||
{
|
||||
if (str.contains("Lock"))
|
||||
{
|
||||
this->main->on_actionLock_triggered();
|
||||
} else if (str.contains("Functions")) {
|
||||
}
|
||||
else if (str.contains("Functions"))
|
||||
{
|
||||
this->main->on_actionFunctions_triggered();
|
||||
} else if (str.contains("Flags")) {
|
||||
}
|
||||
else if (str.contains("Flags"))
|
||||
{
|
||||
this->main->on_actionFlags_triggered();
|
||||
} else if (str.contains("Sections")) {
|
||||
}
|
||||
else if (str.contains("Sections"))
|
||||
{
|
||||
this->main->on_actionSections_triggered();
|
||||
} else if (str.contains("Strings")) {
|
||||
}
|
||||
else if (str.contains("Strings"))
|
||||
{
|
||||
this->main->on_actionStrings_triggered();
|
||||
} else if (str.contains("Imports")) {
|
||||
}
|
||||
else if (str.contains("Imports"))
|
||||
{
|
||||
this->main->on_actionImports_triggered();
|
||||
} else if (str.contains("Symbols")) {
|
||||
}
|
||||
else if (str.contains("Symbols"))
|
||||
{
|
||||
this->main->on_actionSymbols_triggered();
|
||||
} else if (str.contains("Relocs")) {
|
||||
}
|
||||
else if (str.contains("Relocs"))
|
||||
{
|
||||
this->main->on_actionReloc_triggered();
|
||||
} else if (str.contains("Comments")) {
|
||||
}
|
||||
else if (str.contains("Comments"))
|
||||
{
|
||||
this->main->on_actionComents_triggered();
|
||||
} else if (str.contains("Notepad")) {
|
||||
}
|
||||
else if (str.contains("Notepad"))
|
||||
{
|
||||
this->main->on_actionNotepad_triggered();
|
||||
} else if (str.contains("Dashboard")) {
|
||||
}
|
||||
else if (str.contains("Dashboard"))
|
||||
{
|
||||
this->main->on_actionDashboard_triggered();
|
||||
} else if (str.contains("Theme")) {
|
||||
}
|
||||
else if (str.contains("Theme"))
|
||||
{
|
||||
this->main->sideBar->themesButtonToggle();
|
||||
} else if (str.contains("Script")) {
|
||||
}
|
||||
else if (str.contains("Script"))
|
||||
{
|
||||
this->main->on_actionRun_Script_triggered();
|
||||
} else if (str.contains("Tabs")) {
|
||||
}
|
||||
else if (str.contains("Tabs"))
|
||||
{
|
||||
this->main->on_actionTabs_triggered();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//this->main->seek(this->main->core->cmd("?v " + this->text()), this->text());
|
||||
QString off = this->main->core->cmd("afo " + this->text());
|
||||
this->main->seek(off.trimmed(), this->text());
|
||||
@ -137,14 +171,17 @@ void Omnibar::on_gotoEntry_returnPressed()
|
||||
this->restoreCompleter();
|
||||
}
|
||||
|
||||
void Omnibar::fillFlags(QString flag) {
|
||||
void Omnibar::fillFlags(QString flag)
|
||||
{
|
||||
this->flags << flag;
|
||||
}
|
||||
|
||||
void Omnibar::clearFlags() {
|
||||
void Omnibar::clearFlags()
|
||||
{
|
||||
this->flags.clear();
|
||||
}
|
||||
|
||||
QStringList Omnibar::getFlags() {
|
||||
QStringList Omnibar::getFlags()
|
||||
{
|
||||
return this->flags;
|
||||
}
|
||||
|
@ -20,18 +20,18 @@ public:
|
||||
void setupCompleter();
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
MainWindow *main;
|
||||
|
||||
private slots:
|
||||
void on_gotoEntry_returnPressed();
|
||||
void on_gotoEntry_returnPressed();
|
||||
|
||||
void restoreCompleter();
|
||||
void restoreCompleter();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void showCommands();
|
||||
void clearContents();
|
||||
void showCommands();
|
||||
void clearContents();
|
||||
};
|
||||
|
||||
#endif // OMNIBAR_H
|
||||
|
@ -74,12 +74,14 @@ void PieView::dataChanged(const QModelIndex &topLeft,
|
||||
validItems = 0;
|
||||
totalValue = 0.0;
|
||||
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row)
|
||||
{
|
||||
|
||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||
double value = model()->data(index).toDouble();
|
||||
|
||||
if (value > 0.0) {
|
||||
if (value > 0.0)
|
||||
{
|
||||
totalValue += value;
|
||||
validItems++;
|
||||
}
|
||||
@ -108,7 +110,8 @@ QModelIndex PieView::indexAt(const QPoint &point) const
|
||||
int wx = point.x() + horizontalScrollBar()->value();
|
||||
int wy = point.y() + verticalScrollBar()->value();
|
||||
|
||||
if (wx < totalSize) {
|
||||
if (wx < totalSize)
|
||||
{
|
||||
double cx = wx - totalSize / 2;
|
||||
double cy = totalSize / 2 - wy; // positive cy for items above the center
|
||||
|
||||
@ -126,12 +129,14 @@ QModelIndex PieView::indexAt(const QPoint &point) const
|
||||
// Find the relevant slice of the pie.
|
||||
double startAngle = 0.0;
|
||||
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row)
|
||||
{
|
||||
|
||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||
double value = model()->data(index).toDouble();
|
||||
|
||||
if (value > 0.0) {
|
||||
if (value > 0.0)
|
||||
{
|
||||
double sliceAngle = 360 * value / totalValue;
|
||||
|
||||
if (angle >= startAngle && angle < (startAngle + sliceAngle))
|
||||
@ -140,15 +145,19 @@ QModelIndex PieView::indexAt(const QPoint &point) const
|
||||
startAngle += sliceAngle;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
double itemHeight = QFontMetrics(viewOptions().font).height();
|
||||
int listItem = int((wy - margin) / itemHeight);
|
||||
int validRow = 0;
|
||||
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row)
|
||||
{
|
||||
|
||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||
if (model()->data(index).toDouble() > 0.0) {
|
||||
if (model()->data(index).toDouble() > 0.0)
|
||||
{
|
||||
|
||||
if (listItem == validRow)
|
||||
return model()->index(row, 0, rootIndex());
|
||||
@ -191,19 +200,21 @@ QRect PieView::itemRect(const QModelIndex &index) const
|
||||
return QRect();
|
||||
|
||||
int listItem = 0;
|
||||
for (int row = index.row()-1; row >= 0; --row) {
|
||||
for (int row = index.row() - 1; row >= 0; --row)
|
||||
{
|
||||
if (model()->data(model()->index(row, 1, rootIndex())).toDouble() > 0.0)
|
||||
listItem++;
|
||||
}
|
||||
|
||||
double itemHeight;
|
||||
|
||||
switch (index.column()) {
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
itemHeight = QFontMetrics(viewOptions().font).height();
|
||||
|
||||
return QRect(totalSize,
|
||||
int(margin + listItem*itemHeight),
|
||||
int(margin + listItem * itemHeight),
|
||||
totalSize - margin, int(itemHeight));
|
||||
case 1:
|
||||
return viewport()->rect();
|
||||
@ -223,18 +234,21 @@ QRegion PieView::itemRegion(const QModelIndex &index) const
|
||||
return QRegion();
|
||||
|
||||
double startAngle = 0.0;
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||
for (int row = 0; row < model()->rowCount(rootIndex()); ++row)
|
||||
{
|
||||
|
||||
QModelIndex sliceIndex = model()->index(row, 1, rootIndex());
|
||||
double value = model()->data(sliceIndex).toDouble();
|
||||
|
||||
if (value > 0.0) {
|
||||
if (value > 0.0)
|
||||
{
|
||||
double angle = 360 * value / totalValue;
|
||||
|
||||
if (sliceIndex == index) {
|
||||
if (sliceIndex == index)
|
||||
{
|
||||
QPainterPath slicePath;
|
||||
slicePath.moveTo(totalSize / 2, totalSize / 2);
|
||||
slicePath.arcTo(margin, margin, margin+pieSize, margin+pieSize,
|
||||
slicePath.arcTo(margin, margin, margin + pieSize, margin + pieSize,
|
||||
startAngle, angle);
|
||||
slicePath.closeSubpath();
|
||||
|
||||
@ -283,26 +297,27 @@ QModelIndex PieView::moveCursor(QAbstractItemView::CursorAction cursorAction,
|
||||
{
|
||||
QModelIndex current = currentIndex();
|
||||
|
||||
switch (cursorAction) {
|
||||
case MoveLeft:
|
||||
case MoveUp:
|
||||
if (current.row() > 0)
|
||||
current = model()->index(current.row() - 1, current.column(),
|
||||
rootIndex());
|
||||
else
|
||||
current = model()->index(0, current.column(), rootIndex());
|
||||
break;
|
||||
case MoveRight:
|
||||
case MoveDown:
|
||||
if (current.row() < rows(current) - 1)
|
||||
current = model()->index(current.row() + 1, current.column(),
|
||||
rootIndex());
|
||||
else
|
||||
current = model()->index(rows(current) - 1, current.column(),
|
||||
rootIndex());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (cursorAction)
|
||||
{
|
||||
case MoveLeft:
|
||||
case MoveUp:
|
||||
if (current.row() > 0)
|
||||
current = model()->index(current.row() - 1, current.column(),
|
||||
rootIndex());
|
||||
else
|
||||
current = model()->index(0, current.column(), rootIndex());
|
||||
break;
|
||||
case MoveRight:
|
||||
case MoveDown:
|
||||
if (current.row() < rows(current) - 1)
|
||||
current = model()->index(current.row() + 1, current.column(),
|
||||
rootIndex());
|
||||
else
|
||||
current = model()->index(rows(current) - 1, current.column(),
|
||||
rootIndex());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
viewport()->update();
|
||||
@ -341,12 +356,14 @@ void PieView::paintEvent(QPaintEvent *event)
|
||||
double startAngle = 0.0;
|
||||
int row;
|
||||
|
||||
for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||
for (row = 0; row < model()->rowCount(rootIndex()); ++row)
|
||||
{
|
||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||
double value = model()->data(index).toDouble();
|
||||
|
||||
if (value > 0.0) {
|
||||
double angle = 360*value/totalValue;
|
||||
if (value > 0.0)
|
||||
{
|
||||
double angle = 360 * value / totalValue;
|
||||
|
||||
QModelIndex colorIndex = model()->index(row, 0, rootIndex());
|
||||
QColor color = QColor(model()->data(colorIndex, Qt::DecorationRole).toString());
|
||||
@ -358,7 +375,7 @@ void PieView::paintEvent(QPaintEvent *event)
|
||||
else
|
||||
painter.setBrush(QBrush(color));
|
||||
|
||||
painter.drawPie(0, 0, pieSize, pieSize, int(startAngle*16), int(angle*16));
|
||||
painter.drawPie(0, 0, pieSize, pieSize, int(startAngle * 16), int(angle * 16));
|
||||
|
||||
startAngle += angle;
|
||||
}
|
||||
@ -370,7 +387,7 @@ void PieView::paintEvent(QPaintEvent *event)
|
||||
//painter.drawEllipse(meowRect);
|
||||
QPoint p = pieRect.center();
|
||||
QPoint q(margin - 2, margin - 2);
|
||||
painter.drawEllipse(p -= q, pieSize/4, pieSize/4);
|
||||
painter.drawEllipse(p -= q, pieSize / 4, pieSize / 4);
|
||||
|
||||
painter.restore();
|
||||
}
|
||||
@ -387,11 +404,13 @@ int PieView::rows(const QModelIndex &index) const
|
||||
|
||||
void PieView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||
{
|
||||
for (int row = start; row <= end; ++row) {
|
||||
for (int row = start; row <= end; ++row)
|
||||
{
|
||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||
double value = model()->data(index).toDouble();
|
||||
|
||||
if (value > 0.0) {
|
||||
if (value > 0.0)
|
||||
{
|
||||
totalValue += value;
|
||||
++validItems;
|
||||
}
|
||||
@ -402,10 +421,12 @@ void PieView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||
|
||||
void PieView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
||||
{
|
||||
for (int row = start; row <= end; ++row) {
|
||||
for (int row = start; row <= end; ++row)
|
||||
{
|
||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||
double value = model()->data(index).toDouble();
|
||||
if (value > 0.0) {
|
||||
if (value > 0.0)
|
||||
{
|
||||
totalValue -= value;
|
||||
--validItems;
|
||||
}
|
||||
@ -424,19 +445,25 @@ void PieView::scrollTo(const QModelIndex &index, ScrollHint)
|
||||
QRect area = viewport()->rect();
|
||||
QRect rect = visualRect(index);
|
||||
|
||||
if (rect.left() < area.left()) {
|
||||
if (rect.left() < area.left())
|
||||
{
|
||||
horizontalScrollBar()->setValue(
|
||||
horizontalScrollBar()->value() + rect.left() - area.left());
|
||||
} else if (rect.right() > area.right()) {
|
||||
}
|
||||
else if (rect.right() > area.right())
|
||||
{
|
||||
horizontalScrollBar()->setValue(
|
||||
horizontalScrollBar()->value() + qMin(
|
||||
rect.right() - area.right(), rect.left() - area.left()));
|
||||
}
|
||||
|
||||
if (rect.top() < area.top()) {
|
||||
if (rect.top() < area.top())
|
||||
{
|
||||
verticalScrollBar()->setValue(
|
||||
verticalScrollBar()->value() + rect.top() - area.top());
|
||||
} else if (rect.bottom() > area.bottom()) {
|
||||
}
|
||||
else if (rect.bottom() > area.bottom())
|
||||
{
|
||||
verticalScrollBar()->setValue(
|
||||
verticalScrollBar()->value() + qMin(
|
||||
rect.bottom() - area.bottom(), rect.top() - area.top()));
|
||||
@ -457,15 +484,17 @@ void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlag
|
||||
// function to check for intersections.
|
||||
|
||||
QRect contentsRect = rect.translated(
|
||||
horizontalScrollBar()->value(),
|
||||
verticalScrollBar()->value()).normalized();
|
||||
horizontalScrollBar()->value(),
|
||||
verticalScrollBar()->value()).normalized();
|
||||
|
||||
int rows = model()->rowCount(rootIndex());
|
||||
int columns = model()->columnCount(rootIndex());
|
||||
QModelIndexList indexes;
|
||||
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int column = 0; column < columns; ++column) {
|
||||
for (int row = 0; row < rows; ++row)
|
||||
{
|
||||
for (int column = 0; column < columns; ++column)
|
||||
{
|
||||
QModelIndex index = model()->index(row, column, rootIndex());
|
||||
QRegion region = itemRegion(index);
|
||||
if (region.intersects(contentsRect))
|
||||
@ -473,13 +502,15 @@ void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlag
|
||||
}
|
||||
}
|
||||
|
||||
if (indexes.size() > 0) {
|
||||
if (indexes.size() > 0)
|
||||
{
|
||||
int firstRow = indexes[0].row();
|
||||
int lastRow = indexes[0].row();
|
||||
int firstColumn = indexes[0].column();
|
||||
int lastColumn = indexes[0].column();
|
||||
|
||||
for (int i = 1; i < indexes.size(); ++i) {
|
||||
for (int i = 1; i < indexes.size(); ++i)
|
||||
{
|
||||
firstRow = qMin(firstRow, indexes[i].row());
|
||||
lastRow = qMax(lastRow, indexes[i].row());
|
||||
firstColumn = qMin(firstColumn, indexes[i].column());
|
||||
@ -490,7 +521,9 @@ void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlag
|
||||
model()->index(firstRow, firstColumn, rootIndex()),
|
||||
model()->index(lastRow, lastColumn, rootIndex()));
|
||||
selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QModelIndex noIndex;
|
||||
QItemSelection selection(noIndex, noIndex);
|
||||
selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
@ -543,10 +576,13 @@ QRegion PieView::visualRegionForSelection(const QItemSelection &selection) const
|
||||
return QRect();
|
||||
|
||||
QRegion region;
|
||||
for (int i = 0; i < ranges; ++i) {
|
||||
for (int i = 0; i < ranges; ++i)
|
||||
{
|
||||
QItemSelectionRange range = selection.at(i);
|
||||
for (int row = range.top(); row <= range.bottom(); ++row) {
|
||||
for (int col = range.left(); col <= range.right(); ++col) {
|
||||
for (int row = range.top(); row <= range.bottom(); ++row)
|
||||
{
|
||||
for (int col = range.left(); col <= range.right(); ++col)
|
||||
{
|
||||
QModelIndex index = model()->index(row, col, rootIndex());
|
||||
region += visualRect(index);
|
||||
}
|
||||
@ -558,5 +594,5 @@ QRegion PieView::visualRegionForSelection(const QItemSelection &selection) const
|
||||
/*Function to find minimum of x and y*/
|
||||
int PieView::getMin(int x, int y)
|
||||
{
|
||||
return y ^ ((x ^ y) & -(x < y));
|
||||
return y ^ ((x ^ y) & -(x < y));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ protected:
|
||||
|
||||
bool isIndexHidden(const QModelIndex &index) const;
|
||||
|
||||
void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
|
||||
void setSelection(const QRect &, QItemSelectionModel::SelectionFlags command);
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
|
@ -6,8 +6,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class RelocsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class RelocsWidget;
|
||||
}
|
||||
|
||||
class RelocsWidget : public QDockWidget
|
||||
|
@ -25,7 +25,8 @@ void SdbDock::reload(QString path)
|
||||
QList<QString> keys;
|
||||
/* key-values */
|
||||
keys = main->core->sdbListKeys(path);
|
||||
foreach (QString key, keys) {
|
||||
foreach (QString key, keys)
|
||||
{
|
||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, key);
|
||||
tempItem->setText(1, main->core->sdbGet(path, key));
|
||||
@ -37,9 +38,10 @@ void SdbDock::reload(QString path)
|
||||
/* namespaces */
|
||||
keys = main->core->sdbList(path);
|
||||
keys.append("..");
|
||||
foreach (QString key, keys) {
|
||||
foreach (QString key, keys)
|
||||
{
|
||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, key+"/");
|
||||
tempItem->setText(0, key + "/");
|
||||
tempItem->setText(1, "");
|
||||
ui->treeWidget->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
@ -52,29 +54,39 @@ void SdbDock::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QString newpath;
|
||||
|
||||
if (column == 0) {
|
||||
if (item->text(0) == "../") {
|
||||
if (column == 0)
|
||||
{
|
||||
if (item->text(0) == "../")
|
||||
{
|
||||
int idx = path.lastIndexOf("/");
|
||||
if (idx != -1) {
|
||||
newpath = path.mid(0,idx);
|
||||
} else {
|
||||
if (idx != -1)
|
||||
{
|
||||
newpath = path.mid(0, idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
newpath = "";
|
||||
}
|
||||
reload (newpath);
|
||||
reload(newpath);
|
||||
|
||||
} else
|
||||
if (item->text(0).indexOf("/")!=-1) {
|
||||
if (path != "") {
|
||||
newpath = path +"/"+ item->text(0).replace ("/","");
|
||||
} else {
|
||||
newpath = path + item->text(0).replace ("/","");
|
||||
}
|
||||
// enter directory
|
||||
reload (newpath);
|
||||
}
|
||||
else if (item->text(0).indexOf("/") != -1)
|
||||
{
|
||||
if (path != "")
|
||||
{
|
||||
newpath = path + "/" + item->text(0).replace("/", "");
|
||||
}
|
||||
else {
|
||||
//__alert ("TODO: change value");
|
||||
else
|
||||
{
|
||||
newpath = path + item->text(0).replace("/", "");
|
||||
}
|
||||
// enter directory
|
||||
reload(newpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
//__alert ("TODO: change value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,19 +97,21 @@ SdbDock::~SdbDock()
|
||||
|
||||
void SdbDock::on_lockButton_clicked()
|
||||
{
|
||||
if(ui->lockButton->isChecked())
|
||||
if (ui->lockButton->isChecked())
|
||||
{
|
||||
this->setAllowedAreas(Qt::NoDockWidgetArea);
|
||||
ui->lockButton->setIcon( QIcon(":/new/prefix1/lock") );
|
||||
} else {
|
||||
ui->lockButton->setIcon(QIcon(":/new/prefix1/lock"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||
ui->lockButton->setIcon( QIcon(":/new/prefix1/unlock") );
|
||||
ui->lockButton->setIcon(QIcon(":/new/prefix1/unlock"));
|
||||
}
|
||||
}
|
||||
|
||||
void SdbDock::on_treeWidget_itemChanged(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
__alert (item->text(column));
|
||||
__alert(item->text(column));
|
||||
// El nuevo valor esta en:
|
||||
// item->text(column)
|
||||
// ya sabras tu que hacer con el :P
|
||||
|
@ -6,8 +6,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class SdbDock;
|
||||
namespace Ui
|
||||
{
|
||||
class SdbDock;
|
||||
}
|
||||
|
||||
class SdbDock : public QDockWidget
|
||||
|
@ -63,8 +63,8 @@ void SectionsWidget::setupViews()
|
||||
pieChart->setSelectionModel(selectionModel);
|
||||
}
|
||||
|
||||
void SectionsWidget::fillSections(int row, const QString &str, const QString &str2=NULL,
|
||||
const QString &str3=NULL, const QString &str4=NULL)
|
||||
void SectionsWidget::fillSections(int row, const QString &str, const QString &str2 = NULL,
|
||||
const QString &str3 = NULL, const QString &str4 = NULL)
|
||||
{
|
||||
QList<QString> colors;
|
||||
//colors << "#F7464A" << "#46BFBD" << "#FDB45C" << "#949FB1" << "#4D5360" << "#D97041" <<"#C7604C" << "#21323D" << "#9D9B7F" << "#7D4F6D" << "#584A5E";
|
||||
@ -85,28 +85,36 @@ void SectionsWidget::fillSections(int row, const QString &str, const QString &st
|
||||
tempItem->setText(1, str2);
|
||||
tempItem->setText(2, str3);
|
||||
tempItem->setText(3, str4);
|
||||
tempItem->setData( 0, Qt::DecorationRole, QColor(colors[row]));
|
||||
tempItem->setData(0, Qt::DecorationRole, QColor(colors[row]));
|
||||
this->tree->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
|
||||
void SectionsWidget::adjustColumns() {
|
||||
void SectionsWidget::adjustColumns()
|
||||
{
|
||||
int count = 4;
|
||||
for (int i = 0; i != count; ++i) {
|
||||
for (int i = 0; i != count; ++i)
|
||||
{
|
||||
this->tree->resizeColumnToContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool SectionsWidget::eventFilter(QObject *obj, QEvent *event) {
|
||||
if (this->main->responsive) {
|
||||
if (event->type() == QEvent::Resize && obj == this && this->isVisible()) {
|
||||
QResizeEvent *resizeEvent = static_cast<QResizeEvent*>(event);
|
||||
bool SectionsWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (this->main->responsive)
|
||||
{
|
||||
if (event->type() == QEvent::Resize && obj == this && this->isVisible())
|
||||
{
|
||||
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
|
||||
//qDebug("Dock Resized (New Size) - Width: %d Height: %d",
|
||||
// resizeEvent->size().width(),
|
||||
// resizeEvent->size().height());
|
||||
if (resizeEvent->size().width() >= resizeEvent->size().height()) {
|
||||
if (resizeEvent->size().width() >= resizeEvent->size().height())
|
||||
{
|
||||
// Set horizontal view (list)
|
||||
this->main->on_actionSectionsHorizontal_triggered();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set vertical view (Tree)
|
||||
this->main->on_actionSectionsVertical_triggered();
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ class QItemSelectionModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class SectionsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class SectionsWidget;
|
||||
}
|
||||
|
||||
class SectionsWidget : public QSplitter
|
||||
@ -25,7 +26,7 @@ class SectionsWidget : public QSplitter
|
||||
public:
|
||||
explicit SectionsWidget(MainWindow *main, QWidget *parent = 0);
|
||||
void fillSections(int row, const QString &str, const QString &str2,
|
||||
const QString &str3, const QString &str4);
|
||||
const QString &str3, const QString &str4);
|
||||
void adjustColumns();
|
||||
QTreeWidget *tree;
|
||||
|
||||
|
@ -14,14 +14,20 @@ SideBar::SideBar(MainWindow *main) :
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings;
|
||||
if (settings.value("responsive").toBool()) {
|
||||
if (settings.value("responsive").toBool())
|
||||
{
|
||||
ui->respButton->setChecked(true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->respButton->setChecked(false);
|
||||
}
|
||||
if (settings.value("dark").toBool()) {
|
||||
if (settings.value("dark").toBool())
|
||||
{
|
||||
ui->themesButton->setChecked(true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->themesButton->setChecked(false);
|
||||
}
|
||||
}
|
||||
@ -39,9 +45,12 @@ void SideBar::on_tabsButton_clicked()
|
||||
void SideBar::on_consoleButton_clicked()
|
||||
{
|
||||
this->main->on_actionhide_bottomPannel_triggered();
|
||||
if (ui->consoleButton->isChecked()) {
|
||||
if (ui->consoleButton->isChecked())
|
||||
{
|
||||
ui->consoleButton->setIcon(QIcon(":/new/prefix1/img/icons/up_white.png"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->consoleButton->setIcon(QIcon(":/new/prefix1/img/icons/down_white.png"));
|
||||
}
|
||||
}
|
||||
@ -53,25 +62,32 @@ void SideBar::on_webServerButton_clicked()
|
||||
|
||||
void SideBar::on_lockButton_clicked()
|
||||
{
|
||||
if(ui->lockButton->isChecked()) {
|
||||
ui->lockButton->setIcon( QIcon(":/new/prefix1/img/icons/unlock_white.png") );
|
||||
if (ui->lockButton->isChecked())
|
||||
{
|
||||
ui->lockButton->setIcon(QIcon(":/new/prefix1/img/icons/unlock_white.png"));
|
||||
this->main->lockUnlock_Docks(1);
|
||||
} else {
|
||||
ui->lockButton->setIcon( QIcon(":/new/prefix1/img/icons/lock_white.png") );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lockButton->setIcon(QIcon(":/new/prefix1/img/icons/lock_white.png"));
|
||||
this->main->lockUnlock_Docks(0);
|
||||
}
|
||||
}
|
||||
|
||||
void SideBar::themesButtonToggle() {
|
||||
void SideBar::themesButtonToggle()
|
||||
{
|
||||
ui->themesButton->click();
|
||||
}
|
||||
|
||||
void SideBar::on_themesButton_clicked()
|
||||
{
|
||||
if (ui->themesButton->isChecked() ) {
|
||||
if (ui->themesButton->isChecked())
|
||||
{
|
||||
// Dark theme
|
||||
this->main->dark();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear theme
|
||||
this->main->def_theme();
|
||||
}
|
||||
@ -79,7 +95,7 @@ void SideBar::on_themesButton_clicked()
|
||||
|
||||
void SideBar::on_calcInput_textChanged(const QString &arg1)
|
||||
{
|
||||
ui->calcOutput->setText(QString::number(this->main->core->math (arg1)));
|
||||
ui->calcOutput->setText(QString::number(this->main->core->math(arg1)));
|
||||
}
|
||||
|
||||
void SideBar::on_asm2hex_clicked()
|
||||
|
@ -5,8 +5,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class SideBar;
|
||||
namespace Ui
|
||||
{
|
||||
class SideBar;
|
||||
}
|
||||
|
||||
class SideBar : public QWidget
|
||||
|
@ -28,7 +28,7 @@ void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item
|
||||
// TODO: use this info to change disasm contents
|
||||
QString offset = item->text(1);
|
||||
QString name = item->text(2);
|
||||
this->main->seek (offset);
|
||||
this->main->seek(offset);
|
||||
// Rise and shine baby!
|
||||
this->main->memoryDock->raise();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class StringsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class StringsWidget;
|
||||
}
|
||||
|
||||
class StringsWidget : public QDockWidget
|
||||
|
@ -17,11 +17,13 @@ SymbolsWidget::~SymbolsWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SymbolsWidget::fillSymbols() {
|
||||
void SymbolsWidget::fillSymbols()
|
||||
{
|
||||
this->symbolsTreeWidget->clear();
|
||||
for (auto i: this->main->core->getList ("bin", "symbols")) {
|
||||
QStringList pieces = i.split (",");
|
||||
if (pieces.length()==3)
|
||||
for (auto i : this->main->core->getList("bin", "symbols"))
|
||||
{
|
||||
QStringList pieces = i.split(",");
|
||||
if (pieces.length() == 3)
|
||||
this->main->appendRow(this->symbolsTreeWidget, pieces[0], pieces[1], pieces[2]);
|
||||
}
|
||||
this->main->adjustColumns(this->symbolsTreeWidget);
|
||||
|
@ -6,8 +6,9 @@
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class SymbolsWidget;
|
||||
namespace Ui
|
||||
{
|
||||
class SymbolsWidget;
|
||||
}
|
||||
|
||||
class SymbolsWidget : public QDockWidget
|
||||
|
Loading…
Reference in New Issue
Block a user