delorie.com/djgpp/doc/libc/libc_588.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <sys/types.h> #include <sys/mman.h> int mprotect(void *addr, size_t len, int prot); |
This function modifies the access protection of a memory region. Protection occurs in 4Kbyte regions (pages) aligned on 4Kbyte boundaries. All pages in the region will be changed, so addr and len should be multiples of 4096.
The protection prot for each page is specified with the values: PROT_NONE Region can not be touched (if or'ed is ignored). PROT_READ Region can be read (can be or'ed with PROT_WRITE). PROT_WRITE Region can be written (implies read access). This function is only supported on DPMI hosts which provide some V1.0 extensions on V0.9 memory blocks.
The function returns 0 if successful and the value -1 if all the pages could not be set.
ANSI/ISO C | No |
POSIX | No |
mprotect(readonly_buffer,8192,PROT_READ); mprotect(guard_area,4096,PROT_NONE); mprotect(NULL,4096,PROT_WRITE); /* Let NULL pointers not generate * exceptions */ |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |