diff options
| author | Xusheng <xusheng@vector35.com> | 2021-04-19 17:04:24 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2021-05-04 14:04:39 +0800 |
| commit | ad71a51fef925779f5ae30b597efb9979607b693 (patch) | |
| tree | 5f5275f7dc9501c1c3ac824a67d497fc7f39f8fa /binaryview.cpp | |
| parent | 1e2bb984e2fe601b78a4afff3c9097f8f181f9c9 (diff) | |
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()
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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<recursive_mutex> lock(m_mutex); m_callback = []() {}; + // This allows the API side to free the BinaryNinja::AnalysisCompletionEvent object + BNCancelAnalysisCompletionEvent(m_object); } @@ -2061,6 +2063,20 @@ vector<TypeReferenceSource> BinaryView::GetCodeReferencesForTypeFieldFrom(Refere } +vector<uint64_t> BinaryView::GetAllFieldsReferencedByCode(const QualifiedName& type) +{ + size_t count; + BNQualifiedName nameObj = type.GetAPIObject(); + uint64_t* fields = BNGetAllFieldsReferencedByCode(m_object, &nameObj, &count); + + vector<uint64_t> 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<uint64_t> BinaryView::GetCallees(ReferenceSource callSite) { size_t count; @@ -2594,6 +2610,8 @@ vector<BNStringReference> BinaryView::GetStrings(uint64_t start, uint64_t len) } +// The caller of this function must hold a reference to the returned Ref<AnalysisCompletionEvent>. +// Otherwise, it can be freed before the callback is triggered, leading to a crash. Ref<AnalysisCompletionEvent> BinaryView::AddAnalysisCompletionEvent(const function<void()>& callback) { return new AnalysisCompletionEvent(this, callback); |
