r""" ``read`` returns the data reads at most ``length`` bytes from virtual address ``addr``. :param int addr: virtual address to read from. :param int length: number of bytes to read. :return: at most ``length`` bytes from the virtual address ``addr``, empty string on error or no data :rt
(self, addr: int, length: int)
| 4445 | return self._file.navigate(view_name, offset) |
| 4446 | |
| 4447 | def read(self, addr: int, length: int) -> bytes: |
| 4448 | r""" |
| 4449 | ``read`` returns the data reads at most ``length`` bytes from virtual address ``addr``. |
| 4450 | |
| 4451 | :param int addr: virtual address to read from. |
| 4452 | :param int length: number of bytes to read. |
| 4453 | :return: at most ``length`` bytes from the virtual address ``addr``, empty string on error or no data |
| 4454 | :rtype: bytes |
| 4455 | :Example: |
| 4456 | |
| 4457 | >>> #Opening a x86_64 Mach-O binary |
| 4458 | >>> bv = BinaryView.new("/bin/ls") # note that we are using `new` instead of `load` to get the raw view |
| 4459 | >>> bv.read(0,4) |
| 4460 | b'\xcf\xfa\xed\xfe' |
| 4461 | """ |
| 4462 | if (addr < 0) or (length < 0): |
| 4463 | raise ValueError("length and address must both be positive") |
| 4464 | buf = databuffer.DataBuffer(handle=core.BNReadViewBuffer(self.handle, addr, length)) |
| 4465 | return bytes(buf) |
| 4466 | |
| 4467 | def read_int(self, address: int, size: int, sign: bool = True, endian: Optional[Endianness] = None) -> int: |
| 4468 | _endian = self.endianness |