forked from Vector35/binaryninja-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilecontext.h
111 lines (86 loc) · 3.33 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once
#include <QtCore/QString>
#include <map>
#include <set>
#include <string>
#include <ctime>
#include "binaryninjaapi.h"
#include "uicontext.h"
class View;
class ViewFrame;
class ViewType;
class SyncGroup;
// 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() {}
};
/*!
\defgroup filecontext FileContext
\ingroup uiapi
*/
/*!
\ingroup filecontext
*/
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::map<QObject*, QMetaObject::Connection> m_refs;
std::vector<SyncGroup*> m_syncGroups;
std::map<ViewFrame*, std::pair<View*, ViewLocation>> m_syncLastLocation;
bool m_suspendSync = false;
static std::set<FileContext*> m_openFiles;
public:
FileContext(FileMetadataRef file, BinaryViewRef rawData, const QString& filename = QString(),
bool isValidSaveName = false, bool createViews = true);
virtual ~FileContext();
void registerReference(QObject* widget);
void unregisterReference(QObject* widget);
void close();
static void closeAllOpenFiles();
BinaryViewRef getRawData() const { return m_rawData; }
FileMetadataRef getMetadata() const { return m_file; }
QString getFilename() const { return m_filename; }
void setFilename(QString newName) { m_filename = newName; }
ViewFrame* getCurrentViewFrame() const { return m_currentViewFrame; }
QString getTabName(QWidget* widget);
QString getShortFileName(QWidget* widget);
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();
SyncGroup* newSyncGroup();
SyncGroup* syncGroupById(int id);
void deleteSyncGroup(SyncGroup* syncGroup);
SyncGroup* syncGroupForFrame(ViewFrame* frame);
void removeFrame(ViewFrame* frame);
const std::vector<SyncGroup*>& allSyncGroups() const { return m_syncGroups; }
void forceLocationSyncForFrame(ViewFrame* frame);
bool syncLocation(ViewFrame* frame, View* view, const ViewLocation& location);
void suspendSync() { m_suspendSync = true; }
void resumeSync() { m_suspendSync = false; }
static FileContext* newFile();
static FileContext* openFilename(const QString& path);
static const std::set<FileContext*>& getOpenFileContexts();
};