https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a0bbb9ef99a812c67ccd9a2f16016c01b2867444
commit a0bbb9ef99a812c67ccd9a2f16016c01b2867444 Author: Timo Kreuzer <timo.kreu...@reactos.org> AuthorDate: Wed Sep 11 10:57:42 2024 +0300 Commit: Timo Kreuzer <timo.kreu...@reactos.org> CommitDate: Sun Sep 15 12:09:09 2024 +0300 [XDK] Improve unaligned pointer read macros - The #if was missing x86 (Windows SDK bug!) - The unaligned attribute was on the wrong side (Windows SDK bug!) - Add a comment that these are unsafe and shouldn't be used --- sdk/include/xdk/rtlfuncs.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sdk/include/xdk/rtlfuncs.h b/sdk/include/xdk/rtlfuncs.h index 88fd0f76baa..8f5ed2854ba 100644 --- a/sdk/include/xdk/rtlfuncs.h +++ b/sdk/include/xdk/rtlfuncs.h @@ -829,7 +829,13 @@ RtlSetDaclSecurityDescriptor( _In_opt_ PACL Dacl, _In_opt_ BOOLEAN DaclDefaulted); -#if defined(_AMD64_) +// +// These functions are really bad and shouldn't be used. +// They have no type checking and can easily overwrite the target +// variable or only set half of it. +// Use Read/WriteUnalignedU16/U32/U64 from reactos/unaligned.h instead. +// +#if defined(_AMD64_) || defined(_M_AMD64) || defined(_X86) || defined(_M_IX86) /* VOID * RtlStoreUlong( @@ -861,7 +867,7 @@ RtlSetDaclSecurityDescriptor( * PUSHORT SourceAddress); */ #define RtlRetrieveUshort(DestAddress,SrcAddress) \ - *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) + *(USHORT*)(DestAddress) = *(USHORT UNALIGNED *)(SrcAddress) /* VOID * RtlRetrieveUlong( @@ -869,7 +875,7 @@ RtlSetDaclSecurityDescriptor( * PULONG SourceAddress); */ #define RtlRetrieveUlong(DestAddress,SrcAddress) \ - *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) + *(ULONG*)(DestAddress) = *(ULONG UNALIGNED *)(SrcAddress) #else @@ -927,7 +933,7 @@ RtlSetDaclSecurityDescriptor( *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ } -#endif /* defined(_AMD64_) */ +#endif /* defined(_AMD64_) || defined(_M_AMD64) || defined(_X86) || defined(_M_IX86) */ #ifdef _WIN64 /* VOID