]>
git.siccegge.de Git - frida/frida.git/blob - src/core/InformationManager.cxx
1ea4ba0cb0357f7a12235d8af3adb17592659043
1 #include "InformationManager.hxx"
2 #include "disassembler/llvm/LLVMDisassembler.hxx"
3 #include "core/Function.hxx"
4 #include "core/BasicBlock.hxx"
5 #include "core/Comment.hxx"
8 #include <quazip/quazip.h>
9 #include <quazip/quazipfile.h>
11 InformationManager::InformationManager()
12 : logger(log4cxx::Logger::getLogger("InformationManager"))
15 InformationManager::~InformationManager() {
19 for (auto f
: functions
)
23 void InformationManager::reset(const std::string
& filename
) {
24 disassembler
.reset(createLLVMDisassembler(filename
, this));
25 if (disassembler
.get() != NULL
)
26 disassembler
.get()->start();
29 void InformationManager::save(const QString
& filename
) {
31 zip
.open(QuaZip::mdCreate
);
32 zip
.setComment("FRIDA 0.0");
33 QuaZipFile
outZipFile(&zip
);
35 for (auto funpair
: functions
) {
36 Function
* fun
= funpair
.second
;
37 QuaZipNewInfo
zipinfo(fun
->getName().c_str());
38 zipinfo
.setPermissions(static_cast<QFile::Permissions
>(0x6444));
39 outZipFile
.open(QIODevice::WriteOnly
, zipinfo
);
40 QXmlStreamWriter
stream(&outZipFile
);
41 stream
.setAutoFormatting(true);
42 stream
.setAutoFormattingIndent(-1);
43 stream
.writeStartDocument();
45 fun
->serialize(stream
);
47 stream
.writeEndDocument();
54 void InformationManager::signal_new_function(Function
* fun
) {
57 Function
* InformationManager::getFunction(uint64_t address
) {
58 auto it
= functions
.find(address
);
59 if (it
!= functions
.end())
65 BasicBlock
* InformationManager::getBasicBlock(uint64_t address
) {
66 auto it
= blocks
.find(address
);
67 if (it
!= blocks
.end())
73 Function
* InformationManager::newFunction(uint64_t address
) {
74 Function
* fun
= new Function(address
, this);
75 functions
.insert(std::make_pair(address
, fun
));
79 BasicBlock
* InformationManager::newBasicBlock(uint64_t address
) {
80 BasicBlock
* block
= new BasicBlock(address
, this);
81 blocks
.insert(std::make_pair(address
, block
));
85 Comment
* InformationManager::newGlobalComment(uint64_t address
) {
89 Comment
* InformationManager::newLocalComment(uint64_t address
, Function
* f
) {
93 void InformationManager::finishFunction(Function
* fun
) {
94 LOG4CXX_DEBUG(logger
, "Finishing function " << fun
->getName());
95 for (auto b
: fun
->blocks()) {
96 BasicBlock
* bl
= b
.second
;
97 blocks
.insert(std::make_pair(bl
->getStartAddress(), bl
));
99 new_function_signal(fun
);
102 void InformationManager::finishBasicBlock(BasicBlock
* b
) {
105 void InformationManager::finnishComment(Comment
* c
) {
108 void InformationManager::deleteFunction(Function
* f
) {
109 functions
.erase(f
->getStartAddress());
113 void InformationManager::deleteBasicBlock(BasicBlock
* b
) {
114 blocks
.erase(b
->getStartAddress());
118 void InformationManager::deleteComment(Comment
* c
) {