https://git.reactos.org/?p=reactos.git;a=commitdiff;h=351ae6b2b4a7d6b8aa0b6…
commit 351ae6b2b4a7d6b8aa0b6b03cf460aa078c5cdb4
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Fri Sep 21 08:35:38 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Fri Sep 21 08:37:20 2018 +0200
[KMTESTS:CC] Add tests for CcCopyRead that reproduce CORE-15067
CORE-15067
---
modules/rostests/kmtests/ntos_cc/CcCopyRead_drv.c | 19 +++++++++++++++++--
modules/rostests/kmtests/ntos_cc/CcCopyRead_user.c | 12 ++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/modules/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
b/modules/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
index 142e996548..831bf5c252 100644
--- a/modules/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
@@ -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");
diff --git a/modules/rostests/kmtests/ntos_cc/CcCopyRead_user.c
b/modules/rostests/kmtests/ntos_cc/CcCopyRead_user.c
index 1dbc08a5ce..f29495b7a2 100644
--- a/modules/rostests/kmtests/ntos_cc/CcCopyRead_user.c
+++ b/modules/rostests/kmtests/ntos_cc/CcCopyRead_user.c
@@ -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();