CopyMemory
Custom implementation of CopyMemory.
PVOID CopyMemoryEx(PVOID Destination, CONST PVOID Source, SIZE_T Length)
{
PBYTE D = (PBYTE)Destination;
PBYTE S = (PBYTE)Source;
while (Length--)
*D++ = *S++;
return Destination;
}
PVOID CopyMemoryEx2(PVOID Destination, CONST PVOID Source, SIZE_T Length)
{
PBYTE D = (PBYTE)Destination;
PBYTE S = (PBYTE)Source;
if (((ULONG_PTR)D & 7) == 0 && ((ULONG_PTR)S & 7) == 0)
{
while (Length >= sizeof(ULONG64))
{
*(PULONG64)D = *(PULONG64)S;
D += sizeof(ULONG64);
S += sizeof(ULONG64);
Length -= sizeof(ULONG64);
}
}
while (Length--)
*D++ = *S++;
return Destination;
}
PVOID CopyMemoryEx3(PVOID Destination, CONST PVOID Source, SIZE_T Length)
{
PBYTE D = (PBYTE)Destination;
PBYTE S = (PBYTE)Source;
SIZE_T Size = Length;
while (Size >= 4)
{
D[0] = S[0];
D[1] = S[1];
D[2] = S[2];
D[3] = S[3];
D += 4; S += 4;
Size -= 4;
}
while (Size--)
*D++ = *S++;
return Destination;
}Last updated