summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h20
-rw-r--r--binaryninjacore.h17
-rw-r--r--binaryview.cpp12
-rw-r--r--python/binaryview.py20
4 files changed, 68 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index e29f4084..9cef3ee0 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -7840,6 +7840,15 @@ namespace BinaryNinja {
uint64_t entrySize = 0, const std::string& linkedSection = "", const std::string& infoSection = "",
uint64_t infoData = 0);
+ /*! Adds multiple automatically defined sections in a batch operation
+
+ This method is more efficient than calling AddAutoSection multiple times as it only triggers
+ one SectionMap rebuild for all sections.
+
+ \param sections Vector of BNSectionInfo describing the sections to add
+ */
+ void AddAutoSections(const std::vector<BNSectionInfo>& sections);
+
/*! Remove an automatically defined section by name
\param name Name of the section
@@ -7867,6 +7876,17 @@ namespace BinaryNinja {
uint64_t entrySize = 0, const std::string& linkedSection = "", const std::string& infoSection = "",
uint64_t infoData = 0);
+ /*! Adds multiple user-defined sections in a batch operation
+
+ This method is more efficient than calling AddUserSection multiple times as it only triggers
+ one SectionMap rebuild for all sections.
+
+ Note that all data specified must already be mapped by an existing segment.
+
+ \param sections Vector of BNSectionInfo describing the sections to add
+ */
+ void AddUserSections(const std::vector<BNSectionInfo>& sections);
+
/*! Remove a user defined section by name
\param name Name of the section to remove
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 2b057d1e..34cecb28 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -37,7 +37,7 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 150
+#define BN_CURRENT_CORE_ABI_VERSION 151
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
@@ -3682,6 +3682,19 @@ extern "C"
uint32_t flags;
} BNSegmentInfo;
+ typedef struct BNSectionInfo {
+ const char* name;
+ uint64_t start;
+ uint64_t length;
+ BNSectionSemantics semantics;
+ const char* type;
+ uint64_t align;
+ uint64_t entrySize;
+ const char* linkedSection;
+ const char* infoSection;
+ uint64_t infoData;
+ } BNSectionInfo;
+
typedef bool(*BNCollaborationAnalysisConflictHandler)(void*, const char** keys, BNAnalysisMergeConflict** conflicts, size_t conflictCount);
typedef bool(*BNCollaborationNameChangesetFunction)(void*, BNCollaborationChangeset*);
@@ -4566,10 +4579,12 @@ extern "C"
BINARYNINJACOREAPI void BNAddAutoSection(BNBinaryView* view, const char* name, uint64_t start, uint64_t length,
BNSectionSemantics semantics, const char* type, uint64_t align, uint64_t entrySize, const char* linkedSection,
const char* infoSection, uint64_t infoData);
+ BINARYNINJACOREAPI void BNAddAutoSections(BNBinaryView* view, const BNSectionInfo* sectionInfo, size_t count);
BINARYNINJACOREAPI void BNRemoveAutoSection(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI void BNAddUserSection(BNBinaryView* view, const char* name, uint64_t start, uint64_t length,
BNSectionSemantics semantics, const char* type, uint64_t align, uint64_t entrySize, const char* linkedSection,
const char* infoSection, uint64_t infoData);
+ BINARYNINJACOREAPI void BNAddUserSections(BNBinaryView* view, const BNSectionInfo* sectionInfo, size_t count);
BINARYNINJACOREAPI void BNRemoveUserSection(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI BNSection** BNGetSections(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI BNSection** BNGetSectionsAt(BNBinaryView* view, uint64_t addr, size_t* count);
diff --git a/binaryview.cpp b/binaryview.cpp
index 5effe803..ca226119 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -5269,6 +5269,12 @@ void BinaryView::AddAutoSection(const string& name, uint64_t start, uint64_t len
}
+void BinaryView::AddAutoSections(const vector<BNSectionInfo>& sections)
+{
+ BNAddAutoSections(m_object, sections.data(), sections.size());
+}
+
+
void BinaryView::RemoveAutoSection(const string& name)
{
BNRemoveAutoSection(m_object, name.c_str());
@@ -5284,6 +5290,12 @@ void BinaryView::AddUserSection(const string& name, uint64_t start, uint64_t len
}
+void BinaryView::AddUserSections(const vector<BNSectionInfo>& sections)
+{
+ BNAddUserSections(m_object, sections.data(), sections.size());
+}
+
+
void BinaryView::RemoveUserSection(const string& name)
{
BNRemoveUserSection(m_object, name.c_str());
diff --git a/python/binaryview.py b/python/binaryview.py
index 637868b3..2f190375 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -10054,6 +10054,16 @@ to a the type "tagRECT" found in the typelibrary "winX64common"
info_data
)
+ def add_auto_sections(self, sections: List[core.BNSectionInfo]) -> None:
+ """
+ ``add_auto_sections`` Adds analysis sections that specify semantic information about regions of the binary
+
+ :param List[core.BNSectionInfo] sections: list of sections to add
+ :rtype: None
+ """
+ section_list = (core.BNSectionInfo * len(sections))(*sections)
+ core.BNAddAutoSections(self.handle, section_list, len(sections))
+
def remove_auto_section(self, name: str) -> None:
core.BNRemoveAutoSection(self.handle, name)
@@ -10083,6 +10093,16 @@ to a the type "tagRECT" found in the typelibrary "winX64common"
info_data
)
+ def add_user_sections(self, sections: List[core.BNSectionInfo]) -> None:
+ """
+ ``add_user_sections`` Adds user-defined sections that specify semantic information about regions of the binary
+
+ :param List[core.BNSectionInfo] sections: list of sections to add
+ :rtype: None
+ """
+ section_list = (core.BNSectionInfo * len(sections))(*sections)
+ core.BNAddUserSections(self.handle, section_list, len(sections))
+
def remove_user_section(self, name: str) -> None:
core.BNRemoveUserSection(self.handle, name)