diff options
Diffstat (limited to 'python/__init__.py')
| -rw-r--r-- | python/__init__.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/python/__init__.py b/python/__init__.py index b8a87aff..d199385a 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -945,6 +945,7 @@ class BinaryView(object): self._cb.isOffsetReadable = self._cb.isOffsetReadable.__class__(self._is_offset_readable) self._cb.isOffsetWritable = self._cb.isOffsetWritable.__class__(self._is_offset_writable) self._cb.isOffsetExecutable = self._cb.isOffsetExecutable.__class__(self._is_offset_executable) + self._cb.isOffsetBackedByFile = self._cb.isOffsetExecutable.__class__(self._is_offset_backed_by_file) self._cb.getNextValidOffset = self._cb.getNextValidOffset.__class__(self._get_next_valid_offset) self._cb.getStart = self._cb.getStart.__class__(self._get_start) self._cb.getLength = self._cb.getLength.__class__(self._get_length) @@ -1389,6 +1390,13 @@ class BinaryView(object): log_error(traceback.format_exc()) return False + def _is_offset_backed_by_file(self, ctxt, offset): + try: + return self.perform_is_offset_backed_by_file(offset) + except: + log_error(traceback.format_exc()) + return False + def _get_next_valid_offset(self, ctxt, offset): try: return self.perform_get_next_valid_offset(offset) @@ -1632,6 +1640,20 @@ class BinaryView(object): """ return self.is_valid_offset(addr) + def perform_is_offset_backed_by_file(self, addr): + """ + ``perform_is_offset_backed_by_file`` implements a check if a virtual address ``addr`` is backed by the file + contents. + + .. warning:: This method **must not** be called directly. + + :param int addr: a virtual address to be checked + :return: true if the virtual address is backed by the file, false if the virtual address is initialized by \ + the loader + :rtype: int + """ + return self.is_valid_offset(addr) + def perform_get_next_valid_offset(self, addr): """ ``perform_get_next_valid_offset`` implements a query for the next valid readable, writable, or executable virtual @@ -1933,7 +1955,7 @@ class BinaryView(object): def is_offset_readable(self, addr): """ - ``is_valid_offset`` checks if an virtual address ``addr`` is valid for reading. + ``is_offset_readable`` checks if an virtual address ``addr`` is valid for reading. :param int addr: a virtual address to be checked :return: true if the virtual address is valid for reading, false if the virtual address is invalid or error @@ -1943,7 +1965,7 @@ class BinaryView(object): def is_offset_writable(self, addr): """ - ``is_valid_offset`` checks if an virtual address ``addr`` is valid for writing. + ``is_offset_writable`` checks if an virtual address ``addr`` is valid for writing. :param int addr: a virtual address to be checked :return: true if the virtual address is valid for writing, false if the virtual address is invalid or error @@ -1953,7 +1975,7 @@ class BinaryView(object): def is_offset_executable(self, addr): """ - ``is_valid_offset`` checks if an virtual address ``addr`` is valid for executing. + ``is_offset_executable`` checks if an virtual address ``addr`` is valid for executing. :param int addr: a virtual address to be checked :return: true if the virtual address is valid for executing, false if the virtual address is invalid or error @@ -1961,6 +1983,17 @@ class BinaryView(object): """ return core.BNIsOffsetExecutable(self.handle, addr) + def is_offset_backed_by_file(self, addr): + """ + ``is_offset_backed_by_file`` checks if an virtual address ``addr`` is backed by the file contents. + + :param int addr: a virtual address to be checked + :return: true if the virtual address is backed by the file, false if the virtual address is initialized by \ + the loader + :rtype: bool + """ + return core.BNIsOffsetBackedByFile(self.handle, addr) + def save(self, dest): """ ``save`` saves the original binary file to the provided destination ``dest`` along with any modifications. |
