-remove hotkey lock
-remove dc list lock
-simplify/rework refcounting
-remove keyboard queue state lock
-convert some functions into taking pointerargs, not handles
Modified: trunk/reactos/subsys/win32k/include/cursoricon.h
Modified: trunk/reactos/subsys/win32k/include/dce.h
Modified: trunk/reactos/subsys/win32k/include/hotkey.h
Modified: trunk/reactos/subsys/win32k/include/userfuncs.h
Modified: trunk/reactos/subsys/win32k/include/window.h
Modified: trunk/reactos/subsys/win32k/include/winpos.h
Modified: trunk/reactos/subsys/win32k/include/winsta.h
Modified: trunk/reactos/subsys/win32k/ntuser/accelerator.c
Modified: trunk/reactos/subsys/win32k/ntuser/caret.c
Modified: trunk/reactos/subsys/win32k/ntuser/class.c
Modified: trunk/reactos/subsys/win32k/ntuser/cursoricon.c
Modified: trunk/reactos/subsys/win32k/ntuser/focus.c
Modified: trunk/reactos/subsys/win32k/ntuser/hotkey.c
Modified: trunk/reactos/subsys/win32k/ntuser/input.c
Modified: trunk/reactos/subsys/win32k/ntuser/keyboard.c
Modified: trunk/reactos/subsys/win32k/ntuser/menu.c
Modified: trunk/reactos/subsys/win32k/ntuser/metric.c
Modified: trunk/reactos/subsys/win32k/ntuser/misc.c
Modified: trunk/reactos/subsys/win32k/ntuser/monitor.c
Modified: trunk/reactos/subsys/win32k/ntuser/object.c
Modified: trunk/reactos/subsys/win32k/ntuser/scrollbar.c
Modified: trunk/reactos/subsys/win32k/ntuser/windc.c
Modified: trunk/reactos/subsys/win32k/ntuser/window.c
Modified: trunk/reactos/subsys/win32k/ntuser/winpos.c

Modified: trunk/reactos/subsys/win32k/include/cursoricon.h
--- trunk/reactos/subsys/win32k/include/cursoricon.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/cursoricon.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -50,7 +50,6 @@
 
 HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange);
 BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject);
-PCURICON_OBJECT FASTCALL IntGetCurIconObject(HANDLE Handle);
 PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject);
 VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process);
 

Modified: trunk/reactos/subsys/win32k/include/dce.h
--- trunk/reactos/subsys/win32k/include/dce.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/dce.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -50,10 +50,9 @@
 #define  DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(pDCE)
 BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody);
 
-PDCE FASTCALL DceAllocDCE(HWND hWnd, DCE_TYPE Type);
+PDCE FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
 PDCE FASTCALL DCE_FreeDCE(PDCE dce);
 VOID FASTCALL DCE_FreeWindowDCE(HWND);
-HRGN STDCALL  DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags);
 INT  FASTCALL DCE_ExcludeRgn(HDC, HWND, HRGN);
 BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL);
 HWND FASTCALL IntWindowFromDC(HDC hDc);

Modified: trunk/reactos/subsys/win32k/include/hotkey.h
--- trunk/reactos/subsys/win32k/include/hotkey.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/hotkey.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -34,12 +34,6 @@
 VOID
 UnregisterThreadHotKeys(struct _ETHREAD *Thread);
 
-#define IntLockHotKeys(WinStaObject) \
-  ExAcquireFastMutex(&WinStaObject->HotKeyListLock)
-
-#define IntUnLockHotKeys(WinStaObject) \
-  ExReleaseFastMutex(&WinStaObject->HotKeyListLock)
-
 #endif /* _WIN32K_HOTKEY_H */
 
 /* EOF */

Modified: trunk/reactos/subsys/win32k/include/userfuncs.h
--- trunk/reactos/subsys/win32k/include/userfuncs.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/userfuncs.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -67,7 +67,7 @@
 
 HWND FASTCALL UserGetForegroundWindow(VOID);
 
-HWND FASTCALL UserSetFocus(HWND hWnd);
+HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window);
 
 /*************** WINDC.C ***************/
 

