X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=modules%2Frostests%2Fapitests%2Fntdll%2FNtFreeVirtualMemory.c;h=07aa1192187d28fca57ff116490c6e90b5f2a0d6;hp=02ebe8dec6b644cad3e058e22c023682f317db66;hb=a11841c939790b9bd1721f6aeae79e335932528c;hpb=4aabe88288c70e19d7ed73e77743cd0783ba1d37 diff --git a/modules/rostests/apitests/ntdll/NtFreeVirtualMemory.c b/modules/rostests/apitests/ntdll/NtFreeVirtualMemory.c index 02ebe8dec6b..07aa1192187 100644 --- a/modules/rostests/apitests/ntdll/NtFreeVirtualMemory.c +++ b/modules/rostests/apitests/ntdll/NtFreeVirtualMemory.c @@ -3,6 +3,7 @@ * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) * PURPOSE: Test for NtFreeVirtualMemory * COPYRIGHT: Copyright 2011 Jérôme Gardou + * Copyright 2017 Serge Gautherie */ #include "precomp.h" @@ -169,8 +170,48 @@ static void Test_NtFreeVirtualMemory(void) ok(Length == 2*PAGE_SIZE, "Length mismatch : 0x%08lx\n", (ULONG)Length); ok(Buffer2 == Buffer, "The buffer is not aligned to PAGE_SIZE.\n"); } - + +static void Test_NtFreeVirtualMemory_Parameters(void) +{ + NTSTATUS Status; + ULONG FreeType; + int i; + + // 4th parameter: "ULONG FreeType". + + // A type is mandatory. + Status = NtFreeVirtualMemory(NULL, NULL, NULL, 0ul); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); + + // All but MEM_DECOMMIT and MEM_RELEASE are unsupported. + // Each bit one by one. + for (i = 0; i < 32; ++i) + { + FreeType = 1 << i; + if (FreeType == MEM_DECOMMIT || FreeType == MEM_RELEASE) + continue; + + Status = NtFreeVirtualMemory(NULL, NULL, NULL, FreeType); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); + } + // All bits at once. + // Not testing all other values. + Status = NtFreeVirtualMemory(NULL, NULL, NULL, ~(MEM_DECOMMIT | MEM_RELEASE)); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); + Status = NtFreeVirtualMemory(NULL, NULL, NULL, ~MEM_DECOMMIT); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); + Status = NtFreeVirtualMemory(NULL, NULL, NULL, ~MEM_RELEASE); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); + Status = NtFreeVirtualMemory(NULL, NULL, NULL, ~0ul); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); + + // MEM_DECOMMIT and MEM_RELEASE are exclusive. + Status = NtFreeVirtualMemory(NULL, NULL, NULL, MEM_DECOMMIT | MEM_RELEASE); + ok(Status == STATUS_INVALID_PARAMETER_4, "NtFreeVirtualMemory returned status : 0x%08lx\n", Status); +} + START_TEST(NtFreeVirtualMemory) { Test_NtFreeVirtualMemory(); + Test_NtFreeVirtualMemory_Parameters(); } \ No newline at end of file