I know that mprotect is used to protect a whole memory page. Can anyone please tell me if there is a way to protect and unportect a single memory byte?
Asked
Active
Viewed 516 times
1
-
3No, there isn't. The granularity is the page size, so you will have to protect a full page. – Frédéric Hamidi Nov 24 '13 at 09:44
-
3What are you trying to do exactly? – Mat Nov 24 '13 at 09:45
-
Just like using an integer to store a single boolean in uses 32 bits to store only 1 -- of course it works, but it gets inefficient with larger numbers of bits. – Jongware Nov 24 '13 at 14:57
1 Answers
0
Protect how? If you are looking for protection against concurrent reads/right a pthread_mutex_t is what you are looking for.
http://www.sourceware.org/pthreads-win32/manual/pthread_mutex_init.html
As mentioned in the comments, mprotect is used for full pages.

It'sPete
- 5,083
- 8
- 39
- 72