[KMTESTS:CC] Add tests for CcCopyRead that reproduce CORE-15067
authorPierre Schweitzer <pierre@reactos.org>
Fri, 21 Sep 2018 06:35:38 +0000 (08:35 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Fri, 21 Sep 2018 06:37:20 +0000 (08:37 +0200)
CORE-15067

modules/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
modules/rostests/kmtests/ntos_cc/CcCopyRead_user.c

index 142e996..831bf5c 100644 (file)
@@ -15,6 +15,7 @@ typedef struct _TEST_FCB
     FSRTL_ADVANCED_FCB_HEADER Header;
     SECTION_OBJECT_POINTERS SectionObjectPointers;
     FAST_MUTEX HeaderMutex;
+    BOOLEAN BigFile;
 } TEST_FCB, *PTEST_FCB;
 
 static PFILE_OBJECT TestFileObject;
@@ -184,6 +185,7 @@ TestIrpHandler(
         RtlZeroMemory(Fcb, sizeof(*Fcb));
         ExInitializeFastMutex(&Fcb->HeaderMutex);
         FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
+        Fcb->BigFile = FALSE;
         if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
             IoStack->FileObject->FileName.Buffer[1] == 'B')
         {
@@ -205,6 +207,14 @@ TestIrpHandler(
             Fcb->Header.FileSize.QuadPart = 62;
             Fcb->Header.ValidDataLength.QuadPart = 62;
         }
+        else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
+                 IoStack->FileObject->FileName.Buffer[1] == 'F')
+        {
+            Fcb->Header.AllocationSize.QuadPart = 4294967296;
+            Fcb->Header.FileSize.QuadPart = 4294967296;
+            Fcb->Header.ValidDataLength.QuadPart = 4294967296;
+            Fcb->BigFile = TRUE;
+        }
         else
         {
             Fcb->Header.AllocationSize.QuadPart = 512;
@@ -239,8 +249,13 @@ TestIrpHandler(
         if (!FlagOn(Irp->Flags, IRP_NOCACHE))
         {
             ok_irql(PASSIVE_LEVEL);
-            ok(Offset.QuadPart % PAGE_SIZE != 0, "Offset is aligned: %I64i\n", Offset.QuadPart);
-            ok(Length % PAGE_SIZE != 0, "Length is aligned: %I64i\n", Length);
+
+            /* We don't want to test alignement for big files (not the purpose of the test) */
+            if (!Fcb->BigFile)
+            {
+                ok(Offset.QuadPart % PAGE_SIZE != 0, "Offset is aligned: %I64i\n", Offset.QuadPart);
+                ok(Length % PAGE_SIZE != 0, "Length is aligned: %I64i\n", Length);
+            }
 
             Buffer = Irp->AssociatedIrp.SystemBuffer;
             ok(Buffer != NULL, "Null pointer!\n");
index 1dbc08a..f29495b 100644 (file)
@@ -18,6 +18,7 @@ START_TEST(CcCopyRead)
     UNICODE_STRING BigAlignmentTest = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\BigAlignmentTest");
     UNICODE_STRING SmallAlignmentTest = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\SmallAlignmentTest");
     UNICODE_STRING ReallySmallAlignmentTest = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\ReallySmallAlignmentTest");
+    UNICODE_STRING FileBig = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\FileBig");
     
     KmtLoadDriver(L"CcCopyRead", FALSE);
     KmtOpenDriver();
@@ -89,6 +90,17 @@ START_TEST(CcCopyRead)
 
     NtClose(Handle);
 
+    InitializeObjectAttributes(&ObjectAttributes, &FileBig, OBJ_CASE_INSENSITIVE, NULL, NULL);
+    Status = NtOpenFile(&Handle, FILE_ALL_ACCESS, &ObjectAttributes, &IoStatusBlock, 0, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT);
+    ok_eq_hex(Status, STATUS_SUCCESS);
+
+    ByteOffset.QuadPart = 0;
+    Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 1024, &ByteOffset, NULL);
+    ok_eq_hex(Status, STATUS_SUCCESS);
+    ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
+
+    NtClose(Handle);
+
     RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
     KmtCloseDriver();
     KmtUnloadDriver();