[NTUSER] Fix unaligned access in co_IntSetWindowLongPtr

This commit is contained in:
Timo Kreuzer 2024-09-11 15:59:28 +03:00
parent 201f00ab6f
commit dbb72f4923

View file

@ -9,6 +9,8 @@
#include <win32k.h>
#include <immdev.h>
#include <unaligned.h>
DBG_DEFAULT_CHANNEL(UserWnd);
INT gNestedWindowLimit = 50;
@ -3842,16 +3844,18 @@ co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULO
return 0;
}
PVOID Address = (PUCHAR)(&Window[1]) + Index;
#ifdef _WIN64
if (Size == sizeof(LONG))
{
OldValue = *((LONG *)((PCHAR)(Window + 1) + Index));
*((LONG*)((PCHAR)(Window + 1) + Index)) = (LONG)NewValue;
OldValue = ReadUnalignedU32(Address);
WriteUnalignedU32(Address, NewValue);
}
else
#endif
{
OldValue = *((LONG_PTR *)((PCHAR)(Window + 1) + Index));
OldValue = ReadUnalignedUlongPtr(Address);
/*
if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
{
@ -3859,7 +3863,7 @@ co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULO
if (!OldValue) return 0;
}
*/
*((LONG_PTR*)((PCHAR)(Window + 1) + Index)) = NewValue;
WriteUnalignedUlongPtr(Address, NewValue);
}
}