Module: wine Branch: master Commit: 30882eb08e875599a76af5f6b4d7b81019622190 URL: http://source.winehq.org/git/wine.git/?a=commit;h=30882eb08e875599a76af5f6b4...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Tue Nov 22 18:02:26 2011 +0800
kernel32: Add a test to see how a page protection changes after write.
---
dlls/kernel32/tests/virtual.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index aefa9d0..45832fe 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -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