Modified: trunk/reactos/subsys/win32k/include/window.h
--- trunk/reactos/subsys/win32k/include/window.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/window.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -154,7 +154,7 @@
 IntGetActiveWindow (VOID);
 
 BOOL FASTCALL
-IntIsWindowVisible (HWND hWnd);
+IntIsWindowVisible (PWINDOW_OBJECT Window);
 
 BOOL FASTCALL
 IntIsChildWindow (HWND Parent, HWND Child);
@@ -178,10 +178,10 @@
 IntGetParentObject(PWINDOW_OBJECT Wnd);
 
 INT FASTCALL
-IntGetWindowRgn(HWND hWnd, HRGN hRgn);
+IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn);
 
 INT FASTCALL
-IntGetWindowRgnBox(HWND hWnd, RECT *Rect);
+IntGetWindowRgnBox(PWINDOW_OBJECT Window, RECT *Rect);
 
 BOOL FASTCALL
 IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi);
@@ -200,7 +200,7 @@
 DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode);
 
 BOOL FASTCALL
-IntShowOwnedPopups( HWND owner, BOOL fShow );
+IntShowOwnedPopups( PWINDOW_OBJECT owner, BOOL fShow );
 
 #endif /* _WIN32K_WINDOW_H */
 

Modified: trunk/reactos/subsys/win32k/include/winpos.h
--- trunk/reactos/subsys/win32k/include/winpos.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/winpos.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -19,7 +19,7 @@
 BOOL FASTCALL
 IntGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point);
 LRESULT FASTCALL
-co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect);
+co_WinPosGetNonClientSize(PWINDOW_OBJECT Window, RECT* WindowRect, RECT* ClientRect);
 UINT FASTCALL
 co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
 		    POINT* MinTrack, POINT* MaxTrack);

Modified: trunk/reactos/subsys/win32k/include/winsta.h
--- trunk/reactos/subsys/win32k/include/winsta.h	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/include/winsta.h	2005-09-08 16:18:51 UTC (rev 17743)
@@ -42,7 +42,6 @@
     struct _DESKTOP_OBJECT* ActiveDesktop;
     /* FIXME: Clipboard */
     LIST_ENTRY HotKeyListHead;
-    FAST_MUTEX HotKeyListLock;
 } WINSTATION_OBJECT, *PWINSTATION_OBJECT;
 
 extern WINSTATION_OBJECT *InputWindowStation;

