Author: tfaber
Date: Fri Jun 16 11:06:33 2017
New Revision: 75057
URL:
http://svn.reactos.org/svn/reactos?rev=75057&view=rev
Log:
[KMTESTS:MM]
- In the MmMapLockedPagesSpecifyCache test, try to allocate & free memory or unmap a
section view in the mapped buffer space
CORE-13444
Modified:
trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c
Modified: trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_mm/MmMapLock…
==============================================================================
--- trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c [iso-8859-1]
(original)
+++ trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c [iso-8859-1] Fri
Jun 16 11:06:33 2017
@@ -38,6 +38,39 @@
} \
}
+#define CHECK_ALLOC(MappedBuffer, BufferLength) \
+{ \
+ NTSTATUS Status; \
+ PVOID BaseAddress; \
+ SIZE_T Size; \
+ BaseAddress = MappedBuffer; \
+ Size = BufferLength; \
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(), \
+ &BaseAddress, \
+ 0, \
+ &Size, \
+ MEM_RESERVE, \
+ PAGE_READWRITE); \
+ ok_eq_hex(Status, STATUS_CONFLICTING_ADDRESSES); \
+ BaseAddress = MappedBuffer; \
+ Size = 0; \
+ Status = NtFreeVirtualMemory(NtCurrentProcess(), \
+ &BaseAddress, \
+ &Size, \
+ MEM_DECOMMIT); \
+ ok_eq_hex(Status, STATUS_UNABLE_TO_DELETE_SECTION); \
+ BaseAddress = MappedBuffer; \
+ Size = 0; \
+ Status = NtFreeVirtualMemory(NtCurrentProcess(), \
+ &BaseAddress, \
+ &Size, \
+ MEM_RELEASE); \
+ ok_eq_hex(Status, STATUS_UNABLE_TO_DELETE_SECTION); \
+ Status = NtUnmapViewOfSection(NtCurrentProcess(), \
+ MappedBuffer); \
+ ok_eq_hex(Status, STATUS_NOT_MAPPED_VIEW); \
+}
+
START_TEST(MmMapLockedPagesSpecifyCache)
{
QUERY_BUFFER QueryBuffer;
@@ -56,16 +89,18 @@
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- Length = 0;
- FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- Length = sizeof(QUERY_BUFFER);
- FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
Length = 0;
FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
@@ -78,16 +113,18 @@
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- Length = 0;
- FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- Length = sizeof(QUERY_BUFFER);
- FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
Length = 0;
FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
@@ -100,16 +137,18 @@
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- Length = 0;
- FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- Length = sizeof(QUERY_BUFFER);
- FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
Length = 0;
FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
@@ -122,16 +161,18 @@
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- Length = 0;
- FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- Length = sizeof(QUERY_BUFFER);
- FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
Length = 0;
FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
@@ -146,6 +187,7 @@
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
Length = 0;
FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
@@ -158,6 +200,7 @@
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+ CHECK_ALLOC(QueryBuffer.Buffer, BufferLength);
Length = 0;
FILL_READ_BUFFER(QueryBuffer, ReadBuffer);