MCPcopy Create free account
hub / github.com/longld/peda / loadmem

Method loadmem

peda.py:4544–4571  ·  view source on GitHub ↗

Load contents of a raw binary file to memory Usage: MYNAME file address [size]

(self, *arg)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 6

_missing_argumentMethod · 0.95
normalize_argvFunction · 0.85
to_intFunction · 0.85
error_msgFunction · 0.85
warning_msgFunction · 0.85
writememMethod · 0.80

Tested by

no test coverage detected