#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"
+#include "core/events/NewFunctionEvent.hxx"
+
class Interpreter;
class Function;
class QTemporaryFile;
class QPluginLoader;
-using boost::signals2::connection;
-
-class InformationManager {
+class InformationManager : public QObject {
+#ifndef SWIG
+ Q_OBJECT
+signals:
+#else
+public:
+#endif
+ void renameFunctionEvent(RenameFunctionEvent* event);
+ void newFunctionEvent(NewFunctionEvent event);
+ void changeCommentEvent(ChangeCommentEvent* event);
+ void resetEvent();
public:
InformationManager();
~InformationManager();
+ // Start working on a fresh binary
void reset(const std::string& filename);
+
+ // Load a saved binary
void load(const std::string& filename);
+
+ // Save current state to disk
void save(const std::string& filename);
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); }
-
- connection connect_reset_signal(std::function<void ()> f)
- { return reset_signal.connect(f); }
+ // Accessors
+ /* Used by the disassembler to determine whether to use unsafe
+ * heuristics for finding an entry point
+ */
+ bool hasFunctions() const {return functions.size() != 0;}
+
+ uint64_t getEntryAddress() {return disassembler->entryAddress();}
Function* getFunction(uint64_t address);
- bool hasFunctions() const {return functions.size() != 0;}
std::map<uint64_t, Function*>::const_iterator beginFunctions();
std::map<uint64_t, Function*>::const_iterator endFunctions();
BasicBlock* getBasicBlock(uint64_t address);
- bool hasBasicBlocks() const {return blocks.size() != 0;}
std::map<uint64_t, BasicBlock*>::const_iterator beginBasicBlocks();
std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
+ std::pair<
+ std::multimap<uint64_t, Comment*>::const_iterator,
+ std::multimap<uint64_t, Comment*>::const_iterator>
+ getComments(uint64_t address);
+ std::multimap<uint64_t,Comment*>::const_iterator beginComments();
+ std::multimap<uint64_t,Comment*>::const_iterator endComments();
+
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*()
Comment* newLocalComment(uint64_t address, Function* f);
void finishFunction(Function* f);
void finishBasicBlock(BasicBlock* b);
- void finnishComment(Comment* c);
+ void finishComment(Comment* c);
void deleteFunction(Function* f);
void deleteBasicBlock(BasicBlock* b);
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;
std::unique_ptr<QTemporaryFile> tmpfile;
std::vector<QPluginLoader*> plugins;
+ QThread disassemblerThread;
log4cxx::LoggerPtr logger;
};