Skip to content

Commit fb994d5

Browse files
committed
add pydoc for navigation APIs and get_address-for_data_offset
1 parent eda5922 commit fb994d5

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

python/binaryview.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,13 +2694,28 @@ def redo(self):
26942694
self._file.redo()
26952695

26962696
def navigate(self, view, offset):
2697+
"""
2698+
``navigate`` navigates the UI to the specified virtual address
2699+
2700+
.. 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``.
2701+
2702+
:param str view: virtual address to read from.
2703+
:param int offset: address to navigate to
2704+
:return: whether or not navigation succeeded
2705+
:rtype: bool
2706+
:Example:
2707+
2708+
>>> import random
2709+
>>> bv.navigate(bv.view, random.choice(bv.functions).start)
2710+
True
2711+
"""
26972712
return self._file.navigate(view, offset)
26982713

26992714
def read(self, addr, length):
27002715
"""
27012716
``read`` returns the data reads at most ``length`` bytes from virtual address ``addr``.
27022717
2703-
Note: Python2 returns a str, but Python3 returns a bytes object. str(DataBufferObject) will \
2718+
..note:: Python2 returns a str, but Python3 returns a bytes object. str(DataBufferObject) will \
27042719
still get you a str in either case.
27052720
27062721
:param int addr: virtual address to read from.
@@ -5335,6 +5350,13 @@ def get_segment_at(self, addr):
53355350
return Segment(core.BNNewSegmentReference(seg))
53365351

53375352
def get_address_for_data_offset(self, offset):
5353+
"""
5354+
``get_address_for_data_offset`` returns the virtual address that maps to the specific file offset
5355+
5356+
:param int offset: file offset
5357+
:return: the virtual address of the first segment that contains that file location
5358+
:rtype: Int
5359+
"""
53385360
address = ctypes.c_ulonglong()
53395361
if not core.BNGetAddressForDataOffset(self.handle, offset, address):
53405362
return None

python/filemetadata.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,21 @@ def redo(self):
369369
core.BNRedo(self.handle)
370370

371371
def navigate(self, view, offset):
372+
"""
373+
``navigate`` navigates the UI to the specified virtual address
374+
375+
.. 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``.
376+
377+
:param str view: virtual address to read from.
378+
:param int offset: address to navigate to
379+
:return: whether or not navigation succeeded
380+
:rtype: bool
381+
:Example:
382+
383+
>>> import random
384+
>>> bv.navigate(bv.view, random.choice(bv.functions).start)
385+
True
386+
"""
372387
return core.BNNavigate(self.handle, str(view), offset)
373388

374389
def create_database(self, filename, progress_func = None, settings = None):

0 commit comments

Comments
 (0)