Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid memory mapping (UC_ERR_MAP) #10

Open
F-hertz opened this issue Nov 4, 2017 · 3 comments
Open

Invalid memory mapping (UC_ERR_MAP) #10

F-hertz opened this issue Nov 4, 2017 · 3 comments

Comments

@F-hertz
Copy link

F-hertz commented Nov 4, 2017

Hello,

From an so library :
ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped

I got unicorn.unicorn.UcError: Invalid memory mapping (UC_ERR_MAP)
self.mu = Uc(UC_ARCH_X86, UC_MODE_32)

   self.mu.mem_map(0x12000,0x4000)
   self.mu.mem_map(0x18000,0x4000)
   self.mu.mem_map(0x1000 * 1, 0x1000)

is there some hints ?

@pbiernat
Copy link
Owner

pbiernat commented Nov 6, 2017

I don't get any errors from unicorn, at least just from those lines.

Happy to take a look in the next day or so if you want to post the full output and target binary.

@v-p-b
Copy link

v-p-b commented Jan 2, 2018

I get a very similar error when I compile the RC4 sample to 32-bit (gcc -m32):

Traceback (most recent call last):
  File "test.py", line 58, in <module>
    prga=PRGA()
  File "test.py", line 14, in __init__
    self.mu.mem_map(0x804a000L,0x4000)
  File "/usr/local/lib/python2.7/dist-packages/unicorn/unicorn.py", line 407, in mem_map
    raise UcError(status)
unicorn.unicorn.UcError: Invalid memory mapping (UC_ERR_MAP)

Here's the relevant part of the code:

        self.mu.mem_map(0x8048000L,0x4000)
        self.mu.mem_map(0x804a000L,0x4000)
        self.mu.mem_map(0x7ffff000,0x200000)

        self.mu.mem_write(0x804a020L, self.data_0)
        self.mu.mem_write(0x80484cbL, self.code_0)
        self.mu.mem_write(0x80485b1L, self.code_1)

It seems that the mappings overlap: If I change the size of the first mapping to 0x1000 (still plenty to hold the data) the issue goes away.

@psifertex
Copy link

I ran into this error on stream recently. One underlying issue is that if you want to emulate arguments, ripr needs to make sure that region doesn't overlap with existing sections. I'll probably whip up a PR to make that change in a little bit. In the meantime, an easy hack is to just rebase the entire binary to a different offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants