Load contents of a raw binary file to memory Usage: MYNAME file address [size]
(self, *arg)
| 4542 | |
| 4543 | # loadmem() |
| 4544 | def loadmem(self, *arg): |
| 4545 | """ |
| 4546 | Load contents of a raw binary file to memory |
| 4547 | Usage: |
| 4548 | MYNAME file address [size] |
| 4549 | """ |
| 4550 | mem = "" |
| 4551 | (filename, address, size) = normalize_argv(arg, 3) |
| 4552 | address = to_int(address) |
| 4553 | size = to_int(size) |
| 4554 | if filename is not None: |
| 4555 | try: |
| 4556 | mem = open(filename, "rb").read() |
| 4557 | except: |
| 4558 | pass |
| 4559 | if mem == "": |
| 4560 | error_msg("cannot read data or filename is empty") |
| 4561 | return |
| 4562 | if size is not None and size < len(mem): |
| 4563 | mem = mem[:size] |
| 4564 | bytes = peda.writemem(address, mem) |
| 4565 | if bytes > 0: |
| 4566 | msg("Written %d bytes to 0x%x" % (bytes, address)) |
| 4567 | else: |
| 4568 | warning_msg("failed to load filename to memory") |
| 4569 | else: |
| 4570 | self._missing_argument() |
| 4571 | return |
| 4572 | |
| 4573 | # cmpmem() |
| 4574 | def cmpmem(self, *arg): |
nothing calls this directly
no test coverage detected