Skip to content

Commit

Permalink
Add BinaryNinja::Load(Ref<ProjectFile>) to c++ api
Browse files Browse the repository at this point in the history
  • Loading branch information
negasora committed Oct 14, 2024
1 parent a9d3753 commit a10ba14
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions binaryninjaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ namespace BinaryNinja {
};

class BinaryView;
class ProjectFile;

/*! OpenView opens a file on disk and returns a BinaryView, attempting to use the most
relevant BinaryViewType and generating default load options (which are overridable).
Expand Down Expand Up @@ -1527,6 +1528,23 @@ namespace BinaryNinja {
*/
Ref<BinaryView> Load(Ref<BinaryView> rawData, bool updateAnalysis = true, const std::string& options = "{}", std::function<bool(size_t, size_t)> progress = {});

/*! Open a BinaryView from a ProjectFile, initializing data views and loading settings.

@threadmainonly

\see BinaryNinja::Load(const std::string&, bool, std::function<bool(size_t, size_t)>, Json::Value)
for discussion of this function.

\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.
\return Constructed view, or a nullptr Ref<BinaryView>
*/
Ref<BinaryView> Load(Ref<ProjectFile> rawData, bool updateAnalysis = true, const std::string& options = "{}", std::function<bool(size_t, size_t)> progress = {});

/*!
Deprecated. Use non-metadata version.
*/
Expand Down
11 changes: 11 additions & 0 deletions binaryview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5455,6 +5455,17 @@ Ref<BinaryView> BinaryNinja::Load(Ref<BinaryView> view, bool updateAnalysis, con
}


Ref<BinaryView> BinaryNinja::Load(Ref<ProjectFile> projectFile, bool updateAnalysis, const std::string& options, std::function<bool(size_t, size_t)> progress)
{
ProgressContext cb;
cb.callback = progress;
BNBinaryView* handle = BNLoadProjectFile(projectFile->GetObject(), updateAnalysis, options.c_str(), ProgressCallback, &cb);
if (!handle)
return nullptr;
return new BinaryView(handle);
}


SymbolQueue::SymbolQueue()
{
m_object = BNCreateSymbolQueue();
Expand Down

0 comments on commit a10ba14

Please sign in to comment.