remove user handle table lock, cursor locks, message queue locks, hook lock
Modified: trunk/reactos/subsys/win32k/include/cursoricon.h
Modified: trunk/reactos/subsys/win32k/include/hook.h
Modified: trunk/reactos/subsys/win32k/include/msgqueue.h
Modified: trunk/reactos/subsys/win32k/include/object.h
Modified: trunk/reactos/subsys/win32k/misc/object.c
Modified: trunk/reactos/subsys/win32k/ntuser/cursoricon.c
Modified: trunk/reactos/subsys/win32k/ntuser/focus.c
Modified: trunk/reactos/subsys/win32k/ntuser/hook.c
Modified: trunk/reactos/subsys/win32k/ntuser/input.c
Modified: trunk/reactos/subsys/win32k/ntuser/message.c
Modified: trunk/reactos/subsys/win32k/ntuser/msgqueue.c
Modified: trunk/reactos/subsys/win32k/ntuser/painting.c
Modified: trunk/reactos/subsys/win32k/ntuser/window.c
Modified: trunk/reactos/subsys/win32k/ntuser/winsta.c

Modified: trunk/reactos/subsys/win32k/include/cursoricon.h
--- trunk/reactos/subsys/win32k/include/cursoricon.h	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/include/cursoricon.h	2005-09-05 23:11:41 UTC (rev 17685)
@@ -13,7 +13,6 @@
 {
   LIST_ENTRY ListEntry;
   HANDLE Self;
-  FAST_MUTEX Lock;
   LIST_ENTRY ProcessList;
   HMODULE hModule;
   HRSRC hRsrc;
@@ -37,7 +36,6 @@
   BOOL Enabled;
   BOOL SwapButtons;
   UINT ButtonsDown;
-  FAST_MUTEX CursorMutex;
   CURSORCLIP_INFO CursorClipInfo;
   PCURICON_OBJECT CurrentCursorObject;
   BYTE ShowingCursor;
@@ -64,12 +62,6 @@
 #define IntReleaseCurIconObject(CurIconObj) \
   ObmDereferenceObject(CurIconObj)
 
-#define IntLockProcessCursorIcons(W32Process) \
-  ExAcquireFastMutex(&W32Process->CursorIconListLock)
-
-#define IntUnLockProcessCursorIcons(W32Process) \
-  ExReleaseFastMutex(&W32Process->CursorIconListLock)
-
 #endif /* _WIN32K_CURSORICON_H */
 
 /* EOF */

Modified: trunk/reactos/subsys/win32k/include/hook.h
--- trunk/reactos/subsys/win32k/include/hook.h	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/include/hook.h	2005-09-05 23:11:41 UTC (rev 17685)
@@ -19,7 +19,6 @@
 
 typedef struct tagHOOKTABLE
 {
-  FAST_MUTEX Lock;
   LIST_ENTRY Hooks[NB_HOOKS];  /* array of hook chains */
   UINT       Counts[NB_HOOKS]; /* use counts for each hook chain */
 } HOOKTABLE, *PHOOKTABLE;
@@ -27,12 +26,6 @@
 LRESULT FASTCALL co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam);
 VOID FASTCALL HOOK_DestroyThreadHooks(PETHREAD Thread);
 
-#define IntLockHookTable(HookTable) \
-  ExAcquireFastMutex(&HookTable->Lock)
-
-#define IntUnLockHookTable(HookTable) \
-  ExReleaseFastMutex(&HookTable->Lock)
-
 #endif /* _WIN32K_HOOK_H */
 
 /* EOF */

Modified: trunk/reactos/subsys/win32k/include/msgqueue.h
--- trunk/reactos/subsys/win32k/include/msgqueue.h	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/include/msgqueue.h	2005-09-05 23:11:41 UTC (rev 17685)
@@ -67,8 +67,6 @@
   LIST_ENTRY TimerListHead;
   /* Lock for the hardware message list. */
   KMUTEX HardwareLock;
-  /* Lock for the queue. */
-  FAST_MUTEX Lock;
   /* Pointer to the current WM_MOUSEMOVE message */
   PUSER_MESSAGE MouseMoveMsg;
   /* True if a WM_QUIT message is pending. */
@@ -216,12 +214,6 @@
 LPARAM FASTCALL MsqGetMessageExtraInfo(VOID);
 VOID STDCALL MsqRemoveWindowMessagesFromQueue(PVOID pWindow); /* F*(&$ headers, will be gone in the rewrite! */
 
-#define IntLockMessageQueue(MsgQueue) \
-  ExAcquireFastMutex(&(MsgQueue)->Lock)
-
-#define IntUnLockMessageQueue(MsgQueue) \
-  ExReleaseFastMutex(&(MsgQueue)->Lock)
-
 #define IntLockHardwareMessageQueue(MsgQueue) \
   KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
 

