Merge pull request #24 from mrexodia/windows

compile and run on Windows
This commit is contained in:
Hugo Teso 2017-03-31 11:08:01 +02:00 committed by GitHub
commit 4ff86cf42b
27 changed files with 149 additions and 103 deletions

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "iaito_win32"]
path = iaito_win32
url = https://github.com/mrexodia/iaito_win32
[submodule "radare2"]
path = radare2
url = https://github.com/radare/radare2

View File

@ -28,19 +28,19 @@ sys/install.sh
```
r2pm -i www-p
```
- QtCreator and Qt: Right now, Iaitō uses Qt 5.3 so the latest QtCreator needs to be installed and Q t5.3 added during the installation:
- QtCreator and Qt: Right now, Iaitō uses Qt 5.3 so the latest QtCreator needs to be installed and Qt 5.3 added during the installation:
- Download: https://www.qt.io/ide/
- Add Qt 5.3: http://doc.qt.io/qtcreator/creator-project-qmake.html
## Platforms
Iaitō is developed and tested in OS X and Linux, Windows will be added soon. The first release for users will include installers for all three platforms.
Iaitō is developed and tested in OS X, Linux and [Windows](https://github.com/hteso/iaito/wiki/Compiling-on-Windows). The first release for users will include installers for all three platforms.
## Documentation
Proper documentation and website will be created before the first release.
Roadmap information for developers can be found [here](https://github.com/hteso/iaito/wiki/Roadmap)
Roadmap information for developers can be found [here](https://github.com/hteso/iaito/wiki/Roadmap).
## Help

1
iaito_win32 Submodule

@ -0,0 +1 @@
Subproject commit 15d67a7acbbcef3e01acdb0a0986fe4d2468bb1f

1
radare2 Submodule

@ -0,0 +1 @@
Subproject commit 4715f1e2b9394aac832ff5f37e6a7504c59fd993

View File

@ -10,7 +10,11 @@ ICON = img/Enso.icns
TEMPLATE = app
# The application version
VERSION = 1.0-dev
win32 {
VERSION = 1.0
} else {
VERSION = 1.0-dev
}
# Define the preprocessor macro to get the application version in our application.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
@ -36,6 +40,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = iaito
TEMPLATE = app
INCLUDEPATH += ./
SOURCES += main.cpp\
mainwindow.cpp \
newfiledialog.cpp \
@ -130,8 +136,22 @@ FORMS += mainwindow.ui \
RESOURCES += \
resources.qrc
#INCLUDEPATH += /usr/local/radare2/osx/include/libr
INCLUDEPATH += /usr/local/include/libr
INCLUDEPATH += /usr/include/libr
#LIBS += -L/usr/local/radare2/osx/lib -lr_core -lr_config -lr_cons -lr_io -lr_util -lr_flag -lr_asm -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_socket -lr_fs -lr_magic -lr_crypto
LIBS += -L/usr/local/lib -lr_core -lr_config -lr_cons -lr_io -lr_util -lr_flag -lr_asm -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_socket -lr_fs -lr_magic -lr_crypto
win32 {
DEFINES += _CRT_NONSTDC_NO_DEPRECATE
DEFINES += _CRT_SECURE_NO_WARNINGS
INCLUDEPATH += "$$PWD/../iaito_win32/include"
INCLUDEPATH += "$$PWD/../iaito_win32/radare2/include/libr"
!contains(QMAKE_HOST.arch, x86_64) {
LIBS += -L"$$PWD/../iaito_win32/radare2/lib32"
} else {
LIBS += -L"$$PWD/../iaito_win32/radare2/lib64"
}
} else {
#INCLUDEPATH += /usr/local/radare2/osx/include/libr
INCLUDEPATH += /usr/local/include/libr
INCLUDEPATH += /usr/include/libr
#LIBS += -L/usr/local/radare2/osx/lib -lr_core -lr_config -lr_cons -lr_io -lr_util -lr_flag -lr_asm -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_socket -lr_fs -lr_magic -lr_crypto
LIBS += -L/usr/local/lib
}
LIBS += -lr_core -lr_config -lr_cons -lr_io -lr_util -lr_flag -lr_asm -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_socket -lr_fs -lr_magic -lr_crypto

View File

@ -2,11 +2,11 @@
#include <QDebug>
#include "mainwindow.h"
AnalThread::AnalThread(MainWindow *main, QWidget *parent) :
AnalThread::AnalThread(MainWindow *w, QWidget *parent) :
QThread(parent)
{
// Radare core found in:
this->main = main;
this->w = w;
//this->level = 2;
}
@ -14,5 +14,5 @@ AnalThread::AnalThread(MainWindow *main, QWidget *parent) :
void AnalThread::run()
{
//qDebug() << "Anal level: " << this->level;
this->main->core->analyze(this->level);
this->w->core->analyze(this->level);
}

View File

@ -9,13 +9,13 @@ class AnalThread : public QThread
{
Q_OBJECT
public:
explicit AnalThread(MainWindow *main, QWidget *parent = 0);
explicit AnalThread(MainWindow *w, QWidget *parent = 0);
void run();
int level;
private:
MainWindow *main;
MainWindow *w;
};
#endif // ANALTHREAD_H

View File

@ -9,6 +9,7 @@ createNewDialog::createNewDialog(QWidget *parent) :
ui(new Ui::createNewDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
w = new MainWindow(nullptr);
w->core = new QRCore ();
}
@ -65,13 +66,12 @@ void createNewDialog::on_buttonCreate_clicked()
bool created = false;
QString arch = ui->comboArch->currentText();
int bits = atoi (ui->comboBits->currentText().toStdString().c_str());
int fsize = r_num_math (NULL, ui->entrySize->text().toStdString().c_str());
int bits = atoi (ui->comboBits->currentText().toUtf8().constData());
int fsize = r_num_math (NULL, ui->entrySize->text().toUtf8().constData());
QString format = ui->comboFormat->currentText();
if (type == "Assembler") {
const char *asmcode = ui->plainTextEdit->toPlainText().toStdString().c_str();
RAsmCode *code = r_asm_massemble (w->core->core->assembler, asmcode);
RAsmCode *code = r_asm_massemble (w->core->core->assembler, ui->plainTextEdit->toPlainText().toUtf8().constData());
if (code && code->len>0) {
char file[32];
snprintf (file, sizeof(file)-1, "malloc://%d", code->len);
@ -91,8 +91,7 @@ void createNewDialog::on_buttonCreate_clicked()
created = true;
snprintf (file, sizeof(file)-1, "malloc://%d", fsize);
if (w->core->loadFile(file,0,0,1,0,0,false)) {
const char *rapatch = ui->plainTextEdit->toPlainText().toStdString().c_str();
r_core_patch (w->core->core, rapatch);
r_core_patch (w->core->core, ui->plainTextEdit->toPlainText().toUtf8().constData());
r_core_seek(w->core->core, 0, 1);
created = true;
} else {
@ -111,7 +110,7 @@ void createNewDialog::on_buttonCreate_clicked()
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().toStdString().c_str();
QString str = ui->plainTextEdit->toPlainText();
QList <QString> lines = str.split("\n");
foreach (QString str, lines) {
w->core->cmd(str);
@ -124,13 +123,13 @@ void createNewDialog::on_buttonCreate_clicked()
}
} else if (type == "Text") {
char file[32];
const char *hexpairs = ui->plainTextEdit->toPlainText().toStdString().c_str();
int sz = strlen (hexpairs);
QByteArray hexpairs = ui->plainTextEdit->toPlainText().toStdString().c_str();
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(w->core->core,0, (const ut8*)hexpairs, sz);
r_core_write_at(w->core->core,0, (const ut8*)hexpairs.constData(), sz);
} else {
__alert ("failed to open file");
}
@ -140,9 +139,9 @@ void createNewDialog::on_buttonCreate_clicked()
} else if (type == "Hexpairs") {
char file[32];
int sz;
const char *hexpairs = ui->plainTextEdit->toPlainText().toStdString().c_str();
ut8 *buf = (ut8*)malloc (strlen (hexpairs));
sz = r_hex_str2bin (hexpairs, buf);
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)) {

View File

@ -7,6 +7,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
ui->label->setText("<h1>Iaito</h1>"
"Version 1.0 alpha<br />"
"Using r2-" R2_VERSION

View File

@ -6,6 +6,7 @@ CommentsDialog::CommentsDialog(QWidget *parent) :
ui(new Ui::CommentsDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
}
CommentsDialog::~CommentsDialog()

View File

@ -6,6 +6,7 @@ RenameDialog::RenameDialog(QWidget *parent) :
ui(new Ui::RenameDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
}
RenameDialog::~RenameDialog()

View File

@ -8,6 +8,7 @@ XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) :
ui(new Ui::XrefsDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
this->main = main;
// Increase asm text edit margin

View File

@ -1,12 +1,36 @@
#include "mainwindow.h"
#include "newfiledialog.h"
#include <QApplication>
#include <QTextCodec>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationVersion(APP_VERSION);
// Set QString codec to UTF-8
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
#endif
// Check r2 version
QString r2version = r_core_version();
QString localVersion = "" R2_GITTAP;
if(r2version != localVersion)
{
QMessageBox msg;
msg.setIcon(QMessageBox::Critical);
msg.setWindowIcon(QIcon(":/new/prefix1/img/logo-small.png"));
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)
return 1;
}
NewFileDialog n;
n.show();
return a.exec();

View File

@ -20,6 +20,7 @@
#include <QFileDialog>
#include <QPropertyAnimation>
#include <QStyledItemDelegate>
#include <QProcess>
#include <QtGlobal>
#include <QToolTip>
@ -244,7 +245,7 @@ void MainWindow::start_web_server() {
// Start web server
thread.core = core;
thread.start();
sleep (1);
QThread::sleep (1);
if (core->core->http_up == R_FALSE) {
eprintf ("FAILED TO LAUNCH\n");
}
@ -834,7 +835,7 @@ void MainWindow::on_actionStart_Web_Server_triggered()
// Start web server
thread.core = core;
thread.start();
sleep (1);
QThread::sleep (1);
if (core->core->http_up==R_FALSE) {
eprintf ("FAILED TO LAUNCH\n");
}
@ -959,17 +960,8 @@ void MainWindow::add_debug_output(QString msg)
void MainWindow::on_actionNew_triggered()
{
QString path = qApp->applicationDirPath();
eprintf ("(((%s)))\n", path.toLocal8Bit().data());
int pid = fork();
if (pid==-1)
return;
if(!pid) {
QString cmd = path+ "/iaito";
system (cmd.toLocal8Bit().data());
exit(0);
}
exit(0);
qApp->quit();
on_actionLoad_triggered();
}
void MainWindow::on_actionSave_triggered()
@ -1016,15 +1008,10 @@ void MainWindow::on_actionSDB_browser_triggered()
void MainWindow::on_actionLoad_triggered()
{
QString path = qApp->applicationDirPath();
eprintf ("(((%s)))\n", path.toLocal8Bit().data());
int pid = fork();
if (pid==-1)
return;
if(!pid) {
QString cmd = path+ "/iaito";
exit(system (cmd.toLocal8Bit().data()));
}
QProcess* process = new QProcess(this);
process->setProgram(qApp->applicationFilePath());
process->setEnvironment(QProcess::systemEnvironment());
process->start();
}
void MainWindow::on_actionShow_Hide_mainsidebar_triggered()

View File

@ -45,6 +45,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
ui(new Ui::NewFileDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
ui->recentsList->addAction(ui->actionRemove_item);
ui->recentsList->addAction(ui->actionClear_all);
ui->recentsList->setIconSize(QSize(48, 48));

View File

@ -14,6 +14,7 @@ OptionsDialog::OptionsDialog(QWidget *parent):
this->anal_level = 0;
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
ui->progressBar->setVisible(0);
ui->statusLabel->setVisible(0);
@ -79,7 +80,7 @@ void OptionsDialog::on_okButton_clicked()
// Fill asm plugins in hexdump combo
this->w->memoryDock->fillPlugins(this->asm_plugins);
bool va = ui->vaCheckBox->isChecked();
int va = ui->vaCheckBox->isChecked();
ut64 loadaddr = 0LL;
ut64 mapaddr = 0LL;
int bits = 0;
@ -163,7 +164,7 @@ void OptionsDialog::on_okButton_clicked()
anal_level = ui->analCheckBox->isChecked();
this->w->add_output(" > Loading file: " + this->filename);
this->w->core->loadFile(this->filename.toUtf8(), loadaddr, mapaddr, rw, va, bits, binidx, load_bininfo);
this->w->core->loadFile(this->filename, loadaddr, mapaddr, rw, va, bits, binidx, load_bininfo);
//ui->progressBar->setValue(40);
ui->statusLabel->setText("Analysis in progress");

View File

@ -57,7 +57,7 @@ int QRCore::getCycloComplex(ut64 addr) {
QString ret = "";
RAnalFunction *fcn = r_anal_get_fcn_in(core->anal, addr, 0);
if (fcn) {
ret = cmd("afcc @ " + QString::fromUtf8(fcn->name));
ret = cmd("afcc @ " + QString(fcn->name));
return ret.toInt();
} else {
eprintf("qcore->getCycloComplex: no fcn found");
@ -70,7 +70,7 @@ int QRCore::getFcnSize(ut64 addr) {
QString tmp_ret = "";
RAnalFunction *fcn = r_anal_get_fcn_in(core->anal, addr, 0);
if (fcn) {
tmp_ret = cmd("afi~size[1] " + QString::fromUtf8(fcn->name));
tmp_ret = cmd("afi~size[1] " + QString(fcn->name));
ret = tmp_ret.split("\n")[0];
return ret.toInt()/10;
} else {
@ -81,13 +81,13 @@ int QRCore::getFcnSize(ut64 addr) {
QList<QString> QRCore::sdbList(QString path) {
QList<QString> list = QList<QString>();
Sdb *root = sdb_ns_path (core->sdb, path.toUtf8(), 0);
Sdb *root = sdb_ns_path (core->sdb, path.toUtf8().constData(), 0);
if (root) {
void *vsi;
ls_iter_t *iter;
ls_foreach(root->ns, iter, vsi) {
SdbNs *nsi = (SdbNs*)vsi;
list << QString::fromUtf8(nsi->name);
list << nsi->name;
}
}
return list;
@ -95,33 +95,33 @@ QList<QString> QRCore::sdbList(QString path) {
QList<QString> QRCore::sdbListKeys(QString path) {
QList<QString> list = QList<QString>();
Sdb *root = sdb_ns_path (core->sdb, path.toUtf8(), 0);
Sdb *root = sdb_ns_path (core->sdb, path.toUtf8().constData(), 0);
if (root) {
void *vsi;
ls_iter_t *iter;
SdbList *l = sdb_foreach_list(root, false);
ls_foreach(l, iter, vsi) {
SdbKv *nsi = (SdbKv*)vsi;
list << QString::fromUtf8(nsi->key);
list << nsi->key;
}
}
return list;
}
QString QRCore::sdbGet(QString path, QString key) {
Sdb *db = sdb_ns_path (core->sdb, path.toUtf8(), 0);
Sdb *db = sdb_ns_path (core->sdb, path.toUtf8().constData(), 0);
if (db) {
const char *val = sdb_const_get(db, key.toUtf8(), 0);
const char *val = sdb_const_get(db, key.toUtf8().constData(), 0);
if (val && *val)
return QString::fromUtf8(val);
return val;
}
return QString ("");
}
bool QRCore::sdbSet(QString path, QString key, QString val) {
Sdb *db = sdb_ns_path (core->sdb, path.toUtf8(), 1);
Sdb *db = sdb_ns_path (core->sdb, path.toUtf8().constData(), 1);
if (!db) return false;
return sdb_set (db, key.toUtf8(), val.toUtf8(), 0);
return sdb_set (db, key.toUtf8().constData(), val.toUtf8().constData(), 0);
}
QRCore::~QRCore() {
@ -130,26 +130,24 @@ QRCore::~QRCore() {
}
QString QRCore::cmd(const QString &str) {
std::string tmpstr = str.toStdString();
const char* cmd = tmpstr.c_str();
// const char *cmd = (const char *)str.toUtf8();
QByteArray cmd = str.toUtf8();
//r_cons_flush();
char *res = r_core_cmd_str (this->core, cmd);
QString o = (res && *res)? QString::fromUtf8(res): QString();
free (res);
char *res = r_core_cmd_str (this->core, cmd.constData());
QString o = QString(res ? res : "");
//r_mem_free was added in https://github.com/radare/radare2/commit/cd28744049492dc8ac25a1f2b3ba0e42f0e9ce93
r_mem_free(res);
return o;
}
bool QRCore::loadFile(QString path, uint64_t loadaddr=0LL, uint64_t mapaddr=0LL, bool rw=false, bool va=false, int bits = 0, int idx, bool loadbin) {
bool QRCore::loadFile(QString path, uint64_t loadaddr=0LL, uint64_t mapaddr=0LL, bool rw=false, int va=0, int bits = 0, int idx, bool loadbin) {
RCoreFile *f;
if (va==0 || va == 2)
r_config_set_i (core->config, "io.va", va);
// NO ONE KNOWS WHY THIS IS FIXING A SEGFAULT. core->file should have already a proper value. Pancake dixit
//core->file = NULL;
// mapaddr = 0LL;
char *paz = (char*)path.toStdString().c_str();
//printf ("FILE OPEN (%s)\n", paz);
f = r_core_file_open(core, path.toUtf8(), rw?(R_IO_READ|R_IO_WRITE):R_IO_READ, mapaddr);
printf ("FILE OPEN (%s)\n", path.toUtf8().constData());
f = r_core_file_open(core, path.toUtf8().constData(), rw?(R_IO_READ|R_IO_WRITE):R_IO_READ, mapaddr);
if (!f) {
eprintf ("r_core_file_open failed\n");
return false;
@ -157,7 +155,7 @@ bool QRCore::loadFile(QString path, uint64_t loadaddr=0LL, uint64_t mapaddr=0LL,
if (loadbin) {
if (va==1) {
if (r_core_bin_load (core, path.toUtf8(), UT64_MAX)) {
if (r_core_bin_load (core, path.toUtf8().constData(), UT64_MAX)) {
RBinObject *obj = r_bin_get_object(core->bin);
if (obj) {
eprintf ("BITS %d\n", obj->info->bits);
@ -166,7 +164,7 @@ bool QRCore::loadFile(QString path, uint64_t loadaddr=0LL, uint64_t mapaddr=0LL,
eprintf ("CANNOT GET RBIN INFO\n");
}
} else {
if (r_core_bin_load (core, path.toUtf8(), UT64_MAX)) {
if (r_core_bin_load (core, path.toUtf8().constData(), UT64_MAX)) {
RBinObject *obj = r_bin_get_object(core->bin);
if (obj) {
eprintf ("BITS %d\n", obj->info->bits);
@ -195,7 +193,7 @@ bool QRCore::loadFile(QString path, uint64_t loadaddr=0LL, uint64_t mapaddr=0LL,
} else {
// Not loading RBin info coz va = false
}
r_core_hash_load(core, path.toUtf8());
r_core_hash_load(core, path.toUtf8().constData());
fflush (stdout);
return true;
}
@ -272,7 +270,7 @@ QMap<QString, QList<QList<QString>>> QRCore::getNestedComments() {
void QRCore::seek(QString addr) {
if (addr.length()>0)
seek (this->math(addr.toUtf8()));
seek (this->math(addr.toUtf8().constData()));
}
void QRCore::seek(ut64 addr) {
@ -283,7 +281,7 @@ bool QRCore::tryFile(QString path, bool rw) {
RCoreFile *cf;
int flags = R_IO_READ;
if (rw) flags |= R_IO_WRITE;
cf = r_core_file_open (this->core, path.toUtf8(), flags, 0LL);
cf = r_core_file_open (this->core, path.toUtf8().constData(), flags, 0LL);
if (!cf) {
eprintf ("QRCore::tryFile: Cannot open file?\n");
return false;
@ -296,15 +294,14 @@ bool QRCore::tryFile(QString path, bool rw) {
sdb_bool_set (DB, "try.is_writable", is_writable, 0);
sdb_set (DB, "try.filetype", "elf.i386", 0);
sdb_set (DB, "try.filename", path.toUtf8(), 0);
sdb_set (DB, "try.filename", path.toUtf8().constData(), 0);
return true;
}
QList<QString> QRCore::getList(const QString type, const QString subtype) {
QList<QString> QRCore::getList(const QString & type, const QString & subtype) {
RListIter *it;
QList<QString> ret = QList<QString>();
if (this == NULL) return ret;
if (type == "bin") {
if (subtype == "sections") {
QString text = cmd ("S*~^S");
@ -420,7 +417,7 @@ QList<QString> QRCore::getList(const QString type, const QString subtype) {
}
ut64 QRCore::math(const QString &expr) {
return r_num_math (this->core?this->core->num:NULL, expr.toUtf8());
return r_num_math (this->core?this->core->num:NULL, expr.toUtf8().constData());
}
int QRCore::fcnCyclomaticComplexity(ut64 addr) {
@ -455,21 +452,21 @@ QString QRCore::itoa(ut64 num, int rdx) {
}
QString QRCore::config(const QString &k, const QString &v) {
const char *key = k.toUtf8().constData();
QByteArray key = k.toUtf8();
if (v!=NULL) {
r_config_set (core->config, key, v.toUtf8().constData());
r_config_set (core->config, key.constData(), v.toUtf8().constData());
return NULL;
}
return QString(r_config_get (core->config, key));
return QString(r_config_get (core->config, key.constData()));
}
int QRCore::config(const QString &k, int v) {
const char *key = k.toUtf8().constData();
QByteArray key = k.toUtf8();
if (v!=-1) {
r_config_set_i (core->config, key, v);
r_config_set_i (core->config, key.constData(), v);
return 0;
}
return r_config_get_i (core->config, key);
return r_config_get_i (core->config, key.constData());
}
void QRCore::setOptions(QString key) {

View File

@ -6,8 +6,19 @@
#include <QObject>
#include <QStringList>
#include <QMessageBox>
//Workaround for compile errors on Windows
#ifdef _WIN32
#include <r2hacks.h>
#endif //_WIN32
#include "r_core.h"
//Workaround for compile errors on Windows.
#ifdef _WIN32
#undef min
#endif //_WIN32
#define HAVE_LATEST_LIBR2 false
#define QRListForeach(list, it, type, x) \
@ -38,7 +49,7 @@ public:
QList<QList<QString>> getComments();
QMap<QString, QList<QList<QString> > > getNestedComments();
void setOptions(QString key);
bool loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, bool 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);
@ -47,7 +58,7 @@ public:
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();

View File

@ -28,7 +28,6 @@ CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
ui->frame->hide();
// Resize eventfilter
this->installEventFilter(this);
ui->commentsTreeWidget->viewport()->installEventFilter(this);
}

View File

@ -36,7 +36,7 @@ private slots:
void on_actionVertical_triggered();
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
private:
Ui::CommentsWidget *ui;

View File

@ -39,7 +39,6 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
this, SLOT(showTitleContextMenu(const QPoint &)));
// Resize eventfilter
this->installEventFilter(this);
ui->functionsTreeWidget->viewport()->installEventFilter(this);
}

View File

@ -41,7 +41,7 @@ private slots:
void on_nestedFunctionsTree_itemDoubleClicked(QTreeWidgetItem *item, int column);
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
private:
Ui::FunctionsWidget *ui;

View File

@ -99,7 +99,6 @@ MemoryWidget::MemoryWidget(MainWindow *main, QWidget *parent) :
ui->actionRight_align_bytes->setDisabled(true);
// Resize eventfilter
this->installEventFilter(this);
ui->disasTextEdit_2->viewport()->installEventFilter(this);
// Set Splitter stretch factor
@ -455,7 +454,7 @@ void MemoryWidget::refreshDisasm(QString off = "") {
this->disasTextEdit->ensureCursorVisible();
this->disasTextEdit->moveCursor(QTextCursor::End);
while ( this->disasTextEdit->find(QRegExp("^" + s), QTextDocument::FindBackward) ); {
while ( this->disasTextEdit->find(QRegExp("^" + s), QTextDocument::FindBackward) ) {
this->disasTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
}
@ -1382,7 +1381,7 @@ void MemoryWidget::setFcnName(QString addr) {
// TDOD: FIX ME, ugly
if (addr.contains("0x")) {
fcn = this->main->core->functionAt(addr.toULongLong(&ok, 16));
if (ok && fcn && fcn->name != "") {
if (ok && fcn) {
QString segment = this->main->core->cmd("S. @ " + addr).split(" ").last();
addr = segment.trimmed() + ":"+ fcn->name;
}
@ -1594,7 +1593,7 @@ void MemoryWidget::on_actionXRefs_triggered()
RAnalFunction *fcn = this->main->core->functionAt(ele.toLongLong(0, 16));
XrefsDialog* x = new XrefsDialog(this->main, this);
x->setWindowTitle("X-Refs for function " + QString::fromUtf8(fcn->name));
x->setWindowTitle("X-Refs for function " + QString(fcn->name));
// Get Refs and Xrefs
bool ok;

View File

@ -83,7 +83,7 @@ public slots:
void selectHexPreview();
protected:
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
private:
Ui::MemoryWidget *ui;

View File

@ -15,9 +15,6 @@ SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
//setStyleSheet("QSplitter::handle:horizontal { width: 3px; } QSplitter::handle:vertical { height: 3px; }");
setStyleSheet("QSplitter::handle { height: 2px; background-color: rgb(255, 255, 255); image: url(:/new/prefix1/img/icons/tabs.png); }");
// Resize eventfilter
this->installEventFilter(this);
}
/*

View File

@ -39,7 +39,7 @@ private:
QAbstractItemView *pieChart;
QItemSelectionModel *selectionModel;
MainWindow *main;
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
};
#endif // SECTIONSWIDGET_H

View File

@ -49,7 +49,7 @@ void SideBar::on_webServerButton_clicked()
// Start web server
thread.core = this->main->core;
thread.start();
sleep (1);
QThread::sleep (1);
if (this->main->core->core->http_up==R_FALSE) {
eprintf ("FAILED TO LAUNCH\n");
}