diff options
| author | Rusty Wagner <rusty@vector35.com> | 2019-03-19 15:41:08 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2019-03-20 13:00:17 -0400 |
| commit | 411acbaa4a1d217e731d3df0b189445117be3b26 (patch) | |
| tree | 49b5c5290058ffb98dd23ec9a7c1a49921254d15 /ui/filecontext.h | |
| parent | ca1bc587c22928bbd7198813064c9615c3c12771 (diff) | |
Add in progress UI API headers
Diffstat (limited to 'ui/filecontext.h')
| -rw-r--r-- | ui/filecontext.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/ui/filecontext.h b/ui/filecontext.h new file mode 100644 index 00000000..bd11a4ff --- /dev/null +++ b/ui/filecontext.h @@ -0,0 +1,77 @@ +#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<ViewFrame*> m_viewFrames; + + static std::set<FileContext*> m_openFiles; + + friend class ViewFrame; + void registerViewFrame(ViewFrame* frame); + void unregisterViewFrame(ViewFrame* frame); + +public: + FileContext(FileMetadataRef file, BinaryViewRef rawData, + const QString& filename = QString(), bool isValidSaveName = false); + virtual ~FileContext(); + + void close(); + static void closeAllOpenFiles(); + + BinaryViewRef getRawData() const { return m_rawData; } + QString getFilename() const { return m_filename; } + ViewFrame* getCurrentViewFrame() const { return m_currentViewFrame; } + + bool isValidSaveFilename() const { return m_isValidSaveFilename; } + void markAsSaved(const QString& filename); + + bool isModified(); + + BinaryViewRef getDataView(const QString& type, bool createView = false); + std::vector<BinaryViewRef> getAllDataViews(); + + 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; + + void createBinaryViews(); + 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); +}; |
