From de1fd1f76d3d79638fd1dd7c0c005baa1479b6c9 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 3 Jan 2009 04:02:54 +0000 Subject: [PATCH] - Removed SEH abuse and add notes for the hook code, in NtUserDefSetText. - Update NtUserCallHwndLock subfunctions. svn path=/trunk/; revision=38518 --- .../win32/win32k/ntuser/simplecall.c | 40 +++++++-- .../subsystems/win32/win32k/ntuser/window.c | 83 +++++++++---------- 2 files changed, 73 insertions(+), 50 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index 19945949526..68409976f7f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -713,7 +713,7 @@ NtUserCallHwndLock( DPRINT("Enter NtUserCallHwndLock\n"); UserEnterExclusive(); - if (!(Window = UserGetWindowObject(hWnd))) + if (!(Window = UserGetWindowObject(hWnd)) || !Window->Wnd) { RETURN( FALSE); } @@ -742,15 +742,45 @@ NtUserCallHwndLock( Menu->MenuInfo.WndOwner = hWnd; Menu->MenuInfo.Height = 0; - co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + co_WinPosSetWindowPos( Window, + HWND_DESKTOP, + 0,0,0,0, + SWP_NOSIZE| + SWP_NOMOVE| + SWP_NOZORDER| + SWP_NOACTIVATE| + SWP_FRAMECHANGED ); Ret = TRUE; break; } case HWNDLOCK_ROUTINE_REDRAWFRAME: - /* FIXME */ + co_WinPosSetWindowPos( Window, + HWND_DESKTOP, + 0,0,0,0, + SWP_NOSIZE| + SWP_NOMOVE| + SWP_NOZORDER| + SWP_NOACTIVATE| + SWP_FRAMECHANGED ); + Ret = TRUE; + break; + + case HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK: + co_WinPosSetWindowPos( Window, + HWND_DESKTOP, + 0,0,0,0, + SWP_NOSIZE| + SWP_NOMOVE| + SWP_NOZORDER| + SWP_NOACTIVATE| + SWP_FRAMECHANGED ); + if (!IntGetOwner(Window) && !IntGetParent(Window)) + { + co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) hWnd); + } + Ret = TRUE; break; case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW: @@ -758,7 +788,7 @@ NtUserCallHwndLock( break; case HWNDLOCK_ROUTINE_UPDATEWINDOW: - /* FIXME */ + Ret = co_UserRedrawWindow( Window, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); break; } diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 328775bee8a..b90147e49e7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -4569,57 +4569,47 @@ NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText) } Wnd = Window->Wnd; - if(SafeText.Length != 0) + if (SafeText.Length != 0) { - _SEH2_TRY + if (Wnd->WindowName.MaximumLength > 0 && + SafeText.Length <= Wnd->WindowName.MaximumLength - sizeof(UNICODE_NULL)) { - if (Wnd->WindowName.MaximumLength > 0 && - SafeText.Length <= Wnd->WindowName.MaximumLength - sizeof(UNICODE_NULL)) - { - ASSERT(Wnd->WindowName.Buffer != NULL); + ASSERT(Wnd->WindowName.Buffer != NULL); - Wnd->WindowName.Length = SafeText.Length; - Wnd->WindowName.Buffer[SafeText.Length / sizeof(WCHAR)] = L'\0'; - RtlCopyMemory(Wnd->WindowName.Buffer, - SafeText.Buffer, - SafeText.Length); - } - else - { - PWCHAR buf; - Wnd->WindowName.MaximumLength = Wnd->WindowName.Length = 0; - buf = Wnd->WindowName.Buffer; - Wnd->WindowName.Buffer = NULL; - if (buf != NULL) - { - DesktopHeapFree(Wnd->pdesktop, - buf); - } - - Wnd->WindowName.Buffer = DesktopHeapAlloc(Wnd->pdesktop, - SafeText.Length + sizeof(UNICODE_NULL)); - if (Wnd->WindowName.Buffer != NULL) - { - Wnd->WindowName.Buffer[SafeText.Length / sizeof(WCHAR)] = L'\0'; - RtlCopyMemory(Wnd->WindowName.Buffer, - SafeText.Buffer, - SafeText.Length); - Wnd->WindowName.MaximumLength = SafeText.Length + sizeof(UNICODE_NULL); - Wnd->WindowName.Length = SafeText.Length; - } - else - { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - Ret = FALSE; - } - } + Wnd->WindowName.Length = SafeText.Length; + Wnd->WindowName.Buffer[SafeText.Length / sizeof(WCHAR)] = L'\0'; + RtlCopyMemory(Wnd->WindowName.Buffer, + SafeText.Buffer, + SafeText.Length); } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + else { - SetLastNtError(_SEH2_GetExceptionCode()); - Ret = FALSE; + PWCHAR buf; + Wnd->WindowName.MaximumLength = Wnd->WindowName.Length = 0; + buf = Wnd->WindowName.Buffer; + Wnd->WindowName.Buffer = NULL; + if (buf != NULL) + { + DesktopHeapFree(Wnd->pdesktop, buf); + } + + Wnd->WindowName.Buffer = DesktopHeapAlloc(Wnd->pdesktop, + SafeText.Length + sizeof(UNICODE_NULL)); + if (Wnd->WindowName.Buffer != NULL) + { + Wnd->WindowName.Buffer[SafeText.Length / sizeof(WCHAR)] = L'\0'; + RtlCopyMemory(Wnd->WindowName.Buffer, + SafeText.Buffer, + SafeText.Length); + Wnd->WindowName.MaximumLength = SafeText.Length + sizeof(UNICODE_NULL); + Wnd->WindowName.Length = SafeText.Length; + } + else + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + Ret = FALSE; + } } - _SEH2_END; } else { @@ -4628,6 +4618,9 @@ NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText) Wnd->WindowName.Buffer[0] = L'\0'; } + // HAX! FIXME! Windows does not do this in here! + // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than + // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc. /* Send shell notifications */ if (!IntGetOwner(Window) && !IntGetParent(Window)) {