Modified: trunk/reactos/subsys/win32k/ntuser/accelerator.c
--- trunk/reactos/subsys/win32k/ntuser/accelerator.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/accelerator.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -72,7 +72,11 @@
 static
 PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel)
 {
-   PACCELERATOR_TABLE Accel= UserGetObject(&gHandleTable, hAccel,  otAccel);
+   PACCELERATOR_TABLE Accel;
+   
+   if (!hAccel) return NULL;
+   
+   Accel= UserGetObject(&gHandleTable, hAccel,  otAccel);
 
    if (Accel)
    {
@@ -355,7 +359,7 @@
       mesg = 1;
    else if (IntGetCaptureWindow())
       mesg = 2;
-   else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
+   else if (!IntIsWindowVisible(Window)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
       mesg = 3;
    else
    {

Modified: trunk/reactos/subsys/win32k/ntuser/caret.c
--- trunk/reactos/subsys/win32k/ntuser/caret.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/caret.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -221,23 +221,20 @@
    int nWidth,
    int nHeight)
 {
-   PWINDOW_OBJECT WindowObject;
+   PWINDOW_OBJECT Window;
    PUSER_MESSAGE_QUEUE ThreadQueue;
    DECLARE_RETURN(BOOL);
 
    DPRINT("Enter NtUserCreateCaret\n");
    UserEnterExclusive();
 
-   WindowObject = IntGetWindowObject(hWnd);
-   if(!WindowObject)
+   if(!(Window = UserGetWindowObject(hWnd)))
    {
-      SetLastWin32Error(ERROR_INVALID_HANDLE);
       RETURN(FALSE);
    }
 
-   if(WindowObject->OwnerThread != PsGetCurrentThread())
+   if(Window->OwnerThread != PsGetCurrentThread())
    {
-      IntReleaseWindowObject(WindowObject);
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       RETURN(FALSE);
    }
@@ -265,8 +262,6 @@
    ThreadQueue->CaretInfo->Visible = 0;
    ThreadQueue->CaretInfo->Showing = 0;
 
-   IntReleaseWindowObject(WindowObject);
-
    RETURN(TRUE);
 
 CLEANUP:
@@ -282,7 +277,7 @@
    DECLARE_RETURN(UINT);
 
    DPRINT("Enter NtUserGetCaretBlinkTime\n");
-   UserEnterExclusive();
+   UserEnterShared();
 
    RETURN(IntGetCaretBlinkTime());
 
@@ -322,11 +317,11 @@
 }
 
 
-BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject)
+BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window)
 {
    PUSER_MESSAGE_QUEUE ThreadQueue;
 
-   if(WindowObject->OwnerThread != PsGetCurrentThread())
+   if(Window->OwnerThread != PsGetCurrentThread())
    {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return FALSE;
@@ -334,7 +329,7 @@
 
    ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
 
-   if(ThreadQueue->CaretInfo->hWnd != WindowObject->hSelf)
+   if(ThreadQueue->CaretInfo->hWnd != Window->hSelf)
    {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return FALSE;
@@ -342,7 +337,7 @@
 
    if(ThreadQueue->CaretInfo->Visible)
    {
-      IntKillTimer(WindowObject->hSelf, IDCARETTIMER, TRUE);
+      IntKillTimer(Window->hSelf, IDCARETTIMER, TRUE);
 
       co_IntHideCaret(ThreadQueue->CaretInfo);
       ThreadQueue->CaretInfo->Visible = 0;
@@ -358,22 +353,21 @@
 NtUserHideCaret(
    HWND hWnd)
 {
-   PWINDOW_OBJECT WindowObject;
+   PWINDOW_OBJECT Window;
    DECLARE_RETURN(BOOL);
    BOOL ret;
 
    DPRINT("Enter NtUserHideCaret\n");
    UserEnterExclusive();
 
-   WindowObject = IntGetWindowObject(hWnd);
-   if(!WindowObject)
+   if(!(Window = UserGetWindowObject(hWnd)))
    {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       RETURN(FALSE);
    }
 
-   ret = co_UserHideCaret(WindowObject);
-   IntReleaseWindowObject(WindowObject);
+   UserRefObjectCo(Window);
+   ret = co_UserHideCaret(Window);
+   UserDerefObjectCo(Window);
 
    RETURN(ret);
 
@@ -421,22 +415,22 @@
 NtUserShowCaret(
    HWND hWnd)
 {
-   PWINDOW_OBJECT WindowObject;
+   PWINDOW_OBJECT Window;
    DECLARE_RETURN(BOOL);
    BOOL ret;
 
    DPRINT("Enter NtUserShowCaret\n");
    UserEnterExclusive();
 
-   WindowObject = IntGetWindowObject(hWnd);
-   if(!WindowObject)
+   if(!(Window = UserGetWindowObject(hWnd)))
    {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       RETURN(FALSE);
    }
 
-   ret = co_UserShowCaret(WindowObject);
-   IntReleaseWindowObject(WindowObject);
+   UserRefObjectCo(Window);
+   ret = co_UserShowCaret(Window);
+   UserDerefObjectCo(Window);
+
    RETURN(ret);
 
 CLEANUP:

Modified: trunk/reactos/subsys/win32k/ntuser/class.c
--- trunk/reactos/subsys/win32k/ntuser/class.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/class.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -235,22 +235,19 @@
    LPWSTR lpClassName,
    ULONG nMaxCount)
 {
-   PWINDOW_OBJECT WindowObject;
-   LONG Length;
+   PWINDOW_OBJECT Window;
    DECLARE_RETURN(DWORD);
 
    UserEnterShared();
+   DPRINT("Enter NtUserGetClassName\n");   
 
-   WindowObject = IntGetWindowObject(hWnd);
-   if (WindowObject == NULL)
+   if (!(Window = UserGetWindowObject(hWnd)))
    {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       RETURN(0);
    }
-   Length = IntGetClassName(WindowObject, lpClassName, nMaxCount);
-   IntReleaseWindowObject(WindowObject);
-   RETURN(Length);
 
+   RETURN( IntGetClassName(Window, lpClassName, nMaxCount));
+
 CLEANUP:
    DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_);
    UserLeave();

Modified: trunk/reactos/subsys/win32k/ntuser/cursoricon.c
--- trunk/reactos/subsys/win32k/ntuser/cursoricon.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/cursoricon.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -72,35 +72,48 @@
 }
 
 
-
-
-/* temp hack */
-PCURICON_OBJECT FASTCALL UserGetCurIconObject(HANDLE hWnd)
+#if 0
+static
+PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCursor)
 {
-   PCURICON_OBJECT Window = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hWnd, otCursor);
-   if (!Window)
+   PCURICON_OBJECT Cursor;
+   
+   if (!hCursor) return NULL;
+   
+   Cursor = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hCursor, otCursor);
+   if (!Cursor)
    {
       SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
       return NULL;
    }
 
-   ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
-   return Window;
+   ASSERT(USER_BODY_TO_HEADER(Cursor)->RefCount >= 0);
+   return Cursor;
 }
-
-PCURICON_OBJECT FASTCALL
-IntGetCurIconObject(HANDLE Handle)
+#endif
+static
+PCURICON_OBJECT FASTCALL IntGetCurIconObject(HCURSOR hCursor)
 {
-   PCURICON_OBJECT ci = UserGetCurIconObject(Handle);
-   if (ci)
+   PCURICON_OBJECT Cursor;
+   
+   if (!hCursor) return NULL;
+   
+   Cursor = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hCursor, otCursor);
+   if (!Cursor)
    {
-      ASSERT(USER_BODY_TO_HEADER(ci)->RefCount >= 0);
+      SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+      return NULL;
+   }
 
-      USER_BODY_TO_HEADER(ci)->RefCount++;
-   }
-   return ci;
+   ASSERT(USER_BODY_TO_HEADER(Cursor)->RefCount >= 0);
+   
+   USER_BODY_TO_HEADER(Cursor)->RefCount++;
+   
+   return Cursor;
 }
 
