diff --git a/sdk/include/ndk/rtlfuncs.h b/sdk/include/ndk/rtlfuncs.h index 4809b4a0d65..5b6f878b140 100644 --- a/sdk/include/ndk/rtlfuncs.h +++ b/sdk/include/ndk/rtlfuncs.h @@ -2119,13 +2119,42 @@ RtlFindCharInUnicodeString( // // Memory Functions // +#if defined(_M_AMD64) + +FORCEINLINE +VOID +RtlFillMemoryUlong( + _Out_writes_bytes_all_(Length) PVOID Destination, + _In_ SIZE_T Length, + _In_ ULONG Pattern) +{ + PULONG Address = (PULONG)Destination; + if ((Length /= 4) != 0) { + if (((ULONG64)Address & 4) != 0) { + *Address = Pattern; + if ((Length -= 1) == 0) { + return; + } + Address += 1; + } + __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2); + if ((Length & 1) != 0) Address[Length - 1] = Pattern; + } + return; +} + +#define RtlFillMemoryUlonglong(Destination, Length, Pattern) \ + __stosq((PULONG64)(Destination), Pattern, (Length) / 8) + +#else + NTSYSAPI VOID NTAPI RtlFillMemoryUlong( - _In_ PVOID Destination, + _Out_writes_bytes_all_(Length) PVOID Destination, _In_ SIZE_T Length, - _In_ ULONG Fill + _In_ ULONG Pattern ); NTSYSAPI @@ -2137,6 +2166,8 @@ RtlFillMemoryUlonglong( _In_ ULONGLONG Pattern ); +#endif + NTSYSAPI NTSTATUS NTAPI diff --git a/sdk/include/xdk/rtlfuncs.h b/sdk/include/xdk/rtlfuncs.h index ac5214336ec..cba07f72aa5 100644 --- a/sdk/include/xdk/rtlfuncs.h +++ b/sdk/include/xdk/rtlfuncs.h @@ -2376,9 +2376,9 @@ NTSYSAPI VOID NTAPI RtlFillMemoryUlong( - OUT PVOID Destination, - IN SIZE_T Length, - IN ULONG Pattern); + _Out_writes_bytes_all_(Length) PVOID Destination, + _In_ SIZE_T Length, + _In_ ULONG Pattern); NTSYSAPI VOID diff --git a/sdk/lib/rtl/mem.c b/sdk/lib/rtl/mem.c index 6927f543f3e..352d1356908 100644 --- a/sdk/lib/rtl/mem.c +++ b/sdk/lib/rtl/mem.c @@ -92,7 +92,7 @@ RtlFillMemory(PVOID Destination, } - +#ifndef _M_AMD64 /* * @implemented */ @@ -131,7 +131,8 @@ RtlFillMemoryUlonglong( Count--; } } -#endif +#endif // _WIN64 +#endif // _M_AMD64 #undef RtlMoveMemory /*