Modified: trunk/reactos/subsys/win32k/include/object.h
--- trunk/reactos/subsys/win32k/include/object.h	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/include/object.h	2005-09-05 23:11:41 UTC (rev 17685)
@@ -43,16 +43,9 @@
 typedef struct _USER_HANDLE_TABLE
 {
    LIST_ENTRY ListHead;
-   FAST_MUTEX ListLock;
 } USER_HANDLE_TABLE, *PUSER_HANDLE_TABLE;
 
 
-#define ObmpLockHandleTable(HandleTable) \
-  ExAcquireFastMutex(&HandleTable->ListLock)
-
-#define ObmpUnlockHandleTable(HandleTable) \
-  ExReleaseFastMutex(&HandleTable->ListLock)
-
 ULONG FASTCALL
 ObmGetReferenceCount(
   PVOID ObjectBody);

Modified: trunk/reactos/subsys/win32k/misc/object.c
--- trunk/reactos/subsys/win32k/misc/object.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/misc/object.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -111,8 +111,6 @@
   PVOID ObjectBody;
   ULONG i;
 
-  ObmpLockHandleTable(HandleTable);
-
   CurrentEntry = HandleTable->ListHead.Flink;
 
   while (CurrentEntry != &HandleTable->ListHead)
@@ -131,11 +129,8 @@
 	      ObjectHeader->HandleCount--;
 	      Current->Handles[i].ObjectBody = NULL;
 
-	      ObmpUnlockHandleTable(HandleTable);
-
 	      ObmDereferenceObject(ObjectBody);
 
-	      ObmpLockHandleTable(HandleTable);
 	      CurrentEntry = &HandleTable->ListHead;
 	      break;
 	    }
@@ -144,7 +139,6 @@
       CurrentEntry = CurrentEntry->Flink;
     }
 
-  ObmpUnlockHandleTable(HandleTable);
 }
 
 VOID FASTCALL
@@ -177,13 +171,10 @@
   PUSER_HANDLE Entry;
   PVOID ObjectBody;
 
-  ObmpLockHandleTable(HandleTable);
-
   Entry = ObmpGetObjectByHandle(HandleTable, Handle);
   if (Entry == NULL)
     {
       DPRINT1("Invalid handle\n");
-      ObmpUnlockHandleTable(HandleTable);
       return NULL;
     }
 
@@ -197,8 +188,6 @@
       Entry->ObjectBody = NULL;
     }
 
-  ObmpUnlockHandleTable(HandleTable);
-
   return ObjectBody;
 }
 
@@ -372,8 +361,6 @@
       USER_BODY_TO_HEADER(ObjectBody)->HandleCount++;
     }
 
-  ObmpLockHandleTable(HandleTable);
-
   Handle = 1;
   Current = HandleTable->ListHead.Flink;
   /*
@@ -390,7 +377,6 @@
 	  if (!Block->Handles[i].ObjectBody)
 	    {
 	      Block->Handles[i].ObjectBody = ObjectBody;
-	      ObmpUnlockHandleTable(HandleTable);
 	      *HandleReturn = (HANDLE)((Handle + i) << 2);
 	      return STATUS_SUCCESS;
 	    }
@@ -415,7 +401,6 @@
   RtlZeroMemory(NewBlock, sizeof(USER_HANDLE_BLOCK));
   NewBlock->Handles[0].ObjectBody = ObjectBody;
   InsertTailList(&HandleTable->ListHead, &NewBlock->ListEntry);
-  ObmpUnlockHandleTable(HandleTable);
   *HandleReturn = (HANDLE)(Handle << 2);
 
   return STATUS_SUCCESS;
@@ -441,21 +426,16 @@
   PUSER_HANDLE UserHandle;
   PVOID ObjectBody;
 
-  ObmpLockHandleTable(HandleTable);
-
   UserHandle = ObmpGetObjectByHandle(HandleTable, Handle);
 
   if ((UserHandle == NULL) || (UserHandle->ObjectBody == NULL))
     {
-      ObmpUnlockHandleTable(HandleTable);
       return STATUS_UNSUCCESSFUL;
     }
 
   ObjectBody = UserHandle->ObjectBody;
   ObmReferenceObjectByPointer(ObjectBody, ObjectType);
 
-  ObmpUnlockHandleTable(HandleTable);
-
   ObjectHeader = USER_BODY_TO_HEADER(ObjectBody);
 
   if ((ObjectType != otUnknown) && (ObjectHeader->Type != ObjectType))
@@ -491,7 +471,6 @@
 ObmInitializeHandleTable(PUSER_HANDLE_TABLE HandleTable)
 {
   InitializeListHead(&HandleTable->ListHead);
-  ExInitializeFastMutex(&HandleTable->ListLock);
 }
 
 VOID FASTCALL

Modified: trunk/reactos/subsys/win32k/ntuser/cursoricon.c
--- trunk/reactos/subsys/win32k/ntuser/cursoricon.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/ntuser/cursoricon.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -43,7 +43,6 @@
 
 static PAGED_LOOKASIDE_LIST ProcessLookasideList;
 static LIST_ENTRY CurIconList;
-static FAST_MUTEX CurIconListLock;
 
 /* Look up the location of the cursor in the GDIDEVICE structure
  * when all we know is the window station object
@@ -305,7 +304,6 @@
 				 0,
 				 128);
   InitializeListHead(&CurIconList);
-  ExInitializeFastMutex(&CurIconListLock);
 
   return TRUE;
 }
@@ -328,7 +326,6 @@
 
   Win32Process = PsGetWin32Process();
 
-  ExAcquireFastMutex(&Object->Lock);
   Search = Object->ProcessList.Flink;
   while (Search != &Object->ProcessList)
     {
@@ -336,7 +333,6 @@
       if (Current->Process == Win32Process)
         {
           /* Already registered for this process */
