Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-09-2005, 03:05 AM   #1
Damaged Soul
LQ Newbie
Registered: Nov 2004
Posts: 8

Rep: Reputation: 0
Memory Page Protections

I'm trying to figure out how I can determine the protection set on a page of memory. For example, the mprotect syscall lets you specify a set of protection flags in order to change whether a memory page is readable, writable, and executable or not. I don't want to change the protection. I'd basically like to query it and figure out what the current protection is set to for a particular page of memory.

I know in Windows there's VirtualQuery which could help me get that sort of information. But I can't seem to find anything similar for Linux. Does anyone have any ideas how I might accomplish this? (I'm using C/C++, but that doesn't really matter at this point I guess)
Old 07-10-2005, 11:44 AM   #2
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
I assume your using <sys/mman.h>?? If you are it doesn't look like it from what I can see:

int    mlock(const void *, size_t);
int    mlockall(int);
void  *mmap(void *, size_t, int, int, int, off_t);
int    mprotect(void *, size_t, int);
int    msync(void *, size_t, int);
int    munlock(const void *, size_t);
int    munlockall(void);
int    munmap(void *, size_t);
int    shm_open(const char *, int, mode_t);
int    shm_unlink(const char *);
But just look into the header files you're #including and see if anything returns the type of UDT that you'd be looking for.
Old 07-11-2005, 07:51 AM   #3
Registered: Jul 2004
Location: Boston, MA, USA
Distribution: FreeBSD, Debian/AMD64, Ubuntu/i386
Posts: 59

Rep: Reputation: 15
You can temporarily set a SIGSEGV and SIGBUS handler and just try.

Won't work for execute but that is rarely supported on CPUs.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dell Inspiron 8100: No scancodes from Page Up Page Down keys twosider Linux - Laptop and Netbook 1 10-18-2005 10:41 AM
Buffer overflow protections compared ahz Linux - Security 0 01-26-2005 10:54 PM
I cant change the default test page in apache server to add my page.y nhemapriya Linux - Newbie 3 05-13-2004 01:35 PM
RH & HP4050N PCL - page, pause, page, pause, page andguent Linux - Hardware 0 11-10-2003 09:35 AM
Help!?! RH 8 Memory Mapping -High Memory-Virtural Memory issues.. Merlin53 Linux - Hardware 2 06-18-2003 05:48 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration