ReactOS  0.4.15-dev-3173-g40ee59d
RtlCopyMappedMemory.c
Go to the documentation of this file.
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 
13 {
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);
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));
40  ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
41  ok(RtlCompareMemory(Buffer1, Buffer2, sizeof(Buffer1)) == sizeof(Buffer1), "Data not copied\n");
42 }
LONG NTSTATUS
Definition: precomp.h:26
#define StartSeh()
Definition: _sntprintf.h:16
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
START_TEST(RtlCopyMappedMemory)
void * PVOID
Definition: retypes.h:9
Status
Definition: gdiplustypes.h:24
static NTSTATUS(NTAPI *pRtlCopyMappedMemory)(PVOID
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI RtlCopyMappedMemory(_Out_writes_bytes_all_(Size) PVOID Destination, _In_reads_bytes_(Size) const VOID *Source, _In_ SIZE_T Size)
Definition: memstream.c:479
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define ok(value,...)
Definition: atltest.h:57
static const VOID SIZE_T
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define GetProcAddress(x, y)
Definition: compat.h:612
#define STATUS_SUCCESS
Definition: shellext.h:65
#define win_skip
Definition: test.h:151
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17