2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite CcCopyRead test user-mode part
5 * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
10 START_TEST(CcCopyRead
)
14 LARGE_INTEGER ByteOffset
;
15 IO_STATUS_BLOCK IoStatusBlock
;
16 OBJECT_ATTRIBUTES ObjectAttributes
;
17 PVOID Buffer
= RtlAllocateHeap(RtlGetProcessHeap(), 0, 1024);
18 UNICODE_STRING BigAlignmentTest
= RTL_CONSTANT_STRING(L
"\\Device\\Kmtest-CcCopyRead\\BigAlignmentTest");
19 UNICODE_STRING SmallAlignmentTest
= RTL_CONSTANT_STRING(L
"\\Device\\Kmtest-CcCopyRead\\SmallAlignmentTest");
20 UNICODE_STRING ReallySmallAlignmentTest
= RTL_CONSTANT_STRING(L
"\\Device\\Kmtest-CcCopyRead\\ReallySmallAlignmentTest");
22 KmtLoadDriver(L
"CcCopyRead", FALSE
);
25 InitializeObjectAttributes(&ObjectAttributes
, &SmallAlignmentTest
, OBJ_CASE_INSENSITIVE
, NULL
, NULL
);
26 Status
= NtOpenFile(&Handle
, FILE_ALL_ACCESS
, &ObjectAttributes
, &IoStatusBlock
, 0, FILE_NON_DIRECTORY_FILE
| FILE_SYNCHRONOUS_IO_NONALERT
);
27 ok_eq_hex(Status
, STATUS_SUCCESS
);
29 ByteOffset
.QuadPart
= 3;
30 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 3, &ByteOffset
, NULL
);
31 ok_eq_hex(Status
, STATUS_SUCCESS
);
32 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
34 ByteOffset
.QuadPart
= 514;
35 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 514, &ByteOffset
, NULL
);
36 ok_eq_hex(Status
, STATUS_SUCCESS
);
37 ok_eq_hex(((USHORT
*)Buffer
)[242], 0xBABA);
38 ok_eq_hex(((USHORT
*)Buffer
)[243], 0xFFFF);
40 ByteOffset
.QuadPart
= 1000;
41 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 2, &ByteOffset
, NULL
);
42 ok_eq_hex(Status
, STATUS_SUCCESS
);
43 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xFFFF);
44 ok_eq_hex(((USHORT
*)Buffer
)[1], 0xBABA);
48 InitializeObjectAttributes(&ObjectAttributes
, &BigAlignmentTest
, OBJ_CASE_INSENSITIVE
, NULL
, NULL
);
49 Status
= NtOpenFile(&Handle
, FILE_ALL_ACCESS
, &ObjectAttributes
, &IoStatusBlock
, 0, FILE_NON_DIRECTORY_FILE
| FILE_SYNCHRONOUS_IO_NONALERT
);
50 ok_eq_hex(Status
, STATUS_SUCCESS
);
52 ByteOffset
.QuadPart
= 3;
53 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 3, &ByteOffset
, NULL
);
54 ok_eq_hex(Status
, STATUS_SUCCESS
);
55 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
57 ByteOffset
.QuadPart
= 514;
58 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 514, &ByteOffset
, NULL
);
59 ok_eq_hex(Status
, STATUS_SUCCESS
);
60 ok_eq_hex(((USHORT
*)Buffer
)[242], 0xBABA);
61 ok_eq_hex(((USHORT
*)Buffer
)[243], 0xFFFF);
63 ByteOffset
.QuadPart
= 300000;
64 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 10, &ByteOffset
, NULL
);
65 ok_eq_hex(Status
, STATUS_SUCCESS
);
66 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
68 ByteOffset
.QuadPart
= 999990;
69 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 10, &ByteOffset
, NULL
);
70 ok_eq_hex(Status
, STATUS_SUCCESS
);
71 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
73 ByteOffset
.QuadPart
= 1000;
74 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 2, &ByteOffset
, NULL
);
75 ok_eq_hex(Status
, STATUS_SUCCESS
);
76 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xFFFF);
77 ok_eq_hex(((USHORT
*)Buffer
)[1], 0xBABA);
81 InitializeObjectAttributes(&ObjectAttributes
, &ReallySmallAlignmentTest
, OBJ_CASE_INSENSITIVE
, NULL
, NULL
);
82 Status
= NtOpenFile(&Handle
, FILE_ALL_ACCESS
, &ObjectAttributes
, &IoStatusBlock
, 0, FILE_NON_DIRECTORY_FILE
| FILE_SYNCHRONOUS_IO_NONALERT
);
83 ok_eq_hex(Status
, STATUS_SUCCESS
);
85 ByteOffset
.QuadPart
= 1;
86 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 61, &ByteOffset
, NULL
);
87 ok_eq_hex(Status
, STATUS_SUCCESS
);
88 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
92 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer
);