-          ExReleaseFastMutex(&Object->Lock);
           return TRUE;
         }
       Search = Search->Flink;
@@ -351,7 +347,6 @@
   InsertHeadList(&Object->ProcessList, &Current->ListEntry);
   Current->Process = Win32Process;
 
-  ExReleaseFastMutex(&Object->Lock);
   return TRUE;
 }
 
@@ -362,8 +357,6 @@
   PLIST_ENTRY CurrentEntry;
   PCURICON_OBJECT Object;
 
-  ExAcquireFastMutex(&CurIconListLock);
-
   CurrentEntry = CurIconList.Flink;
   while (CurrentEntry != &CurIconList)
   {
@@ -380,18 +373,15 @@
         }
         if (! ReferenceCurIconByProcess(Object))
         {
-          ExReleaseFastMutex(&CurIconListLock);
           return NULL;
         }
-        ExReleaseFastMutex(&CurIconListLock);
+
         return Object;
       }
     }
     ObmDereferenceObject(Object);
   }
 
-  ExReleaseFastMutex(&CurIconListLock);
-
   return NULL;
 }
 
@@ -410,7 +400,6 @@
   }
 
   Object->Self = Handle;
-  ExInitializeFastMutex(&Object->Lock);
   InitializeListHead(&Object->ProcessList);
 
   if (! ReferenceCurIconByProcess(Object))
@@ -421,9 +410,7 @@
     return NULL;
   }
 
-  ExAcquireFastMutex(&CurIconListLock);
   InsertHeadList(&CurIconList, &Object->ListEntry);
-  ExReleaseFastMutex(&CurIconListLock);
 
   ObmDereferenceObject(Object);
 
@@ -440,8 +427,6 @@
   PCURICON_PROCESS Current = NULL;
   PW32PROCESS W32Process = PsGetWin32Process();
 
-  ExAcquireFastMutex(&Object->Lock);
-
   /* Private objects can only be destroyed by their own process */
   if (NULL == Object->hModule)
     {
@@ -449,14 +434,12 @@
     Current = CONTAINING_RECORD(Object->ProcessList.Flink, CURICON_PROCESS, ListEntry);
     if (Current->Process != W32Process)
       {
-        ExReleaseFastMutex(&Object->Lock);
         DPRINT1("Trying to destroy private icon/cursor of another process\n");
         return FALSE;
       }
     }
   else if (! ProcessCleanup)
     {
-      ExReleaseFastMutex(&Object->Lock);
       DPRINT("Trying to destroy shared icon/cursor\n");
       return FALSE;
     }
@@ -480,17 +463,13 @@
   /* If there are still processes referencing this object we can't destroy it yet */
   if (! IsListEmpty(&Object->ProcessList))
     {
-    ExReleaseFastMutex(&Object->Lock);
     return TRUE;
     }
 
-  ExReleaseFastMutex(&Object->Lock);
 
   if (! ProcessCleanup)
     {
-    ExAcquireFastMutex(&CurIconListLock);
     RemoveEntryList(&Object->ListEntry);
-    ExReleaseFastMutex(&CurIconListLock);
     }
 
   CurInfo = IntGetSysCursorInfo(WinStaObject);
@@ -536,8 +515,6 @@
     return;
   }
 
