find_package(Qt5 CONFIG REQUIRED Widgets Gui)
find_package(PkgConfig)
pkg_check_modules(LOG4CXX REQUIRED liblog4cxx)
+pkg_check_modules(GUILE REQUIRED guile-2.0)
#add_compile_options(${LOG4CXX_CFLAGS})
add_definitions(${LOG4CXX_CFLAGS})
+add_definitions(${GUILE_CFLAGS})
find_program(LLVM_CONFIG llvm-config-3.5)
src/main.cxx
src/gui/Mainwindow.cxx
src/gui/widgets/BasicBlockWidget.cxx
+ src/gui/widgets/ScriptingDock.cxx
src/disassembler/Disassembler.cxx
src/disassembler/llvm/LLVMDisassembler.cxx
)
src/gui/qt.hxx
src/gui/Mainwindow.hxx
src/gui/widgets/BasicBlockWidget.hxx
+ src/gui/widgets/ScriptingDock.hxx
src/disassembler/llvm/LLVMDisassembler.hxx
src/disassembler/Disassembler.hxx
)
qt5_use_modules(frida Widgets)
INCLUDE_DIRECTORIES("src")
-TARGET_LINK_LIBRARIES(frida ${QT_LIBRARIES} ${LLVM_LDFLAGS} ${LLVM_LIBS} ${LOG4CXX_LDFLAGS} -ltinfo -lpthread -ldl)
+TARGET_LINK_LIBRARIES(frida ${QT_LIBRARIES} ${LLVM_LDFLAGS} ${LLVM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} -ltinfo -lpthread -ldl)
fileMenu->addSeparator();
fileMenu->addAction(exitAction);
+ scripting = new ScriptingDock(tr("Scripting"), this);
+ scripting->setAllowedAreas(Qt::BottomDockWidgetArea);
+ addDockWidget(Qt::BottomDockWidgetArea, scripting);
+
listWidget = new QListWidget();
stackedWidget = new QStackedWidget();
dockWidget = new QDockWidget(tr("Functions"), this);
#include "disassembler/Disassembler.hxx"
#include "widgets/BasicBlockWidget.hxx"
+#include "widgets/ScriptingDock.hxx"
class Mainwindow : public QMainWindow {
Q_OBJECT
QListWidget * listWidget;
QStackedWidget * stackedWidget;
QDockWidget * dockWidget;
+ ScriptingDock * scripting;
QAction *exitAction;
QAction *openAction;
#include <QPainter>
#include <QTableWidget>
#include <QVBoxLayout>
+#include <QGraphicsSceneMouseEvent>
+#include <QTextBrowser>
+#include <QPushButton>
+#include <QLineEdit>
--- /dev/null
+#include "ScriptingDock.hxx"
+
+void ScriptingDock::doEvaluate() {
+ QString text = line->text();
+ line->clear();
+ LOG4CXX_INFO(logger, "Evaluating String \"" << text.toStdString() << "\"");
+ browser->append(QString("> ") + text);
+
+ SCM result_obj = scm_c_eval_string(text.toStdString().c_str());
+ SCM result_str = scm_object_to_string(result_obj, SCM_UNDEFINED);
+
+ SCM output = scm_get_output_string(guile_output_port);
+ browser->append(scm_to_locale_string(output));
+ browser->append(scm_to_locale_string(result_str));
+}
--- /dev/null
+#ifndef INCLUDE__ScriptingDock_hxx
+#define INCLUDE__ScriptingDock_hxx
+#include "gui/qt.hxx"
+#include <libguile.h>
+#include <log4cxx/logger.h>
+
+class ScriptingDock : public QDockWidget {
+ Q_OBJECT
+
+public:
+ ScriptingDock(const QString& title, QWidget * parent = 0)
+ : logger(log4cxx::Logger::getLogger("ScriptingDock")) {
+ QDockWidget(title, parent);
+ QWidget * widget = new QWidget;
+ widget->setLayout(layout = new QGridLayout(this));
+ layout->addWidget(browser = new QTextBrowser, 0, 0, 1, 0);
+ layout->addWidget(line = new QLineEdit, 1, 0);
+ layout->addWidget(button = new QPushButton(tr("Evaluate")), 1, 1);
+ setWidget(widget);
+ connect(button, SIGNAL(released()), this, SLOT(doEvaluate()));
+ connect(line, SIGNAL(returnPressed()), this, SLOT(doEvaluate()));
+ scm_init_guile();
+ guile_output_port = scm_open_output_string();
+ scm_set_current_output_port(guile_output_port);
+ }
+private:
+ log4cxx::LoggerPtr logger;
+
+ QTextBrowser * browser;
+ QGridLayout * layout;
+ QPushButton * button;
+ QLineEdit * line;
+
+ SCM guile_output_port;
+private slots:
+ void doEvaluate();
+};
+
+#endif