summaryrefslogtreecommitdiff
path: root/python/__init__.py
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2022-03-11 15:37:46 -0500
committerBrian Potchik <brian@vector35.com>2022-03-11 15:37:46 -0500
commitc7ffb77e1fdc2e9bc7a2de27c2feddf15e8b54ea (patch)
treede3dab55961109ef0fa80b35552868633989f1c8 /python/__init__.py
parentb301cffd61be0fdec9fec2e65995778e41c2fb33 (diff)
Add simple load API for creating a BinaryView from various input types.
Diffstat (limited to 'python/__init__.py')
-rw-r--r--python/__init__.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/python/__init__.py b/python/__init__.py
index b973118a..e0cd31ad 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -278,6 +278,32 @@ def get_memory_usage_info() -> Mapping[str, int]:
return result
+def load(*args, **kwargs) -> Optional[BinaryView]:
+ """
+ `load` is a convenience wrapper for :py:class:`BinaryViewType.load` that opens a BinaryView object.
+
+ :param Union[str, bytes, bytearray, 'databuffer.DataBuffer'] source: a file or byte stream for which load load into a virtual memory space
+ :param bool update_analysis: whether or not to run :func:`update_analysis_and_wait` after opening a :py:class:`BinaryView`, defaults to ``True``
+ :param callback progress_func: optional function to be called with the current progress and total count
+ :param dict options: a dictionary in the form {setting identifier string : object value}
+ :return: returns a :py:class:`BinaryView` object for the given filename or ``None``
+ :rtype: :py:class:`BinaryView` or ``None``
+
+ :Example:
+ >>> from binaryninja import *
+ >>> with load("/bin/ls") as bv:
+ ... print(len(list(bv.functions)))
+ ...
+ 134
+
+ >>> with load(bytes.fromhex('5054ebfe'), options={'loader.architecture' : 'x86'}) as bv:
+ ... print(len(list(bv.functions)))
+ ...
+ 1
+ """
+ return BinaryViewType.load(*args, **kwargs)
+
+
def open_view(*args, **kwargs) -> Optional[BinaryView]:
"""
`open_view` is a convenience wrapper for :py:class:`get_view_of_file_with_options` that opens a BinaryView object.