From: Jérôme Gardou Date: Mon, 30 Jun 2014 19:50:28 +0000 (+0000) Subject: [NTDLL_APITEST] X-Git-Tag: backups/0.3.17@66124~930 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=265497886ff7ff4302bd80ae75365cb6b4a94ce2 [NTDLL_APITEST] - Add a test showing that memory content is still available after changing protection to PAGE_NOACCESS svn path=/trunk/; revision=63678 --- diff --git a/rostests/apitests/ntdll/NtProtectVirtualMemory.c b/rostests/apitests/ntdll/NtProtectVirtualMemory.c index e1bbe04c57d..e492ecebbb4 100644 --- a/rostests/apitests/ntdll/NtProtectVirtualMemory.c +++ b/rostests/apitests/ntdll/NtProtectVirtualMemory.c @@ -89,6 +89,27 @@ START_TEST(NtProtectVirtualMemory) { ok(*allocationStart == 0, "Test should not go as far as this.\n"); } EndSeh(STATUS_ACCESS_VIOLATION); + + /* Set it as readable again */ + status = NtProtectVirtualMemory(NtCurrentProcess(), + (void**)&allocationStart, + &allocationSize, + PAGE_READONLY, + &oldProtection); + ok(NT_SUCCESS(status), "NtProtectVirtualMemory failed.\n"); + ok(oldProtection == PAGE_NOACCESS, "Expected PAGE_READONLY, got %08lx.\n", oldProtection); + + /* Try writing it */ + StartSeh() + { + *allocationStart = 0xAA; + } EndSeh(STATUS_ACCESS_VIOLATION); + + /* Try reading it */ + StartSeh() + { + ok(*allocationStart == 0xFF, "Memory content was not preserved.\n"); + } EndSeh(STATUS_SUCCESS); /* Free memory */ status = NtFreeVirtualMemory(NtCurrentProcess(), @@ -96,4 +117,4 @@ START_TEST(NtProtectVirtualMemory) &allocationSize, MEM_RELEASE); ok(NT_SUCCESS(status), "Failed freeing memory.\n"); -} \ No newline at end of file +}