summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2020-11-29 14:31:07 -0500
committerJordan Wiens <jordan@psifertex.com>2020-11-29 14:31:07 -0500
commitfb994d5d1de44c162cdc63b3c648f3bff0ad9d31 (patch)
treea37588b92e9db5741ba9b989fc6722fb74b20fa2 /python
parenteda59222b770f25c13d2d01dd19332f2f1e18317 (diff)
add pydoc for navigation APIs and get_address-for_data_offset
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py24
-rw-r--r--python/filemetadata.py15
2 files changed, 38 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 84191bc1..9d095388 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -2694,13 +2694,28 @@ class BinaryView(object):
self._file.redo()
def navigate(self, view, offset):
+ """
+ ``navigate`` navigates the UI to the specified virtual address
+
+ .. note:: Despite the confusing name, ``view`` in this context is not a BinaryView but rather a string describing the different UI Views. Check :py:attr:`view` while in different views to see examples such as ``Linear:ELF``, ``Graph:PE``.
+
+ :param str view: virtual address to read from.
+ :param int offset: address to navigate to
+ :return: whether or not navigation succeeded
+ :rtype: bool
+ :Example:
+
+ >>> import random
+ >>> bv.navigate(bv.view, random.choice(bv.functions).start)
+ True
+ """
return self._file.navigate(view, offset)
def read(self, addr, length):
"""
``read`` returns the data reads at most ``length`` bytes from virtual address ``addr``.
- Note: Python2 returns a str, but Python3 returns a bytes object. str(DataBufferObject) will \
+ ..note:: Python2 returns a str, but Python3 returns a bytes object. str(DataBufferObject) will \
still get you a str in either case.
:param int addr: virtual address to read from.
@@ -5335,6 +5350,13 @@ class BinaryView(object):
return Segment(core.BNNewSegmentReference(seg))
def get_address_for_data_offset(self, offset):
+ """
+ ``get_address_for_data_offset`` returns the virtual address that maps to the specific file offset
+
+ :param int offset: file offset
+ :return: the virtual address of the first segment that contains that file location
+ :rtype: Int
+ """
address = ctypes.c_ulonglong()
if not core.BNGetAddressForDataOffset(self.handle, offset, address):
return None
diff --git a/python/filemetadata.py b/python/filemetadata.py
index e8c72775..3f2e88ef 100644
--- a/python/filemetadata.py
+++ b/python/filemetadata.py
@@ -369,6 +369,21 @@ class FileMetadata(object):
core.BNRedo(self.handle)
def navigate(self, view, offset):
+ """
+ ``navigate`` navigates the UI to the specified virtual address
+
+ .. note:: Despite the confusing name, ``view`` in this context is not a BinaryView but rather a string describing the different UI Views. Check :py:attr:`view` while in different views to see examples such as ``Linear:ELF``, ``Graph:PE``.
+
+ :param str view: virtual address to read from.
+ :param int offset: address to navigate to
+ :return: whether or not navigation succeeded
+ :rtype: bool
+ :Example:
+
+ >>> import random
+ >>> bv.navigate(bv.view, random.choice(bv.functions).start)
+ True
+ """
return core.BNNavigate(self.handle, str(view), offset)
def create_database(self, filename, progress_func = None, settings = None):