-  ExAcquireFastMutex(&CurIconListLock);
-
   CurrentEntry = CurIconList.Flink;
   while (CurrentEntry != &CurIconList)
   {
@@ -545,29 +522,23 @@
     CurrentEntry = CurrentEntry->Flink;
     if(NT_SUCCESS(ObmReferenceObjectByPointer(Object, otCursorIcon)))
       {
-      ExAcquireFastMutex(&Object->Lock);
       ProcessEntry = Object->ProcessList.Flink;
       while (ProcessEntry != &Object->ProcessList)
       {
         ProcessData = CONTAINING_RECORD(ProcessEntry, CURICON_PROCESS, ListEntry);
         if (Win32Process == ProcessData->Process)
         {
-          ExReleaseFastMutex(&Object->Lock);
           RemoveEntryList(&Object->ListEntry);
           IntDestroyCurIconObject(WinStaObject, Object, TRUE);
           break;
         }
         ProcessEntry = ProcessEntry->Flink;
       }
-      if (ProcessEntry == &Object->ProcessList)
-      {
-        ExReleaseFastMutex(&Object->Lock);
-      }
+
       ObmDereferenceObject(Object);
     }
   }
 
-  ExReleaseFastMutex(&CurIconListLock);
   ObDereferenceObject(WinStaObject);
 }
 

Modified: trunk/reactos/subsys/win32k/ntuser/focus.c
--- trunk/reactos/subsys/win32k/ntuser/focus.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/ntuser/focus.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -190,18 +190,15 @@
    co_IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
 
    IntSetFocusMessageQueue(Window->MessageQueue);
-   IntLockMessageQueue(Window->MessageQueue);
    if (Window->MessageQueue)
    {
       Window->MessageQueue->ActiveWindow = hWnd;
    }
-   IntUnLockMessageQueue(Window->MessageQueue);
-   IntLockMessageQueue(FocusWindow->MessageQueue);
+
    if (FocusWindow->MessageQueue)
    {
       FocusWindow->MessageQueue->FocusWindow = hWndFocus;
    }
-   IntUnLockMessageQueue(FocusWindow->MessageQueue);
 
    if (PrevForegroundQueue != Window->MessageQueue)
    {
@@ -299,9 +296,7 @@
 
    /* FIXME: Call hooks. */
 
-   IntLockMessageQueue(ThreadQueue);
    ThreadQueue->ActiveWindow = hWnd;
-   IntUnLockMessageQueue(ThreadQueue);
 
    co_IntSendDeactivateMessages(hWndPrev, hWnd);
    co_IntSendActivateMessages(hWndPrev, hWnd, FALSE);
@@ -326,9 +321,7 @@
       return hWndPrev;
    }
 
-   IntLockMessageQueue(ThreadQueue);
    ThreadQueue->FocusWindow = hWnd;
-   IntUnLockMessageQueue(ThreadQueue);
 
    co_IntSendKillFocusMessages(hWndPrev, hWnd);
    co_IntSendSetFocusMessages(hWndPrev, hWnd);
@@ -499,9 +492,7 @@
    }
 
    co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd);
-   IntLockMessageQueue(ThreadQueue);
    ThreadQueue->CaptureWindow = hWnd;
-   IntUnLockMessageQueue(ThreadQueue);
 
    RETURN( hWndPrev);
    

Modified: trunk/reactos/subsys/win32k/ntuser/hook.c
--- trunk/reactos/subsys/win32k/ntuser/hook.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/ntuser/hook.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -48,7 +48,6 @@
   Table = ExAllocatePoolWithTag(PagedPool, sizeof(HOOKTABLE), TAG_HOOK);
   if (NULL != Table)
     {
-      ExInitializeFastMutex(&Table->Lock);
       for (i = 0; i < NB_HOOKS; i++)
         {
           InitializeListHead(&Table->Hooks[i]);
@@ -96,9 +95,7 @@
   Hook->HookId = HookId;
   RtlInitUnicodeString(&Hook->ModuleName, NULL);
 
-  IntLockHookTable(Table);
   InsertHeadList(&Table->Hooks[HOOKID_TO_INDEX(HookId)], &Hook->Chain);
-  IntUnLockHookTable(Table);
 
   return Hook;
 }
@@ -132,7 +129,6 @@
   PHOOK Hook;
   PLIST_ENTRY Elem;
 
-  IntLockHookTable(Table);
   Hook = IntGetFirstHook(Table, HookId);
   while (NULL != Hook && NULL == Hook->Proc)
     {
@@ -140,7 +136,6 @@
       Hook = (Elem == &Table->Hooks[HOOKID_TO_INDEX(HookId)]
               ? NULL : CONTAINING_RECORD(Elem, HOOK, Chain));
     }
-  IntUnLockHookTable(Table);
 
   return Hook;
 }
