From 3b78fdde216213cb34ee183556b6722f3309cb27 Mon Sep 17 00:00:00 2001 From: Joachim Henze Date: Sat, 10 Jun 2023 12:40:38 +0200 Subject: [PATCH] [0.4.9][NTUSER] co_UserDestroyWindow: Validate window before destroying it (#5054) Prevent the window from being destroyed twice fixes CORE-18821 'WIN32K BSOD 0x1E when opening Build menu in AVR Studio 4.19' port of 0.4.15-dev-5938-g 77d46531648c244b6eec2cdb75a710d4e8ffd8cb And port back also some unrelated formatting improvements, and kill a block of code that was commented out in all branches, and was not x64 compatible in 0.4.7/0.4.8, and therefore was a diff already anyway. --- win32ss/user/ntuser/window.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c index 12790a5820f..4b08259fd26 100644 --- a/win32ss/user/ntuser/window.c +++ b/win32ss/user/ntuser/window.c @@ -739,7 +739,7 @@ IntGetWindowProc(PWND pWnd, PCLS Class; WNDPROC gcpd, Ret = 0; - ASSERT(UserIsEnteredExclusive() == TRUE); + ASSERT(UserIsEnteredExclusive()); Class = pWnd->pcls; @@ -1695,7 +1695,7 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, pWnd->spwndOwner = OwnerWindow; pWnd->fnid = 0; pWnd->spwndLastActive = pWnd; - pWnd->state2 |= WNDS2_WIN40COMPAT; // FIXME!!! + pWnd->state2 |= WNDS2_WIN40COMPAT; pWnd->pcls = Class; pWnd->hModule = Cs->hInstance; pWnd->style = Cs->style & ~WS_VISIBLE; @@ -2563,6 +2563,9 @@ BOOLEAN co_UserDestroyWindow(PVOID Object) ASSERT_REFS_CO(Window); // FIXME: Temp HACK? + if (!IntIsWindow(UserHMGetHandle(Window))) + return TRUE; + hWnd = Window->head.h; ti = PsGetCurrentThreadWin32Thread(); @@ -3574,13 +3577,6 @@ co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULO #endif { OldValue = *((LONG_PTR *)((PCHAR)(Window + 1) + Index)); - /* - if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW) - { - OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi); - if (!OldValue) return 0; - } - */ *((LONG_PTR*)((PCHAR)(Window + 1) + Index)) = NewValue; }