[KMTESTS:MM] Properly clean up files
authorPierre Schweitzer <pierre@reactos.org>
Sun, 12 Aug 2018 08:05:25 +0000 (10:05 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 12 Aug 2018 08:05:25 +0000 (10:05 +0200)
This fixes driver unloading on Windows.

ROSTESTS-266

modules/rostests/kmtests/ntos_mm/NtCreateSection_drv.c

index 45f20b5..a547207 100644 (file)
@@ -413,13 +413,16 @@ TestIrpHandler(
     {
         Fcb = IoStack->FileObject->FsContext;
         ok(Fcb != NULL, "Null pointer!\n");
-        if (IoStack->FileObject->SectionObjectPointer != NULL &&
-            IoStack->FileObject->SectionObjectPointer->SharedCacheMap != NULL)
+        if (IoStack->FileObject->SectionObjectPointer != NULL)
         {
             LARGE_INTEGER Zero = RTL_CONSTANT_LARGE_INTEGER(0LL);
 
-            CcFlushCache(&Fcb->SectionObjectPointers, NULL, 0, NULL);
-            CcPurgeCacheSection(&Fcb->SectionObjectPointers, NULL, 0, FALSE);
+            if (CcIsFileCached(IoStack->FileObject))
+            {
+                CcFlushCache(&Fcb->SectionObjectPointers, NULL, 0, NULL);
+                CcPurgeCacheSection(&Fcb->SectionObjectPointers, NULL, 0, FALSE);
+            }
+
             KeInitializeEvent(&CacheUninitEvent.Event, NotificationEvent, FALSE);
             CcUninitializeCacheMap(IoStack->FileObject, &Zero, &CacheUninitEvent);
             KeWaitForSingleObject(&CacheUninitEvent.Event, Executive, KernelMode, FALSE, NULL);