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");
21 KmtLoadDriver(L
"CcCopyRead", FALSE
);
24 InitializeObjectAttributes(&ObjectAttributes
, &SmallAlignmentTest
, OBJ_CASE_INSENSITIVE
, NULL
, NULL
);
25 Status
= NtOpenFile(&Handle
, FILE_ALL_ACCESS
, &ObjectAttributes
, &IoStatusBlock
, 0, FILE_NON_DIRECTORY_FILE
| FILE_SYNCHRONOUS_IO_NONALERT
);
26 ok_eq_hex(Status
, STATUS_SUCCESS
);
28 ByteOffset
.QuadPart
= 3;
29 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 3, &ByteOffset
, NULL
);
30 ok_eq_hex(Status
, STATUS_SUCCESS
);
31 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
33 ByteOffset
.QuadPart
= 514;
34 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 514, &ByteOffset
, NULL
);
35 ok_eq_hex(Status
, STATUS_SUCCESS
);
36 ok_eq_hex(((USHORT
*)Buffer
)[242], 0xBABA);
37 ok_eq_hex(((USHORT
*)Buffer
)[243], 0xFFFF);
39 ByteOffset
.QuadPart
= 1000;
40 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 2, &ByteOffset
, NULL
);
41 ok_eq_hex(Status
, STATUS_SUCCESS
);
42 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xFFFF);
43 ok_eq_hex(((USHORT
*)Buffer
)[1], 0xBABA);
47 InitializeObjectAttributes(&ObjectAttributes
, &BigAlignmentTest
, OBJ_CASE_INSENSITIVE
, NULL
, NULL
);
48 Status
= NtOpenFile(&Handle
, FILE_ALL_ACCESS
, &ObjectAttributes
, &IoStatusBlock
, 0, FILE_NON_DIRECTORY_FILE
| FILE_SYNCHRONOUS_IO_NONALERT
);
49 ok_eq_hex(Status
, STATUS_SUCCESS
);
51 ByteOffset
.QuadPart
= 3;
52 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 3, &ByteOffset
, NULL
);
53 ok_eq_hex(Status
, STATUS_SUCCESS
);
54 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
56 ByteOffset
.QuadPart
= 514;
57 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 514, &ByteOffset
, NULL
);
58 ok_eq_hex(Status
, STATUS_SUCCESS
);
59 ok_eq_hex(((USHORT
*)Buffer
)[242], 0xBABA);
60 ok_eq_hex(((USHORT
*)Buffer
)[243], 0xFFFF);
62 ByteOffset
.QuadPart
= 300000;
63 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 10, &ByteOffset
, NULL
);
64 ok_eq_hex(Status
, STATUS_SUCCESS
);
65 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
67 ByteOffset
.QuadPart
= 999990;
68 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 10, &ByteOffset
, NULL
);
69 ok_eq_hex(Status
, STATUS_SUCCESS
);
70 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xBABA);
72 ByteOffset
.QuadPart
= 1000;
73 Status
= NtReadFile(Handle
, NULL
, NULL
, NULL
, &IoStatusBlock
, Buffer
, 2, &ByteOffset
, NULL
);
74 ok_eq_hex(Status
, STATUS_SUCCESS
);
75 ok_eq_hex(((USHORT
*)Buffer
)[0], 0xFFFF);
76 ok_eq_hex(((USHORT
*)Buffer
)[1], 0xBABA);
80 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer
);