POSIX defines the mprotect() interface to allow programs to change the permissions of existing regions of memory: #include <sys/mman.h> int mprotect (const void *addr, A call to mprotect() will change the protection mode for the memory pages contained in [addr,addr+len), where addr is page-aligned. Theprotparameter accepts the same values as theprotgiven tommap():PROT_NONE,PROT_READ,PROT_WRITE, andPROT_EXEC. These values are not additive; if a region of memory is readable, andprot is set to onlyPROT_WRITE, the call will make the region only writable. On some systems,mprotect()may operate only on memory mappings previously created viammap(). On Linux,mprotect()can operate on any region of memory. On success, mprotect() returns 0. On failure, it returns -1, and setserrnoto one of the following: EACCESS
EINVAL
ENOMEM
blog comments powered by Disqus |