X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fcore%2FInformationManager.hxx;h=ddba5a3f8e4080f49b4f8cedbd6a51cd47c9a1f5;hp=4e1b3187a52a081e5453aa9beb661af872170d55;hb=HEAD;hpb=64cdefa8eebaedef3a852b061d4df431b7e6c654 diff --git a/src/core/InformationManager.hxx b/src/core/InformationManager.hxx index 4e1b318..ddba5a3 100644 --- a/src/core/InformationManager.hxx +++ b/src/core/InformationManager.hxx @@ -1,47 +1,132 @@ #ifndef INCLUDE__InformationManager_hxx #define INCLUDE__InformationManager_hxx -#include +#include #include #include -#include +#include +#include +#include + +#include "qt.hxx" +#include "disassembler/Disassembler.hxx" + +#include "core/events/NewFunctionEvent.hxx" + +class Interpreter; -class Disassembler; class Function; +class BasicBlock; +class Comment; + +class RenameFunctionEvent; +class NewFunctionEvent; +class ChangeCommentEvent; class QString; +class QTemporaryFile; +class QPluginLoader; -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); - void save(const QString& filename); - boost::signals2::connection - connect_new_function_signal(std::function f) - { return new_function_signal.connect(f); } + // Load a saved binary + void load(const std::string& filename); - void signal_new_function(Function* f) - { functions.insert(f); new_function_signal(f); } + // Save current state to disk + void save(const std::string& filename); - boost::signals2::connection - connect_new_dyn_symbol_signal(std::function f) - { return new_dyn_symbol_signal.connect(f); } + Disassembler* getDisassembler() + { return disassembler.get(); } - void signal_new_dyn_symbol(const std::string& f) - { new_dyn_symbol_signal(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;} - boost::signals2::connection - connect_reset_signal(std::function f) - { return reset_signal.connect(f); } + uint64_t getEntryAddress() {return disassembler->entryAddress();} + + Function* getFunction(uint64_t address); + std::map::const_iterator beginFunctions(); + std::map::const_iterator endFunctions(); + + BasicBlock* getBasicBlock(uint64_t address); + std::map::const_iterator beginBasicBlocks(); + std::map::const_iterator endBasicBlocks(); + + std::pair< + std::multimap::const_iterator, + std::multimap::const_iterator> + getComments(uint64_t address); + std::multimap::const_iterator beginComments(); + std::multimap::const_iterator endComments(); + + Interpreter* getInterpreter(const std::string& name); + bool hasInterpreters() const {return interpreters.size() != 0;} + std::map::const_iterator beginInterpreters(); + std::map::const_iterator endInterpreters(); + + /* Protocoll: + * + * Users may allocate new Data containers with the new*() + * functions. Once they have populated the information they hand + * over the object to the information manager using the finish*() + * functions. + * + * if new*() returns NULL there already exists a function at the + * specified address. Users may then get the old object if they + * wish or (more likely) skip creating it. Uniqueness of the + * object is only guaranteed as compared to the finish()ed + * objects. + * + * Users are responsible for destroying functions iff they do not + * finish them using the delete*() functions. Once the objects are + * finished, the information manager is responsible for cleaning + * up the memory. If delete*() is called on a finished object, bad + * thingsmay happen. + */ + Function* newFunction(uint64_t address); + Function* newDynamicFunction(uint64_t address); + BasicBlock* newBasicBlock(uint64_t address); + Comment* newGlobalComment(uint64_t address); + Comment* newLocalComment(uint64_t address, Function* f); + void finishFunction(Function* f); + void finishBasicBlock(BasicBlock* b); + void finishComment(Comment* c); + void deleteFunction(Function* f); + void deleteBasicBlock(BasicBlock* b); + void deleteComment(Comment* c); - Disassembler* getDisassembler() - { return disassembler.get(); } private: - boost::signals2::signal reset_signal; - boost::signals2::signal new_function_signal; - boost::signals2::signal new_dyn_symbol_signal; std::unique_ptr disassembler; - std::set functions; + + std::map interpreters; + std::map functions; + std::map blocks; + std::multimap comments; + + std::string filename; + std::unique_ptr tmpfile; + std::vector plugins; + + QThread disassemblerThread; + log4cxx::LoggerPtr logger; }; #endif /* INCLUDE__InformationManager_hxx */