[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
This commit is contained in:
Timo Kreuzer 2024-09-11 10:57:42 +03:00
parent 2af6fd4def
commit a0bbb9ef99

View file

@ -829,7 +829,13 @@ RtlSetDaclSecurityDescriptor(
_In_opt_ PACL Dacl, _In_opt_ PACL Dacl,
_In_opt_ BOOLEAN DaclDefaulted); _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 /* VOID
* RtlStoreUlong( * RtlStoreUlong(
@ -861,7 +867,7 @@ RtlSetDaclSecurityDescriptor(
* PUSHORT SourceAddress); * PUSHORT SourceAddress);
*/ */
#define RtlRetrieveUshort(DestAddress,SrcAddress) \ #define RtlRetrieveUshort(DestAddress,SrcAddress) \
*(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) *(USHORT*)(DestAddress) = *(USHORT UNALIGNED *)(SrcAddress)
/* VOID /* VOID
* RtlRetrieveUlong( * RtlRetrieveUlong(
@ -869,7 +875,7 @@ RtlSetDaclSecurityDescriptor(
* PULONG SourceAddress); * PULONG SourceAddress);
*/ */
#define RtlRetrieveUlong(DestAddress,SrcAddress) \ #define RtlRetrieveUlong(DestAddress,SrcAddress) \
*(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) *(ULONG*)(DestAddress) = *(ULONG UNALIGNED *)(SrcAddress)
#else #else
@ -927,7 +933,7 @@ RtlSetDaclSecurityDescriptor(
*((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
} }
#endif /* defined(_AMD64_) */ #endif /* defined(_AMD64_) || defined(_M_AMD64) || defined(_X86) || defined(_M_IX86) */
#ifdef _WIN64 #ifdef _WIN64
/* VOID /* VOID