Commit 30882eb0 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

kernel32: Add a test to see how a page protection changes after write.

parent ad0f8b6b
......@@ -1523,6 +1523,21 @@ static void test_VirtualProtect(void)
VirtualFree(base, 0, MEM_FREE);
}
static BOOL is_mem_writable(DWORD prot)
{
switch (prot & 0xff)
{
case PAGE_READWRITE:
case PAGE_WRITECOPY:
case PAGE_EXECUTE_READWRITE:
case PAGE_EXECUTE_WRITECOPY:
return TRUE;
default:
return FALSE;
}
}
static void test_VirtualAlloc_protection(void)
{
static const struct test_data
......@@ -1575,7 +1590,7 @@ static void test_VirtualAlloc_protection(void)
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
{
SetLastError(0xdeadbeef);
base = VirtualAlloc(0, si.dwPageSize, MEM_RESERVE | MEM_COMMIT, td[i].prot);
base = VirtualAlloc(0, si.dwPageSize, MEM_COMMIT, td[i].prot);
if (td[i].success)
{
......@@ -1592,6 +1607,16 @@ static void test_VirtualAlloc_protection(void)
ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
ok(info.Type == MEM_PRIVATE, "%d: %#x != MEM_PRIVATE\n", i, info.Type);
if (is_mem_writable(info.Protect))
{
base[0] = 0xfe;
SetLastError(0xdeadbeef);
ret = VirtualQuery(base, &info, sizeof(info));
ok(ret, "VirtualQuery failed %d\n", GetLastError());
ok(info.Protect == td[i].prot, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot);
}
VirtualFree(base, 0, MEM_FREE);
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment