mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
fixed overlaping memory problem with RtlMoveMemory. The rewrite of RtlMoveMemory did not handling overlaping memory. it shows with ntdll_winetest rtl, use the old asm version from the string.a instead
svn path=/trunk/; revision=24273
This commit is contained in:
parent
b3f30cb100
commit
7a0843f8af
3 changed files with 24 additions and 67 deletions
23
reactos/lib/rtl/RtlMoveMemory.c
Normal file
23
reactos/lib/rtl/RtlMoveMemory.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#undef RtlMoveMemory
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
RtlMoveMemory (
|
||||
PVOID Destination,
|
||||
CONST VOID * Source,
|
||||
ULONG Length
|
||||
)
|
||||
{
|
||||
memmove (
|
||||
Destination,
|
||||
Source,
|
||||
Length
|
||||
);
|
||||
}
|
|
@ -214,73 +214,6 @@ ByteZero:
|
|||
ret 8
|
||||
.endfunc
|
||||
|
||||
.func RtlMoveMemory@12
|
||||
_RtlMoveMemory@12:
|
||||
|
||||
/* Save volatiles */
|
||||
push esi
|
||||
push edi
|
||||
|
||||
/* Get pointers and size */
|
||||
mov esi, [esp+16]
|
||||
mov edi, [esp+12]
|
||||
mov ecx, [esp+20]
|
||||
cld
|
||||
|
||||
/* Check if the destination is higher (or equal) */
|
||||
cmp esi, edi
|
||||
jbe Overlap
|
||||
|
||||
/* Set ULONG size and UCHAR remainder */
|
||||
DoMove:
|
||||
mov edx, ecx
|
||||
and edx, 3
|
||||
shr ecx, 2
|
||||
|
||||
/* Do the move */
|
||||
rep movsd
|
||||
or ecx, edx
|
||||
jnz ByteMove
|
||||
|
||||
/* Return */
|
||||
pop edi
|
||||
pop esi
|
||||
ret 12
|
||||
|
||||
ByteMove:
|
||||
/* Move what's left */
|
||||
rep stosb
|
||||
|
||||
DoneMove:
|
||||
/* Restore volatiles */
|
||||
pop edi
|
||||
pop esi
|
||||
ret 12
|
||||
|
||||
Overlap:
|
||||
/* Don't copy if they're equal */
|
||||
jz DoneMove
|
||||
|
||||
/* Compare pointer distance with given length and check for overlap */
|
||||
mov eax, edi
|
||||
sub eax, esi
|
||||
cmp ecx, eax
|
||||
jbe DoMove
|
||||
|
||||
/* Set direction flag for backward move */
|
||||
std
|
||||
|
||||
/* Copy byte-by-byte the non-overlapping distance */
|
||||
add esi, ecx
|
||||
add edi, ecx
|
||||
dec esi
|
||||
dec edi
|
||||
|
||||
/* Do the move, reset flag and return */
|
||||
rep movsb
|
||||
cld
|
||||
jmp DoneMove
|
||||
.endfunc
|
||||
|
||||
.func @RtlPrefetchMemoryNonTemporal@8, @RtlPrefetchMemoryNonTemporal@8
|
||||
@RtlPrefetchMemoryNonTemporal@8:
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<file>sqrt_asm.s</file>
|
||||
<file>tan_asm.s</file>
|
||||
</directory>
|
||||
<file>RtlMoveMemory.c</file>
|
||||
</if>
|
||||
|
||||
<ifnot property="ARCH" value="i386">
|
||||
|
|
Loading…
Reference in a new issue