From 55d09ef598e4538c60c09c23190a5ddcc142b799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Thu, 5 Feb 2004 20:09:10 +0000 Subject: [PATCH] Don't callback from kernel to usermode if the thread is exiting svn path=/trunk/; revision=8042 --- reactos/include/napi/win32.h | 5 +++-- reactos/subsys/win32k/main/dllmain.c | 4 +++- reactos/subsys/win32k/ntuser/message.c | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/reactos/include/napi/win32.h b/reactos/include/napi/win32.h index 55b05664813..1e7568f2f35 100644 --- a/reactos/include/napi/win32.h +++ b/reactos/include/napi/win32.h @@ -11,6 +11,7 @@ typedef struct _W32THREAD struct _KBDTABLES* KeyboardLayout; struct _DESKTOP_OBJECT* Desktop; DWORD MessagePumpHookValue; + BOOLEAN IsExiting; } W32THREAD, *PW32THREAD; #include @@ -30,8 +31,8 @@ typedef struct _W32PROCESS struct _WINSTATION_OBJECT* WindowStation; WORD GDIObjects; WORD UserObjects; - BOOL CreatedWindowOrDC; - BOOL ManualGuiCheck; + BOOLEAN CreatedWindowOrDC; + BOOLEAN ManualGuiCheck; } W32PROCESS, *PW32PROCESS; PW32THREAD STDCALL diff --git a/reactos/subsys/win32k/main/dllmain.c b/reactos/subsys/win32k/main/dllmain.c index 3a0c4d6f605..95ab484902c 100644 --- a/reactos/subsys/win32k/main/dllmain.c +++ b/reactos/subsys/win32k/main/dllmain.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dllmain.c,v 1.65 2004/01/24 08:26:25 ekohl Exp $ +/* $Id: dllmain.c,v 1.66 2004/02/05 20:09:10 gvg Exp $ * * Entry Point for win32k.sys */ @@ -141,6 +141,7 @@ Win32kThreadCallback (struct _ETHREAD *Thread, DbgPrint (" Create thread\n"); #endif + Win32Thread->IsExiting = FALSE; IntDestroyCaret(Win32Thread); Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread); Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout(); @@ -170,6 +171,7 @@ Win32kThreadCallback (struct _ETHREAD *Thread, DbgPrint (" Destroy thread\n"); #endif + Win32Thread->IsExiting = TRUE; HOOK_DestroyThreadHooks(Thread); RemoveTimersThread(Thread->Cid.UniqueThread); UnregisterThreadHotKeys(Thread); diff --git a/reactos/subsys/win32k/ntuser/message.c b/reactos/subsys/win32k/ntuser/message.c index 9f177249768..c98afdfabac 100644 --- a/reactos/subsys/win32k/ntuser/message.c +++ b/reactos/subsys/win32k/ntuser/message.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: message.c,v 1.48 2004/01/28 20:54:30 gvg Exp $ +/* $Id: message.c,v 1.49 2004/02/05 20:09:10 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -716,6 +716,7 @@ IntSendMessage(HWND hWnd, PMSGMEMORY MsgMemoryEntry; INT lParamBufferSize; LPARAM lParamPacked; + PW32THREAD Win32Thread; /* FIXME: Check for a broadcast or topmost destination. */ @@ -727,11 +728,18 @@ IntSendMessage(HWND hWnd, return 0; } - /* FIXME: Check for an exiting window. */ + Win32Thread = PsGetWin32Thread(); - if (NULL != PsGetWin32Thread() && - Window->MessageQueue == PsGetWin32Thread()->MessageQueue) + if (NULL != Win32Thread && + Window->MessageQueue == Win32Thread->MessageQueue) { + if (Win32Thread->IsExiting) + { + /* Never send messages to exiting threads */ + IntReleaseWindowObject(Window); + return 0; + } + /* See if this message type is present in the table */ MsgMemoryEntry = FindMsgMemory(Msg); if (NULL == MsgMemoryEntry)