It's actually fun! And was less pain than expected.
Seems receiving commands from geiser is still kind-of broken but we'll
see
Ref T24
SET_SOURCE_FILES_PROPERTIES(src/bindings/guile/frida.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_MODULE(guile-frida-binding guile src/bindings/guile/frida.i)
SWIG_LINK_LIBRARIES(guile-frida-binding ${GUILE_LDFLAGS})
-
+qt5_use_modules(guile-frida-binding Widgets)
#################
# Main Programm #
void Comment::setText(const std::string& text) {
ChangeCommentEvent event(address, location, this);
this->text = text;
- manager->dispatch(&event);
+ Q_EMIT manager->changeCommentEvent(&event);
}
uint64_t Comment::getAddress() {
void Function::setName(const std::string& new_name) {
name = new_name;
RenameFunctionEvent event(new_name, this, start_address);
- manager->dispatch(&event);
+ Q_EMIT manager->renameFunctionEvent(&event);
}
void Function::serialize(QXmlStreamWriter& stream) {
blocks.insert(std::make_pair(bl->getStartAddress(), bl));
}
NewFunctionEvent event(fun->getStartAddress(), fun);
- dispatch(&event);
+ Q_EMIT newFunctionEvent(&event);
}
void InformationManager::finishBasicBlock(BasicBlock*) {
void InformationManager::finishComment(Comment* c) {
LOG4CXX_DEBUG(logger, "Finishing comment " << c->getAddress());
ChangeCommentEvent event(c->getAddress(), c->getLocation(), c);
- dispatch(&event);
+ Q_EMIT changeCommentEvent(&event);
}
void InformationManager::deleteFunction(Function* f) {
#define INCLUDE__InformationManager_hxx
#include <log4cxx/logger.h>
-#include <boost/signals2.hpp>
#include <functional>
#include <string>
#include <map>
#include <vector>
+#include <memory>
+#include "qt.hxx"
#include "disassembler/Disassembler.hxx"
class Interpreter;
class QTemporaryFile;
class QPluginLoader;
-using boost::signals2::connection;
-
-class InformationManager {
+class InformationManager : public QObject {
+#ifndef SWIG
+ Q_OBJECT
+Q_SIGNALS:
+#else
+public:
+#endif
+ void renameFunctionEvent(RenameFunctionEvent* event);
+ void newFunctionEvent(NewFunctionEvent* event);
+ void changeCommentEvent(ChangeCommentEvent* event);
+ void reset();
public:
InformationManager();
~InformationManager();
Disassembler* getDisassembler()
{ return disassembler.get(); }
- // Rename Function
- typedef std::function<void (RenameFunctionEvent*)> RenameFunctionHandler;
- connection registerRenameFunctionEvent(RenameFunctionHandler h)
- { return renameFunctionSignal.connect(h); }
- void dispatch(RenameFunctionEvent* event)
- { renameFunctionSignal(event); }
-
- // New Function
- typedef std::function<void (NewFunctionEvent*)> NewFunctionHandler;
- connection registerNewFunctionEvent(NewFunctionHandler h)
- { return newFunctionSignal.connect(h); }
- void dispatch(NewFunctionEvent* event)
- { newFunctionSignal(event); }
-
- // Change Comment
- typedef std::function<void (ChangeCommentEvent*)> ChangeCommentHandler;
- connection registerChangeCommentEvent(ChangeCommentHandler h)
- { return changeCommentSignal.connect(h); }
- void dispatch(ChangeCommentEvent* event)
- { changeCommentSignal(event); }
-
- // Reset frida
- connection connect_reset_signal(std::function<void ()> f)
- { return reset_signal.connect(f); }
-
// Accessors
Function* getFunction(uint64_t address);
bool hasFunctions() const {return functions.size() != 0;}
void deleteComment(Comment* c);
private:
- boost::signals2::signal<void (RenameFunctionEvent*)> renameFunctionSignal;
- boost::signals2::signal<void (NewFunctionEvent*)> newFunctionSignal;
- boost::signals2::signal<void (ChangeCommentEvent*)> changeCommentSignal;
-
- boost::signals2::signal<void ()> reset_signal;
-
std::unique_ptr<Disassembler> disassembler;
std::map<std::string, Interpreter*> interpreters;
QTreeWidgetItem * external = new QTreeWidgetItem(listWidget, QStringList("External Functions"));
external->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
external->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd)));
- mgr->registerNewFunctionEvent([=] (NewFunctionEvent* event) {
- std::string name = event->function->getName();
- if (event->function->isDynamic()) {
- auto item = new QTreeWidgetItem(external, QStringList(name.c_str()));
- item->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd)));
- } else {
- addFunction(event->function);
- }
- });
- mgr->registerRenameFunctionEvent([&](RenameFunctionEvent* event) {
- if (objects_list_by_address.find(event->address) == objects_list_by_address.end())
- return;
- auto item = objects_list_by_address[event->address];
- if (item) item->setText(0, event->new_name.c_str());
- });
+ connect(mgr, &InformationManager::newFunctionEvent,
+ [=] (NewFunctionEvent* event) {
+ std::string name = event->function->getName();
+ if (event->function->isDynamic()) {
+ auto item = new QTreeWidgetItem(external, QStringList(name.c_str()));
+ item->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd)));
+ } else {
+ addFunction(event->function);
+ }
+ });
+ connect(mgr, &InformationManager::renameFunctionEvent,
+ [&](RenameFunctionEvent* event) {
+ if (objects_list_by_address.find(event->address) == objects_list_by_address.end())
+ return;
+ auto item = objects_list_by_address[event->address];
+ if (item) item->setText(0, event->new_name.c_str());
+ });
setGlobalHotkeys();
}
, logger(log4cxx::Logger::getLogger("gui.BasicBlockWidget." + name.toStdString())) {
next[0] = NULL; next[1] = NULL;
- block->getManager()->registerRenameFunctionEvent([=](RenameFunctionEvent* event) {updateFunctionName(event);});
+ QObject::connect(block->getManager(), &InformationManager::renameFunctionEvent,
+ [=](RenameFunctionEvent* event) {updateFunctionName(event);});
_widget.reset(new CustomQGraphicsTextItem("", this));
_widget->setPos(5, 20);
});
instructions = block->getInstructions();
populateWidget();
- block->getManager()->registerChangeCommentEvent([=](ChangeCommentEvent* e) {changeCommentHandler(e);});
+ QObject::connect(block->getManager(), &InformationManager::changeCommentEvent,
+ [=](ChangeCommentEvent* e) {changeCommentHandler(e);});
}
void BasicBlockWidget::updateFunctionName(RenameFunctionEvent *event) {