@@ -153,18 +148,15 @@
   int HookId = Hook->HookId;
   PLIST_ENTRY Elem;
 
-  IntLockHookTable(Table);
   Elem = Hook->Chain.Flink;
   while (Elem != &Table->Hooks[HOOKID_TO_INDEX(HookId)])
     {
       Hook = CONTAINING_RECORD(Elem, HOOK, Chain);
       if (NULL != Hook->Proc)
         {
-          IntUnLockHookTable(Table);
           return Hook;
         }
     }
-  IntUnLockHookTable(Table);
 
   if (NULL != GlobalHooks && Table != GlobalHooks)  /* now search through the global table */
     {
@@ -203,10 +195,6 @@
       return;
     }
 
-  if (! TableAlreadyLocked)
-    {
-      IntLockHookTable(Table);
-    }
   if (0 != Table->Counts[HOOKID_TO_INDEX(Hook->HookId)])
     {
       Hook->Proc = NULL; /* chain is in use, just mark it and return */
@@ -215,10 +203,6 @@
     {
       IntFreeHook(Table, Hook, WinStaObj);
     }
-  if (! TableAlreadyLocked)
-    {
-      IntUnLockHookTable(Table);
-    }
 }
 
 /* release a hook chain, removing deleted hooks if the use count drops to 0 */
@@ -233,12 +217,10 @@
       return;
     }
 
-  IntLockHookTable(Table);
   /* use count shouldn't already be 0 */
   ASSERT(0 != Table->Counts[HOOKID_TO_INDEX(HookId)]);
   if (0 == Table->Counts[HOOKID_TO_INDEX(HookId)])
     {
-      IntUnLockHookTable(Table);
       return;
     }
   if (0 == --Table->Counts[HOOKID_TO_INDEX(HookId)])
@@ -254,7 +236,6 @@
             }
         }
     }
-  IntUnLockHookTable(Table);
 }
 
 static LRESULT FASTCALL
@@ -316,14 +297,10 @@
       return 0;
     }
 
-  IntLockHookTable(Table);
   Table->Counts[HOOKID_TO_INDEX(HookId)]++;
-  IntUnLockHookTable(Table);
   if (Table != GlobalHooks && GlobalHooks != NULL)
     {
-      IntLockHookTable(GlobalHooks);
       GlobalHooks->Counts[HOOKID_TO_INDEX(HookId)]++;
-      IntUnLockHookTable(GlobalHooks);
     }
 
   Result = co_IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc,
@@ -369,7 +346,7 @@
           DPRINT1("Invalid window station????\n");
           return;
         }
-      IntLockHookTable(GlobalHooks);
+
       for (HookId = WH_MINHOOK; HookId <= WH_MAXHOOK; HookId++)
         {
           /* only low-level keyboard/mouse global hooks can be owned by a thread */
@@ -390,7 +367,7 @@
               break;
             }
         }
-      IntUnLockHookTable(GlobalHooks);
+
       ObDereferenceObject(WinStaObj);
     }
 }

Modified: trunk/reactos/subsys/win32k/ntuser/input.c
--- trunk/reactos/subsys/win32k/ntuser/input.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/ntuser/input.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -930,7 +930,6 @@
   SwapButtons = CurInfo->SwapButtons;
   DoMove = FALSE;
 
-  ExAcquireFastMutex(&CurInfo->CursorMutex);
   IntGetCursorLocation(WinSta, &MousePos);
   OrgPos.x = MousePos.x;
   OrgPos.y = MousePos.y;
@@ -981,8 +980,6 @@
     DoMove = (MousePos.x != OrgPos.x || MousePos.y != OrgPos.y);
   }
 
-  ExReleaseFastMutex(&CurInfo->CursorMutex);
-
   if (DoMove)
   {
     dc = DC_LockDc(hDC);

Modified: trunk/reactos/subsys/win32k/ntuser/message.c
--- trunk/reactos/subsys/win32k/ntuser/message.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/ntuser/message.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -1745,16 +1745,12 @@
 
    Queue = PsGetWin32Thread()->MessageQueue;
 
-   IntLockMessageQueue(Queue);
-
    Result = MAKELONG(Queue->QueueBits, Queue->ChangedBits);
    if (ClearChanges)
    {
       Queue->ChangedBits = 0;
    }
 
-   IntUnLockMessageQueue(Queue);
-
    RETURN( Result);
    
 CLEANUP:

Modified: trunk/reactos/subsys/win32k/ntuser/msgqueue.c
--- trunk/reactos/subsys/win32k/ntuser/msgqueue.c	2005-09-05 22:39:29 UTC (rev 17684)
+++ trunk/reactos/subsys/win32k/ntuser/msgqueue.c	2005-09-05 23:11:41 UTC (rev 17685)
@@ -77,10 +77,8 @@
     return 0;
 
   MessageQueue = Win32Thread->MessageQueue;
-  IntLockMessageQueue(MessageQueue);
   MessageQueue->WakeMask = WakeMask;
   MessageEventHandle = MessageQueue->NewMessagesHandle;
-  IntUnLockMessageQueue(MessageQueue);
 
   return MessageEventHandle;
 }
