/
filecontext.h
78 lines (58 loc) · 2.32 KB
/
filecontext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include <QtCore/QString>
#include <map>
#include <set>
#include <string>
#include "binaryninjaapi.h"
#include "uicontext.h"
class ViewFrame;
class ViewType;
// This base class is required for building the Python bindings. The other base classes of FileContext are
// ignored (as they have no functions that should be exported to Python), but this would leave the binding
// generator with a derived class with no base and a compiler error.
class FileContextBase
{
public:
FileContextBase() {}
};
class BINARYNINJAUIAPI FileContext: public FileContextBase, public BinaryNinja::NavigationHandler
{
QString m_filename;
bool m_isValidSaveFilename;
FileMetadataRef m_file;
BinaryViewRef m_rawData;
std::map<QString, BinaryViewRef> m_dataViews;
ViewFrame* m_currentViewFrame;
std::set<QObject*> m_refs;
static std::set<FileContext*> m_openFiles;
void createBinaryViews();
public:
FileContext(FileMetadataRef file, BinaryViewRef rawData, const QString& filename = QString(), bool isValidSaveName = false, bool createViews = true);
virtual ~FileContext();
void registerReference(QWidget* widget);
void close();
static void closeAllOpenFiles();
BinaryViewRef getRawData() const { return m_rawData; }
QString getFilename() const { return m_filename; }
void setFilename(QString newName) {m_filename = newName;}
ViewFrame* getCurrentViewFrame() const { return m_currentViewFrame; }
bool isValidSaveFilename() const { return m_isValidSaveFilename; }
void markAsSaved(const QString& filename);
bool isModified();
BinaryViewRef createDataView(const QString& type);
BinaryViewRef getDataView(const QString& type, bool createView = false);
std::vector<BinaryViewRef> getAllDataViews();
void refreshDataViewCache();
void setCurrentViewFrame(ViewFrame* view);
virtual std::string GetCurrentView() override;
virtual uint64_t GetCurrentOffset() override;
virtual bool Navigate(const std::string& view, uint64_t offset) override;
QString getBestType();
std::vector<QString> getAvailableTypes();
bool isTypeAvailable(const QString& type);
bool resolveType(const QString& type, ViewType*& viewType, BinaryViewTypeRef& data);
bool resolveTypeAndData(const QString& type, ViewType*& viewType, BinaryViewRef& data);
void updateAnalysis();
static FileContext* newFile();
static FileContext* openFilename(const QString& path);
};