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. --- binaryview.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index 83ed3f3b..b5c34177 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -5316,11 +5316,7 @@ Ref BinaryData::CreateFromFile(FileMetadata* file, FileAccessor* acc Ref BinaryNinja::Load(const std::string& filename, bool updateAnalysis, std::function progress, Ref options) { - BNBinaryView* handle = BNLoadFilename(filename.c_str(), updateAnalysis, - (bool (*)(size_t, size_t))progress.target(), options->m_object); - if (!handle) - return nullptr; - return new BinaryView(handle); + return Load(filename, updateAnalysis, options->GetJsonString(), progress); } @@ -5336,8 +5332,30 @@ Ref BinaryNinja::Load( Ref BinaryNinja::Load(Ref view, bool updateAnalysis, std::function progress, Ref options, bool isDatabase) { - BNBinaryView* handle = BNLoadBinaryView(view->GetObject(), updateAnalysis, - (bool (*)(size_t, size_t))progress.target(), options->m_object, isDatabase); + return Load(view, updateAnalysis, options->GetJsonString(), progress); +} + + +Ref BinaryNinja::Load(const std::string& filename, bool updateAnalysis, const std::string& options, std::function progress) +{ + BNBinaryView* handle = BNLoadFilename(filename.c_str(), updateAnalysis, options.c_str(), (bool (*)(size_t, size_t))progress.target()); + if (!handle) + return nullptr; + return new BinaryView(handle); +} + + +Ref BinaryNinja::Load(const DataBuffer& rawData, bool updateAnalysis, const std::string& options, std::function progress) +{ + Ref file = new FileMetadata(); + Ref view = new BinaryData(file, rawData); + return Load(view, updateAnalysis, options, progress); +} + + +Ref BinaryNinja::Load(Ref view, bool updateAnalysis, const std::string& options, std::function progress) +{ + BNBinaryView* handle = BNLoadBinaryView(view->GetObject(), updateAnalysis, options.c_str(), (bool (*)(size_t, size_t))progress.target()); if (!handle) return nullptr; return new BinaryView(handle); -- cgit v1.3.1