From 411acbaa4a1d217e731d3df0b189445117be3b26 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 19 Mar 2019 15:41:08 -0400 Subject: Add in progress UI API headers --- ui/filecontext.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 ui/filecontext.h (limited to 'ui/filecontext.h') 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 +#include +#include +#include +#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 m_dataViews; + + ViewFrame* m_currentViewFrame; + std::set m_viewFrames; + + static std::set 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 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 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); +}; -- cgit v1.3.1