ReactOS  0.4.15-dev-1632-g4e289ce
CcCopyRead_user.c
Go to the documentation of this file.
1 /*
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>
6  */
7 
8 #include <kmt_test.h>
9 
11 {
12  HANDLE Handle;
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");
21  UNICODE_STRING FileBig = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\FileBig");
22  UNICODE_STRING BehaviourTestFile = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\BehaviourTestFile");
23 
24  KmtLoadDriver(L"CcCopyRead", FALSE);
25  KmtOpenDriver();
26 
30 
31  ByteOffset.QuadPart = 3;
34  ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
35 
36  ByteOffset.QuadPart = 514;
39  ok_eq_hex(((USHORT *)Buffer)[242], 0xBABA);
40  ok_eq_hex(((USHORT *)Buffer)[243], 0xFFFF);
41 
42  ByteOffset.QuadPart = 1000;
45  ok_eq_hex(((USHORT *)Buffer)[0], 0xFFFF);
46  ok_eq_hex(((USHORT *)Buffer)[1], 0xBABA);
47 
48  NtClose(Handle);
49 
53 
54  ByteOffset.QuadPart = 3;
57  ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
58 
59  ByteOffset.QuadPart = 514;
62  ok_eq_hex(((USHORT *)Buffer)[242], 0xBABA);
63  ok_eq_hex(((USHORT *)Buffer)[243], 0xFFFF);
64 
65  ByteOffset.QuadPart = 300000;
68  ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
69 
70  ByteOffset.QuadPart = 999990;
73  ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
74 
75  ByteOffset.QuadPart = 1000;
78  ok_eq_hex(((USHORT *)Buffer)[0], 0xFFFF);
79  ok_eq_hex(((USHORT *)Buffer)[1], 0xBABA);
80 
81  NtClose(Handle);
82 
86 
87  ByteOffset.QuadPart = 1;
90  ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
91 
92  NtClose(Handle);
93 
97 
98  ByteOffset.QuadPart = 0;
101  ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
102 
103  NtClose(Handle);
104 
108 
109  ByteOffset.QuadPart = 0;
111 
112  NtClose(Handle);
113 
114  RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
115  KmtCloseDriver();
116  KmtUnloadDriver();
117 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
VOID KmtCloseDriver(VOID)
Definition: support.c:207
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
START_TEST(CcCopyRead)
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43
static const WCHAR L[]
Definition: oid.c:1250
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
VOID KmtUnloadDriver(VOID)
Definition: support.c:156
unsigned short USHORT
Definition: pedump.c:61
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_In_ HANDLE Handle
Definition: extypes.h:390
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ok_eq_hex(value, expected)
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:128
VOID KmtOpenDriver(VOID)
Definition: support.c:181
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:725
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14