def get_memory_map(): # import labeless.rdebug api.Listmemory() t = api.cvar.memory rv = rpc.GetMemoryMapResult() for i in xrange(t.sorted.n): mi = rv.memories.add() m = api.void_to_t_memory(api.Getsortedbyselection(t.sorted, i)) module = api.Findmodule(m.base) module_name = ("'%s'" % module.modname) if module else '' mi.access = m.access mi.base = m.base mi.name = str(module_name) mi.size = m.size return rv
def read_memory_regions(regions): api.Listmemory() rv = rpc.ReadMemoryRegionsResult() for r in regions: mem = rv.memories.add() mem.addr = int(r.addr) mem.size = int(r.size) m = safe_read_chunked_memory_region_as_one(mem.addr, mem.size) if m is None: print >> sys.stderr, 'safe_read_chunked_memory_region_as_one() failed for (0x%08X, 0x%08X)' % ( mem.addr, mem.size) continue mem.mem = str(m[1]) mem.protect = int(m[2]) return rv