From ad71a51fef925779f5ae30b597efb9979607b693 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Mon, 19 Apr 2021 17:04:24 +0800 Subject: render non-member access to type on a new line add Python API for retrieving all type fields referenced by code change m_updatesRequired to std::atomic_bool fix potential UAF after calling AnalysisCompletionEvent::Cancel() --- binaryview.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index bde0afca..ec3fc8f7 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -362,6 +362,8 @@ void AnalysisCompletionEvent::Cancel() { unique_lock lock(m_mutex); m_callback = []() {}; + // This allows the API side to free the BinaryNinja::AnalysisCompletionEvent object + BNCancelAnalysisCompletionEvent(m_object); } @@ -2061,6 +2063,20 @@ vector BinaryView::GetCodeReferencesForTypeFieldFrom(Refere } +vector BinaryView::GetAllFieldsReferencedByCode(const QualifiedName& type) +{ + size_t count; + BNQualifiedName nameObj = type.GetAPIObject(); + uint64_t* fields = BNGetAllFieldsReferencedByCode(m_object, &nameObj, &count); + + vector result(fields, &fields[count]); + // Data refs and the fields above are both an array of uint64_t, so they can be freed in + // the same way + BNFreeDataReferences(fields); + return result; +} + + vector BinaryView::GetCallees(ReferenceSource callSite) { size_t count; @@ -2594,6 +2610,8 @@ vector BinaryView::GetStrings(uint64_t start, uint64_t len) } +// The caller of this function must hold a reference to the returned Ref. +// Otherwise, it can be freed before the callback is triggered, leading to a crash. Ref BinaryView::AddAnalysisCompletionEvent(const function& callback) { return new AnalysisCompletionEvent(this, callback); -- cgit v1.3.1