]>
git.siccegge.de Git - frida/frida.git/blob - src/core/InformationManager.cxx
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() {
15 for (auto f
: functions
)
19 void InformationManager::reset(const std::string
& filename
) {
20 disassembler
.reset(createLLVMDisassembler(filename
, this));
21 if (disassembler
.get() != NULL
)
22 disassembler
.get()->start();
25 void InformationManager::save(const QString
& filename
) {
27 zip
.open(QuaZip::mdCreate
);
28 zip
.setComment("FRIDA 0.0");
29 QuaZipFile
outZipFile(&zip
);
31 for (auto funpair
: functions
) {
32 Function
* fun
= funpair
.second
;
33 QuaZipNewInfo
zipinfo(fun
->getName().c_str());
34 zipinfo
.setPermissions(static_cast<QFile::Permissions
>(0x6444));
35 outZipFile
.open(QIODevice::WriteOnly
, zipinfo
);
36 QXmlStreamWriter
stream(&outZipFile
);
37 stream
.setAutoFormatting(true);
38 stream
.setAutoFormattingIndent(-1);
39 stream
.writeStartDocument();
41 fun
->serialize(stream
);
43 stream
.writeEndDocument();
50 void InformationManager::signal_new_function(Function
* fun
) {
53 Function
* InformationManager::getFunction(uint64_t address
) {
54 auto it
= functions
.find(address
);
55 if (it
!= functions
.end())
61 BasicBlock
* InformationManager::getBasicBlock(uint64_t address
) {
62 auto it
= blocks
.find(address
);
63 if (it
!= blocks
.end())
69 Function
* InformationManager::newFunction(uint64_t address
) {
70 Function
* fun
= new Function(address
, this);
71 functions
.insert(std::make_pair(address
, fun
));
75 BasicBlock
* InformationManager::newBasicBlock(uint64_t address
) {
76 BasicBlock
* block
= new BasicBlock(address
, this);
77 blocks
.insert(std::make_pair(address
, block
));
81 Comment
* InformationManager::newGlobalComment(uint64_t address
) {
85 Comment
* InformationManager::newLocalComment(uint64_t address
, Function
* f
) {
89 void InformationManager::finishFunction(Function
* fun
) {
90 for (auto b
: fun
->blocks()) {
91 BasicBlock
* bl
= b
.second
;
92 blocks
.insert(std::make_pair(bl
->getStartAddress(), bl
));
94 new_function_signal(fun
);
97 void InformationManager::finishBasicBlock(BasicBlock
* b
) {
100 void InformationManager::finnishComment(Comment
* c
) {
103 void InformationManager::deleteFunction(Function
* f
) {
104 functions
.erase(f
->getStartAddress());
108 void InformationManager::deleteBasicBlock(BasicBlock
* b
) {
109 blocks
.erase(b
->getStartAddress());
113 void InformationManager::deleteComment(Comment
* c
) {