+
+
 #define COLORCURSORS_ALLOWED FALSE
 HCURSOR FASTCALL
 IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,

Modified: trunk/reactos/subsys/win32k/ntuser/focus.c
--- trunk/reactos/subsys/win32k/ntuser/focus.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/focus.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -316,25 +316,28 @@
    return hWndPrev;
 }
 
+static
 HWND FASTCALL
-co_IntSetFocusWindow(HWND hWnd)
+co_IntSetFocusWindow(PWINDOW_OBJECT Window)
 {
    HWND hWndPrev = 0;
    PUSER_MESSAGE_QUEUE ThreadQueue;
 
+   ASSERT_REFS_CO(Window);
+
    ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
    ASSERT(ThreadQueue != 0);
 
    hWndPrev = ThreadQueue->FocusWindow;
-   if (hWndPrev == hWnd)
+   if (hWndPrev == Window->hSelf)
    {
       return hWndPrev;
    }
 
-   ThreadQueue->FocusWindow = hWnd;
+   ThreadQueue->FocusWindow = Window->hSelf;
 
-   co_IntSendKillFocusMessages(hWndPrev, hWnd);
-   co_IntSendSetFocusMessages(hWndPrev, hWnd);
+   co_IntSendKillFocusMessages(hWndPrev, Window->hSelf);
+   co_IntSendSetFocusMessages(hWndPrev, Window->hSelf);
 
    return hWndPrev;
 }
@@ -513,18 +516,14 @@
 
 
 
