# 20.2.2 Memory pages

You can control different operations over the memory pages of the target process. This is an important task that should be handled by the debugger layer to get information to get the ranges of memory mapped.

The '!maps' command will list all the regions mapped in the target process. For example:

    [0x4A13B8C0]> !maps
    0xbfe15000 - 0xbfe2a000 rw-- 0x00015000 [stack]
    0xb7f87000 - 0xb7f88000 r-x- 0x00001000 [vdso]
    0x4a155000 - 0x4a157000 rw-- 0x00002000 /lib/ld-2.5.so
    0x4a13b000 * 0x4a155000 r-x- 0x0001a000 /lib/ld-2.5.so
    0x0805c000 - 0x0805d000 rw-u 0x00001000 /bin/ls
    0x08048000 - 0x0805c000 r-xu 0x00014000 /bin/ls

The columns are start address, end address, permissions, size and name of region. At the same time all the proper flags are registered in the core named as 'section.foo' and 'section.foo_end'.

This way it is possible to iterate in scripts from these ranges easily. The '*' between the from-to addresses allows you to easily view where you are located

    -- analyze a section
    function opcleaner_section(name)
      print("FROM: "..r.get("section."..name))
      from = r.get("section."..name)
      to   = r.get("section."..name.."_end")
      old_opcode = ''

      print (string.format("Segment "..name.." at 0x%x",from))

      --- ... do the job here ...
    end

So we can now work on a single segment just giving the section name:

    opcleaner_section ("_text")

We can locate the current seek in the maps by typing '!maps?':

    [0x4A13B8C0]> !maps?
    0x4a13b000 * 0x4a155000 r-x- 0x0001a000 /lib/ld-2.5.so