Author: tfaber Date: Sun Jun 21 19:15:01 2015 New Revision: 68234
URL: http://svn.reactos.org/svn/reactos?rev=68234&view=rev Log: [RTL][NDK][NTDLL_APITEST] - Properly implement/declare/test RtlCopyMappedMemory... it's not that hard CORE-9857
Added: trunk/rostests/apitests/ntdll/RtlCopyMappedMemory.c (with props) Modified: trunk/reactos/include/ndk/rtlfuncs.h trunk/reactos/lib/rtl/memstream.c trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/testlist.c
Modified: trunk/reactos/include/ndk/rtlfuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev=... ============================================================================== --- trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] Sun Jun 21 19:15:01 2015 @@ -2046,6 +2046,14 @@ _In_ ULONGLONG Pattern );
+NTSYSAPI +NTSTATUS +NTAPI +RtlCopyMappedMemory( + _Out_writes_bytes_all_(Size) PVOID Destination, + _In_reads_bytes_(Size) const VOID *Source, + _In_ SIZE_T Size +);
NTSYSAPI SIZE_T
Modified: trunk/reactos/lib/rtl/memstream.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/memstream.c?rev=682... ============================================================================== --- trunk/reactos/lib/rtl/memstream.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/memstream.c [iso-8859-1] Sun Jun 21 19:15:01 2015 @@ -469,13 +469,24 @@ /* * @implemented */ -VOID +NTSTATUS NTAPI RtlCopyMappedMemory( - _Out_ PVOID Destination, - _In_ const VOID *Source, + _Out_writes_bytes_all_(Size) PVOID Destination, + _In_reads_bytes_(Size) const VOID *Source, _In_ SIZE_T Size) { - /* FIXME: This is supposed to handle STATUS_IN_PAGE_ERROR exceptions */ - RtlCopyMemory(Destination, Source, Size); -} + NTSTATUS Status = STATUS_SUCCESS; + _SEH2_TRY + { + RtlCopyMemory(Destination, Source, Size); + } + _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_IN_PAGE_ERROR + ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + return Status; +}
Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists.... ============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Sun Jun 21 19:15:01 2015 @@ -15,6 +15,7 @@ NtQueryVolumeInformationFile.c NtSaveKey.c RtlBitmap.c + RtlCopyMappedMemory.c RtlDetermineDosPathNameType.c RtlDoesFileExists.c RtlDosPathNameToNtPathName_U.c
Added: trunk/rostests/apitests/ntdll/RtlCopyMappedMemory.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlCopyMapp... ============================================================================== --- trunk/rostests/apitests/ntdll/RtlCopyMappedMemory.c (added) +++ trunk/rostests/apitests/ntdll/RtlCopyMappedMemory.c [iso-8859-1] Sun Jun 21 19:15:01 2015 @@ -0,0 +1,35 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for RtlCopyMappedMemory + * PROGRAMMERS: Thomas Faber thomas.faber@reactos.org + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <ndk/rtlfuncs.h> + +START_TEST(RtlCopyMappedMemory) +{ + NTSTATUS Status; + UCHAR Buffer1[32]; + UCHAR Buffer2[32]; + + StartSeh() RtlCopyMappedMemory(NULL, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION); + StartSeh() RtlCopyMappedMemory(Buffer1, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION); + StartSeh() RtlCopyMappedMemory(NULL, Buffer1, 1); EndSeh(STATUS_ACCESS_VIOLATION); + + StartSeh() + Status = RtlCopyMappedMemory(NULL, NULL, 0); + EndSeh(STATUS_SUCCESS); + ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status); + + RtlFillMemory(Buffer1, sizeof(Buffer1), 0x11); + RtlFillMemory(Buffer2, sizeof(Buffer2), 0x22); + StartSeh() + Status = RtlCopyMappedMemory(Buffer1, Buffer2, sizeof(Buffer1)); + EndSeh(STATUS_SUCCESS); + ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status); + ok(RtlCompareMemory(Buffer1, Buffer2, sizeof(Buffer1)) == sizeof(Buffer1), "Data not copied\n"); +}
Propchange: trunk/rostests/apitests/ntdll/RtlCopyMappedMemory.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/rostests/apitests/ntdll/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c?... ============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Sun Jun 21 19:15:01 2015 @@ -19,6 +19,7 @@ extern void func_NtSaveKey(void); extern void func_NtSystemInformation(void); extern void func_RtlBitmap(void); +extern void func_RtlCopyMappedMemory(void); extern void func_RtlDetermineDosPathNameType(void); extern void func_RtlDoesFileExists(void); extern void func_RtlDosPathNameToNtPathName_U(void); @@ -53,6 +54,7 @@ { "NtSaveKey", func_NtSaveKey}, { "NtSystemInformation", func_NtSystemInformation }, { "RtlBitmapApi", func_RtlBitmap }, + { "RtlCopyMappedMemory", func_RtlCopyMappedMemory }, { "RtlDetermineDosPathNameType", func_RtlDetermineDosPathNameType }, { "RtlDoesFileExists", func_RtlDoesFileExists }, { "RtlDosPathNameToNtPathName_U", func_RtlDosPathNameToNtPathName_U },