From a348dab8b14b8ddd36c400ae39a7a48b6a28e829 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Mon, 27 May 2024 15:29:48 -0400 Subject: Update load APIs to take a JSON string for options. --- binaryninjaapi.h | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 55bb3b44..55b8ef55 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1366,6 +1366,7 @@ namespace BinaryNinja { std::vector GetRaw() const; std::vector> GetArray() const; std::map> GetKeyValueStore() const; + std::string GetJsonString() const; // For key-value data only /*! Get a Metadata object by key. Only for if IsKeyValueStore == true @@ -1483,15 +1484,12 @@ namespace BinaryNinja { \param filename Path to filename or BNDB to open. \param updateAnalysis If true, UpdateAnalysisAndWait() will be called after opening a BinaryView. + \param options A Json string whose keys are setting identifiers and whose values are the desired settings. \param progress Optional function to be called with progress updates as the view is being loaded. If the function returns false, it will cancel Load. - \param options A Json object whose keys are setting identifiers and whose values are - the desired settings. \return Constructed view, or a nullptr Ref */ - Ref Load(const std::string& filename, bool updateAnalysis = true, - std::function progress = {}, Ref options = new Metadata(MetadataType::KeyValueDataType)); - + Ref Load(const std::string& filename, bool updateAnalysis = true, const std::string& options = "{}", std::function progress = {}); /*! Open a BinaryView from a raw data buffer, initializing data views and loading settings. @threadmainonly @@ -1502,14 +1500,12 @@ namespace BinaryNinja { \param rawData Buffer with raw binary data to load (cannot load from bndb) \param updateAnalysis If true, UpdateAnalysisAndWait() will be called after opening a BinaryView. + \param options A Json string whose keys are setting identifiers and whose values are the desired settings. \param progress Optional function to be called with progress updates as the view is being loaded. If the function returns false, it will cancel Load. - \param options A Json object whose keys are setting identifiers and whose values are - the desired settings. \return Constructed view, or a nullptr Ref */ - Ref Load(const DataBuffer& rawData, bool updateAnalysis = true, - std::function progress = {}, Ref options = new Metadata(MetadataType::KeyValueDataType)); + Ref Load(const DataBuffer& rawData, bool updateAnalysis = true, const std::string& options = "{}", std::function progress = {}); /*! Open a BinaryView from a raw BinaryView, initializing data views and loading settings. @@ -1522,16 +1518,27 @@ namespace BinaryNinja { \param rawData BinaryView with raw binary data to load \param updateAnalysis If true, UpdateAnalysisAndWait() will be called after opening a BinaryView. + \param options A Json string whose keys are setting identifiers and whose values are the desired settings. \param progress Optional function to be called with progress updates as the view is being loaded. If the function returns false, it will cancel Load. - \param options A Json object whose keys are setting identifiers and whose values are - the desired settings. - \param isDatabase True if the view being loaded is the raw view of an already opened database. \return Constructed view, or a nullptr Ref */ - Ref Load(Ref rawData, bool updateAnalysis = true, - std::function progress = {}, Ref options = new Metadata(MetadataType::KeyValueDataType), - bool isDatabase = false); + Ref Load(Ref rawData, bool updateAnalysis = true, const std::string& options = "{}", std::function progress = {}); + + /*! + Deprecated. Use non-metadata version. + */ + Ref Load(const std::string& filename, bool updateAnalysis, std::function progress, Ref options = new Metadata(MetadataType::KeyValueDataType)); + + /*! + Deprecated. Use non-metadata version. + */ + Ref Load(const DataBuffer& rawData, bool updateAnalysis, std::function progress, Ref options = new Metadata(MetadataType::KeyValueDataType)); + + /*! + Deprecated. Use non-metadata version. + */ + Ref Load(Ref rawData, bool updateAnalysis, std::function progress, Ref options = new Metadata(MetadataType::KeyValueDataType), bool isDatabase = false); /*! Demangles using LLVM's demangler -- cgit v1.3.1