First code commit
First commit with the app code
BIN
Screenshots/Screenshot.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
136
src/Iaito.pro
Normal file
@ -0,0 +1,136 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-02-27T11:31:27
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
ICON = img/Enso.icns
|
||||
|
||||
# No idea what this does exactly
|
||||
TEMPLATE = app
|
||||
|
||||
# The application version
|
||||
VERSION = 1.0-dev
|
||||
|
||||
# Define the preprocessor macro to get the application version in our application.
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
||||
QT += core gui webkit webkitwidgets
|
||||
QT_CONFIG -= no-pkg-config
|
||||
|
||||
macx {
|
||||
QMAKE_CXXFLAGS = -mmacosx-version-min=10.7 -std=gnu0x -stdlib=libc+
|
||||
EXTSO=dylib
|
||||
} else {
|
||||
win32 {
|
||||
EXTSO=dll
|
||||
} else {
|
||||
EXTSO=so
|
||||
}
|
||||
}
|
||||
CONFIG += c++11
|
||||
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = Iaito
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
newfiledialog.cpp \
|
||||
optionsdialog.cpp \
|
||||
highlighter.cpp \
|
||||
qrcore.cpp \
|
||||
createnewdialog.cpp \
|
||||
hexascii_highlighter.cpp \
|
||||
webserverthread.cpp \
|
||||
widgets/pieview.cpp \
|
||||
widgets/sectionswidget.cpp \
|
||||
widgets/codegraphic.cpp \
|
||||
widgets/notepad.cpp \
|
||||
mdhighlighter.cpp \
|
||||
widgets/functionswidget.cpp \
|
||||
dialogs/renamedialog.cpp \
|
||||
dialogs/aboutdialog.cpp \
|
||||
widgets/importswidget.cpp \
|
||||
widgets/symbolswidget.cpp \
|
||||
widgets/relocswidget.cpp \
|
||||
widgets/commentswidget.cpp \
|
||||
widgets/stringswidget.cpp \
|
||||
widgets/flagswidget.cpp \
|
||||
widgets/memwidget/memorywidget.cpp \
|
||||
qrdisasm.cpp \
|
||||
widgets/sdbdock.cpp \
|
||||
analthread.cpp \
|
||||
dialogs/commentsdialog.cpp \
|
||||
widgets/sidebar.cpp \
|
||||
helpers.cpp \
|
||||
widgets/omnibar.cpp \
|
||||
widgets/dashboard.cpp \
|
||||
dialogs/xrefsdialog.cpp \
|
||||
hexhighlighter.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
newfiledialog.h \
|
||||
optionsdialog.h \
|
||||
highlighter.h \
|
||||
qrcore.h \
|
||||
createnewdialog.h \
|
||||
hexascii_highlighter.h \
|
||||
webserverthread.h \
|
||||
widgets/pieview.h \
|
||||
widgets/sectionswidget.h \
|
||||
widgets/codegraphic.h \
|
||||
widgets/notepad.h \
|
||||
mdhighlighter.h \
|
||||
widgets/functionswidget.h \
|
||||
dialogs/renamedialog.h \
|
||||
dialogs/aboutdialog.h \
|
||||
widgets/importswidget.h \
|
||||
widgets/symbolswidget.h \
|
||||
widgets/relocswidget.h \
|
||||
widgets/commentswidget.h \
|
||||
widgets/stringswidget.h \
|
||||
widgets/flagswidget.h \
|
||||
widgets/memwidget/memorywidget.h \
|
||||
qrdisasm.h \
|
||||
widgets/sdbdock.h \
|
||||
analthread.h \
|
||||
dialogs/commentsdialog.h \
|
||||
widgets/sidebar.h \
|
||||
helpers.h \
|
||||
widgets/omnibar.h \
|
||||
widgets/dashboard.h \
|
||||
dialogs/xrefsdialog.h \
|
||||
widgets/banned.h \
|
||||
hexhighlighter.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
newfiledialog.ui \
|
||||
optionsdialog.ui \
|
||||
createnewdialog.ui \
|
||||
widgets/notepad.ui \
|
||||
widgets/functionswidget.ui \
|
||||
dialogs/aboutdialog.ui \
|
||||
dialogs/renamedialog.ui \
|
||||
widgets/importswidget.ui \
|
||||
widgets/symbolswidget.ui \
|
||||
widgets/relocswidget.ui \
|
||||
widgets/commentswidget.ui \
|
||||
widgets/stringswidget.ui \
|
||||
widgets/flagswidget.ui \
|
||||
widgets/memwidget/memorywidget.ui \
|
||||
widgets/sdbdock.ui \
|
||||
dialogs/commentsdialog.ui \
|
||||
widgets/sidebar.ui \
|
||||
widgets/dashboard.ui \
|
||||
dialogs/xrefsdialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
#INCLUDEPATH += /usr/local/radare2/osx/include/libr
|
||||
INCLUDEPATH += /usr/local/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
|
18
src/analthread.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "analthread.h"
|
||||
#include <QDebug>
|
||||
#include "mainwindow.h"
|
||||
|
||||
AnalThread::AnalThread(MainWindow *main, QWidget *parent) :
|
||||
QThread(parent)
|
||||
{
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
//this->level = 2;
|
||||
}
|
||||
|
||||
// run() will be called when a thread starts
|
||||
void AnalThread::run()
|
||||
{
|
||||
//qDebug() << "Anal level: " << this->level;
|
||||
this->main->core->analyze(this->level);
|
||||
}
|
21
src/analthread.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef ANALTHREAD_H
|
||||
#define ANALTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class AnalThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AnalThread(MainWindow *main, QWidget *parent = 0);
|
||||
void run();
|
||||
int level;
|
||||
|
||||
private:
|
||||
|
||||
MainWindow *main;
|
||||
};
|
||||
|
||||
#endif // ANALTHREAD_H
|
183
src/createnewdialog.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
#include "createnewdialog.h"
|
||||
#include "ui_createnewdialog.h"
|
||||
#include <QMessageBox>
|
||||
#include "newfiledialog.h"
|
||||
#include "r_util.h"
|
||||
|
||||
createNewDialog::createNewDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::createNewDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
w = new MainWindow(this);
|
||||
w->core = new QRCore ();
|
||||
}
|
||||
|
||||
createNewDialog::~createNewDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void createNewDialog::on_pushButton_2_clicked()
|
||||
{
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
NewFileDialog* n = new NewFileDialog(this);
|
||||
n->show();
|
||||
}
|
||||
|
||||
void createNewDialog::on_pushButton_3_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void createNewDialog::on_exampleButton_clicked()
|
||||
{
|
||||
QString type = ui->comboType->currentText();
|
||||
QString str;
|
||||
if (type == "Assembler") {
|
||||
str = "; Sample program code\nmov eax, 1\nint 0x80";
|
||||
} else if (type == "Text") {
|
||||
str = "Hello World";
|
||||
} else if (type == "Rapatch") {
|
||||
str = "; Sample rapatch script\n"
|
||||
"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") {
|
||||
str = "w Hello\ns+5\nw World";
|
||||
} else if (type == "Hexpairs") {
|
||||
str = "48656c6c6f20576f726c6400";
|
||||
} else fprintf (stderr, "Unknown combo value selected");
|
||||
if (str.length()>0)
|
||||
ui->plainTextEdit->setPlainText(str);
|
||||
// }
|
||||
}
|
||||
|
||||
void createNewDialog::on_buttonCreate_clicked()
|
||||
{
|
||||
QString type = ui->comboType->currentText();
|
||||
QString str;
|
||||
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());
|
||||
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);
|
||||
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)) {
|
||||
created = true;
|
||||
r_core_write_at(w->core->core,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) {
|
||||
char file[32];
|
||||
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_seek(w->core->core, 0, 1);
|
||||
created = true;
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
}
|
||||
} 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) {
|
||||
char file[32];
|
||||
created = true;
|
||||
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();
|
||||
QList <QString> lines = str.split("\n");
|
||||
foreach (QString str, lines) {
|
||||
w->core->cmd(str);
|
||||
}
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Invalid file size");
|
||||
}
|
||||
} else if (type == "Text") {
|
||||
char file[32];
|
||||
const char *hexpairs = ui->plainTextEdit->toPlainText().toStdString().c_str();
|
||||
int sz = strlen (hexpairs);
|
||||
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);
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
}
|
||||
} else {
|
||||
__alert ("Empty string?");
|
||||
}
|
||||
} 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);
|
||||
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, buf, sz);
|
||||
} else {
|
||||
__alert ("failed to open file");
|
||||
}
|
||||
} 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");
|
||||
created = false;
|
||||
delete w->core;
|
||||
}
|
||||
|
||||
if (created) {
|
||||
|
||||
// Close dialog and open OptionsDialog
|
||||
close();
|
||||
|
||||
w->core->seek(0);
|
||||
w->updateFrames();
|
||||
w->setFilename("-");
|
||||
w->add_output("Finished, check its contents");
|
||||
w->showMaximized();
|
||||
} else {
|
||||
__alert ("No file created.");
|
||||
|
||||
}
|
||||
}
|
33
src/createnewdialog.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef CREATENEWDIALOG_H
|
||||
#define CREATENEWDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "mainwindow.h"
|
||||
|
||||
namespace Ui {
|
||||
class createNewDialog;
|
||||
}
|
||||
|
||||
class createNewDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit createNewDialog(QWidget *parent = 0);
|
||||
~createNewDialog();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
void on_exampleButton_clicked();
|
||||
|
||||
void on_buttonCreate_clicked();
|
||||
|
||||
private:
|
||||
Ui::createNewDialog *ui;
|
||||
MainWindow* w;
|
||||
};
|
||||
|
||||
#endif // CREATENEWDIALOG_H
|
458
src/createnewdialog.ui
Normal file
@ -0,0 +1,458 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>createNewDialog</class>
|
||||
<widget class="QDialog" name="createNewDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>587</width>
|
||||
<height>474</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="resources.qrc">:/new/prefix1/img/logo-small.png</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"> Create new file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Architecture:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboArch">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>arm</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>bf</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dalvik</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dcpu16</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>java</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>mips</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ppc</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>psosvm</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>rar</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>x86</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>z80</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Bits:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBits">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>16</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>32</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>64</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Binary format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboFormat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Raw</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ELF</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>PE</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>MACH-0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>COFF</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Plan9</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="entrySize">
|
||||
<property name="inputMask">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">0</string>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Input type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboType">
|
||||
<property name="currentText">
|
||||
<string>Text</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Text</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Hexpairs</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Assembler</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Radare2 script</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rapatch</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>C Code</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exampleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true">Fill the textarea with example code</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Example</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonCreate">
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
27
src/dialogs/aboutdialog.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "aboutdialog.h"
|
||||
#include "ui_aboutdialog.h"
|
||||
#include "r_userconf.h"
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AboutDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->label->setText("<h1>Iaito</h1>"
|
||||
"Version 1.0 alpha<br />"
|
||||
"Using r2-" R2_VERSION
|
||||
"<h2>License</h2>"
|
||||
"This Software is released under the GNU General Public License v3.0"
|
||||
"<h2>Authors</h2>"
|
||||
"Hugo Teso <hugo.teso@gmail.org>\nSoon to be thousands more!");
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AboutDialog::on_buttonBox_rejected()
|
||||
{
|
||||
close();
|
||||
}
|
25
src/dialogs/aboutdialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef ABOUTDIALOG_H
|
||||
#define ABOUTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
}
|
||||
|
||||
class AboutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutDialog(QWidget *parent = 0);
|
||||
~AboutDialog();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
Ui::AboutDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ABOUTDIALOG_H
|
99
src/dialogs/aboutdialog.ui
Normal file
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AboutDialog</class>
|
||||
<widget class="QDialog" name="AboutDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="aboutLogo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../resources.qrc">:/new/prefix1/img/logo-small.png</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
29
src/dialogs/commentsdialog.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "commentsdialog.h"
|
||||
#include "ui_commentsdialog.h"
|
||||
|
||||
CommentsDialog::CommentsDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CommentsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CommentsDialog::~CommentsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CommentsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
// Meow
|
||||
}
|
||||
|
||||
void CommentsDialog::on_buttonBox_rejected()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
QString CommentsDialog::getComment() {
|
||||
QString ret = ui->lineEdit->text();
|
||||
return ret;
|
||||
}
|
29
src/dialogs/commentsdialog.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef COMMENTSDIALOG_H
|
||||
#define COMMENTSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class CommentsDialog;
|
||||
}
|
||||
|
||||
class CommentsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CommentsDialog(QWidget *parent = 0);
|
||||
~CommentsDialog();
|
||||
|
||||
QString getComment();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
Ui::CommentsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // COMMENTSDIALOG_H
|
109
src/dialogs/commentsdialog.ui
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CommentsDialog</class>
|
||||
<widget class="QDialog" name="CommentsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CommentsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CommentsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
36
src/dialogs/renamedialog.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "renamedialog.h"
|
||||
#include "ui_renamedialog.h"
|
||||
|
||||
RenameDialog::RenameDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::RenameDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
RenameDialog::~RenameDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void RenameDialog::on_buttonBox_accepted()
|
||||
{
|
||||
// Rename function and refresh widgets
|
||||
QString name = ui->nameEdit->text();
|
||||
}
|
||||
|
||||
void RenameDialog::on_buttonBox_rejected()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void RenameDialog::setFunctionName(QString fcnName)
|
||||
{
|
||||
ui->nameEdit->setText(fcnName);
|
||||
}
|
||||
|
||||
QString RenameDialog::getFunctionName()
|
||||
{
|
||||
QString ret = ui->nameEdit->text();
|
||||
return ret;
|
||||
}
|
30
src/dialogs/renamedialog.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef RENAMEDIALOG_H
|
||||
#define RENAMEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class RenameDialog;
|
||||
}
|
||||
|
||||
class RenameDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RenameDialog(QWidget *parent = 0);
|
||||
~RenameDialog();
|
||||
|
||||
void setFunctionName(QString fcnName);
|
||||
QString getFunctionName();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
Ui::RenameDialog *ui;
|
||||
};
|
||||
|
||||
#endif // RENAMEDIALOG_H
|
112
src/dialogs/renamedialog.ui
Normal file
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RenameDialog</class>
|
||||
<widget class="QDialog" name="RenameDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>75</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Rename function</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string>Function name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="nameEdit">
|
||||
<property name="inputMask">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RenameDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RenameDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
132
src/dialogs/xrefsdialog.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
#include "xrefsdialog.h"
|
||||
#include "ui_xrefsdialog.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::XrefsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->main = main;
|
||||
|
||||
// Increase asm text edit margin
|
||||
QTextDocument *asm_docu = ui->previewTextEdit->document();
|
||||
asm_docu->setDocumentMargin(10);
|
||||
|
||||
// Syntax highlight
|
||||
highlighter = new Highlighter(this->main, ui->previewTextEdit->document());
|
||||
|
||||
// Highlight current line
|
||||
connect(ui->previewTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
|
||||
}
|
||||
|
||||
XrefsDialog::~XrefsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void XrefsDialog::fillRefs(QList<QStringList> refs, QList<QStringList> xrefs) {
|
||||
ui->fromTreeWidget->clear();
|
||||
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));
|
||||
tempItem->setText(1, refs.at(i).at(1));
|
||||
//tempItem->setToolTip( 0, this->main->core->cmd("pdi 10 @ " + refs.at(i).at(0)) );
|
||||
//tempItem->setToolTip( 1, this->main->core->cmd("pdi 10 @ " + refs.at(i).at(0)) );
|
||||
ui->fromTreeWidget->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
// Adjust columns to content
|
||||
int count = ui->fromTreeWidget->columnCount();
|
||||
for (int i = 0; i != count; ++i) {
|
||||
ui->fromTreeWidget->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
ui->toTreeWidget->clear();
|
||||
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));
|
||||
tempItem->setText(1, xrefs.at(i).at(1));
|
||||
//tempItem->setToolTip( 0, this->main->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) );
|
||||
//tempItem->setToolTip( 1, this->main->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) );
|
||||
ui->toTreeWidget->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
// Adjust columns to content
|
||||
int count2 = ui->toTreeWidget->columnCount();
|
||||
for (int i = 0; i != count2; ++i) {
|
||||
ui->toTreeWidget->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QString offset = item->text(0);
|
||||
RAnalFunction *fcn = this->main->core->functionAt(offset.toLongLong(0, 16));
|
||||
//this->add_debug_output( fcn->name );
|
||||
this->main->seek(offset, fcn->name);
|
||||
this->close();
|
||||
}
|
||||
|
||||
void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
QString offset = item->text(0);
|
||||
RAnalFunction *fcn = this->main->core->functionAt(offset.toLongLong(0, 16));
|
||||
//this->add_debug_output( fcn->name );
|
||||
this->main->seek(offset, fcn->name);
|
||||
this->close();
|
||||
}
|
||||
|
||||
QString XrefsDialog::normalizeAddr(QString addr) {
|
||||
QString base = addr.split("0x")[1].trimmed();
|
||||
int len = base.length();
|
||||
if (len < 8) {
|
||||
int padding = 8 - len;
|
||||
QString zero = "0";
|
||||
QString zeroes = zero.repeated(padding);
|
||||
QString s = "0x" + zeroes + base;
|
||||
return s;
|
||||
} else {
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
void XrefsDialog::highlightCurrentLine() {
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
|
||||
if (ui->previewTextEdit->isReadOnly()) {
|
||||
QTextEdit::ExtraSelection selection;
|
||||
|
||||
QColor lineColor = QColor(190, 144, 212);
|
||||
|
||||
selection.format.setBackground(lineColor);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||
selection.cursor = ui->previewTextEdit->textCursor();
|
||||
selection.cursor.clearSelection();
|
||||
extraSelections.append(selection);
|
||||
|
||||
ui->previewTextEdit->setExtraSelections(extraSelections);
|
||||
}
|
||||
}
|
||||
|
||||
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->moveCursor(QTextCursor::End);
|
||||
int pos = ui->previewTextEdit->find( this->normalizeAddr(offset), QTextDocument::FindBackward);
|
||||
ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
|
||||
}
|
||||
|
||||
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->moveCursor(QTextCursor::End);
|
||||
int pos = ui->previewTextEdit->find( this->normalizeAddr(offset), QTextDocument::FindBackward);
|
||||
ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
|
||||
}
|
46
src/dialogs/xrefsdialog.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef XREFSDIALOG_H
|
||||
#define XREFSDIALOG_H
|
||||
|
||||
#include "highlighter.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class XrefsDialog;
|
||||
}
|
||||
|
||||
class XrefsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XrefsDialog(MainWindow *main, QWidget *parent = 0);
|
||||
~XrefsDialog();
|
||||
|
||||
void fillRefs(QList<QStringList> refs, QList<QStringList> xrefs);
|
||||
|
||||
private slots:
|
||||
|
||||
void on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
void on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
QString normalizeAddr(QString addr);
|
||||
|
||||
void highlightCurrentLine();
|
||||
void on_fromTreeWidget_itemSelectionChanged();
|
||||
|
||||
void on_toTreeWidget_itemSelectionChanged();
|
||||
|
||||
private:
|
||||
Ui::XrefsDialog *ui;
|
||||
MainWindow *main;
|
||||
|
||||
Highlighter *highlighter;
|
||||
|
||||
};
|
||||
|
||||
#endif // XREFSDIALOG_H
|
198
src/dialogs/xrefsdialog.ui
Normal file
@ -0,0 +1,198 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>XrefsDialog</class>
|
||||
<widget class="QDialog" name="XrefsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>350</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">XRefs for </string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="handleWidth">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string notr="true">X-Refs to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="toTreeWidget">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Code</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string notr="true">X-Refs from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="fromTreeWidget">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Code</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string notr="true">Code preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="previewTextEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Anonymous Pro</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>XrefsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>XrefsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
BIN
src/fonts/Anonymous Pro.ttf
Normal file
BIN
src/fonts/Inconsolata-Regular.ttf
Normal file
31
src/helpers.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "helpers.h"
|
||||
|
||||
QHelpers::QHelpers(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
// Meow
|
||||
}
|
||||
|
||||
void QHelpers::normalizeFont(QPlainTextEdit *edit) {
|
||||
#ifdef Q_OS_LINUX
|
||||
// Add custom monospaced font
|
||||
QFontDatabase fontDB;
|
||||
fontDB.addApplicationFont(":/new/prefix1/fonts/Inconsolata-Regular.ttf");
|
||||
|
||||
QFont anonFont("Inconsolata", 12);
|
||||
QTextDocument *out_doc = edit->document();
|
||||
out_doc->setDefaultFont(anonFont);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QHelpers::normalizeEditFont(QTextEdit *edit) {
|
||||
#ifdef Q_OS_LINUX
|
||||
// Add custom monospaced font
|
||||
QFontDatabase fontDB;
|
||||
fontDB.addApplicationFont(":/new/prefix1/fonts/Inconsolata-Regular.ttf");
|
||||
|
||||
QFont anonFont("Inconsolata", 12);
|
||||
QTextDocument *out_doc = edit->document();
|
||||
out_doc->setDefaultFont(anonFont);
|
||||
#endif
|
||||
}
|
24
src/helpers.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef QHELPERS_H
|
||||
#define QHELPERS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTextEdit>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
class QHelpers : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QHelpers(QObject *parent = 0);
|
||||
void normalizeFont(QPlainTextEdit *edit);
|
||||
void normalizeEditFont(QTextEdit *edit);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // HELPERS_H
|
49
src/hexascii_highlighter.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include <QtGui>
|
||||
|
||||
#include "hexascii_highlighter.h"
|
||||
|
||||
AsciiHighlighter::AsciiHighlighter(QTextDocument *parent)
|
||||
: QSyntaxHighlighter(parent)
|
||||
{
|
||||
HighlightingRule rule;
|
||||
|
||||
asciiFormat.setForeground(QColor(65, 131, 215));
|
||||
rule.pattern = QRegExp("\\b[A-Za-z0-9]+\\b");
|
||||
rule.format = asciiFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
commentStartExpression = QRegExp("/\\*");
|
||||
commentEndExpression = QRegExp("\\*/");
|
||||
}
|
||||
|
||||
void AsciiHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
setCurrentBlockState(0);
|
||||
|
||||
int startIndex = 0;
|
||||
if (previousBlockState() != 1)
|
||||
startIndex = commentStartExpression.indexIn(text);
|
||||
|
||||
while (startIndex >= 0) {
|
||||
int endIndex = commentEndExpression.indexIn(text, startIndex);
|
||||
int commentLength;
|
||||
if (endIndex == -1) {
|
||||
setCurrentBlockState(1);
|
||||
commentLength = text.length() - startIndex;
|
||||
} else {
|
||||
commentLength = endIndex - startIndex
|
||||
+ commentEndExpression.matchedLength();
|
||||
}
|
||||
setFormat(startIndex, commentLength, multiLineCommentFormat);
|
||||
startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
|
||||
}
|
||||
}
|
40
src/hexascii_highlighter.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef ASCIIHIGHLIGHTER_H
|
||||
#define ASCIIHIGHLIGHTER_H
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
#include <QHash>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
class QTextDocument;
|
||||
|
||||
class AsciiHighlighter : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AsciiHighlighter(QTextDocument *parent = 0);
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString &text);
|
||||
|
||||
private:
|
||||
struct HighlightingRule
|
||||
{
|
||||
QRegExp pattern;
|
||||
QTextCharFormat format;
|
||||
};
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
|
||||
QRegExp commentStartExpression;
|
||||
QRegExp commentEndExpression;
|
||||
|
||||
QTextCharFormat keywordFormat;
|
||||
QTextCharFormat classFormat;
|
||||
QTextCharFormat singleLineCommentFormat;
|
||||
QTextCharFormat multiLineCommentFormat;
|
||||
QTextCharFormat quotationFormat;
|
||||
QTextCharFormat asciiFormat;
|
||||
};
|
||||
|
||||
#endif // ASCIIHIGHLIGHTER_H
|
76
src/hexhighlighter.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include <QtGui>
|
||||
|
||||
#include "hexhighlighter.h"
|
||||
|
||||
HexHighlighter::HexHighlighter(QTextDocument *parent)
|
||||
: QSyntaxHighlighter(parent)
|
||||
{
|
||||
HighlightingRule rule;
|
||||
|
||||
keywordFormat.setForeground(QColor(65, 131, 215));
|
||||
keywordFormat.setFontWeight(QFont::Bold);
|
||||
QStringList keywordPatterns;
|
||||
// I know, your eyes are bleeding, mine too
|
||||
keywordPatterns << "\\b20\\b" << "\\b21\\b" << "\\b22\\b" << "\\b23\\b" << "\\b24\\b" << "\\b25\\b" << "\\b26\\b"
|
||||
<< "\\b27\\b" << "\\b28\\b" << "\\b29\\b" << "\\b2a\\b" << "\\b2b\\b" << "\\b2c\\b" << "\\b2d\\b"
|
||||
<< "\\b2e\\b" << "\\b2f\\b" << "\\b30\\b" << "\\b31\\b" << "\\b32\\b" << "\\b33\\b" << "\\b34\\b"
|
||||
<< "\\b35\\b" << "\\b36\\b" << "\\b37\\b" << "\\b38\\b" << "\\b39\\b" << "\\b3a\\b" << "\\b3b\\b"
|
||||
<< "\\b3c\\b" << "\\b3d\\b" << "\\b3e\\b" << "\\b3f\\b" << "\\b41\\b" << "\\b42\\b" << "\\b43\\b"
|
||||
<< "\\b44\\b" << "\\b45\\b" << "\\b46\\b" << "\\b47\\b" << "\\b48\\b" << "\\b49\\b" << "\\b4a\\b"
|
||||
<< "\\b4b\\b" << "\\b4c\\b" << "\\b4d\\b" << "\\b4e\\b" << "\\b4f\\b" << "\\b50\\b" << "\\b51\\b"
|
||||
<< "\\b52\\b" << "\\b53\\b" << "\\b54\\b" << "\\b55\\b" << "\\b56\\b" << "\\b57\\b" << "\\b58\\b"
|
||||
<< "\\b59\\b" << "\\b5a\\b" << "\\b5b\\b" << "\\b5c\\b" << "\\b5d\\b" << "\\b5e\\b" << "\\b5f\\b"
|
||||
<< "\\b60\\b" << "\\b61\\b" << "\\b62\\b" << "\\b63\\b" << "\\b64\\b" << "\\b65\\b" << "\\b66\\b"
|
||||
<< "\\b67\\b" << "\\b68\\b" << "\\b69\\b" << "\\b6a\\b" << "\\b6b\\b" << "\\b6c\\b" << "\\b6d\\b"
|
||||
<< "\\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) {
|
||||
rule.pattern = QRegExp(pattern);
|
||||
rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
rule.format = keywordFormat;
|
||||
highlightingRules.append(rule);
|
||||
}
|
||||
|
||||
singleLineCommentFormat.setFontWeight(QFont::Bold);
|
||||
singleLineCommentFormat.setForeground(Qt::darkGreen);
|
||||
rule.pattern = QRegExp(";[^\n]*");
|
||||
rule.format = singleLineCommentFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
commentStartExpression = QRegExp("/\\*");
|
||||
commentEndExpression = QRegExp("\\*/");
|
||||
}
|
||||
|
||||
void HexHighlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
setCurrentBlockState(0);
|
||||
|
||||
int startIndex = 0;
|
||||
if (previousBlockState() != 1)
|
||||
startIndex = commentStartExpression.indexIn(text);
|
||||
|
||||
while (startIndex >= 0) {
|
||||
int endIndex = commentEndExpression.indexIn(text, startIndex);
|
||||
int commentLength;
|
||||
if (endIndex == -1) {
|
||||
setCurrentBlockState(1);
|
||||
commentLength = text.length() - startIndex;
|
||||
} else {
|
||||
commentLength = endIndex - startIndex
|
||||
+ commentEndExpression.matchedLength();
|
||||
}
|
||||
setFormat(startIndex, commentLength, multiLineCommentFormat);
|
||||
startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
|
||||
}
|
||||
}
|
||||
|
40
src/hexhighlighter.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef HEXHIGHLIGHTER_H
|
||||
#define HEXHIGHLIGHTER_H
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
#include <QHash>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
class QTextDocument;
|
||||
|
||||
class HexHighlighter : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HexHighlighter(QTextDocument *parent = 0);
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString &text);
|
||||
|
||||
private:
|
||||
struct HighlightingRule
|
||||
{
|
||||
QRegExp pattern;
|
||||
QTextCharFormat format;
|
||||
};
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
|
||||
QRegExp commentStartExpression;
|
||||
QRegExp commentEndExpression;
|
||||
|
||||
QTextCharFormat keywordFormat;
|
||||
QTextCharFormat classFormat;
|
||||
QTextCharFormat singleLineCommentFormat;
|
||||
QTextCharFormat multiLineCommentFormat;
|
||||
QTextCharFormat quotationFormat;
|
||||
QTextCharFormat functionFormat;
|
||||
};
|
||||
|
||||
#endif // HEXHIGHLIGHTER_H
|
75
src/highlighter.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include <QtGui>
|
||||
|
||||
#include "highlighter.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
Highlighter::Highlighter(MainWindow *main, QTextDocument *parent) :
|
||||
QSyntaxHighlighter(parent)
|
||||
{
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
|
||||
HighlightingRule rule;
|
||||
|
||||
keywordFormat.setForeground(QColor(65, 131, 215));
|
||||
keywordFormat.setFontWeight(QFont::Bold);
|
||||
|
||||
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.setFontWeight(QFont::Bold);
|
||||
|
||||
foreach (const QString &pattern, this->main->core->regs) {
|
||||
rule.pattern = QRegExp("\\b" + pattern + "\\b");
|
||||
rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
rule.format = regFormat;
|
||||
highlightingRules.append(rule);
|
||||
}
|
||||
|
||||
|
||||
singleLineCommentFormat.setFontWeight(QFont::Bold);
|
||||
singleLineCommentFormat.setForeground(QColor(63, 195, 128));
|
||||
rule.pattern = QRegExp(";[^\n]*");
|
||||
rule.format = singleLineCommentFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
commentStartExpression = QRegExp("/\\*");
|
||||
commentEndExpression = QRegExp("\\*/");
|
||||
}
|
||||
|
||||
void Highlighter::highlightBlock(const QString &text)
|
||||
{
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
setCurrentBlockState(0);
|
||||
|
||||
int startIndex = 0;
|
||||
if (previousBlockState() != 1)
|
||||
startIndex = commentStartExpression.indexIn(text);
|
||||
|
||||
while (startIndex >= 0) {
|
||||
int endIndex = commentEndExpression.indexIn(text, startIndex);
|
||||
int commentLength;
|
||||
if (endIndex == -1) {
|
||||
setCurrentBlockState(1);
|
||||
commentLength = text.length() - startIndex;
|
||||
} else {
|
||||
commentLength = endIndex - startIndex
|
||||
+ commentEndExpression.matchedLength();
|
||||
}
|
||||
setFormat(startIndex, commentLength, multiLineCommentFormat);
|
||||
startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
|
||||
}
|
||||
}
|
44
src/highlighter.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef HIGHLIGHTER_H
|
||||
#define HIGHLIGHTER_H
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
#include <QHash>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
class QTextDocument;
|
||||
class MainWindow;
|
||||
|
||||
class Highlighter : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Highlighter(MainWindow *main, QTextDocument *parent = 0);
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString &text);
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
|
||||
struct HighlightingRule
|
||||
{
|
||||
QRegExp pattern;
|
||||
QTextCharFormat format;
|
||||
};
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
|
||||
QRegExp commentStartExpression;
|
||||
QRegExp commentEndExpression;
|
||||
|
||||
QTextCharFormat keywordFormat;
|
||||
QTextCharFormat regFormat;
|
||||
QTextCharFormat classFormat;
|
||||
QTextCharFormat singleLineCommentFormat;
|
||||
QTextCharFormat multiLineCommentFormat;
|
||||
QTextCharFormat quotationFormat;
|
||||
QTextCharFormat functionFormat;
|
||||
};
|
||||
|
||||
#endif // HIGHLIGHTER_H
|
12269
src/html/Chart.js
vendored
Normal file
45
src/html/bar.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bar Chart</title>
|
||||
<script src="qrc:/html/Chart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width: 95%; height: 90%">
|
||||
<canvas id="canvas"height="70"></canvas>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
|
||||
|
||||
var barChartData = {
|
||||
labels : ["January","February","March","April","May","June","July"],
|
||||
datasets : [
|
||||
{
|
||||
fillColor : "rgba(220,220,220,0.5)",
|
||||
strokeColor : "rgba(220,220,220,0.8)",
|
||||
highlightFill: "rgba(220,220,220,0.75)",
|
||||
highlightStroke: "rgba(220,220,220,1)",
|
||||
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
|
||||
},
|
||||
{
|
||||
fillColor : "rgba(151,187,205,0.5)",
|
||||
strokeColor : "rgba(151,187,205,0.8)",
|
||||
highlightFill : "rgba(151,187,205,0.75)",
|
||||
highlightStroke : "rgba(151,187,205,1)",
|
||||
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
window.onload = function(){
|
||||
var ctx = document.getElementById("canvas").getContext("2d");
|
||||
window.myBar = new Chart(ctx).Bar(barChartData, {
|
||||
responsive : true
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
71
src/html/fcn_graph.html
Normal file
@ -0,0 +1,71 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Polar Area Chart</title>
|
||||
<script src="qrc:/html/Chart.js"></script>
|
||||
<script src="qrc:/html/utils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="canvas-holder" style="width:100%;">
|
||||
<canvas id="chart-area" width="225" height="225"/>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var chartColors = window.chartColors;
|
||||
var color = Chart.helpers.color;
|
||||
var config = {
|
||||
data: {
|
||||
datasets: [{
|
||||
data: [MEOW],
|
||||
backgroundColor: [
|
||||
color(chartColors.red).alpha(0.5).rgbString(),
|
||||
color(chartColors.blue).alpha(0.5).rgbString(),
|
||||
color(chartColors.yellow).alpha(0.5).rgbString(),
|
||||
color(chartColors.green).alpha(0.5).rgbString(),
|
||||
color(chartColors.purple).alpha(0.5).rgbString(),
|
||||
]
|
||||
}],
|
||||
labels: [
|
||||
"CC",
|
||||
"Refs",
|
||||
"BB",
|
||||
"XRefs",
|
||||
"End BB"
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
title: {
|
||||
display: false,
|
||||
text: 'Chart.js Polar Area Chart'
|
||||
},
|
||||
tooltips: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
displayColors: false,
|
||||
},
|
||||
scale: {
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
},
|
||||
reverse: false
|
||||
},
|
||||
animation: {
|
||||
duration: 0,
|
||||
animateRotate: false,
|
||||
animateScale: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.onload = function() {
|
||||
var ctx = document.getElementById("chart-area");
|
||||
window.myPolarArea = Chart.PolarArea(ctx, config);
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
65
src/html/fcn_radar.html
Normal file
@ -0,0 +1,65 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Radar Chart</title>
|
||||
<script src="qrc:/html/Chart.js"></script>
|
||||
<script src="qrc:/html/utils.js"></script>
|
||||
<style>
|
||||
canvas{
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%">
|
||||
<canvas id="canvas" height="230" width="230"></canvas>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var color = Chart.helpers.color;
|
||||
var radarChartData = {
|
||||
type: 'radar',
|
||||
data: {
|
||||
labels : ["Cyclomatic complexity", "Refs", "Basic Blocks", "XRefs", "End BB"],
|
||||
datasets : [
|
||||
{
|
||||
label: "Amount",
|
||||
backgroundColor: color(window.chartColors.blue).alpha(0.2).rgbString(),
|
||||
borderColor: window.chartColors.blue,
|
||||
pointBackgroundColor: window.chartColors.blue,
|
||||
data : [MEOW]
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
title: {
|
||||
display: false,
|
||||
text: 'Binary statistics'
|
||||
},
|
||||
tooltips: {
|
||||
intersect: false,
|
||||
displayColors: false,
|
||||
},
|
||||
animation: {
|
||||
duration: 0
|
||||
},
|
||||
scale: {
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
window.onload = function(){
|
||||
var ctx = document.getElementById("canvas").getContext("2d");
|
||||
window.myLine = new Chart(ctx, radarChartData);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
43
src/html/graph.html
Normal file
@ -0,0 +1,43 @@
|
||||
<html>
|
||||
<body>
|
||||
<!--
|
||||
<style type="text/css">
|
||||
.center {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
/* top: 50%; */
|
||||
-webkit-transform: translate(-50%, 0);
|
||||
transform: translate(-50%, 0);
|
||||
}
|
||||
</style>
|
||||
-->
|
||||
<div class="center" id="output"></div>
|
||||
|
||||
<script src="qrc:/html/viz.js"></script>
|
||||
|
||||
<script type="text/vnd.graphviz" id="test">
|
||||
MEOW
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function src(id) {
|
||||
return document.getElementById(id).innerHTML;
|
||||
}
|
||||
|
||||
var format = "svg";
|
||||
var engine = "dot";
|
||||
|
||||
var result = Viz(src("test"), format, engine);
|
||||
//var result = Viz(input, format, engine);
|
||||
|
||||
if (format == "svg") {
|
||||
document.getElementById("output").innerHTML = result;
|
||||
} else {
|
||||
document.getElementById("output").innerHTML = "";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
35
src/html/graph/index.html
Normal file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="language" content="en" />
|
||||
|
||||
<title>radare2</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="qrc:/graph/html/graph/lib/css/disasm.css" />
|
||||
<link rel="stylesheet" type="text/css" href="qrc:/graph/html/graph/lib/css/joint.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="qrc:/graph/html/graph/lib/css/main.css" />
|
||||
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/joint.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/joint.layout.DirectedGraph.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/r2_bokken.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/r2ui.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/disasm.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-1.9.0.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-ui-latest.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery.scrollTo-latest.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/disasm_panel.js"></script>
|
||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/bokken.js"></script>
|
||||
</head>
|
||||
<body style="margin: 0px">
|
||||
|
||||
<div id="main_panel" class="ec_gui_background">
|
||||
<div id="center_panel" style="width: 100%; height: 100%; border-top: 0; padding-bottom: 1em;">
|
||||
<div id="disasm_tab" style="width: 100%; height: 1000px; border-top: 0; padding-bottom: 1em;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
176
src/html/graph/lib/css/disasm.css
Normal file
@ -0,0 +1,176 @@
|
||||
.bbcanvas { float: left; }
|
||||
|
||||
.flatcanvas { float: left; }
|
||||
|
||||
.insaddr {
|
||||
min-width: 7em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#outergbox {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.instruction {
|
||||
font-family: monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.instructiondesc {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.data {
|
||||
text-align: right;
|
||||
min-width: 18px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
.instructionbox {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#gbox {
|
||||
position: relative;
|
||||
/*margin: 10px;*/
|
||||
}
|
||||
|
||||
.bytes {
|
||||
display: inline-block;
|
||||
width: 170px;
|
||||
}
|
||||
|
||||
input:focus {outline: none; }
|
||||
|
||||
.ec_fline {color: rgb(0,127,127);}
|
||||
.ec_help {color: rgb(0,127,127);}
|
||||
.ec_args {color: rgb(0,127,127);}
|
||||
.ec_label {color: rgb(0,127,127);}
|
||||
.ec_flow {color: rgb(0,127,127);}
|
||||
.ec_prompt {color: rgb(0,127,127);}
|
||||
.ec_input {color: rgb(0,127,127);}
|
||||
.ec_btext {color: rgb(0,127,127);}
|
||||
.ec_swi {color: rgb(0,127,127);}
|
||||
.ec_comment {color: rgb(0,127,127);}
|
||||
.ec_fname {color: rgb(127,0,0);}
|
||||
.ec_flag {color: rgb(0,127,127);}
|
||||
.ec_offset {color: #0661FF;}
|
||||
.ec_other {color: rgb(127,127,127);} /* byte color bu default */
|
||||
.ec_b0x00 {color: rgb(0,127,0);}
|
||||
.ec_b0x7f {color: rgb(0,127,127);}
|
||||
.ec_b0xff {color: rgb(127,0,0);}
|
||||
.ec_math {color: rgb(127,127,0);}
|
||||
.ec_bin {color: rgb(127,127,0);}
|
||||
.ec_push {color: rgb(127,0,127);}
|
||||
.ec_pop {color: rgb(255,0,255);}
|
||||
.ec_jmp {color: rgb(0,127,0);}
|
||||
.ec_cjmp {color: rgb(0,127,0);}
|
||||
.ec_call {color: #EC0000;}
|
||||
.ec_nop {color: rgb(0,0,127);}
|
||||
.ec_ret {color: rgb(127,0,0);}
|
||||
.ec_trap {color: rgb(255,0,0);}
|
||||
.ec_invalid {color: rgb(255,0,0);}
|
||||
.ec_cmp {color: rgb(0,127,127);}
|
||||
.ec_reg {color: rgb(0,127,127);} /* (also applies to qword, brackets, etc) */
|
||||
.ec_creg {color: rgb(0,127,127);}
|
||||
.ec_mov {color: #5C5C5C;}
|
||||
.ec_num {color: #7B03B0;}
|
||||
|
||||
.ec_gui_cflow {color: rgb(255,255,0);}
|
||||
.ec_gui_dataoffset {color: rgb(127,127,0);}
|
||||
.ec_gui_background {background-color: rgb(255,255,255); }
|
||||
.ec_gui_alt_background {background-color: rgb(234, 249, 255); }
|
||||
.ec_gui_border {border-color: rgb(234, 249, 255); }
|
||||
|
||||
.autohighlight { background-color: #8AFF77 !important; }
|
||||
.autohighlighti { background-color: #8AFF77; }
|
||||
|
||||
.hidden {display:none;}
|
||||
|
||||
.lines {margin-left: 100px;}
|
||||
|
||||
.basicblock {
|
||||
border: 1px solid;
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
-webkit-user-select: none;
|
||||
box-sizing: border-box;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.basicblock .instruction,
|
||||
.basicblock input {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#canvas {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
background: transparent;
|
||||
width:100%;
|
||||
height:100%;
|
||||
margin:10px;
|
||||
}
|
||||
|
||||
#canvas svg,
|
||||
#minimap svg {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#minimap svg .link,
|
||||
#canvas svg .link {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#minimap svg .connection {
|
||||
stroke-width: 5;
|
||||
}
|
||||
|
||||
#minimap {
|
||||
border: 1px solid black;
|
||||
position:absolute;
|
||||
width:200px;
|
||||
height:200px;
|
||||
z-index: -10;
|
||||
background: #EAF9FF;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80); /* For IE8 and earlier */
|
||||
}
|
||||
|
||||
#minimap .basicblock {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#canvas #minimap_area {
|
||||
display: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
#canvas #minimap_area svg {
|
||||
stroke: transparent;
|
||||
}
|
||||
|
||||
#minimap_area {
|
||||
border: 1px solid black;
|
||||
position:absolute;
|
||||
background: black;
|
||||
opacity: 0.2;
|
||||
filter: alpha(opacity=20); /* For IE8 and earlier */
|
||||
}
|
||||
|
||||
#radareApp_mp_panels_pageDisassembler {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#main_panel {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.right_label {
|
||||
float: right;
|
||||
}
|
||||
|
9
src/html/graph/lib/css/joint.min.css
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/*! JointJS v0.9.2 - JavaScript diagramming library 2014-09-17
|
||||
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
.viewport{-webkit-user-select:none;-moz-user-select:none;user-select:none}[magnet=true]:not(.element){cursor:crosshair}[magnet=true]:not(.element):hover{opacity:.7}.element{cursor:move}.element *{vector-effect:non-scaling-stroke;-moz-user-select:none;user-drag:none}.connection-wrap{fill:none;stroke:#000;stroke-width:15;stroke-linecap:round;stroke-linejoin:round;opacity:0;cursor:move}.connection-wrap:hover{opacity:.4;stroke-opacity:.4}.connection{fill:none;stroke-linejoin:round}.marker-source,.marker-target{vector-effect:non-scaling-stroke}.marker-vertices{opacity:0;cursor:move}.marker-arrowheads{opacity:0;cursor:move;cursor:-webkit-grab;cursor:-moz-grab}.link-tools{opacity:0;cursor:pointer}.link-tools .tool-options{display:none}.link-tools .tool-remove circle{fill:red}.link-tools .tool-remove path{fill:#fff}.link:hover .marker-vertices,.link:hover .marker-arrowheads,.link:hover .link-tools{opacity:1}.marker-vertex{fill:#1ABC9C}.marker-vertex:hover{fill:#34495E;stroke:none}.marker-arrowhead{fill:#1ABC9C}.marker-arrowhead:hover{fill:#F39C12;stroke:none}.marker-vertex-remove{cursor:pointer;opacity:.1;fill:#fff}.marker-vertex-group:hover .marker-vertex-remove{opacity:1}.marker-vertex-remove-area{opacity:.1;cursor:pointer}.marker-vertex-group:hover .marker-vertex-remove-area{opacity:1}.highlighted{opacity:.7}text.highlighted{fill:red}@media screen and (-webkit-min-device-pixel-ratio:0){.highlighted{outline:2px solid red;opacity:initial}}.element .fobj body{background-color:transparent;margin:0}.element .fobj div{text-align:center;vertical-align:middle;display:table-cell;padding:0 5px}
|
262
src/html/graph/lib/css/main.css
Normal file
@ -0,0 +1,262 @@
|
||||
|
||||
/* CUSTOMIZE/OVERRIDE THE DEFAULT CSS */
|
||||
/* remove padding and scrolling from elements that contain an Accordion OR a content-div */
|
||||
.ui-layout-center , /* has content-div */
|
||||
.ui-layout-west , /* has Accordion */
|
||||
.ui-layout-east , /* has content-div ... */
|
||||
.ui-layout-east .ui-layout-content { /* content-div has Accordion */
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ui-layout-center P.ui-layout-content {
|
||||
line-height: 1.4em;
|
||||
margin: 0; /* remove top/bottom margins from <P> used as content-div */
|
||||
}
|
||||
|
||||
.ui-layout-resizer {
|
||||
background-color: #373737 !important;
|
||||
|
||||
}
|
||||
|
||||
.ui-layout-east h4 { /* Footer in East-pane */
|
||||
font-size: 0.9em;
|
||||
font-weight: normal;
|
||||
/*border-width: 1px 0 0;*/
|
||||
}
|
||||
|
||||
.ui-layout-pane {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.ui-layout-toggler {
|
||||
background-color: #797979 !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.ui-layout-center {
|
||||
/* remove default padding on center-pane so tabs widget fills it */
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ui-helper-clearfix:before,
|
||||
.ui-helper-clearfix:after {
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
.ui-helper-clearfix:after {
|
||||
clear: both;
|
||||
}
|
||||
.ui-helper-clearfix {
|
||||
min-height: 0;
|
||||
support: IE7
|
||||
}
|
||||
|
||||
.ui-tabs .ui-tabs-nav {
|
||||
font-size: 0.8em;
|
||||
background: #c0c0c0;
|
||||
border: 1px solid #797979;
|
||||
color: rgb(89, 89, 89);
|
||||
border-width: 0 0 1px;
|
||||
padding: 7px 10px;
|
||||
height: 17px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ui-tabs .ui-tabs-nav li {
|
||||
list-style: none;
|
||||
float: left;
|
||||
position: relative;
|
||||
top: 0;
|
||||
margin: 1px .2em 0 0;
|
||||
border-bottom: 0;
|
||||
padding: 0px 25px;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
background-color: #c0c0c0;
|
||||
height: 20px;
|
||||
|
||||
}
|
||||
|
||||
.ui-tabs .ui-tabs-nav li a {
|
||||
float: left;
|
||||
padding: 0px;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited {
|
||||
color: #555555;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.ui-widget-header {
|
||||
border: 1px solid #aaaaaa;
|
||||
background: #cccccc;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ui-tabs-nav li.ui-tabs-active a {
|
||||
/*color: rgb(107, 105, 9);*/
|
||||
color:white;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.ui-tabs-nav li.ui-tabs-active {
|
||||
background-color: rgb(127,127,127);
|
||||
border-bottom: 10px solid rgb(127,127,127);
|
||||
border-top: 10px solid rgb(127,127,127);
|
||||
height: 14px;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
.ui-tabs .ui-tabs-panel {
|
||||
padding: 1em 0em;
|
||||
}
|
||||
|
||||
.entry {
|
||||
font-size: 0.8em;
|
||||
padding: 0px 0px 0px 10px;
|
||||
|
||||
}
|
||||
|
||||
.jqtree-tree {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.jqtree-tree .jqtree-element {
|
||||
margin: -0.2em 0;
|
||||
font-family: monospace;
|
||||
cursor: auto;
|
||||
padding: 0px 5px;
|
||||
}
|
||||
|
||||
.jqtree-tree .jqtree-folder {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.jqtree-tree .jqtree-title {
|
||||
color: rgb(127,127,127);
|
||||
margin-left: 1em;
|
||||
}
|
||||
.jqtree-tree .jqtree-toggler {
|
||||
color: rgb(127,127,127);
|
||||
font-size: 0.8em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jqtree-tree .autohighlighti {
|
||||
background-color: rgb(127, 127, 127);
|
||||
color: rgb(20,20,20);
|
||||
}
|
||||
|
||||
.history.autohighlighti {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.hex .autohighlighti {
|
||||
background-color: yellow;
|
||||
color: rgb(20,20,20);
|
||||
}
|
||||
|
||||
.history_idx {
|
||||
background-color: rgb(127,127,127) !important;
|
||||
border-bottom: 6px solid rgb(127,127,127);
|
||||
border-top: 4px solid rgb(127,127,127);
|
||||
border-right: 3px solid rgb(127,127,127);
|
||||
border-left: 3px solid rgb(127,127,127);
|
||||
height: 14px;
|
||||
margin-top: -10px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
h3, h4 { /* Headers & Footer in Center & East panes */
|
||||
font-size: 0.8em;
|
||||
background: #c0c0c0;
|
||||
border: 1px solid #797979;
|
||||
color: rgb(89, 89, 89);
|
||||
border-width: 0 0 1px;
|
||||
padding: 7px 10px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
#center_panel {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
|
||||
#command {
|
||||
background: #c0c0c0;
|
||||
border: 1px solid #797979;
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
/*font-size: 0.4em;*/
|
||||
padding: 5px;
|
||||
width: 99%;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
#cmd_output {
|
||||
/*font-size: 0.8em;*/
|
||||
color: rgb(127,127,127);
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
#cmd_output > p {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#history {
|
||||
background: #c0c0c0;
|
||||
padding: 3px 5px;
|
||||
/*font-size: 0.4em;*/
|
||||
}
|
||||
|
||||
#information {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
#cmd_input {
|
||||
position: relative;
|
||||
}
|
||||
#cmd_input > label {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
bottom: 0;
|
||||
right: 30px;
|
||||
width: 0%;
|
||||
}
|
||||
|
||||
/*Hex panel */
|
||||
.hex {
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
width: 650px;
|
||||
height: 100%;
|
||||
}
|
||||
.hexdump {
|
||||
float: left;
|
||||
line-height: 20px;
|
||||
width: 340px;
|
||||
}
|
||||
.hextext {
|
||||
float: left;
|
||||
line-height: 20px;
|
||||
width: 140px;
|
||||
color: white;
|
||||
}
|
||||
.hexoffset {
|
||||
float: left;
|
||||
line-height: 20px;
|
||||
padding-right: 30px;
|
||||
text-align: right;
|
||||
width: 100px;
|
||||
}
|
49
src/html/graph/lib/js/bokken.js
Normal file
@ -0,0 +1,49 @@
|
||||
var myLayout;
|
||||
|
||||
$(document).ready( function() {
|
||||
|
||||
r2ui.load_colors();
|
||||
r2.load_settings();
|
||||
|
||||
// Create panels
|
||||
var disasm_panel = new DisasmPanel();
|
||||
disasm_panel.display = "graph";
|
||||
r2ui._dis = disasm_panel;
|
||||
|
||||
// For enyo compatibility
|
||||
r2ui.ra = {};
|
||||
r2ui.mp = {};
|
||||
r2ui.ra.getIndex = function() {};
|
||||
r2ui.ra.setIndex = function() {};
|
||||
r2ui.mp.openPage = function() {};
|
||||
r2ui._hex = {};
|
||||
r2ui._hex.seek = function() {};
|
||||
|
||||
|
||||
// Workaround for Chrome 48 getTransformToElement removal
|
||||
// https://github.com/clientIO/joint/issues/203
|
||||
SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) {
|
||||
return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM());
|
||||
};
|
||||
|
||||
// Render Disasm Panel
|
||||
r2ui._dis.seek(location.hash.substring(1));
|
||||
r2ui._dis.render("graph");
|
||||
});
|
||||
|
||||
// Overwritting since its used in disasm_panel.js
|
||||
function render_history() {}
|
||||
|
||||
function scroll_to_element(element) {
|
||||
if (element === undefined || element === null) return;
|
||||
var top = Math.max(0,element.documentOffsetTop() - ( window.innerHeight / 2 ));
|
||||
$('#center_panel').scrollTo(top, {axis: 'y'});
|
||||
r2ui._dis.scroll_offset = top;
|
||||
}
|
||||
|
||||
function store_scroll_offset() {
|
||||
r2ui._dis.scroll_offset = $('#center_panel').scrollTop();
|
||||
}
|
||||
function scroll_to_last_offset() {
|
||||
if (r2ui._dis.scroll_offset !== null) $('#center_panel').scrollTo(r2ui._dis.scroll_offset, {axis: 'y'});
|
||||
}
|
1087
src/html/graph/lib/js/disasm.js
Normal file
593
src/html/graph/lib/js/disasm_panel.js
Normal file
@ -0,0 +1,593 @@
|
||||
// DISASSEMBLER PANEL
|
||||
var DisasmPanel = function () {
|
||||
this.display = "flat";
|
||||
this.min = 0;
|
||||
this.max = 0;
|
||||
this.block = 512;
|
||||
this.base = "entry0";
|
||||
this.selected = null;
|
||||
this.selected_offset = null;
|
||||
this.tmp_address = null;
|
||||
this.renaming = null;
|
||||
this.renameOldValue = "";
|
||||
this.rbox = null;
|
||||
this.panel = $("#disasm_tab")[0];
|
||||
this.scroll_offset = null;
|
||||
this.minimap = true;
|
||||
this.instructions = [];
|
||||
this.scrolling = false;
|
||||
};
|
||||
DisasmPanel.prototype.render = function(mode) {
|
||||
|
||||
// r2ui.seek("$$", false);
|
||||
$("#center_panel").unbind( "click" );
|
||||
$(document).unbind( "keypress" );
|
||||
$(document).unbind( "click" );
|
||||
$(document).unbind( "dblclick" );
|
||||
$("#center_panel").scroll(on_scroll);
|
||||
$(document).keypress(handleKeypress);
|
||||
$(document).click(handleClick);
|
||||
$(document).dblclick(handleDoubleClick);
|
||||
// Context menu for disas addresses:
|
||||
$(document).contextmenu({
|
||||
delegate: ".addr",
|
||||
menu: [
|
||||
{title: "jump to address<kbd>g</kbd>", cmd: "goto"},
|
||||
{title: "rename<kbd>n</kbd>", cmd: "rename"},
|
||||
{title: "add comment<kbd>;</kbd>", cmd: "comment"},
|
||||
{title: "code<kbd>c</kbd>", cmd: "define"},
|
||||
{title: "undefine<kbd>u</kbd>", cmd: "undefine"},
|
||||
{title: "random colors<kbd>R</kbd>", cmd: "randomcolors"},
|
||||
{title: "switch disasm/graph<kbd>s</kbd>", cmd: "switchview"}
|
||||
],
|
||||
preventSelect: true,
|
||||
taphold: true,
|
||||
preventContextMenuForPopup: true,
|
||||
show: false,
|
||||
position: function(event, ui){
|
||||
return {my: "left+100 top-10", at: "left bottom", of: ui.target};
|
||||
},
|
||||
beforeOpen: function(event, ui) {
|
||||
var address = get_address_from_class(ui.target[0]);
|
||||
var xrefs_to = [];
|
||||
var xrefs_from = [];
|
||||
var xrefto_submenu = null;
|
||||
var xreffrom_submenu = null;
|
||||
var refs = [];
|
||||
var addr = "";
|
||||
var type = "";
|
||||
r2.cmd("axf @" + address, function(x){
|
||||
var lines = x.split('\n');
|
||||
for (var l in lines) {
|
||||
if (lines[l] !== "") xrefs_to[xrefs_to.length] = lines[l];
|
||||
}
|
||||
});
|
||||
if (xrefs_to.length > 0) {
|
||||
$(document).contextmenu("showEntry", "xrefs_to", true);
|
||||
refs = [];
|
||||
for (var r in xrefs_to) {
|
||||
addr = xrefs_to[r].split(' ')[1];
|
||||
type = xrefs_to[r].split(' ')[0];
|
||||
refs[refs.length] = {title: addr + "<kbd>" + type + "</kbd>", cmd: "jumpto_" + addr};
|
||||
}
|
||||
xrefto_submenu = {title: "xrefs to", children: refs};
|
||||
}
|
||||
r2.cmd("axt @" + address, function(x){
|
||||
var lines = x.split('\n');
|
||||
for (var l in lines) {
|
||||
if (lines[l] !== "") xrefs_from[xrefs_from.length] = lines[l];
|
||||
}
|
||||
});
|
||||
if (xrefs_from.length > 0) {
|
||||
$(document).contextmenu("showEntry", "xrefs_from", true);
|
||||
refs = [];
|
||||
for (var r in xrefs_from) {
|
||||
addr = xrefs_from[r].split(' ')[1];
|
||||
type = xrefs_from[r].split(' ')[0];
|
||||
refs[refs.length] = {title: addr + "<kbd>" + type + "</kbd>", cmd: "jumpto_" + addr};
|
||||
}
|
||||
xreffrom_submenu = {title: "xrefs from", children: refs};
|
||||
}
|
||||
var menu = [
|
||||
{title: "jump to address<kbd>g</kbd>", cmd: "goto"},
|
||||
{title: "rename<kbd>n</kbd>", cmd: "rename"},
|
||||
{title: "add comment<kbd>;</kbd>", cmd: "comment"},
|
||||
{title: "code<kbd>c</kbd>", cmd: "define"},
|
||||
{title: "undefine<kbd>u</kbd>", cmd: "undefine"},
|
||||
{title: "random colors<kbd>R</kbd>", cmd: "randomcolors"},
|
||||
{title: "switch disasm/graph<kbd>s</kbd>", cmd: "switchview"}
|
||||
];
|
||||
if (xreffrom_submenu !== null || xrefto_submenu !== null) {
|
||||
if (xrefto_submenu !== null) menu[menu.length] = xrefto_submenu;
|
||||
if (xreffrom_submenu !== null) menu[menu.length] = xreffrom_submenu;
|
||||
}
|
||||
$(document).contextmenu("replaceMenu", menu);
|
||||
|
||||
r2.cmdj("pdj 1 @" + address, function(x) {
|
||||
if(x) {
|
||||
if(x[0].fcn_addr == x[0].offset) {
|
||||
$(document).contextmenu("showEntry", "define", false);
|
||||
$(document).contextmenu("showEntry", "undefine", true);
|
||||
} else {
|
||||
$(document).contextmenu("showEntry", "define", true);
|
||||
$(document).contextmenu("showEntry", "undefine", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ui.target.hasClass('insaddr')) {
|
||||
$(document).contextmenu("showEntry", "comment", true);
|
||||
$(document).contextmenu("showEntry", "rename", true);
|
||||
} else {
|
||||
$(document).contextmenu("showEntry", "comment", false);
|
||||
$(document).contextmenu("showEntry", "rename", true);
|
||||
$(document).contextmenu("showEntry", "define", false);
|
||||
$(document).contextmenu("showEntry", "undefine", false);
|
||||
}
|
||||
if (ui.target.hasClass('reloc') || ui.target.hasClass('symbol') || ui.target.hasClass('import')) {
|
||||
$(document).contextmenu("showEntry", "comment", false);
|
||||
$(document).contextmenu("showEntry", "rename", false);
|
||||
$(document).contextmenu("showEntry", "define", false);
|
||||
$(document).contextmenu("showEntry", "undefine", false);
|
||||
}
|
||||
// Context manu on disasm panel
|
||||
if (!$.contains($("#disasm_tab")[0], ui.target[0])) {
|
||||
$(document).contextmenu("showEntry", "switchview", false);
|
||||
}
|
||||
},
|
||||
select: function(event, ui) {
|
||||
$(document).contextmenu("close");
|
||||
var target = ui.target[0];
|
||||
var address = get_address_from_class(target);
|
||||
if (ui.cmd.indexOf("jumpto_") === 0) {
|
||||
address = ui.cmd.substring(ui.cmd.indexOf("jumpto_") + 7);
|
||||
do_jumpto(address);
|
||||
}
|
||||
switch (ui.cmd) {
|
||||
case "goto": do_goto(); break;
|
||||
case "comment": do_comment(target); break;
|
||||
case "rename": do_rename(target, event); break;
|
||||
case "define": do_define(target); break;
|
||||
case "undefine": do_undefine(target); break;
|
||||
case "randomcolors": do_randomcolors(target); break;
|
||||
case "switchview": do_switchview(target); break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Show disasm panel and seek to entrypoint
|
||||
if (mode === "flat")
|
||||
this.display_flat();
|
||||
else if (mode === "graph")
|
||||
this.display_graph();
|
||||
var addr = null;
|
||||
if (this.selected_offset !== null) {
|
||||
addr = this.selected_offset;
|
||||
} else {
|
||||
addr = this.base;
|
||||
}
|
||||
r2ui.seek(addr,true);
|
||||
if (addr.indexOf("0x") === 0) {
|
||||
addr = address_canonicalize(addr);
|
||||
} else {
|
||||
addr = r2.get_flag_address(addr);
|
||||
}
|
||||
scroll_to_address(addr);
|
||||
};
|
||||
|
||||
DisasmPanel.prototype.seek = function(addr, scroll) {
|
||||
var panel = this.panel;
|
||||
var error = false;
|
||||
if (this.display === "graph") {
|
||||
panel.innerHTML = "";
|
||||
r2.cmd("agj " + addr, function(x) {
|
||||
panel.innerHTML = "<div id='minimap'></div></div><div id='canvas' class='canvas enyo-selectable ec_gui_background'></div>";
|
||||
// If render fails (address does not belong to function) then switch to flat view
|
||||
if (render_graph(x) === false) error = true;
|
||||
});
|
||||
}
|
||||
if (error) this.display_flat();
|
||||
if (this.display === "flat") {
|
||||
this.min = this.max = 0;
|
||||
r2.get_disasm_before_after(addr, -100, 100, function(x) {
|
||||
panel.innerHTML = "<div id='canvas' class='canvas enyo-selectable ec_gui_background'></div>";
|
||||
r2ui._dis.instructions = x;
|
||||
render_instructions(r2ui._dis.instructions);
|
||||
});
|
||||
}
|
||||
this.selected = get_element_by_address(addr);
|
||||
this.selected_offset = addr;
|
||||
|
||||
render_history();
|
||||
rehighlight_iaddress(addr);
|
||||
};
|
||||
|
||||
DisasmPanel.prototype.display_graph = function() {
|
||||
this.display = "graph";
|
||||
$("#main_panel").removeClass("ec_gui_background");
|
||||
$("#main_panel").addClass("ec_gui_alt_background");
|
||||
if ($('#minimap').length) $('#minimap')[0].innerHTML = "";
|
||||
};
|
||||
|
||||
DisasmPanel.prototype.display_flat = function() {
|
||||
this.display = "flat";
|
||||
$("#main_panel").removeClass("ec_gui_alt_background");
|
||||
$("#main_panel").addClass("ec_gui_background");
|
||||
if ($('#minimap').length) $('#minimap')[0].innerHTML = "";
|
||||
};
|
||||
|
||||
DisasmPanel.prototype.goToAddress = function() {
|
||||
if (this.renaming === null && this.selected !== null && (this.selected.className.indexOf(" addr ") > -1)) {
|
||||
var address = get_address_from_class(this.selected);
|
||||
if (this.selected.className.indexOf("ec_gui_dataoffset") > -1) {
|
||||
// address is located in not executable memory, switching to hex view
|
||||
r2ui.openpage(address, 2);
|
||||
return;
|
||||
}
|
||||
if (address !== undefined && address !== null) {
|
||||
address = address_canonicalize(address);
|
||||
do_jumpto(address);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DisasmPanel.prototype.handleInputTextChange = function() {
|
||||
if (this.renaming !== null && this.rbox.value.length > 0) {
|
||||
if ($(this.selected).hasClass('insaddr')) {
|
||||
var old_value = get_offset_flag(r2ui._dis.selected_offset);
|
||||
var type = "offsets";
|
||||
r2.cmdj("afij @ " + r2ui._dis.selected_offset, function(x) {
|
||||
if (x !== null && x !== undefined) {
|
||||
if ("0x" + x[0].offset.toString(16) === r2ui._dis.selected_offset) {
|
||||
type = "functions";
|
||||
}
|
||||
}
|
||||
});
|
||||
rename(r2ui._dis.selected_offset, old_value, this.rbox.value, type);
|
||||
} else if ($(this.selected).hasClass('faddr')) {
|
||||
if ($(this.selected).hasClass('fvar'))
|
||||
r2.cmd("afvn " + r2ui._dis.renameOldValue + " " + r2ui._dis.rbox.value + " @ " + r2ui._dis.selected_offset, function(x){});
|
||||
else if ($(this.selected).hasClass('farg'))
|
||||
r2.cmd("afan " + r2ui._dis.renameOldValue + " " + r2ui._dis.rbox.value + " @ " + r2ui._dis.selected_offset, function(x){});
|
||||
} else {
|
||||
// TODO, try to recognize other spaces
|
||||
var old_value = r2ui._dis.renameOldValue;
|
||||
if (old_value.indexOf("0x") === 0) old_value = "";
|
||||
rename(r2ui._dis.selected_offset, old_value, r2ui._dis.rbox.value, "*");
|
||||
}
|
||||
var instruction;
|
||||
if (this.display == "flat") instruction = $(this.selected).closest(".instructionbox").find('.insaddr')[0];
|
||||
if (this.display == "graph") instruction = $(this.selected).closest(".instruction").find('.insaddr')[0];
|
||||
this.renaming = null;
|
||||
var address = get_address_from_class(instruction);
|
||||
update_binary_details();
|
||||
r2ui.seek(address, false);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
};
|
||||
function scroll_to_address(address, pos) {
|
||||
if (address === undefined || address === null) return;
|
||||
var offset = 0;
|
||||
if (pos == "top") offset = $('#center_panel').height();
|
||||
else if (pos == "bottom") offset = 0;
|
||||
else offset = window.innerHeight / 2;
|
||||
var elements = $(".insaddr.addr_" + address);
|
||||
if (elements === undefined || elements === null) return;
|
||||
if (elements[0] === undefined || elements[0] === null) return;
|
||||
var top = elements[0].documentOffsetTop() - offset;
|
||||
top = Math.max(0,top);
|
||||
$('#center_panel').scrollTo(top, {axis: 'y'});
|
||||
r2ui._dis.scroll_offset = top;
|
||||
}
|
||||
|
||||
|
||||
function handleClick(inEvent) {
|
||||
|
||||
if ($(inEvent.target).hasClass('addr')) {
|
||||
if ($(inEvent.target).hasClass('history')) {
|
||||
var idx = inEvent.target.className.split(" ").filter(function(x) { return x.substr(0,"history_idx_".length) == "history_idx_"; });
|
||||
idx = String(idx).split("_")[2];
|
||||
r2ui.history_idx = idx;
|
||||
do_jumpto(r2ui.history[idx]);
|
||||
}
|
||||
// If instruction address, add address to history
|
||||
else if ($(inEvent.target).hasClass('insaddr')) {
|
||||
var address = get_address_from_class(inEvent.target);
|
||||
r2ui._dis.selected = inEvent.target;
|
||||
r2ui._dis.selected_offset = address;
|
||||
rehighlight_iaddress(address);
|
||||
|
||||
r2ui.history_push(address);
|
||||
render_history();
|
||||
var get_more_instructions = false;
|
||||
var next_instruction;
|
||||
var prev_instruction;
|
||||
if (r2ui._dis.display == "flat") {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".instructionbox").next().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) > $("#gbox .instructionbox").length - 10) {
|
||||
get_more_instructions = true;
|
||||
address = get_address_from_class(next_instruction);
|
||||
}
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".instructionbox").prev().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) < 10) {
|
||||
get_more_instructions = true;
|
||||
address = get_address_from_class(prev_instruction);
|
||||
}
|
||||
}
|
||||
if (r2ui._dis.display == "graph") {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".instruction").next().find('.insaddr')[0];
|
||||
if (next_instruction === undefined || next_instruction === null) {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".basicblock").next().find('.insaddr')[0];
|
||||
}
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".instruction").prev().find('.insaddr')[0];
|
||||
if (prev_instruction === undefined || prev_instruction === null) {
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".basicblock").prev().find('.insaddr').last()[0];
|
||||
}
|
||||
}
|
||||
if (get_more_instructions) {
|
||||
r2ui.seek(address, false);
|
||||
rehighlight_iaddress(address);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
||||
} else if ($(inEvent.target).hasClass('fvar') || $(inEvent.target).hasClass('farg')) {
|
||||
var eid = null;
|
||||
address = get_address_from_class(inEvent.target, "faddr");
|
||||
r2ui._dis.selected = inEvent.target;
|
||||
r2ui._dis.selected_offset = address;
|
||||
var classes = inEvent.target.className.split(' ');
|
||||
for (var j in classes) {
|
||||
var klass = classes[j];
|
||||
if (klass.indexOf("id_") === 0) eid = klass.substring(3);
|
||||
}
|
||||
if (eid !== null) rehighlight_iaddress(eid, "id");
|
||||
}
|
||||
}
|
||||
|
||||
function handleDoubleClick (inEvent) {
|
||||
if ($(inEvent.target).hasClass('addr') && !$(inEvent.target).hasClass('insaddr')) {
|
||||
var address = get_address_from_class(inEvent.target);
|
||||
do_jumpto(address);
|
||||
}
|
||||
}
|
||||
|
||||
// key handler
|
||||
function handleKeypress(inEvent) {
|
||||
var keynum = inEvent.keyCode || inEvent.charCode || inEvent.which || 0;
|
||||
var key = String.fromCharCode(keynum);
|
||||
// console.log(key);
|
||||
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return;
|
||||
if ($(inEvent.target).prop("tagName") === "INPUT" || $(inEvent.target).prop("tagName") === "TEXTAREA") return;
|
||||
|
||||
if (r2ui._dis.renaming !== null) return;
|
||||
|
||||
// Spacebar Switch flat and graph views
|
||||
if (key === ' ') {
|
||||
do_switchview();
|
||||
inEvent.preventDefault();
|
||||
}
|
||||
|
||||
if (key === 'm' && r2ui._dis.display == "graph") toggle_minimap();
|
||||
|
||||
// h Seek to previous address in history
|
||||
if (key === 'h') do_jumpto(r2ui.history_prev());
|
||||
|
||||
// l Seek to next address in history
|
||||
if (key === 'l') do_jumpto(r2ui.history_next());
|
||||
|
||||
// j Seek to next Instruction
|
||||
if (key === 'j') {
|
||||
var get_more_instructions = false;
|
||||
if ($(r2ui._dis.selected).hasClass("insaddr")) {
|
||||
var next_instruction;
|
||||
if (r2ui._dis.display == "flat") {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".instructionbox").next().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) > $("#gbox .instructionbox").length - 10) get_more_instructions = true;
|
||||
}
|
||||
if (r2ui._dis.display == "graph") {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".instruction").next().find('.insaddr')[0];
|
||||
if (next_instruction === undefined || next_instruction === null) {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".basicblock").next().find('.insaddr')[0];
|
||||
}
|
||||
}
|
||||
|
||||
// if (next_instruction === null || next_instruction === undefined) return;
|
||||
var address = get_address_from_class(next_instruction);
|
||||
if (get_more_instructions) {
|
||||
r2ui.seek(address, false);
|
||||
} else {
|
||||
r2ui.history_push(address);
|
||||
render_history();
|
||||
r2ui._dis.selected = next_instruction;
|
||||
r2ui._dis.selected_offset = address;
|
||||
}
|
||||
rehighlight_iaddress(address);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
||||
// k Seek to previous instruction
|
||||
if (key === 'k') {
|
||||
var get_more_instructions = false;
|
||||
if ($(r2ui._dis.selected).hasClass("insaddr")) {
|
||||
var prev_instruction;
|
||||
if (r2ui._dis.display == "flat") {
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".instructionbox").prev().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) < 10) get_more_instructions = true;
|
||||
}
|
||||
if (r2ui._dis.display == "graph") {
|
||||
var prev_instruction = $(r2ui._dis.selected).closest(".instruction").prev().find('.insaddr')[0];
|
||||
if (prev_instruction === undefined || prev_instruction === null) {
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".basicblock").prev().find('.insaddr').last()[0];
|
||||
}
|
||||
}
|
||||
var address = get_address_from_class(prev_instruction);
|
||||
if (get_more_instructions) {
|
||||
r2ui.seek(address, false);
|
||||
} else {
|
||||
r2ui.history_push(address);
|
||||
render_history();
|
||||
r2ui._dis.selected = prev_instruction;
|
||||
r2ui._dis.selected_offset = address;
|
||||
}
|
||||
rehighlight_iaddress(address);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
||||
// c Define function
|
||||
if (key === 'c') do_define(r2ui._dis.selected);
|
||||
|
||||
// u Clear function metadata
|
||||
if (key === 'u') do_undefine(r2ui._dis.selected);
|
||||
|
||||
// g Go to address
|
||||
if (key === 'g') {
|
||||
var a = prompt('Go to');
|
||||
if (a !== null) do_jumpto(a);
|
||||
}
|
||||
|
||||
// ; Add comment
|
||||
if (key === ';') do_comment(r2ui._dis.selected);
|
||||
|
||||
// n Rename
|
||||
if (key === 'n') do_rename(r2ui._dis.selected, inEvent);
|
||||
|
||||
if (key === 'R') do_randomcolors();
|
||||
|
||||
// esc
|
||||
if (keynum === 27) {
|
||||
// Esc belongs to renaming
|
||||
if(r2ui._dis.renaming !== null) {
|
||||
r2ui._dis.renaming.innerHTML = r2ui._dis.renameOldValue;
|
||||
r2ui._dis.renaming = null;
|
||||
} else {
|
||||
// go back in history
|
||||
var addr = r2ui.history_prev();
|
||||
if (addr !== undefined && addr !== null) r2ui.seek(addr, false);
|
||||
scroll_to_address(addr);
|
||||
}
|
||||
}
|
||||
// enter
|
||||
if (keynum === 13) {
|
||||
r2ui._dis.goToAddress();
|
||||
}
|
||||
}
|
||||
|
||||
function do_switchview() {
|
||||
var address = get_address_from_class(r2ui._dis.selected);
|
||||
if (address !== undefined && address !== null) {
|
||||
if (r2ui._dis.display === "flat") r2ui._dis.display_graph();
|
||||
else if (r2ui._dis.display === "graph") r2ui._dis.display_flat();
|
||||
r2ui.seek(address, true);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
||||
|
||||
function do_jumpto(address) {
|
||||
var element = $('.insaddr.addr_' + address);
|
||||
if (element.length > 0) {
|
||||
r2ui.history_push(address);
|
||||
r2ui._dis.selected = element[0];
|
||||
r2ui._dis.selected_offset = address;
|
||||
render_history();
|
||||
} else {
|
||||
r2ui.seek(address, true);
|
||||
}
|
||||
rehighlight_iaddress(address);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
|
||||
function do_rename(element, inEvent) {
|
||||
var address = get_address_from_class(element);
|
||||
if ($(element).hasClass("addr") && $(element).hasClass("flag")) {
|
||||
var space = "*";
|
||||
if ($(element).hasClass("function")) space = "functions";
|
||||
if ($(element).hasClass("import")) space = "functions";
|
||||
if ($(element).hasClass("symbol")) space = "symbols";
|
||||
if ($(element).hasClass("reloc")) space = "relocs";
|
||||
if ($(element).hasClass("section")) space = "sections";
|
||||
if ($(element).hasClass("string")) space = "strings";
|
||||
var old_value = $(element).html();
|
||||
var new_name = prompt('New name', old_value);
|
||||
if (new_name !== null) {
|
||||
rename(address, old_value, new_name, space);
|
||||
store_scroll_offset();
|
||||
r2ui.seek("$$", false);
|
||||
scroll_to_last_offset();
|
||||
}
|
||||
} else if (r2ui._dis.renaming === null && element !== null && $(element).hasClass("addr")) {
|
||||
r2ui._dis.selected = element;
|
||||
r2ui._dis.selected_offset = address;
|
||||
r2ui._dis.renaming = element;
|
||||
r2ui._dis.renameOldValue = element.innerHTML;
|
||||
r2ui._dis.rbox = document.createElement('input');
|
||||
r2ui._dis.rbox.setAttribute("type", "text");
|
||||
r2ui._dis.rbox.setAttribute("id", "rename");
|
||||
r2ui._dis.rbox.setAttribute("style", "border-width: 0;padding: 0;");
|
||||
r2ui._dis.rbox.setAttribute("onChange", "handleInputTextChange()");
|
||||
if ($(element).hasClass('insaddr')) {
|
||||
var value = get_offset_flag(address);
|
||||
r2ui._dis.rbox.setAttribute("value",value);
|
||||
r2ui._dis.rbox.setSelectionRange(value.length, value.length);
|
||||
} else {
|
||||
r2ui._dis.rbox.setAttribute("value", r2ui._dis.renameOldValue);
|
||||
r2ui._dis.rbox.setSelectionRange(r2ui._dis.renameOldValue.length, r2ui._dis.renameOldValue.length);
|
||||
}
|
||||
r2ui._dis.renaming.innerHTML = "";
|
||||
r2ui._dis.renaming.appendChild(r2ui._dis.rbox);
|
||||
setTimeout('r2ui._dis.rbox.focus();', 200);
|
||||
inEvent.returnValue=false;
|
||||
inEvent.preventDefault();
|
||||
} else if (r2ui._dis.renaming === null && element !== null && $(element).hasClass("faddr")) {
|
||||
address = get_address_from_class(element, "faddr");
|
||||
r2ui._dis.selected = element;
|
||||
r2ui._dis.selected_offset = address;
|
||||
r2ui._dis.renaming = element;
|
||||
r2ui._dis.renameOldValue = element.innerText;
|
||||
r2ui._dis.rbox = document.createElement('input');
|
||||
r2ui._dis.rbox.setAttribute("type", "text");
|
||||
r2ui._dis.rbox.setAttribute("id", "rename");
|
||||
r2ui._dis.rbox.setAttribute("style", "border-width: 0;padding: 0;");
|
||||
r2ui._dis.rbox.setAttribute("onChange", "handleInputTextChange()");
|
||||
r2ui._dis.rbox.setAttribute("value", r2ui._dis.renameOldValue);
|
||||
r2ui._dis.rbox.setSelectionRange(r2ui._dis.renameOldValue.length, r2ui._dis.renameOldValue.length);
|
||||
r2ui._dis.renaming.innerHTML = "";
|
||||
r2ui._dis.renaming.appendChild(r2ui._dis.rbox);
|
||||
setTimeout('r2ui._dis.rbox.focus();', 200);
|
||||
inEvent.returnValue=false;
|
||||
inEvent.preventDefault();
|
||||
}
|
||||
update_binary_details();
|
||||
}
|
||||
|
||||
function do_comment(element) {
|
||||
var address = get_address_from_class(element);
|
||||
var c = prompt('Comment');
|
||||
if (c !== null) {
|
||||
r2.cmd('CC ' + c + " @ " + address);
|
||||
r2ui.seek(address, false);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
||||
|
||||
function do_undefine(element) {
|
||||
var address = get_address_from_class(element);
|
||||
r2.cmd("af-");
|
||||
r2.update_flags();
|
||||
update_binary_details();
|
||||
if (r2ui._dis.display == "graph") r2ui._dis.display_flat();
|
||||
r2ui.seek(address, false);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
|
||||
function do_define(element) {
|
||||
var address = get_address_from_class(element);
|
||||
var msg = prompt ('Function name?');
|
||||
if (msg !== null) {
|
||||
r2.cmd("af " + msg + " @ " + address);
|
||||
r2.update_flags();
|
||||
update_binary_details();
|
||||
r2ui.seek(address, false);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
14
src/html/graph/lib/js/joint.js
Normal file
9
src/html/graph/lib/js/joint.layout.DirectedGraph.js
Normal file
9555
src/html/graph/lib/js/jquery-1.9.0.js
vendored
Normal file
14879
src/html/graph/lib/js/jquery-ui-latest.js
vendored
Normal file
187
src/html/graph/lib/js/jquery.scrollTo-latest.js
Normal file
@ -0,0 +1,187 @@
|
||||
/*!
|
||||
* jQuery.scrollTo
|
||||
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
|
||||
* Licensed under MIT
|
||||
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
||||
* @projectDescription Easy element scrolling using jQuery.
|
||||
* @author Ariel Flesler
|
||||
* @version 1.4.14
|
||||
*/
|
||||
;(function (define) {
|
||||
'use strict';
|
||||
|
||||
define(['jquery'], function ($) {
|
||||
|
||||
var $scrollTo = $.scrollTo = function( target, duration, settings ) {
|
||||
return $(window).scrollTo( target, duration, settings );
|
||||
};
|
||||
|
||||
$scrollTo.defaults = {
|
||||
axis:'xy',
|
||||
duration: 0,
|
||||
limit:true
|
||||
};
|
||||
|
||||
// Returns the element that needs to be animated to scroll the window.
|
||||
// Kept for backwards compatibility (specially for localScroll & serialScroll)
|
||||
$scrollTo.window = function( scope ) {
|
||||
return $(window)._scrollable();
|
||||
};
|
||||
|
||||
// Hack, hack, hack :)
|
||||
// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
|
||||
$.fn._scrollable = function() {
|
||||
return this.map(function() {
|
||||
var elem = this,
|
||||
isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;
|
||||
|
||||
if (!isWin)
|
||||
return elem;
|
||||
|
||||
var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
|
||||
|
||||
return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ?
|
||||
doc.body :
|
||||
doc.documentElement;
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.scrollTo = function( target, duration, settings ) {
|
||||
if (typeof duration == 'object') {
|
||||
settings = duration;
|
||||
duration = 0;
|
||||
}
|
||||
if (typeof settings == 'function')
|
||||
settings = { onAfter:settings };
|
||||
|
||||
if (target == 'max')
|
||||
target = 9e9;
|
||||
|
||||
settings = $.extend( {}, $scrollTo.defaults, settings );
|
||||
// Speed is still recognized for backwards compatibility
|
||||
duration = duration || settings.duration;
|
||||
// Make sure the settings are given right
|
||||
settings.queue = settings.queue && settings.axis.length > 1;
|
||||
|
||||
if (settings.queue)
|
||||
// Let's keep the overall duration
|
||||
duration /= 2;
|
||||
settings.offset = both( settings.offset );
|
||||
settings.over = both( settings.over );
|
||||
|
||||
return this._scrollable().each(function() {
|
||||
// Null target yields nothing, just like jQuery does
|
||||
if (target == null) return;
|
||||
|
||||
var elem = this,
|
||||
$elem = $(elem),
|
||||
targ = target, toff, attr = {},
|
||||
win = $elem.is('html,body');
|
||||
|
||||
switch (typeof targ) {
|
||||
// A number will pass the regex
|
||||
case 'number':
|
||||
case 'string':
|
||||
if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
|
||||
targ = both( targ );
|
||||
// We are done
|
||||
break;
|
||||
}
|
||||
// Relative/Absolute selector, no break!
|
||||
targ = win ? $(targ) : $(targ, this);
|
||||
if (!targ.length) return;
|
||||
case 'object':
|
||||
// DOMElement / jQuery
|
||||
if (targ.is || targ.style)
|
||||
// Get the real position of the target
|
||||
toff = (targ = $(targ)).offset();
|
||||
}
|
||||
|
||||
var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
|
||||
|
||||
$.each( settings.axis.split(''), function( i, axis ) {
|
||||
var Pos = axis == 'x' ? 'Left' : 'Top',
|
||||
pos = Pos.toLowerCase(),
|
||||
key = 'scroll' + Pos,
|
||||
old = elem[key],
|
||||
max = $scrollTo.max(elem, axis);
|
||||
|
||||
if (toff) {// jQuery / DOMElement
|
||||
attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
|
||||
|
||||
// If it's a dom element, reduce the margin
|
||||
if (settings.margin) {
|
||||
attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
|
||||
attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
|
||||
}
|
||||
|
||||
attr[key] += offset[pos] || 0;
|
||||
|
||||
if(settings.over[pos])
|
||||
// Scroll to a fraction of its width/height
|
||||
attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
|
||||
} else {
|
||||
var val = targ[pos];
|
||||
// Handle percentage values
|
||||
attr[key] = val.slice && val.slice(-1) == '%' ?
|
||||
parseFloat(val) / 100 * max
|
||||
: val;
|
||||
}
|
||||
|
||||
// Number or 'number'
|
||||
if (settings.limit && /^\d+$/.test(attr[key]))
|
||||
// Check the limits
|
||||
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );
|
||||
|
||||
// Queueing axes
|
||||
if (!i && settings.queue) {
|
||||
// Don't waste time animating, if there's no need.
|
||||
if (old != attr[key])
|
||||
// Intermediate animation
|
||||
animate( settings.onAfterFirst );
|
||||
// Don't animate this axis again in the next iteration.
|
||||
delete attr[key];
|
||||
}
|
||||
});
|
||||
|
||||
animate( settings.onAfter );
|
||||
|
||||
function animate( callback ) {
|
||||
$elem.animate( attr, duration, settings.easing, callback && function() {
|
||||
callback.call(this, targ, settings);
|
||||
});
|
||||
}
|
||||
}).end();
|
||||
};
|
||||
|
||||
// Max scrolling position, works on quirks mode
|
||||
// It only fails (not too badly) on IE, quirks mode.
|
||||
$scrollTo.max = function( elem, axis ) {
|
||||
var Dim = axis == 'x' ? 'Width' : 'Height',
|
||||
scroll = 'scroll'+Dim;
|
||||
|
||||
if (!$(elem).is('html,body'))
|
||||
return elem[scroll] - $(elem)[Dim.toLowerCase()]();
|
||||
|
||||
var size = 'client' + Dim,
|
||||
html = elem.ownerDocument.documentElement,
|
||||
body = elem.ownerDocument.body;
|
||||
|
||||
return Math.max( html[scroll], body[scroll] ) - Math.min( html[size] , body[size] );
|
||||
};
|
||||
|
||||
function both( val ) {
|
||||
return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
|
||||
}
|
||||
|
||||
// AMD requirement
|
||||
return $scrollTo;
|
||||
})
|
||||
}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
// Node
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
factory(jQuery);
|
||||
}
|
||||
}));
|
597
src/html/graph/lib/js/r2_bokken.js
Normal file
@ -0,0 +1,597 @@
|
||||
/* radare2 Copyleft 2013-2014 pancake */
|
||||
|
||||
var r2 = {};
|
||||
|
||||
// TODO: avoid globals
|
||||
var backward = false;
|
||||
var next_curoff = 0;
|
||||
var next_lastoff = 0;
|
||||
var prev_curoff = 0;
|
||||
var prev_lastoff = 0;
|
||||
var hascmd = false;
|
||||
|
||||
// async helper
|
||||
function asyncLoop(iterations, func, callback) {
|
||||
var index = 0;
|
||||
var done = false;
|
||||
var loop = {
|
||||
next: function() {
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (index < iterations) {
|
||||
index++;
|
||||
func(loop);
|
||||
|
||||
} else {
|
||||
done = true;
|
||||
callback();
|
||||
}
|
||||
},
|
||||
|
||||
iteration: function() {
|
||||
return index - 1;
|
||||
},
|
||||
|
||||
break: function() {
|
||||
done = true;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
loop.next();
|
||||
return loop;
|
||||
}
|
||||
|
||||
if (typeof (module) !== 'undefined') {
|
||||
module.exports = function(r) {
|
||||
if (typeof (r) == 'function') {
|
||||
hascmd = r;
|
||||
} else {
|
||||
hascmd = r.cmd;
|
||||
}
|
||||
return r2;
|
||||
}
|
||||
}
|
||||
|
||||
r2.project_name = "";
|
||||
|
||||
r2.plugin = function() {
|
||||
console.error ("r2.plugin is not available in this environment");
|
||||
}
|
||||
try {
|
||||
if (r2plugin) {
|
||||
r2.plugin = r2plugin
|
||||
}
|
||||
} catch ( e ) {}
|
||||
|
||||
r2.root = "http://localhost:9090"; // prefix path
|
||||
|
||||
/* helpers */
|
||||
function dump(obj) {
|
||||
var x = "";
|
||||
for (var a in obj) x += a + "\n";
|
||||
if (typeof ('alert') != 'undefined') {
|
||||
alert (x);
|
||||
} else {
|
||||
console.log (x);
|
||||
}
|
||||
}
|
||||
|
||||
r2.analAll = function() {
|
||||
r2.cmd ("aa", function() {});
|
||||
}
|
||||
|
||||
r2.analOp = function(addr, cb) {
|
||||
r2.cmd ("aoj 1 @ " + addr, function(txt) {
|
||||
try {
|
||||
cb(JSON.parse (txt)[0]);
|
||||
} catch ( e ) {
|
||||
console.error (e)
|
||||
cb (txt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
r2.varMap = [];
|
||||
r2.argMap = [];
|
||||
|
||||
function objtostr(obj) {
|
||||
var str = "";
|
||||
for (var a in obj)
|
||||
str += a + ": " + obj[a] + ",\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
function Ajax(method, uri, body, fn) {
|
||||
|
||||
if (typeof (XMLHttpRequest) == "undefined")
|
||||
return false;
|
||||
|
||||
var x = new XMLHttpRequest ();
|
||||
if (!x)
|
||||
return false;
|
||||
|
||||
x.open (method, uri, false);
|
||||
x.setRequestHeader ('Accept', 'text/plain');
|
||||
x.setRequestHeader ('Accept', 'text/html');
|
||||
x.setRequestHeader ("Content-Type", "application/x-ww-form-urlencoded; charset=UTF-8");
|
||||
x.onreadystatechange = function(y) {
|
||||
if (x.status == 200) {
|
||||
if (fn) {
|
||||
fn (x.responseText);
|
||||
}
|
||||
} else {
|
||||
console.error ("ajax " + x.status)
|
||||
}
|
||||
}
|
||||
x.send (body);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
r2.assemble = function(offset, opcode, fn) {
|
||||
var off = offset ? "@" + offset : '';
|
||||
r2.cmd ('"pa ' + opcode + '"' + off, fn);
|
||||
}
|
||||
|
||||
r2.disassemble = function(offset, bytes, fn) {
|
||||
var off = offset ? "@" + offset : '';
|
||||
var str = 'pi @b:' + bytes + off;
|
||||
r2.cmd (str, fn);
|
||||
}
|
||||
|
||||
r2.get_hexdump = function(offset, length, cb) {
|
||||
r2.cmd ("px " + length + "@" + offset, cb);
|
||||
}
|
||||
|
||||
r2.get_disasm = function(offset, length, cb) {
|
||||
// TODO: honor offset and length
|
||||
r2.cmd ("pD " + length + "@" + offset, cb);
|
||||
}
|
||||
|
||||
r2.get_disasm_before = function(offset, start, cb) {
|
||||
var before = [];
|
||||
r2.cmd("pdj -" + start + "@" + offset, function(x) {
|
||||
before = JSON.parse(x);
|
||||
});
|
||||
cb(before);
|
||||
}
|
||||
|
||||
r2.get_disasm_after = function(offset, end, cb) {
|
||||
var after = [];
|
||||
r2.cmd("pdj " + end + "@" + offset, function(x) {
|
||||
after = JSON.parse(x);
|
||||
});
|
||||
cb(after);
|
||||
}
|
||||
|
||||
r2.get_disasm_before_after = function(offset, start, end, cb) {
|
||||
var before = [];
|
||||
var after = [];
|
||||
r2.cmd("pdj " + start + " @" + offset, function(x) {
|
||||
before = JSON.parse(x);
|
||||
});
|
||||
r2.cmd("pdj " + end + "@" + offset, function(x) {
|
||||
after = JSON.parse(x);
|
||||
});
|
||||
var opcodes = before.concat(after);
|
||||
cb(opcodes);
|
||||
}
|
||||
|
||||
r2.Config = function(k, v, fn) {
|
||||
if (typeof v == 'function' || !v) { // get
|
||||
r2.cmd ("e " + k, fn || v);
|
||||
} else { // set
|
||||
r2.cmd ("e " + k + "=" + v, fn);
|
||||
}
|
||||
return r2;
|
||||
}
|
||||
|
||||
r2.sections = {};
|
||||
|
||||
r2.load_mmap = function() {
|
||||
r2.cmdj("iSj", function(x) {
|
||||
if (x !== undefined && x !== null) {
|
||||
r2.sections = x;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_address_type = function(address) {
|
||||
var offset = parseInt(address, 16);
|
||||
for (var i in r2.sections) {
|
||||
if (offset >= r2.sections[i].addr && offset < r2.sections[i].addr + r2.sections[i].size) {
|
||||
if (r2.sections[i].flags.indexOf("x") > -1) {
|
||||
return "instruction";
|
||||
}
|
||||
else {
|
||||
return "memory";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
r2.settings = {};
|
||||
|
||||
r2.load_settings = function() {
|
||||
r2.cmd ("e asm.arch", function(x) {r2.settings['asm.arch'] = x.trim();});
|
||||
r2.cmd ("e asm.bits", function(x) {r2.settings['asm.bits'] = x.trim();});
|
||||
r2.cmd ("e asm.bytes", function(x) {r2.settings['asm.bytes'] = toBoolean(x.trim());});
|
||||
r2.cmd ("e asm.flags", function(x) {r2.settings['asm.flags'] = toBoolean(x.trim());});
|
||||
r2.cmd ("e asm.offset", function(x) {r2.settings['asm.offset'] = toBoolean(x.trim());});
|
||||
r2.cmd ("e asm.lines", function(x) {r2.settings['asm.lines'] = toBoolean(x.trim());});
|
||||
r2.cmd ("e asm.xrefs", function(x) {r2.settings['asm.xrefs'] = toBoolean(x.trim());});
|
||||
r2.cmd ("e asm.cmtright", function(x) {r2.settings['asm.cmtright'] = toBoolean(x.trim());});
|
||||
r2.cmd ("e asm.pseudo", function(x) {r2.settings['asm.pseudo'] = toBoolean(x.trim());});
|
||||
// console.log("Loading settings from r2");
|
||||
// console.log(r2.settings);
|
||||
}
|
||||
|
||||
|
||||
r2.flags = {};
|
||||
|
||||
r2.update_flags = function() {
|
||||
r2.cmd ("fs *;fj", function(x) {
|
||||
|
||||
var fs = JSON.parse (x);
|
||||
if (fs !== undefined && fs !== null) {
|
||||
r2.flags = {};
|
||||
for (var f in fs) {
|
||||
var addr = "0x" + fs[f].offset.toString(16);
|
||||
addr = address_canonicalize(addr);
|
||||
if (addr in r2.flags) {
|
||||
var fl = r2.flags[addr];
|
||||
fl[fl.length] = { name: fs[f].name, size: fs[f].size};
|
||||
r2.flags[addr] = fl;
|
||||
} else {
|
||||
r2.flags[addr] = [{ name: fs[f].name, size: fs[f].size}];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_flag_address = function(name) {
|
||||
for (var f in r2.flags) {
|
||||
for (var v in r2.flags[f]) {
|
||||
if (name == r2.flags[f][v].name) return f;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
r2.get_flag_names = function(offset) {
|
||||
var names = [];
|
||||
for (var i in r2.flags[offset]) {
|
||||
names[names.length] = r2.flags[offset][i].name;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
r2.set_flag_space = function(ns, fn) {
|
||||
r2.cmd ("fs " + ns, fn);
|
||||
}
|
||||
|
||||
r2.get_flags = function(fn) {
|
||||
r2.cmd ("fj", function(x) {
|
||||
fn (x ? JSON.parse (x) : []);
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_opcodes = function(off, n, cb) {
|
||||
r2.cmd ("pdj @" + off + "!" + n, function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_bytes = function(off, n, cb) {
|
||||
r2.cmd ("pcj @" + off + "!" + n, function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.asm_config = {};
|
||||
|
||||
r2.store_asm_config = function() {
|
||||
config = {};
|
||||
r2.cmd ("e", function(x) {
|
||||
conf = x.split("\n");
|
||||
for (var prop in conf) {
|
||||
var fields = conf[prop].split(" ");
|
||||
if (fields.length == 3) {
|
||||
// TODO: Dont know why byt e~asm. is not working so filtering here
|
||||
if (fields[0].trim().indexOf("asm.") == 0) config[fields[0].trim()] = fields[2].trim();
|
||||
}
|
||||
}
|
||||
r2.asm_config = config;
|
||||
});
|
||||
}
|
||||
|
||||
r2.restore_asm_config = function() {
|
||||
cmd = "";
|
||||
for (var prop in r2.asm_config) {
|
||||
cmd += "e " + prop + "=" + r2.asm_config[prop] + ";";
|
||||
}
|
||||
r2.cmd (cmd, function(x) {});
|
||||
}
|
||||
|
||||
r2.get_info = function(cb) {
|
||||
r2.cmd ("ij", function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
r2.bin_relocs = function(cb) {
|
||||
r2.cmd ("irj", function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
r2.bin_imports = function(cb) {
|
||||
r2.cmd ("iij", function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.bin_symbols = function(cb) {
|
||||
r2.cmd ("isj", function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.bin_sections = function(cb) {
|
||||
r2.cmd ("iSj", function(json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.cmds = function(cmds, cb) {
|
||||
if (cmds.length == 0) return;
|
||||
var cmd = cmds[0];
|
||||
cmds = cmds.splice (1);
|
||||
function lala() {
|
||||
if (cmd == undefined || cmds.length == 0) {
|
||||
return;
|
||||
}
|
||||
cmd = cmds[0];
|
||||
cmds = cmds.splice (1);
|
||||
r2.cmd (cmd, lala);
|
||||
if (cb) {
|
||||
cb ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
r2.cmd (cmd, lala);
|
||||
}
|
||||
|
||||
function _internal_cmd(c, cb) {
|
||||
if (typeof (r2cmd) != 'undefined') {
|
||||
hascmd = r2cmd;
|
||||
}
|
||||
if (hascmd) {
|
||||
// TODO: use setTimeout for async?
|
||||
if (typeof (r2plugin) != "undefined") {
|
||||
// duktape
|
||||
cb (r2cmd(c));
|
||||
} else {
|
||||
// node
|
||||
return hascmd (c, cb);
|
||||
}
|
||||
} else {
|
||||
Ajax ('GET', r2.root + "/cmd/" + encodeURI(c), '', function(x) {
|
||||
if (cb) {
|
||||
cb (x);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
r2.cmd = function(c, cb) {
|
||||
if (Array.isArray (c)) {
|
||||
var res = [];
|
||||
var idx = 0;
|
||||
asyncLoop (c.length, function(loop) {
|
||||
_internal_cmd (c[idx], function(result) {
|
||||
idx = loop.iteration();
|
||||
res[idx] = result.replace(/\n$/, "");
|
||||
idx++;
|
||||
loop.next ();
|
||||
});
|
||||
}, function() {
|
||||
// all iterations done
|
||||
cb (res);
|
||||
});
|
||||
} else {
|
||||
_internal_cmd (c, cb);
|
||||
}
|
||||
}
|
||||
|
||||
r2.cmdj = function(c, cb) {
|
||||
r2.cmd (c, function(x) {
|
||||
try {
|
||||
cb (JSON.parse(x));
|
||||
} catch ( e ) {
|
||||
cb (null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
r2.alive = function(cb) {
|
||||
r2.cmd ("b", function(o) {
|
||||
var ret = false;
|
||||
if (o && o.length () > 0) {
|
||||
ret = true;
|
||||
}
|
||||
if (cb) {
|
||||
cb (o);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
r2.getTextLogger = function(obj) {
|
||||
if (typeof (obj) != "object") {
|
||||
obj = {};
|
||||
}
|
||||
obj.last = 0;
|
||||
obj.events = {};
|
||||
obj.interval = null;
|
||||
r2.cmd ("Tl", function(x) {
|
||||
obj.last = +x;
|
||||
});
|
||||
obj.load = function(cb) {
|
||||
r2.cmd ("Tj " + (obj.last + 1), function(ret) {
|
||||
if (cb) {
|
||||
cb (JSON.parse (ret));
|
||||
}
|
||||
});
|
||||
}
|
||||
obj.clear = function(cb) {
|
||||
// XXX: fix l-N
|
||||
r2.cmd ("T-", cb); //+obj.last, cb);
|
||||
}
|
||||
obj.send = function(msg, cb) {
|
||||
r2.cmd ("T " + msg, cb);
|
||||
}
|
||||
obj.refresh = function(cb) {
|
||||
obj.load (function(ret) {
|
||||
//obj.last = 0;
|
||||
for (var i = 0; i < ret.length; i++) {
|
||||
var message = ret[i];
|
||||
obj.events["message"] ({
|
||||
"id": message[0],
|
||||
"text": message[1]
|
||||
});
|
||||
if (message[0] > obj.last) {
|
||||
obj.last = message[0];
|
||||
}
|
||||
}
|
||||
if (cb) {
|
||||
cb ();
|
||||
}
|
||||
});
|
||||
}
|
||||
obj.autorefresh = function(n) {
|
||||
if (!n) {
|
||||
if (obj.interval) {
|
||||
obj.interval.stop ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
function to() {
|
||||
obj.refresh (function() {
|
||||
//obj.clear ();
|
||||
});
|
||||
if (r2ui.selected_panel === "Logs")
|
||||
setTimeout (to, n * 1000);
|
||||
else console.log("Not in logs :(");
|
||||
return true;
|
||||
}
|
||||
obj.interval = setTimeout (to, n * 1000);
|
||||
}
|
||||
obj.on = function(ev, cb) {
|
||||
obj.events[ev] = cb;
|
||||
return obj;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
r2.filter_asm = function(x, display) {
|
||||
var curoff = backward ? prev_curoff : next_curoff;
|
||||
;
|
||||
var lastoff = backward ? prev_lastoff : next_lastoff;
|
||||
;
|
||||
var lines = x.split (/\n/g);
|
||||
r2.cmd ("s", function(x) {
|
||||
curoff = x;
|
||||
});
|
||||
for (var i = lines.length - 1; i > 0; i--) {
|
||||
var a = lines[i].match (/0x([a-fA-F0-9]+)/);
|
||||
if (a && a.length > 0) {
|
||||
lastoff = a[0].replace (/:/g, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (display == "afl") {
|
||||
//hasmore (false);
|
||||
var z = "";
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var row = lines[i].replace (/\ +/g, " ").split (/ /g);
|
||||
z += row[0] + " " + row[3] + "\n";
|
||||
}
|
||||
x = z;
|
||||
} else if (display[0] == 'f') {
|
||||
//hasmore (false);
|
||||
if (display[1] == 's') {
|
||||
var z = "";
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var row = lines[i].replace (/\ +/g, " ").split (/ /g);
|
||||
var mark = row[1] == '*' ? '*' : ' ';
|
||||
var space = row[2] ? row[2] : row[1];
|
||||
if (!space) continue;
|
||||
z += row[0] + " " + mark + " <a href=\"javascript:runcmd('fs " +
|
||||
space + "')\">" + space + "</a>\n";
|
||||
}
|
||||
x = z;
|
||||
} else {
|
||||
}
|
||||
} else if (display[0] == "i") {
|
||||
//hasmore (false);
|
||||
if (display[1]) {
|
||||
var z = "";
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var elems = lines[i].split (/ /g);
|
||||
var name = "";
|
||||
var addr = "";
|
||||
for (var j = 0; j < elems.length; j++) {
|
||||
var kv = elems[j].split (/=/);
|
||||
if (kv[0] == "addr") {
|
||||
addr = kv[1];
|
||||
}
|
||||
if (kv[0] == "name") {
|
||||
name = kv[1];
|
||||
}
|
||||
if (kv[0] == "string") {
|
||||
name = kv[1];
|
||||
}
|
||||
}
|
||||
z += addr + " " + name + "\n";
|
||||
}
|
||||
x = z;
|
||||
}
|
||||
} //else hasmore (true);
|
||||
|
||||
function haveDisasm(x) {
|
||||
if (x[0] == 'p' && x[1] == 'd') return true;
|
||||
if (x.indexOf (";pd") != -1) return true;
|
||||
return false;
|
||||
}
|
||||
if (haveDisasm (display)) {
|
||||
x = x.replace (/function:/g, "<span style=color:green>function:</span>");
|
||||
x = x.replace (/;(\s+)/g, ";");
|
||||
x = x.replace (/;(.*)/g, "// <span style='color:#209020'>$1</span>");
|
||||
x = x.replace (/(bl|goto|call)/g, "<b style='color:green'>call</b>");
|
||||
x = x.replace (/(jmp|bne|beq|js|jnz|jae|jge|jbe|jg|je|jl|jz|jb|ja|jne)/g, "<b style='color:green'>$1</b>");
|
||||
x = x.replace (/(dword|qword|word|byte|movzx|movsxd|cmovz|mov\ |lea\ )/g, "<b style='color:#1070d0'>$1</b>");
|
||||
x = x.replace (/(hlt|leave|iretd|retn|ret)/g, "<b style='color:red'>$1</b>");
|
||||
x = x.replace (/(add|sbb|sub|mul|div|shl|shr|and|not|xor|inc|dec|sar|sal)/g, "<b style='color:#d06010'>$1</b>");
|
||||
x = x.replace (/(push|pop)/g, "<b style='color:#40a010'>$1</b>");
|
||||
x = x.replace (/(test|cmp)/g, "<b style='color:#c04080'>$1</b>");
|
||||
x = x.replace (/(outsd|out|string|invalid|int |int3|trap|main|in)/g, "<b style='color:red'>$1</b>");
|
||||
x = x.replace (/nop/g, "<b style='color:blue'>nop</b>");
|
||||
x = x.replace (/(sym|fcn|str|imp|loc)\.([^:<(\\\/ \|)\->]+)/g, "<a href='javascript:r2ui.seek(\"$1.$2\")'>$1.$2</a>");
|
||||
}
|
||||
x = x.replace (/0x([a-zA-Z0-9]+)/g, "<a href='javascript:r2ui.seek(\"0x$1\")'>0x$1</a>");
|
||||
// registers
|
||||
if (backward) {
|
||||
prev_curoff = curoff;
|
||||
prev_lastoff = lastoff;
|
||||
} else {
|
||||
next_curoff = curoff;
|
||||
next_lastoff = lastoff;
|
||||
if (!prev_curoff) {
|
||||
prev_curoff = next_curoff;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
252
src/html/graph/lib/js/r2ui.js
Normal file
@ -0,0 +1,252 @@
|
||||
var r2ui = {};
|
||||
|
||||
r2ui.selected_panel = "Disassembler";
|
||||
|
||||
r2ui.history = [];
|
||||
r2ui.history_idx = 0;
|
||||
|
||||
r2ui.colors = {};
|
||||
|
||||
r2ui.load_colors = function () {
|
||||
// change css on the fly!
|
||||
r2.cmdj("ecj", function(x) {
|
||||
for (var i in x) {
|
||||
r2ui.colors[".ec_" + i.replace("gui.","gui_")] = "rgb(" + String(x[i]) + ")";
|
||||
}
|
||||
});
|
||||
for (var k in document.styleSheets) {
|
||||
var mysheet = document.styleSheets[k];
|
||||
var myrules = mysheet.cssRules? mysheet.cssRules: mysheet.rules;
|
||||
var targetrule;
|
||||
for (var j in myrules) {
|
||||
if (myrules[j].selectorText !== undefined && myrules[j].selectorText !== null) {
|
||||
if (myrules[j].selectorText.toLowerCase().indexOf(".ec_") === 0) {
|
||||
var sel = myrules[j].selectorText; //.toLowerCase().replace("gui.","gui_");
|
||||
/*
|
||||
var color = r2ui.colors[sel];
|
||||
if (color !== undefined && color !== null) {
|
||||
if (sel == ".ec_gui_background" || sel == ".ec_gui_alt_background") {
|
||||
myrules[j].style.backgroundColor = color;
|
||||
} else if (sel == ".ec_border") myrules[j].style.borderColor = color;
|
||||
else myrules[j].style.color = color;
|
||||
} else {
|
||||
if (sel == ".ec_gui_background" || sel == ".ec_gui_alt_background") r2ui.colors[sel] = myrules[j].style.backgroundColor;
|
||||
else if (sel == ".ec_gui_border") r2ui.colors[sel] = myrules[j].style.borderColor;
|
||||
else r2ui.colors[sel] = myrules[j].style.color;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
r2ui.basic_blocks = {};
|
||||
r2ui.use_sdb = false;
|
||||
r2ui.get_fcn_BB = function(fcn_offset, bb_offset) {
|
||||
if (r2ui.use_sdb) {
|
||||
var path = "webui/graph/" + fcn_offset + "/" + bb_offset;
|
||||
var bb = null;
|
||||
r2.cmd("k " + path, function(x) {
|
||||
var lines = decodeURIComponent(x).split("\n");
|
||||
for (var l in lines) {
|
||||
var line = lines[l];
|
||||
if (line !== "") {
|
||||
bb = {};
|
||||
var props = line.split(",");
|
||||
bb.x = props[0];
|
||||
bb.y = props[1];
|
||||
if (props[2] === "" || props[2] === undefined) props[2] = "transparent";
|
||||
bb.color = props[2].replace(/\*\*/g, ",");
|
||||
}
|
||||
}
|
||||
});
|
||||
return bb;
|
||||
} else {
|
||||
return r2ui.basic_blocks[bb_offset];
|
||||
}
|
||||
};
|
||||
r2ui.get_fcn_BBs = function(fcn_offset) {
|
||||
if (r2ui.use_sdb) {
|
||||
var path = "webui/graph/" + fcn_offset + "/*";
|
||||
var BBs = {};
|
||||
r2.cmd("k " + path, function(x) {
|
||||
var lines = decodeURIComponent(x).split("\n");
|
||||
for (var l in lines) {
|
||||
var line = lines[l];
|
||||
if (line !== "") {
|
||||
offset = line.split("=")[0];
|
||||
line = line.split("=")[1];
|
||||
var bb = {};
|
||||
var props = line.split(",");
|
||||
bb.x = props[0];
|
||||
bb.y = props[1];
|
||||
if (props[2] === "" || props[2] === undefined) props[2] = "transparent";
|
||||
bb.color = props[2].replace(/\*\*/g, ",");
|
||||
BBs[offset] = bb;
|
||||
}
|
||||
}
|
||||
});
|
||||
return BBs;
|
||||
} else {
|
||||
return r2ui.basic_blocks;
|
||||
}
|
||||
};
|
||||
r2ui.update_fcn_BB = function(fcn_offset, bb_offset, bbinfo) {
|
||||
if (r2ui.use_sdb) {
|
||||
var path = "webui/graph/" + fcn_offset + "/" + bb_offset;
|
||||
if (bbinfo.color === undefined) bbinfo.color = "transparent";
|
||||
var value = bbinfo.x + "," + bbinfo.y + "," + bbinfo.color.replace(/,/g, "**");
|
||||
r2.cmd("k " + path + "=" + encodeURIComponent(value), function(x) { });
|
||||
} else {
|
||||
r2ui.basic_blocks[bb_offset] = bbinfo;
|
||||
}
|
||||
};
|
||||
|
||||
r2ui.current_fcn_offset = null;
|
||||
r2ui.graph = null;
|
||||
r2ui.console_lang = "r2";
|
||||
r2ui.toggle_console_lang = function() {
|
||||
if (r2ui.console_lang == "r2") r2ui.console_lang = "js";
|
||||
else if (r2ui.console_lang == "js") r2ui.console_lang = "r2";
|
||||
$("#cmd_input > label").html(r2ui.console_lang);
|
||||
};
|
||||
|
||||
r2ui.history_push = function (x) {
|
||||
if (x != r2ui.history_last()) {
|
||||
if (r2ui.history_idx != r2ui.history.length)
|
||||
r2ui.history = r2ui.history.splice (0,r2ui.history_idx);
|
||||
r2ui.history_idx++;
|
||||
r2ui.history.push (x);
|
||||
}
|
||||
};
|
||||
|
||||
r2ui.history_pop = function () {
|
||||
// console.log("history pop");
|
||||
if (r2ui.history_idx == r2ui.history.length) r2ui.history_idx--;
|
||||
// console.log(r2ui.history_idx + "/" + r2ui.history.length);
|
||||
return r2ui.history.pop();
|
||||
};
|
||||
|
||||
r2ui.history_last = function () {
|
||||
if (r2ui.history.length > 0) {
|
||||
return r2ui.history[r2ui.history_idx - 1];
|
||||
}
|
||||
};
|
||||
|
||||
r2ui.history_prev = function () {
|
||||
// console.log("history prev");
|
||||
if (r2ui.history_idx > 1) r2ui.history_idx--;
|
||||
// console.log(r2ui.history_idx + "/" + r2ui.history.length);
|
||||
return r2ui.history[r2ui.history_idx - 1];
|
||||
};
|
||||
|
||||
r2ui.history_next = function () {
|
||||
// console.log("history next");
|
||||
var ret = r2ui.history[r2ui.history_idx];
|
||||
if (r2ui.history_idx < r2ui.history.length) r2ui.history_idx++;
|
||||
// console.log(r2ui.history_idx + "/" + r2ui.history.length);
|
||||
return ret;
|
||||
};
|
||||
|
||||
r2ui.next_instruction = function() {
|
||||
var offset = parseInt(r2ui.history_last(), 16);
|
||||
r2.cmd ("pdl 1", function (x) {
|
||||
offset += parseInt(x.trim());
|
||||
});
|
||||
return "0x" + offset.toString(16);
|
||||
};
|
||||
|
||||
r2ui.prev_instruction = function() {
|
||||
var offset = parseInt(r2ui.history_last(), 16);
|
||||
r2.cmdj("pdfj", function (x) {
|
||||
if (x !== undefined && x !== null) {
|
||||
for (var i in x.ops) {
|
||||
if (i === 0) continue;
|
||||
var opcode = x.ops[i];
|
||||
if (opcode.offset == offset) {
|
||||
offset = x.ops[i-1].offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return "0x" + offset.toString(16);
|
||||
};
|
||||
|
||||
r2ui.seek = function (addr, push, scroll) {
|
||||
if (addr === undefined) return;
|
||||
// Resolve flag in case we dont have an address
|
||||
if (addr.indexOf("0x") === 0) {
|
||||
addr = address_canonicalize(addr);
|
||||
} else {
|
||||
var a = r2.get_flag_address(addr);
|
||||
if (a !== null) {
|
||||
addr = address_canonicalize(a);
|
||||
} else {
|
||||
r2.cmd("ss " + addr + ";s", function(x) {
|
||||
addr = address_canonicalize(x.replace('\n',''));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (push) r2ui.history_push(addr);
|
||||
|
||||
// if (r2ui.ra.getIndex ()==2) r2ui.ra.setIndex (1);
|
||||
|
||||
r2.cmd ("ss " + addr, function () {
|
||||
r2ui._dis.seek(addr, scroll);
|
||||
r2ui._hex.seek(addr, scroll);
|
||||
});
|
||||
// if (r2ui._dis.tmp_address !== undefined) r2ui._dis.tmp_address = addr;
|
||||
};
|
||||
|
||||
r2ui.seek_in_graph = function (addr, push) {
|
||||
if (push) r2ui.history_push (addr);
|
||||
|
||||
// if (r2ui.ra.getIndex ()==2) r2ui.ra.setIndex (1);
|
||||
|
||||
r2.cmd ("ss "+addr, function () {
|
||||
rehighlight_iaddress(addr);
|
||||
r2ui._hex.seek(addr);
|
||||
r2ui._hex.scrollTo(0, 0);
|
||||
});
|
||||
};
|
||||
|
||||
r2ui.seek_prev = function () {
|
||||
// XXX. this is only for disasm
|
||||
var addr = r2ui.history.pop ();
|
||||
r2.cmd("ss "+addr, function () {
|
||||
r2ui._dis.seek(addr);
|
||||
r2ui._dis.scrollTo(0, 0);
|
||||
r2ui._hex.seek(addr);
|
||||
r2ui._hex.scrollTo(0, 0);
|
||||
});
|
||||
};
|
||||
|
||||
/* used from mainpanel */
|
||||
r2ui.openpage = function(addr, idx) {
|
||||
if (idx === undefined) {
|
||||
idx = addr;
|
||||
addr = undefined;
|
||||
}
|
||||
if (addr !== undefined) {
|
||||
r2ui.seek(addr, true);
|
||||
}
|
||||
|
||||
// What is this for?
|
||||
if (r2ui.ra.getIndex()==2) r2ui.ra.setIndex(1);
|
||||
|
||||
r2ui.mp.openPage(idx);
|
||||
|
||||
};
|
||||
|
||||
r2ui.opendis = function (addr) {
|
||||
r2ui.openpage(addr, 0);
|
||||
};
|
||||
|
||||
r2ui.openhex = function (addr) {
|
||||
r2ui.openpage(addr, 2);
|
||||
};
|
||||
|
||||
|
109
src/html/radar.html
Normal file
@ -0,0 +1,109 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Statistics</title>
|
||||
<script src="qrc:/html/Chart.js"></script>
|
||||
<script src="qrc:/html/utils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width: 100%; overflow: hidden;">
|
||||
<div id="canvas-holder" style="width:40%; float: left;">
|
||||
<canvas id="canvas" width="230" height="230"/>
|
||||
</div>
|
||||
<div id="canvas-holder" style="width:40%; margin-left: 500px;">
|
||||
<canvas id="canvas2" width="230" height="230"/>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var chartColors = window.chartColors;
|
||||
var color = Chart.helpers.color;
|
||||
var lineChartData = {
|
||||
type: 'radar',
|
||||
data: {
|
||||
labels : ["Functions","Imports","Symbols","Strings","Relocs", "Sections"],
|
||||
datasets : [
|
||||
{
|
||||
label: "Amount",
|
||||
backgroundColor: color(window.chartColors.blue).alpha(0.2).rgbString(),
|
||||
borderColor: window.chartColors.blue,
|
||||
pointBackgroundColor: window.chartColors.blue,
|
||||
data : [MEOW]
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
title: {
|
||||
display: false,
|
||||
text: 'Binary statistics'
|
||||
},
|
||||
tooltips: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
displayColors: false,
|
||||
},
|
||||
scale: {
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var config = {
|
||||
data: {
|
||||
datasets: [{
|
||||
data: [WOEM],
|
||||
backgroundColor: [
|
||||
color(chartColors.red).alpha(0.5).rgbString(),
|
||||
color(chartColors.blue).alpha(0.5).rgbString(),
|
||||
color(chartColors.yellow).alpha(0.5).rgbString(),
|
||||
color(chartColors.green).alpha(0.5).rgbString(),
|
||||
color(chartColors.purple).alpha(0.5).rgbString(),
|
||||
color(chartColors.grey).alpha(0.5).rgbString(),
|
||||
]
|
||||
}],
|
||||
labels : ["Functions","Imports","Symbols","Strings","Relocs", "Sections"]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
title: {
|
||||
display: false,
|
||||
text: 'Chart.js Polar Area Chart'
|
||||
},
|
||||
tooltips: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
displayColors: false,
|
||||
},
|
||||
scale: {
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
},
|
||||
reverse: false
|
||||
},
|
||||
animation: {
|
||||
duration: 0,
|
||||
animateRotate: false,
|
||||
animateScale: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
window.onload = function(){
|
||||
var ctx = document.getElementById("canvas");
|
||||
window.myLine = new Chart(ctx, lineChartData);
|
||||
var ctx2 = document.getElementById("canvas2");
|
||||
window.myPolarArea2= Chart.PolarArea(ctx2, config);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
86
src/html/stats.html
Normal file
@ -0,0 +1,86 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Statistics</title>
|
||||
<script src="qrc:/html/Chart.js"></script>
|
||||
<script src="qrc:/html/utils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%; height:100%;">
|
||||
<canvas id="canvas" height="360" width="890"></canvas>
|
||||
</div>
|
||||
<script>
|
||||
var lineChartData = {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels : ["Functions","Imports","Symbols","Strings","Relocs", "Sections"],
|
||||
datasets : [
|
||||
{
|
||||
fill: false,
|
||||
lineTension: 0.1,
|
||||
borderCapStyle: 'butt',
|
||||
borderDash: [],
|
||||
borderDashOffset: 0.0,
|
||||
borderJoinStyle: 'miter',
|
||||
pointBorderWidth: 1,
|
||||
pointHoverRadius: 5,
|
||||
pointHoverBorderWidth: 2,
|
||||
pointRadius: 1,
|
||||
pointHitRadius: 10,
|
||||
spanGaps: false,
|
||||
label: "Found",
|
||||
backgroundColor: window.chartColors.blue,
|
||||
borderColor: window.chartColors.blue,
|
||||
data : [MEOW]
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
title:{
|
||||
display: false,
|
||||
text:'Binary statistics'
|
||||
},
|
||||
tooltips: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
displayColors: false,
|
||||
},
|
||||
hover: {
|
||||
mode: 'nearest',
|
||||
intersect: true
|
||||
},
|
||||
animation: {
|
||||
duration: 0
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
display: true,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Flags'
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
display: true,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Value'
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
window.onload = function(){
|
||||
var ctx = document.getElementById("canvas").getContext("2d");
|
||||
window.myLine = new Chart(ctx, lineChartData);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
13
src/html/utils.js
Normal file
@ -0,0 +1,13 @@
|
||||
window.chartColors = {
|
||||
red: 'rgb(255, 99, 132)',
|
||||
orange: 'rgb(255, 159, 64)',
|
||||
yellow: 'rgb(255, 205, 86)',
|
||||
green: 'rgb(75, 192, 192)',
|
||||
blue: 'rgb(54, 162, 235)',
|
||||
purple: 'rgb(153, 102, 255)',
|
||||
grey: 'rgb(231,233,237)'
|
||||
};
|
||||
|
||||
window.randomScalingFactor = function() {
|
||||
return (Math.random() > 0.5 ? 1.0 : -1.0) * Math.round(Math.random() * 100);
|
||||
}
|
1302
src/html/viz.js
Normal file
BIN
src/img/Enso copy.icns
Normal file
BIN
src/img/Enso.icns
Normal file
16
src/img/Enso.svg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/img/Logo simple white.xcf
Normal file
BIN
src/img/Logo simple.xcf
Normal file
BIN
src/img/Logo.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
src/img/Logo.xcf
Normal file
BIN
src/img/icons/arrow_left.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
src/img/icons/arrow_right.png
Normal file
After Width: | Height: | Size: 243 B |
BIN
src/img/icons/clear_light.png
Normal file
After Width: | Height: | Size: 252 B |
BIN
src/img/icons/cloud.png
Normal file
After Width: | Height: | Size: 320 B |
BIN
src/img/icons/cloud_white.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
src/img/icons/cog.png
Normal file
After Width: | Height: | Size: 340 B |
BIN
src/img/icons/cog_light.png
Normal file
After Width: | Height: | Size: 342 B |
BIN
src/img/icons/cog_white.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
src/img/icons/disas_light.png
Normal file
After Width: | Height: | Size: 158 B |
BIN
src/img/icons/disas_white.png
Normal file
After Width: | Height: | Size: 149 B |
BIN
src/img/icons/down.png
Normal file
After Width: | Height: | Size: 207 B |
BIN
src/img/icons/down_white.png
Normal file
After Width: | Height: | Size: 174 B |
BIN
src/img/icons/edit_light.png
Normal file
After Width: | Height: | Size: 267 B |
BIN
src/img/icons/equalizer.png
Normal file
After Width: | Height: | Size: 198 B |
BIN
src/img/icons/eye.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
src/img/icons/eye_white.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
src/img/icons/graph_light.png
Normal file
After Width: | Height: | Size: 256 B |
BIN
src/img/icons/graph_white.png
Normal file
After Width: | Height: | Size: 217 B |
BIN
src/img/icons/help.png
Normal file
After Width: | Height: | Size: 222 B |
BIN
src/img/icons/hexdump_light.png
Normal file
After Width: | Height: | Size: 137 B |
BIN
src/img/icons/hexdump_white.png
Normal file
After Width: | Height: | Size: 137 B |
BIN
src/img/icons/left.png
Normal file
After Width: | Height: | Size: 763 B |
BIN
src/img/icons/load_light.png
Normal file
After Width: | Height: | Size: 305 B |
BIN
src/img/icons/lock.png
Normal file
After Width: | Height: | Size: 274 B |
BIN
src/img/icons/lock_white.png
Normal file
After Width: | Height: | Size: 226 B |
BIN
src/img/icons/new_light.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
src/img/icons/play.png
Normal file
After Width: | Height: | Size: 205 B |
BIN
src/img/icons/plus.png
Normal file
After Width: | Height: | Size: 141 B |
BIN
src/img/icons/polar.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
src/img/icons/polar_white.png
Normal file
After Width: | Height: | Size: 199 B |
BIN
src/img/icons/radar.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
src/img/icons/radar_white.png
Normal file
After Width: | Height: | Size: 188 B |
BIN
src/img/icons/redo.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/img/icons/right.png
Normal file
After Width: | Height: | Size: 697 B |
BIN
src/img/icons/run_light.png
Normal file
After Width: | Height: | Size: 283 B |
BIN
src/img/icons/save_light.png
Normal file
After Width: | Height: | Size: 272 B |
BIN
src/img/icons/spin.png
Normal file
After Width: | Height: | Size: 309 B |
BIN
src/img/icons/spin_grey.png
Normal file
After Width: | Height: | Size: 309 B |
BIN
src/img/icons/spin_white.png
Normal file
After Width: | Height: | Size: 252 B |
BIN
src/img/icons/tabs.png
Normal file
After Width: | Height: | Size: 170 B |
BIN
src/img/icons/tabs_white.png
Normal file
After Width: | Height: | Size: 146 B |