We have an array that is oversized for alignment purposes, such that off by one errors are not caught by the usual mechanisms.
Is it possible to protect a small, arbitrary region (16 bytes at the beginning and end of an array) in Windows, such that it causes an access violation? Language is C++.
I believe that in the x86 architecture the finest granularity you can achieve in marking memory as protected is for a page (4K I think). You could set up the array such that the beginning or end falls across a page boundary (and have that page protected). But to have both ends fall across such boundaries would of course require a very specific array length.
Here is an example of how to set up guard pages.