[KMTESTS:EX]
authorThomas Faber <thomas.faber@reactos.org>
Mon, 16 Sep 2013 19:02:28 +0000 (19:02 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Mon, 16 Sep 2013 19:02:28 +0000 (19:02 +0000)
- Test that quota allocations keep their QUOTA_POOL_MASK bit in POOL_HEADER

svn path=/trunk/; revision=60175

rostests/kmtests/include/kmt_test.h
rostests/kmtests/ntos_ex/ExPools.c

index b00962a..0cfacbf 100644 (file)
@@ -131,6 +131,7 @@ extern PDRIVER_OBJECT KmtDriverObject;
 VOID KmtSetIrql(IN KIRQL NewIrql);
 BOOLEAN KmtAreInterruptsEnabled(VOID);
 ULONG KmtGetPoolTag(PVOID Memory);
 VOID KmtSetIrql(IN KIRQL NewIrql);
 BOOLEAN KmtAreInterruptsEnabled(VOID);
 ULONG KmtGetPoolTag(PVOID Memory);
+USHORT KmtGetPoolType(PVOID Memory);
 #elif defined KMT_USER_MODE
 DWORD KmtRunKernelTest(IN PCSTR TestName);
 
 #elif defined KMT_USER_MODE
 DWORD KmtRunKernelTest(IN PCSTR TestName);
 
@@ -334,6 +335,20 @@ ULONG KmtGetPoolTag(PVOID Memory)
     return Header->PoolTag;
 }
 
     return Header->PoolTag;
 }
 
+USHORT KmtGetPoolType(PVOID Memory)
+{
+    PPOOL_HEADER Header;
+
+    /* it's not so easy for allocations of PAGE_SIZE */
+    if (((ULONG_PTR)Memory & (PAGE_SIZE - 1)) == 0)
+        return 0;
+
+    Header = Memory;
+    Header--;
+
+    return Header->PoolType;
+}
+
 INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
 #elif defined KMT_USER_MODE
 static PKMT_RESULTBUFFER KmtAllocateResultBuffer(SIZE_T ResultBufferSize)
 INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
 #elif defined KMT_USER_MODE
 static PKMT_RESULTBUFFER KmtAllocateResultBuffer(SIZE_T ResultBufferSize)
index ed1aca5..a9dc117 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
 #define NDEBUG
 #include <debug.h>
 
+#define TAG_POOLTEST 'tstP'
+
+#define BASE_POOL_TYPE_MASK 1
+#define QUOTA_POOL_MASK 8
+
 static
 LONG
 GetRefCount(
 static
 LONG
 GetRefCount(
@@ -19,8 +24,6 @@ GetRefCount(
     return Header->PointerCount;
 }
 
     return Header->PointerCount;
 }
 
-#define TAG_POOLTEST 'tstP'
-
 static VOID PoolsTest(VOID)
 {
     PVOID Ptr;
 static VOID PoolsTest(VOID)
 {
     PVOID Ptr;
@@ -190,6 +193,7 @@ TestPoolQuota(VOID)
     PVOID Memory;
     LONG InitialRefCount;
     LONG RefCount;
     PVOID Memory;
     LONG InitialRefCount;
     LONG RefCount;
+    USHORT PoolType;
     NTSTATUS ExceptionStatus;
 
     InitialRefCount = GetRefCount(Process);
     NTSTATUS ExceptionStatus;
 
     InitialRefCount = GetRefCount(Process);
@@ -212,6 +216,13 @@ TestPoolQuota(VOID)
         StoredProcess = ((PVOID *)((ULONG_PTR)Memory + 2 * sizeof(LIST_ENTRY)))[-1];
         ok_eq_pointer(StoredProcess, Process);
 
         StoredProcess = ((PVOID *)((ULONG_PTR)Memory + 2 * sizeof(LIST_ENTRY)))[-1];
         ok_eq_pointer(StoredProcess, Process);
 
+        /* Pool type should have QUOTA_POOL_MASK set */
+        PoolType = KmtGetPoolType(Memory);
+        ok(PoolType != 0, "PoolType is 0\n");
+        PoolType--;
+        ok(PoolType & QUOTA_POOL_MASK, "PoolType = %x\n", PoolType);
+        ok((PoolType & BASE_POOL_TYPE_MASK) == PagedPool, "PoolType = %x\n", PoolType);
+
         ExFreePoolWithTag(Memory, 'tQmK');
         RefCount = GetRefCount(Process);
         ok_eq_long(RefCount, InitialRefCount);
         ExFreePoolWithTag(Memory, 'tQmK');
         RefCount = GetRefCount(Process);
         ok_eq_long(RefCount, InitialRefCount);