summaryrefslogtreecommitdiff
path: root/python/workflow.py
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2025-11-24 15:35:58 -0500
committerBrian Potchik <brian@vector35.com>2025-11-24 15:35:58 -0500
commitb4d77d5b44dd322042f90b5a4a4da9075d05b644 (patch)
tree9d13e5ae7c4c2f62ffd67ba79bfb8cc42b1566cc /python/workflow.py
parentd3d4d43d223da5cd84b48a129b54acc39612c986 (diff)
Add AnalysisContext FFI for SectionMap queries.
Diffstat (limited to 'python/workflow.py')
-rw-r--r--python/workflow.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/python/workflow.py b/python/workflow.py
index ed6bc876..61827b55 100644
--- a/python/workflow.py
+++ b/python/workflow.py
@@ -293,6 +293,83 @@ class AnalysisContext:
"""
return core.BNAnalysisContextIsOffsetBackedByFile(self.handle, offset)
+ def is_offset_code_semantics(self, offset: int) -> bool:
+ """
+ Check if an offset has code semantics in the cached section map.
+
+ :param offset: Offset to check
+ :return: True if offset has code semantics
+ """
+ return core.BNAnalysisContextIsOffsetCodeSemantics(self.handle, offset)
+
+ def is_offset_extern_semantics(self, offset: int) -> bool:
+ """
+ Check if an offset has external semantics in the cached section map.
+
+ :param offset: Offset to check
+ :return: True if offset has external semantics
+ """
+ return core.BNAnalysisContextIsOffsetExternSemantics(self.handle, offset)
+
+ def is_offset_writable_semantics(self, offset: int) -> bool:
+ """
+ Check if an offset has writable semantics in the cached section map.
+
+ :param offset: Offset to check
+ :return: True if offset has writable semantics
+ """
+ return core.BNAnalysisContextIsOffsetWritableSemantics(self.handle, offset)
+
+ def is_offset_readonly_semantics(self, offset: int) -> bool:
+ """
+ Check if an offset has read-only semantics in the cached section map.
+
+ :param offset: Offset to check
+ :return: True if offset has read-only semantics
+ """
+ return core.BNAnalysisContextIsOffsetReadOnlySemantics(self.handle, offset)
+
+ def get_sections(self) -> List['binaryninja.binaryview.Section']:
+ """
+ Get all sections from the cached section map.
+
+ :return: List of all sections
+ """
+ count = ctypes.c_ulonglong()
+ sections = core.BNAnalysisContextGetSections(self.handle, count)
+ result = []
+ for i in range(count.value):
+ result.append(binaryninja.binaryview.Section(core.BNNewSectionReference(sections[i])))
+ core.BNFreeSectionList(sections, count.value)
+ return result
+
+ def get_section_by_name(self, name: str) -> Optional['binaryninja.binaryview.Section']:
+ """
+ Get a section by name from the cached section map.
+
+ :param name: Section name
+ :return: Section with the given name, or None if not found
+ """
+ section = core.BNAnalysisContextGetSectionByName(self.handle, name)
+ if not section:
+ return None
+ return binaryninja.binaryview.Section(section)
+
+ def get_sections_at(self, addr: int) -> List['binaryninja.binaryview.Section']:
+ """
+ Get all sections containing the given address from the cached section map.
+
+ :param addr: Address to query
+ :return: List of sections containing the address
+ """
+ count = ctypes.c_ulonglong()
+ sections = core.BNAnalysisContextGetSectionsAt(self.handle, addr, count)
+ result = []
+ for i in range(count.value):
+ result.append(binaryninja.binaryview.Section(core.BNNewSectionReference(sections[i])))
+ core.BNFreeSectionList(sections, count.value)
+ return result
+
def get_start(self) -> int:
"""
Get the start address from the cached memory map.