From 8e2e95ed7e42915415c81e10f35623ef1248917b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 26 Aug 2010 18:05:55 +0200 Subject: [PATCH] ntdll/tests: Add a test for the protection state of the read-write data section. --- dlls/ntdll/tests/info.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index f30c6ab50f..ffeb22a997 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -1073,6 +1073,7 @@ static void test_queryvirtualmemory(void) NTSTATUS status; SIZE_T readcount; static const char teststring[] = "test string"; + static char datatestbuf[42] = "abc"; static char rwtestbuf[42]; MEMORY_BASIC_INFORMATION mbi; char stackbuf[42]; @@ -1112,7 +1113,15 @@ static void test_queryvirtualmemory(void) if (mbi.Protect != PAGE_READONLY) todo_wine ok( mbi.Protect == PAGE_READONLY, "mbi.Protect is 0x%x, expected 0x%X\n", mbi.Protect, PAGE_READONLY); - trace("Check flags of read-write global data (.bss) at %p\n", rwtestbuf); + trace("Check flags of read-write data at %p\n", datatestbuf); + status = pNtQueryVirtualMemory(NtCurrentProcess(), datatestbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount); + ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY); + ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT); + ok (mbi.Protect == PAGE_READWRITE, "mbi.Protect is 0x%x, expected 0x%X\n", mbi.Protect, PAGE_READWRITE); + + trace("Check flags of read-write uninitialized data (.bss) at %p\n", rwtestbuf); status = pNtQueryVirtualMemory(NtCurrentProcess(), rwtestbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);