[CRYPT32]
[reactos.git] / rostests / kmtests / ntos_mm / ZwAllocateVirtualMemory.c
index d551ee2..52e973d 100644 (file)
@@ -31,8 +31,13 @@ typedef struct _TEST_CONTEXT
 
 #define ALLOC_MEMORY_WITH_FREE(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect, RetStatus, FreeStatus)   \
     do {                                                                                                                   \
+        PVOID __BaseSave = BaseAddress;                                                                                    \
         Status = ZwAllocateVirtualMemory(ProcessHandle, &BaseAddress, ZeroBits, &RegionSize, AllocationType, Protect);     \
         ok_eq_hex(Status, RetStatus);                                                                                      \
+        if (__BaseSave != NULL)                                                                                            \
+            ok_eq_pointer(BaseAddress, __BaseSave);                                                                        \
+        else if (!NT_SUCCESS(Status))                                                                                      \
+            ok_eq_pointer(BaseAddress, NULL);                                                                              \
         RegionSize = 0;                                                                                                    \
         Status = ZwFreeVirtualMemory(ProcessHandle, &BaseAddress, &RegionSize, MEM_RELEASE);                               \
         if (FreeStatus != IGNORE) ok_eq_hex(Status, FreeStatus);                                                           \
@@ -64,7 +69,6 @@ static
 SIZE_T
 CheckBufferRead(CONST VOID *Source, CONST VOID *Destination, SIZE_T Length, NTSTATUS ExpectedStatus)
 {
-    NTSTATUS ExceptionStatus;
     SIZE_T Match = 0;
 
     KmtStartSeh()
@@ -79,7 +83,6 @@ VOID
 CheckBufferReadWrite(PVOID Destination, CONST VOID *Source, SIZE_T Length, NTSTATUS ExpectedStatus)
 {
     //do a little bit of writing/reading to memory
-    NTSTATUS ExceptionStatus;
     SIZE_T Match = 0;
 
     KmtStartSeh()
@@ -106,7 +109,7 @@ SimpleErrorChecks(VOID)
 
     //BASE ADDRESS TESTS
     Base = (PVOID)0x00567A20;
-    ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_CONFLICTING_ADDRESSES, STATUS_FREE_VM_NOT_AT_BASE);
+    ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_CONFLICTING_ADDRESSES, STATUS_UNABLE_TO_DELETE_SECTION);
 
     Base = (PVOID) 0x60000000;
     ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
@@ -167,7 +170,6 @@ NTSTATUS
 SimpleAllocation(VOID)
 {
     NTSTATUS Status;
-    NTSTATUS ExceptionStatus;
     PVOID Base = NULL;
     SIZE_T RegionSize = DEFAULT_ALLOC_SIZE;
 
@@ -238,8 +240,7 @@ SimpleAllocation(VOID)
     //////////////////////////////////////////////////////////////////////////
     // GUARD PAGES
     //////////////////////////////////////////////////////////////////////////
-/* FIXME: We don't support guard pages. See CORE-6639, ROSTESTS-107 */
-#ifdef ROSTESTS_107_FIXED
+
     RegionSize = 1000;
     Base = NULL;
     ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, (MEM_COMMIT | MEM_RESERVE), (PAGE_GUARD | PAGE_READWRITE));
@@ -257,7 +258,6 @@ SimpleAllocation(VOID)
 
     RegionSize = 0;
     ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
-#endif /* ROSTESTS_107_FIXED */
 
     return Status;
 }
@@ -442,7 +442,7 @@ SystemProcessTest(VOID)
         goto cleanup;
     }
 
-    Status = ObReferenceObjectByHandle(Thread1, THREAD_ALL_ACCESS, PsThreadType, KernelMode, &ThreadObjects[0], NULL);
+    Status = ObReferenceObjectByHandle(Thread1, THREAD_ALL_ACCESS, *PsThreadType, KernelMode, &ThreadObjects[0], NULL);
     if (!NT_SUCCESS(Status))
     {
         trace("error referencing thread1\n");
@@ -456,7 +456,7 @@ SystemProcessTest(VOID)
         goto cleanup;
     }
 
-    Status = ObReferenceObjectByHandle(Thread2, THREAD_ALL_ACCESS, PsThreadType, KernelMode, &ThreadObjects[1], NULL);
+    Status = ObReferenceObjectByHandle(Thread2, THREAD_ALL_ACCESS, *PsThreadType, KernelMode, &ThreadObjects[1], NULL);
     if (!NT_SUCCESS(Status))
     {
         trace("error referencing thread2\n");
@@ -506,7 +506,7 @@ START_TEST(ZwAllocateVirtualMemory)
 
     Status = STATUS_SUCCESS;
     Status = StressTesting(MEM_COMMIT);
-    ok_eq_hex(Status, STATUS_COMMITMENT_LIMIT);
+    ok_eq_hex(Status, STATUS_NO_MEMORY);
 
     SystemProcessTest();
 }