ZeroMemory
VOID ImplZeroMemory1(PVOID Destination, SIZE_T Size)
{
PBYTE Dest = (PBYTE)Destination;
while (Size--)
{
*Dest++ = 0;
}
}
VOID ImplZeroMemory2(PVOID Destination, SIZE_T Size)
{
PCHAR Pointer = (PCHAR)Destination;
PCHAR End = Pointer + Size;
for (;;)
{
if (Pointer >= End) break; *Pointer++ = 0;
if (Pointer >= End) break; *Pointer++ = 0;
if (Pointer >= End) break; *Pointer++ = 0;
if (Pointer >= End) break; *Pointer++ = 0;
}
}
VOID ImplZeroMemory3(PVOID Destination, SIZE_T Size)
{
PBYTE Dest = (PBYTE)Destination;
while (Size >= sizeof(ULONG64))
{
*(PULONG64)Dest = 0;
Dest += sizeof(ULONG64);
Size -= sizeof(ULONG64);
}
while (Size--)
*Dest++ = 0;
}
VOID ImplZeroMemory4(PVOID Destination, SIZE_T Size)
{
PBYTE Dest = (PBYTE)Destination;
for (SIZE_T i = 0; i < Size; i++)
Dest[i] = 0;
}
VOID ImplZeroMemory5(PVOID Destination, SIZE_T Size)
{
PBYTE p = (PBYTE)Destination;
PBYTE end = p + Size;
while (p < end)
*p++ = 0;
}
VOID ImplZeroMemory6(PVOID Destination, SIZE_T Size)
{
PBYTE Dest = (PBYTE)Destination;
while (Size >= 8)
{
Dest[0] = 0;
Dest[1] = 0;
Dest[2] = 0;
Dest[3] = 0;
Dest[4] = 0;
Dest[5] = 0;
Dest[6] = 0;
Dest[7] = 0;
Dest += 8;
Size -= 8;
}
while (Size--)
*Dest++ = 0;
}
VOID ImplZeroMemory7(PVOID Destination, SIZE_T Size)
{
PBYTE Dest = (PBYTE)Destination;
while (Size && ((ULONG_PTR)Dest & 7))
{
*Dest++ = 0;
Size--;
}
while (Size >= sizeof(ULONG64))
{
*(PULONG64)Dest = 0;
Dest += sizeof(ULONG64);
Size -= sizeof(ULONG64);
}
while (Size--)
*Dest++ = 0;
}Last updated