MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / rebase

Method rebase

python/binaryview.py:9332–9371  ·  view source on GitHub ↗

``rebase`` rebase the existing :py:class:`BinaryView` into a new :py:class:`BinaryView` at the specified virtual address .. note:: This method does not update corresponding UI components. If the `BinaryView` is associated with \ UI components then initiate the rebase operation within the UI,

(self, address: int, force: Optional[bool] = False,
	           progress_func: Optional[ProgressFuncType] = None)

Source from the content-addressed store, hash-verified

9330 return _workflow.Workflow(handle=handle, object_handle=self.handle)
9331
9332 def rebase(self, address: int, force: Optional[bool] = False,
9333 progress_func: Optional[ProgressFuncType] = None) -> Optional['BinaryView']:
9334 """
9335 ``rebase`` rebase the existing :py:class:`BinaryView` into a new :py:class:`BinaryView` at the specified virtual address
9336
9337 .. note:: This method does not update corresponding UI components. If the `BinaryView` is associated with \
9338 UI components then initiate the rebase operation within the UI, e.g. using the command palette. If working with views that \
9339 are not associated with UI components while the UI is active, then set ``force`` to ``True`` to enable rebasing.
9340
9341 :param int address: virtual address of the start of the :py:class:`BinaryView`
9342 :param bool force: enable rebasing while the UI is active
9343 :return: the new :py:class:`BinaryView` object or ``None`` on failure
9344 :rtype: :py:class:`BinaryView` or ``None``
9345 :Example:
9346 >>> from binaryninja import load
9347 >>> bv = load('/bin/ls')
9348 >>> print(bv)
9349 <BinaryView: '/bin/ls', start 0x100000000, len 0x182f8>
9350 >>> newbv = bv.rebase(0x400000)
9351 >>> print(newbv)
9352 <BinaryView: '/bin/ls', start 0x400000, len 0x182f8>
9353 """
9354 result = False
9355 if core.BNIsUIEnabled() and not force:
9356 log_warn(
9357 "The BinaryView rebase API does not update corresponding UI components. If the BinaryView is not associated with the UI rerun with 'force = True'."
9358 )
9359 return None
9360 if progress_func is None:
9361 result = core.BNRebase(self.handle, address)
9362 else:
9363 result = core.BNRebaseWithProgress(
9364 self.handle, address, None,
9365 ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong,
9366 ctypes.c_ulonglong)(lambda ctxt, cur, total: progress_func(cur, total))
9367 )
9368 if result:
9369 return self.get_view_of_type(self.view_type)
9370 else:
9371 return None
9372
9373 def show_plain_text_report(self, title: str, contents: str) -> None:
9374 core.BNShowPlainTextReport(self.handle, title, contents)

Callers

nothing calls this directly

Calls 2

get_view_of_typeMethod · 0.95
log_warnFunction · 0.85

Tested by

no test coverage detected