From 9537f33da6b8de883a45c4b7758f0dc5c1438ed7 Mon Sep 17 00:00:00 2001 From: Zichuan Li Date: Tue, 21 May 2024 17:56:03 -0400 Subject: Solved issue #1180 by adding new APIs 1. Add two new APIs for multiple entry functions `GetAllAnalysisEntryFunctions` and `AddToEntryFunctions` 2. Add Python APIs `entry_functions` and `add_to_entry_functions`. `entry_functions` resturns a list of functions, which supports parsing functions in `init_array`, `fini_array` and TLS callbacks. 3. Modify bin-info, it now prints all entry functions --- binaryview.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index b5c34177..929d0fe9 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -1985,6 +1985,12 @@ void BinaryView::AddEntryPointForAnalysis(Platform* platform, uint64_t addr) } +void BinaryView::AddToEntryFunctions(Function* func) +{ + BNAddToEntryFunctions(m_object, func->GetObject()); +} + + void BinaryView::RemoveAnalysisFunction(Function* func, bool updateRefs) { BNRemoveAnalysisFunction(m_object, func->GetObject(), updateRefs); @@ -2208,6 +2214,21 @@ Ref BinaryView::GetAnalysisEntryPoint() } +vector> BinaryView::GetAllEntryFunctions() +{ + size_t count; + BNFunction** funcs = BNGetAllEntryFunctions(m_object, &count); + if (count == 0) + return {}; + + vector> result; + for (size_t i = 0; i < count; i++) + result.push_back(new Function(BNNewFunctionReference(funcs[i]))); + BNFreeFunctionList(funcs, count); + return result; +} + + Ref BinaryView::GetRecentBasicBlockForAddress(uint64_t addr) { BNBasicBlock* block = BNGetRecentBasicBlockForAddress(m_object, addr); -- cgit v1.3.1