From 9a41e5d6ecb11a1c436723083e21262b882b0567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 12 Jul 2011 17:55:20 +0000 Subject: [PATCH] [APITESTS] - Add some more tests to NtFreeVirtualMemory svn path=/trunk/; revision=52659 --- rostests/apitests/ntdll/NtFreeVirtualMemory.c | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/rostests/apitests/ntdll/NtFreeVirtualMemory.c b/rostests/apitests/ntdll/NtFreeVirtualMemory.c index 74a7f65772a..416e54b6e2d 100644 --- a/rostests/apitests/ntdll/NtFreeVirtualMemory.c +++ b/rostests/apitests/ntdll/NtFreeVirtualMemory.c @@ -111,6 +111,38 @@ static void Test_NtFreeVirtualMemory(void) ok(Length == PAGE_SIZE, "Length mismatch : 0x08x\n", Length); ok(Buffer2 == (PVOID)((ULONG_PTR)Buffer+PAGE_SIZE), "The buffer is not aligned to PAGE_SIZE.\n"); + /* Same, but try to free the second page before the first one */ + Length = 2*PAGE_SIZE; + Status = NtAllocateVirtualMemory(NtCurrentProcess(), + &Buffer, + 0, + &Length, + MEM_RESERVE, + PAGE_READWRITE); + ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed : 0x%08x\n", Status); + ok(Length == 2*PAGE_SIZE, "Length mismatch : 0x08x\n", Length); + ok(((ULONG_PTR)Buffer % PAGE_SIZE) == 0, "The buffer is not aligned to PAGE_SIZE.\n"); + + Buffer2 = (PVOID)((ULONG_PTR)Buffer+PAGE_SIZE); + Length = PAGE_SIZE; + Status = NtFreeVirtualMemory(NtCurrentProcess(), + &Buffer2, + &Length, + MEM_RELEASE); + ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed : 0x%08x\n", Status); + ok(Length == PAGE_SIZE, "Length mismatch : 0x08x\n", Length); + ok(Buffer2 == (PVOID)((ULONG_PTR)Buffer+PAGE_SIZE), "The buffer is not aligned to PAGE_SIZE.\n"); + + Buffer2 = Buffer; + Length = PAGE_SIZE; + Status = NtFreeVirtualMemory(NtCurrentProcess(), + &Buffer2, + &Length, + MEM_RELEASE); + ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed : 0x%08x\n", Status); + ok(Length == PAGE_SIZE, "Length mismatch : 0x08x\n", Length); + ok(Buffer2 == Buffer, "The buffer is not aligned to PAGE_SIZE.\n"); + /* Now allocate two pages and try to free them in the middle */ Length = 2*PAGE_SIZE; Status = NtAllocateVirtualMemory(NtCurrentProcess(),