``write`` writes the bytes in ``data`` to the virtual address ``addr``. :param int addr: virtual address to write to. :param bytes data: data to be written at addr. :param bool except_on_relocation: (default True) raise exception when write overlaps a relocation :return: number of bytes
(self, addr: int, data: bytes, except_on_relocation: bool = True)
| 4499 | return uuid.UUID(bytes=data) |
| 4500 | |
| 4501 | def write(self, addr: int, data: bytes, except_on_relocation: bool = True) -> int: |
| 4502 | """ |
| 4503 | ``write`` writes the bytes in ``data`` to the virtual address ``addr``. |
| 4504 | |
| 4505 | :param int addr: virtual address to write to. |
| 4506 | :param bytes data: data to be written at addr. |
| 4507 | :param bool except_on_relocation: (default True) raise exception when write overlaps a relocation |
| 4508 | :return: number of bytes written to virtual address ``addr`` |
| 4509 | :rtype: int |
| 4510 | :Example: |
| 4511 | |
| 4512 | >>> bv.read(0,4) |
| 4513 | b'BBBB' |
| 4514 | >>> bv.write(0, b"AAAA") |
| 4515 | 4 |
| 4516 | >>> bv.read(0,4) |
| 4517 | b'AAAA' |
| 4518 | """ |
| 4519 | if not (isinstance(data, bytes) or isinstance(data, bytearray) or isinstance(data, str)): |
| 4520 | raise TypeError("Must be bytes, bytearray, or str") |
| 4521 | buf = databuffer.DataBuffer(data) |
| 4522 | if except_on_relocation and self.range_contains_relocation(addr, len(data)): |
| 4523 | raise RelocationWriteException("Attempting to write to a location which has a relocation") |
| 4524 | |
| 4525 | return core.BNWriteViewBuffer(self.handle, addr, buf.handle) |
| 4526 | |
| 4527 | def insert(self, addr: int, data: bytes) -> int: |
| 4528 | """ |
no test coverage detected