@@ -96,9 +94,7 @@
     return FALSE;
 
   MessageQueue = Win32Thread->MessageQueue;
-  IntLockMessageQueue(MessageQueue);
   MessageQueue->WakeMask = ~0;
-  IntUnLockMessageQueue(MessageQueue);
 
   return TRUE;
 }
@@ -106,26 +102,22 @@
 VOID FASTCALL
 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue)
 {
-  IntLockMessageQueue(Queue);
   Queue->PaintCount++;
   Queue->PaintPosted = TRUE;
   Queue->QueueBits |= QS_PAINT;
   Queue->ChangedBits |= QS_PAINT;
   if (Queue->WakeMask & QS_PAINT)
     KeSetEvent(Queue->NewMessages, IO_NO_INCREMENT, FALSE);
-  IntUnLockMessageQueue(Queue);
 }
 
 VOID FASTCALL
 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue)
 {
-  IntLockMessageQueue(Queue);
   Queue->PaintCount--;
   if (Queue->PaintCount == 0)
     {
       Queue->PaintPosted = FALSE;
     }
-  IntUnLockMessageQueue(Queue);
 }
 
 
@@ -760,12 +752,9 @@
   ObmDereferenceObject(Window);
   ObDereferenceObject (Thread);
 
-//  IntLockMessageQueue(pThread->MessageQueue);
 //  InsertHeadList(&pThread->MessageQueue->PostedMessagesListHead,
 //		 &Message->ListEntry);
 //  KeSetEvent(pThread->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-//  IntUnLockMessageQueue(pThread->MessageQueue);
-
 }
 
 PUSER_MESSAGE FASTCALL
@@ -797,13 +786,11 @@
   PLIST_ENTRY ListEntry;
   PUSER_SENT_MESSAGE_NOTIFY Message;
 
-  IntLockMessageQueue(MessageQueue);
   while (!IsListEmpty(&MessageQueue->SentMessagesListHead))
   {
     ListEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
     Message = CONTAINING_RECORD(ListEntry, USER_SENT_MESSAGE_NOTIFY,
 				ListEntry);
-    IntUnLockMessageQueue(MessageQueue);
 
     co_IntCallSentMessageCallback(Message->CompletionCallback,
 				Message->hWnd,
@@ -811,9 +798,8 @@
 				Message->CompletionCallbackContext,
 				Message->Result);
 
-    IntLockMessageQueue(MessageQueue);
   }
-  IntUnLockMessageQueue(MessageQueue);
+
 }
 
 BOOLEAN FASTCALL
@@ -831,10 +817,8 @@
   BOOL SenderReturned;
   PUSER_SENT_MESSAGE_NOTIFY NotifyMessage;
 
-  IntLockMessageQueue(MessageQueue);
   if (IsListEmpty(&MessageQueue->SentMessagesListHead))
     {
-      IntUnLockMessageQueue(MessageQueue);
       return(FALSE);
     }
 
@@ -847,8 +831,6 @@
   InsertTailList(&MessageQueue->LocalDispatchingMessagesHead,
 		 &Message->ListEntry);
 
