1 #ifndef INCLUDE__InformationManager_hxx
2 #define INCLUDE__InformationManager_hxx
4 #include <log4cxx/logger.h>
12 #include "disassembler/Disassembler.hxx"
14 #include "core/events/NewFunctionEvent.hxx"
22 class RenameFunctionEvent;
23 class NewFunctionEvent;
24 class ChangeCommentEvent;
30 class InformationManager : public QObject {
37 void renameFunctionEvent(RenameFunctionEvent* event);
38 void newFunctionEvent(NewFunctionEvent event);
39 void changeCommentEvent(ChangeCommentEvent* event);
43 ~InformationManager();
45 // Start working on a fresh binary
46 void reset(const std::string& filename);
48 // Load a saved binary
49 void load(const std::string& filename);
51 // Save current state to disk
52 void save(const std::string& filename);
54 Disassembler* getDisassembler()
55 { return disassembler.get(); }
58 /* Used by the disassembler to determine whether to use unsafe
59 * heuristics for finding an entry point
61 bool hasFunctions() const {return functions.size() != 0;}
63 Function* getFunction(uint64_t address);
64 std::map<uint64_t, Function*>::const_iterator beginFunctions();
65 std::map<uint64_t, Function*>::const_iterator endFunctions();
67 BasicBlock* getBasicBlock(uint64_t address);
68 std::map<uint64_t, BasicBlock*>::const_iterator beginBasicBlocks();
69 std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
72 std::multimap<uint64_t, Comment*>::const_iterator,
73 std::multimap<uint64_t, Comment*>::const_iterator>
74 getComments(uint64_t address);
75 std::multimap<uint64_t,Comment*>::const_iterator beginComments();
76 std::multimap<uint64_t,Comment*>::const_iterator endComments();
78 Interpreter* getInterpreter(const std::string& name);
79 bool hasInterpreters() const {return interpreters.size() != 0;}
80 std::map<std::string, Interpreter*>::const_iterator beginInterpreters();
81 std::map<std::string, Interpreter*>::const_iterator endInterpreters();
85 * Users may allocate new Data containers with the new*()
86 * functions. Once they have populated the information they hand
87 * over the object to the information manager using the finish*()
90 * if new*() returns NULL there already exists a function at the
91 * specified address. Users may then get the old object if they
92 * wish or (more likely) skip creating it. Uniqueness of the
93 * object is only guaranteed as compared to the finish()ed
96 * Users are responsible for destroying functions iff they do not
97 * finish them using the delete*() functions. Once the objects are
98 * finished, the information manager is responsible for cleaning
99 * up the memory. If delete*() is called on a finished object, bad
102 Function* newFunction(uint64_t address);
103 Function* newDynamicFunction(uint64_t address);
104 BasicBlock* newBasicBlock(uint64_t address);
105 Comment* newGlobalComment(uint64_t address);
106 Comment* newLocalComment(uint64_t address, Function* f);
107 void finishFunction(Function* f);
108 void finishBasicBlock(BasicBlock* b);
109 void finishComment(Comment* c);
110 void deleteFunction(Function* f);
111 void deleteBasicBlock(BasicBlock* b);
112 void deleteComment(Comment* c);
115 std::unique_ptr<Disassembler> disassembler;
117 std::map<std::string, Interpreter*> interpreters;
118 std::map<uint64_t, Function*> functions;
119 std::map<uint64_t, BasicBlock*> blocks;
120 std::multimap<uint64_t, Comment*> comments;
122 std::string filename;
123 std::unique_ptr<QTemporaryFile> tmpfile;
124 std::vector<QPluginLoader*> plugins;
126 QThread disassemblerThread;
127 log4cxx::LoggerPtr logger;
130 #endif /* INCLUDE__InformationManager_hxx */