X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2FMainwindow.cxx;h=39fc83e0d83b4506ccc8d4e56ef5ca5ec138d2af;hp=f28f1e25a23161630c985e52319ab13d74582660;hb=af104b02984cca1973051b301c946d5937b9af4d;hpb=cab6494b97d1626c7b9285b69df324d9c9953614 diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index f28f1e2..39fc83e 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -6,6 +6,7 @@ #include "core/BasicBlock.hxx" #include "core/InformationManager.hxx" #include "core/events/RenameFunctionEvent.hxx" +#include "core/events/NewFunctionEvent.hxx" #include "widgets/FridaDock.hxx" #include "widgets/LogDock.hxx" @@ -43,15 +44,11 @@ Mainwindow::Mainwindow(InformationManager* mgr) QMenu* interpretermenu = menuBar()->addMenu(tr("&Interpreter")); - QPluginLoader* loader = new QPluginLoader("libguilePlugin", this); - if (!loader->load()) - LOG4CXX_ERROR(logger, "Loading plugin failed: " << loader->errorString().toStdString()); - interpreter["GUILE"] = qobject_cast(loader->instance()); fdock = new FridaDock(tr("Frida Dock"), this); fdock->addTab(new LogDock(fdock), "Log"); - fdock->addTab(new ScriptingDock(interpreter["GUILE"], fdock), "guile"); + fdock->addTab(new ScriptingDock(manager->getInterpreter("GUILE"), fdock), "guile"); fdock->setAllowedAreas(Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, fdock); QAction* guileLoad = new QAction(tr("&GUILE"), this); @@ -59,11 +56,13 @@ Mainwindow::Mainwindow(InformationManager* mgr) connect(guileLoad, &QAction::triggered, [&]() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Script"), "", - tr("Binaries") + " (*." + - interpreter["GUILE"]->fileExtension().c_str() + ")"); - std::stringstream a, b; - std::string c; - interpreter["GUILE"]->loadFile(fileName.toStdString(), a, b, c); + tr("Scripts") + " (*." + + manager->getInterpreter("GUILE")->fileExtension().c_str() + ")"); + if(! fileName.isNull()) { + std::stringstream a, b; + std::string c; + manager->getInterpreter("GUILE")->loadFile(fileName.toStdString(), a, b, c); + } }); listWidget = new QTreeWidget(); @@ -91,12 +90,16 @@ Mainwindow::Mainwindow(InformationManager* mgr) QTreeWidgetItem * external = new QTreeWidgetItem(listWidget, QStringList("External Functions")); external->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); external->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd))); - mgr->connect_new_function_signal([&] (Function* fun) {addFunction(fun);}); - mgr->connect_new_dyn_symbol_signal([=] (const std::string& name) { - auto item = new QTreeWidgetItem(external, QStringList(name.c_str())); - item->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->connect_rename_function_signal([&](RenameFunctionEvent* event) { + 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]; @@ -128,15 +131,29 @@ void Mainwindow::quit() } void Mainwindow::open() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", - tr("Binaries (*)")); - manager->reset(fileName.toStdString()); + QFileDialog dialog(this, tr("Open bianry"), "", tr("Binaries (*)")); + + if (dialog.exec()) { + QStringList files = dialog.selectedFiles(); + if(1 != files.size()) { + LOG4CXX_ERROR(logger, "Needs exactly one file name") + } else { + manager->reset(files[0].toStdString()); + } + } } void Mainwindow::load() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", - tr("Frida Archives (*.frida)")); - manager->load(fileName.toStdString()); + QFileDialog dialog(this, tr("Open saved FrIDa file"), "", tr("Frida Archives (*.frida)")); + + if (dialog.exec()) { + QStringList files = dialog.selectedFiles(); + if(1 != files.size()) { + LOG4CXX_ERROR(logger, "Needs exactly one file name") + } else { + manager->load(files[0].toStdString()); + } + } } void Mainwindow::save() {