-  IntUnLockMessageQueue(MessageQueue);
-
   if (Message->HookMessage)
     {
       Result = co_HOOK_CallHooks(Message->Msg.message,
@@ -867,13 +849,9 @@
 
   /* remove the message from the local dispatching list, because it doesn't need
      to be cleaned up on thread termination anymore */
-  IntLockMessageQueue(MessageQueue);
   RemoveEntryList(&Message->ListEntry);
-  IntUnLockMessageQueue(MessageQueue);
 
   /* remove the message from the dispatching list, so lock the sender's message queue */
-  IntLockMessageQueue(Message->SenderQueue);
-
   SenderReturned = (Message->DispatchingListEntry.Flink == NULL);
   if(!SenderReturned)
   {
@@ -895,9 +873,6 @@
       KeSetEvent(Message->CompletionEvent, IO_NO_INCREMENT, FALSE);
     }
 
-  /* unlock the sender's message queue, the safe operation is done */
-  IntUnLockMessageQueue(Message->SenderQueue);
-
   /* Notify the sender if they specified a callback. */
   if (!SenderReturned && Message->CompletionCallback != NULL)
     {
@@ -942,8 +917,6 @@
   MessageQueue = Window->MessageQueue;
   ASSERT(MessageQueue);
 
-  IntLockMessageQueue(MessageQueue);
-
   /* remove the posted messages for this window */
   CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
   ListHead = &MessageQueue->PostedMessagesListHead;
@@ -973,7 +946,6 @@
                                       ListEntry);
       if(SentMessage->Msg.hwnd == Window->Self)
       {
-        IntLockMessageQueue(SentMessage->SenderQueue);
         DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n");
 
         /* remove the message from the dispatching list */
@@ -987,7 +959,6 @@
         {
           KeSetEvent(SentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
         }
-        IntUnLockMessageQueue(SentMessage->SenderQueue);
 
         /* dereference our and the sender's message queue */
         IntDereferenceMessageQueue(MessageQueue);
@@ -1003,21 +974,18 @@
         CurrentEntry = CurrentEntry->Flink;
       }
     }
-  IntUnLockMessageQueue(MessageQueue);
 }
 
 VOID FASTCALL
 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
 		     PUSER_SENT_MESSAGE_NOTIFY NotifyMessage)
 {
-  IntLockMessageQueue(MessageQueue);
   InsertTailList(&MessageQueue->NotifyMessagesListHead,
 		 &NotifyMessage->ListEntry);
   MessageQueue->QueueBits |= QS_SENDMESSAGE;
   MessageQueue->ChangedBits |= QS_SENDMESSAGE;
   if (MessageQueue->WakeMask & QS_SENDMESSAGE)
     KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-  IntUnLockMessageQueue(MessageQueue);
 }
 
 NTSTATUS FASTCALL
@@ -1064,14 +1032,10 @@
   IntReferenceMessageQueue(MessageQueue);
 
   /* add it to the list of pending messages */
-  IntLockMessageQueue(ThreadQueue);
   InsertTailList(&ThreadQueue->DispatchingMessagesHead, &Message->DispatchingListEntry);
-  IntUnLockMessageQueue(ThreadQueue);
 
   /* queue it in the destination's message queue */
-  IntLockMessageQueue(MessageQueue);
   InsertTailList(&MessageQueue->SentMessagesListHead, &Message->ListEntry);
-  IntUnLockMessageQueue(MessageQueue);
 
   MessageQueue->QueueBits |= QS_SENDMESSAGE;
   MessageQueue->ChangedBits |= QS_SENDMESSAGE;
@@ -1095,7 +1059,6 @@
       {
         /* look up if the message has not yet dispatched, if so
            make sure it can't pass a result and it must not set the completion event anymore */
-	IntLockMessageQueue(MessageQueue);
         Entry = MessageQueue->SentMessagesListHead.Flink;
         while (Entry != &MessageQueue->SentMessagesListHead)
           {
@@ -1110,11 +1073,9 @@
               }
             Entry = Entry->Flink;
           }
-        IntUnLockMessageQueue(MessageQueue);
 
 	/* remove from the local dispatching list so the other thread knows,
 	   it can't pass a result and it must not set the completion event anymore */
-	IntLockMessageQueue(ThreadQueue);
         Entry = ThreadQueue->DispatchingMessagesHead.Flink;
         while (Entry != &ThreadQueue->DispatchingMessagesHead)
           {
@@ -1133,7 +1094,6 @@
               }
             Entry = Entry->Flink;
           }
-	IntUnLockMessageQueue(ThreadQueue);
 
 	DPRINT("MsqSendMessage (blocked) timed out\n");
       }
@@ -1159,7 +1119,6 @@
           {
             /* look up if the message has not yet been dispatched, if so
                make sure it can't pass a result and it must not set the completion event anymore */
-	    IntLockMessageQueue(MessageQueue);
             Entry = MessageQueue->SentMessagesListHead.Flink;
             while (Entry != &MessageQueue->SentMessagesListHead)
               {
@@ -1174,11 +1133,9 @@
                   }
                 Entry = Entry->Flink;
               }
-	    IntUnLockMessageQueue(MessageQueue);
 
 	    /* remove from the local dispatching list so the other thread knows,
 	       it can't pass a result and it must not set the completion event anymore */
-	    IntLockMessageQueue(ThreadQueue);
             Entry = ThreadQueue->DispatchingMessagesHead.Flink;
             while (Entry != &ThreadQueue->DispatchingMessagesHead)
               {
@@ -1197,7 +1154,6 @@
                   }
                 Entry = Entry->Flink;
               }
-	    IntUnLockMessageQueue(ThreadQueue);
 
 	    DPRINT("MsqSendMessage timed out\n");
             break;
@@ -1223,27 +1179,23 @@
   {
     return;
   }
