#include "InformationManager.hxx"
+#include "bindings/Interpreter.hxx"
#include "disassembler/llvm/LLVMDisassembler.hxx"
#include "core/Function.hxx"
#include "core/BasicBlock.hxx"
: logger(log4cxx::Logger::getLogger("core.InformationManager"))
{
current_information_manager = this;
+
+ QPluginLoader* loader = new QPluginLoader("libguilePlugin", NULL);
+ if (!loader->load())
+ LOG4CXX_ERROR(logger, "Loading plugin failed: " << loader->errorString().toStdString());
+ interpreters["GUILE"] = qobject_cast<Interpreter*>(loader->instance());
+ plugins.push_back(loader);
}
InformationManager::~InformationManager() {
for (auto f : functions)
delete f.second;
+
+ for (auto i : plugins)
+ delete i;
}
void InformationManager::reset(const std::string& filename) {
}
+/* *********************************
+ * Accessors for the Interpreter map
+ */
+
+Interpreter* InformationManager::getInterpreter(const std::string& name) {
+ auto it = interpreters.find(name);
+ if (it != interpreters.end())
+ return it->second;
+ else
+ return NULL;
+}
+
+std::map<std::string, Interpreter*>::const_iterator InformationManager::beginInterpreters() {
+ return interpreters.begin();
+}
+std::map<std::string, Interpreter*>::const_iterator InformationManager::endInterpreters() {
+ return interpreters.end();
+}
+
/* ********************************
* Factory methods for data classes
#include <functional>
#include <string>
#include <map>
+#include <vector>
#include "disassembler/Disassembler.hxx"
+class Interpreter;
+
class Function;
class BasicBlock;
class Comment;
class QString;
class QTemporaryFile;
+class QPluginLoader;
class InformationManager {
public:
std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
+ Interpreter* getInterpreter(const std::string& name);
+ bool hasInterpreters() const {return interpreters.size() != 0;}
+ std::map<std::string, Interpreter*>::const_iterator beginInterpreters();
+ std::map<std::string, Interpreter*>::const_iterator endInterpreters();
+
+
/* Protocoll:
*
* Users may allocate new Data containers with the new*()
boost::signals2::signal<void (const std::string& name)> new_dyn_symbol_signal;
boost::signals2::signal<void (RenameFunctionEvent*)> rename_function_signal;
std::unique_ptr<Disassembler> disassembler;
+ std::map<std::string, Interpreter*> interpreters;
std::map<uint64_t, Function*> functions;
std::map<uint64_t, BasicBlock*> blocks;
std::string filename;
std::unique_ptr<QTemporaryFile> tmpfile;
+ std::vector<QPluginLoader*> plugins;
log4cxx::LoggerPtr logger;
};
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<Interpreter*>(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);
[&]() {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Script"), "",
tr("Binaries") + " (*." +
- interpreter["GUILE"]->fileExtension().c_str() + ")");
+ manager->getInterpreter("GUILE")->fileExtension().c_str() + ")");
std::stringstream a, b;
std::string c;
- interpreter["GUILE"]->loadFile(fileName.toStdString(), a, b, c);
+ manager->getInterpreter("GUILE")->loadFile(fileName.toStdString(), a, b, c);
});
listWidget = new QTreeWidget();
class FunctionWidget;
class BasicBlockWidget;
class FridaDock;
-class Interpreter;
class Mainwindow : public QMainWindow {
Q_OBJECT
std::map<QTreeWidgetItem*, FunctionWidget*> objects_list;
std::map<uint64_t, QTreeWidgetItem*> objects_list_by_address;
std::vector<QTreeWidgetItem*> group_list;
- std::map<std::string, Interpreter*> interpreter;
InformationManager* manager;
log4cxx::LoggerPtr logger;