https://git.reactos.org/?p=reactos.git;a=commitdiff;h=05cd3406e7ae5040497fc…
commit 05cd3406e7ae5040497fc517baa81663802ebc2f
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Fri May 12 15:55:47 2023 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Thu May 25 18:56:02 2023 +0300
[USER32] Fix SetWindowWord/Long
These must use the corresponding NtUserSetWindowWord/Long function and cannot use
NtUserSetWindowLongPtr, otherwise the function can fail, when there is only space for a
LONG, but not for a LONG_PTR at the specified offset.
---
win32ss/user/ntuser/window.c | 2 +-
win32ss/user/user32/windows/class.c | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index 7bc57864b78..b4ab2d6e69f 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -4148,7 +4148,7 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue)
if ((ULONG)Index > (Window->cbwndExtra - sizeof(WORD)))
{
- EngSetLastError(ERROR_INVALID_PARAMETER);
+ EngSetLastError(ERROR_INVALID_INDEX);
RETURN( 0);
}
diff --git a/win32ss/user/user32/windows/class.c b/win32ss/user/user32/windows/class.c
index 6abaf350bc1..63c84a46e60 100644
--- a/win32ss/user/user32/windows/class.c
+++ b/win32ss/user/user32/windows/class.c
@@ -1666,7 +1666,8 @@ SetWindowWord ( HWND hWnd,int nIndex,WORD wNewWord )
}
break;
}
- return (WORD)NtUserSetWindowLongPtr(hWnd, nIndex, wNewWord, FALSE);
+ /* DO NOT USE NtUserSetWindowLong(Ptr)! */
+ return NtUserSetWindowWord(hWnd, nIndex, wNewWord);
}
/*
@@ -1680,7 +1681,8 @@ SetWindowLongA(
int nIndex,
LONG dwNewLong)
{
- return (LONG)NtUserSetWindowLongPtr(hWnd, nIndex, dwNewLong, TRUE);
+ /* DO NOT USE NtUserSetWindowLongPtr! */
+ return NtUserSetWindowLong(hWnd, nIndex, dwNewLong, TRUE);
}
/*
@@ -1693,7 +1695,8 @@ SetWindowLongW(
int nIndex,
LONG dwNewLong)
{
- return (LONG)NtUserSetWindowLongPtr(hWnd, nIndex, dwNewLong, FALSE);
+ /* DO NOT USE NtUserSetWindowLongPtr! */
+ return NtUserSetWindowLong(hWnd, nIndex, dwNewLong, FALSE);
}
#ifdef _WIN64