Writes data to the specified virtual address Arguments: address(int): Virtual address to write data(str): Bytes to write Note: This routine does not check the bounds on the write to ensure that it stays in the same segment. E
(self, address, data)
| 1530 | return b''.join(retval) |
| 1531 | |
| 1532 | def write(self, address, data): |
| 1533 | """Writes data to the specified virtual address |
| 1534 | |
| 1535 | Arguments: |
| 1536 | address(int): Virtual address to write |
| 1537 | data(str): Bytes to write |
| 1538 | |
| 1539 | Note: |
| 1540 | This routine does not check the bounds on the write to ensure |
| 1541 | that it stays in the same segment. |
| 1542 | |
| 1543 | Examples: |
| 1544 | |
| 1545 | >>> bash = ELF(which('bash')) |
| 1546 | >>> bash.read(bash.address+1, 3) |
| 1547 | b'ELF' |
| 1548 | >>> bash.write(bash.address, b"HELO") |
| 1549 | >>> bash.read(bash.address, 4) |
| 1550 | b'HELO' |
| 1551 | """ |
| 1552 | offset = self.vaddr_to_offset(address) |
| 1553 | |
| 1554 | if offset is not None: |
| 1555 | length = len(data) |
| 1556 | self.mmap[offset:offset+length] = data |
| 1557 | |
| 1558 | return None |
| 1559 | |
| 1560 | def save(self, path=None): |
| 1561 | """Save the ELF to a file |
no test coverage detected