1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE:         Test for RtlCopyMappedMemory
5  * PROGRAMMERS:     Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 static NTSTATUS (NTAPI *pRtlCopyMappedMemory)(PVOID, const VOID *, SIZE_T);
11 
12 START_TEST(RtlCopyMappedMemory)
13 {
14     NTSTATUS Status;
15     UCHAR Buffer1[32];
16     UCHAR Buffer2[32];
17 
18     pRtlCopyMappedMemory = (PVOID)GetProcAddress(GetModuleHandleW(L"ntdll.dll"),
19                                                  "RtlCopyMappedMemory");
20     if (!pRtlCopyMappedMemory)
21     {
22         win_skip("RtlCopyMappedMemory (NT >= 5.2 API) not available\n");
23         return;
24     }
25 
26     StartSeh() pRtlCopyMappedMemory(NULL, NULL, 1);     EndSeh(STATUS_ACCESS_VIOLATION);
27     StartSeh() pRtlCopyMappedMemory(Buffer1, NULL, 1);  EndSeh(STATUS_ACCESS_VIOLATION);
28     StartSeh() pRtlCopyMappedMemory(NULL, Buffer1, 1);  EndSeh(STATUS_ACCESS_VIOLATION);
29 
30     StartSeh()
31         Status = pRtlCopyMappedMemory(NULL, NULL, 0);
32     EndSeh(STATUS_SUCCESS);
33     ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
34 
35     RtlFillMemory(Buffer1, sizeof(Buffer1), 0x11);
36     RtlFillMemory(Buffer2, sizeof(Buffer2), 0x22);
37     StartSeh()
38         Status = pRtlCopyMappedMemory(Buffer1, Buffer2, sizeof(Buffer1));
39     EndSeh(STATUS_SUCCESS);
40     ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
41     ok(RtlCompareMemory(Buffer1, Buffer2, sizeof(Buffer1)) == sizeof(Buffer1), "Data not copied\n");
42 }
43