Can I set/disable read(or write)-access privilage of the last several elements of an ordinary array in C/C++ ? Since I cannot use other processes' memory, I suspect this could be possible but how? I googled but couldnt find.
If I can, how?
Because I want to try something like this:
SetPrivilage(arr,LAST_5_ELEMENTS,false);
try
{
for(int i=0;;i++) //without bound checking. i know its evil. just trying if it is possible
{
arr[i]++; //array is 1-billion elements
}
}
catch(int catch_end_of_array)
{
printf("array-inc complete");
}
Memory:
|start of array |00|01|02|03|04|05|06|07|..|..|1B|start of protected page|xx|xx|xx|xx|xx|xx|xx|xx|xx|xx|xx|xx|xx|
Lets assume I learned how to protect a page, then how could i declare an array just near the page so arrays end-point will be next to the page. ?