From d34a8d86bcd110e982aa9912f9f8e80b54dc3206 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Thu, 29 Apr 2010 13:41:32 +0000 Subject: [PATCH] [win32k] - Fix a problem where application that used WH_CBT hook procedures were receiving destroy window notification on windows that were never created. The window was never created because the application had returned a non zero value when it was notified of window creation, which effectively destroys the window and returns failure for window creation. See CBTProc Function on MSDN. Fixes bug #4461. svn path=/trunk/; revision=47059 --- reactos/subsystems/win32/win32k/ntuser/window.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index f95965027bd..aa1cbc0188e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -2468,7 +2468,23 @@ AllocErr: CLEANUP: if (!_ret_ && Window && Window->Wnd && ti) + { + ULONG SavedHooks; + /* HACK: co_UserDestroyWindow will call CBT proc with code HCBT_DESTROYWND. + Applications can choke on this as a hwnd was never returned from this call */ + /* Save the flags */ + SavedHooks = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->fsHooks; + + /* Temporary remove the flag */ + ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->fsHooks &= ~HOOKID_TO_FLAG(WH_CBT); + + /* Destroy the window */ co_UserDestroyWindow(Window); + + /* Restore the flag */ + ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->fsHooks = SavedHooks; + } + // UserFreeWindowInfo(ti, Window); if (Window) {