-HWND FASTCALL UserSetFocus(HWND hWnd)
+HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window OPTIONAL)
 {
-   if (hWnd)
+   if (Window)
    {
-      PWINDOW_OBJECT Window;
       PUSER_MESSAGE_QUEUE ThreadQueue;
       HWND hWndPrev, hWndTop;
 
-      if (!(Window = UserGetWindowObject(hWnd)))
-      {
-         return( 0);
-      }
+      ASSERT_REFS_CO(Window);
 
       ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
 
@@ -539,15 +538,17 @@
          return( 0);
       }
 
-      hWndTop = UserGetAncestor(hWnd, GA_ROOT);
+      hWndTop = UserGetAncestor(Window->hSelf, GA_ROOT);
       if (hWndTop != UserGetActiveWindow())
       {
-         PWINDOW_OBJECT WndTops = IntGetWindowObject(hWndTop);
+         PWINDOW_OBJECT WndTops = UserGetWindowObject(hWndTop);
+         
+         UserRefObjectCo(WndTops);
          co_IntSetActiveWindow(WndTops);
-         IntReleaseWindowObject(WndTops);//temp hack
+         UserDerefObjectCo(WndTops);
       }
 
-      hWndPrev = co_IntSetFocusWindow(hWnd);
+      hWndPrev = co_IntSetFocusWindow(Window);
 
       return( hWndPrev);
    }
@@ -565,13 +566,24 @@
 HWND STDCALL
 NtUserSetFocus(HWND hWnd)
 {
+   PWINDOW_OBJECT Window;
    DECLARE_RETURN(HWND);
+   HWND ret;
 
    DPRINT("Enter NtUserSetFocus(%x)\n", hWnd);
    UserEnterExclusive();
 
-   RETURN(UserSetFocus(hWnd));
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN(NULL);
+   }
 
+   UserRefObjectCo(Window);
+   ret = co_UserSetFocus(Window);
+   UserDerefObjectCo(Window);
+   
+   RETURN(ret);
+
 CLEANUP:
    DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_);
    UserLeave();

Modified: trunk/reactos/subsys/win32k/ntuser/hotkey.c
--- trunk/reactos/subsys/win32k/ntuser/hotkey.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/hotkey.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -42,7 +42,6 @@
 InitHotKeys(PWINSTATION_OBJECT WinStaObject)
 {
    InitializeListHead(&WinStaObject->HotKeyListHead);
-   ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
 
    return STATUS_SUCCESS;
 }
@@ -72,8 +71,6 @@
       return FALSE;
    }
 
-   IntLockHotKeys(WinStaObject);
-
    Entry = WinStaObject->HotKeyListHead.Flink;
    while (Entry != &WinStaObject->HotKeyListHead)
    {
@@ -92,7 +89,6 @@
          if (id != NULL)
             *id = HotKeyItem->id;
 
-         IntUnLockHotKeys(WinStaObject);
 
          return TRUE;
       }
@@ -100,8 +96,6 @@
       Entry = Entry->Flink;
    }
 
-   IntUnLockHotKeys(WinStaObject);
-
    return FALSE;
 }
 
@@ -119,8 +113,6 @@
    if(!WinStaObject)
       return;
 
-   IntLockHotKeys(WinStaObject);
-
    Entry = WinStaObject->HotKeyListHead.Flink;
    while (Entry != &WinStaObject->HotKeyListHead)
    {
@@ -135,7 +127,6 @@
       }
    }
 
-   IntUnLockHotKeys(WinStaObject);
 }
 
 
@@ -152,8 +143,6 @@
    if(!WinStaObject)
       return;
 
-   IntLockHotKeys(WinStaObject);
-
    Entry = WinStaObject->HotKeyListHead.Flink;
    while (Entry != &WinStaObject->HotKeyListHead)
    {
@@ -168,7 +157,6 @@
       }
    }
 
-   IntUnLockHotKeys(WinStaObject);
 }
 
 
@@ -220,14 +208,11 @@
    }
    else
    {
-      Window = IntGetWindowObject(hWnd);
-      if(!Window)
+      if(!(Window = UserGetWindowObject(hWnd)))
       {
-         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
          RETURN( FALSE);
       }
       HotKeyThread = Window->OwnerThread;
-      IntReleaseWindowObject(Window);
    }
 
 
@@ -239,19 +224,15 @@
       RETURN( FALSE);
    }
 
-   IntLockHotKeys(WinStaObject);
-
    /* Check for existing hotkey */
    if (IsHotKey (WinStaObject, fsModifiers, vk))
    {
-      IntUnLockHotKeys(WinStaObject);
       RETURN( FALSE);
    }
 
    HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
    if (HotKeyItem == NULL)
    {
-      IntUnLockHotKeys(WinStaObject);
       RETURN( FALSE);
    }
 
