]>
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"
7 #include <quazip/quazip.h>
8 #include <quazip/quazipfile.h>
10 InformationManager::~InformationManager() {
14 for (auto f
: functions
)
18 void InformationManager::reset(const std::string
& filename
) {
19 disassembler
.reset(createLLVMDisassembler(filename
, this));
20 if (disassembler
.get() != NULL
)
21 disassembler
.get()->start();
24 void InformationManager::save(const QString
& filename
) {
26 zip
.open(QuaZip::mdCreate
);
27 zip
.setComment("FRIDA 0.0");
28 QuaZipFile
outZipFile(&zip
);
30 for (auto funpair
: functions
) {
31 Function
* fun
= funpair
.second
;
32 QuaZipNewInfo
zipinfo(fun
->getName().c_str());
33 zipinfo
.setPermissions(static_cast<QFile::Permissions
>(0x6444));
34 outZipFile
.open(QIODevice::WriteOnly
, zipinfo
);
35 QXmlStreamWriter
stream(&outZipFile
);
36 stream
.setAutoFormatting(true);
37 stream
.setAutoFormattingIndent(-1);
38 stream
.writeStartDocument();
39 stream
.writeStartElement("function");
40 stream
.writeAttribute("name", fun
->getName().c_str());
41 stream
.writeAttribute("entry", QString::number(fun
->getStartAddress(), 16));
43 for (auto& blockentry
: fun
->blocks()) {
44 stream
.writeStartElement("block");
45 stream
.writeAttribute("id", blockentry
.second
->getName().c_str());
46 stream
.writeTextElement("start", QString::number(blockentry
.second
->getStartAddress(), 16));
47 stream
.writeTextElement("end", QString::number(blockentry
.second
->getEndAddress(), 16));
48 if (0 != blockentry
.second
->getNextBlock(0))
49 stream
.writeTextElement("next", QString::number(blockentry
.second
->getNextBlock(0), 16));
50 if (0 != blockentry
.second
->getNextBlock(1))
51 stream
.writeTextElement("next", QString::number(blockentry
.second
->getNextBlock(1), 16));
52 stream
.writeEndElement(); // "block"
55 stream
.writeEndElement(); // "function"
56 stream
.writeEndDocument();
63 void InformationManager::signal_new_function(Function
* fun
) {
64 functions
.insert(std::make_pair(fun
->getStartAddress(), fun
));
65 for (auto b
: fun
->blocks()) {
66 BasicBlock
* bl
= b
.second
;
67 blocks
.insert(std::make_pair(bl
->getStartAddress(), bl
));
69 new_function_signal(fun
);