From 643a182dd0023b6dab3bfdf4ff36fc245a9073cd Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 17 Mar 2005 13:07:28 +0000 Subject: [PATCH] Now that CSRSS is getting unloaded we must unregister the primitive message queue when it's about to be destroyed. svn path=/trunk/; revision=14159 --- reactos/subsys/win32k/include/input.h | 1 + reactos/subsys/win32k/ntuser/misc.c | 14 ++++++++++++-- reactos/subsys/win32k/ntuser/msgqueue.c | 16 +++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/reactos/subsys/win32k/include/input.h b/reactos/subsys/win32k/include/input.h index 052dff854d0..00ec42f79ca 100644 --- a/reactos/subsys/win32k/include/input.h +++ b/reactos/subsys/win32k/include/input.h @@ -8,6 +8,7 @@ InitInputImpl(VOID); NTSTATUS FASTCALL InitKeyboardImpl(VOID); PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue(VOID); +VOID W32kUnregisterPrimitiveMessageQueue(VOID); PKBDTABLES W32kGetDefaultKeyLayout(VOID); VOID FASTCALL W32kKeyProcessMessage(LPMSG Msg, PKBDTABLES KeyLayout); BOOL FASTCALL IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt); diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index 7135b288fa4..27c68e43cca 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -17,13 +17,15 @@ /* registered Logon process */ PW32PROCESS LogonProcess = NULL; -void W32kRegisterPrimitiveMessageQueue() { +VOID W32kRegisterPrimitiveMessageQueue(VOID) +{ extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; if( !pmPrimitiveMessageQueue ) { PW32THREAD pThread; pThread = PsGetWin32Thread(); if( pThread && pThread->MessageQueue ) { pmPrimitiveMessageQueue = pThread->MessageQueue; + IntReferenceMessageQueue(pmPrimitiveMessageQueue); DPRINT( "Installed primitive input queue.\n" ); } } else { @@ -31,7 +33,15 @@ void W32kRegisterPrimitiveMessageQueue() { } } -PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() { +VOID W32kUnregisterPrimitiveMessageQueue(VOID) +{ + extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; + IntDereferenceMessageQueue(pmPrimitiveMessageQueue); + pmPrimitiveMessageQueue = NULL; +} + +PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() +{ extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; return pmPrimitiveMessageQueue; } diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c index 900f3b9b6b3..b1c00482c93 100644 --- a/reactos/subsys/win32k/ntuser/msgqueue.c +++ b/reactos/subsys/win32k/ntuser/msgqueue.c @@ -1413,15 +1413,21 @@ VOID FASTCALL MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) { PDESKTOP_OBJECT desk; + /* remove the message queue from any desktops */ - if((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0))) - { - InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0); - IntDereferenceMessageQueue(MessageQueue); - } + if ((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0))) + { + InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0); + IntDereferenceMessageQueue(MessageQueue); + } + /* if this is the primitive message queue, deregister it */ + if (MessageQueue == W32kGetPrimitiveMessageQueue()) + W32kUnregisterPrimitiveMessageQueue(); + /* clean it up */ MsqCleanupMessageQueue(MessageQueue); + /* decrease the reference counter, if it hits zero, the queue will be freed */ IntDereferenceMessageQueue(MessageQueue); }