Possible Duplicate:
Retrieving the memory map of its own process in OS X 10.5/10.6
On OS X, I can use mprotect()
to request that a specific page of memory be made some combination of readable, writable or executable.
I want to know how to find out what the current protection level is. As an example, on Linux I can cat /proc/$$/maps
to find out the same information:
$ cat /proc/$$/maps
00400000-004db000 r-xp 00000000 fb:00 131145 /bin/bash
006da000-006db000 r--p 000da000 fb:00 131145 /bin/bash
006db000-006e4000 rw-p 000db000 fb:00 131145 /bin/bash
006e4000-006ea000 rw-p 00000000 00:00 0
00df4000-00e55000 rw-p 00000000 00:00 0 [heap]
...
Here I can see that there are 5 ranges of memory mapped for the main executable (bash
), one is read/execute, one is read-only, and the rest are read/write.
I've looked through all the man pages and official APIs I can find to get the same information on OS X, and have come up empty so far. The only thing I've found that's close is to use mincore()
to figure out if a page is in-core or not. But that's not enough; I also want the current set of permissions.
Is there any undocumented way to do this?