-  IntLockMessageQueue(MessageQueue);
   InsertTailList(&MessageQueue->PostedMessagesListHead,
 		 &Message->ListEntry);
   MessageQueue->QueueBits |= MessageBits;
   MessageQueue->ChangedBits |= MessageBits;
   if (MessageQueue->WakeMask & MessageBits)
     KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-  IntUnLockMessageQueue(MessageQueue);
 }
 
 VOID FASTCALL
 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode)
 {
-  IntLockMessageQueue(MessageQueue);
   MessageQueue->QuitPosted = TRUE;
   MessageQueue->QuitExitCode = ExitCode;
   MessageQueue->QueueBits |= QS_POSTMESSAGE;
   MessageQueue->ChangedBits |= QS_POSTMESSAGE;
   if (MessageQueue->WakeMask & QS_POSTMESSAGE)
     KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-  IntUnLockMessageQueue(MessageQueue);
 }
 
 BOOLEAN STDCALL
@@ -1266,7 +1218,6 @@
 				    Remove, Message));
     }
 
-  IntLockMessageQueue(MessageQueue);
   CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
   ListHead = &MessageQueue->PostedMessagesListHead;
   while (CurrentEntry != ListHead)
@@ -1282,13 +1233,13 @@
 	    {
 	      RemoveEntryList(&CurrentMessage->ListEntry);
 	    }
-	  IntUnLockMessageQueue(MessageQueue);
+
 	  *Message = CurrentMessage;
 	  return(TRUE);
 	}
       CurrentEntry = CurrentEntry->Flink;
     }
-  IntUnLockMessageQueue(MessageQueue);
+
   return(FALSE);
 }
 
@@ -1350,7 +1301,6 @@
   InitializeListHead(&MessageQueue->DispatchingMessagesHead);
   InitializeListHead(&MessageQueue->LocalDispatchingMessagesHead);
   KeInitializeMutex(&MessageQueue->HardwareLock, 0);
-  ExInitializeFastMutex(&MessageQueue->Lock);
   MessageQueue->QuitPosted = FALSE;
   MessageQueue->QuitExitCode = 0;
   KeQueryTickCount(&LargeTickCount);
@@ -1389,8 +1339,6 @@
   PTIMER_ENTRY CurrentTimer;
   PUSER_SENT_MESSAGE CurrentSentMessage;
 
-  IntLockMessageQueue(MessageQueue);
-
   /* cleanup posted messages */
   while (!IsListEmpty(&MessageQueue->PostedMessagesListHead))
     {
@@ -1407,7 +1355,6 @@
       CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
                                              ListEntry);
 
-      IntLockMessageQueue(CurrentSentMessage->SenderQueue);
       DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n");
 
       /* remove the message from the dispatching list */
@@ -1421,7 +1368,6 @@
       {
         KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
       }
-      IntUnLockMessageQueue(CurrentSentMessage->SenderQueue);
 
       /* dereference our and the sender's message queue */
       IntDereferenceMessageQueue(MessageQueue);
@@ -1447,7 +1393,6 @@
       CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
                                              ListEntry);
 
-      IntLockMessageQueue(CurrentSentMessage->SenderQueue);
       /* remove the message from the dispatching list */
       if(CurrentSentMessage->DispatchingListEntry.Flink != NULL)
       {
@@ -1461,7 +1406,6 @@
       {
         KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
       }
-      IntUnLockMessageQueue(CurrentSentMessage->SenderQueue);
       
       /* dereference our and the sender's message queue */
       IntDereferenceMessageQueue(MessageQueue);
@@ -1484,7 +1428,6 @@
          locked later */
     }
 
-  IntUnLockMessageQueue(MessageQueue);
 }
 
 PUSER_MESSAGE_QUEUE FASTCALL
@@ -1698,14 +1641,12 @@
   DPRINT("MsqSetTimer queue %p wnd %x id %p period %u timerproc %p msg %d\n",
          MessageQueue, Wnd, IDEvent, Period, TimerFunc, Msg);
 
-  IntLockMessageQueue(MessageQueue);
   Timer = RemoveTimer(MessageQueue, Wnd, IDEvent, Msg);
   if (NULL == Timer)
     {
       Timer = ExAllocateFromPagedLookasideList(&TimerLookasideList);
       if (NULL == Timer)
         {
-          IntUnLockMessageQueue(MessageQueue);
           DPRINT1("Failed to allocate timer entry\n");
           return FALSE;
         }
@@ -1733,8 +1674,6 @@
   DumpTimerList(MessageQueue);
 #endif /* ! defined(NDEBUG) */
 
-  IntUnLockMessageQueue(MessageQueue);
-
[truncated at 1000 lines; 131 more skipped]