@@ -264,8 +245,6 @@
    InsertHeadList (&WinStaObject->HotKeyListHead,
                    &HotKeyItem->ListEntry);
 
-   IntUnLockHotKeys(WinStaObject);
-
    RETURN( TRUE);
 
 CLEANUP:
@@ -288,10 +267,8 @@
    DPRINT("Enter NtUserUnregisterHotKey\n");
    UserEnterExclusive();
 
-   Window = IntGetWindowObject(hWnd);
-   if(!Window)
+   if(!(Window = UserGetWindowObject(hWnd)))
    {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       RETURN( FALSE);
    }
 
@@ -300,12 +277,9 @@
 
    if(!WinStaObject)
    {
-      IntReleaseWindowObject(Window);
       RETURN( FALSE);
    }
 
-   IntLockHotKeys(WinStaObject);
-
    Entry = WinStaObject->HotKeyListHead.Flink;
    while (Entry != &WinStaObject->HotKeyListHead)
    {
@@ -317,18 +291,13 @@
       {
          RemoveEntryList (&HotKeyItem->ListEntry);
          ExFreePool (HotKeyItem);
-         IntUnLockHotKeys(WinStaObject);
 
-         IntReleaseWindowObject(Window);
          RETURN( TRUE);
       }
 
       Entry = Entry->Flink;
    }
 
-   IntUnLockHotKeys(WinStaObject);
-
-   IntReleaseWindowObject(Window);
    RETURN( FALSE);
 
 CLEANUP:

Modified: trunk/reactos/subsys/win32k/ntuser/input.c
--- trunk/reactos/subsys/win32k/ntuser/input.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/input.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -35,7 +35,7 @@
 #define NDEBUG
 #include <debug.h>
 
-extern BYTE QueueKeyStateTable[];
+extern BYTE gQueueKeyStateTable[];
 
 /* GLOBALS *******************************************************************/
 
@@ -377,7 +377,7 @@
    PWINDOW_OBJECT Window;
    MSG Mesg;
 
-   if (!(Window = IntGetWindowObject(InputWindowStation->ShellWindow)))
+   if (!(Window = UserGetWindowObject(InputWindowStation->ShellWindow)))
    {
       DPRINT1("Couldn't find window to send Windows key message!\n");
       return;
@@ -390,8 +390,6 @@
 
    /* The QS_HOTKEY is just a guess */
    MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
-
-   ObmDereferenceObject(Window);
 }
 
 STATIC VOID STDCALL
