Created
August 18, 2016 21:14
-
-
Save katlogic/3e20fc65c13ef66525d948c946236dd0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
static int data[1] __attribute__((aligned(4096))) = {1}; | |
int main() | |
{ | |
MEMORY_BASIC_INFORMATION info; | |
VirtualQuery(&data, &info, sizeof(info)); | |
printf("%d\n", info.Protect==PAGE_WRITECOPY); | |
DWORD old, old2; | |
VirtualProtect(&data, 4096, PAGE_NOACCESS, &old); // ANY flag for that matter | |
VirtualProtect(&data, 4096, old, &old); | |
printf("%d\n", info.Protect==PAGE_WRITECOPY); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment