https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a11841c939790b9bd1721f6aeae79e335932528c

commit a11841c939790b9bd1721f6aeae79e335932528c
Author: Serge Gautherie <[email protected]>
AuthorDate: Mon Nov 27 00:51:18 2017 +0100

    [NTDLL_APITEST] Create Test_NtFreeVirtualMemory_Parameters(). CORE-13126
    
    - Test 4th parameter ("ULONG FreeType") invalid values.
---
 .../rostests/apitests/ntdll/NtFreeVirtualMemory.c  | 43 +++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/modules/rostests/apitests/ntdll/NtFreeVirtualMemory.c 
b/modules/rostests/apitests/ntdll/NtFreeVirtualMemory.c
index 02ebe8dec6..07aa119218 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 <[email protected]>
+ *              Copyright 2017 Serge Gautherie 
<[email protected]>
  */
 
 #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

Reply via email to