@@ -1026,42 +1024,42 @@
    Msg.message = 0;
    if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
    {
-      QueueKeyStateTable[VK_LBUTTON] |= 0xc0;
+      gQueueKeyStateTable[VK_LBUTTON] |= 0xc0;
       Msg.message = SwapBtnMsg[0][SwapButtons];
       CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
       MsqInsertSystemMessage(&Msg);
    }
    else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
    {
-      QueueKeyStateTable[VK_LBUTTON] &= ~0x80;
+      gQueueKeyStateTable[VK_LBUTTON] &= ~0x80;
       Msg.message = SwapBtnMsg[1][SwapButtons];
       CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
       MsqInsertSystemMessage(&Msg);
    }
    if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
    {
-      QueueKeyStateTable[VK_MBUTTON] |= 0xc0;
+      gQueueKeyStateTable[VK_MBUTTON] |= 0xc0;
       Msg.message = WM_MBUTTONDOWN;
       CurInfo->ButtonsDown |= MK_MBUTTON;
       MsqInsertSystemMessage(&Msg);
    }
    else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
    {
-      QueueKeyStateTable[VK_MBUTTON] &= ~0x80;
+      gQueueKeyStateTable[VK_MBUTTON] &= ~0x80;
       Msg.message = WM_MBUTTONUP;
       CurInfo->ButtonsDown &= ~MK_MBUTTON;
       MsqInsertSystemMessage(&Msg);
    }
    if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
    {
-      QueueKeyStateTable[VK_RBUTTON] |= 0xc0;
+      gQueueKeyStateTable[VK_RBUTTON] |= 0xc0;
       Msg.message = SwapBtnMsg[0][!SwapButtons];
       CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
       MsqInsertSystemMessage(&Msg);
    }
    else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
    {
-      QueueKeyStateTable[VK_RBUTTON] &= ~0x80;
+      gQueueKeyStateTable[VK_RBUTTON] &= ~0x80;
       Msg.message = SwapBtnMsg[1][!SwapButtons];
       CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
       MsqInsertSystemMessage(&Msg);
@@ -1079,14 +1077,14 @@
       Msg.message = WM_XBUTTONDOWN;
       if(mi->mouseData & XBUTTON1)
       {
-         QueueKeyStateTable[VK_XBUTTON1] |= 0xc0;
+         gQueueKeyStateTable[VK_XBUTTON1] |= 0xc0;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
          CurInfo->ButtonsDown |= XBUTTON1;
          MsqInsertSystemMessage(&Msg);
       }
       if(mi->mouseData & XBUTTON2)
       {
-         QueueKeyStateTable[VK_XBUTTON2] |= 0xc0;
+         gQueueKeyStateTable[VK_XBUTTON2] |= 0xc0;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
          CurInfo->ButtonsDown |= XBUTTON2;
          MsqInsertSystemMessage(&Msg);
@@ -1097,14 +1095,14 @@
       Msg.message = WM_XBUTTONUP;
       if(mi->mouseData & XBUTTON1)
       {
-         QueueKeyStateTable[VK_XBUTTON1] &= ~0x80;
+         gQueueKeyStateTable[VK_XBUTTON1] &= ~0x80;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
          CurInfo->ButtonsDown &= ~XBUTTON1;
          MsqInsertSystemMessage(&Msg);
       }
       if(mi->mouseData & XBUTTON2)
       {
-         QueueKeyStateTable[VK_XBUTTON2] &= ~0x80;
+         gQueueKeyStateTable[VK_XBUTTON2] &= ~0x80;
          Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
          CurInfo->ButtonsDown &= ~XBUTTON2;
          MsqInsertSystemMessage(&Msg);

Modified: trunk/reactos/subsys/win32k/ntuser/keyboard.c
--- trunk/reactos/subsys/win32k/ntuser/keyboard.c	2005-09-08 15:51:44 UTC (rev 17742)
+++ trunk/reactos/subsys/win32k/ntuser/keyboard.c	2005-09-08 16:18:51 UTC (rev 17743)
@@ -49,24 +49,16 @@
 /* From kbdxx.c -- Key changes with numlock */
 #define KNUMP         0x400
 
-/* Lock the keyboard state to prevent unusual concurrent access */
-FAST_MUTEX QueueStateLock;
 
-BYTE QueueKeyStateTable[256];
+BYTE gQueueKeyStateTable[256];
 
-#define IntLockQueueState \
-  ExAcquireFastMutex(&QueueStateLock)
 
-#define IntUnLockQueueState \
-  ExReleaseFastMutex(&QueueStateLock)
-
 /* FUNCTIONS *****************************************************************/
 
 /* Initialization -- Right now, just zero the key state and init the lock */
 NTSTATUS FASTCALL InitKeyboardImpl(VOID)
 {
-   ExInitializeFastMutex(&QueueStateLock);
-   RtlZeroMemory(&QueueKeyStateTable,0x100);
+   RtlZeroMemory(&gQueueKeyStateTable,0x100);
    return STATUS_SUCCESS;
 }
 
@@ -93,7 +85,7 @@
    if (vk == VK_CAPITAL || vk == VK_NUMLOCK)
    {
       if (down)
-         QueueKeyStateTable[vk] ^= KS_LOCK_BIT;
+         gQueueKeyStateTable[vk] ^= KS_LOCK_BIT;
    }
 
    if (ext && vk == VK_LSHIFT)
@@ -104,46 +96,46 @@
       vk = VK_RMENU;
 
    if (down)
-      QueueKeyStateTable[vk] |= KS_DOWN_BIT;
+      gQueueKeyStateTable[vk] |= KS_DOWN_BIT;
    else
-      QueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
+      gQueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
 
    if (vk == VK_LSHIFT || vk == VK_RSHIFT)
    {
-      if ((QueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
-            (QueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
+      if ((gQueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
+            (gQueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
       {
-         QueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
+         gQueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
       }
       else
       {
-         QueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
+         gQueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
       }
    }
 
    if (vk == VK_LCONTROL || vk == VK_RCONTROL)
    {
-      if ((QueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
-            (QueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
+      if ((gQueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
+            (gQueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
       {
-         QueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
+         gQueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
       }
       else
       {
-         QueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
+         gQueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
       }
    }
 
    if (vk == VK_LMENU || vk == VK_RMENU)
    {
-      if ((QueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
-            (QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
+      if ((gQueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
+            (gQueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
       {
-         QueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
+         gQueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
       }
       else
       {
-         QueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK;
+         gQueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK;
       }
    }
 }
@@ -351,13 +343,12 @@
 {
    DWORD ret = 0;
 
-   IntLockQueueState;
    if( key < 0x100 )
    {
-      ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
-            (QueueKeyStateTable[key] & KS_LOCK_BIT);
+      ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
+            (gQueueKeyStateTable[key] & KS_LOCK_BIT);
    }
-   IntUnLockQueueState;
+
    return ret;
 }
 
@@ -386,13 +377,12 @@
 {
    DWORD ret = 0;
 
-   IntLockQueueState;
    if( key < 0x100 )
    {
-      ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
-            (QueueKeyStateTable[key] & KS_LOCK_BIT);
+      ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
+            (gQueueKeyStateTable[key] & KS_LOCK_BIT);
    }
-   IntUnLockQueueState;
+
    return ret;
 }
 
@@ -434,7 +424,6 @@
    }
    else
    {
-      IntLockQueueState;
       ToUnicodeResult = ToUnicodeInner( wVirtKey,
                                         wScanCode,
                                         lpKeyState,
@@ -443,7 +432,6 @@
                                         wFlags,
                                         PsGetWin32Thread() ?
                                         PsGetWin32Thread()->KeyboardLayout : 0 );
-      IntUnLockQueueState;
    }
 
    return ToUnicodeResult;
@@ -458,7 +446,7 @@
 {
    return ToUnicodeEx( wVirtKey,
                        wScanCode,
-                       QueueKeyStateTable,
+                       gQueueKeyStateTable,
                        pwszBuff,
                        cchBuff,
                        wFlags,
@@ -735,14 +723,12 @@
 
    ScanCode = (lpMsg->lParam >> 16) & 0xff;
 
-   IntLockQueueState;
-
    /* All messages have to contain the cursor point. */
    IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation,
                         &NewMsg.pt);
 
    UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff,
-                           QueueKeyStateTable, wp, 2, 0,
+                           gQueueKeyStateTable, wp, 2, 0,
                            keyLayout );
 
    if (UState == 1)
@@ -797,7 +783,6 @@
       Result = TRUE;
    }
 
-   IntUnLockQueueState;
    return Result;
 }
 
@@ -807,33 +792,47 @@
    LPBYTE lpKeyState)
 {
    BOOL Result = TRUE;
-
-   IntLockQueueState;
+   DECLARE_RETURN(DWORD);
+   
+   DPRINT("Enter NtUserGetKeyboardState\n");
+   UserEnterShared();
+   
    if (lpKeyState)
    {
-      if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, QueueKeyStateTable, 256)))
+      if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, gQueueKeyStateTable, 256)))
          Result = FALSE;
    }
-   IntUnLockQueueState;
-   return Result;
+
+   RETURN(Result);
+   
+CLEANUP:
+   DPRINT("Leave NtUserGetKeyboardState, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 STDCALL
-NtUserSetKeyboardState(
-   LPBYTE lpKeyState)
+NtUserSetKeyboardState(LPBYTE lpKeyState)
 {
    BOOL Result = TRUE;
+   DECLARE_RETURN(DWORD);
+   
+   DPRINT("Enter NtUserSetKeyboardState\n");
+   UserEnterExclusive();
 
-   IntLockQueueState;
    if (lpKeyState)
    {
-      if(! NT_SUCCESS(MmCopyFromCaller(QueueKeyStateTable, lpKeyState, 256)))
+      if(! NT_SUCCESS(MmCopyFromCaller(gQueueKeyStateTable, lpKeyState, 256)))
          Result = FALSE;
    }
-   IntUnLockQueueState;
+   
[truncated at 1000 lines; 1785 more skipped]