https://git.reactos.org/?p=reactos.git;a=commitdiff;h=38487d63d807705c67308…
commit 38487d63d807705c67308bdac3091032c35a04be
Author:     Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Sep 1 12:40:24 2018 +0200
Commit:     Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Sep 1 12:41:02 2018 +0200
    [KMTESTS:CC] Add a test for pinning without access
---
 modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c  | 19 ++++++++++++++++++-
 modules/rostests/kmtests/ntos_cc/CcPinRead_user.c |  3 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
index 34ceb13696..9b1d214d16 100644
--- a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
@@ -217,6 +217,8 @@ PerformTest(
         Fcb = ExAllocatePool(NonPagedPool, sizeof(TEST_FCB));
         if (!skip(Fcb != NULL, "ExAllocatePool failed\n"))
         {
+            BOOLEAN PinAccess = (TestId != 4);
+
             RtlZeroMemory(Fcb, sizeof(TEST_FCB));
             ExInitializeFastMutex(&Fcb->HeaderMutex);
             FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
@@ -225,7 +227,7 @@ PerformTest(
             TestFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
             KmtStartSeh();
-            CcInitializeCacheMap(TestFileObject, &FileSizes, TRUE, &Callbacks,
NULL);
+            CcInitializeCacheMap(TestFileObject, &FileSizes, PinAccess,
&Callbacks, NULL);
             KmtEndSeh(STATUS_SUCCESS);
             if (!skip(CcIsFileCached(TestFileObject) == TRUE, "CcInitializeCacheMap
failed\n"))
@@ -300,6 +302,21 @@ PerformTest(
                         ExFreePool(TestContext);
                     }
                 }
+                else if (TestId == 4)
+                {
+                    Ret = FALSE;
+                    Offset.QuadPart = 0x1000;
+                    KmtStartSeh();
+                    Ret = CcPinRead(TestFileObject, &Offset,
FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT, &Bcb, (PVOID *)&Buffer);
+                    KmtEndSeh(STATUS_SUCCESS);
+
+                    if (!skip(Ret == TRUE, "CcPinRead failed\n"))
+                    {
+                        ok_eq_ulong(Buffer[0x2000 / sizeof(ULONG)], 0);
+
+                        CcUnpinData(Bcb);
+                    }
+                }
             }
         }
     }
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_user.c
b/modules/rostests/kmtests/ntos_cc/CcPinRead_user.c
index c7a93a5d96..78818164e8 100644
--- a/modules/rostests/kmtests/ntos_cc/CcPinRead_user.c
+++ b/modules/rostests/kmtests/ntos_cc/CcPinRead_user.c
@@ -20,8 +20,9 @@ START_TEST(CcPinRead)
     /* 3 tests for offset
      * 1 test for BCB
+     * 1 test for pinning access
      */
-    for (TestId = 0; TestId < 4; ++TestId)
+    for (TestId = 0; TestId < 5; ++TestId)
     {
         Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
         ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);