From 141cf04239f3049c1c180fb2c6c3aa84b13c8590 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Tue, 19 Nov 2019 17:54:23 +0900 Subject: [PATCH] [NTUSER] Fix condition of HSHELL_WINDOWCREATED (#2046) CORE-15655 If the owner window doesn't exist or is invisible or has WS_EX_TOOLWINDOW style, HSHELL_WINDOWCREATED regards the window a non-owned window. You can watch the shell hook information by using CORE-15655 ShellHookChecker.zip. --- win32ss/user/ntuser/window.c | 16 ++++++++++------ win32ss/user/ntuser/winpos.c | 16 +++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c index c34dcea55f0..ee65215959d 100644 --- a/win32ss/user/ntuser/window.c +++ b/win32ss/user/ntuser/window.c @@ -2351,13 +2351,17 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, IntSendParentNotify(Window, WM_CREATE); /* Notify the shell that a new window was created */ - if (UserIsDesktopWindow(Window->spwndParent) && - Window->spwndOwner == NULL && - (Window->style & WS_VISIBLE) && - (!(Window->ExStyle & WS_EX_TOOLWINDOW) || - (Window->ExStyle & WS_EX_APPWINDOW))) + if (Window->spwndOwner == NULL || + !(Window->spwndOwner->style & WS_VISIBLE) || + (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW)) { - co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)hWnd, 0); + if (UserIsDesktopWindow(Window->spwndParent) && + (Window->style & WS_VISIBLE) && + (!(Window->ExStyle & WS_EX_TOOLWINDOW) || + (Window->ExStyle & WS_EX_APPWINDOW))) + { + co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)hWnd, 0); + } } /* Initialize and show the window's scrollbars */ diff --git a/win32ss/user/ntuser/winpos.c b/win32ss/user/ntuser/winpos.c index 10ec112e346..6467c2cad86 100644 --- a/win32ss/user/ntuser/winpos.c +++ b/win32ss/user/ntuser/winpos.c @@ -1904,11 +1904,17 @@ co_WinPosSetWindowPos( } else if (WinPos.flags & SWP_SHOWWINDOW) { - if (UserIsDesktopWindow(Window->spwndParent) && - Window->spwndOwner == NULL && - (!(Window->ExStyle & WS_EX_TOOLWINDOW) || - (Window->ExStyle & WS_EX_APPWINDOW))) - co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0); + if (Window->spwndOwner == NULL || + !(Window->spwndOwner->style & WS_VISIBLE) || + (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW)) + { + if (UserIsDesktopWindow(Window->spwndParent) && + (!(Window->ExStyle & WS_EX_TOOLWINDOW) || + (Window->ExStyle & WS_EX_APPWINDOW))) + { + co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0); + } + } Window->style |= WS_VISIBLE; //IntSetStyle( Window, WS_VISIBLE, 0 ); Window->head.pti->cVisWindows++;