Commit in reactos on win32k_user_rewrite
include/win32k/ntuser.h+22-171.137 -> 1.137.4.1
ntoskrnl/include/internal/ex.h+1-11.39.2.2 -> 1.39.2.2.2.1
subsys/win32k/eng/mouse.c+37-181.76 -> 1.76.2.1
subsys/win32k/include/internal.h+1009added 1.1.4.1
                     /misc.h+45added 1.1.4.1
                     /callback.h+1-11.18 -> 1.18.8.1
                     /object.h+50-641.24 -> 1.24.4.1
                     /tags.h+11.5 -> 1.5.12.1
                     /accelerator.h-241.1 removed
                     /caret.h-371.4 removed
                     /class.h-811.24 removed
                     /cleanup.h-201.4 removed
                     /clipboard.h-91.1 removed
                     /cursoricon.h-741.8 removed
                     /dce.h-581.14 removed
                     /desktop.h-671.8 removed
                     /focus.h-251.4 removed
                     /hook.h-411.3 removed
                     /hotkey.h-471.4 removed
                     /input.h-201.7 removed
                     /menu.h-1271.29 removed
                     /mouse.h-301.13 removed
                     /msgqueue.h-2441.38 removed
                     /painting.h-261.14 removed
                     /prop.h-241.7 removed
                     /scroll.h-221.5 removed
                     /timer.h-181.5 removed
                     /vis.h-271.6 removed
                     /window.h-2291.59 removed
                     /winpos.h-391.14 removed
                     /winsta.h-561.25 removed
subsys/win32k/main/dllmain.c+57-681.76 -> 1.76.12.1
subsys/win32k/makefile+3-31.101 -> 1.101.4.1
             /w32k.h+13-331.4 -> 1.4.4.1
subsys/win32k/misc/object.c+124-3711.12 -> 1.12.8.1
subsys/win32k/ntuser/accelerator.c+1-4671.10 -> 1.10.12.1
                    /callback.c+45-281.25 -> 1.25.8.1
                    /caret.c+1-3891.12 -> 1.12.12.1
                    /class.c+151-3911.59 -> 1.59.8.1
                    /clipboard.c-2841.11 -> 1.11.8.1
                    /desktop.c+59-391.17 -> 1.17.2.1
                    /focus.c+327-4021.24 -> 1.24.4.1
                    /guicheck.c+4-81.19 -> 1.19.12.1
                    /hook.c+2-6211.8 -> 1.8.12.1
                    /hotkey.c+1-2911.10 -> 1.10.12.1
                    /input.c+28-1061.36 -> 1.36.4.1
                    /keyboard.c+3-91.31 -> 1.31.2.1
                    /menu.c+1-19641.55 -> 1.55.12.1
                    /message.c+200-8911.71 -> 1.71.4.1
                    /metric.c+48-501.21 -> 1.21.12.1
                    /misc.c+21-8311.83 -> 1.83.2.1
                    /msgqueue.c+61-1121.100 -> 1.100.12.1
                    /painting.c+187-3811.84 -> 1.84.2.1
                    /prop.c+1-1511.11 -> 1.11.12.1
                    /scrollbar.c+37-2051.34 -> 1.34.4.1
                    /stubs.c+1469-91.45 -> 1.45.12.1
                    /timer.c+15-741.33 -> 1.33.4.1
                    /vis.c+3-141.29 -> 1.29.12.1
                    /windc.c+45-1511.66 -> 1.66.12.1
                    /window.c+689-28361.244 -> 1.244.2.1
                    /winpos.c+275-3671.120 -> 1.120.2.1
                    /winsta.c+6-161.64 -> 1.64.8.1
subsys/win32k/objects/cursoricon.c+254-8911.63 -> 1.63.2.1
+5297-13899
2 added + 23 removed + 38 modified, total 63 files
created a local branch so i don't have to sync up the other changes all the time

reactos/include/win32k
ntuser.h 1.137 -> 1.137.4.1
diff -u -r1.137 -r1.137.4.1
--- ntuser.h	24 Jun 2004 09:44:05 -0000	1.137
+++ ntuser.h	15 Jul 2004 20:07:15 -0000	1.137.4.1
@@ -5,14 +5,14 @@
 
 #define WM_SYSTIMER 280
 
-ULONG STDCALL
-NtUserGetSystemMetrics(ULONG Index);
+INT STDCALL
+NtUserGetSystemMetrics(INT Index);
 
 DWORD STDCALL
-NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi);
+NtUserGetClassLong(HWND hWnd, INT Offset, BOOL Ansi);
 
 LONG STDCALL
-NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi);
+NtUserGetWindowLong(HWND hWnd, INT Index, BOOL Ansi);
 
 INT STDCALL
 NtUserReleaseDC(HWND hWnd, HDC hDc);
@@ -386,8 +386,8 @@
   HANDLE Handle,
   DWORD Unknown);
 
-BOOLEAN STDCALL
-NtUserDestroyWindow(HWND Wnd);
+BOOL STDCALL
+NtUserDestroyWindow(HWND hWnd);
 
 typedef struct tagNTUSERDISPATCHMESSAGEINFO
 {
@@ -836,7 +836,7 @@
   HRGN hRgn,
   BOOL bErase);
 
-DWORD
+HDC
 STDCALL
 NtUserGetWindowDC(
   HWND hWnd);
@@ -894,20 +894,25 @@
   LPWSTR lpString,
   INT nMaxCount);
 
-DWORD
+BOOL
 STDCALL
 NtUserInvalidateRect(
-HWND hWnd,
-CONST RECT *lpRect,
-BOOL bErase);
+  HWND hWnd,
+  CONST RECT *lpRect,
+  BOOL bErase);
 
-DWORD
+BOOL
 STDCALL
-  NtUserInvalidateRgn(
+NtUserInvalidateRgn(
   HWND hWnd,
   HRGN hRgn,
   BOOL bErase);
 
+BOOL
+STDCALL
+NtUserValidateRgn(
+  HWND hWnd,
+  HRGN hRgn);
 
 BOOL
 STDCALL
@@ -1240,7 +1245,7 @@
 DWORD STDCALL
 NtUserSetClassLong(
   HWND  hWnd,
-  DWORD Offset,
+  INT Offset,
   LONG  dwNewLong,
   BOOL  Ansi );
 
@@ -1444,7 +1449,7 @@
 STDCALL
 NtUserSetWindowLong(
   HWND hWnd,
-  DWORD Index,
+  INT Index,
   LONG NewValue,
   BOOL Ansi);
 
@@ -1655,7 +1660,7 @@
 NtUserValidateHandleSecure(
   DWORD Unknown0);
 
-VOID STDCALL
+BOOL STDCALL
 NtUserValidateRect(HWND Wnd, const RECT* Rect);
 
 
@@ -1712,7 +1717,7 @@
 NtUserGetParent(HWND hWnd);
 
 HWND STDCALL
-NtUserGetWindow(HWND hWnd, UINT Relationship);
+NtUserGetWindow(HWND hWnd, UINT uCmd);
 
 HWND STDCALL
 NtUserGetLastActivePopup(HWND hWnd);

reactos/ntoskrnl/include/internal
ex.h 1.39.2.2 -> 1.39.2.2.2.1
diff -u -r1.39.2.2 -r1.39.2.2.2.1
--- ex.h	12 Jul 2004 19:54:46 -0000	1.39.2.2
+++ ex.h	15 Jul 2004 20:07:16 -0000	1.39.2.2.2.1
@@ -51,7 +51,7 @@
   PUSER_MESSAGE_QUEUE ActiveMessageQueue;
   /* Rectangle of the work area */
   RECT WorkArea;
-  /* Handle of the desktop window. */
+  /* Pointer of the desktop window. */
   PWINDOW_OBJECT DesktopWindow;
   PWINDOW_OBJECT PrevActiveWindow;
 #else

reactos/subsys/win32k/eng
mouse.c 1.76 -> 1.76.2.1
diff -u -r1.76 -r1.76.2.1
--- mouse.c	14 Jul 2004 20:48:57 -0000	1.76
+++ mouse.c	15 Jul 2004 20:07:16 -0000	1.76.2.1
@@ -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: mouse.c,v 1.76 2004/07/14 20:48:57 navaraf Exp $
+/* $Id: mouse.c,v 1.76.2.1 2004/07/15 20:07:16 weiden Exp $
  *
  * PROJECT:          ReactOS kernel
  * PURPOSE:          Mouse
@@ -60,12 +60,12 @@
     CurInfo->x = BitmapObj->SurfObj.sizlBitmap.cx / 2;
     CurInfo->y = BitmapObj->SurfObj.sizlBitmap.cy / 2;
     ExReleaseFastMutex(&CurInfo->CursorMutex);
-
+    
     GdiDev = GDIDEV(&BitmapObj->SurfObj);
     BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
     DC_UnlockDc( hDisplayDC );
-
-    IntSetCursor(InputWindowStation, NULL, TRUE);
+    
+    IntSetCursor(NULL, TRUE);
     
     CurInfo->Enabled = (SPS_ACCEPT_EXCLUDE == GdiDev->PointerStatus ||
                         SPS_ACCEPT_NOEXCLUDE == GdiDev->PointerStatus);
@@ -78,7 +78,7 @@
   {
     if(IntGetWindowStationObject(InputWindowStation))
     {
-       IntSetCursor(InputWindowStation, NULL, TRUE);
+       IntSetCursor(NULL, TRUE);
        CurInfo->Enabled = FALSE;
        CurInfo->CursorClipInfo.IsClipped = FALSE;
        ObDereferenceObject(InputWindowStation);
@@ -98,7 +98,7 @@
   LONG tmp;
   PSYSTEM_CURSORINFO CurInfo;
   BOOL MouseEnabled = FALSE;
-  PCURICON_OBJECT Cursor;
+  PCURSOR_OBJECT Cursor;
 
 
   /* Mouse is not allowed to move if GDI is busy drawing */
@@ -161,9 +161,9 @@
         }
       CurInfo->SafetySwitch = TRUE;
       if (GDIDEVFUNCS(SurfObj).MovePointer)
-         GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, -1, -1, NULL);
+        GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, -1, -1, NULL);
       else
-         EngMovePointer(SurfObj, -1, -1, NULL);
+        EngMovePointer(SurfObj, -1, -1, NULL);
       ExReleaseFastMutex(&CurInfo->CursorMutex);
     }
     
@@ -231,9 +231,9 @@
           return FALSE;
         }
       if (GDIDEVFUNCS(SurfObj).MovePointer)
-         GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
+        GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
       else
-         EngMovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
+        EngMovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
       SetPointerRect(CurInfo, &PointerRect);
       CurInfo->SafetySwitch = FALSE;
     }
@@ -591,13 +591,18 @@
       HPALETTE BWPalette, DestPalette;
       ULONG BWColors[] = {0, 0xFFFFFF};
       PDC Dc;
+      PPALGDI PalObj;
+      LONG DestMode;
 
       BWPalette = EngCreatePalette(PAL_INDEXED, sizeof(BWColors) / sizeof(ULONG),
          BWColors, 0, 0, 0);
       Dc = DC_LockDc(IntGetScreenDC());
       DestPalette = Dc->w.hPalette;
+      PalObj = PALETTE_LockPalette(DestPalette);
+      DestMode = PalObj->Mode;
+      PALETTE_UnlockPalette(DestPalette);
       DC_UnlockDc(IntGetScreenDC());
-      ppdev->PointerXlateObject = IntEngCreateXlate(0, PAL_INDEXED,
+      ppdev->PointerXlateObject = IntEngCreateXlate(DestMode, PAL_INDEXED,
          DestPalette, BWPalette);
       EngDeletePalette(BWPalette);
    }
@@ -619,13 +624,27 @@
 
       switch (pso->iBitmapFormat)
       {
-         case BMF_1BPP: lDelta = Size.cx >> 3; break;
-         case BMF_4BPP: lDelta = Size.cx >> 1; break;
-         case BMF_8BPP: lDelta = Size.cx; break;
-         case BMF_16BPP: lDelta = Size.cx << 1; break;
-         case BMF_24BPP: lDelta = Size.cx * 3; break; 
-         case BMF_32BPP: lDelta = Size.cx << 2; break;
-         default: lDelta = 0; break;
+         case BMF_1BPP:
+	   lDelta = Size.cx >> 3;
+	   break;
+         case BMF_4BPP:
+	   lDelta = Size.cx >> 1;
+	   break;
+         case BMF_8BPP:
+	   lDelta = Size.cx;
+	   break;
+         case BMF_16BPP:
+	   lDelta = Size.cx << 1;
+	   break;
+         case BMF_24BPP:
+	   lDelta = Size.cx * 3;
+	   break; 
+         case BMF_32BPP:
+	   lDelta = Size.cx << 2;
+	   break;
+         default:
+	   lDelta = 0;
+	   break;
       }
 
       ppdev->PointerSaveSurface = (HSURF)EngCreateBitmap(

reactos/subsys/win32k/include
internal.h added at 1.1.4.1
diff -N internal.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ internal.h	15 Jul 2004 20:07:16 -0000	1.1.4.1
@@ -0,0 +1,1009 @@
+#ifndef _NTUSER_H
+#define _NTUSER_H
+
+/*
+ * Forward declarations to win32k internal structures and types
+ */
+struct _ACCELERATOR_TABLE;
+struct _THRDCARETINFO;
+struct _CLASS_OBJECT;
+struct _CURSOR_OBJECT;
+struct _CURSORCLIP_INFO;
+struct _SYSTEM_CURSORINFO;
+struct tagDCE;
+struct tagHOOK;
+struct tagHOOKTABLE;
+struct _HOT_KEY_ITEM;
+struct _MENU_ITEM;
+struct _MENU_OBJECT;
+struct _USER_MESSAGE;
+struct _USER_SENT_MESSAGE;
+struct _USER_SENT_MESSAGE_NOTIFY;
+struct _USER_MESSAGE_QUEUE;
+struct _PROPERTY;
+struct _WINDOW_SCROLLINFO;
+struct _MSG_TIMER_ENTRY;
+struct _INTERNALPOS;
+struct _INTERNAL_WINDOWPOS;
+struct _DOSENDMESSAGE;
+struct tagMSGMEMORY;
+
+/*
+ * Pointer types
+ */
+
+typedef struct _ACCELERATOR_TABLE *PACCELERATOR_TABLE;
+typedef struct _THRDCARETINFO *PTHRDCARETINFO;
+typedef struct _CLASS_OBJECT *PCLASS_OBJECT;
+typedef struct _CURSOR_OBJECT *PCURSOR_OBJECT;
+typedef struct _CURSORCLIP_INFO *PCURSORCLIP_INFO;
+typedef struct _SYSTEM_CURSORINFO *PSYSTEM_CURSORINFO;
+typedef struct tagDCE *PDCE;
+typedef struct tagHOOK *PHOOK;
+typedef struct tagHOOKTABLE *PHOOKTABLE;
+typedef struct _HOT_KEY_ITEM *PHOT_KEY_ITEM;
+typedef struct _MENU_ITEM *PMENU_ITEM;
+typedef struct _MENU_OBJECT *PMENU_OBJECT;
+typedef struct _USER_MESSAGE *PUSER_MESSAGE;
+typedef struct _USER_SENT_MESSAGE *PUSER_SENT_MESSAGE;
+typedef struct _USER_SENT_MESSAGE_NOTIFY *PUSER_SENT_MESSAGE_NOTIFY;
+typedef struct _USER_MESSAGE_QUEUE *PUSER_MESSAGE_QUEUE;
+typedef struct _PROPERTY *PPROPERTY;
+typedef struct _WINDOW_SCROLLINFO *PWINDOW_SCROLLINFO;
+typedef struct _MSG_TIMER_ENTRY *PMSG_TIMER_ENTRY;
+typedef struct _INTERNALPOS *PINTERNALPOS;
+typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT;
+typedef struct _INTERNAL_WINDOWPOS *PINTERNAL_WINDOWPOS;
+typedef struct _DOSENDMESSAGE *PDOSENDMESSAGE;
+typedef struct tagMSGMEMORY *PMSGMEMORY;
+
+/*
+ * Other types
+ */
+
+typedef HANDLE HDCE;
+
+/*
+ * Include the ex.h here, it contains the definitions for
+ * the WINSTATION_OBJECT and DESKTOP_OBJECT structures
+ */
+
+#include <internal/ex.h>
+
+/*
+ * win32k internal
+ */
+
+/* ACCELERATORS ***************************************************************/
+
+typedef struct _ACCELERATOR_TABLE
+{
+  int Count;
+  LPACCEL Table;
+} ACCELERATOR_TABLE;
+
+/* CARETS *********************************************************************/
+
+#define IDCARETTIMER (0xffff)
+
+/* a copy of this structure is in lib/user32/include/user32.h */
+typedef struct _THRDCARETINFO
+{
+  PWINDOW_OBJECT Window;
+  HBITMAP Bitmap;
+  POINT Pos;
+  SIZE Size;
+  BYTE Visible;
+  BYTE Showing;
+} THRDCARETINFO;
+
+/* WINDOW CLASSES *************************************************************/
+
+#define IS_ATOM(x) \
+  (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
+
+#define ClassReferenceObject(ClassObj) \
+  InterlockedIncrement((LONG*)(ClassObj))
+
+#define ClassDereferenceObject(ClassObj) \
+  if(InterlockedDecrement((LONG*)((ClassObj)->RefCount)) == 0) \
+  { \
+    ExFreePool(ClassObj); \
+  }
+
+typedef struct _CLASS_OBJECT
+{
+  LONG    RefCount;
+  
+  UINT    cbSize;
+  UINT    style;
+  WNDPROC lpfnWndProcA;
+  WNDPROC lpfnWndProcW;
+  int     cbClsExtra;
+  int     cbWndExtra;
+  HANDLE  hInstance;
+  HICON   hIcon;
+  HCURSOR hCursor;
+  HBRUSH  hbrBackground;
+  UNICODE_STRING lpszMenuName;
+  RTL_ATOM Atom;
+  HICON   hIconSm;
+  BOOL Unicode;
+  BOOL Global;
+  LIST_ENTRY ListEntry;
+  PBYTE   ExtraData;
+  /* list of windows */
+  LIST_ENTRY ClassWindowsListHead;
+} CLASS_OBJECT;
+
+PCLASS_OBJECT FASTCALL IntCreateClass(CONST WNDCLASSEXW *lpwcx,
+                                      DWORD Flags,
+                                      WNDPROC wpExtra,
+                                      PUNICODE_STRING MenuName,
+                                      RTL_ATOM Atom);
+PCLASS_OBJECT FASTCALL IntRegisterClass(CONST WNDCLASSEXW *lpwcx, PUNICODE_STRING ClassName, 
+                                        PUNICODE_STRING MenuName, WNDPROC wpExtra, DWORD Flags);
+ULONG         FASTCALL IntGetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, BOOL Ansi);
+ULONG         FASTCALL IntSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL Ansi);
+BOOL          FASTCALL IntGetClassName(PWINDOW_OBJECT WindowObject, PUNICODE_STRING ClassName, ULONG nMaxCount);
+BOOL          FASTCALL IntReferenceClassByNameOrAtom(PCLASS_OBJECT *Class, PUNICODE_STRING ClassNameOrAtom, HINSTANCE hInstance);
+BOOL          FASTCALL IntReferenceClassByName(PCLASS_OBJECT *Class, PUNICODE_STRING ClassName, HINSTANCE hInstance);
+BOOL          FASTCALL IntReferenceClassByAtom(PCLASS_OBJECT* Class, RTL_ATOM Atom, HINSTANCE hInstance);
+
+/* CURSORS AND ICONS **********************************************************/
+
+#define IntGetSysCursorInfo(WinStaObj) \
+  (PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor)
+
+#define IntLockProcessCursorIcons(W32Process) \
+  ExAcquireFastMutex(&W32Process->CursorIconListLock)
+
+#define IntUnLockProcessCursorIcons(W32Process) \
+  ExReleaseFastMutex(&W32Process->CursorIconListLock)
+
+typedef struct _CURSOR_OBJECT
+{
+  HANDLE Handle;
+  LIST_ENTRY ListEntry;
+  PW32PROCESS Process;
+  HMODULE hModule;
+  HRSRC hRsrc;
+  HRSRC hGroupRsrc;
+  SIZE Size;
+  BYTE Shadow;
+  ICONINFO IconInfo;
+} CURSOR_OBJECT;
+
+typedef struct _CURSORCLIP_INFO
+{
+  BOOL IsClipped;
+  UINT Left;
+  UINT Top;
+  UINT Right;
+  UINT Bottom;
+} CURSORCLIP_INFO;
+
+typedef struct _SYSTEM_CURSORINFO
+{
+  BOOL Enabled;
+  BOOL SwapButtons;
+  UINT ButtonsDown;
+  LONG x, y;
+  BOOL SafetySwitch;
+  UINT SafetyRemoveCount;
+  LONG PointerRectLeft;
+  LONG PointerRectTop;
+  LONG PointerRectRight;
+  LONG PointerRectBottom;
+  FAST_MUTEX CursorMutex;
+  CURSORCLIP_INFO CursorClipInfo;
+  PCURSOR_OBJECT CurrentCursorObject;
+  BYTE ShowingCursor;
+  UINT DblClickSpeed;
+  UINT DblClickWidth;
+  UINT DblClickHeight;
+  DWORD LastBtnDown;
+  LONG LastBtnDownX;
+  LONG LastBtnDownY;
+  HANDLE LastClkWnd;
+} SYSTEM_CURSORINFO;
+
+PCURSOR_OBJECT FASTCALL IntSetCursor(PCURSOR_OBJECT NewCursor, BOOL ForceChange);
+PCURSOR_OBJECT FASTCALL IntCreateCursorObject(HANDLE *Handle);
+VOID           FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process);
+VOID           FASTCALL IntGetCursorIconInfo(PCURSOR_OBJECT Cursor, PICONINFO IconInfo);
+BOOL           FASTCALL IntGetCursorIconSize(PCURSOR_OBJECT Cursor, BOOL *fIcon, SIZE *Size);
+BOOL           FASTCALL IntGetCursorInfo(PCURSORINFO pci);
+BOOL           FASTCALL IntDestroyCursorObject(PCURSOR_OBJECT Object, BOOL RemoveFromProcess);
+PCURSOR_OBJECT FASTCALL IntFindExistingCursorObject(HMODULE hModule, HRSRC hRsrc, LONG cx, LONG cy);
+VOID           FASTCALL IntGetClipCursor(RECT *lpRect);
+VOID           FASTCALL IntSetCursorIconData(PCURSOR_OBJECT Cursor, BOOL *fIcon, POINT *Hotspot,
+                                             HMODULE hModule, HRSRC hRsrc, HRSRC hGroupRsrc);
+BOOL           FASTCALL IntDrawIconEx(HDC hdc, int xLeft, int yTop, PCURSOR_OBJECT Cursor, int cxWidth, int cyWidth,
+                                      UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags);
+
+/* DCES ***********************************************************************/
+
+/* DC hook codes */
+#define DCHC_INVALIDVISRGN      0x0001
+#define DCHC_DELETEDC           0x0002
+
+#define DCHF_INVALIDATEVISRGN   0x0001
+#define DCHF_VALIDATEVISRGN     0x0002
+
+#define  DCEOBJ_AllocDCE()  \
+  ((HDCE) GDIOBJ_AllocObj (sizeof (DCE), GDI_OBJECT_TYPE_DCE, (GDICLEANUPPROC) DCE_InternalDelete))
+#define  DCEOBJ_FreeDCE(hDCE)  GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE, GDIOBJFLAG_DEFAULT)
+#define  DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE))
+#define  DCEOBJ_UnlockDCE(hDCE) GDIOBJ_UnlockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
+
+typedef enum
+{
+    DCE_CACHE_DC,   /* This is a cached DC (allocated by USER) */
+    DCE_CLASS_DC,   /* This is a class DC (style CS_CLASSDC) */
+    DCE_WINDOW_DC   /* This is a window DC (style CS_OWNDC) */
+} DCE_TYPE, *PDCE_TYPE;
+
+typedef struct tagDCE
+{
+    struct tagDCE  *next;
+    HANDLE         Handle;
+    HDC            hDC;
+    PWINDOW_OBJECT CurrentWindow;
+    PWINDOW_OBJECT DCWindow;
+    HRGN           hClipRgn;
+    DCE_TYPE       type;
+    DWORD          DCXFlags;
+} DCE;  /* PDCE already declared at top of file */
+
+PDCE           FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
+PDCE           FASTCALL DCE_FreeDCE(PDCE dce);
+VOID           FASTCALL DCE_FreeWindowDCE(PWINDOW_OBJECT);
+HRGN           FASTCALL DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, PWINDOW_OBJECT Child, ULONG CFlags);
+INT            FASTCALL DCE_ExcludeRgn(HDC, PWINDOW_OBJECT, HRGN);
+BOOL           FASTCALL DCE_InvalidateDCE(PWINDOW_OBJECT, const PRECTL);
+BOOL           FASTCALL DCE_InternalDelete(PDCE dce);
+PWINDOW_OBJECT FASTCALL IntWindowFromDC(HDC hDc);
+PDCE           FASTCALL DceFreeDCE(PDCE dce);
+void           FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window);
+void           FASTCALL DceEmptyCache(void);
+VOID           FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window, int DeltaX, int DeltaY);
+HDC            FASTCALL IntGetDCEx(PWINDOW_OBJECT Window, HRGN ClipRegion, ULONG Flags);
+INT            FASTCALL IntReleaseDC(PWINDOW_OBJECT Window, HDC hDc);
+
+/* DESKTOPS *******************************************************************/
+
+extern PDESKTOP_OBJECT InputDesktop;
+extern HDESK InputDesktopHandle; 
+extern PCLASS_OBJECT DesktopWindowClass;
+extern HDC ScreenDeviceContext;
+
+#define IntIsActiveDesktop(Desktop) \
+  ((Desktop)->WindowStation->ActiveDesktop == (Desktop))
+
+NTSTATUS            FASTCALL InitDesktopImpl(VOID);
+NTSTATUS            FASTCALL CleanupDesktopImpl(VOID);
+VOID                FASTCALL IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop, PRECT Rect);
+HDC                 FASTCALL IntGetScreenDC(VOID);
+PWINDOW_OBJECT      FASTCALL IntGetDesktopWindow (VOID);
+PWINDOW_OBJECT      FASTCALL IntGetCurrentThreadDesktopWindow(VOID);
+PUSER_MESSAGE_QUEUE FASTCALL IntGetActiveMessageQueue(VOID);
+PUSER_MESSAGE_QUEUE FASTCALL IntSetActiveMessageQueue(PUSER_MESSAGE_QUEUE NewQueue);
+PDESKTOP_OBJECT     FASTCALL IntGetActiveDesktop(VOID);
+NTSTATUS            FASTCALL IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height);
+NTSTATUS            FASTCALL IntHideDesktop(PDESKTOP_OBJECT Desktop);
+HDESK               FASTCALL IntGetDesktopObjectHandle(PDESKTOP_OBJECT DesktopObject);
+NTSTATUS            FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP_OBJECT *Object);
+
+/* FOCUS **********************************************************************/
+
+PWINDOW_OBJECT FASTCALL IntGetCaptureWindow(VOID);
+PWINDOW_OBJECT FASTCALL IntGetFocusWindow(VOID);
+PWINDOW_OBJECT FASTCALL IntGetThreadFocusWindow(VOID);
+BOOL           FASTCALL IntMouseActivateWindow(PWINDOW_OBJECT DesktopWindow, PWINDOW_OBJECT Window);
+BOOL           FASTCALL IntSetForegroundWindow(PWINDOW_OBJECT Window);
+PWINDOW_OBJECT FASTCALL IntSetActiveWindow(PWINDOW_OBJECT Window);
+PWINDOW_OBJECT FASTCALL IntGetForegroundWindow(VOID);
+PWINDOW_OBJECT FASTCALL IntGetActiveWindow(VOID);
+PWINDOW_OBJECT FASTCALL IntSetFocus(PWINDOW_OBJECT Window);
+PWINDOW_OBJECT FASTCALL IntSetCapture(PWINDOW_OBJECT Window);
+
+/* HOOKS **********************************************************************/
+
+#define HOOK_THREAD_REFERENCED	(0x1)
+#define NB_HOOKS (WH_MAXHOOK-WH_MINHOOK+1)
+
+typedef struct tagHOOK
+{
+  LIST_ENTRY Chain;          /* Hook chain entry */
+  HHOOK      Self;           /* user handle for this hook */
+  PETHREAD   Thread;         /* Thread owning the hook */
+  int        HookId;         /* Hook table index */
+  HOOKPROC   Proc;           /* Hook function */
+  BOOLEAN    Ansi;           /* Is it an Ansi hook? */
+  ULONG      Flags;          /* Some internal flags */
+  UNICODE_STRING ModuleName; /* Module name for global hooks */
+} HOOK;
+
+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;
+
+/* HOTKEYS ********************************************************************/
+
+typedef struct _HOT_KEY_ITEM
+{
+  LIST_ENTRY ListEntry;
+  struct _ETHREAD *Thread;
+  PWINDOW_OBJECT Window;
+  int id;
+  UINT fsModifiers;
+  UINT vk;
+} HOT_KEY_ITEM;
+
+/* INPUT **********************************************************************/
+
+#define ThreadHasInputAccess(W32Thread) \
+  (TRUE)
+
+NTSTATUS            FASTCALL InitInputImpl(VOID);
+NTSTATUS            FASTCALL InitKeyboardImpl(VOID);
+PUSER_MESSAGE_QUEUE FASTCALL W32kGetPrimitiveMessageQueue(VOID);
+PKBDTABLES          FASTCALL W32kGetDefaultKeyLayout(VOID);
+VOID                FASTCALL W32kKeyProcessMessage(LPMSG Msg, PKBDTABLES KeyLayout);
+BOOL                FASTCALL IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt);
+BOOL                FASTCALL IntMouseInput(MOUSEINPUT *mi);
+BOOL                FASTCALL IntKeyboardInput(KEYBDINPUT *ki);
+UINT                FASTCALL IntSendInput(UINT nInputs, LPINPUT pInput, INT cbSize);
+
+/* MENUS **********************************************************************/
+
+#define IS_ATOM(x) \
+  (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
+  
+#define MENU_ITEM_TYPE(flags) \
+  ((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))
+  
+#ifndef MF_END
+#define MF_END             (0x0080)
+#endif
+
+typedef struct _MENU_ITEM
+{
+  struct _MENU_ITEM *Next;
+  UINT fType;
+  UINT fState;
+  UINT wID;
+  HMENU hSubMenu;
+  HBITMAP hbmpChecked;
+  HBITMAP hbmpUnchecked;
+  ULONG_PTR dwItemData;
+  UNICODE_STRING Text;
+  HBITMAP hbmpItem;
+  RECT Rect;
+  UINT XTab;
+} MENU_ITEM;
+
+typedef struct _MENU_OBJECT
+{
+  PW32PROCESS W32Process;
+  LIST_ENTRY ListEntry;
+  FAST_MUTEX MenuItemsLock;
+  PMENU_ITEM MenuItemList;
+  ROSMENUINFO MenuInfo;
+  BOOL RtoL;
+} MENU_OBJECT;
+
+/* MESSAGE QUEUE **************************************************************/
+
+#define MSQ_HUNG        5000
+
+#define IntLockMessageQueue(MsgQueue) \
+  ExAcquireFastMutex(&(MsgQueue)->Lock)
+
+#define IntUnLockMessageQueue(MsgQueue) \
+  ExReleaseFastMutex(&(MsgQueue)->Lock)
+
+#define IntLockHardwareMessageQueue(MsgQueue) \
+  KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
+
+#define IntUnLockHardwareMessageQueue(MsgQueue) \
+  KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
+
+#define IntReferenceMessageQueue(MsgQueue) \
+  InterlockedIncrement(&(MsgQueue)->References)
+
+#define IntDereferenceMessageQueue(MsgQueue) \
+  do { \
+    if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
+    { \
+      DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
+      ExFreePool((MsgQueue)); \
+    } \
+  } while(0)
+
+/* check the queue status */
+#define MsqIsSignaled(MsgQueue) \
+  (((MsgQueue)->WakeBits & (MsgQueue)->WakeMask) || ((MsgQueue)->ChangedBits & (MsgQueue)->ChangedMask))
+
+#define IS_BTN_MESSAGE(message,code) \
+  ((message) == WM_LBUTTON##code || \
+   (message) == WM_MBUTTON##code || \
+   (message) == WM_RBUTTON##code || \
+   (message) == WM_XBUTTON##code || \
+   (message) == WM_NCLBUTTON##code || \
+   (message) == WM_NCMBUTTON##code || \
+   (message) == WM_NCRBUTTON##code || \
+   (message) == WM_NCXBUTTON##code )
+
+#define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
+
+typedef struct _USER_MESSAGE
+{
+  LIST_ENTRY ListEntry;
+  BOOLEAN FreeLParam;
+  MSG Msg;
+} USER_MESSAGE;
+
+typedef struct _USER_SENT_MESSAGE
+{
+  LIST_ENTRY ListEntry;
+  MSG Msg;
+  PKEVENT CompletionEvent;
+  LRESULT* Result;
+  struct _USER_MESSAGE_QUEUE* SenderQueue;
+  SENDASYNCPROC CompletionCallback;
+  ULONG_PTR CompletionCallbackContext;
+  /* entry in the dispatching list of the sender's message queue */
+  LIST_ENTRY DispatchingListEntry;
+} USER_SENT_MESSAGE;
+
+typedef struct _USER_SENT_MESSAGE_NOTIFY
+{
+  SENDASYNCPROC CompletionCallback;
+  ULONG_PTR CompletionCallbackContext;
+  LRESULT Result;
+  HWND hWnd;
+  UINT Msg;
+  LIST_ENTRY ListEntry;
+} USER_SENT_MESSAGE_NOTIFY;
+
+typedef struct _USER_MESSAGE_QUEUE
+{
+  /* Reference counter, only access this variable with interlocked functions! */
+  LONG References;
+  
+  /* Owner of the message queue */
+  struct _ETHREAD *Thread;
+  /* Queue of messages sent to the queue. */
+  LIST_ENTRY SentMessagesListHead;
+  /* Queue of messages posted to the queue. */
+  LIST_ENTRY PostedMessagesListHead;
+  /* Queue of sent-message notifies for the queue. */
+  LIST_ENTRY NotifyMessagesListHead;
+  /* Queue for hardware messages for the queue. */
+  LIST_ENTRY HardwareMessagesListHead;
+  /* 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. */
+  BOOLEAN QuitPosted;
+  /* The quit exit code. */
+  ULONG QuitExitCode;
+  /* Set if there are new messages in any of the queues. */
+  KEVENT NewMessages;  
+  /* Last time PeekMessage() was called. */
+  ULONG LastMsgRead;
+  /* True if a window needs painting. */
+  BOOLEAN PaintPosted;
+  /* Count of paints pending. */
+  ULONG PaintCount;
+  /* Current window with focus (ie. receives keyboard input) for this queue. */
+  PWINDOW_OBJECT FocusWindow;
+  /* Current active window for this queue. */
+  PWINDOW_OBJECT ActiveWindow;
+  /* Current capture window for this queue. */
+  PWINDOW_OBJECT CaptureWindow;
+  /* Current move/size window for this queue */
+  PWINDOW_OBJECT MoveSize;
+  /* Current menu owner window for this queue */
+  PWINDOW_OBJECT MenuOwner;
+  /* Identifes the menu state */
+  BYTE MenuState;
+  /* Caret information for this queue */
+  PTHRDCARETINFO CaretInfo;
+  
+  /* Window hooks */
+  PHOOKTABLE Hooks;
+
+  /* queue state tracking */
+  WORD WakeBits;
+  WORD WakeMask;
+  WORD ChangedBits;
+  WORD ChangedMask;
+  
+  /* extra message information */
+  LPARAM ExtraInfo;
+
+  /* messages that are currently dispatched by other threads */
+  LIST_ENTRY DispatchingMessagesHead;
+  /* messages that are currently dispatched by this message queue, required for cleanup */
+  LIST_ENTRY LocalDispatchingMessagesHead;
+} USER_MESSAGE_QUEUE;
+
+typedef struct _DOSENDMESSAGE
+{
+  UINT uFlags;
+  UINT uTimeout;
+  ULONG_PTR Result;
+} DOSENDMESSAGE;
+
+typedef struct tagMSGMEMORY
+{
+  UINT Message;
+  UINT Size;
+  INT Flags;
+} MSGMEMORY;
+
+BOOL                FASTCALL MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue);
+NTSTATUS            FASTCALL MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
+                                            PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam,
+                                            UINT uTimeout, BOOL Block, ULONG_PTR *uResult);
+PUSER_MESSAGE       FASTCALL MsqCreateMessage(LPMSG Msg, BOOLEAN FreeLParam);
+VOID                FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message);
+VOID                FASTCALL MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue, MSG* Msg, BOOLEAN FreeLParam);
+VOID                FASTCALL MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode);
+BOOLEAN             FASTCALL MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
+                                            IN BOOLEAN Hardware,
+                                            IN BOOLEAN Remove,
+                                            IN PWINDOW_OBJECT FilterWindow,
+                                            IN UINT MsgFilterLow,
+                                            IN UINT MsgFilterHigh,
+                                            OUT PUSER_MESSAGE* Message);
+VOID                FASTCALL MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue);
+VOID                FASTCALL MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
+PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(struct _ETHREAD *Thread);
+VOID                FASTCALL MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
+PUSER_MESSAGE_QUEUE FASTCALL MsqGetHardwareMessageQueue(VOID);
+NTSTATUS            FASTCALL MsqWaitForNewMessage(PUSER_MESSAGE_QUEUE MessageQueue);
+NTSTATUS            FASTCALL MsqInitializeImpl(VOID);
+BOOLEAN             FASTCALL MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue);
+NTSTATUS            FASTCALL MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue);
+VOID                FASTCALL MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue, PUSER_SENT_MESSAGE_NOTIFY NotifyMessage);
+VOID                FASTCALL MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
+VOID                FASTCALL MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
+NTSTATUS            FASTCALL CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry);
+NTSTATUS            FASTCALL CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg);
+LRESULT             FASTCALL IntSendMessage(PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam);
+LRESULT             FASTCALL IntSendMessageTimeout(PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam, 
+                                                   UINT uFlags, UINT uTimeout, ULONG_PTR *uResult);
+BOOL                FASTCALL IntWaitMessage(PWINDOW_OBJECT Window, UINT MsgFilterMin, UINT MsgFilterMax);
+BOOL                FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl);
+inline VOID                  MsqSetQueueBits(PUSER_MESSAGE_QUEUE queue, WORD bits);
+inline VOID                  MsqClearQueueBits(PUSER_MESSAGE_QUEUE queue, WORD bits);
+BOOL                         IntInitMessagePumpHook(VOID);
+BOOL                         IntUninitMessagePumpHook(VOID);
+PHOOKTABLE          FASTCALL MsqGetHooks(PUSER_MESSAGE_QUEUE Queue);
+VOID                FASTCALL MsqSetHooks(PUSER_MESSAGE_QUEUE Queue, PHOOKTABLE Hooks);
+LPARAM              FASTCALL MsqSetMessageExtraInfo(LPARAM lParam);
+LPARAM              FASTCALL MsqGetMessageExtraInfo(VOID);
+
+/* MESSAGES *******************************************************************/
+
+BOOL       FASTCALL IntPeekMessage(PUSER_MESSAGE Msg, PWINDOW_OBJECT FilterWindow,
+                                   UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg);
+BOOL       FASTCALL IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, PWINDOW_OBJECT MsgWindow,
+                                             LPMSG Msg, USHORT *HitTest, BOOL Remove);
+PMSGMEMORY FASTCALL FindMsgMemory(UINT Msg);
+UINT       FASTCALL MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam);
+BOOL       FASTCALL IntGetMessage(PUSER_MESSAGE Msg, PWINDOW_OBJECT FilterWindow,
+                                  UINT MsgFilterMin, UINT MsgFilterMax, BOOL *GotMessage);
+LRESULT    FASTCALL IntDispatchMessage(PNTUSERDISPATCHMESSAGEINFO MsgInfo, PWINDOW_OBJECT Window);
+
+/* KEYBOARD *******************************************************************/
+
+VOID           FASTCALL MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+VOID           FASTCALL MsqPostHotKeyMessage(PVOID Thread, PWINDOW_OBJECT Window, WPARAM wParam, LPARAM lParam);
+VOID           FASTCALL MsqInsertSystemMessage(MSG* Msg);
+BOOL           FASTCALL MsqIsDblClk(LPMSG Msg, BOOL Remove);
+PWINDOW_OBJECT FASTCALL MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, PWINDOW_OBJECT Window);
+
+/* PAINTING *******************************************************************/
+
+#define DCX_DCEEMPTY		0x00000800
+#define DCX_DCEBUSY		0x00001000
+#define DCX_DCEDIRTY		0x00002000
+#define DCX_USESTYLE		0x00010000
+#define DCX_WINDOWPAINT		0x00020000
+#define DCX_KEEPCLIPRGN		0x00040000
+#define DCX_NOCLIPCHILDREN      0x00080000
+
+#define IntLockWindowUpdate(Window) \
+  ExAcquireFastMutex(&Window->UpdateLock)
+
+#define IntUnLockWindowUpdate(Window) \
+  ExReleaseFastMutex(&Window->UpdateLock)
+
+#define IntInvalidateRect(WndObj, Rect, Erase) \
+   IntRedrawWindow((WndObj), (LPRECT)(Rect), 0, RDW_INVALIDATE | ((Erase) ? RDW_ERASE : 0))
+
+#define IntInvalidateRgn(WndObj, Rgn, Erase) \
+   IntRedrawWindow((WndObj), NULL, (Rgn), RDW_INVALIDATE | ((Erase) ? RDW_ERASE : 0))
+
+#define IntValidateRect(WndObj, Rect) \
+   IntRedrawWindow((WndObj), (Rect), NULL, RDW_VALIDATE | RDW_NOCHILDREN)
+
+#define IntValidateRgn(WndObj, hRgn) \
+   IntRedrawWindow((WndObj), NULL, (hRgn), RDW_VALIDATE | RDW_NOCHILDREN)
+
+#define IntUpdateWindow(WndObj) \
+   IntRedrawWindow((WndObj), NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN)
+
+#define IntIsWindowDirty(Window) \
+  ((Window->Style & WS_VISIBLE) && \
+      ((Window->UpdateRegion != NULL) || \
+       (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) || \
+       (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)))
+
+VOID FASTCALL IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion);
+BOOL FASTCALL IntRedrawWindow(PWINDOW_OBJECT Window, LPRECT UpdateRect, HRGN UpdateRgn, UINT Flags);
+BOOL FASTCALL IntGetPaintMessage(PWINDOW_OBJECT Window, UINT MsgFilterMin, UINT MsgFilterMax,
+                                 PW32THREAD Thread, MSG *Message, BOOL Remove);
+HDC  FASTCALL IntBeginPaint(PWINDOW_OBJECT Window, PAINTSTRUCT* lPs);
+BOOL FASTCALL IntEndPaint(PWINDOW_OBJECT Window, CONST PAINTSTRUCT* lPs);
+BOOL FASTCALL IntGetUpdateRect(PWINDOW_OBJECT Window, LPRECT Rect, BOOL Erase);
+INT  FASTCALL IntGetUpdateRgn(PWINDOW_OBJECT Window, HRGN hRgn, BOOL bErase);
+
+/* WINDOW PROPERTIES **********************************************************/
+
+typedef struct _PROPERTY
+{
+  LIST_ENTRY PropListEntry;
+  HANDLE Data;
+  ATOM Atom;
+} PROPERTY;
+
+BOOL      FASTCALL IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data);
+PPROPERTY FASTCALL IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom);
+
+/* SCROLL BARS ****************************************************************/
+
+#define IntGetScrollbarInfoFromWindow(Window, i) \
+  ((PSCROLLBARINFO)(&((Window)->Scroll + i)->ScrollBarInfo))
+
+#define IntGetScrollInfoFromWindow(Window, i) \
+  ((LPSCROLLINFO)(&((Window)->Scroll + i)->ScrollInfo))
+
+#define SBOBJ_TO_SBID(Obj)	((Obj) - OBJID_HSCROLL)
+#define SBID_IS_VALID(id)	(id == SB_HORZ || id == SB_VERT || id == SB_CTL)
+
+typedef struct _WINDOW_SCROLLINFO
+{
+  SCROLLBARINFO ScrollBarInfo;
+  SCROLLINFO ScrollInfo;
+} WINDOW_SCROLLINFO;
+
+BOOL  FASTCALL IntCreateScrollBars(PWINDOW_OBJECT Window);
+BOOL  FASTCALL IntDestroyScrollBars(PWINDOW_OBJECT Window);
+BOOL  FASTCALL IntGetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi);
+BOOL  FASTCALL IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows);
+BOOL  FASTCALL IntEnableWindowScrollBar(PWINDOW_OBJECT Window, UINT wSBflags, UINT wArrows);
+BOOL  FASTCALL IntSetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, SETSCROLLBARINFO *info);
+DWORD FASTCALL IntShowScrollBar(PWINDOW_OBJECT Window, int wBar, DWORD bShow);
+BOOL  FASTCALL IntGetScrollBarRect (PWINDOW_OBJECT Window, INT nBar, PRECT lprect);
+DWORD FASTCALL IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw);
+BOOL  FASTCALL IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi);
+
+/* TIMERS *********************************************************************/
+
+typedef struct _MSG_TIMER_ENTRY{
+   LIST_ENTRY     ListEntry;
+   LARGE_INTEGER  Timeout;
+   HANDLE         ThreadID;
+   UINT           Period;
+   MSG            Msg;
+} MSG_TIMER_ENTRY;
+
+NTSTATUS         FASTCALL InitTimerImpl(VOID);
+VOID             FASTCALL RemoveTimersThread(HANDLE ThreadID);
+VOID             FASTCALL RemoveTimersWindow(PWINDOW_OBJECT Window);
+PMSG_TIMER_ENTRY FASTCALL IntRemoveTimer(PWINDOW_OBJECT Window, UINT_PTR IDEvent, HANDLE ThreadID, BOOL SysTimer);
+UINT_PTR         FASTCALL IntSetTimer(PWINDOW_OBJECT WindowObject, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, BOOL SystemTimer);
+
+/* VISIBLE REGION *************************************************************/
+
+HRGN FASTCALL VIS_ComputeVisibleRegion(PWINDOW_OBJECT Window, BOOLEAN ClientArea,
+                                       BOOLEAN ClipChildren, BOOLEAN ClipSiblings);
+VOID FASTCALL VIS_WindowLayoutChanged(PWINDOW_OBJECT Window, HRGN UncoveredRgn);
+
+/* WINDOWS ********************************************************************/
+
+/* same as HWND_BOTTOM */
+#define WINDOW_BOTTOM	((PWINDOW_OBJECT)1)
+/* same as HWND_NOTOPMOST */
+#define WINDOW_NOTOPMOST	((PWINDOW_OBJECT)-2)
+/* same as HWND_TOP */
+#define WINDOW_TOP	((PWINDOW_OBJECT)0)
+/* same as HWND_TOPMOST */
+#define WINDOW_TOPMOST	((PWINDOW_OBJECT)(-1))
+/* same as HWND_MESSAGE */
+#define WINDOW_MESSAGE	((PWINDOW_OBJECT)-3)
+
+/* Window flags. */
+#define WINDOWOBJECT_NEED_SIZE            (0x00000001)
+#define WINDOWOBJECT_NEED_ERASEBKGND      (0x00000002)
+#define WINDOWOBJECT_NEED_NCPAINT         (0x00000004)
+#define WINDOWOBJECT_NEED_INTERNALPAINT   (0x00000008)
+#define WINDOWOBJECT_RESTOREMAX           (0x00000020)
+
+#define WINDOWSTATUS_DESTROYING         (0x1)
+#define WINDOWSTATUS_DESTROYED          (0x2)
+
+#define HAS_DLGFRAME(Style, ExStyle) \
+            (((ExStyle) & WS_EX_DLGMODALFRAME) || \
+            (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME))))
+
+#define HAS_THICKFRAME(Style, ExStyle) \
+            (((Style) & WS_THICKFRAME) && \
+            (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)))
+
+#define HAS_THINFRAME(Style, ExStyle) \
+            (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP))))
+
+#define IntIsDesktopWindow(WndObj) \
+  ((WndObj)->Parent == NULL)
+
+#define IntIsBroadcastHwnd(hWnd) \
+  (hWnd == HWND_BROADCAST || hWnd == HWND_TOPMOST)
+
+#define IntWndBelongsToThread(WndObj, W32Thread) \
+  ((WndObj)->MessageQueue->Thread->Win32Thread == W32Thread)
+
+#define IntGetWndThreadId(WndObj) \
+  ((WndObj)->MessageQueue->Thread->Cid.UniqueThread)
+
+#define IntGetWndProcessId(WndObj) \
+  ((WndObj)->MessageQueue->Thread->ThreadsProcess->UniqueProcessId)
+
+#define IntGetParentObject(WndObj) \
+  ((WndObj)->Parent)
+
+#define IntIsWindow(WndObj) \
+  ((WndObj) != NULL && ObmObjectDeleted(WndObj) == FALSE)
+
+#define IntReferenceWindowObject(WndObj) \
+  ObmReferenceObject(WndObj)
+
+#define IntReleaseWindowObject(WndObj) \
+  ObmDereferenceObject(WndObj)
+
+#define IntIsWindowInDestroy(WndObj) \
+  (((Window)->Status & WINDOWSTATUS_DESTROYING) == WINDOWSTATUS_DESTROYING)
+
+#define IntMoveWindow(WndObj, X, Y, nWidth, nHeight, bRepaint) \
+  IntSetWindowPos((WndObj), 0, (X), (Y), (nWidth), (nHeight), \
+                  ((bRepaint) ? SWP_NOZORDER | SWP_NOACTIVATE : SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW))
+
+typedef struct _INTERNALPOS
+{
+  RECT NormalRect;
+  POINT IconPos;
+  POINT MaxPos;
+} INTERNALPOS;
+
+typedef struct _WINDOW_OBJECT
+{
+  /* Handle for the window. */
+  HANDLE Handle;
+  /* Entry in the list of thread windows. */
+  LIST_ENTRY ThreadListEntry;
+  /* Pointer to the window class. */
+  PCLASS_OBJECT Class;
+  /* entry in the window list of the class object */
+  LIST_ENTRY ClassListEntry;
+  /* Extended style. */
+  DWORD ExStyle;
+  /* Window name. */
+  UNICODE_STRING WindowName;
+  /* Window ID */
+  ULONG WindowID;
+  /* Style. */
+  DWORD Style;
+  /* Context help id */
+  DWORD ContextHelpId;
+  /* Handle of the module that created the window. */
+  HINSTANCE Instance;
+  /* Entry in the thread's list of windows. */
+  LIST_ENTRY ListEntry;
+  /* Pointer to the extra data associated with the window. */
+  PBYTE ExtraData;
+  /* Size of the extra data associated with the window. */
+  ULONG ExtraDataSize;
+  /* Position of the window. */
+  RECT WindowRect;
+  /* Position of the window's client area. */
+  RECT ClientRect;
+  /* Window flags. */
+  ULONG Flags;
+  /* Handle of region of the window to be updated. */
+  HRGN UpdateRegion;
+  HRGN NCUpdateRegion;
+  /* Handle of the window region. */
+  HRGN WindowRegion;
+  /* Lock to be held when manipulating (NC)UpdateRegion */
+  FAST_MUTEX UpdateLock;
+  /* Pointer to the owning thread's message queue. */
+  PUSER_MESSAGE_QUEUE MessageQueue;
+  /* First child window */
+  struct _WINDOW_OBJECT* FirstChild;
+  /* Last Child Window */
+  struct _WINDOW_OBJECT* LastChild;
+  /* Next sibling */
+  struct _WINDOW_OBJECT* NextSibling;
+  /* Previous sibling */
+  struct _WINDOW_OBJECT* PrevSibling;
+  /* parent window. */
+  struct _WINDOW_OBJECT* Parent;
+  /* owner window. */
+  struct _WINDOW_OBJECT* Owner;
+  /* DC Entries (DCE) */ 
+  PDCE Dce;
+  /* Property list head.*/
+  LIST_ENTRY PropListHead;
+  /* Count of properties */
+  ULONG PropListItems;
+  /* Scrollbar info */
+  PWINDOW_SCROLLINFO Scroll;
+  LONG UserData;
+  BOOL Unicode;
+  WNDPROC WndProcA;
+  WNDPROC WndProcW;
+  struct _WINDOW_OBJECT* LastPopup; /* last active popup window */
+  PINTERNALPOS InternalPos;
+  ULONG Status;
+  /* counter for tiled child windows */
+  ULONG TiledCounter;
+} WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */
+
+PWINDOW_OBJECT FASTCALL IntCreateWindow(DWORD dwExStyle, PUNICODE_STRING ClassName, PUNICODE_STRING WindowName,
+                                        ULONG dwStyle, LONG x, LONG y, LONG nWidth, LONG nHeight,
+                                        PWINDOW_OBJECT Parent, PMENU_OBJECT Menu, ULONG WindowID, HINSTANCE hInstance,
+                                        LPVOID lpParam, DWORD dwShowMode, BOOL bUnicodeWindow);
+BOOL           FASTCALL IntDestroyWindow(PWINDOW_OBJECT Window, PW32PROCESS ProcessData, PW32THREAD ThreadData, BOOL SendMessages);
+NTSTATUS       FASTCALL InitWindowImpl (VOID);
+NTSTATUS       FASTCALL CleanupWindowImpl (VOID);
+VOID           FASTCALL IntGetClientRect (PWINDOW_OBJECT WindowObject, PRECT Rect);
+PWINDOW_OBJECT FASTCALL IntGetActiveWindow (VOID);
+BOOL           FASTCALL IntIsWindowVisible (PWINDOW_OBJECT Wnd);
+BOOL           FASTCALL IntIsChildWindow (PWINDOW_OBJECT Parent, PWINDOW_OBJECT Child);
+VOID           FASTCALL IntUnlinkWindow(PWINDOW_OBJECT Wnd);
+VOID           FASTCALL IntLinkWindow(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndParent, PWINDOW_OBJECT WndPrevSibling);
+PWINDOW_OBJECT FASTCALL IntGetAncestor(PWINDOW_OBJECT Wnd, UINT Type);
+PWINDOW_OBJECT FASTCALL IntGetParent(PWINDOW_OBJECT Wnd);
+INT            FASTCALL IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn);
+INT            FASTCALL IntGetWindowRgnBox(PWINDOW_OBJECT Window, RECT *Rect);
+BOOL           FASTCALL IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi);
+LONG           FASTCALL IntGetWindowLong(PWINDOW_OBJECT WindowObject, INT Index, BOOL Ansi);
+LONG           FASTCALL IntSetWindowLong(PWINDOW_OBJECT WindowObject, INT Index, LONG NewValue, BOOL Ansi);
+VOID           FASTCALL IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, INT *cx, INT *cy);
+BOOL           FASTCALL IntAnyPopup(VOID);
+PWINDOW_OBJECT FASTCALL IntGetShellWindow(VOID);
+PWINDOW_OBJECT FASTCALL IntSetParent(PWINDOW_OBJECT Window, PWINDOW_OBJECT WndNewParent);
+BOOL           FASTCALL IntSetShellWindowEx(PWINDOW_OBJECT Shell, PWINDOW_OBJECT ListView);
+WORD           FASTCALL IntSetWindowWord(PWINDOW_OBJECT WindowObject, INT Index, WORD NewValue);
+ULONG          FASTCALL IntGetWindowThreadProcessId(PWINDOW_OBJECT Window, ULONG *Pid);
+PWINDOW_OBJECT FASTCALL IntGetWindow(PWINDOW_OBJECT Window, UINT uCmd);
+DWORD                   IntRemoveWndProcHandle(WNDPROC Handle);
+DWORD                   IntRemoveProcessWndProcHandles(HANDLE ProcessID);
+DWORD                   IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode);
+
+/* WINPOS *********************************************************************/
+
+/* Undocumented flags. */
+#define SWP_NOCLIENTMOVE          0x0800
+#define SWP_NOCLIENTSIZE          0x1000
+
+#define IntPtInWindow(WndObject,x,y) \
+  ((x) >= (WndObject)->WindowRect.left && \
+   (x) < (WndObject)->WindowRect.right && \
+   (y) >= (WndObject)->WindowRect.top && \
+   (y) < (WndObject)->WindowRect.bottom && \
+   (!(WndObject)->WindowRegion || ((WndObject)->Style & WS_MINIMIZE) || \
+    NtGdiPtInRegion((WndObject)->WindowRegion, (INT)((x) - (WndObject)->WindowRect.left), \
+                    (INT)((y) - (WndObject)->WindowRect.top))))
+
+#define HWNDValidateWindowObject(hwnd) \
+  ((PWINDOW_OBJECT)(hwnd) > WINDOW_BOTTOM && (PWINDOW_OBJECT)(hwnd) < WINDOW_MESSAGE)
+
+typedef struct _INTERNAL_WINDOWPOS
+{
+  PWINDOW_OBJECT Window;
+  PWINDOW_OBJECT InsertAfter;
+  int x;
+  int y;
+  int cx;
+  int cy;
+  UINT flags;
+} INTERNAL_WINDOWPOS;
+
+BOOL         FASTCALL IntGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point);
+LRESULT      FASTCALL WinPosGetNonClientSize(PWINDOW_OBJECT Window, RECT* WindowRect, RECT* ClientRect);
+UINT         FASTCALL WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos, POINT* MinTrack, POINT* MaxTrack);
+UINT         FASTCALL WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos);
+BOOLEAN      FASTCALL WinPosSetWindowPos(PWINDOW_OBJECT Window, PWINDOW_OBJECT InsertAfter, INT x, INT y, INT cx, INT cy, UINT flags);
+BOOLEAN      FASTCALL WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd);
+USHORT       FASTCALL WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, PWINDOW_OBJECT* Window);
+VOID         FASTCALL WinPosActivateOtherWindow(PWINDOW_OBJECT Window);
+PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT *pt, PRECT RestoreRect);
+VOID         FASTCALL WinPosSetupInternalPos(VOID);
+
+/* WINDOW STATION *************************************************************/
+
+extern WINSTATION_OBJECT *InputWindowStation;
+extern PW32PROCESS LogonProcess;
+
+#define WINSTA_ROOT_NAME	L"\\Windows\\WindowStations"
+#define WINSTA_ROOT_NAME_LENGTH	23
+
+/* Window Station Status Flags */
+#define WSS_LOCKED	(1)
+#define WSS_NOINTERACTIVE	(2)
+
+#define PROCESS_WINDOW_STATION() \
+  ((HWINSTA)(IoGetCurrentProcess()->Win32WindowStation))
+
+#define SET_PROCESS_WINDOW_STATION(WinSta) \
+  ((IoGetCurrentProcess()->Win32WindowStation) = (PVOID)(WinSta))
+
+NTSTATUS FASTCALL InitWindowStationImpl(VOID);
+NTSTATUS FASTCALL CleanupWindowStationImpl(VOID);
+NTSTATUS FASTCALL IntValidateWindowStationHandle(HWINSTA WindowStation,
+                                                 KPROCESSOR_MODE AccessMode,
+                                                 ACCESS_MASK DesiredAccess,
+                                                 PWINSTATION_OBJECT *Object);
+
+BOOL     FASTCALL IntGetWindowStationObject(PWINSTATION_OBJECT Object);
+BOOL     FASTCALL IntInitializeDesktopGraphics(VOID);
+VOID     FASTCALL IntEndDesktopGraphics(VOID);
+BOOL     FASTCALL IntGetFullWindowStationName(OUT PUNICODE_STRING FullName,
+                                              IN PUNICODE_STRING WinStaName,
+                                              IN OPTIONAL PUNICODE_STRING DesktopName);
+
+/* MOUSE **********************************************************************/
+
+#ifndef XBUTTON1
+#define XBUTTON1	(0x01)
+#endif
+#ifndef XBUTTON2
+#define XBUTTON2	(0x02)
+#endif
+#ifndef MOUSEEVENTF_XDOWN
+#define MOUSEEVENTF_XDOWN	(0x80)
+#endif
+#ifndef MOUSEEVENTF_XUP
+#define MOUSEEVENTF_XUP	(0x100)
+#endif
+
+BOOL FASTCALL IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo);
+BOOL FASTCALL IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap);
+INT  FASTCALL MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
+INT  FASTCALL MouseSafetyOnDrawEnd(SURFOBJ *SurfObj);
[truncated at 1000 lines; 13 more skipped]

reactos/subsys/win32k/include
misc.h added at 1.1.4.1
diff -N misc.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc.h	15 Jul 2004 20:07:16 -0000	1.1.4.1
@@ -0,0 +1,45 @@
+#ifndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H
+#define _SUBSYS_WIN32K_INCLUDE_CLEANUP_H
+
+NTSTATUS FASTCALL InitCleanupImpl(VOID);
+
+NTSTATUS FASTCALL
+IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
+                         PUNICODE_STRING Source);
+
+NTSTATUS FASTCALL
+IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
+                                      PUNICODE_STRING Source);
+
+NTSTATUS FASTCALL
+IntUnicodeStringToNULLTerminated(PWSTR *Dest, PUNICODE_STRING Src);
+
+void FASTCALL
+IntFreeNULLTerminatedFromUnicodeString(PWSTR NullTerminated, PUNICODE_STRING UnicodeString);
+
+/*
+ * User Locks
+ */
+
+VOID FASTCALL
+IntInitUserResourceLocks(VOID);
+
+VOID FASTCALL
+IntCleanupUserResourceLocks(VOID);
+
+inline VOID
+IntUserEnterCritical(VOID);
+
+inline VOID
+IntUserEnterCriticalShared(VOID);
+
+inline VOID
+IntUserLeaveCritical(VOID);
+
+inline BOOL
+IntUserIsInCritical(VOID);
+
+inline NTSTATUS
+IntConvertThreadToGUIThread(PETHREAD Thread);
+
+#endif /* ndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H */

reactos/subsys/win32k/include
callback.h 1.18 -> 1.18.8.1
diff -u -r1.18 -r1.18.8.1
--- callback.h	20 Jun 2004 12:34:20 -0000	1.18
+++ callback.h	15 Jul 2004 20:07:16 -0000	1.18.8.1
@@ -4,7 +4,7 @@
 LRESULT STDCALL
 IntCallWindowProc(WNDPROC Proc,
                   BOOLEAN IsAnsiProc,
-                  HWND Wnd,
+                  PWINDOW_OBJECT Window,
                   UINT Message,
                   WPARAM wParam,
                   LPARAM lParam,

reactos/subsys/win32k/include
object.h 1.24 -> 1.24.4.1
diff -u -r1.24 -r1.24.4.1
--- object.h	3 Jul 2004 13:55:36 -0000	1.24
+++ object.h	15 Jul 2004 20:07:16 -0000	1.24.4.1
@@ -1,65 +1,38 @@
 #ifndef _WIN32K_OBJECT_H
 #define _WIN32K_OBJECT_H
 
-#include <windows.h>
-#include <win32k/gdiobj.h>
-#include <win32k/bitmaps.h>
-#include <win32k/pen.h>
+/*
+ * User Objects
+ */
+
+#define N_USER_HANDLES	0x4000
 
 typedef enum {
-  otUnknown = 0,
-  otClass,
-  otWindow,
-  otMenu,
-  otAcceleratorTable,
-  otCursorIcon,
-  otHookProc
+  otUNKNOWN = 0,
+  otWINDOW,
+  otMENU,
+  otACCEL,
+  otCURSOR,
+  otHOOK,
+  otDWP
 } USER_OBJECT_TYPE;
 
+typedef struct _USER_OBJECT_HEADER *PUSER_OBJECT_HEADER;
+
 typedef struct _USER_OBJECT_HEADER
-/*
- * Header for user object
- */
 {
   USER_OBJECT_TYPE Type;
-  LONG HandleCount;
+  PUSER_OBJECT_HEADER *Slot;
   LONG RefCount;
-  CSHORT Size;
-} USER_OBJECT_HEADER, *PUSER_OBJECT_HEADER;
-
-typedef struct _USER_HANDLE
-{
-  PVOID ObjectBody;
-} USER_HANDLE, *PUSER_HANDLE;
-
-#define HANDLE_BLOCK_ENTRIES ((PAGE_SIZE-sizeof(LIST_ENTRY))/sizeof(USER_HANDLE))
-
-typedef struct _USER_HANDLE_BLOCK
-{
-  LIST_ENTRY ListEntry;
-  USER_HANDLE Handles[HANDLE_BLOCK_ENTRIES];
-} USER_HANDLE_BLOCK, *PUSER_HANDLE_BLOCK;
+} USER_OBJECT_HEADER;
 
 typedef struct _USER_HANDLE_TABLE
 {
-   LIST_ENTRY ListHead;
-   FAST_MUTEX ListLock;
+  ULONG HandleCount;
+  PUSER_OBJECT_HEADER Handles[N_USER_HANDLES];
 } USER_HANDLE_TABLE, *PUSER_HANDLE_TABLE;
 
-
-#define ObmpLockHandleTable(HandleTable) \
-  ExAcquireFastMutex(&HandleTable->ListLock)
-
-#define ObmpUnlockHandleTable(HandleTable) \
-  ExReleaseFastMutex(&HandleTable->ListLock)
-
-ULONG FASTCALL
-ObmGetReferenceCount(
-  PVOID ObjectBody);
-
-ULONG FASTCALL
-ObmGetHandleCount(
-  PVOID ObjectBody);
+typedef BOOL (FASTCALL *PFNENUMHANDLESPROC)(PVOID ObjectBody, PVOID UserData);
 
 VOID FASTCALL
 ObmReferenceObject(
@@ -69,35 +42,39 @@
 ObmDereferenceObject(
   PVOID ObjectBody);
 
-NTSTATUS FASTCALL
-ObmReferenceObjectByPointer(
-  PVOID ObjectBody,
-  USER_OBJECT_TYPE ObjectType);
+PVOID FASTCALL
+ObmEnumHandles(
+  PUSER_HANDLE_TABLE HandleTable,
+  USER_OBJECT_TYPE ObjectType,
+  PVOID UserData,
+  PFNENUMHANDLESPROC EnumProc);
+
+BOOL FASTCALL
+ObmObjectDeleted(
+  PVOID ObjectBody);
 
 PVOID FASTCALL
 ObmCreateObject(
   PUSER_HANDLE_TABLE HandleTable,
   PHANDLE Handle,
-	USER_OBJECT_TYPE ObjectType,
+  USER_OBJECT_TYPE ObjectType,
   ULONG ObjectSize);
 
-NTSTATUS FASTCALL
-ObmCreateHandle(
+USER_OBJECT_TYPE FASTCALL
+ObmGetObjectType(
   PUSER_HANDLE_TABLE HandleTable,
-  PVOID ObjectBody,
-	PHANDLE HandleReturn);
+  PVOID ObjectBody);
 
-NTSTATUS FASTCALL
-ObmReferenceObjectByHandle(
+BOOL FASTCALL
+ObmDeleteObject(
   PUSER_HANDLE_TABLE HandleTable,
-  HANDLE Handle,
-	USER_OBJECT_TYPE ObjectType,
-	PVOID* Object);
+  PVOID ObjectBody);
 
-NTSTATUS FASTCALL
-ObmCloseHandle(
+PVOID FASTCALL
+ObmGetObject(
   PUSER_HANDLE_TABLE HandleTable,
-  HANDLE Handle);
+  HANDLE Handle,
+  USER_OBJECT_TYPE ObjectType);
 
 VOID FASTCALL
 ObmInitializeHandleTable(
@@ -110,7 +87,15 @@
 PUSER_HANDLE_TABLE FASTCALL
 ObmCreateHandleTable(VOID);
 
-VOID  FASTCALL ObmDestroyHandleTable (PUSER_HANDLE_TABLE HandleTable);
+VOID FASTCALL
+ObmDestroyHandleTable (PUSER_HANDLE_TABLE HandleTable);
+
+#define IntGetUserObject(ObjectType, Handle) \
+  ObmGetObject(PsGetWin32Process()->WindowStation->HandleTable, (Handle), ot##ObjectType )
+
+/*
+ * GDI
+ */
 
 ULONG FASTCALL CreateGDIHandle (ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject);
 VOID  FASTCALL FreeGDIHandle (ULONG Handle);
@@ -135,3 +120,4 @@
 #endif /* _WIN32K_OBJECT_H */
 
 /* EOF */
+

reactos/subsys/win32k/include
tags.h 1.5 -> 1.5.12.1
diff -u -r1.5 -r1.5.12.1
--- tags.h	23 May 2004 09:36:47 -0000	1.5
+++ tags.h	15 Jul 2004 20:07:16 -0000	1.5.12.1
@@ -14,6 +14,7 @@
 #define TAG_USRMSG	TAG('U', 'M', 'S', 'G') /* user message */
 #define TAG_WNDPROP	TAG('W', 'P', 'R', 'P') /* window property */
 #define TAG_WNAM	TAG('W', 'N', 'A', 'M') /* window name */
+#define TAG_CLASS	TAG('W', 'C', 'L', 'S') /* window class */
 #define TAG_WINLIST	TAG('W', 'N', 'L', 'S') /* window handle list */
 #define TAG_WININTLIST	TAG('W', 'N', 'I', 'P') /* window internal pos */
 #define TAG_WINPROCLST	TAG('W', 'N', 'P', 'L') /* window proc list */

reactos/subsys/win32k/include
accelerator.h removed after 1.1
diff -N accelerator.h
--- accelerator.h	7 Dec 2003 12:59:34 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-#ifndef _WIN32K_ACCELERATOR_H
-#define _WIN32K_ACCELERATOR_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <include/winsta.h>
-#include <include/window.h>
-
-typedef struct _ACCELERATOR_TABLE
-{
-  int Count;
-  LPACCEL Table;
-} ACCELERATOR_TABLE, *PACCELERATOR_TABLE;
-
-NTSTATUS FASTCALL
-InitAcceleratorImpl();
-
-NTSTATUS FASTCALL
-CleanupAcceleratorImpl();
-
-VOID
-RegisterThreadAcceleratorTable(struct _ETHREAD *Thread);
-
-#endif /* _WIN32K_ACCELERATOR_H */

reactos/subsys/win32k/include
caret.h removed after 1.4
diff -N caret.h
--- caret.h	20 Dec 2003 15:42:46 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-#ifndef _WIN32K_CARET_H
-#define _WIN32K_CARET_H
-
-#include <windows.h>
-#include <internal/ps.h>
-
-#define IDCARETTIMER (0xffff)
-
-/* a copy of this structure is in lib/user32/include/user32.h */
-typedef struct _THRDCARETINFO
-{
-  HWND hWnd;
-  HBITMAP Bitmap;
-  POINT Pos;
-  SIZE Size;
-  BYTE Visible;
-  BYTE Showing;
-} THRDCARETINFO, *PTHRDCARETINFO;
-
-BOOL FASTCALL
-IntDestroyCaret(PW32THREAD Win32Thread);
-
-BOOL FASTCALL
-IntSetCaretBlinkTime(UINT uMSeconds);
-
-BOOL FASTCALL
-IntSetCaretPos(int X, int Y);
-
-BOOL FASTCALL
-IntSwitchCaretShowing(PVOID Info);
-
-VOID FASTCALL
-IntDrawCaret(HWND hWnd);
-
-#endif /* _WIN32K_CARET_H */
-
-/* EOF */

reactos/subsys/win32k/include
class.h removed after 1.24
diff -N class.h
--- class.h	27 May 2004 11:47:42 -0000	1.24
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-#ifndef _WIN32K_CLASS_H
-#define _WIN32K_CLASS_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <ddk/ntapi.h>
-#include <napi/win32.h>
-
-#define IS_ATOM(x) \
-  (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
-
-typedef struct _WNDCLASS_OBJECT
-{
-  UINT    cbSize;
-  UINT    style;
-  WNDPROC lpfnWndProcA;
-  WNDPROC lpfnWndProcW;
-  int     cbClsExtra;
-  int     cbWndExtra;
-  HANDLE  hInstance;
-  HICON   hIcon;
-  HCURSOR hCursor;
-  HBRUSH  hbrBackground;
-  UNICODE_STRING lpszMenuName;
-  RTL_ATOM Atom;
-  HICON   hIconSm;
-  BOOL Unicode;
-  BOOL Global;
-  LIST_ENTRY ListEntry;
-  PCHAR   ExtraData;
-  /* list of windows */
-  FAST_MUTEX ClassWindowsListLock;
-  LIST_ENTRY ClassWindowsListHead;
-} WNDCLASS_OBJECT, *PWNDCLASS_OBJECT;
-
-NTSTATUS FASTCALL
-InitClassImpl(VOID);
-
-NTSTATUS FASTCALL
-CleanupClassImpl(VOID);
-
-#define IntLockProcessClasses(W32Process) \
-  ExAcquireFastMutex(&(W32Process)->ClassListLock)
-
-#define IntUnLockProcessClasses(W32Process) \
-  ExReleaseFastMutex(&(W32Process)->ClassListLock)
-
-#define IntLockClassWindows(ClassObj) \
-  ExAcquireFastMutex(&(ClassObj)->ClassWindowsListLock)
-
-#define IntUnLockClassWindows(ClassObj) \
-  ExReleaseFastMutex(&(ClassObj)->ClassWindowsListLock)
-
-#define ClassDereferenceObject(ClassObj) \
-  ObmDereferenceObject(ClassObj)
-
-BOOL FASTCALL
-ClassReferenceClassByAtom(
-   PWNDCLASS_OBJECT* Class,
-   RTL_ATOM Atom,
-   HINSTANCE hInstance);
-
-BOOL FASTCALL
-ClassReferenceClassByName(
-   PWNDCLASS_OBJECT *Class,
-   LPCWSTR ClassName,
-   HINSTANCE hInstance);
-
-BOOL FASTCALL
-ClassReferenceClassByNameOrAtom(
-   PWNDCLASS_OBJECT *Class,
-   LPCWSTR ClassNameOrAtom,
-   HINSTANCE hInstance);
-
-struct _WINDOW_OBJECT;
-ULONG FASTCALL
-IntGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset, BOOL Ansi);
-
-#endif /* _WIN32K_CLASS_H */
-
-/* EOF */

reactos/subsys/win32k/include
cleanup.h removed after 1.4
diff -N cleanup.h
--- cleanup.h	16 Jun 2004 06:09:40 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-#ifndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H
-#define _SUBSYS_WIN32K_INCLUDE_CLEANUP_H
-
-NTSTATUS FASTCALL InitCleanupImpl(VOID);
-
-NTSTATUS FASTCALL
-IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
-                         PUNICODE_STRING Source);
-
-NTSTATUS FASTCALL
-IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
-                                      PUNICODE_STRING Source);
-
-NTSTATUS FASTCALL
-IntUnicodeStringToNULLTerminated(PWSTR *Dest, PUNICODE_STRING Src);
-
-void FASTCALL
-IntFreeNULLTerminatedFromUnicodeString(PWSTR NullTerminated, PUNICODE_STRING UnicodeString);
-
-#endif /* ndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H */

reactos/subsys/win32k/include
clipboard.h removed after 1.1
diff -N clipboard.h
--- clipboard.h	14 Dec 2003 12:39:32 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,9 +0,0 @@
-#ifndef _WIN32K_CLIPBOARD_H
-#define _WIN32K_CLIPBOARD_H
-
-#include <windows.h>
-
-UINT FASTCALL
-IntEnumClipboardFormats(UINT format);
-
-#endif /* _WIN32K_CLIPBOARD_H */

reactos/subsys/win32k/include
cursoricon.h removed after 1.8
diff -N cursoricon.h
--- cursoricon.h	14 May 2004 23:57:32 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-#ifndef _WIN32K_CURSORICON_H
-#define _WIN32K_CURSORICON_H
-
-#define MAXCURICONHANDLES 4096
-
-typedef struct _CURICON_OBJECT
-{
-  HANDLE Self;
-  LIST_ENTRY ListEntry;
-  PW32PROCESS Process;
-  HMODULE hModule;
-  HRSRC hRsrc;
-  HRSRC hGroupRsrc;
-  SIZE Size;
-  BYTE Shadow;
-  ICONINFO IconInfo;
-} CURICON_OBJECT, *PCURICON_OBJECT;
-
-typedef struct _CURSORCLIP_INFO
-{
-  BOOL IsClipped;
-  UINT Left;
-  UINT Top;
-  UINT Right;
-  UINT Bottom;
-} CURSORCLIP_INFO, *PCURSORCLIP_INFO;
-
-typedef struct _SYSTEM_CURSORINFO
-{
-  BOOL Enabled;
-  BOOL SwapButtons;
-  UINT ButtonsDown;
-  LONG x, y;
-  BOOL SafetySwitch;
-  UINT SafetyRemoveCount;
-  LONG PointerRectLeft;
-  LONG PointerRectTop;
-  LONG PointerRectRight;
-  LONG PointerRectBottom;
-  FAST_MUTEX CursorMutex;
-  CURSORCLIP_INFO CursorClipInfo;
-  PCURICON_OBJECT CurrentCursorObject;
-  BYTE ShowingCursor;
-  UINT DblClickSpeed;
-  UINT DblClickWidth;
-  UINT DblClickHeight;
-  DWORD LastBtnDown;
-  LONG LastBtnDownX;
-  LONG LastBtnDownY;
-  HANDLE LastClkWnd;
-} SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO;
-
-HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange);
-BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject);
-PCURICON_OBJECT FASTCALL IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle);
-PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject);
-VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process);
-
-#define IntGetSysCursorInfo(WinStaObj) \
-  (PSYSTEM_CURSORINFO)((WinStaObj)->SystemCursor)
-
-#define IntReleaseCurIconObject(CurIconObj) \
-  ObmDereferenceObject(CurIconObj)
-
-#define IntLockProcessCursorIcons(W32Process) \
-  ExAcquireFastMutex(&W32Process->CursorIconListLock)
-
-#define IntUnLockProcessCursorIcons(W32Process) \
-  ExReleaseFastMutex(&W32Process->CursorIconListLock)
-
-#endif /* _WIN32K_CURSORICON_H */
-
-/* EOF */
-

reactos/subsys/win32k/include
dce.h removed after 1.14
diff -N dce.h
--- dce.h	4 Feb 2004 22:59:04 -0000	1.14
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,58 +0,0 @@
-#ifndef _WIN32K_DCE_H
-#define _WIN32K_DCE_H
-
-/* Ported from WINE by Jason Filby */
-
-typedef struct tagDCE *PDCE;
-
-#include <user32/wininternal.h>
-#include <include/window.h>
-
-typedef HANDLE HDCE;
-
-/* DC hook codes */
-#define DCHC_INVALIDVISRGN      0x0001
-#define DCHC_DELETEDC           0x0002
-
-#define DCHF_INVALIDATEVISRGN   0x0001
-#define DCHF_VALIDATEVISRGN     0x0002
-
-typedef enum
-{
-    DCE_CACHE_DC,   /* This is a cached DC (allocated by USER) */
-    DCE_CLASS_DC,   /* This is a class DC (style CS_CLASSDC) */
-    DCE_WINDOW_DC   /* This is a window DC (style CS_OWNDC) */
-} DCE_TYPE, *PDCE_TYPE;
-
-typedef struct tagDCE
-{
-    struct tagDCE *next;
-    HDC          hDC;
-    HWND         hwndCurrent;
-    HWND         hwndDC;
-    HRGN         hClipRgn;
-    DCE_TYPE     type;
-    DWORD        DCXFlags;
-    HANDLE       Self;
-} DCE;  /* PDCE already declared at top of file */
-
-#define  DCEOBJ_AllocDCE()  \
-  ((HDCE) GDIOBJ_AllocObj (sizeof (DCE), GDI_OBJECT_TYPE_DCE, (GDICLEANUPPROC) DCE_InternalDelete))
-#define  DCEOBJ_FreeDCE(hDCE)  GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE, GDIOBJFLAG_DEFAULT)
-#define  DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE))
-#define  DCEOBJ_UnlockDCE(hDCE) GDIOBJ_UnlockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
-
-PDCE FASTCALL DceAllocDCE(HWND hWnd, 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);
-BOOL FASTCALL DCE_InternalDelete(PDCE dce);
-HWND FASTCALL IntWindowFromDC(HDC hDc);
-PDCE FASTCALL DceFreeDCE(PDCE dce);
-void FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window);
-void FASTCALL DceEmptyCache(void);
-VOID FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window, int DeltaX, int DeltaY);
-
-#endif /* _WIN32K_DCE_H */

reactos/subsys/win32k/include
desktop.h removed after 1.8
diff -N desktop.h
--- desktop.h	9 Jul 2004 20:57:38 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-#ifndef _WIN32K_DESKTOP_H
-#define _WIN32K_DESKTOP_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <internal/ex.h>
-#include <internal/ps.h>
-#include "msgqueue.h"
-#include "window.h"
-
-extern PDESKTOP_OBJECT InputDesktop;
-extern HDESK InputDesktopHandle; 
-extern PWNDCLASS_OBJECT DesktopWindowClass;
-extern HDC ScreenDeviceContext;
-
-NTSTATUS FASTCALL
-InitDesktopImpl(VOID);
-
-NTSTATUS FASTCALL
-CleanupDesktopImpl(VOID);
-
-VOID FASTCALL
-IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop, PRECT Rect);
-
-LRESULT CALLBACK
-IntDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
-HDC FASTCALL
-IntGetScreenDC(VOID);
-
-HWND FASTCALL
-IntGetDesktopWindow (VOID);
-
-HWND FASTCALL
-IntGetCurrentThreadDesktopWindow(VOID);
-
-PUSER_MESSAGE_QUEUE FASTCALL
-IntGetFocusMessageQueue(VOID);
-
-VOID FASTCALL
-IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue);
-
-PDESKTOP_OBJECT FASTCALL
-IntGetActiveDesktop(VOID);
-
-NTSTATUS FASTCALL
-IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height);
-
-NTSTATUS FASTCALL
-IntHideDesktop(PDESKTOP_OBJECT Desktop);
-
-HDESK FASTCALL
-IntGetDesktopObjectHandle(PDESKTOP_OBJECT DesktopObject);
-
-NTSTATUS FASTCALL
-IntValidateDesktopHandle(
-   HDESK Desktop,
-   KPROCESSOR_MODE AccessMode,
-   ACCESS_MASK DesiredAccess,
-   PDESKTOP_OBJECT *Object);
-
-#define IntIsActiveDesktop(Desktop) \
-  ((Desktop)->WindowStation->ActiveDesktop == (Desktop))
-
-#endif /* _WIN32K_DESKTOP_H */
-
-/* EOF */

reactos/subsys/win32k/include
focus.h removed after 1.4
diff -N focus.h
--- focus.h	27 Jan 2004 08:49:58 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-#ifndef _WIN32K_FOCUS_H
-#define _WIN32K_FOCUS_H
-
-/*
- * These functions take the window handles from current message queue.
- */
-HWND FASTCALL
-IntGetCaptureWindow();
-HWND FASTCALL
-IntGetFocusWindow();
-
-/*
- * These functions take the window handles from current thread queue.
- */
-HWND FASTCALL
-IntGetThreadFocusWindow();
-
-BOOL FASTCALL
-IntMouseActivateWindow(PWINDOW_OBJECT Window);
-BOOL FASTCALL
-IntSetForegroundWindow(PWINDOW_OBJECT Window);
-HWND FASTCALL
-IntSetActiveWindow(PWINDOW_OBJECT Window);
-
-#endif /* _WIN32K_FOCUS_H */

reactos/subsys/win32k/include
hook.h removed after 1.3
diff -N hook.h
--- hook.h	7 Apr 2004 00:58:05 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-#ifndef _WIN32K_HOOK_H
-#define _WIN32K_HOOK_H
-
-#include <windows.h>
-#include <internal/ps.h>
-
-#define HOOK_THREAD_REFERENCED	(0x1)
-
-typedef struct tagHOOK
-{
-  LIST_ENTRY Chain;          /* Hook chain entry */
-  HHOOK      Self;           /* user handle for this hook */
-  PETHREAD   Thread;         /* Thread owning the hook */
-  int        HookId;         /* Hook table index */
-  HOOKPROC   Proc;           /* Hook function */
-  BOOLEAN    Ansi;           /* Is it an Ansi hook? */
-  ULONG      Flags;          /* Some internal flags */
-  UNICODE_STRING ModuleName; /* Module name for global hooks */
-} HOOK, *PHOOK;
-
-#define NB_HOOKS (WH_MAXHOOK-WH_MINHOOK+1)
-
-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;
-
-LRESULT FASTCALL 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 */

reactos/subsys/win32k/include
hotkey.h removed after 1.4
diff -N hotkey.h
--- hotkey.h	24 Feb 2004 13:27:02 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,47 +0,0 @@
-#ifndef _WIN32K_HOTKEY_H
-#define _WIN32K_HOTKEY_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <include/winsta.h>
-#include <include/window.h>
-
-typedef struct _HOT_KEY_ITEM
-{
-  LIST_ENTRY ListEntry;
-  struct _ETHREAD *Thread;
-  HWND hWnd;
-  int id;
-  UINT fsModifiers;
-  UINT vk;
-} HOT_KEY_ITEM, *PHOT_KEY_ITEM;
-
-NTSTATUS FASTCALL
-InitHotKeys(PWINSTATION_OBJECT WinStaObject);
-
-NTSTATUS FASTCALL
-CleanupHotKeys(PWINSTATION_OBJECT WinStaObject);
-
-BOOL
-GetHotKey (PWINSTATION_OBJECT WinStaObject,
-       UINT fsModifiers,
-	   UINT vk,
-	   struct _ETHREAD **Thread,
-	   HWND *hWnd,
-	   int *id);
-
-VOID
-UnregisterWindowHotKeys(PWINDOW_OBJECT Window);
-
-VOID
-UnregisterThreadHotKeys(struct _ETHREAD *Thread);
-
-#define IntLockHotKeys(WinStaObject) \
-  ExAcquireFastMutex(&WinStaObject->HotKeyListLock)
-
-#define IntUnLockHotKeys(WinStaObject) \
-  ExReleaseFastMutex(&WinStaObject->HotKeyListLock)
-
-#endif /* _WIN32K_HOTKEY_H */
-
-/* EOF */

reactos/subsys/win32k/include
input.h removed after 1.7
diff -N input.h
--- input.h	29 Apr 2004 20:26:35 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-#ifndef _WIN32K_INPUT_H
-#define _WIN32K_INPUT_H
-
-#include <internal/kbd.h>
-
-NTSTATUS FASTCALL
-InitInputImpl(VOID);
-NTSTATUS FASTCALL
-InitKeyboardImpl(VOID);
-PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue(VOID);
-PKBDTABLES W32kGetDefaultKeyLayout(VOID);
-VOID FASTCALL W32kKeyProcessMessage(LPMSG Msg, PKBDTABLES KeyLayout);
-BOOL FASTCALL IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt);
-BOOL FASTCALL IntMouseInput(MOUSEINPUT *mi);
-BOOL FASTCALL IntKeyboardInput(KEYBDINPUT *ki);
-
-#define ThreadHasInputAccess(W32Thread) \
-  (TRUE)
-
-#endif /* _WIN32K_INPUT_H */

reactos/subsys/win32k/include
menu.h removed after 1.29
diff -N menu.h
--- menu.h	24 Feb 2004 13:27:02 -0000	1.29
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,127 +0,0 @@
-#ifndef _WIN32K_MENU_H
-#define _WIN32K_MENU_H
-
-#include <ddk/ntddk.h>
-#include <napi/win32.h>
-#include <win32k/menu.h>
-
-#define IS_ATOM(x) \
-  (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
-  
-#define MENU_ITEM_TYPE(flags) \
-  ((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))
-  
-#ifndef MF_END
-#define MF_END             (0x0080)
-#endif
-
-typedef struct _MENU_ITEM
-{
-  struct _MENU_ITEM *Next;
-  UINT fType;
-  UINT fState;
-  UINT wID;
-  HMENU hSubMenu;
-  HBITMAP hbmpChecked;
-  HBITMAP hbmpUnchecked;
-  ULONG_PTR dwItemData;
-  UNICODE_STRING Text;
-  HBITMAP hbmpItem;
-  RECT Rect;
-  UINT XTab;
-} MENU_ITEM, *PMENU_ITEM;
-
-typedef struct _MENU_OBJECT
-{
-  PW32PROCESS W32Process;
-  LIST_ENTRY ListEntry;
-  FAST_MUTEX MenuItemsLock;
-  PMENU_ITEM MenuItemList;
-  ROSMENUINFO MenuInfo;
-  BOOL RtoL;
-} MENU_OBJECT, *PMENU_OBJECT;
-
-PMENU_OBJECT FASTCALL
-IntGetMenuObject(HMENU hMenu);
-
-#define IntLockMenuItems(MenuObj) \
-  ExAcquireFastMutex(&MenuObj->MenuItemsLock)
-
-#define IntUnLockMenuItems(MenuObj) \
-  ExReleaseFastMutex(&MenuObj->MenuItemsLock)
-
-#define IntLockProcessMenus(W32Process) \
-  ExAcquireFastMutex(&W32Process->MenuListLock)
-
-#define IntUnLockProcessMenus(W32Process) \
-  ExReleaseFastMutex(&W32Process->MenuListLock)
-
-#define IntReleaseMenuObject(MenuObj) \
-  ObmDereferenceObject(MenuObj)
-
-BOOL FASTCALL
-IntFreeMenuItem(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem,
-    BOOL RemoveFromList, BOOL bRecurse);
-    
-BOOL FASTCALL
-IntRemoveMenuItem(PMENU_OBJECT MenuObject, UINT uPosition, UINT uFlags, 
-                   BOOL bRecurse);
-    
-UINT FASTCALL
-IntDeleteMenuItems(PMENU_OBJECT MenuObject, BOOL bRecurse);
-
-BOOL FASTCALL
-IntDestroyMenuObject(PMENU_OBJECT MenuObject, BOOL bRecurse, BOOL RemoveFromProcess);
-
-PMENU_OBJECT FASTCALL
-IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar);
-
-PMENU_OBJECT FASTCALL
-IntCloneMenu(PMENU_OBJECT Source);
-
-BOOL FASTCALL
-IntSetMenuFlagRtoL(PMENU_OBJECT MenuObject);
-
-BOOL FASTCALL
-IntSetMenuContextHelpId(PMENU_OBJECT MenuObject, DWORD dwContextHelpId);
-
-BOOL FASTCALL
-IntGetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi);
-
-BOOL FASTCALL
-IntIsMenu(HMENU hMenu);
-
-BOOL FASTCALL
-IntSetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi);
-
-int FASTCALL
-IntGetMenuItemByFlag(PMENU_OBJECT MenuObject, UINT uSearchBy, UINT fFlag, 
-                      PMENU_ITEM *MenuItem, PMENU_ITEM *PrevMenuItem);
-                   
-UINT FASTCALL
-IntEnableMenuItem(PMENU_OBJECT MenuObject, UINT uIDEnableItem, UINT uEnable);
-
-DWORD FASTCALL
-IntCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck);
-
-BOOL FASTCALL
-IntSetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT uItem, UINT fByPos);
-
-BOOL FASTCALL
-IntSetMenuItemRect(PMENU_OBJECT MenuObject, UINT Item, BOOL fByPos, RECT *rcRect);
-
-BOOL FASTCALL
-IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process);
-
-BOOL FASTCALL
-IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
-                  PROSMENUITEMINFO ItemInfo);
-
-
-NTSTATUS FASTCALL
-InitMenuImpl(VOID);
-
-NTSTATUS FASTCALL
-CleanupMenuImpl(VOID);
-
-#endif /* _WIN32K_MENU_H */

reactos/subsys/win32k/include
mouse.h removed after 1.13
diff -N mouse.h
--- mouse.h	3 Jul 2004 13:55:36 -0000	1.13
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-#ifndef _WIN32K_MOUSE_H
-#define _WIN32K_MOUSE_H
-
-#include "../eng/misc.h"
-#include <include/winsta.h>
-//#include <ddk/ntddmou.h>
-
-BOOL FASTCALL IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo);
-BOOL FASTCALL IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap);
-INT  FASTCALL MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
-INT  FASTCALL MouseSafetyOnDrawEnd(SURFOBJ *SurfObj);
-BOOL FASTCALL MouseMoveCursor(LONG X, LONG Y);
-VOID FASTCALL EnableMouse(HDC hDisplayDC);
-VOID          MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount);
-VOID FASTCALL SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect);
-
-#ifndef XBUTTON1
-#define XBUTTON1	(0x01)
-#endif
-#ifndef XBUTTON2
-#define XBUTTON2	(0x02)
-#endif
-#ifndef MOUSEEVENTF_XDOWN
-#define MOUSEEVENTF_XDOWN	(0x80)
-#endif
-#ifndef MOUSEEVENTF_XUP
-#define MOUSEEVENTF_XUP	(0x100)
-#endif
-
-#endif /* _WIN32K_MOUSE_H */

reactos/subsys/win32k/include
msgqueue.h removed after 1.38
diff -N msgqueue.h
--- msgqueue.h	20 Jun 2004 16:27:14 -0000	1.38
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,244 +0,0 @@
-#ifndef _WIN32K_MSGQUEUE_H
-#define _WIN32K_MSGQUEUE_H
-
-#include <internal/ex.h>
-#include <windows.h>
-#include "caret.h"
-#include "hook.h"
-
-#define MSQ_HUNG        5000
-
-typedef struct _USER_MESSAGE
-{
-  LIST_ENTRY ListEntry;
-  BOOLEAN FreeLParam;
-  MSG Msg;
-} USER_MESSAGE, *PUSER_MESSAGE;
-
-struct _USER_MESSAGE_QUEUE;
-
-typedef struct _USER_SENT_MESSAGE
-{
-  LIST_ENTRY ListEntry;
-  MSG Msg;
-  PKEVENT CompletionEvent;
-  LRESULT* Result;
-  struct _USER_MESSAGE_QUEUE* SenderQueue;
-  SENDASYNCPROC CompletionCallback;
-  ULONG_PTR CompletionCallbackContext;
-  /* entry in the dispatching list of the sender's message queue */
-  LIST_ENTRY DispatchingListEntry;
-} USER_SENT_MESSAGE, *PUSER_SENT_MESSAGE;
-
-typedef struct _USER_SENT_MESSAGE_NOTIFY
-{
-  SENDASYNCPROC CompletionCallback;
-  ULONG_PTR CompletionCallbackContext;
-  LRESULT Result;
-  HWND hWnd;
-  UINT Msg;
-  LIST_ENTRY ListEntry;
-} USER_SENT_MESSAGE_NOTIFY, *PUSER_SENT_MESSAGE_NOTIFY;
-
-typedef struct _USER_MESSAGE_QUEUE
-{
-  /* Reference counter, only access this variable with interlocked functions! */
-  LONG References;
-  
-  /* Owner of the message queue */
-  struct _ETHREAD *Thread;
-  /* Queue of messages sent to the queue. */
-  LIST_ENTRY SentMessagesListHead;
-  /* Queue of messages posted to the queue. */
-  LIST_ENTRY PostedMessagesListHead;
-  /* Queue of sent-message notifies for the queue. */
-  LIST_ENTRY NotifyMessagesListHead;
-  /* Queue for hardware messages for the queue. */
-  LIST_ENTRY HardwareMessagesListHead;
-  /* 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. */
-  BOOLEAN QuitPosted;
-  /* The quit exit code. */
-  ULONG QuitExitCode;
-  /* Set if there are new messages in any of the queues. */
-  KEVENT NewMessages;  
-  /* Last time PeekMessage() was called. */
-  ULONG LastMsgRead;
-  /* Current window with focus (ie. receives keyboard input) for this queue. */
-  HWND FocusWindow;
-  /* True if a window needs painting. */
-  BOOLEAN PaintPosted;
-  /* Count of paints pending. */
-  ULONG PaintCount;
-  /* Current active window for this queue. */
-  HWND ActiveWindow;
-  /* Current capture window for this queue. */
-  HWND CaptureWindow;
-  /* Current move/size window for this queue */
-  HWND MoveSize;
-  /* Current menu owner window for this queue */
-  HWND MenuOwner;
-  /* Identifes the menu state */
-  BYTE MenuState;
-  /* Caret information for this queue */
-  PTHRDCARETINFO CaretInfo;
-  
-  /* Window hooks */
-  PHOOKTABLE Hooks;
-
-  /* queue state tracking */
-  WORD WakeBits;
-  WORD WakeMask;
-  WORD ChangedBits;
-  WORD ChangedMask;
-  
-  /* extra message information */
-  LPARAM ExtraInfo;
-
-  /* messages that are currently dispatched by other threads */
-  LIST_ENTRY DispatchingMessagesHead;
-  /* messages that are currently dispatched by this message queue, required for cleanup */
-  LIST_ENTRY LocalDispatchingMessagesHead;
-} USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;
-
-BOOL FASTCALL
-MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue);
-NTSTATUS FASTCALL
-MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-	       HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
-               UINT uTimeout, BOOL Block, ULONG_PTR *uResult);
-PUSER_MESSAGE FASTCALL
-MsqCreateMessage(LPMSG Msg, BOOLEAN FreeLParam);
-VOID FASTCALL
-MsqDestroyMessage(PUSER_MESSAGE Message);
-VOID FASTCALL
-MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-	       MSG* Msg, BOOLEAN FreeLParam);
-VOID FASTCALL
-MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode);
-BOOLEAN STDCALL
-MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
-	       IN BOOLEAN Hardware,
-	       IN BOOLEAN Remove,
-	       IN HWND Wnd,
-	       IN UINT MsgFilterLow,
-	       IN UINT MsgFilterHigh,
-	       OUT PUSER_MESSAGE* Message);
-VOID FASTCALL
-MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue);
-VOID FASTCALL
-MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
-PUSER_MESSAGE_QUEUE FASTCALL
-MsqCreateMessageQueue(struct _ETHREAD *Thread);
-VOID FASTCALL
-MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
-PUSER_MESSAGE_QUEUE FASTCALL
-MsqGetHardwareMessageQueue(VOID);
-NTSTATUS FASTCALL
-MsqWaitForNewMessage(PUSER_MESSAGE_QUEUE MessageQueue);
-NTSTATUS FASTCALL
-MsqInitializeImpl(VOID);
-BOOLEAN FASTCALL
-MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue);
-NTSTATUS FASTCALL
-MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue);
-VOID FASTCALL
-MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-		     PUSER_SENT_MESSAGE_NOTIFY NotifyMessage);
-VOID FASTCALL
-MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
-VOID FASTCALL
-MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
-LRESULT FASTCALL
-IntSendMessage(HWND hWnd,
-		UINT Msg,
-		WPARAM wParam,
-		LPARAM lParam);
-LRESULT FASTCALL
-IntPostOrSendMessage(HWND hWnd,
-		     UINT Msg,
-		     WPARAM wParam,
-		     LPARAM lParam);
-LRESULT FASTCALL
-IntSendMessageTimeout(HWND hWnd,
-                      UINT Msg,
-                      WPARAM wParam,
-                      LPARAM lParam,
-                      UINT uFlags,
-                      UINT uTimeout,
-                      ULONG_PTR *uResult);
-LRESULT FASTCALL
-IntDispatchMessage(MSG* Msg);
-BOOL FASTCALL
-IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl);
-
-VOID FASTCALL
-MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
-VOID FASTCALL
-MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam);
-VOID FASTCALL
-MsqInsertSystemMessage(MSG* Msg);
-BOOL FASTCALL
-MsqIsDblClk(LPMSG Msg, BOOL Remove);
-HWND FASTCALL
-MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd);
-
-inline BOOL MsqIsSignaled( PUSER_MESSAGE_QUEUE queue );
-inline VOID MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits );
-inline VOID MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits );
-BOOL IntInitMessagePumpHook();
-BOOL IntUninitMessagePumpHook();
-#define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
-
-PHOOKTABLE FASTCALL MsqGetHooks(PUSER_MESSAGE_QUEUE Queue);
-VOID FASTCALL MsqSetHooks(PUSER_MESSAGE_QUEUE Queue, PHOOKTABLE Hooks);
-
-LPARAM FASTCALL MsqSetMessageExtraInfo(LPARAM lParam);
-LPARAM FASTCALL MsqGetMessageExtraInfo(VOID);
-
-#define IntLockMessageQueue(MsgQueue) \
-  ExAcquireFastMutex(&(MsgQueue)->Lock)
-
-#define IntUnLockMessageQueue(MsgQueue) \
-  ExReleaseFastMutex(&(MsgQueue)->Lock)
-
-#define IntLockHardwareMessageQueue(MsgQueue) \
-  KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
-
-#define IntUnLockHardwareMessageQueue(MsgQueue) \
-  KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
-
-#define IntReferenceMessageQueue(MsgQueue) \
-  InterlockedIncrement(&(MsgQueue)->References)
-
-#define IntDereferenceMessageQueue(MsgQueue) \
-  do { \
-    if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
-    { \
-      DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
-      ExFreePool((MsgQueue)); \
-    } \
-  } while(0)
-
-/* check the queue status */
-#define MsqIsSignaled(MsgQueue) \
-  (((MsgQueue)->WakeBits & (MsgQueue)->WakeMask) || ((MsgQueue)->ChangedBits & (MsgQueue)->ChangedMask))
-
-#define IS_BTN_MESSAGE(message,code) \
-  ((message) == WM_LBUTTON##code || \
-   (message) == WM_MBUTTON##code || \
-   (message) == WM_RBUTTON##code || \
-   (message) == WM_XBUTTON##code || \
-   (message) == WM_NCLBUTTON##code || \
-   (message) == WM_NCMBUTTON##code || \
-   (message) == WM_NCRBUTTON##code || \
-   (message) == WM_NCXBUTTON##code )
-
-#endif /* _WIN32K_MSGQUEUE_H */
-
-/* EOF */

reactos/subsys/win32k/include
painting.h removed after 1.14
diff -N painting.h
--- painting.h	29 Apr 2004 21:13:16 -0000	1.14
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,26 +0,0 @@
-#ifndef _WIN32K_PAINTING_H
-#define _WIN32K_PAINTING_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <include/class.h>
-#include <include/msgqueue.h>
-#include <include/window.h>
-
-VOID FASTCALL
-IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion);
-BOOL FASTCALL
-IntRedrawWindow(PWINDOW_OBJECT Wnd, const RECT* UpdateRect, HRGN UpdateRgn, ULONG Flags);
-BOOL FASTCALL
-IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, PW32THREAD Thread,
-                   MSG *Message, BOOL Remove);
-BOOL STDCALL
-NtUserValidateRgn(HWND hWnd, HRGN hRgn);
-
-#define IntLockWindowUpdate(Window) \
-  ExAcquireFastMutex(&Window->UpdateLock)
-
-#define IntUnLockWindowUpdate(Window) \
-  ExReleaseFastMutex(&Window->UpdateLock)
-
-#endif /* _WIN32K_PAINTING_H */

reactos/subsys/win32k/include
prop.h removed after 1.7
diff -N prop.h
--- prop.h	26 Feb 2004 22:23:54 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-#ifndef _WIN32K_PROP_H
-#define _WIN32K_PROP_H
-
-typedef struct _PROPERTY
-{
-  LIST_ENTRY PropListEntry;
-  HANDLE Data;
-  ATOM Atom;
-} PROPERTY, *PPROPERTY;
-
-BOOL FASTCALL
-IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data);
-
-PPROPERTY FASTCALL
-IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom);
-
-#define IntLockWindowProperties(Window) \
-  ExAcquireFastMutex(&Window->PropListLock)
-
-#define IntUnLockWindowProperties(Window) \
-  ExReleaseFastMutex(&Window->PropListLock)
-
-#endif /* _WIN32K_PROP_H */
-

reactos/subsys/win32k/include
scroll.h removed after 1.5
diff -N scroll.h
--- scroll.h	12 May 2004 09:47:15 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
-#ifndef _WIN32K_SCROLL_H
-#define _WIN32K_SCROLL_H
-
-typedef struct _WINDOW_SCROLLINFO
-{
-  SCROLLBARINFO ScrollBarInfo;
-  SCROLLINFO ScrollInfo;
-} WINDOW_SCROLLINFO, *PWINDOW_SCROLLINFO;
-
-#define IntGetScrollbarInfoFromWindow(Window, i) \
-  ((PSCROLLBARINFO)(&((Window)->Scroll + i)->ScrollBarInfo))
-
-#define IntGetScrollInfoFromWindow(Window, i) \
-  ((LPSCROLLINFO)(&((Window)->Scroll + i)->ScrollInfo))
-
-#define SBOBJ_TO_SBID(Obj)	((Obj) - OBJID_HSCROLL)
-#define SBID_IS_VALID(id)	(id == SB_HORZ || id == SB_VERT || id == SB_CTL)
-
-BOOL FASTCALL IntCreateScrollBars(PWINDOW_OBJECT Window);
-BOOL FASTCALL IntDestroyScrollBars(PWINDOW_OBJECT Window);
-
-#endif /* _WIN32K_SCROLL_H */

reactos/subsys/win32k/include
timer.h removed after 1.5
diff -N timer.h
--- timer.h	31 Mar 2004 18:37:11 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-#ifndef _WIN32K_TIMER_H
-#define _WIN32K_TIMER_H
-
-typedef struct _MSG_TIMER_ENTRY{
-   LIST_ENTRY     ListEntry;
-   LARGE_INTEGER  Timeout;
-   HANDLE          ThreadID;
-   UINT           Period;
-   MSG            Msg;
-} MSG_TIMER_ENTRY, *PMSG_TIMER_ENTRY;
-
-NTSTATUS FASTCALL InitTimerImpl(VOID);
-VOID FASTCALL RemoveTimersThread(HANDLE ThreadID);
-VOID FASTCALL RemoveTimersWindow(HWND hWnd);
-PMSG_TIMER_ENTRY FASTCALL IntRemoveTimer(HWND hWnd, UINT_PTR IDEvent, HANDLE ThreadID, BOOL SysTimer);
-UINT_PTR FASTCALL IntSetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, BOOL SystemTimer);
-
-#endif /* _WIN32K_TIMER_H */

reactos/subsys/win32k/include
vis.h removed after 1.6
diff -N vis.h
--- vis.h	17 Jan 2004 15:18:25 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-/* $Id: vis.h,v 1.6 2004/01/17 15:18:25 navaraf Exp $
- *
- * COPYRIGHT:        See COPYING in the top level directory
- * PROJECT:          ReactOS Win32k subsystem
- * PURPOSE:          Visibility computations interface definition
- * FILE:             include/win32k/vis.h
- * PROGRAMMER:       Ge van Geldorp (ge@gse.nl)
- *
- */
-
-#ifndef _WIN32K_VIS_H
-#define _WIN32K_VIS_H
-
-#include <internal/ex.h>
-#include <include/window.h>
-
-HRGN FASTCALL
-VIS_ComputeVisibleRegion(PWINDOW_OBJECT Window, BOOLEAN ClientArea,
-   BOOLEAN ClipChildren, BOOLEAN ClipSiblings);
-
-VOID FASTCALL
-VIS_WindowLayoutChanged(PWINDOW_OBJECT Window, HRGN UncoveredRgn);
-
-#endif /* ! defined(_WIN32K_VIS_H) */
-
-/* EOF */
-

reactos/subsys/win32k/include
window.h removed after 1.59
diff -N window.h
--- window.h	27 May 2004 11:47:42 -0000	1.59
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,229 +0,0 @@
-#ifndef _WIN32K_WINDOW_H
-#define _WIN32K_WINDOW_H
-
-struct _PROPERTY;
-struct _WINDOW_OBJECT;
-typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT;
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <include/object.h>
-#include <include/class.h>
-#include <include/msgqueue.h>
-#include <include/winsta.h>
-#include <include/dce.h>
-#include <include/prop.h>
-#include <include/scroll.h>
-
-
-VOID FASTCALL
-WinPosSetupInternalPos(VOID);
-
-typedef struct _INTERNALPOS
-{
-  RECT NormalRect;
-  POINT IconPos;
-  POINT MaxPos;
-} INTERNALPOS, *PINTERNALPOS;
-
-typedef struct _WINDOW_OBJECT
-{
-  /* Pointer to the window class. */
-  PWNDCLASS_OBJECT Class;
-  /* entry in the window list of the class object */
-  LIST_ENTRY ClassListEntry;
-  /* Extended style. */
-  DWORD ExStyle;
-  /* Window name. */
-  UNICODE_STRING WindowName;
-  /* Style. */
-  DWORD Style;
-  /* Context help id */
-  DWORD ContextHelpId;
-  /* system menu handle. */
-  HMENU SystemMenu;
-  /* Handle of the module that created the window. */
-  HINSTANCE Instance;
-  /* Entry in the thread's list of windows. */
-  LIST_ENTRY ListEntry;
-  /* Pointer to the extra data associated with the window. */
-  PCHAR ExtraData;
-  /* Size of the extra data associated with the window. */
-  ULONG ExtraDataSize;
-  /* Position of the window. */
-  RECT WindowRect;
-  /* Position of the window's client area. */
-  RECT ClientRect;
-  /* Handle for the window. */
-  HANDLE Self;
-  /* Window flags. */
-  ULONG Flags;
-  /* Window menu handle or window id */
-  UINT IDMenu;
-  /* Handle of region of the window to be updated. */
-  HANDLE UpdateRegion;
-  HANDLE NCUpdateRegion;
-  /* Handle of the window region. */
-  HANDLE WindowRegion;
-  /* Lock to be held when manipulating (NC)UpdateRegion */
-  FAST_MUTEX UpdateLock;
-  /* Pointer to the owning thread's message queue. */
-  PUSER_MESSAGE_QUEUE MessageQueue;
-  /* Lock for the list of child windows. */
-  FAST_MUTEX RelativesLock;
-  struct _WINDOW_OBJECT* FirstChild;
-  struct _WINDOW_OBJECT* LastChild;
-  struct _WINDOW_OBJECT* NextSibling;
-  struct _WINDOW_OBJECT* PrevSibling;
-  /* Entry in the list of thread windows. */
-  LIST_ENTRY ThreadListEntry;
-  /* Handle to the parent window. */
-  HANDLE Parent;
-  /* Handle to the owner window. */
-  HANDLE Owner;
-  /* DC Entries (DCE) */
-  PDCE Dce;
-  /* Property list head.*/
-  LIST_ENTRY PropListHead;
-  FAST_MUTEX PropListLock;
-  ULONG PropListItems;
-  /* Scrollbar info */
-  PWINDOW_SCROLLINFO Scroll;
-  LONG UserData;
-  BOOL Unicode;
-  WNDPROC WndProcA;
-  WNDPROC WndProcW;
-  PETHREAD OwnerThread;
-  HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
-  PINTERNALPOS InternalPos;
-  ULONG Status;
-  /* counter for tiled child windows */
-  ULONG TiledCounter;
-} WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */
-
-/* Window flags. */
-#define WINDOWOBJECT_NEED_SIZE            (0x00000001)
-#define WINDOWOBJECT_NEED_ERASEBKGND      (0x00000002)
-#define WINDOWOBJECT_NEED_NCPAINT         (0x00000004)
-#define WINDOWOBJECT_NEED_INTERNALPAINT   (0x00000008)
-#define WINDOWOBJECT_RESTOREMAX           (0x00000020)
-
-#define WINDOWSTATUS_DESTROYING         (0x1)
-#define WINDOWSTATUS_DESTROYED          (0x2)
-
-#define HAS_DLGFRAME(Style, ExStyle) \
-            (((ExStyle) & WS_EX_DLGMODALFRAME) || \
-            (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME))))
-
-#define HAS_THICKFRAME(Style, ExStyle) \
-            (((Style) & WS_THICKFRAME) && \
-            (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)))
-
-#define HAS_THINFRAME(Style, ExStyle) \
-            (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP))))
-
-#define IntIsDesktopWindow(WndObj) \
-  (WndObj->Parent == NULL)
-
-#define IntIsBroadcastHwnd(hWnd) \
-  (hWnd == HWND_BROADCAST || hWnd == HWND_TOPMOST)
-
-#define IntGetWindowObject(hWnd) \
-  IntGetProcessWindowObject(PsGetWin32Process(), hWnd)
-
-#define IntReferenceWindowObject(WndObj) \
-  ObmReferenceObjectByPointer(WndObj, otWindow)
-
-#define IntReleaseWindowObject(WndObj) \
-  ObmDereferenceObject(WndObj)
-
-#define IntWndBelongsToThread(WndObj, W32Thread) \
-  (((WndObj->OwnerThread && WndObj->OwnerThread->Win32Thread)) && \
-   (WndObj->OwnerThread->Win32Thread == W32Thread))
-
-#define IntGetWndThreadId(WndObj) \
-  WndObj->OwnerThread->Cid.UniqueThread
-
-#define IntGetWndProcessId(WndObj) \
-  WndObj->OwnerThread->ThreadsProcess->UniqueProcessId
-
-#define IntLockRelatives(WndObj) \
-  ExAcquireFastMutex(&WndObj->RelativesLock)
-
-#define IntUnLockRelatives(WndObj) \
-  ExReleaseFastMutex(&WndObj->RelativesLock)
-
-#define IntLockThreadWindows(Thread) \
-  ExAcquireFastMutex(&Thread->WindowListLock)
-
-#define IntUnLockThreadWindows(Thread) \
-  ExReleaseFastMutex(&Thread->WindowListLock)
-
-
-PWINDOW_OBJECT FASTCALL
-IntGetProcessWindowObject(PW32PROCESS ProcessData, HWND hWnd);
-
-BOOL FASTCALL
-IntIsWindow(HWND hWnd);
-
-HWND* FASTCALL
-IntWinListChildren(PWINDOW_OBJECT Window);
-
-NTSTATUS FASTCALL
-InitWindowImpl (VOID);
-
-NTSTATUS FASTCALL
-CleanupWindowImpl (VOID);
-
-VOID FASTCALL
-IntGetClientRect (PWINDOW_OBJECT WindowObject, PRECT Rect);
-
-HWND FASTCALL
-IntGetActiveWindow (VOID);
-
-BOOL FASTCALL
-IntIsWindowVisible (HWND hWnd);
-
-BOOL FASTCALL
-IntIsChildWindow (HWND Parent, HWND Child);
-
-VOID FASTCALL
-IntUnlinkWindow(PWINDOW_OBJECT Wnd);
-
-VOID FASTCALL
-IntLinkWindow(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndParent, PWINDOW_OBJECT WndPrevSibling);
-
-PWINDOW_OBJECT FASTCALL
-IntGetAncestor(PWINDOW_OBJECT Wnd, UINT Type);
-
-PWINDOW_OBJECT FASTCALL
-IntGetParent(PWINDOW_OBJECT Wnd);
-
-PWINDOW_OBJECT FASTCALL
-IntGetParentObject(PWINDOW_OBJECT Wnd);
-
-INT FASTCALL
-IntGetWindowRgn(HWND hWnd, HRGN hRgn);
-
-INT FASTCALL
-IntGetWindowRgnBox(HWND hWnd, RECT *Rect);
-
-BOOL FASTCALL
-IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi);
-
-VOID FASTCALL
-IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, INT *cx, INT *cy);
-
-BOOL FASTCALL
-IntAnyPopup(VOID);
-
-BOOL FASTCALL
-IntIsWindowInDestroy(PWINDOW_OBJECT Window);
-
-DWORD IntRemoveWndProcHandle(WNDPROC Handle);
-DWORD IntRemoveProcessWndProcHandles(HANDLE ProcessID);
-DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode);
-
-#endif /* _WIN32K_WINDOW_H */
-
-/* EOF */

reactos/subsys/win32k/include
winpos.h removed after 1.14
diff -N winpos.h
--- winpos.h	14 Apr 2004 17:19:38 -0000	1.14
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
-#ifndef _WIN32K_WINPOS_H
-#define _WIN32K_WINPOS_H
-
-/* Undocumented flags. */
-#define SWP_NOCLIENTMOVE          0x0800
-#define SWP_NOCLIENTSIZE          0x1000
-
-#define IntPtInWindow(WndObject,x,y) \
-  ((x) >= (WndObject)->WindowRect.left && \
-   (x) < (WndObject)->WindowRect.right && \
-   (y) >= (WndObject)->WindowRect.top && \
-   (y) < (WndObject)->WindowRect.bottom && \
-   (!(WndObject)->WindowRegion || ((WndObject)->Style & WS_MINIMIZE) || \
-    NtGdiPtInRegion((WndObject)->WindowRegion, (INT)((x) - (WndObject)->WindowRect.left), \
-                    (INT)((y) - (WndObject)->WindowRect.top))))
-
-BOOL FASTCALL
-IntGetClientOrigin(HWND hWnd, LPPOINT Point);
-LRESULT FASTCALL
-WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect);
-UINT FASTCALL
-WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
-		    POINT* MinTrack, POINT* MaxTrack);
-UINT FASTCALL
-WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos);
-BOOLEAN FASTCALL
-WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx,
-		   INT cy, UINT flags);
-BOOLEAN FASTCALL
-WinPosShowWindow(HWND Wnd, INT Cmd);
-USHORT FASTCALL
-WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, 
-		      PWINDOW_OBJECT* Window);
-VOID FASTCALL WinPosActivateOtherWindow(PWINDOW_OBJECT Window);
-
-PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, 
-                                            POINT *pt, PRECT RestoreRect);
-
-#endif /* _WIN32K_WINPOS_H */

reactos/subsys/win32k/include
winsta.h removed after 1.25
diff -N winsta.h
--- winsta.h	1 May 2004 16:43:14 -0000	1.25
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,56 +0,0 @@
-#ifndef _WIN32K_WINSTA_H
-#define _WIN32K_WINSTA_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <internal/ex.h>
-#include <internal/ps.h>
-#include "msgqueue.h"
-
-#define PROCESS_WINDOW_STATION() \
-  ((HWINSTA)(IoGetCurrentProcess()->Win32WindowStation))
-
-#define SET_PROCESS_WINDOW_STATION(WinSta) \
-  ((IoGetCurrentProcess()->Win32WindowStation) = (PVOID)(WinSta))
-  
-#define WINSTA_ROOT_NAME	L"\\Windows\\WindowStations"
-#define WINSTA_ROOT_NAME_LENGTH	23
-
-/* Window Station Status Flags */
-#define WSS_LOCKED	(1)
-#define WSS_NOINTERACTIVE	(2)
-
-extern WINSTATION_OBJECT *InputWindowStation;
-extern PW32PROCESS LogonProcess;
-
-NTSTATUS FASTCALL
-InitWindowStationImpl(VOID);
-
-NTSTATUS FASTCALL
-CleanupWindowStationImpl(VOID);
-
-NTSTATUS FASTCALL
-IntValidateWindowStationHandle(
-   HWINSTA WindowStation,
-   KPROCESSOR_MODE AccessMode,
-   ACCESS_MASK DesiredAccess,
-   PWINSTATION_OBJECT *Object);
-
-BOOL FASTCALL
-IntGetWindowStationObject(PWINSTATION_OBJECT Object);
-
-BOOL FASTCALL
-IntInitializeDesktopGraphics(VOID);
-
-VOID FASTCALL
-IntEndDesktopGraphics(VOID);
-
-BOOL FASTCALL
-IntGetFullWindowStationName(
-   OUT PUNICODE_STRING FullName,
-   IN PUNICODE_STRING WinStaName,
-   IN OPTIONAL PUNICODE_STRING DesktopName);
-
-#endif /* _WIN32K_WINSTA_H */
-
-/* EOF */

reactos/subsys/win32k/main
dllmain.c 1.76 -> 1.76.12.1
diff -u -r1.76 -r1.76.12.1
--- dllmain.c	22 May 2004 21:12:15 -0000	1.76
+++ dllmain.c	15 Jul 2004 20:07:16 -0000	1.76.12.1
@@ -16,12 +16,14 @@
  *  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.76 2004/05/22 21:12:15 weiden Exp $
+/* $Id: dllmain.c,v 1.76.12.1 2004/07/15 20:07:16 weiden Exp $
  *
  *  Entry Point for win32k.sys
  */
 #include <w32k.h>
-#include <roscfg.h>
+
+#define NDEBUG
+#include <debug.h>
 
 #ifdef __USE_W32API
 typedef NTSTATUS (STDCALL *PW32_PROCESS_CALLBACK)(
@@ -53,22 +55,14 @@
   PW32PROCESS Win32Process;
   NTSTATUS Status;
 
-#if 0
-  DbgPrint ("Win32kProcessCallback() called\n");
-#endif
+  DPRINT("Win32kProcessCallback() called\n");
 
   Win32Process = Process->Win32Process;
   if (Create)
     {
-#if 0
-      DbgPrint ("  Create process\n");
-#endif
-
-      InitializeListHead(&Win32Process->ClassListHead);
-      ExInitializeFastMutex(&Win32Process->ClassListLock);
+      DPRINT("W32k: Create process\n");
       
-      InitializeListHead(&Win32Process->MenuListHead);
-      ExInitializeFastMutex(&Win32Process->MenuListLock);      
+      InitializeListHead(&Win32Process->ClassListHead);     
 
       InitializeListHead(&Win32Process->PrivateFontListHead);
       ExInitializeFastMutex(&Win32Process->PrivateFontListLock);
@@ -87,8 +81,7 @@
 					   &Win32Process->WindowStation);
 	  if (!NT_SUCCESS(Status))
 	    {
-	      DbgPrint("Win32K: Failed to reference a window station for "
-		       "process.\n");
+	      DPRINT1("Win32K: Failed to reference a window station for process.\n");
 	    }
 	}
       
@@ -97,13 +90,7 @@
     }
   else
     {
-#if 0
-      DbgPrint ("  Destroy process\n");
-      DbgPrint ("  IRQ level: %lu\n", KeGetCurrentIrql ());
-#endif
-	  IntRemoveProcessWndProcHandles((HANDLE)Process->UniqueProcessId);
-      IntCleanupMenus(Process, Win32Process);
-      IntCleanupCurIcons(Process, Win32Process);
+      DPRINT("W32k: Destroy process, IRQ level: %lu\n", KeGetCurrentIrql ());
 
       CleanupForProcess(Process, Process->UniqueProcessId);
 
@@ -130,20 +117,16 @@
   PW32THREAD Win32Thread;
   NTSTATUS Status;
 
-#if 0
-  DbgPrint ("Win32kThreadCallback() called\n");
-#endif
+  DPRINT("Win32kThreadCallback() called\n");
 
   Process = Thread->ThreadsProcess;
   Win32Thread = Thread->Win32Thread;
   if (Create)
     {
-#if 0
-      DbgPrint ("  Create thread\n");
-#endif
+      DPRINT("W32k: Create thread\n");
 
       Win32Thread->IsExiting = FALSE;
-      IntDestroyCaret(Win32Thread);
+      /* FIXME - destroy caret */
       Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
       Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
       Win32Thread->MessagePumpHookValue = 0;
@@ -165,7 +148,7 @@
 					     NULL);
 	  if (!NT_SUCCESS(Status))
 	    {
-	      DbgPrint("Win32K: Failed to reference a desktop for thread.\n");
+	      DPRINT1("Win32K: Failed to reference a desktop for thread.\n");
 	    }
 	  
 	  Win32Thread->hDesktop = Process->Win32Desktop;
@@ -173,14 +156,13 @@
     }
   else
     {
-#if 0
-      DbgPrint ("  Destroy thread\n");
-#endif
+      DPRINT("W32k: Destroy thread\n");
 
       Win32Thread->IsExiting = TRUE;
+      #if 0
       HOOK_DestroyThreadHooks(Thread);
+      #endif
       RemoveTimersThread(Thread->Cid.UniqueThread);
-      UnregisterThreadHotKeys(Thread);
       DestroyThreadWindows(Thread);
       IntBlockInput(Win32Thread, FALSE);
       MsqDestroyMessageQueue(Win32Thread->MessageQueue);
@@ -218,6 +200,8 @@
       return STATUS_UNSUCCESSFUL;
     }
 
+  IntInitUserResourceLocks();
+
   /*
    * Register our per-process and per-thread structures.
    */
@@ -234,35 +218,21 @@
     DbgPrint("Failed to initialize window station implementation!\n");
     return STATUS_UNSUCCESSFUL;
   }
-
-  Status = InitClassImpl();
-  if (!NT_SUCCESS(Status))
-  {
-    DbgPrint("Failed to initialize window class implementation!\n");
-    return STATUS_UNSUCCESSFUL;
-  }
-
+  
   Status = InitDesktopImpl();
   if (!NT_SUCCESS(Status))
   {
     DbgPrint("Failed to initialize window station implementation!\n");
     return STATUS_UNSUCCESSFUL;
   }
-
-  Status = InitWindowImpl();
-  if (!NT_SUCCESS(Status))
-  {
-    DbgPrint("Failed to initialize window implementation!\n");
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  Status = InitMenuImpl();
+  
+  Status = InitTimerImpl();
   if (!NT_SUCCESS(Status))
   {
-    DbgPrint("Failed to initialize menu implementation!\n");
+    DbgPrint("Failed to initialize timer implementation!\n");
     return STATUS_UNSUCCESSFUL;
   }
-
+  
   Status = InitInputImpl();
   if (!NT_SUCCESS(Status))
     {
@@ -283,21 +253,7 @@
       DbgPrint("Failed to initialize message queue implementation.\n");
       return(Status);
     }
-
-  Status = InitTimerImpl();
-  if (!NT_SUCCESS(Status))
-    {
-      DbgPrint("Failed to initialize timer implementation.\n");
-      return(Status);
-    }
-
-  Status = InitAcceleratorImpl();
-  if (!NT_SUCCESS(Status))
-    {
-      DbgPrint("Failed to initialize accelerator implementation.\n");
-      return(Status);
-    }
-
+  
   InitGdiObjectHandleTable ();
 
   /* Initialize FreeType library */
@@ -323,4 +279,37 @@
   return TRUE;
 }
 
+NTSTATUS
+IntConvertProcessToGUIProcess(PEPROCESS Process)
+{
+  /* FIXME - Convert process to GUI process! */
+  DPRINT1("FIXME: Convert Process to GUI Process!!!!\n");
+  return STATUS_UNSUCCESSFUL;
+}
+
+inline NTSTATUS
+IntConvertThreadToGUIThread(PETHREAD Thread)
+{
+  NTSTATUS Status;
+  
+  /* FIXME - do this atomic!!! */
+  
+  if(Thread->Win32Thread != NULL)
+  {
+    return STATUS_SUCCESS;
+  }
+  
+  /* FIXME - Convert thread to GUI thread! */
+  Status = STATUS_UNSUCCESSFUL;
+  DPRINT1("FIXME: Convert Thread to GUI Thread!!!!\n");
+  
+  if(NT_SUCCESS(Status) && Thread->ThreadsProcess->Win32Process == NULL)
+  {
+    /* We also need to convert the process */
+    return IntConvertProcessToGUIProcess(Thread->ThreadsProcess);
+  }
+  
+  return Status;
+}
+
 /* EOF */

reactos/subsys/win32k
makefile 1.101 -> 1.101.4.1
diff -u -r1.101 -r1.101.4.1
--- makefile	3 Jul 2004 13:55:36 -0000	1.101
+++ makefile	15 Jul 2004 20:07:17 -0000	1.101.4.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.101 2004/07/03 13:55:36 navaraf Exp $
+# $Id: makefile,v 1.101.4.1 2004/07/15 20:07:17 weiden Exp $
 
 PATH_TO_TOP = ../..
 
@@ -53,12 +53,12 @@
 
 LDR_OBJECTS = ldr/loader.o
 
-NTUSER_OBJECTS = ntuser/accelerator.o ntuser/callback.o ntuser/caret.o ntuser/class.o \
+NTUSER_OBJECTS = ntuser/ntuser.o ntuser/accelerator.o ntuser/callback.o ntuser/caret.o ntuser/class.o \
                  ntuser/clipboard.o ntuser/csr.o ntuser/focus.o ntuser/desktop.o \
                  ntuser/guicheck.o ntuser/hook.o ntuser/hotkey.o ntuser/input.o \
                  ntuser/keyboard.o ntuser/menu.o ntuser/message.o ntuser/metric.o \
                  ntuser/misc.o ntuser/msgqueue.o ntuser/painting.o ntuser/prop.o \
-                 ntuser/scrollbar.o ntuser/stubs.o ntuser/timer.o ntuser/useratom.o \
+                 ntuser/scrollbar.o ntuser/stubs.o ntuser/timer.o ntuser/useratom.o ntuser/userlock.o \
                  ntuser/vis.o ntuser/windc.o ntuser/window.o ntuser/winpos.o ntuser/winsta.o
 
 OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o  \

reactos/subsys/win32k
w32k.h 1.4 -> 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- w32k.h	3 Jul 2004 13:55:36 -0000	1.4
+++ w32k.h	15 Jul 2004 20:07:17 -0000	1.4.4.1
@@ -12,11 +12,10 @@
 #include <ddk/ntddk.h>
 #include <ddk/ntddmou.h>
 
-#include <win32k/win32k.h>
-#include <csrss/csrss.h>
-
 #include <internal/ob.h>
 #include <internal/safe.h>
+#include <internal/kbd.h>
+#include <internal/ps.h>
 
 #include <napi/win32.h>
 #include <ntos.h>
@@ -24,56 +23,37 @@
 #include <float.h>
 #include <windows.h>
 
+#include <win32k/win32k.h>
+#include <csrss/csrss.h>
+
 #include <rosrtl/string.h>
 #include <user32/callback.h>
 
-#include <include/accelerator.h>
-#include <include/callback.h>
-#include <include/caret.h>
-#include <include/class.h>
-#include <include/cleanup.h>
-#include <include/clipboard.h>
+#include <eng/objects.h>
+#include <eng/misc.h>
+#include <eng/handle.h>
+#include <eng/clip.h>
+
+#include <include/misc.h>
 #include <include/color.h>
 #include <include/csr.h>
-#include <include/cursoricon.h>
-#include <include/dce.h>
-#include <include/desktop.h>
 #include <include/dib.h>
 #include <include/eng.h>
 #include <include/error.h>
-#include <include/focus.h>
 #include <include/guicheck.h>
-#include <include/hook.h>
-#include <include/hotkey.h>
-#include <include/input.h>
 #include <include/inteng.h>
 #include <include/intgdi.h>
-#include <include/menu.h>
-#include <include/mouse.h>
-#include <include/msgqueue.h>
 #include <include/object.h>
 #include <include/paint.h>
-#include <include/painting.h>
 #include <include/palette.h>
 #include <include/path.h>
-#include <include/prop.h>
 #include <include/rect.h>
-#include <include/scroll.h>
 #include <include/surface.h>
 #include <include/tags.h>
 #include <include/text.h>
-#include <include/timer.h>
-#include <include/timer.h>
 #include <include/useratom.h>
-#include <include/vis.h>
-#include <include/window.h>
-#include <include/winpos.h>
-#include <include/winsta.h>
-
-#include <eng/objects.h>
-#include <eng/misc.h>
-#include <eng/handle.h>
-#include <eng/clip.h>
+#include <include/internal.h>
+#include <include/callback.h>
 
 #include <dib/dib.h>
 

reactos/subsys/win32k/misc
object.c 1.12 -> 1.12.8.1
diff -u -r1.12 -r1.12.8.1
--- object.c	20 Jun 2004 00:45:36 -0000	1.12
+++ object.c	15 Jul 2004 20:07:17 -0000	1.12.8.1
@@ -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: object.c,v 1.12 2004/06/20 00:45:36 navaraf Exp $
+/* $Id: object.c,v 1.12.8.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -28,9 +28,7 @@
  *     06-06-2001  CSH  Ported kernel object manager
  */
 /* INCLUDES ******************************************************************/
-
-#include <ddk/ntddk.h>
-#include <include/object.h>
+#include <w32k.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -43,206 +41,7 @@
 
 /* FUNCTIONS *****************************************************************/
 
-VOID FASTCALL
-ObmpPerformRetentionChecks(PUSER_OBJECT_HEADER ObjectHeader)
-{
-  if (ObjectHeader->RefCount < 0)
-    {
-      DPRINT1("ObjectHeader 0x%X has invalid reference count (%d)\n",
-	       ObjectHeader, ObjectHeader->RefCount);
-    }
-  
-  if (ObjectHeader->HandleCount < 0)
-    {
-      DPRINT1("Object 0x%X has invalid handle count (%d)\n",
-	       ObjectHeader, ObjectHeader->HandleCount);
-    }
-  
-  if ((ObjectHeader->RefCount == 0) && (ObjectHeader->HandleCount == 0))
-    {
-      ExFreePool(ObjectHeader);
-    }
-}
 
-PUSER_HANDLE FASTCALL
-ObmpGetObjectByHandle(PUSER_HANDLE_TABLE HandleTable,
-		      HANDLE Handle)
-/*
- * FUNCTION: Get the data structure for a handle
- * ARGUMENTS:
- *   HandleTable = Table to search
- *   Handle      = Handle to get data structure for
- * RETURNS:
- *   Pointer to the data structure identified by the handle on success,
- *   NULL on failure
- */
-{
-  ULONG Index = (((ULONG)Handle) >> 2) - 1;
-  ULONG Count = Index / HANDLE_BLOCK_ENTRIES;
-  PUSER_HANDLE_BLOCK Block = NULL;
-  PLIST_ENTRY Current;
-  ULONG i;
-  
-  if (NULL == Handle)
-    {
-      return NULL;
-    }
-
-  Current = HandleTable->ListHead.Flink;
-  
-  for (i = 0; i < Count; i++)
-    {
-      Current = Current->Flink;
-      if (Current == &(HandleTable->ListHead))
-	{
-      DPRINT1("Invalid handle 0x%x\n", Handle);
-	  return NULL;
-	}
-    }
-  
-  Block = CONTAINING_RECORD(Current, USER_HANDLE_BLOCK, ListEntry);
-  return &(Block->Handles[Index % HANDLE_BLOCK_ENTRIES]);
-}
-
-VOID FASTCALL
-ObmpCloseAllHandles(PUSER_HANDLE_TABLE HandleTable)
-{
-  PLIST_ENTRY CurrentEntry;
-  PUSER_HANDLE_BLOCK Current;
-  PVOID ObjectBody;
-  ULONG i;
-
-  ObmpLockHandleTable(HandleTable);
-  
-  CurrentEntry = HandleTable->ListHead.Flink;
-
-  while (CurrentEntry != &HandleTable->ListHead)
-    {
-      Current = CONTAINING_RECORD(CurrentEntry, USER_HANDLE_BLOCK, ListEntry);
-      
-      for (i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
-	{
-	  ObjectBody = Current->Handles[i].ObjectBody;
-	  
-	  if (ObjectBody != NULL)
-	    {
-	      PUSER_OBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
-	      
-	      ObmReferenceObjectByPointer(ObjectBody, otUnknown);
-	      ObjectHeader->HandleCount--;
-	      Current->Handles[i].ObjectBody = NULL;
-	      
-	      ObmpUnlockHandleTable(HandleTable);
-	      
-	      ObmDereferenceObject(ObjectBody);
-
-	      ObmpLockHandleTable(HandleTable);
-	      CurrentEntry = &HandleTable->ListHead;
-	      break;
-	    }
-	}
-      
-      CurrentEntry = CurrentEntry->Flink;
-    }
-  
-  ObmpUnlockHandleTable(HandleTable);
-}
-
-VOID FASTCALL
-ObmpDeleteHandleTable(PUSER_HANDLE_TABLE HandleTable)
-{
-  PUSER_HANDLE_BLOCK Current;
-  PLIST_ENTRY CurrentEntry;
-
-  ObmpCloseAllHandles(HandleTable);
-  
-  CurrentEntry = RemoveHeadList(&HandleTable->ListHead);
-  
-  while (CurrentEntry != &HandleTable->ListHead)
-  {
-    Current = CONTAINING_RECORD(CurrentEntry,
-				USER_HANDLE_BLOCK,
-				ListEntry);
-
-    ExFreePool(Current);
-    
-    CurrentEntry = RemoveHeadList(&HandleTable->ListHead);
-  }
-}
-
-PVOID FASTCALL
-ObmpDeleteHandle(PUSER_HANDLE_TABLE HandleTable,
-		 HANDLE Handle)
-{
-  PUSER_OBJECT_HEADER ObjectHeader;
-  PUSER_HANDLE Entry;
-  PVOID ObjectBody;
-
-  ObmpLockHandleTable(HandleTable);
-  
-  Entry = ObmpGetObjectByHandle(HandleTable, Handle);
-  if (Entry == NULL)
-    {
-      DPRINT1("Invalid handle\n");
-      ObmpUnlockHandleTable(HandleTable);
-      return NULL;
-    }
-
-  ObjectBody = Entry->ObjectBody;
-  
-  if (ObjectBody != NULL)
-    {
-      ObjectHeader = BODY_TO_HEADER(ObjectBody);
-      ObjectHeader->HandleCount--;
-      ObmReferenceObjectByPointer(ObjectBody, otUnknown);
-      Entry->ObjectBody = NULL;
-    }
-  
-  ObmpUnlockHandleTable(HandleTable);
-
-  return ObjectBody;
-}
-
-NTSTATUS FASTCALL
-ObmpInitializeObject(PUSER_HANDLE_TABLE HandleTable,
-		     PUSER_OBJECT_HEADER ObjectHeader,
-		     PHANDLE Handle,
-		     USER_OBJECT_TYPE ObjectType,
-		     ULONG ObjectSize)
-{
-  DWORD Status = STATUS_SUCCESS;
-  
-  ObjectHeader->Type = ObjectType;
-  ObjectHeader->HandleCount = 0;
-  ObjectHeader->RefCount = 1;
-  ObjectHeader->Size = ObjectSize;
-
-  if (Handle != NULL)
-    {
-      Status = ObmCreateHandle(HandleTable,
-			       HEADER_TO_BODY(ObjectHeader),
-			       Handle);
-    }
-
-  return Status;
-}
-
-
-ULONG FASTCALL
-ObmGetReferenceCount(PVOID ObjectBody)
-{
-  PUSER_OBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
-
-  return ObjectHeader->RefCount;
-}
-
-ULONG FASTCALL
-ObmGetHandleCount(PVOID ObjectBody)
-{
-  PUSER_OBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
-
-  return ObjectHeader->HandleCount;
-}
 
 VOID FASTCALL
 ObmReferenceObject(PVOID ObjectBody)
@@ -255,17 +54,11 @@
 {
   PUSER_OBJECT_HEADER ObjectHeader;
   
-  if (!ObjectBody)
-    {
-      DPRINT1("Cannot Reference NULL!\n");
-      return;
-    }
+  ASSERT(ObjectBody);
   
   ObjectHeader = BODY_TO_HEADER(ObjectBody);
-  
-  ObjectHeader->RefCount++;
 
-  ObmpPerformRetentionChecks(ObjectHeader);
+  InterlockedIncrement(&ObjectHeader->RefCount);
 }
 
 VOID FASTCALL
@@ -279,40 +72,42 @@
 {
   PUSER_OBJECT_HEADER ObjectHeader;
   
-  if (!ObjectBody)
-    {
-      DPRINT1("Cannot Dereference NULL!\n");
-      return;
-    }
+  ASSERT(ObjectBody);
   
   ObjectHeader = BODY_TO_HEADER(ObjectBody);
   
-  ObjectHeader->RefCount--;
-  ObmpPerformRetentionChecks(ObjectHeader);
+  if(InterlockedDecrement(&ObjectHeader->RefCount) == 0)
+  {
+    /* free the object when 0 references reached */
+    ExFreePool(ObjectHeader);
+  }
 }
 
-NTSTATUS FASTCALL
-ObmReferenceObjectByPointer(PVOID ObjectBody,
-			    USER_OBJECT_TYPE ObjectType)
-/*
- * FUNCTION: Increments the pointer reference count for a given object
- * ARGUMENTS:
- *         ObjectBody = Object's body
- *         ObjectType = Object type
- * RETURNS: Status
- */
-{
-  PUSER_OBJECT_HEADER ObjectHeader;
-  
-  ObjectHeader = BODY_TO_HEADER(ObjectBody);
-  
-  if ((ObjectType != otUnknown) && (ObjectHeader->Type != ObjectType))
+PVOID FASTCALL
+ObmEnumHandles(PUSER_HANDLE_TABLE HandleTable,
+               USER_OBJECT_TYPE ObjectType,
+               PVOID UserData,
+               PFNENUMHANDLESPROC EnumProc)
+{
+  PUSER_OBJECT_HEADER ObjectHeader, *Slot, *LastSlot;
+  
+  ASSERT(EnumProc);
+  
+  /* enumerate all handles */
+  Slot = HandleTable->Handles;
+  for(LastSlot = HandleTable->Handles + N_USER_HANDLES; Slot < LastSlot; Slot++)
+  {
+    if((ObjectHeader = *Slot) && (ObjectType == ObjectHeader->Type || ObjectType == otUNKNOWN))
     {
-      return STATUS_INVALID_PARAMETER;
+      PVOID ObjectBody = HEADER_TO_BODY(ObjectHeader);
+      if(EnumProc(ObjectBody, UserData))
+      {
+        return ObjectBody;
+      }
     }
-  ObjectHeader->RefCount++;
+  }
   
-  return STATUS_SUCCESS;
+  return NULL;
 }
 
 PVOID FASTCALL
@@ -321,183 +116,141 @@
 		USER_OBJECT_TYPE ObjectType,
 		ULONG ObjectSize)
 {
-  PUSER_OBJECT_HEADER ObjectHeader;
+  PUSER_OBJECT_HEADER ObjectHeader, *Slot, *LastSlot;
   PVOID ObjectBody;
-  DWORD Status;
+  
+  ASSERT(HandleTable);
+  ASSERT(Handle);
+  ASSERT(ObjectSize);
+  
+  if(HandleTable->HandleCount == N_USER_HANDLES)
+  {
+    DPRINT1("No more free user handles!\n");
+    return NULL;
+  }
   
   ObjectHeader = (PUSER_OBJECT_HEADER)ExAllocatePool(PagedPool, 
-				     ObjectSize + sizeof(USER_OBJECT_HEADER));
+                                                     sizeof(USER_OBJECT_HEADER) + ObjectSize);
   if (!ObjectHeader)
-    {
-      return NULL;
-    }
+  {
+    DPRINT1("Not enough memory to create a user object\n");
+    return NULL;
+  }
   
-  ObjectBody = HEADER_TO_BODY(ObjectHeader);
+  ObjectHeader->Type = ObjectType;
+  ObjectHeader->RefCount = 1;
   
+  ObjectBody = HEADER_TO_BODY(ObjectHeader);
   RtlZeroMemory(ObjectBody, ObjectSize);
   
-  Status = ObmpInitializeObject(HandleTable,
-				ObjectHeader,
-				Handle,
-				ObjectType,
-				ObjectSize);
-  
-  if (!NT_SUCCESS(Status))
+  /* search for a free handle slot */
+  Slot = HandleTable->Handles;
+  for(LastSlot = HandleTable->Handles + N_USER_HANDLES; Slot < LastSlot; Slot++)
+  {
+    if(InterlockedCompareExchange((LONG*)Slot, (LONG)ObjectHeader, 0) == 0)
     {
-      ExFreePool(ObjectHeader);
-      return NULL;
+      /* found and assigned a free handle */
+      InterlockedIncrement((LONG*)&HandleTable->HandleCount);
+      
+      ObjectHeader->Slot = Slot; 
+      *Handle = (HANDLE)(((Slot - HandleTable->Handles) >> 2) + 1);
+      return ObjectBody;
     }
+  }
   
-  return ObjectBody;
+  ExFreePool(ObjectHeader);
+  
+  return NULL;
 }
 
-NTSTATUS FASTCALL
-ObmCreateHandle(PUSER_HANDLE_TABLE HandleTable,
-		PVOID ObjectBody,
-		PHANDLE HandleReturn)
-/*
- * FUNCTION: Add a handle referencing an object
- * ARGUMENTS:
- *   HandleTable = Table to put handle in
- *   ObjectBody  = Object body that the handle should refer to
- * RETURNS: The created handle
- */
+BOOL FASTCALL
+ObmObjectDeleted(PVOID ObjectBody)
 {
-  PUSER_HANDLE_BLOCK NewBlock;
-  PLIST_ENTRY Current;
-  ULONG Handle;
-  ULONG i;
-
-  if (ObjectBody != NULL) 
-    {
-      BODY_TO_HEADER(ObjectBody)->HandleCount++;
-    }
+  PUSER_OBJECT_HEADER ObjectHeader;
   
-  ObmpLockHandleTable(HandleTable);
-
-  Handle = 1;
-  Current = HandleTable->ListHead.Flink;
-  /*
-   * Scan through the currently allocated Handle blocks looking for a free
-   * slot
-   */
-  while (Current != &(HandleTable->ListHead))
-    {
-      PUSER_HANDLE_BLOCK Block = 
-	CONTAINING_RECORD(Current, USER_HANDLE_BLOCK, ListEntry);
-           
-      for (i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
-	{
-	  if (!Block->Handles[i].ObjectBody)
-	    {
-	      Block->Handles[i].ObjectBody = ObjectBody;
-	      ObmpUnlockHandleTable(HandleTable);
-	      *HandleReturn = (HANDLE)((Handle + i) << 2);
-	      return STATUS_SUCCESS;
-	    }
-	}
-
-      Handle = Handle + HANDLE_BLOCK_ENTRIES;
-      Current = Current->Flink;
-    }
-
-  /*
-   * Add a new Handle block to the end of the list
-   */
-  NewBlock = (PUSER_HANDLE_BLOCK)ExAllocatePool(PagedPool, 
-						sizeof(USER_HANDLE_BLOCK));
-  if (!NewBlock)
-    {
-      DPRINT1("Unable to allocate new handle block\n");
-      *HandleReturn = (PHANDLE)NULL;
-      return STATUS_INSUFFICIENT_RESOURCES;
-    }
+  ASSERT(ObjectBody);
   
-  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;
+  ObjectHeader = BODY_TO_HEADER(ObjectBody);
+  return ((ObjectHeader->Slot == NULL) || (*(ObjectHeader->Slot) != ObjectHeader));
 }
 
-NTSTATUS FASTCALL
-ObmReferenceObjectByHandle(PUSER_HANDLE_TABLE HandleTable,
-			   HANDLE Handle,
-			   USER_OBJECT_TYPE ObjectType,
-			   PVOID* Object)
-/*
- * FUNCTION: Increments the reference count for an object and returns a
- *           pointer to its body
- * ARGUMENTS:
- *         HandleTable = Table to search
- *         Handle = Handle for the object
- *         ObjectType = Type of object
- *         Object (OUT) = Points to the object body on return
- * RETURNS: Status
- */
+USER_OBJECT_TYPE FASTCALL
+ObmGetObjectType(PUSER_HANDLE_TABLE HandleTable,
+                 PVOID ObjectBody)
 {
   PUSER_OBJECT_HEADER ObjectHeader;
-  PUSER_HANDLE UserHandle;
-  PVOID ObjectBody;
-  
-  ObmpLockHandleTable(HandleTable);
   
-  UserHandle = ObmpGetObjectByHandle(HandleTable, Handle);
-  
-  if ((UserHandle == NULL) || (UserHandle->ObjectBody == NULL))
-    {
-      ObmpUnlockHandleTable(HandleTable);
-      return STATUS_UNSUCCESSFUL;
-    }
+  ASSERT(ObjectBody);
   
-  ObjectBody = UserHandle->ObjectBody;
-  ObmReferenceObjectByPointer(ObjectBody, ObjectType);
+  ObjectHeader = BODY_TO_HEADER(ObjectBody);
+  return ObjectHeader->Type;
+}
+
+BOOL FASTCALL
+ObmDeleteObject(PUSER_HANDLE_TABLE HandleTable,
+                PVOID ObjectBody)
+{
+  PUSER_OBJECT_HEADER ObjectHeader;
   
-  ObmpUnlockHandleTable(HandleTable);
+  ASSERT(ObjectBody);
   
   ObjectHeader = BODY_TO_HEADER(ObjectBody);
   
-  if ((ObjectType != otUnknown) && (ObjectHeader->Type != ObjectType))
-    {
-      DPRINT1("Object type mismatch 0x%x 0x%x\n", ObjectType, ObjectHeader->Type);
-      return STATUS_UNSUCCESSFUL;
-    }
+  if(ObjectHeader->Slot == NULL)
+  {
+    DPRINT1("Object 0x%x has been deleted already!\n");
+    return FALSE;
+  }
   
-  *Object = ObjectBody;
+  /* remove the object from the handle table */
+  InterlockedCompareExchange((LONG*)ObjectHeader->Slot, 0, (LONG)ObjectHeader);
+  InterlockedDecrement((LONG*)&HandleTable->HandleCount);
+  ObjectHeader->Slot = NULL;
   
-  return STATUS_SUCCESS;
+  ObmDereferenceObject(ObjectBody);
+  
+  return TRUE;
 }
 
-NTSTATUS FASTCALL
-ObmCloseHandle(PUSER_HANDLE_TABLE HandleTable,
-	       HANDLE Handle)
+PVOID FASTCALL
+ObmGetObject(PUSER_HANDLE_TABLE HandleTable,
+             HANDLE Handle,
+	     USER_OBJECT_TYPE ObjectType)
 {
-  PVOID ObjectBody;
-
-  ObjectBody = ObmpDeleteHandle(HandleTable, Handle);
-  if (ObjectBody == NULL)
-    {
-      return STATUS_UNSUCCESSFUL;
-    }
+  PUSER_OBJECT_HEADER *Slot, ObjectHeader;
   
-  ObmDereferenceObject(ObjectBody);
+  if(Handle == NULL || (ULONG)Handle > N_USER_HANDLES)
+  {
+    return FALSE;
+  }
+  
+  Slot = HandleTable->Handles + (ULONG)Handle - 1;
+  if((ObjectHeader = (*Slot)) && (ObjectType == ObjectHeader->Type))
+  {
+    return HEADER_TO_BODY(ObjectHeader);
+  }
   
-  return STATUS_SUCCESS;
+  return NULL;
 }
 
 VOID FASTCALL
 ObmInitializeHandleTable(PUSER_HANDLE_TABLE HandleTable)
 {
-  InitializeListHead(&HandleTable->ListHead);
-  ExInitializeFastMutex(&HandleTable->ListLock);
+  PUSER_OBJECT_HEADER *Slot, *LastSlot;
+  
+  HandleTable->HandleCount = 0;
+  /* Clear the handle table */
+  Slot = HandleTable->Handles;
+  for(LastSlot = HandleTable->Handles + N_USER_HANDLES; Slot < LastSlot; Slot++)
+  {
+    *Slot = NULL;
+  }
 }
 
 VOID FASTCALL
 ObmFreeHandleTable(PUSER_HANDLE_TABLE HandleTable)
 {
-  ObmpDeleteHandleTable(HandleTable);
+  /* FIXME - delete all handles */
 }
 
 PUSER_HANDLE_TABLE FASTCALL

reactos/subsys/win32k/ntuser
accelerator.c 1.10 -> 1.10.12.1
diff -u -r1.10 -r1.10.12.1
--- accelerator.c	10 May 2004 17:07:18 -0000	1.10
+++ accelerator.c	15 Jul 2004 20:07:17 -0000	1.10.12.1
@@ -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: accelerator.c,v 1.10 2004/05/10 17:07:18 weiden Exp $
+/* $Id: accelerator.c,v 1.10.12.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -55,470 +55,4 @@
 
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS FASTCALL
-InitAcceleratorImpl(VOID)
-{
-  return(STATUS_SUCCESS);
-}
 
-NTSTATUS FASTCALL
-CleanupAcceleratorImpl(VOID)
-{
-  return(STATUS_SUCCESS);
-}
-
-int
-STDCALL
-NtUserCopyAcceleratorTable(
-  HACCEL Table,
-  LPACCEL Entries,
-  int EntriesCount)
-{
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE AcceleratorTable;
-  NTSTATUS Status;
-  int Ret;
-  
-  Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(),
-    UserMode,
-	0,
-	&WindowStation);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    return 0;
-  }
-  
-  Status = ObmReferenceObjectByHandle(WindowStation->HandleTable,
-    Table,
-    otAcceleratorTable,
-    (PVOID*)&AcceleratorTable);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE);
-    ObDereferenceObject(WindowStation);
-    return 0;
-  }
-  
-  if(Entries)
-  {
-    Ret = min(EntriesCount, AcceleratorTable->Count);
-    Status = MmCopyToCaller(Entries, AcceleratorTable->Table, Ret * sizeof(ACCEL));
-    if (!NT_SUCCESS(Status))
-    {
-	  ObmDereferenceObject(AcceleratorTable);
-      ObDereferenceObject(WindowStation);
-      SetLastNtError(Status);
-      return 0;
-    }
-  }
-  else
-  {
-    Ret = AcceleratorTable->Count;
-  }
-  
-  ObmDereferenceObject(AcceleratorTable);
-  ObDereferenceObject(WindowStation);
-
-  return Ret;
-}
-
-HACCEL
-STDCALL
-NtUserCreateAcceleratorTable(
-  LPACCEL Entries,
-  SIZE_T EntriesCount)
-{
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE AcceleratorTable;
-  NTSTATUS Status;
-  HACCEL Handle;
-
-  DPRINT("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
-    Entries, EntriesCount);
-
-  Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(),
-    UserMode,
-	0,
-	&WindowStation);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    DPRINT1("E1\n");
-    return FALSE;
-  }
-
-  AcceleratorTable = ObmCreateObject(
-    WindowStation->HandleTable,
-    (PHANDLE)&Handle,
-    otAcceleratorTable,
-	sizeof(ACCELERATOR_TABLE));
-  if (AcceleratorTable == NULL)
-  {
-    ObDereferenceObject(WindowStation);
-    SetLastNtError(STATUS_NO_MEMORY);
-    DPRINT1("E2\n");
-    return (HACCEL) 0;
-  }
-
-  AcceleratorTable->Count = EntriesCount;
-  if (AcceleratorTable->Count > 0)
-  {
-	AcceleratorTable->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL);
-	if (AcceleratorTable->Table == NULL)
-	{
-		ObmCloseHandle(WindowStation->HandleTable, Handle);
-		ObDereferenceObject(WindowStation);
-		SetLastNtError(Status);
-		DPRINT1("E3\n");
-		return (HACCEL) 0;
-	}
-
-    Status = MmCopyFromCaller(AcceleratorTable->Table, Entries, EntriesCount * sizeof(ACCEL));
-    if (!NT_SUCCESS(Status))
-    {
-	  ExFreePool(AcceleratorTable->Table);
-	  ObmCloseHandle(WindowStation->HandleTable, Handle);
-      ObDereferenceObject(WindowStation);
-      SetLastNtError(Status);
-      DPRINT1("E4\n");
-      return (HACCEL) 0;
-    }
-  }
-
-  ObDereferenceObject(WindowStation);
-
-  /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
-
-  DPRINT("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x end\n",
-    Entries, EntriesCount, Handle);
-
-  return (HACCEL) Handle;
-}
-
-BOOLEAN
-STDCALL
-NtUserDestroyAcceleratorTable(
-  HACCEL Table)
-{
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE AcceleratorTable;
-  NTSTATUS Status;
-
-  /* FIXME: If the handle table is from a call to LoadAcceleratorTable, decrement it's
-     usage count (and return TRUE).
-	 FIXME: Destroy only tables created using CreateAcceleratorTable.
-   */
-
-  DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n",
-    Table);
-
-  Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(),
-    UserMode,
-	0,
-	&WindowStation);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    DPRINT1("E1\n");
-    return FALSE;
-  }
-
-  Status = ObmReferenceObjectByHandle(WindowStation->HandleTable,
-    Table,
-    otAcceleratorTable,
-    (PVOID*)&AcceleratorTable);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE);
-    ObDereferenceObject(WindowStation);
-    DPRINT1("E2\n");
-    return FALSE;
-  }
-
-  ObmCloseHandle(WindowStation->HandleTable, Table);
-
-  if (AcceleratorTable->Table != NULL)
-  {
-    ExFreePool(AcceleratorTable->Table);
-  }
-
-  ObDereferenceObject(WindowStation);
-
-  DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n",
-    Table);
-
-  return TRUE;
-}
-
-static BOOLEAN
-IntTranslateAccelerator(HWND hWnd,
-  UINT message,
-  WPARAM wParam,
-  LPARAM lParam,
-  BYTE fVirt,
-  WORD key,
-  WORD cmd)
-{
-  UINT mesg = 0;
-
-  DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n",
-    hWnd, message, wParam, lParam, fVirt, key, cmd);
-
-  if (wParam != key)
-    {
-      DPRINT("T0\n");
-      return FALSE;
-    }
-
-  if (message == WM_CHAR)
-    {
-      if (!(fVirt & FALT) && !(fVirt & FVIRTKEY))
-        {
-          DPRINT("found accel for WM_CHAR: ('%c')\n", wParam & 0xff);
-          goto found;
-        }
-    }
-  else
-    {
-      if ((fVirt & FVIRTKEY) > 0)
-        {
-          INT mask = 0;
-          DPRINT("found accel for virt_key %04x (scan %04x)\n",
-            wParam, 0xff & HIWORD(lParam));
-
-		  DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n",
-            NtUserGetKeyState(VK_SHIFT));
-		  DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n",
-            NtUserGetKeyState(VK_CONTROL));
-		  DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n",
-            NtUserGetKeyState(VK_MENU));
-
-		  if (NtUserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
-          if (NtUserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
-          if (NtUserGetKeyState(VK_MENU) & 0x8000) mask |= FALT;
-          if (mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
-          DPRINT("but incorrect SHIFT/CTRL/ALT-state\n");
-        }
-      else
-        {
-          if (!(lParam & 0x01000000))  /* no special_key */
-            {
-              if ((fVirt & FALT) && (lParam & 0x20000000))
-                {                            /* ^^ ALT pressed */
-                  DPRINT("found accel for Alt-%c\n", wParam & 0xff);
-                  goto found;
-                }
-            }
-        }
-    }
-
-  DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n",
-    hWnd, message, wParam, lParam, fVirt, key, cmd);
-
-  return FALSE;
-
- found:
-    if (message == WM_KEYUP || message == WM_SYSKEYUP)
-        mesg = 1;
-    else if (IntGetCaptureWindow())
-        mesg = 2;
-    else if (!IntIsWindowVisible(hWnd)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
-        mesg = 3;
-    else
-    {
-#if 0
-        HMENU hMenu, hSubMenu, hSysMenu;
-        UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos;
-
-        hMenu = (NtUserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd);
-        hSysMenu = get_win_sys_menu(hWnd);
-
-        /* find menu item and ask application to initialize it */
-        /* 1. in the system menu */
-        hSubMenu = hSysMenu;
-        nPos = cmd;
-        if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
-        {
-			IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
-            if(hSubMenu != hSysMenu)
-            {
-                nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
-                TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
-                IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
-            }
-            uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
-        }
-        else /* 2. in the window's menu */
-        {
-            hSubMenu = hMenu;
-            nPos = cmd;
-            if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
-            {
-                IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
-                if(hSubMenu != hMenu)
-                {
-                    nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
-                    TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
-                    IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
-                }
-                uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
-            }
-        }
-
-        if (uSysStat != (UINT)-1)
-        {
-            if (uSysStat & (MF_DISABLED|MF_GRAYED))
-                mesg=4;
-            else
-                mesg=WM_SYSCOMMAND;
-        }
-        else
-        {
-            if (uStat != (UINT)-1)
-            {
-                if (IsIconic(hWnd))
-                    mesg=5;
-                else
-                {
-                    if (uStat & (MF_DISABLED|MF_GRAYED))
-                        mesg=6;
-                    else
-                        mesg=WM_COMMAND;
-                }
-            }
-            else
-			{
-              mesg=WM_COMMAND;
-			}
-        }
-#else
-      DPRINT1("menu search not implemented");
-      mesg = WM_COMMAND;
-#endif
-    }
-
-  if (mesg == WM_COMMAND)
-    {
-      DPRINT(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd);
-      IntSendMessage(hWnd, mesg, 0x10000 | cmd, 0L);
-    }
-  else if (mesg == WM_SYSCOMMAND)
-    {
-      DPRINT(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd);
-      IntSendMessage(hWnd, mesg, cmd, 0x00010000L);
-    }
-  else
-    {
-      /*  some reasons for NOT sending the WM_{SYS}COMMAND message:
-       *   #0: unknown (please report!)
-       *   #1: for WM_KEYUP,WM_SYSKEYUP
-       *   #2: mouse is captured
-       *   #3: window is disabled
-       *   #4: it's a disabled system menu option
-       *   #5: it's a menu option, but window is iconic
-       *   #6: it's a menu option, but disabled
-       */
-      DPRINT(", but won't send WM_{SYS}COMMAND, reason is #%d\n", mesg);
-      if (mesg == 0)
-	    {
-          DPRINT1(" unknown reason - please report!");
-	    }
-    }
-
-  DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n",
-    hWnd, message, wParam, lParam, fVirt, key, cmd);
-
-  return TRUE;
-}
-
-int
-STDCALL
-NtUserTranslateAccelerator(
-  HWND Window,
-  HACCEL Table,
-  LPMSG Message)
-{
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE AcceleratorTable;
-  NTSTATUS Status;
-  ULONG i;
-
-  DPRINT("NtUserTranslateAccelerator(Window %x, Table %x, Message %p)\n",
-    Window, Table, Message);
-
-  if (Message == NULL)
-    {
-	  SetLastNtError(STATUS_INVALID_PARAMETER);
-	  DPRINT1("E0a\n");
-      return 0;
-    }
-
-  if (Table == NULL)
-    {
-      SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE);
-	  DPRINT1("E0b\n");
-      return 0;
-    }
-
-  if ((Message->message != WM_KEYDOWN) &&
-	  (Message->message != WM_KEYUP) &&
-	  (Message->message != WM_SYSKEYDOWN) &&
-	  (Message->message != WM_SYSKEYUP) &&
-	  (Message->message != WM_CHAR))
-  {
-    DPRINT1("E0c\n");
-    return 0;
-  }
-
-  Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(),
-    UserMode,
-	0,
-	&WindowStation);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    DPRINT1("E1\n");
-    return 0;
-  }
-
-  Status = ObmReferenceObjectByHandle(WindowStation->HandleTable,
-    Table,
-    otAcceleratorTable,
-    (PVOID*)&AcceleratorTable);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE);
-    ObDereferenceObject(WindowStation);
-    DPRINT1("E2\n");
-    return 0;
-  }
-
-  /* FIXME: Associate AcceleratorTable with the current thread */
-
-  /* FIXME: If Window is active and no window has focus, translate WM_SYSKEYUP and WM_SYSKEY_DOWN instead */
-
-  for (i = 0; i < AcceleratorTable->Count; i++)
-    {
-      if (IntTranslateAccelerator(Window, Message->message, Message->wParam, Message->lParam,
-		  AcceleratorTable->Table[i].fVirt, AcceleratorTable->Table[i].key,
-		  AcceleratorTable->Table[i].cmd))
-        {
-          ObDereferenceObject(WindowStation);
-          DPRINT("NtUserTranslateAccelerator(Window %x, Table %x, Message %p) = %i end\n",
-                 Window, Table, Message, 1);
-          return 1;
-        }
-      if (((AcceleratorTable->Table[i].fVirt & 0x80) > 0))
-        {
-          break;
-        }
-    }
-
-  ObDereferenceObject(WindowStation);
-
-  DPRINT("NtUserTranslateAccelerator(Window %x, Table %x, Message %p) = %i end\n",
-    Window, Table, Message, 0);
-
-  return 0;
-}

reactos/subsys/win32k/ntuser
callback.c 1.25 -> 1.25.8.1
diff -u -r1.25 -r1.25.8.1
--- callback.c	20 Jun 2004 12:34:20 -0000	1.25
+++ callback.c	15 Jul 2004 20:07:17 -0000	1.25.8.1
@@ -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: callback.c,v 1.25 2004/06/20 12:34:20 navaraf Exp $
+/* $Id: callback.c,v 1.25.8.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -38,6 +38,16 @@
 #define NDEBUG
 #include <debug.h>
 
+#define UserCallback(StatusVar, a, b, c, d, e) \
+  if(IntUserIsInCritical()) \
+  { \
+    IntUserLeaveCritical(); \
+    StatusVar = NtW32Call(a, b, c, d, e); \
+    IntUserEnterCritical(); \
+  } \
+  else \
+    StatusVar = NtW32Call(a, b, c, d, e) \
+
 /* CALLBACK MEMORY MANAGEMENT ************************************************/
 
 typedef struct _INT_CALLBACK_HEADER
@@ -128,11 +138,12 @@
   Arguments.Msg = Msg;
   Arguments.Context = CompletionCallbackContext;
   Arguments.Result = Result;
-  Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC,
-		     &Arguments,
-		     sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
-		     NULL,
-		     NULL);
+  UserCallback(Status,
+               USER32_CALLBACK_SENDASYNCPROC,
+	       &Arguments,
+	       sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
+	       NULL,
+	       NULL);
   if (!NT_SUCCESS(Status))
     {
       return;
@@ -143,7 +154,7 @@
 LRESULT STDCALL
 IntCallWindowProc(WNDPROC Proc,
                    BOOLEAN IsAnsiProc,
-		   HWND Wnd,
+		   PWINDOW_OBJECT Window,
 		   UINT Message,
 		   WPARAM wParam,
 		   LPARAM lParam,
@@ -176,18 +187,21 @@
     }
   Arguments->Proc = Proc;
   Arguments->IsAnsiProc = IsAnsiProc;
-  Arguments->Wnd = Wnd;
+  Arguments->Wnd = (Window ? Window->Handle : NULL);
   Arguments->Msg = Message;
   Arguments->wParam = wParam;
   Arguments->lParam = lParam;
   Arguments->lParamBufferSize = lParamBufferSize;
   ResultPointer = Arguments;
   ResultLength = ArgumentLength;
-  Status = NtW32Call(USER32_CALLBACK_WINDOWPROC,
-		     Arguments,
-		     ArgumentLength,
-		     &ResultPointer,
-		     &ResultLength);
+  /* FIXME - reference the window */
+  UserCallback(Status,
+               USER32_CALLBACK_WINDOWPROC,
+	       Arguments,
+	       ArgumentLength,
+	       &ResultPointer,
+	       &ResultLength);
+  /* FIXME - check if window is still there and if the process/thread had been killed */
   if (!NT_SUCCESS(Status))
     {
       if (0 < lParamBufferSize)
@@ -219,11 +233,12 @@
 
   ResultPointer = &Result;
   ResultLength = sizeof(LRESULT);
-  Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
-		     NULL,
-		     0,
-		     &ResultPointer,
-		     &ResultLength);
+  UserCallback(Status,
+               USER32_CALLBACK_LOADSYSMENUTEMPLATE,
+	       NULL,
+	       0,
+	       &ResultPointer,
+	       &ResultLength);
   if (!NT_SUCCESS(Status))
     {
       return(0);
@@ -242,11 +257,12 @@
 
   ResultPointer = &Result;
   ResultLength = sizeof(LRESULT);
-  Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS,
-		     &DefaultCursor,
-		     sizeof(BOOL),
-		     &ResultPointer,
-		     &ResultLength);
+  UserCallback(Status,
+               USER32_CALLBACK_LOADDEFAULTCURSORS,
+	       &DefaultCursor,
+	       sizeof(BOOL),
+	       &ResultPointer,
+	       &ResultLength);
   if (!NT_SUCCESS(Status))
     {
       return FALSE;
@@ -352,11 +368,12 @@
   
   ResultPointer = &Result;
   ResultLength = sizeof(LRESULT);
-  Status = NtW32Call(USER32_CALLBACK_HOOKPROC,
-		     Argument,
-		     ArgumentLength,
-		     &ResultPointer,
-		     &ResultLength);
+  UserCallback(Status,
+               USER32_CALLBACK_HOOKPROC,
+	       Argument,
+	       ArgumentLength,
+	       &ResultPointer,
+	       &ResultLength);
   
   IntCbFreeMemory(Argument);
   

reactos/subsys/win32k/ntuser
caret.c 1.12 -> 1.12.12.1
diff -u -r1.12 -r1.12.12.1
--- caret.c	10 May 2004 17:07:18 -0000	1.12
+++ caret.c	15 Jul 2004 20:07:17 -0000	1.12.12.1
@@ -1,4 +1,4 @@
-/* $Id: caret.c,v 1.12 2004/05/10 17:07:18 weiden Exp $
+/* $Id: caret.c,v 1.12.12.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -14,391 +14,3 @@
 #define NDEBUG
 #include <debug.h>
 
-#define MIN_CARETBLINKRATE 100
-#define MAX_CARETBLINKRATE 10000
-#define DEFAULT_CARETBLINKRATE 530
-#define CARET_REGKEY L"\\Registry\\User\\.Default\\Control Panel\\Desktop"
-#define CARET_VALUENAME L"CursorBlinkRate"
-
-BOOL FASTCALL
-IntHideCaret(PTHRDCARETINFO CaretInfo)
-{
-  if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
-  {
-    IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-    CaretInfo->Showing = 0;
-    return TRUE;
-  }
-  return FALSE;
-}
-
-BOOL FASTCALL
-IntDestroyCaret(PW32THREAD Win32Thread)
-{
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue;
-  
-  if(!ThreadQueue || !ThreadQueue->CaretInfo)
-    return FALSE;
-  
-  IntHideCaret(ThreadQueue->CaretInfo);
-  ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
-  ThreadQueue->CaretInfo->hWnd = (HWND)0;
-  ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
-  ThreadQueue->CaretInfo->Showing = 0;
-  ThreadQueue->CaretInfo->Visible = 0;
-  return TRUE;
-}
-
-BOOL FASTCALL
-IntSetCaretBlinkTime(UINT uMSeconds)
-{
-  /* Don't save the new value to the registry! */
-  NTSTATUS Status;
-  PWINSTATION_OBJECT WinStaObject;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-	                                  KernelMode,
-				          0,
-				          &WinStaObject);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  /* windows doesn't do this check */
-  if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    ObDereferenceObject(WinStaObject);
-    return FALSE;
-  }
-  
-  WinStaObject->CaretBlinkRate = uMSeconds;
-  
-  ObDereferenceObject(WinStaObject);
-  return TRUE;
-}
-
-UINT FASTCALL
-IntQueryCaretBlinkRate(VOID)
-{
-  UNICODE_STRING KeyName, ValueName;
-  NTSTATUS Status;
-  HANDLE KeyHandle = NULL;
-  OBJECT_ATTRIBUTES KeyAttributes;
-  PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
-  ULONG Length = 0;
-  ULONG ResLength = 0;
-  ULONG Val = 0;
-  
-  RtlRosInitUnicodeStringFromLiteral(&KeyName, CARET_REGKEY);
-  RtlRosInitUnicodeStringFromLiteral(&ValueName, CARET_VALUENAME);
-  
-  InitializeObjectAttributes(&KeyAttributes, &KeyName, OBJ_CASE_INSENSITIVE,
-                             NULL, NULL);
-  
-  Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
-  if(!NT_SUCCESS(Status))
-  {
-    return 0;
-  }
-  
-  Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
-                           0, 0, &ResLength);
-  if((Status != STATUS_BUFFER_TOO_SMALL))
-  {
-    NtClose(KeyHandle);
-    return 0;
-  }
-  
-  ResLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
-  KeyValuePartialInfo = ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
-  Length = ResLength;
-  
-  if(!KeyValuePartialInfo)
-  {
-    NtClose(KeyHandle);
-    return 0;
-  }
-  
-  Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
-                           (PVOID)KeyValuePartialInfo, Length, &ResLength);
-  if(!NT_SUCCESS(Status) || (KeyValuePartialInfo->Type != REG_SZ))
-  {
-    NtClose(KeyHandle);
-    ExFreePool(KeyValuePartialInfo);
-    return 0;
-  }
-  
-  ValueName.Length = KeyValuePartialInfo->DataLength;
-  ValueName.MaximumLength = KeyValuePartialInfo->DataLength;
-  ValueName.Buffer = (PWSTR)KeyValuePartialInfo->Data;
-  
-  Status = RtlUnicodeStringToInteger(&ValueName, 0, &Val);
-  if(!NT_SUCCESS(Status))
-  {
-    Val = 0;
-  }
-  
-  ExFreePool(KeyValuePartialInfo);
-  NtClose(KeyHandle);
-  
-  return (UINT)Val;
-}
-
-UINT FASTCALL
-IntGetCaretBlinkTime(VOID)
-{
-  NTSTATUS Status;
-  PWINSTATION_OBJECT WinStaObject;
-  UINT Ret;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-	                                  KernelMode,
-				          0,
-				          &WinStaObject);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return 0;
-  }
-  
-  Ret = WinStaObject->CaretBlinkRate;
-  if(!Ret)
-  {
-    /* load it from the registry the first call only! */
-    Ret = WinStaObject->CaretBlinkRate = IntQueryCaretBlinkRate();
-  }
-  
-  /* windows doesn't do this check */
-  if((Ret < MIN_CARETBLINKRATE) || (Ret > MAX_CARETBLINKRATE))
-  {
-    Ret = DEFAULT_CARETBLINKRATE;
-  }
-  
-  ObDereferenceObject(WinStaObject);
-  return Ret;
-}
-
-BOOL FASTCALL
-IntSetCaretPos(int X, int Y)
-{
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  if(ThreadQueue->CaretInfo->hWnd)
-  {
-    if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y)
-    {
-      IntHideCaret(ThreadQueue->CaretInfo);
-      ThreadQueue->CaretInfo->Showing = 0;
-      ThreadQueue->CaretInfo->Pos.x = X;
-      ThreadQueue->CaretInfo->Pos.y = Y;
-      IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-      IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
-    }
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-BOOL FASTCALL
-IntSwitchCaretShowing(PVOID Info)
-{
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  if(ThreadQueue->CaretInfo->hWnd)
-  {
-    ThreadQueue->CaretInfo->Showing = (ThreadQueue->CaretInfo->Showing ? 0 : 1);
-    MmCopyToCaller(Info, ThreadQueue->CaretInfo, sizeof(THRDCARETINFO));
-    return TRUE;
-  }
-  
-  return FALSE;
-}
-
-VOID FASTCALL
-IntDrawCaret(HWND hWnd)
-{
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible && 
-     ThreadQueue->CaretInfo->Showing)
-  {
-    IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-    ThreadQueue->CaretInfo->Showing = 1;
-  }
-}
-
-
-
-BOOL
-STDCALL
-NtUserCreateCaret(
-  HWND hWnd,
-  HBITMAP hBitmap,
-  int nWidth,
-  int nHeight)
-{
-  PWINDOW_OBJECT WindowObject;
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  
-  WindowObject = IntGetWindowObject(hWnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
-    return FALSE;
-  }
-  
-  if(WindowObject->OwnerThread != PsGetCurrentThread())
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE);
-  
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  IntHideCaret(ThreadQueue->CaretInfo);
-  
-  ThreadQueue->CaretInfo->hWnd = hWnd;
-  if(hBitmap)
-  {
-    ThreadQueue->CaretInfo->Bitmap = hBitmap;
-    ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
-  }
-  else
-  {
-    ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
-    ThreadQueue->CaretInfo->Size.cx = nWidth;
-    ThreadQueue->CaretInfo->Size.cy = nHeight;
-  }
-  ThreadQueue->CaretInfo->Visible = 0;
-  ThreadQueue->CaretInfo->Showing = 0;
-  
-  IntReleaseWindowObject(WindowObject);  
-  return TRUE;
-}
-
-UINT
-STDCALL
-NtUserGetCaretBlinkTime(VOID)
-{
-  return IntGetCaretBlinkTime();
-}
-
-BOOL
-STDCALL
-NtUserGetCaretPos(
-  LPPOINT lpPoint)
-{
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  NTSTATUS Status;
-  
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  return TRUE;
-}
-
-BOOL
-STDCALL
-NtUserHideCaret(
-  HWND hWnd)
-{
-  PWINDOW_OBJECT WindowObject;
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  
-  WindowObject = IntGetWindowObject(hWnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-  
-  if(WindowObject->OwnerThread != PsGetCurrentThread())
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  if(ThreadQueue->CaretInfo->hWnd != hWnd)
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  if(ThreadQueue->CaretInfo->Visible)
-  {
-    IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE);
-    
-    IntHideCaret(ThreadQueue->CaretInfo);
-    ThreadQueue->CaretInfo->Visible = 0;
-    ThreadQueue->CaretInfo->Showing = 0;
-  }
-  
-  IntReleaseWindowObject(WindowObject);
-  return TRUE;
-}
-
-BOOL
-STDCALL
-NtUserShowCaret(
-  HWND hWnd)
-{
-  PWINDOW_OBJECT WindowObject;
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  
-  WindowObject = IntGetWindowObject(hWnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-  
-  if(WindowObject->OwnerThread != PsGetCurrentThread())
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-  
-  if(ThreadQueue->CaretInfo->hWnd != hWnd)
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  if(!ThreadQueue->CaretInfo->Visible)
-  {
-    ThreadQueue->CaretInfo->Visible = 1;
-    if(!ThreadQueue->CaretInfo->Showing)
-    {
-      IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-    }
-    IntSetTimer(hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
-  }
-  
-  IntReleaseWindowObject(WindowObject);
-  return TRUE;
-}

reactos/subsys/win32k/ntuser
class.c 1.59 -> 1.59.8.1
diff -u -r1.59 -r1.59.8.1
--- class.c	21 Jun 2004 20:56:53 -0000	1.59
+++ class.c	15 Jul 2004 20:07:17 -0000	1.59.8.1
@@ -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: class.c,v 1.59 2004/06/21 20:56:53 hbirr Exp $
+/* $Id: class.c,v 1.59.8.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -48,26 +48,23 @@
 }
 
 BOOL FASTCALL
-ClassReferenceClassByAtom(
-   PWNDCLASS_OBJECT* Class,
-   RTL_ATOM Atom,
-   HINSTANCE hInstance)
+IntReferenceClassByAtom(PCLASS_OBJECT* Class,
+                        RTL_ATOM Atom,
+                        HINSTANCE hInstance)
 {
-   PWNDCLASS_OBJECT Current, BestMatch = NULL;
+   PCLASS_OBJECT Current, BestMatch = NULL;
    PLIST_ENTRY CurrentEntry;
    PW32PROCESS Process = PsGetWin32Process();
   
-   IntLockProcessClasses(Process);
    CurrentEntry = Process->ClassListHead.Flink;
    while (CurrentEntry != &Process->ClassListHead)
    {
-      Current = CONTAINING_RECORD(CurrentEntry, WNDCLASS_OBJECT, ListEntry);
+      Current = CONTAINING_RECORD(CurrentEntry, CLASS_OBJECT, ListEntry);
       
       if (Current->Atom == Atom && (hInstance == NULL || Current->hInstance == hInstance))
       {
          *Class = Current;
-         ObmReferenceObject(Current);
-         IntUnLockProcessClasses(Process);
+         ClassReferenceObject(Current);
          return TRUE;
       }
 
@@ -76,12 +73,11 @@
 
       CurrentEntry = CurrentEntry->Flink;
    }
-   IntUnLockProcessClasses(Process);
 
    if (BestMatch != NULL)
    {
       *Class = BestMatch;
-      ObmReferenceObject(BestMatch);
+      ClassReferenceObject(BestMatch);
       return TRUE;
    }
   
@@ -89,184 +85,95 @@
 }
 
 BOOL FASTCALL
-ClassReferenceClassByName(
-   PWNDCLASS_OBJECT *Class,
-   LPCWSTR ClassName,
-   HINSTANCE hInstance)
+IntReferenceClassByName(PCLASS_OBJECT *Class,
+                        PUNICODE_STRING ClassName,
+                        HINSTANCE hInstance)
 {
-   PWINSTATION_OBJECT WinStaObject;
-   NTSTATUS Status;
-   BOOL Found;
    RTL_ATOM ClassAtom;
+   NTSTATUS Status;
+   PWINSTATION_OBJECT WinStaObject = PsGetWin32Process()->WindowStation;
 
-   if (!ClassName)
-      return FALSE;
-
-   Status = IntValidateWindowStationHandle(
-      PROCESS_WINDOW_STATION(),
-      KernelMode,
-      0,
-      &WinStaObject);
-
-   if (!NT_SUCCESS(Status))
-   {
-      DPRINT("Validation of window station handle (0x%X) failed\n",
-	     PROCESS_WINDOW_STATION());
+   if (!ClassName || !WinStaObject)
       return FALSE;
-   }
 
    Status = RtlLookupAtomInAtomTable(
       WinStaObject->AtomTable,
-      (LPWSTR)ClassName,
+      (LPWSTR)ClassName->Buffer,
       &ClassAtom);
 
    if (!NT_SUCCESS(Status))
    {
-      ObDereferenceObject(WinStaObject);  
       return FALSE;
    }
 
-   Found = ClassReferenceClassByAtom(Class, ClassAtom, hInstance);
-   ObDereferenceObject(WinStaObject);  
-
-   return Found;
+   return IntReferenceClassByAtom(Class, ClassAtom, hInstance);
 }
 
 BOOL FASTCALL
-ClassReferenceClassByNameOrAtom(
-   PWNDCLASS_OBJECT *Class,
-   LPCWSTR ClassNameOrAtom,
-   HINSTANCE hInstance)
-{
-   BOOL Found;
-
-   if (IS_ATOM(ClassNameOrAtom))
-      Found = ClassReferenceClassByAtom(Class, (RTL_ATOM)((ULONG_PTR)ClassNameOrAtom), hInstance);
-   else
-      Found = ClassReferenceClassByName(Class, ClassNameOrAtom, hInstance);
-
-   return Found;
-}
-
-DWORD STDCALL
-NtUserGetClassInfo(
-   HINSTANCE hInstance,
-   LPCWSTR lpClassName,
-   LPWNDCLASSEXW lpWndClassEx,
-   BOOL Ansi,
-   DWORD unknown3)
+IntReferenceClassByNameOrAtom(PCLASS_OBJECT *Class,
+                              PUNICODE_STRING ClassNameOrAtom,
+			      HINSTANCE hInstance)
 {
-   PWNDCLASS_OBJECT Class;
-   RTL_ATOM Atom;
-
-   if (IS_ATOM(lpClassName))
-      DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance);
-   else
-      DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance);
-
-   if (!ClassReferenceClassByNameOrAtom(&Class, lpClassName, hInstance))
-   {
-      SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
-      return 0;
-   }
-
-   lpWndClassEx->cbSize = sizeof(LPWNDCLASSEXW);
-   lpWndClassEx->style = Class->style;
-   if (Ansi)
-      lpWndClassEx->lpfnWndProc = Class->lpfnWndProcA;
-   else
-      lpWndClassEx->lpfnWndProc = Class->lpfnWndProcW;
-   lpWndClassEx->cbClsExtra = Class->cbClsExtra;
-   lpWndClassEx->cbWndExtra = Class->cbWndExtra;
-   /* This is not typo, we're really not going to use Class->hInstance here. */
-   lpWndClassEx->hInstance = hInstance;
-   lpWndClassEx->hIcon = Class->hIcon;
-   lpWndClassEx->hCursor = Class->hCursor;
-   lpWndClassEx->hbrBackground = Class->hbrBackground;
-   if (Class->lpszMenuName.MaximumLength)
-      RtlCopyUnicodeString((PUNICODE_STRING)lpWndClassEx->lpszMenuName, &Class->lpszMenuName);
-   else
-      lpWndClassEx->lpszMenuName = Class->lpszMenuName.Buffer;
-   lpWndClassEx->lpszClassName = lpClassName;
-   lpWndClassEx->hIconSm = Class->hIconSm;
-   Atom = Class->Atom;
+   if (IS_ATOM(ClassNameOrAtom->Buffer))
+      return IntReferenceClassByAtom(Class, (RTL_ATOM)((ULONG_PTR)ClassNameOrAtom->Buffer), hInstance);
    
-   ObmDereferenceObject(Class);
-
-   return Atom;
+   return IntReferenceClassByName(Class, ClassNameOrAtom, hInstance);
 }
 
-ULONG FASTCALL
-IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
-   ULONG nMaxCount)
-{
-   ULONG Length;
-   LPWSTR Name;
-   PWINSTATION_OBJECT WinStaObject;
-   NTSTATUS Status;
-
-   Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-      KernelMode, 0, &WinStaObject);
-   if (!NT_SUCCESS(Status))
-   {
-      DPRINT("Validation of window station handle (0x%X) failed\n",
-         PROCESS_WINDOW_STATION());
-      return 0;
-   }
-   Length = 0;
-   Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
-      WindowObject->Class->Atom, NULL, NULL, NULL, &Length);
-   Name = ExAllocatePoolWithTag(PagedPool, Length + sizeof(UNICODE_NULL), TAG_STRING);
-   Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
-      WindowObject->Class->Atom, NULL, NULL, Name, &Length);
-   if (!NT_SUCCESS(Status))
-   {
-      DPRINT("IntGetClassName: RtlQueryAtomInAtomTable failed\n");
-      return 0;
-   }
-   Length /= sizeof(WCHAR);
-   if (Length > nMaxCount)
-   {
-      Length = nMaxCount;
-   }
-   wcsncpy(lpClassName, Name, Length);
-   /* FIXME: Check buffer size before doing this! */
-   *(lpClassName + Length) = 0;
-   ExFreePool(Name);
-   ObDereferenceObject(WinStaObject);
-
-   return Length;
-}
-
-DWORD STDCALL
-NtUserGetClassName (
-  HWND hWnd,
-  LPWSTR lpClassName,
-  ULONG nMaxCount)
+BOOL FASTCALL
+IntGetClassName(PWINDOW_OBJECT WindowObject, PUNICODE_STRING ClassName, ULONG nMaxCount)
 {
-   PWINDOW_OBJECT WindowObject;
-   LONG Length;
-
-   WindowObject = IntGetWindowObject(hWnd);
-   if (WindowObject == NULL)
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return 0;
-   }
-   Length = IntGetClassName(WindowObject, lpClassName, nMaxCount);
-   IntReleaseWindowObject(WindowObject);
-   return Length;
-}
+  ULONG Length;
+  NTSTATUS Status;
+  PWINSTATION_OBJECT WinStaObject = PsGetWin32Process()->WindowStation;
 
-DWORD STDCALL
-NtUserGetWOWClass(DWORD Unknown0,
-		  DWORD Unknown1)
-{
-  UNIMPLEMENTED;
-  return(0);
+  if (!WinStaObject)
+  {
+    return 0;
+  }
+  
+  ClassName->Length = 0;
+  Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
+                                   WindowObject->Class->Atom,
+                                   NULL,
+                                   NULL,
+                                   NULL,
+                                   &Length);
+  if(!NT_SUCCESS(Status))
+  {
+    return FALSE;
+  }
+  
+  ClassName->Length = (USHORT)Length;
+  ClassName->MaximumLength = ClassName->Length + sizeof(WCHAR);
+  ClassName->Buffer = ExAllocatePoolWithTag(PagedPool, ClassName->MaximumLength, TAG_STRING);
+  
+  if(!ClassName->Buffer)
+  {
+    DPRINT1("IntGetClassName: Not enough memory to allocate memory for the class name!\n");
+    return FALSE;
+  }
+  
+  Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
+                                   WindowObject->Class->Atom,
+                                   NULL,
+                                   NULL,
+                                   ClassName->Buffer,
+                                   &Length);
+  if(!NT_SUCCESS(Status))
+  {
+    DPRINT1("IntGetClassName: RtlQueryAtomInAtomTable failed\n");
+    RtlFreeUnicodeString(ClassName);
+    return FALSE;
+  }
+  
+  ClassName->Length = (USHORT)Length;
+  ClassName->Buffer[Length / sizeof(WCHAR)] = L'\0';
+  
+  return TRUE;
 }
 
-PWNDCLASS_OBJECT FASTCALL
+PCLASS_OBJECT FASTCALL
 IntCreateClass(
    CONST WNDCLASSEXW *lpwcx,
    DWORD Flags,
@@ -274,7 +181,7 @@
    PUNICODE_STRING MenuName,
    RTL_ATOM Atom)
 {
-	PWNDCLASS_OBJECT ClassObject;
+	PCLASS_OBJECT ClassObject;
 	ULONG  objectSize;
 	BOOL Global;
 
@@ -283,7 +190,7 @@
 	/* Check for double registration of the class. */
 	if (PsGetWin32Process() != NULL)
 	{
-		if (ClassReferenceClassByAtom(&ClassObject, Atom, lpwcx->hInstance))
+		if (IntReferenceClassByAtom(&ClassObject, Atom, lpwcx->hInstance))
 		{
 			/*
 			 * NOTE: We may also get a global class from
@@ -299,14 +206,15 @@
 		}	
 	}
 	
-	objectSize = sizeof(WNDCLASS_OBJECT) + lpwcx->cbClsExtra;
-	ClassObject = ObmCreateObject(NULL, NULL, otClass, objectSize);
-	if (ClassObject == 0)
+	objectSize = sizeof(CLASS_OBJECT) + lpwcx->cbClsExtra;
+	if (!(ClassObject = ExAllocatePoolWithTag(PagedPool, objectSize, TAG_CLASS)))
 	{          
 		SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
 		return(NULL);
 	}
 	
+	ClassObject->RefCount = 1;
+	
 	ClassObject->cbSize = lpwcx->cbSize;
 	ClassObject->style = lpwcx->style;
 	ClassObject->cbClsExtra = lpwcx->cbClsExtra;
@@ -367,123 +275,77 @@
 	}
 
 	InitializeListHead(&ClassObject->ClassWindowsListHead);
-	ExInitializeFastMutex(&ClassObject->ClassWindowsListLock);
 
 	return(ClassObject);
 }
 
-RTL_ATOM STDCALL
-NtUserRegisterClassExWOW(
-   CONST WNDCLASSEXW* lpwcx,
-   PUNICODE_STRING ClassName,
-   PUNICODE_STRING ClassNameCopy,
-   PUNICODE_STRING MenuName,
-   WNDPROC wpExtra, /* FIXME: Windows uses this parameter for something different. */
-   DWORD Flags,
-   DWORD Unknown7)
-
-/*
- * FUNCTION:
- *   Registers a new class with the window manager
- * ARGUMENTS:
- *   lpwcx          = Win32 extended window class structure
- *   bUnicodeClass = Whether to send ANSI or unicode strings
- *                   to window procedures
- *   wpExtra       = Extra window procedure, if this is not null, its used for the second window procedure for standard controls.
- * RETURNS:
- *   Atom identifying the new class
- */
-{
-   WNDCLASSEXW SafeClass;
-   PWINSTATION_OBJECT WinStaObject;
-   PWNDCLASS_OBJECT ClassObject;
-   NTSTATUS Status;
-   RTL_ATOM Atom;
-  
-   if (!lpwcx)
-   {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return (RTL_ATOM)0;
-   }
-
-   if (Flags & ~REGISTERCLASS_ALL)
-   {
-      SetLastWin32Error(ERROR_INVALID_FLAGS);
-      return (RTL_ATOM)0;
-   }
-
-   Status = MmCopyFromCaller(&SafeClass, lpwcx, sizeof(WNDCLASSEXW));
-   if (!NT_SUCCESS(Status))
-   {
-      SetLastNtError(Status);
-      return (RTL_ATOM)0;
-   }
-  
-   /* Deny negative sizes */
-   if (lpwcx->cbClsExtra < 0 || lpwcx->cbWndExtra < 0)
-   {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return (RTL_ATOM)0;
-   }
+PCLASS_OBJECT FASTCALL
+IntRegisterClass(CONST WNDCLASSEXW *lpwcx, PUNICODE_STRING ClassName, PUNICODE_STRING MenuName,
+                 WNDPROC wpExtra, DWORD Flags)
+{
+  PWINSTATION_OBJECT WinStaObject;
+  RTL_ATOM Atom;
+  NTSTATUS Status;
+  PCLASS_OBJECT Ret;
   
-  DPRINT("About to open window station handle (0x%X)\n", 
-    PROCESS_WINDOW_STATION());
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-    KernelMode,
-    0,
-    &WinStaObject);
-  if (!NT_SUCCESS(Status))
+  WinStaObject = PsGetWin32Process()->WindowStation;
+  if(WinStaObject == NULL)
   {
-    DPRINT("Validation of window station handle (0x%X) failed\n",
-      PROCESS_WINDOW_STATION());
-    return((RTL_ATOM)0);
+    if(IS_ATOM(ClassName->Buffer))
+    {
+      DbgPrint("XUnable to register class 0x%x (process %d), window station is inaccessible\n", ClassName->Buffer, PsGetCurrentProcessId());
+    }
+    else
+    {
+      DbgPrint("XUnable to register class %wZ (process %d), window station is inaccessible\n", ClassName, PsGetCurrentProcessId());
+    }
+    return NULL;
   }
-  if (ClassName->Length)
+  
+  /* FIXME - check the rights of the thread's desktop if we're allowed to register a class? */
+  
+  if(ClassName->Length)
   {
-    DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer);
-    /* FIXME - Safely copy/verify the buffer first!!! */
+    DPRINT1("IntRegisterClass(%wZ)\n", ClassName);
     Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
-      ClassName->Buffer,
-      &Atom);
+                                   ClassName->Buffer,
+                                   &Atom);
     if (!NT_SUCCESS(Status))
     {
-      ObDereferenceObject(WinStaObject);
-      DPRINT("Failed adding class name (%S) to atom table\n",
-	ClassName->Buffer);
+      DPRINT("Failed adding class name (%wZ) to atom table\n", ClassName);
       SetLastNtError(Status);      
-      return((RTL_ATOM)0);
+      return NULL;
     }
   }
   else
   {
     Atom = (RTL_ATOM)(ULONG)ClassName->Buffer;
   }
-  ClassObject = IntCreateClass(&SafeClass, Flags, wpExtra, MenuName, Atom);
-  if (ClassObject == NULL)
+  
+  Ret = IntCreateClass(lpwcx, Flags, wpExtra, MenuName, Atom);
+  if(Ret == NULL)
   {
-    if (ClassName->Length)
+    if(ClassName->Length)
     {
       RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
     }
-    ObDereferenceObject(WinStaObject);
-    DPRINT("Failed creating window class object\n");
-    return((RTL_ATOM)0);
+    return NULL;
   }
-  IntLockProcessClasses(PsGetWin32Process());
-  InsertTailList(&PsGetWin32Process()->ClassListHead, &ClassObject->ListEntry);
-  IntUnLockProcessClasses(PsGetWin32Process());
-  ObDereferenceObject(WinStaObject);
-  return(Atom);
+  
+  /* FIXME - reference the window station? */
+  InsertTailList(&PsGetWin32Process()->ClassListHead, &Ret->ListEntry);
+  
+  return Ret;
 }
 
 ULONG FASTCALL
-IntGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset, BOOL Ansi)
+IntGetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, BOOL Ansi)
 {
   LONG Ret;
 
   if ((int)Offset >= 0)
     {
-      DPRINT("GetClassLong(%x, %d)\n", WindowObject->Self, Offset);
+      DPRINT("GetClassLong(%x, %d)\n", WindowObject->Handle, Offset);
       if ((Offset + sizeof(LONG)) > WindowObject->Class->cbClsExtra)
 	{
 	  SetLastWin32Error(ERROR_INVALID_PARAMETER);
@@ -540,62 +402,58 @@
   return(Ret);
 }
 
-DWORD STDCALL
-NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi)
-{
-  PWINDOW_OBJECT WindowObject;
-  LONG Ret;
-
-  WindowObject = IntGetWindowObject(hWnd);
-  if (WindowObject == NULL)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return 0;
-  }
-  Ret = IntGetClassLong(WindowObject, Offset, Ansi);
-  IntReleaseWindowObject(WindowObject);
-  return(Ret);
-}
-
-void FASTCALL
+ULONG FASTCALL
 IntSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL Ansi)
 {
+  ULONG Ret = 0;
+  
   if ((int)Offset >= 0)
     {
-      DPRINT("SetClassLong(%x, %d, %x)\n", WindowObject->Self, Offset, dwNewLong);
+      LONG *Addr;
+      DPRINT("SetClassLong(%x, %d, %x)\n", WindowObject->Handle, Offset, dwNewLong);
       if ((Offset + sizeof(LONG)) > WindowObject->Class->cbClsExtra)
 	{
 	  SetLastWin32Error(ERROR_INVALID_PARAMETER);
-	  return;
+	  return 0;
 	}
-      *((LONG *)(WindowObject->Class->ExtraData + Offset)) = dwNewLong;
-      return;
+      Addr = ((LONG *)(WindowObject->Class->ExtraData + Offset));
+      Ret = *Addr;
+      *Addr = dwNewLong;
+      return Ret;
     }
   
   switch (Offset)
     {
     case GCL_CBWNDEXTRA:
+      Ret = WindowObject->Class->cbWndExtra;
       WindowObject->Class->cbWndExtra = dwNewLong;
       break;
     case GCL_CBCLSEXTRA:
+      Ret = WindowObject->Class->cbClsExtra;
       WindowObject->Class->cbClsExtra = dwNewLong;
       break;
     case GCL_HBRBACKGROUND:
+      Ret = (ULONG)WindowObject->Class->hbrBackground;
       WindowObject->Class->hbrBackground = (HBRUSH)dwNewLong;
       break;
     case GCL_HCURSOR:
+      Ret = (ULONG)WindowObject->Class->hCursor;
       WindowObject->Class->hCursor = (HCURSOR)dwNewLong;
       break;
     case GCL_HICON:
+      Ret = (ULONG)WindowObject->Class->hIcon;
       WindowObject->Class->hIcon = (HICON)dwNewLong;
       break;
     case GCL_HICONSM:
+      Ret = (ULONG)WindowObject->Class->hIconSm;
       WindowObject->Class->hIconSm = (HICON)dwNewLong;
       break;
     case GCL_HMODULE:
+      Ret = (ULONG)WindowObject->Class->hInstance;
       WindowObject->Class->hInstance = (HINSTANCE)dwNewLong;
       break;
     case GCL_MENUNAME:
+      /* FIXME - what do we return in this case? */
       if (WindowObject->Class->lpszMenuName.MaximumLength)
         RtlFreeUnicodeString(&WindowObject->Class->lpszMenuName);
       if (!IS_INTRESOURCE(dwNewLong))
@@ -613,124 +471,26 @@
       }
       break;
     case GCL_STYLE:
+      Ret = WindowObject->Class->style;
       WindowObject->Class->style = dwNewLong;
       break;
     case GCL_WNDPROC:
-	  if (Ansi)
-	  {
-		WindowObject->Class->lpfnWndProcA = (WNDPROC)dwNewLong;
-        WindowObject->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE);
-		WindowObject->Class->Unicode = FALSE;
-	  }
-	  else
-	  {
-		WindowObject->Class->lpfnWndProcW = (WNDPROC)dwNewLong;
-        WindowObject->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE);
-		WindowObject->Class->Unicode = TRUE;
-	  }
+      /* FIXME - what do we return in this case? */
+      if (Ansi)
+      {
+	WindowObject->Class->lpfnWndProcA = (WNDPROC)dwNewLong;
+	WindowObject->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE);
+	WindowObject->Class->Unicode = FALSE;
+      }
+      else
+      {
+	WindowObject->Class->lpfnWndProcW = (WNDPROC)dwNewLong;
+	WindowObject->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE);
+	WindowObject->Class->Unicode = TRUE;
+      }
       break;
     }
-}
-
-DWORD STDCALL
-NtUserSetClassLong(HWND hWnd,
-		   DWORD Offset,
-		   LONG dwNewLong,
-		   BOOL Ansi)
-{
-  PWINDOW_OBJECT WindowObject;
-  LONG Ret;
-
-  WindowObject = IntGetWindowObject(hWnd);
-  if (WindowObject == NULL)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return 0;
-  }
-  Ret = IntGetClassLong(WindowObject, Offset, Ansi);
-  IntSetClassLong(WindowObject, Offset, dwNewLong, Ansi);
-  IntReleaseWindowObject(WindowObject);
-  return(Ret);
-}
-
-DWORD STDCALL
-NtUserSetClassWord(DWORD Unknown0,
-		   DWORD Unknown1,
-		   DWORD Unknown2)
-{
-  UNIMPLEMENTED;
-  return(0);
-}
-
-BOOL STDCALL
-NtUserUnregisterClass(
-   LPCWSTR ClassNameOrAtom,
-	 HINSTANCE hInstance,
-	 DWORD Unknown)
-{
-   NTSTATUS Status;
-   PWNDCLASS_OBJECT Class;
-   PWINSTATION_OBJECT WinStaObject;
-  
-   DPRINT("NtUserUnregisterClass(%S)\n", ClassNameOrAtom);
-   
-   if (!ClassNameOrAtom)
-   {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return FALSE;
-   }
-  
-   Status = IntValidateWindowStationHandle(
-      PROCESS_WINDOW_STATION(),
-      KernelMode,
-      0,
-      &WinStaObject);
-   if (!NT_SUCCESS(Status))
-   {
-      SetLastWin32Error(ERROR_INVALID_HANDLE);
-      return FALSE;
-   }
-
-   if (!ClassReferenceClassByNameOrAtom(&Class, ClassNameOrAtom, hInstance))
-   {
-      ObDereferenceObject(WinStaObject);
-      SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
-      return FALSE;
-   }
-  
-   if (Class->hInstance && Class->hInstance != hInstance)
-   {
-      ClassDereferenceObject(Class);
-      ObDereferenceObject(WinStaObject);
-      SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
-      return FALSE;
-   }
-  
-  IntLockClassWindows(Class);
-   if (!IsListEmpty(&Class->ClassWindowsListHead))
-   {
-      IntUnLockClassWindows(Class);
-      /* Dereference the ClassReferenceClassByNameOrAtom() call */
-      ObmDereferenceObject(Class);
-      ObDereferenceObject(WinStaObject);
-      SetLastWin32Error(ERROR_CLASS_HAS_WINDOWS);
-      return FALSE;
-   }
-   IntUnLockClassWindows(Class);
-  
-   /* Dereference the ClassReferenceClassByNameOrAtom() call */
-   ClassDereferenceObject(Class);
-  
-   RemoveEntryList(&Class->ListEntry);
-
-   RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Class->Atom);
-  
-   /* Free the object */
-   ClassDereferenceObject(Class);
-   
-   ObDereferenceObject(WinStaObject);
   
-   return TRUE;
+  return Ret;
 }
 
-/* EOF */

reactos/subsys/win32k/ntuser
clipboard.c 1.11 -> 1.11.8.1
diff -u -r1.11 -r1.11.8.1
--- clipboard.c	20 Jun 2004 00:45:36 -0000	1.11
+++ clipboard.c	15 Jul 2004 20:07:17 -0000	1.11.8.1
@@ -29,288 +29,4 @@
 #define NDEBUG
 #include <debug.h>
 
-#define CHECK_LOCK                                                      \
-        if (ClipboardThread && ClipboardThread != PsGetWin32Thread())   \
-        {                                                               \
-        SetLastWin32Error(ERROR_LOCKED);                                \
-        return FALSE;                                                   \
-        }
 
-PW32THREAD ClipboardThread;
-HWND ClipboardWindow;
-HWND tempClipboardWindow;
-HANDLE hCBData;
-UINT   uCBFormat;
-
-ULONG FASTCALL
-IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName)
-{
-
-   return IntGetAtomName((RTL_ATOM)format, FormatName->Buffer,
-      FormatName->MaximumLength);
-}
-
-UINT FASTCALL
-IntEnumClipboardFormats(UINT format)
-{
-
-   CHECK_LOCK
-
-   if (!hCBData)
-       return FALSE;
-   //UNIMPLEMENTED;
-   return 1;
-}
-
-BOOL STDCALL
-NtUserOpenClipboard(HWND hWnd, DWORD Unknown1)
-{
-   CHECK_LOCK
-
-   tempClipboardWindow = hWnd;
-   ClipboardThread = PsGetWin32Thread();
-   return TRUE;
-}
-
-BOOL STDCALL
-NtUserCloseClipboard(VOID)
-{
-   CHECK_LOCK
-
-   ClipboardWindow = 0;
-   ClipboardThread = NULL;
-   return TRUE;
-}
-
-/*
- * @unimplemented
- */
-HWND STDCALL
-NtUserGetOpenClipboardWindow(VOID)
-{
-   /*
-   UNIMPLEMENTED
-   return 0;
-   */
-   return ClipboardWindow;
-}
-
-BOOL STDCALL
-NtUserChangeClipboardChain(HWND hWndRemove, HWND hWndNewNext)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-DWORD STDCALL
-NtUserCountClipboardFormats(VOID)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-DWORD STDCALL
-NtUserEmptyClipboard(VOID)
-{
-   CHECK_LOCK
-
-//   if (!hCBData)
-//       return FALSE;
-
-//   FIXME!
-//   GlobalUnlock(hCBData);
-//   GlobalFree(hCBData);
-   hCBData = NULL;
-   uCBFormat = 0;
-   ClipboardWindow = tempClipboardWindow;
-
-   return TRUE;
-}
-
-HANDLE STDCALL
-NtUserGetClipboardData(UINT uFormat, DWORD Unknown1)
-{
-   CHECK_LOCK
-
-   if ((uFormat==1 && uCBFormat==13) || (uFormat==13 && uCBFormat==1))
-       uCBFormat = uFormat;
-
-   if (uFormat != uCBFormat)
-       return FALSE;
-
-   return hCBData;
-}
-
-INT STDCALL
-NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
-   INT cchMaxCount)
-{
-  NTSTATUS Status;
-  PWSTR Buf;
-  UNICODE_STRING SafeFormatName, BufFormatName;
-  ULONG Ret;
-
-  if((cchMaxCount < 1) || !FormatName)
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-
-  /* copy the FormatName UNICODE_STRING structure */
-  Status = MmCopyFromCaller(&SafeFormatName, FormatName, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return 0;
-  }
-
-  /* Allocate memory for the string */
-  Buf = ExAllocatePoolWithTag(PagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
-  if(!Buf)
-  {
-    SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-    return 0;
-  }
-
-  /* Setup internal unicode string */
-  BufFormatName.Length = 0;
-  BufFormatName.MaximumLength = min(cchMaxCount * sizeof(WCHAR), SafeFormatName.MaximumLength);
-  BufFormatName.Buffer = Buf;
-
-  if(BufFormatName.MaximumLength < sizeof(WCHAR))
-  {
-    ExFreePool(Buf);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-
-  if (format >= 0xC000)
-  {
-     Ret = IntGetClipboardFormatName(format, &BufFormatName);
-  }
-  else
-  {
-     SetLastNtError(NO_ERROR);
-     return 0;
-  }
-
-  /* copy the UNICODE_STRING buffer back to the user */
-  Status = MmCopyToCaller(SafeFormatName.Buffer, BufFormatName.Buffer, BufFormatName.MaximumLength);
-  if(!NT_SUCCESS(Status))
-  {
-    ExFreePool(Buf);
-    SetLastNtError(Status);
-    return 0;
-  }
-
-  BufFormatName.MaximumLength = SafeFormatName.MaximumLength;
-  BufFormatName.Buffer = SafeFormatName.Buffer;
-
-  /* update the UNICODE_STRING structure (only the Length member should change) */
-  Status = MmCopyToCaller(FormatName, &BufFormatName, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    ExFreePool(Buf);
-    SetLastNtError(Status);
-    return 0;
-  }
-
-  ExFreePool(Buf);
-  return Ret;
-}
-
-HWND STDCALL
-NtUserGetClipboardOwner(VOID)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-DWORD STDCALL
-NtUserGetClipboardSequenceNumber(VOID)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-HWND STDCALL
-NtUserGetClipboardViewer(VOID)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-INT STDCALL
-NtUserGetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-BOOL STDCALL
-NtUserIsClipboardFormatAvailable(UINT format)
-{
-   //UNIMPLEMENTED
-
-   if (format != 1 && format != 13) {
-      DbgPrint("Clipboard Format unavailable (%d)\n", format);
-      return FALSE;
-   }
-
-   if ((format==1 && uCBFormat==13) || (format==13 && uCBFormat==1))
-       uCBFormat = format;
-
-   if (format != uCBFormat)
-     return FALSE;
-
-   return TRUE;
-}
-
-//SetClipboardData(CF_UNICODETEXT, hdst);
-HANDLE STDCALL
-NtUserSetClipboardData(UINT uFormat, HANDLE hMem, DWORD Unknown2)
-{
-//    LPVOID pMem;
-    CHECK_LOCK
-
-
-   if (uFormat != 1 && uFormat != 13) {
-      DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
-      return FALSE;
-   }
-
-    if (hMem)
-    {
-        uCBFormat = uFormat;
-        hCBData = hMem;
-        //pMem = GlobalLock(hMem);
-        /*
-        switch (uFormat) {
-            default:
-                DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
-                return FALSE;
-            case CF_TEXT:             // 1
-                break;
-            case CF_UNICODETEXT:      // 13
-                break;
-            case CF_BITMAP:           // 2
-                break;
-            case CF_OEMTEXT:          // 7
-                break;
-        } */
-    }
-    else
-    {
-    //the window provides data in the specified format
-    }
-    return hMem;
-}
-
-HWND STDCALL
-NtUserSetClipboardViewer(HWND hWndNewViewer)
-{
-   UNIMPLEMENTED
-   return 0;
-}
-
-/* EOF */

reactos/subsys/win32k/ntuser
desktop.c 1.17 -> 1.17.2.1
diff -u -r1.17 -r1.17.2.1
--- desktop.c	9 Jul 2004 20:57:38 -0000	1.17
+++ desktop.c	15 Jul 2004 20:07:17 -0000	1.17.2.1
@@ -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: desktop.c,v 1.17 2004/07/09 20:57:38 gvg Exp $
+ *  $Id: desktop.c,v 1.17.2.1 2004/07/15 20:07:17 weiden Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -30,6 +30,9 @@
 /* INCLUDES ******************************************************************/
 #include <w32k.h>
 
+#define NDEBUG
+#include <debug.h>
+
 #if 0
 /* not yet defined in w32api... */
 NTSTATUS STDCALL
@@ -134,6 +137,14 @@
   return InputDesktop;
 }
 
+PWINDOW_OBJECT FASTCALL
+IntGetCurrentThreadDesktopWindow(VOID)
+{
+  PDESKTOP_OBJECT pdo = PsGetWin32Thread()->Desktop;
+  
+  return (pdo != NULL ? pdo->DesktopWindow : NULL);
+}
+
 /*
  * returns or creates a handle to the desktop object
  */
@@ -172,30 +183,53 @@
 }
 
 PUSER_MESSAGE_QUEUE FASTCALL
-IntGetFocusMessageQueue(VOID)
+IntGetActiveMessageQueue(VOID)
 {
    PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
    if (!pdo)
    {
-      DPRINT("No active desktop\n");
+      DPRINT1("No active desktop\n");
       return(NULL);
    }
    return (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
 }
 
-VOID FASTCALL
-IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
+PWINDOW_OBJECT FASTCALL
+IntGetForegroundWindow(VOID)
 {
-   PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
-   if (!pdo)
+  PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetActiveMessageQueue();
+  return (ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : NULL);
+}
+
+PUSER_MESSAGE_QUEUE FASTCALL
+IntSetActiveMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
+{
+   PUSER_MESSAGE_QUEUE Prev;
+   PDESKTOP_OBJECT pdo;
+   
+   if (!(pdo = IntGetActiveDesktop()))
    {
-      DPRINT("No active desktop\n");
-      return;
+      DPRINT1("No active desktop\n");
+      return NULL;
    }
-   pdo->ActiveMessageQueue = NewQueue;
+   
+   if(NewQueue != NULL)
+   {
+     IntReferenceMessageQueue(NewQueue);
+   }
+   
+   Prev = (PUSER_MESSAGE_QUEUE)InterlockedExchange((LONG*)&pdo->ActiveMessageQueue, (LONG)NewQueue);
+   
+   if(Prev != NULL)
+   {
+     IntDereferenceMessageQueue(Prev);
+   }
+   
+   return Prev;
 }
 
-HWND FASTCALL IntGetDesktopWindow(VOID)
+PWINDOW_OBJECT FASTCALL
+IntGetDesktopWindow(VOID)
 {
    PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
    if (!pdo)
@@ -206,17 +240,6 @@
   return pdo->DesktopWindow;
 }
 
-HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
-{
-  PDESKTOP_OBJECT pdo = PsGetWin32Thread()->Desktop;
-  if (NULL == pdo)
-    {
-      DPRINT1("Thread doesn't have a desktop\n");
-      return NULL;
-    }
-  return pdo->DesktopWindow;
-}
-
 /* PUBLIC FUNCTIONS ***********************************************************/
 
 NTSTATUS FASTCALL
@@ -226,7 +249,7 @@
   CSRSS_API_REPLY Reply;
 
   Request.Type = CSRSS_SHOW_DESKTOP;
-  Request.Data.ShowDesktopRequest.DesktopWindow = Desktop->DesktopWindow;
+  Request.Data.ShowDesktopRequest.DesktopWindow = Desktop->DesktopWindow->Handle;
   Request.Data.ShowDesktopRequest.Width = Width;
   Request.Data.ShowDesktopRequest.Height = Height;
 
@@ -245,15 +268,7 @@
 
   return NotifyCsrss(&Request, &Reply);
 #else
-  PWINDOW_OBJECT DesktopWindow;
-
-  DesktopWindow = IntGetWindowObject(Desktop->DesktopWindow);
-  if (! DesktopWindow)
-    {
-      return ERROR_INVALID_WINDOW_HANDLE;
-    }
-  DesktopWindow->Style &= ~WS_VISIBLE;
-
+  Desktop->DesktopWindow->Style &= ~WS_VISIBLE;
   return STATUS_SUCCESS;
 #endif
 }
@@ -637,17 +652,18 @@
       return FALSE;
    }
 
-   ObDereferenceObject(Object);
-
    DPRINT("Closing desktop handle (0x%X)\n", hDesktop);
 
    Status = ZwClose(hDesktop);
    if (!NT_SUCCESS(Status))
    {
+      ObDereferenceObject(Object);
       SetLastNtError(Status);
       return FALSE;
    }
 
+   ObDereferenceObject(Object);
+
    return TRUE;
 }
 
@@ -666,17 +682,21 @@
  *    @implemented
  */
 
-BOOL STDCALL
-NtUserPaintDesktop(HDC hDC)
+BOOL FASTCALL
+IntPaintDesktop(HDC hDC)
 {
   RECT Rect;
   HBRUSH DesktopBrush, PreviousBrush;
-  HWND hWndDesktop;
+  PWINDOW_OBJECT WndDesktop;
 
   IntGdiGetClipBox(hDC, &Rect);
 
-  hWndDesktop = IntGetDesktopWindow();
-  DesktopBrush = (HBRUSH)NtUserGetClassLong(hWndDesktop, GCL_HBRBACKGROUND, FALSE);
+  if(!(WndDesktop = IntGetDesktopWindow()))
+  {
+    return FALSE;
+  }
+  
+  DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE);
 
   /*
    * Paint desktop background

reactos/subsys/win32k/ntuser
focus.c 1.24 -> 1.24.4.1
diff -u -r1.24 -r1.24.4.1
--- focus.c	23 Jun 2004 15:38:07 -0000	1.24
+++ focus.c	15 Jul 2004 20:07:17 -0000	1.24.4.1
@@ -16,467 +16,392 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: focus.c,v 1.24 2004/06/23 15:38:07 weiden Exp $
+ * $Id: focus.c,v 1.24.4.1 2004/07/15 20:07:17 weiden Exp $
  */
-
 #include <w32k.h>
 
 #define NDEBUG
-#include <win32k/debug1.h>
 #include <debug.h>
 
-HWND FASTCALL
-IntGetCaptureWindow()
-{
-   PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
-   return ForegroundQueue != NULL ? ForegroundQueue->CaptureWindow : 0;
-}
-
-HWND FASTCALL
-IntGetFocusWindow()
-{
-   PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
-   return ForegroundQueue != NULL ? ForegroundQueue->FocusWindow : 0;
-}
-
-HWND FASTCALL
-IntGetThreadFocusWindow()
-{
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   return ThreadQueue != NULL ? ThreadQueue->FocusWindow : 0;
-}
 
-VOID FASTCALL
-IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd)
+PWINDOW_OBJECT FASTCALL
+IntGetActiveWindow(VOID)
 {
-   if (hWndPrev)
-   {
-      IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0);
-      IntPostOrSendMessage(hWndPrev, WM_ACTIVATE,
-         MAKEWPARAM(WA_INACTIVE, NtUserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
-         (LPARAM)hWnd);
-   }
+  PUSER_MESSAGE_QUEUE ThreadQueue;
+  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+  return (ThreadQueue != NULL ? ThreadQueue->ActiveWindow : NULL);
 }
 
-VOID FASTCALL
-IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
+PWINDOW_OBJECT FASTCALL
+IntGetCaptureWindow(VOID)
 {
-   if (hWnd)
-   {
-      /* Send palette messages */
-      if (IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0))
-      {
-         IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING,
-            (WPARAM)hWnd, 0);
-      }
-
-      if (NtUserGetWindow(hWnd, GW_HWNDPREV) != NULL)
-         WinPosSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
-            SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
-
-      /* FIXME: IntIsWindow */
-
-      IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == NtUserGetForegroundWindow()), 0);
-      /* FIXME: WA_CLICKACTIVE */
-      IntPostOrSendMessage(hWnd, WM_ACTIVATE,
-         MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
-                    NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
-         (LPARAM)hWndPrev);
-   }
+  PUSER_MESSAGE_QUEUE ThreadQueue;
+  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+  /* FIXME - return NULL if we're not the active input queue? */
+  return (ThreadQueue != NULL ? ThreadQueue->CaptureWindow : NULL);
 }
 
-VOID FASTCALL
-IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd)
+PWINDOW_OBJECT FASTCALL
+IntGetFocusWindow(VOID)
 {
-   if (hWndPrev)
-   {
-      IntPostOrSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0);
-   }
+  PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetActiveMessageQueue();
+  
+  if(ForegroundQueue != NULL && ForegroundQueue != PsGetWin32Thread()->MessageQueue)
+  {
+    /*
+     * GetFocus() only returns the handle if the current thread is the active
+     * input thread
+     */
+    return ForegroundQueue->FocusWindow;
+  }
+  
+  return NULL;
 }
 
-VOID FASTCALL
-IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd)
+PWINDOW_OBJECT
+FASTCALL IntGetThreadFocusWindow(VOID)
 {
-   if (hWnd)
-   {
-      IntPostOrSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0);
-   }
+  PUSER_MESSAGE_QUEUE ThreadQueue = PsGetWin32Thread()->MessageQueue;
+  return (ThreadQueue != NULL ? ThreadQueue->FocusWindow : NULL);
 }
 
-HWND FASTCALL
-IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner)
+BOOL FASTCALL
+IntSetForegroundWindow(PWINDOW_OBJECT Window)
 {
-  HWND Ret;
-  PWINDOW_OBJECT Child, OwnerWnd;
-  IntLockRelatives(Root);
-  
-  for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
-  {
-    IntLockRelatives(Child);
-    OwnerWnd = IntGetWindowObject(Child->Owner);
-    IntUnLockRelatives(Child);
-    if(!OwnerWnd)
-      continue;
-    
-    if(OwnerWnd == Owner)
+  PDESKTOP_OBJECT pdo;
+  PWINDOW_OBJECT PrevActiveWindow;
+  PUSER_MESSAGE_QUEUE PrevForegroundQueue;
+  
+  ASSERT(Window);
+  
+  /* FIXME - check if the calling process is allowed to set the foreground window.
+             See AllowSetForegroundWindow() */
+  
+  /* FIXME - check if changing the foreground window is locked for the current process.
+             See LockSetForegroundWindow() - Is this related to AllowSetForegroundWindow()? */
+  
+  if((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+  {
+    DPRINT("Failed - Child\n");
+    return FALSE;
+  }
+  
+  if(!(Window->Style & WS_VISIBLE))
+  {
+    DPRINT("Failed - Invisible\n");
+    return FALSE;
+  }
+  
+  /*
+   * It's not permitted to change the foreground window if the current input
+   * message queue has active menus (2000/XP and later)
+   */
+  
+  if(pdo->ActiveMessageQueue != NULL &&
+     pdo->ActiveMessageQueue->MenuOwner != NULL)
+  {
+    DPRINT("Can't set foreground window, menus are opened!\n");
+    return FALSE;
+  }
+  
+  /* Switch the message queue */
+  PrevForegroundQueue = IntSetActiveMessageQueue(Window->MessageQueue);
+  
+  if(PrevForegroundQueue != NULL && PrevForegroundQueue != Window->MessageQueue)
+  {
+    /* We have to change the active message queue. Notify the active and focus
+       windows of the previous active message queue */
+    if(PrevForegroundQueue->ActiveWindow != NULL)
+    {
+      #if 0
+      IntSendDeactivateMessages(PrevForegroundQueue->ActiveWindow, Window);
+      #endif
+    }
+    if(PrevForegroundQueue->FocusWindow != NULL)
     {
-      IntUnLockRelatives(Root);
-      Ret = Child->Self;
-      IntReleaseWindowObject(OwnerWnd);
-      return Ret;
+      #if 0
+      IntSendKillFocusMessages(PrevForegroundQueue->FocusWindow, Window->MessageQueue->FocusWindow);
+      #endif
     }
-    IntReleaseWindowObject(OwnerWnd);
   }
   
-  IntUnLockRelatives(Root);
-  return NULL;
+  /*
+   * We're ready to switch the active window and 
+   * send an activation message to the new active window
+   */
+  
+  PrevActiveWindow = MsqSetStateWindow(Window->MessageQueue, MSQ_STATE_ACTIVE, Window);
+  if(PrevActiveWindow != NULL && PrevActiveWindow != Window)
+  {
+    /* Send a deactivation message to the previous active window */
+    #if 0
+    IntSendDeactivateMessages(PrevActiveWindow, Window);
+    #endif
+  }
+  
+  /* FIXME - send a focus message, too? */
+  
+  return TRUE;
 }
 
 STATIC BOOL FASTCALL
 IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWindow, BOOL MouseActivate)
 {
-   HWND hWnd = Window->Self;
-   HWND hWndPrev = NULL;
-   HWND hWndFocus = FocusWindow->Self;
-   HWND hWndFocusPrev = NULL;
-   PUSER_MESSAGE_QUEUE PrevForegroundQueue;
-
-   DPRINT("IntSetForegroundAndFocusWindow(%x, %x, %s)\n", hWnd, hWndFocus, MouseActivate ? "TRUE" : "FALSE");
-   DPRINT("(%wZ)\n", &Window->WindowName);
-
-   if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
-   {
-      DPRINT("Failed - Child\n");
-      return FALSE;
-   }
-
-   if (0 == (Window->Style & WS_VISIBLE))
-   {
-      DPRINT("Failed - Invisible\n");
-      return FALSE;
-   }
-
-   PrevForegroundQueue = IntGetFocusMessageQueue();
-   if (PrevForegroundQueue != 0)
-   {
-      hWndPrev = PrevForegroundQueue->ActiveWindow;
-   }
-
-   if (hWndPrev == hWnd)
-   {
-      DPRINT("Failed - Same\n");
-      return TRUE;
-   }
-
-   hWndFocusPrev = (PrevForegroundQueue == FocusWindow->MessageQueue
-                    ? FocusWindow->MessageQueue->FocusWindow : NULL);
-
-   /* FIXME: Call hooks. */
-
-   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);
-
-   IntSendDeactivateMessages(hWndPrev, hWnd);
-   IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
-   if (PrevForegroundQueue != Window->MessageQueue)
-   {
-      /* FIXME: Send WM_ACTIVATEAPP to all thread windows. */
-   }
-   IntSendSetFocusMessages(hWndFocusPrev, hWndFocus);
-   IntSendActivateMessages(hWndPrev, hWnd, MouseActivate);
-   
-   return TRUE;
+  PUSER_MESSAGE_QUEUE PrevForegroundQueue;
+  PWINDOW_OBJECT PrevActiveWindow, PrevFocusWindow;
+  
+  ASSERT(Window);
+  ASSERT(FocusWindow);
+  
+  /* Window and FocusWindow MUST belong to the same thread! */
+  ASSERT(Window->MessageQueue == FocusWindow->MessageQueue);
+  
+  if((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+  {
+    DPRINT("Failed - Child\n");
+    return FALSE;
+  }
+  
+  if(!(Window->Style & WS_VISIBLE))
+  {
+    DPRINT("Failed - Invisible\n");
+    return FALSE;
+  }
+  
+  /*
+   * Change the active/focus window in the message queue. This may not be the
+   * active message queue but we switch the windows here already.
+   */
+  
+  PrevActiveWindow = MsqSetStateWindow(Window->MessageQueue, MSQ_STATE_ACTIVE, Window);
+  if(PrevActiveWindow != NULL && PrevActiveWindow != Window)
+  {
+    /* Send deactivation message */
+    #if 0
+    IntSendDeactivateMessages(PrevWindow, Window);
+    #endif
+  }
+  
+  PrevFocusWindow = MsqSetStateWindow(Window->MessageQueue, MSQ_STATE_FOCUS, FocusWindow);
+  if(PrevFocusWindow != NULL && PrevFocusWindow != FocusWindow)
+  {
+    /* Send kill focus message */
+    #if 0
+    IntSendKillFocusMessages(PrevFocusWindow, FocusWindow);
+    #endif
+  }
+  
+  /*
+   * Switch the desktop's active message queue
+   */
+  
+  PrevForegroundQueue = IntSetActiveMessageQueue(Window->MessageQueue);
+  
+  /*
+   * If we actually changed the active message queue, we have to notify
+   * the previous active message queue. We don't send but post messages in this
+   * case.
+   */
+  
+  if(PrevForegroundQueue != NULL && PrevForegroundQueue != Window->MessageQueue)
+  {
+    /* Changed the desktop's foreground message queue, we need to notify the old thread */
+    if(PrevForegroundQueue->ActiveWindow != NULL)
+    {
+      #if 0
+      IntSendDeactivateMessages(PrevForegroundQueue->ActiveWindow, Window);
+      #endif
+    }
+    /* we also killed the focus */
+    if(PrevForegroundQueue->FocusWindow != NULL)
+    {
+      #if 0
+      IntSendKillFocusMessages(PrevForegroundQueue->FocusWindow, FocusWindow);
+      #endif
+    }
+  }
+  
+  /*
+   * We're ready to notify the windows of our message queue that had been
+   * activated.
+   */
+  
+  if(Window != NULL && PrevActiveWindow != Window)
+  {
+    #if 0
+    IntSendActivateMessages(PrevActiveWindow, Window, MouseActivate);
+    #endif
+  }
+  
+  if(FocusWindow != NULL && PrevFocusWindow != FocusWindow)
+  {
+    #if 0
+    IntSendSetFocusMessages(PrevFocusWindow, FocusWindow);
+    #endif
+  }
+  
+  return TRUE;
 }
 
-BOOL FASTCALL
-IntSetForegroundWindow(PWINDOW_OBJECT Window)
+PWINDOW_OBJECT FASTCALL
+IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner)
 {
-   return IntSetForegroundAndFocusWindow(Window, Window, FALSE);
+  PWINDOW_OBJECT Child;
+  
+  ASSERT(Root);
+  
+  if(Owner != NULL)
+  {
+    for(Child = Root->FirstChild; Child != NULL; Child = Child->NextSibling)
+    {
+      if(Child->Owner == Owner)
+      {
+        return Child;
+      }
+    }
+  }
+  
+  return NULL;
 }
 
 BOOL FASTCALL
-IntMouseActivateWindow(PWINDOW_OBJECT Window)
+IntMouseActivateWindow(PWINDOW_OBJECT DesktopWindow, PWINDOW_OBJECT Window)
 {
-  HWND Top;
   PWINDOW_OBJECT TopWindow;
   
+  ASSERT(Window);
+  ASSERT(DesktopWindow);
+  
   if(Window->Style & WS_DISABLED)
   {
-    BOOL Ret;
-    PWINDOW_OBJECT TopWnd;
-    PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-    if(DesktopWindow)
+    if((TopWindow = IntFindChildWindowToOwner(DesktopWindow, Window)))
     {
-      Top = IntFindChildWindowToOwner(DesktopWindow, Window);
-      if((TopWnd = IntGetWindowObject(Top)))
-      {
-        Ret = IntMouseActivateWindow(TopWnd);
-        IntReleaseWindowObject(TopWnd);
-        IntReleaseWindowObject(DesktopWindow);
-        return Ret;
-      }
-      IntReleaseWindowObject(DesktopWindow);
+      /* FIXME - do we need some pretection to prevent stack overflows? */
+      return IntMouseActivateWindow(DesktopWindow, TopWindow);
     }
+    
     return FALSE;
   }
   
-  Top = NtUserGetAncestor(Window->Self, GA_ROOT);
-  if (Top != Window->Self)
+  if((TopWindow = IntGetAncestor(Window, GA_ROOT)))
+  {
+    IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
+  }
+  
+  return TRUE;
+}
+
+PWINDOW_OBJECT FASTCALL
+IntSetActiveWindow(PWINDOW_OBJECT Window)
+{
+  PWINDOW_OBJECT PrevWindow;
+  PUSER_MESSAGE_QUEUE ThreadQueue;
+  
+  ThreadQueue = PsGetWin32Thread()->MessageQueue;
+  
+  if(Window != NULL)
+  {
+    if(ThreadQueue != Window->MessageQueue)
     {
-      TopWindow = IntGetWindowObject(Top);
+      /* don't allow to change the active window, if it doesn't belong to the
+         calling thread */
+      return NULL;
     }
-  else
+    
+    if(!(Window->Style & WS_VISIBLE) ||
+       (Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
     {
-      TopWindow = Window;
+      /* FIXME - Is that right? */
+      return ThreadQueue->ActiveWindow;
     }
-
-  IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
-
-  if (Top != Window->Self)
+  }
+  
+  PrevWindow = MsqSetStateWindow(ThreadQueue, MSQ_STATE_ACTIVE, Window);
+  
+  if(PrevWindow != Window)
+  {
+    #if 0
+    if(PrevWindow != NULL)
     {
-      IntReleaseWindowObject(TopWindow);
+      IntSendDeactivateMessages(PrevWindow, Window);
     }
-  return TRUE;
-}
-
-HWND FASTCALL
-IntSetActiveWindow(PWINDOW_OBJECT Window)
-{
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-   HWND hWndPrev;
-   HWND hWnd = 0;
-
-   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   ASSERT(ThreadQueue != 0);
-
-   if (Window != 0)
-   {
-      if (!(Window->Style & WS_VISIBLE) ||
-          (Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
-      {
-         return ThreadQueue ? 0 : ThreadQueue->ActiveWindow;
-      }
-      hWnd = Window->Self;
-   }
-
-   hWndPrev = ThreadQueue->ActiveWindow;
-   if (hWndPrev == hWnd)
-   {
-      return hWndPrev;
-   }
-
-   /* FIXME: Call hooks. */
-
-   IntLockMessageQueue(ThreadQueue);
-   ThreadQueue->ActiveWindow = hWnd;
-   IntUnLockMessageQueue(ThreadQueue);
-
-   IntSendDeactivateMessages(hWndPrev, hWnd);
-   IntSendActivateMessages(hWndPrev, hWnd, FALSE);
-
-/* FIXME */
-/*   return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/
-   return hWndPrev;
-}
-
-HWND FASTCALL
-IntSetFocusWindow(HWND hWnd)
-{
-   HWND hWndPrev = 0;
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-
-   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   ASSERT(ThreadQueue != 0);
-
-   hWndPrev = ThreadQueue->FocusWindow;
-   if (hWndPrev == hWnd)
-   {
-      return hWndPrev;
-   }
-
-   IntLockMessageQueue(ThreadQueue);
-   ThreadQueue->FocusWindow = hWnd;
-   IntUnLockMessageQueue(ThreadQueue);
-
-   IntSendKillFocusMessages(hWndPrev, hWnd);
-   IntSendSetFocusMessages(hWndPrev, hWnd);
-
-   return hWndPrev;
-}
-
-/*
- * @implemented
- */
-HWND STDCALL
-NtUserGetForegroundWindow(VOID)
-{
-   PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
-   return ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : 0;
-}
-
-/*
- * @implemented
- */
-HWND STDCALL
-NtUserGetActiveWindow(VOID)
-{
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   return ThreadQueue ? ThreadQueue->ActiveWindow : 0;
-}
-
-HWND STDCALL
-NtUserSetActiveWindow(HWND hWnd)
-{
-   DPRINT("NtUserSetActiveWindow(%x)\n", hWnd);
-
-   if (hWnd)
-   {
-      PWINDOW_OBJECT Window;
-      PUSER_MESSAGE_QUEUE ThreadQueue;
-      HWND hWndPrev;
-
-      Window = IntGetWindowObject(hWnd);
-      if (Window == NULL)
-      {
-         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-         return 0;
-      }
-
-      DPRINT("(%wZ)\n", &Window->WindowName);
-
-      ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
-      if (Window->MessageQueue != ThreadQueue)
-      {
-         IntReleaseWindowObject(Window);
-         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-         return 0;
-      }
-
-      hWndPrev = IntSetActiveWindow(Window);
-      IntReleaseWindowObject(Window);
-
-      return hWndPrev;
-   }
-   else
-   {
-      return IntSetActiveWindow(0);
-   }
+    IntSendActivateMessages(PrevWindow, Window, FALSE);
+    #endif
+  }
+  
+  return PrevWindow;
 }
 
-/*
- * @implemented
- */
-HWND STDCALL
-NtUserGetCapture(VOID)
+PWINDOW_OBJECT FASTCALL
+IntSetFocusWindow(PWINDOW_OBJECT Window)
 {
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   return ThreadQueue ? ThreadQueue->CaptureWindow : 0;
+  PWINDOW_OBJECT PrevWindow;
+  
+  PrevWindow = MsqSetStateWindow(Window->MessageQueue, MSQ_STATE_FOCUS, Window);
+  
+  #if 0
+  if(Window != PrevWindow)
+  {
+    IntSendKillFocusMessages(PrevWindow, Window);
+    IntSendSetFocusMessages(PrevWindow, Window);
+  }
+  #endif
+  
+  return PrevWindow;
 }
 
-/*
- * @implemented
- */
-HWND STDCALL
-NtUserSetCapture(HWND hWnd)
+PWINDOW_OBJECT FASTCALL
+IntSetFocus(PWINDOW_OBJECT Window)
 {
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-   PWINDOW_OBJECT Window;
-   HWND hWndPrev;
-
-   DPRINT("NtUserSetCapture(%x)\n", hWnd);
-
-   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   if((Window = IntGetWindowObject(hWnd)))
-   {
-      if(Window->MessageQueue != ThreadQueue)
-      {
-         IntReleaseWindowObject(Window);
-         return NULL;
-      }
-   }
-   hWndPrev = MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, hWnd);
-   
-   /* also remove other windows if not capturing anymore */
-   if(hWnd == NULL)
-   {
-     MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL);
-     MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL);
-   }
-   
-   IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd);
-   IntLockMessageQueue(ThreadQueue);
-   ThreadQueue->CaptureWindow = hWnd;
-   IntUnLockMessageQueue(ThreadQueue);
-
-   return hWndPrev;
+  if(Window != NULL)
+  {
+    PUSER_MESSAGE_QUEUE ThreadQueue;
+    PWINDOW_OBJECT WindowTop;
+    
+    ThreadQueue = PsGetWin32Thread()->MessageQueue;
+    
+    if(Window->Style & (WS_MINIMIZE | WS_DISABLED))
+    {
+      /* FIXME - Is this right? */
+      return (ThreadQueue ? ThreadQueue->FocusWindow : NULL);
+    }
+    
+    if(Window->MessageQueue != ThreadQueue)
+    {
+      /* don't allow to set focus to windows that don't belong to the calling
+         thread */
+      return NULL;
+    }
+    
+    WindowTop = IntGetAncestor(Window, GA_ROOT);
+    if(WindowTop != ThreadQueue->ActiveWindow &&
+       WindowTop->MessageQueue == ThreadQueue)
+    {
+      /* only activate the top level window belongs to the calling thread and
+         isn't already active */
+      IntSetActiveWindow(WindowTop);
+    }
+    
+    return IntSetFocusWindow(Window);
+  }
+  
+  return IntSetFocusWindow(NULL);
 }
 
-/*
- * @implemented
- */
-HWND STDCALL
-NtUserSetFocus(HWND hWnd)
+PWINDOW_OBJECT FASTCALL
+IntSetCapture(PWINDOW_OBJECT Window)
 {
-   DPRINT("NtUserSetFocus(%x)\n", hWnd);
-
-   if (hWnd)
-   {
-      PWINDOW_OBJECT Window;
-      PUSER_MESSAGE_QUEUE ThreadQueue;
-      HWND hWndPrev, hWndTop;
-
-      Window = IntGetWindowObject(hWnd);
-      if (Window == NULL)
-      {
-         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-         return 0;
-      }
-
-      ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
-      if (Window->Style & (WS_MINIMIZE | WS_DISABLED))
-      {
-         IntReleaseWindowObject(Window);
-         return (ThreadQueue ? ThreadQueue->FocusWindow : 0);
-      }
-
-      if (Window->MessageQueue != ThreadQueue)
-      {
-         IntReleaseWindowObject(Window);
-         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-         return 0;
-      }
-
-      hWndTop = NtUserGetAncestor(hWnd, GA_ROOT);
-      if (hWndTop != NtUserGetActiveWindow())
-      {
-         NtUserSetActiveWindow(hWndTop);
-      }
-
-      hWndPrev = IntSetFocusWindow(hWnd);
-      IntReleaseWindowObject(Window);
-
-      return hWndPrev;
-   }
-   else
-   {
-      return IntSetFocusWindow(NULL);
-   }
+  PUSER_MESSAGE_QUEUE ThreadQueue;
+  
+  ThreadQueue = PsGetWin32Thread()->MessageQueue;
+  
+  if(Window != NULL && (Window->MessageQueue != ThreadQueue))
+  {
+    /* don't allow to set focus to windows that don't belong to the calling
+       thread */
+    return NULL;
+  }
+  
+  return MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, Window);
 }
 
-/* EOF */

reactos/subsys/win32k/ntuser
guicheck.c 1.19 -> 1.19.12.1
diff -u -r1.19 -r1.19.12.1
--- guicheck.c	21 May 2004 10:09:31 -0000	1.19
+++ guicheck.c	15 Jul 2004 20:07:17 -0000	1.19.12.1
@@ -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: guicheck.c,v 1.19 2004/05/21 10:09:31 weiden Exp $
+/* $Id: guicheck.c,v 1.19.12.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -48,12 +48,12 @@
 AddGuiApp(PW32PROCESS W32Data)
 {
   W32Data->Flags |= W32PF_CREATEDWINORDC;
-  if (0 == NrGuiApplicationsRunning++)
+  if (InterlockedIncrement(&NrGuiApplicationsRunning) == 1)
     {
       if (! IntInitializeDesktopGraphics())
         {
           W32Data->Flags &= ~W32PF_CREATEDWINORDC;
-          NrGuiApplicationsRunning--;
+          InterlockedDecrement(&NrGuiApplicationsRunning);
           return FALSE;
         }
     }
@@ -65,11 +65,7 @@
 RemoveGuiApp(PW32PROCESS W32Data)
 {
   W32Data->Flags &= ~W32PF_CREATEDWINORDC;
-  if (0 < NrGuiApplicationsRunning)
-    {
-      NrGuiApplicationsRunning--;
-    }
-  if (0 == NrGuiApplicationsRunning)
+  if (InterlockedDecrement(&NrGuiApplicationsRunning))
     {
       IntEndDesktopGraphics();
     }

reactos/subsys/win32k/ntuser
hook.c 1.8 -> 1.8.12.1
diff -u -r1.8 -r1.8.12.1
--- hook.c	10 May 2004 17:07:18 -0000	1.8
+++ hook.c	15 Jul 2004 20:07:17 -0000	1.8.12.1
@@ -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: hook.c,v 1.8 2004/05/10 17:07:18 weiden Exp $
+/* $Id: hook.c,v 1.8.12.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -32,625 +32,6 @@
 #include <w32k.h>
 
 #define NDEBUG
-#include <win32k/debug1.h>
+#include <debug.h>
 
-#define HOOKID_TO_INDEX(HookId) (HookId - WH_MINHOOK)
 
-STATIC PHOOKTABLE GlobalHooks;
-
-/* create a new hook table */
-STATIC FASTCALL PHOOKTABLE
-IntAllocHookTable(void)
-{
-  PHOOKTABLE Table;
-  UINT i;
-
-  Table = ExAllocatePoolWithTag(PagedPool, sizeof(HOOKTABLE), TAG_HOOK);
-  if (NULL != Table)
-    {
-      ExInitializeFastMutex(&Table->Lock);
-      for (i = 0; i < NB_HOOKS; i++)
-        {
-          InitializeListHead(&Table->Hooks[i]);
-          Table->Counts[i] = 0;
-        }
-    }
-
-  return Table;
-}
-
-/* create a new hook and add it to the specified table */
-STATIC FASTCALL PHOOK
-IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinStaObj)
-{
-  PHOOK Hook;
-  PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(Thread->Win32Thread->MessageQueue);
-  HANDLE Handle;
-
-  if (NULL == Table)
-    {
-      Table = IntAllocHookTable();
-      if (NULL == Table)
-        {
-          return NULL;
-        }
-      if (Global)
-        {
-          GlobalHooks = Table;
-        }
-      else
-        {
-          MsqSetHooks(Thread->Win32Thread->MessageQueue, Table);
-        }
-    }
-
-  Hook = ObmCreateObject(WinStaObj->HandleTable, &Handle,
-                         otHookProc, sizeof(HOOK));
-  if (NULL == Hook)
-    {
-      return NULL;
-    }
-
-  Hook->Self = Handle;
-  Hook->Thread = Thread;
-  Hook->HookId = HookId;
-  RtlInitUnicodeString(&Hook->ModuleName, NULL);
-
-  IntLockHookTable(Table);
-  InsertHeadList(&Table->Hooks[HOOKID_TO_INDEX(HookId)], &Hook->Chain);
-  IntUnLockHookTable(Table);
-
-  return Hook;
-}
-
-/* get the hook table that a given hook belongs to */
-STATIC PHOOKTABLE FASTCALL
-IntGetTable(PHOOK Hook)
-{
-  if (NULL == Hook->Thread || WH_KEYBOARD_LL == Hook->HookId ||
-      WH_MOUSE_LL == Hook->HookId)
-    {
-      return GlobalHooks;
-    }
-
-  return MsqGetHooks(Hook->Thread->Win32Thread->MessageQueue);
-}
-
-/* get the first hook in the chain */
-STATIC PHOOK FASTCALL
-IntGetFirstHook(PHOOKTABLE Table, int HookId)
-{
-  PLIST_ENTRY Elem = Table->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
-  return Elem == &Table->Hooks[HOOKID_TO_INDEX(HookId)]
-         ? NULL : CONTAINING_RECORD(Elem, HOOK, Chain);
-}
-
-/* find the first non-deleted hook in the chain */
-STATIC PHOOK FASTCALL
-IntGetFirstValidHook(PHOOKTABLE Table, int HookId)
-{
-  PHOOK Hook;
-  PLIST_ENTRY Elem;
-
-  IntLockHookTable(Table);
-  Hook = IntGetFirstHook(Table, HookId);
-  while (NULL != Hook && NULL == Hook->Proc)
-    {
-      Elem = Hook->Chain.Flink;
-      Hook = (Elem == &Table->Hooks[HOOKID_TO_INDEX(HookId)]
-              ? NULL : CONTAINING_RECORD(Elem, HOOK, Chain));
-    }
-  IntUnLockHookTable(Table);
-  
-  return Hook;
-}
-
-/* find the next hook in the chain, skipping the deleted ones */
-STATIC PHOOK FASTCALL
-IntGetNextHook(PHOOK Hook)
-{
-  PHOOKTABLE Table = IntGetTable(Hook);
-  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 */
-    {
-      return IntGetFirstValidHook(GlobalHooks, HookId);
-    }
-
-  return NULL;
-}
-
-/* free a hook, removing it from its chain */
-STATIC VOID FASTCALL
-IntFreeHook(PHOOKTABLE Table, PHOOK Hook, PWINSTATION_OBJECT WinStaObj)
-{
-  RemoveEntryList(&Hook->Chain);
-  RtlFreeUnicodeString(&Hook->ModuleName);
-  
-  /* Dereference thread if required */
-  if(Hook->Flags & HOOK_THREAD_REFERENCED)
-    ObDereferenceObject(Hook->Thread);
-  
-  /* Close handle */
-  ObmCloseHandle(WinStaObj->HandleTable, Hook->Self);
-}
-
-/* remove a hook, freeing it if the chain is not in use */
-STATIC FASTCALL VOID
-IntRemoveHook(PHOOK Hook, PWINSTATION_OBJECT WinStaObj)
-{
-  PHOOKTABLE Table = IntGetTable(Hook);
-
-  ASSERT(NULL != Table);
-  if (NULL == Table)
-    {
-      return;
-    }
-
-  IntLockHookTable(Table);
-  if (0 != Table->Counts[HOOKID_TO_INDEX(Hook->HookId)])
-    {
-      Hook->Proc = NULL; /* chain is in use, just mark it and return */
-    }
-  else
-    {
-      IntFreeHook(Table, Hook, WinStaObj);
-    }
-  IntUnLockHookTable(Table);
-}
-
-/* release a hook chain, removing deleted hooks if the use count drops to 0 */
-STATIC VOID FASTCALL
-IntReleaseHookChain(PHOOKTABLE Table, int HookId, PWINSTATION_OBJECT WinStaObj)
-{
-  PLIST_ENTRY Elem;
-  PHOOK HookObj;
-
-  if (NULL == Table)
-    {
-      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)])
-    {
-      Elem = Table->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
-      while (Elem != &Table->Hooks[HOOKID_TO_INDEX(HookId)])
-        {
-          HookObj = CONTAINING_RECORD(Elem, HOOK, Chain);
-          Elem = Elem->Flink;
-          if (NULL == HookObj->Proc)
-            {
-              IntFreeHook(Table, HookObj, WinStaObj);
-            }
-        }
-    }
-  IntUnLockHookTable(Table);
-}
-
-LRESULT FASTCALL
-HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
-{
-  PHOOK Hook;
-  PHOOKTABLE Table = MsqGetHooks(PsGetWin32Thread()->MessageQueue);
-  LRESULT Result;
-  PWINSTATION_OBJECT WinStaObj;
-  NTSTATUS Status;
-
-  ASSERT(WH_MINHOOK <= HookId && HookId <= WH_MAXHOOK);
-
-  if (NULL == Table || ! (Hook = IntGetFirstValidHook(Table, HookId)))
-    {
-      /* try global table */
-      Table = GlobalHooks;
-      if (NULL == Table || ! (Hook = IntGetFirstValidHook(Table, HookId)))
-        {
-          return 0;  /* no hook set */
-        }
-    }
-
-  if (Hook->Thread != PsGetCurrentThread())
-    {
-      DPRINT1("Calling hooks in other threads not implemented yet");
-      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 = IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc,
-                           Hook->Ansi, &Hook->ModuleName);
-
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				          KernelMode,
-				          0,
-				          &WinStaObj);
-  
-  if(! NT_SUCCESS(Status))
-    {
-      DPRINT1("Invalid window station????\n");
-    }
-  else
-    {
-      IntReleaseHookChain(MsqGetHooks(PsGetWin32Thread()->MessageQueue), HookId, WinStaObj);
-      IntReleaseHookChain(GlobalHooks, HookId, WinStaObj);
-      ObDereferenceObject(WinStaObj);
-    }
-
-  return Result;
-}
-
-VOID FASTCALL
-HOOK_DestroyThreadHooks(PETHREAD Thread)
-{
-  int HookId;
-  PLIST_ENTRY Elem;
-  PHOOK HookObj;
-  PWINSTATION_OBJECT WinStaObj;
-  NTSTATUS Status;
-
-  if (NULL != GlobalHooks)
-    {
-      Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                              KernelMode,
-                                              0,
-                                              &WinStaObj);
-  
-      if(! NT_SUCCESS(Status))
-        {
-          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 */
-          switch(HookId)
-            {
-            case WH_KEYBOARD_LL:
-            case WH_MOUSE_LL:
-              Elem = GlobalHooks->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
-              while (Elem != &GlobalHooks->Hooks[HOOKID_TO_INDEX(HookId)])
-                {
-                  HookObj = CONTAINING_RECORD(Elem, HOOK, Chain);
-                  Elem = Elem->Flink;
-                  if (HookObj->Thread == Thread)
-                    {
-                      IntRemoveHook(HookObj, WinStaObj);
-                    }
-                }
-              break;
-            }
-        }
-      IntUnLockHookTable(GlobalHooks);
-      ObDereferenceObject(WinStaObj);
-    }
-}
-
-LRESULT
-STDCALL
-NtUserCallNextHookEx(
-  HHOOK Hook,
-  int Code,
-  WPARAM wParam,
-  LPARAM lParam)
-{
-  PHOOK HookObj, NextObj;
-  PWINSTATION_OBJECT WinStaObj;
-  NTSTATUS Status;
-
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				          KernelMode,
-				          0,
-				          &WinStaObj);
-  
-  if(! NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      return FALSE;
-    }
-
-  Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook,
-                                      otHookProc, (PVOID *) &HookObj);
-  ObDereferenceObject(WinStaObj);
-  if (! NT_SUCCESS(Status))
-    {
-      DPRINT1("Invalid handle passed to NtUserCallNextHookEx\n");
-      SetLastNtError(Status);
-      return 0;
-    }
-  ASSERT(Hook == HookObj->Self);
-
-  if (NULL != HookObj->Thread && (HookObj->Thread != PsGetCurrentThread()))
-    {
-      DPRINT1("Thread mismatch\n");
-      ObmDereferenceObject(HookObj);
-      SetLastWin32Error(ERROR_INVALID_HANDLE);
-      return 0;
-    }
-
-  NextObj = IntGetNextHook(HookObj);
-  ObmDereferenceObject(HookObj);
-  if (NULL != NextObj)
-    {
-      DPRINT1("Calling next hook not implemented\n");
-      UNIMPLEMENTED
-      SetLastWin32Error(ERROR_NOT_SUPPORTED);
-      return 0;
-    }
-
-  return 0;
-}
-
-DWORD
-STDCALL
-NtUserSetWindowsHookAW(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-HHOOK
-STDCALL
-NtUserSetWindowsHookEx(
-  HINSTANCE Mod,
-  PUNICODE_STRING UnsafeModuleName,
-  DWORD ThreadId,
-  int HookId,
-  HOOKPROC HookProc,
-  BOOL Ansi)
-{
-  PWINSTATION_OBJECT WinStaObj;
-  BOOLEAN Global, ReleaseThread;
-  PETHREAD Thread;
-  PHOOK Hook;
-  UNICODE_STRING ModuleName;
-  NTSTATUS Status;
-  HHOOK Handle;
-
-  if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId || NULL == HookProc)
-    {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return NULL;
-    }
-
-  if (ThreadId)  /* thread-local hook */
-    {
-      if (HookId == WH_JOURNALRECORD ||
-          HookId == WH_JOURNALPLAYBACK ||
-          HookId == WH_KEYBOARD_LL ||
-          HookId == WH_MOUSE_LL ||
-          HookId == WH_SYSMSGFILTER)
-        {
-          /* these can only be global */
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return NULL;
-        }
-      Mod = NULL;
-      Global = FALSE;
-      if (! NT_SUCCESS(PsLookupThreadByThreadId((PVOID) ThreadId, &Thread)))
-        {
-          DPRINT1("Invalid thread id 0x%x\n", ThreadId);
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return NULL;
-        }
-      if (Thread->ThreadsProcess != PsGetCurrentProcess())
-        {
-          ObDereferenceObject(Thread);
-          DPRINT1("Can't specify thread belonging to another process\n");
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return NULL;
-        }
-      ReleaseThread = TRUE;
-    }
-  else  /* system-global hook */
-    {
-      ReleaseThread = FALSE;
-      if (HookId == WH_KEYBOARD_LL || HookId == WH_MOUSE_LL)
-        {
-          Mod = NULL;
-          Thread = PsGetCurrentThread();
-        }
-      else if (NULL ==  Mod)
-        {
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return NULL;
-        }
-      else
-        {
-          Thread = NULL;
-        }
-      Global = TRUE;
-    }
-
-  /* We only (partially) support local WH_CBT hooks for now */
-  if (WH_CBT != HookId || Global)
-    {
-#if 0 /* Removed to get winEmbed working again */
-      UNIMPLEMENTED
-#else
-      DPRINT1("Not implemented: HookId %d Global %s\n", HookId, Global ? "TRUE" : "FALSE");
-#endif
-      if(ReleaseThread)
-        ObDereferenceObject(Thread);
-      SetLastWin32Error(ERROR_NOT_SUPPORTED);
-      return NULL;
-    }
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				          KernelMode,
-				          0,
-				          &WinStaObj);
-  
-  if(! NT_SUCCESS(Status))
-    {
-      if(ReleaseThread && Thread)
-        ObDereferenceObject(Thread);
-      SetLastNtError(Status);
-      return (HANDLE) NULL;
-    }
-
-  Hook = IntAddHook(Thread, HookId, Global, WinStaObj);
-  if (NULL == Hook)
-    {
-      if(ReleaseThread)
-        ObDereferenceObject(Thread);
-      ObDereferenceObject(WinStaObj);
-      return NULL;
-    }
-  
-  if(ReleaseThread)
-    Hook->Flags |= HOOK_THREAD_REFERENCED;
-  
-  if (NULL != Mod)
-    {
-      Status = MmCopyFromCaller(&ModuleName, UnsafeModuleName, sizeof(UNICODE_STRING));
-      if (! NT_SUCCESS(Status))
-        {
-          ObmDereferenceObject(Hook);
-          IntRemoveHook(Hook, WinStaObj);
-          if(ReleaseThread)
-            ObDereferenceObject(Thread);
-          ObDereferenceObject(WinStaObj);
-          SetLastNtError(Status);
-          return NULL;
-        }
-      Hook->ModuleName.Buffer = ExAllocatePoolWithTag(PagedPool,
-                                                      ModuleName.MaximumLength,
-                                                      TAG_HOOK);
-      if (NULL == Hook->ModuleName.Buffer)
-        {
-          ObmDereferenceObject(Hook);
-          IntRemoveHook(Hook, WinStaObj);
-          if(ReleaseThread)
-            ObDereferenceObject(Thread);
-          ObDereferenceObject(WinStaObj);
-          SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-          return NULL;
-        }
-      Hook->ModuleName.MaximumLength = ModuleName.MaximumLength;
-      Status = MmCopyFromCaller(Hook->ModuleName.Buffer,
-                               ModuleName.Buffer,
-                               ModuleName.MaximumLength);
-      if (! NT_SUCCESS(Status))
-        {
-          ObmDereferenceObject(Hook);
-          IntRemoveHook(Hook, WinStaObj);
-          if(ReleaseThread)
-            ObDereferenceObject(Thread);
-          ObDereferenceObject(WinStaObj);
-          SetLastNtError(Status);
-          return NULL;
-        }
-      Hook->ModuleName.Length = ModuleName.Length;
-    }
-
-  Hook->Proc = HookProc;
-  Hook->Ansi = Ansi;
-  Handle = Hook->Self;
-
-  ObmDereferenceObject(Hook);
-  ObDereferenceObject(WinStaObj);
-
-  return Handle;
-}
-
-DWORD
-STDCALL
-NtUserSetWinEventHook(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-BOOL
-STDCALL
-NtUserUnhookWindowsHookEx(
-  HHOOK Hook)
-{
-  PWINSTATION_OBJECT WinStaObj;
-  PHOOK HookObj;
-  NTSTATUS Status;
-
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				          KernelMode,
-				          0,
-				          &WinStaObj);
-  
-  if(! NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      return FALSE;
-    }
-
-  Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook,
-                                      otHookProc, (PVOID *) &HookObj);
-  if (! NT_SUCCESS(Status))
-    {
-      DPRINT1("Invalid handle passed to NtUserUnhookWindowsHookEx\n");
-      ObDereferenceObject(WinStaObj);
-      SetLastNtError(Status);
-      return FALSE;
-    }
-  ASSERT(Hook == HookObj->Self);
-
-  IntRemoveHook(HookObj, WinStaObj);
-
-  ObmDereferenceObject(HookObj);
-  ObDereferenceObject(WinStaObj);
-
-  return TRUE;
-}
-
-DWORD
-STDCALL
-NtUserUnhookWinEvent(
-  DWORD Unknown0)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-/* EOF */

reactos/subsys/win32k/ntuser
hotkey.c 1.10 -> 1.10.12.1
diff -u -r1.10 -r1.10.12.1
--- hotkey.c	25 May 2004 15:52:44 -0000	1.10
+++ hotkey.c	15 Jul 2004 20:07:17 -0000	1.10.12.1
@@ -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: hotkey.c,v 1.10 2004/05/25 15:52:44 navaraf Exp $
+/* $Id: hotkey.c,v 1.10.12.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -26,299 +26,9 @@
  * REVISION HISTORY:
  *       02-11-2003  EK  Created
  */
-
-/* INCLUDES ******************************************************************/
-
 #include <w32k.h>
 
 #define NDEBUG
 #include <debug.h>
 
 
-/* GLOBALS *******************************************************************/
-
-/* FUNCTIONS *****************************************************************/
-
-NTSTATUS FASTCALL
-InitHotKeys(PWINSTATION_OBJECT WinStaObject)
-{
-  InitializeListHead(&WinStaObject->HotKeyListHead);
-  ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
-
-  return STATUS_SUCCESS;
-}
-
-
-NTSTATUS FASTCALL
-CleanupHotKeys(PWINSTATION_OBJECT WinStaObject)
-{
-
-  return STATUS_SUCCESS;
-}
-
-
-BOOL
-GetHotKey (PWINSTATION_OBJECT WinStaObject,
-       UINT fsModifiers,
-	   UINT vk,
-	   struct _ETHREAD **Thread,
-	   HWND *hWnd,
-	   int *id)
-{
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  
-  if(!WinStaObject)
-  {
-    return FALSE;
-  }
-
-  IntLockHotKeys(WinStaObject);
-
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
-      HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD(Entry,
-						     HOT_KEY_ITEM,
-						     ListEntry);
-      if (HotKeyItem->fsModifiers == fsModifiers &&
-	  HotKeyItem->vk == vk)
-	{
-	  if (Thread != NULL)
-	    *Thread = HotKeyItem->Thread;
-
-	  if (hWnd != NULL)
-	    *hWnd = HotKeyItem->hWnd;
-
-	  if (id != NULL)
-	    *id = HotKeyItem->id;
-
-	  IntUnLockHotKeys(WinStaObject);
-
-	  return TRUE;
-	}
-
-      Entry = Entry->Flink;
-    }
-
-  IntUnLockHotKeys(WinStaObject);
-
-  return FALSE;
-}
-
-
-VOID
-UnregisterWindowHotKeys(PWINDOW_OBJECT Window)
-{
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINSTATION_OBJECT WinStaObject = NULL;
-  
-  if(Window->OwnerThread && Window->OwnerThread->ThreadsProcess &&
-     Window->OwnerThread->ThreadsProcess->Win32Process)
-    WinStaObject = Window->OwnerThread->ThreadsProcess->Win32Process->WindowStation;
-
-  if(!WinStaObject)
-    return;
-
-  IntLockHotKeys(WinStaObject);
-
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
-      HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-						      HOT_KEY_ITEM,
-						      ListEntry);
-      Entry = Entry->Flink;
-      if (HotKeyItem->hWnd == Window->Self)
-	{
-	  RemoveEntryList (&HotKeyItem->ListEntry);
-	  ExFreePool (HotKeyItem);
-	}
-    }
-
-  IntUnLockHotKeys(WinStaObject);
-}
-
-
-VOID
-UnregisterThreadHotKeys(struct _ETHREAD *Thread)
-{
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINSTATION_OBJECT WinStaObject = NULL;
-  
-  if(Thread->ThreadsProcess && Thread->ThreadsProcess->Win32Process)
-    WinStaObject = Thread->ThreadsProcess->Win32Process->WindowStation;
-  
-  if(!WinStaObject)
-    return;
-  
-  IntLockHotKeys(WinStaObject);
-
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
-      HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-						      HOT_KEY_ITEM,
-						      ListEntry);
-      Entry = Entry->Flink;
-      if (HotKeyItem->Thread == Thread)
-	{
-	  RemoveEntryList (&HotKeyItem->ListEntry);
-	  ExFreePool (HotKeyItem);
-	}
-    }
-
-  IntUnLockHotKeys(WinStaObject);
-}
-
-
-static BOOL
-IsHotKey (PWINSTATION_OBJECT WinStaObject,
-      UINT fsModifiers,
-	  UINT vk)
-{
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
-      HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-						      HOT_KEY_ITEM,
-						      ListEntry);
-      if (HotKeyItem->fsModifiers == fsModifiers &&
-	  HotKeyItem->vk == vk)
-	{
-	  return TRUE;
-	}
-
-      Entry = Entry->Flink;
-    }
-
-  return FALSE;
-}
-
-
-BOOL STDCALL
-NtUserRegisterHotKey(HWND hWnd,
-		     int id,
-		     UINT fsModifiers,
-		     UINT vk)
-{
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINDOW_OBJECT Window;
-  PWINSTATION_OBJECT WinStaObject = NULL;
-  PETHREAD HotKeyThread;
-  
-  if (hWnd == NULL)
-  {
-    HotKeyThread = PsGetCurrentThread();
-  }
-  else
-  {
-    Window = IntGetWindowObject(hWnd);
-    if(!Window)
-    {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return FALSE;
-    }
-    HotKeyThread = Window->OwnerThread;
-    IntReleaseWindowObject(Window);
-  }
-
-  
-  if(HotKeyThread->ThreadsProcess && HotKeyThread->ThreadsProcess->Win32Process)
-    WinStaObject = HotKeyThread->ThreadsProcess->Win32Process->WindowStation;
-  
-  if(!WinStaObject)
-  {
-    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;
-    }
-
-  HotKeyItem->Thread = HotKeyThread;
-  HotKeyItem->hWnd = hWnd;
-  HotKeyItem->id = id;
-  HotKeyItem->fsModifiers = fsModifiers;
-  HotKeyItem->vk = vk;
-
-  InsertHeadList (&WinStaObject->HotKeyListHead,
-		  &HotKeyItem->ListEntry);
-
-  IntUnLockHotKeys(WinStaObject);
-  
-  return TRUE;
-}
-
-
-BOOL STDCALL
-NtUserUnregisterHotKey(HWND hWnd,
-		       int id)
-{
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINDOW_OBJECT Window;
-  PWINSTATION_OBJECT WinStaObject = NULL;
-  
-  Window = IntGetWindowObject(hWnd);
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-  
-  if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process)
-    WinStaObject = Window->OwnerThread->ThreadsProcess->Win32Process->WindowStation;
-  
-  if(!WinStaObject)
-  {
-    IntReleaseWindowObject(Window);
-    return FALSE;
-  }
-
-  IntLockHotKeys(WinStaObject);
-
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
-      HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-						      HOT_KEY_ITEM,
-						      ListEntry);
-      if (HotKeyItem->hWnd == hWnd &&
-	  HotKeyItem->id == id)
-	{
-	  RemoveEntryList (&HotKeyItem->ListEntry);
-	  ExFreePool (HotKeyItem);
-	  IntUnLockHotKeys(WinStaObject);
-	  
-	  IntReleaseWindowObject(Window);
-	  return TRUE;
-	}
-
-      Entry = Entry->Flink;
-    }
-
-  IntUnLockHotKeys(WinStaObject);
-  
-  IntReleaseWindowObject(Window);
-  return FALSE;
-}
-
-/* EOF */

reactos/subsys/win32k/ntuser
input.c 1.36 -> 1.36.4.1
diff -u -r1.36 -r1.36.4.1
--- input.c	4 Jul 2004 01:23:32 -0000	1.36
+++ input.c	15 Jul 2004 20:07:17 -0000	1.36.4.1
@@ -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: input.c,v 1.36 2004/07/04 01:23:32 navaraf Exp $
+/* $Id: input.c,v 1.36.4.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -135,9 +135,11 @@
   OBJECT_ATTRIBUTES KeyboardObjectAttributes;
   IO_STATUS_BLOCK Iosb;
   NTSTATUS Status;
+#if 0
   MSG msg;
   PUSER_MESSAGE_QUEUE FocusQueue;
   struct _ETHREAD *FocusThread;
+#endif
   
   RtlRosInitUnicodeStringFromLiteral(&KeyboardDeviceName, L"\\??\\Keyboard");
   InitializeObjectAttributes(&KeyboardObjectAttributes,
@@ -178,9 +180,11 @@
 	  KEY_EVENT_RECORD KeyEvent;
 	  LPARAM lParam = 0;
 	  UINT fsModifiers;
+#if 0
 	  struct _ETHREAD *Thread;
 	  HWND hWnd;
 	  int id;
+#endif
 
 	  Status = NtReadFile (KeyboardDeviceHandle,
 			       NULL,
@@ -233,7 +237,7 @@
 	      /* Context mode. 1 if ALT if pressed while the key is pressed */
 	      lParam |= (1 << 29);
 	    }
-	  
+#if 0
 	  if (GetHotKey(InputWindowStation,
 			fsModifiers,
 			KeyEvent.wVirtualKeyCode,
@@ -293,6 +297,7 @@
 	   * Post a keyboard message.
 	   */
 	  MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
+#endif
 	}
       DPRINT( "KeyboardInput Thread Stopped...\n" );
     }
@@ -445,80 +450,6 @@
   return(STATUS_SUCCESS);
 }
 
-BOOL
-STDCALL
-NtUserDragDetect(
-  HWND hWnd,
-  LONG x,
-  LONG y)
-{
-  UNIMPLEMENTED
-  return 0;
-}
-
-BOOL FASTCALL
-IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt)
-{
-  PW32THREAD OldBlock;
-  ASSERT(W32Thread);
-  
-  if(!W32Thread->Desktop || (W32Thread->IsExiting && BlockIt))
-  {
-    /*
-     * fail blocking if exiting the thread
-     */
-    
-    return FALSE;
-  }
-  
-  /*
-   * FIXME - check access rights of the window station
-   *         e.g. services running in the service window station cannot block input
-   */
-  if(!ThreadHasInputAccess(W32Thread) ||
-     !IntIsActiveDesktop(W32Thread->Desktop))
-  {
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  ASSERT(W32Thread->Desktop);
-  OldBlock = W32Thread->Desktop->BlockInputThread;
-  if(OldBlock)
-  {
-    if(OldBlock != W32Thread)
-    {
-      SetLastWin32Error(ERROR_ACCESS_DENIED);
-      return FALSE;
-    }
-    W32Thread->Desktop->BlockInputThread = (BlockIt ? W32Thread : NULL);
-    return OldBlock == NULL;
-  }
-  
-  W32Thread->Desktop->BlockInputThread = (BlockIt ? W32Thread : NULL);
-  return OldBlock == NULL;
-}
-
-BOOL
-STDCALL
-NtUserBlockInput(
-  BOOL BlockIt)
-{
-  return IntBlockInput(PsGetWin32Thread(), BlockIt);
-}
-
-BOOL FASTCALL
-IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap)
-{
-  PSYSTEM_CURSORINFO CurInfo;
-  BOOL res;
-  
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  res = CurInfo->SwapButtons;
-  CurInfo->SwapButtons = Swap;
-  return res;
-}
-
 BOOL FASTCALL
 IntMouseInput(MOUSEINPUT *mi)
 {
@@ -536,7 +467,6 @@
   PDC dc;
   RECTL PointerRect;
   PWINDOW_OBJECT DesktopWindow;
-  NTSTATUS Status;
   
 #if 1
   HDC hDC;
@@ -570,7 +500,7 @@
   
   SwapButtons = CurInfo->SwapButtons;
   DoMove = FALSE;
-
+  
   ExAcquireFastMutex(&CurInfo->CursorMutex);
   MousePos.x = CurInfo->x;
   MousePos.y = CurInfo->y;
@@ -587,17 +517,15 @@
       MousePos.y += mi->dy;
     }
     
-    Status = ObmReferenceObjectByHandle(WinSta->HandleTable,
-      WinSta->ActiveDesktop->DesktopWindow, otWindow, (PVOID*)&DesktopWindow);
-    if (NT_SUCCESS(Status))
+    DesktopWindow = WinSta->ActiveDesktop->DesktopWindow;
+    if (DesktopWindow != NULL)
     {
       if(MousePos.x >= DesktopWindow->ClientRect.right)
         MousePos.x = DesktopWindow->ClientRect.right - 1;
       if(MousePos.y >= DesktopWindow->ClientRect.bottom)
         MousePos.y = DesktopWindow->ClientRect.bottom - 1;
     }
-    ObmDereferenceObject(DesktopWindow);
-
+    
     if(MousePos.x < 0)
       MousePos.x = 0;
     if(MousePos.y < 0)
@@ -634,26 +562,25 @@
     {
       hBitmap = dc->w.hBitmap;
       DC_UnlockDc(hDC);
-
+      
       BitmapObj = BITMAPOBJ_LockBitmap(hBitmap);
       if (BitmapObj)
       {
         SurfObj = &BitmapObj->SurfObj;
-
+        
         if (GDIDEV(SurfObj)->MovePointer)
         {
           GDIDEV(SurfObj)->MovePointer(SurfObj, MousePos.x, MousePos.y, &PointerRect);
         }
-
         BITMAPOBJ_UnlockBitmap(hBitmap);
-
+        
         ExAcquireFastMutex(&CurInfo->CursorMutex);
         SetPointerRect(CurInfo, &PointerRect);
         ExReleaseFastMutex(&CurInfo->CursorMutex);
       }
     }
   }
-
+  
   /*
    * Insert the messages into the system queue
    */
@@ -760,9 +687,8 @@
   return FALSE;
 }
 
-UINT
-STDCALL
-NtUserSendInput(
+UINT FASTCALL
+IntSendInput(
   UINT nInputs,
   LPINPUT pInput,
   INT cbSize)
@@ -778,11 +704,9 @@
     return 0;
   }
   
-  if(!nInputs || !pInput || (cbSize != sizeof(INPUT)))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
+  ASSERT(nInputs);
+  ASSERT(pInput);
+  ASSERT(cbSize == sizeof(INPUT));
   
   /*
    * FIXME - check access rights of the window station
@@ -795,18 +719,9 @@
     return 0;
   }
   
-  cnt = 0;
-  while(nInputs--)
+  for(cnt = 0; nInputs--; pInput++)
   {
     INPUT SafeInput;
-    NTSTATUS Status;
-    
-    Status = MmCopyFromCaller(&SafeInput, pInput++, sizeof(INPUT));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      return cnt;
-    }
     
     switch(SafeInput.type)
     {
@@ -835,4 +750,11 @@
   return cnt;
 }
 
+BOOL FASTCALL
+IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt)
+{
+  UNIMPLEMENTED;
+  return FALSE;
+}
+
 /* EOF */

reactos/subsys/win32k/ntuser
keyboard.c 1.31 -> 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- keyboard.c	8 Jul 2004 12:55:01 -0000	1.31
+++ keyboard.c	15 Jul 2004 20:07:17 -0000	1.31.2.1
@@ -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: keyboard.c,v 1.31 2004/07/08 12:55:01 navaraf Exp $
+/* $Id: keyboard.c,v 1.31.2.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -89,13 +89,6 @@
     if (down) QueueKeyStateTable[vk] ^= KS_LOCK_BIT;
   } 
 
-  if (ext && vk == VK_LSHIFT)
-    vk = VK_RSHIFT;
-  if (ext && vk == VK_LCONTROL)
-    vk = VK_RCONTROL;
-  if (ext && vk == VK_LMENU)
-    vk = VK_RMENU;
-
   if (down)
     QueueKeyStateTable[vk] |= KS_DOWN_BIT;
   else
@@ -600,7 +593,8 @@
 #undef XX_STATUS
 }
 
-PKBDTABLES W32kGetDefaultKeyLayout() {
+PKBDTABLES FASTCALL
+W32kGetDefaultKeyLayout(VOID) {
   PKBDTABLES pkKeyboardLayout = 0;
   InitKbdLayout( (PVOID) &pkKeyboardLayout );
   return pkKeyboardLayout;

reactos/subsys/win32k/ntuser
menu.c 1.55 -> 1.55.12.1
diff -u -r1.55 -r1.55.12.1
--- menu.c	13 May 2004 20:21:27 -0000	1.55
+++ menu.c	15 Jul 2004 20:07:17 -0000	1.55.12.1
@@ -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: menu.c,v 1.55 2004/05/13 20:21:27 navaraf Exp $
+/* $Id: menu.c,v 1.55.12.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -26,1972 +26,9 @@
  * REVISION HISTORY:
  *       07/30/2003  CSH  Created
  */
-/* INCLUDES ******************************************************************/
-
 #include <w32k.h>
 
 #define NDEBUG
 #include <debug.h>
 
-/* INTERNAL ******************************************************************/
-
-/* maximum number of menu items a menu can contain */
-#define MAX_MENU_ITEMS (0x4000)
-#define MAX_GOINTOSUBMENU (0x10)
-
-#define UpdateMenuItemState(state, change) \
-{\
-  if((change) & MFS_DISABLED) { \
-    (state) |= MFS_DISABLED; \
-  } else { \
-    (state) &= ~MFS_DISABLED; \
-  } \
-  if((change) & MFS_CHECKED) { \
-    (state) |= MFS_CHECKED; \
-  } else { \
-    (state) &= ~MFS_CHECKED; \
-  } \
-  if((change) & MFS_HILITE) { \
-    (state) |= MFS_HILITE; \
-  } else { \
-    (state) &= ~MFS_HILITE; \
-  } \
-  if((change) & MFS_DEFAULT) { \
-    (state) |= MFS_DEFAULT; \
-  } else { \
-    (state) &= ~MFS_DEFAULT; \
-  } \
-  if((change) & MF_MOUSESELECT) { \
-    (state) |= MF_MOUSESELECT; \
-  } else { \
-    (state) &= ~MF_MOUSESELECT; \
-  } \
-}
-
-#define FreeMenuText(MenuItem) \
-{ \
-  if((MENU_ITEM_TYPE((MenuItem)->fType) == MF_STRING) && \
-           (MenuItem)->Text.Length) { \
-    RtlFreeUnicodeString(&(MenuItem)->Text); \
-  } \
-}
-
-#define InRect(r, x, y) \
-      ( ( ((r).right >=  x)) && \
-        ( ((r).left <= x)) && \
-        ( ((r).bottom >=  y)) && \
-        ( ((r).top <= y)) )
-
-NTSTATUS FASTCALL
-InitMenuImpl(VOID)
-{
-  return(STATUS_SUCCESS);
-}
-
-NTSTATUS FASTCALL
-CleanupMenuImpl(VOID)
-{
-  return(STATUS_SUCCESS);
-}
-
-#if 0
-void FASTCALL
-DumpMenuItemList(PMENU_ITEM MenuItem)
-{
-  UINT cnt = 0;
-  while(MenuItem)
-  {
-    if(MenuItem->Text.Length)
-      DbgPrint(" %d. %wZ\n", ++cnt, &MenuItem->Text);
-    else
-      DbgPrint(" %d. NO TEXT dwTypeData==%d\n", ++cnt, (DWORD)MenuItem->Text.Buffer);
-    DbgPrint("   fType=");
-    if(MFT_BITMAP & MenuItem->fType) DbgPrint("MFT_BITMAP ");
-    if(MFT_MENUBARBREAK & MenuItem->fType) DbgPrint("MFT_MENUBARBREAK ");
-    if(MFT_MENUBREAK & MenuItem->fType) DbgPrint("MFT_MENUBREAK ");
-    if(MFT_OWNERDRAW & MenuItem->fType) DbgPrint("MFT_OWNERDRAW ");
-    if(MFT_RADIOCHECK & MenuItem->fType) DbgPrint("MFT_RADIOCHECK ");
-    if(MFT_RIGHTJUSTIFY & MenuItem->fType) DbgPrint("MFT_RIGHTJUSTIFY ");
-    if(MFT_SEPARATOR & MenuItem->fType) DbgPrint("MFT_SEPARATOR ");
-    if(MFT_STRING & MenuItem->fType) DbgPrint("MFT_STRING ");
-    DbgPrint("\n   fState=");
-    if(MFS_DISABLED & MenuItem->fState) DbgPrint("MFS_DISABLED ");
-    else DbgPrint("MFS_ENABLED ");
-    if(MFS_CHECKED & MenuItem->fState) DbgPrint("MFS_CHECKED ");
-    else DbgPrint("MFS_UNCHECKED ");
-    if(MFS_HILITE & MenuItem->fState) DbgPrint("MFS_HILITE ");
-    else DbgPrint("MFS_UNHILITE ");
-    if(MFS_DEFAULT & MenuItem->fState) DbgPrint("MFS_DEFAULT ");
-    if(MFS_GRAYED & MenuItem->fState) DbgPrint("MFS_GRAYED ");
-    DbgPrint("\n   wId=%d\n", MenuItem->wID);
-    MenuItem = MenuItem->Next;
-  }
-  DbgPrint("Entries: %d\n", cnt);
-  return;
-}
-#endif
-
-PMENU_OBJECT FASTCALL
-IntGetMenuObject(HMENU hMenu)
-{
-  PMENU_OBJECT MenuObject;
-  PW32PROCESS W32Process = PsGetWin32Process();
-  
-  if(!W32Process)
-  {
-    return NULL;
-  }
-  
-  NTSTATUS Status = ObmReferenceObjectByHandle(W32Process->
-                      WindowStation->HandleTable, hMenu, otMenu, 
-                      (PVOID*)&MenuObject);
-  if (!NT_SUCCESS(Status))
-  {
-    return NULL;
-  }
-  return MenuObject;
-}
-
-BOOL FASTCALL
-IntFreeMenuItem(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem,
-    BOOL RemoveFromList, BOOL bRecurse)
-{
-  FreeMenuText(MenuItem);
-  if(RemoveFromList)
-  {
-    /* FIXME - Remove from List */
-    MenuObject->MenuInfo.MenuItemCount--;
-  }
-  if(bRecurse && MenuItem->hSubMenu)
-  {
-    PMENU_OBJECT SubMenuObject;
-    SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu );
-    if(SubMenuObject)
-    {
-      IntDestroyMenuObject(SubMenuObject, bRecurse, TRUE);
-      IntReleaseMenuObject(SubMenuObject);
-    }
-  }
-  
-  /* Free memory */
-  ExFreePool(MenuItem);
-  
-  return TRUE;
-}
-
-BOOL FASTCALL
-IntRemoveMenuItem(PMENU_OBJECT MenuObject, UINT uPosition, UINT uFlags, 
-                   BOOL bRecurse)
-{
-  PMENU_ITEM PrevMenuItem, MenuItem;
-  if(IntGetMenuItemByFlag(MenuObject, uPosition, uFlags, &MenuItem, 
-                           &PrevMenuItem) > -1)
-  {
-    if(MenuItem)
-    {
-      if(PrevMenuItem)
-        PrevMenuItem->Next = MenuItem->Next;
-      else
-      {
-        MenuObject->MenuItemList = MenuItem->Next;
-      }
-      return IntFreeMenuItem(MenuObject, MenuItem, TRUE, bRecurse);
-    }
-  }
-  return FALSE;
-}
-
-UINT FASTCALL
-IntDeleteMenuItems(PMENU_OBJECT MenuObject, BOOL bRecurse)
-{
-  UINT res = 0;
-  PMENU_ITEM NextItem;
-  PMENU_ITEM CurItem = MenuObject->MenuItemList;
-  while(CurItem)
-  {
-    NextItem = CurItem->Next;
-    IntFreeMenuItem(MenuObject, CurItem, FALSE, bRecurse);
-    CurItem = NextItem;
-    res++;
-  }
-  MenuObject->MenuInfo.MenuItemCount = 0;
-  MenuObject->MenuItemList = NULL;
-  return res;
-}
-
-BOOL FASTCALL
-IntDestroyMenuObject(PMENU_OBJECT MenuObject, 
-                     BOOL bRecurse, BOOL RemoveFromProcess)
-{
-  if(MenuObject)
-  {
-    /* remove all menu items */
-    IntLockMenuItems(MenuObject);
-    IntDeleteMenuItems(MenuObject, bRecurse); /* do not destroy submenus */
-    IntUnLockMenuItems(MenuObject);
-    
-    if(RemoveFromProcess)
-    {
-      IntLockProcessMenus(MenuObject->W32Process);
-      RemoveEntryList(&MenuObject->ListEntry);
-      IntUnLockProcessMenus(MenuObject->W32Process);
-    }
-    
-    ObmCloseHandle(MenuObject->W32Process->WindowStation->HandleTable, MenuObject->MenuInfo.Self);
-  
-    return TRUE;
-  }
-  return FALSE;
-}
-
-PMENU_OBJECT FASTCALL
-IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
-{
-  PMENU_OBJECT MenuObject;
-  PW32PROCESS Win32Process = PsGetWin32Process();
-
-  MenuObject = (PMENU_OBJECT)ObmCreateObject(
-      Win32Process->WindowStation->HandleTable, Handle, 
-      otMenu, sizeof(MENU_OBJECT));
-
-  if(!MenuObject)
-  {
-    *Handle = 0;
-    return NULL;
-  }
-  
-  MenuObject->W32Process = Win32Process;
-  MenuObject->RtoL = FALSE; /* default */
-  MenuObject->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
-  MenuObject->MenuInfo.fMask = 0; /* not used */
-  MenuObject->MenuInfo.dwStyle = 0; /* FIXME */
-  MenuObject->MenuInfo.cyMax = 0; /* default */
-  MenuObject->MenuInfo.hbrBack =
-     NtGdiCreateSolidBrush(RGB(192, 192, 192)); /* FIXME: default background color */
-  MenuObject->MenuInfo.dwContextHelpID = 0; /* default */  
-  MenuObject->MenuInfo.dwMenuData = 0; /* default */
-  MenuObject->MenuInfo.Self = *Handle;
-  MenuObject->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
-  MenuObject->MenuInfo.Flags = (IsMenuBar ? 0 : MF_POPUP);
-  MenuObject->MenuInfo.Wnd = NULL;
-  MenuObject->MenuInfo.WndOwner = NULL;
-  MenuObject->MenuInfo.Height = 0;
-  MenuObject->MenuInfo.Width = 0;
-  MenuObject->MenuInfo.TimeToHide = FALSE;
-  
-  MenuObject->MenuInfo.MenuItemCount = 0;
-  MenuObject->MenuItemList = NULL;
-  ExInitializeFastMutex(&MenuObject->MenuItemsLock);
-
-  /* Insert menu item into process menu handle list */
-  IntLockProcessMenus(Win32Process);
-  InsertTailList(&Win32Process->MenuListHead, &MenuObject->ListEntry);
-  IntUnLockProcessMenus(Win32Process);
-
-  return MenuObject;
-}
-
-BOOL FASTCALL
-IntCloneMenuItems(PMENU_OBJECT Destination, PMENU_OBJECT Source)
-{
-  PMENU_ITEM MenuItem, NewMenuItem = NULL;
-  PMENU_ITEM Old = NULL;
-
-  if(!Source->MenuInfo.MenuItemCount)
-    return FALSE;
-
-  IntLockMenuItems(Destination);
-  IntLockMenuItems(Source);
-
-  MenuItem = Source->MenuItemList;
-  while(MenuItem)
-  {
-    Old = NewMenuItem;
-    if(NewMenuItem)
-      NewMenuItem->Next = MenuItem;
-    NewMenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM);
-    if(!NewMenuItem)
-      break;
-    NewMenuItem->fType = MenuItem->fType;
-    NewMenuItem->fState = MenuItem->fState;
-    NewMenuItem->wID = MenuItem->wID;
-    NewMenuItem->hSubMenu = MenuItem->hSubMenu;
-    NewMenuItem->hbmpChecked = MenuItem->hbmpChecked;
-    NewMenuItem->hbmpUnchecked = MenuItem->hbmpUnchecked;
-    NewMenuItem->dwItemData = MenuItem->dwItemData;
-    if((MENU_ITEM_TYPE(NewMenuItem->fType) == MF_STRING))
-    {
-      if(MenuItem->Text.Length)
-      {
-        NewMenuItem->Text.Length = 0;
-        NewMenuItem->Text.MaximumLength = MenuItem->Text.MaximumLength;
-        NewMenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, MenuItem->Text.MaximumLength, TAG_STRING);
-        if(!NewMenuItem->Text.Buffer)
-        {
-          ExFreePool(NewMenuItem);
-          break;
-        }
-        RtlCopyUnicodeString(&NewMenuItem->Text, &MenuItem->Text);
-      }
-      else
-      {
-        NewMenuItem->Text.Buffer = MenuItem->Text.Buffer;
-      }
-    }
-    else
-    {
-      NewMenuItem->Text.Buffer = MenuItem->Text.Buffer;
-    }
-    NewMenuItem->hbmpItem = MenuItem->hbmpItem;
-
-    NewMenuItem->Next = NULL;
-    if(Old)
-      Old->Next = NewMenuItem;
-    else
-      Destination->MenuItemList = NewMenuItem;
-    Destination->MenuInfo.MenuItemCount++;
-    MenuItem = MenuItem->Next;
-  }
-
-  IntUnLockMenuItems(Source);
-  IntUnLockMenuItems(Destination);
-  return TRUE;
-}
-
-PMENU_OBJECT FASTCALL
-IntCloneMenu(PMENU_OBJECT Source)
-{
-  HANDLE Handle;
-  PMENU_OBJECT MenuObject;
-  PW32PROCESS Process = PsGetWin32Process();
-  
-  if(!Source)
-    return NULL;
-    
-  MenuObject = (PMENU_OBJECT)ObmCreateObject(
-    Process->WindowStation->HandleTable, &Handle, 
-    otMenu, sizeof(MENU_OBJECT));  
-  if(!MenuObject)
-    return NULL;
-  
-  MenuObject->W32Process = Process;
-  MenuObject->RtoL = Source->RtoL;
-  MenuObject->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
-  MenuObject->MenuInfo.fMask = Source->MenuInfo.fMask;
-  MenuObject->MenuInfo.dwStyle = Source->MenuInfo.dwStyle;
-  MenuObject->MenuInfo.cyMax = Source->MenuInfo.cyMax;
-  MenuObject->MenuInfo.hbrBack = Source->MenuInfo.hbrBack;
-  MenuObject->MenuInfo.dwContextHelpID = Source->MenuInfo.dwContextHelpID; 
-  MenuObject->MenuInfo.dwMenuData = Source->MenuInfo.dwMenuData;
-  MenuObject->MenuInfo.Self = Handle;
-  MenuObject->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
-  MenuObject->MenuInfo.Wnd = NULL;
-  MenuObject->MenuInfo.WndOwner = NULL;
-  MenuObject->MenuInfo.Height = 0;
-  MenuObject->MenuInfo.Width = 0;
-  MenuObject->MenuInfo.TimeToHide = FALSE;
-  
-  MenuObject->MenuInfo.MenuItemCount = 0;
-  MenuObject->MenuItemList = NULL;  
-  ExInitializeFastMutex(&MenuObject->MenuItemsLock);
-  
-  /* Insert menu item into process menu handle list */
-  IntLockProcessMenus(Process);
-  InsertTailList(&Process->MenuListHead, &MenuObject->ListEntry);
-  IntUnLockProcessMenus(Process);
-
-  IntCloneMenuItems(MenuObject, Source);
-
-  return MenuObject;
-}
-
-BOOL FASTCALL
-IntSetMenuFlagRtoL(PMENU_OBJECT MenuObject)
-{
-  MenuObject->RtoL = TRUE;
-  return TRUE;
-}
-
-BOOL FASTCALL
-IntSetMenuContextHelpId(PMENU_OBJECT MenuObject, DWORD dwContextHelpId)
-{
-  MenuObject->MenuInfo.dwContextHelpID = dwContextHelpId;
-  return TRUE;
-}
-
-BOOL FASTCALL
-IntGetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi)
-{
-  if(lpmi->fMask & MIM_BACKGROUND)
-    lpmi->hbrBack = MenuObject->MenuInfo.hbrBack;
-  if(lpmi->fMask & MIM_HELPID)
-    lpmi->dwContextHelpID = MenuObject->MenuInfo.dwContextHelpID;
-  if(lpmi->fMask & MIM_MAXHEIGHT)
-    lpmi->cyMax = MenuObject->MenuInfo.cyMax;
-  if(lpmi->fMask & MIM_MENUDATA)
-    lpmi->dwMenuData = MenuObject->MenuInfo.dwMenuData;
-  if(lpmi->fMask & MIM_STYLE)
-    lpmi->dwStyle = MenuObject->MenuInfo.dwStyle;
-  if (sizeof(MENUINFO) < lpmi->cbSize)
-    {
-      RtlCopyMemory((char *) lpmi + sizeof(MENUINFO),
-                    (char *) &MenuObject->MenuInfo + sizeof(MENUINFO),
-                    lpmi->cbSize - sizeof(MENUINFO));
-    }
-
-  return TRUE;
-}
-
-
-BOOL FASTCALL
-IntIsMenu(HMENU hMenu)
-{
-  PMENU_OBJECT Menu;
-  
-  if((Menu = IntGetMenuObject(hMenu)))
-  {
-    IntReleaseMenuObject(Menu);
-    return TRUE;
-  }
-  return FALSE;
-}
-
-
-BOOL FASTCALL
-IntSetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi)
-{
-  if(lpmi->fMask & MIM_BACKGROUND)
-    MenuObject->MenuInfo.hbrBack = lpmi->hbrBack;
-  if(lpmi->fMask & MIM_HELPID)
-    MenuObject->MenuInfo.dwContextHelpID = lpmi->dwContextHelpID;
-  if(lpmi->fMask & MIM_MAXHEIGHT)
-    MenuObject->MenuInfo.cyMax = lpmi->cyMax;
-  if(lpmi->fMask & MIM_MENUDATA)
-    MenuObject->MenuInfo.dwMenuData = lpmi->dwMenuData;
-  if(lpmi->fMask & MIM_STYLE)
-    MenuObject->MenuInfo.dwStyle = lpmi->dwStyle;
-  if(lpmi->fMask & MIM_APPLYTOSUBMENUS)
-    {
-    /* FIXME */
-    }
-  if (sizeof(MENUINFO) < lpmi->cbSize)
-    {
-      MenuObject->MenuInfo.FocusedItem = lpmi->FocusedItem;
-      MenuObject->MenuInfo.Height = lpmi->Height;
-      MenuObject->MenuInfo.Width = lpmi->Width;
-      MenuObject->MenuInfo.Wnd = lpmi->Wnd;
-      MenuObject->MenuInfo.WndOwner = lpmi->WndOwner;
-      MenuObject->MenuInfo.TimeToHide = lpmi->TimeToHide;
-    }
-
-  return TRUE;
-}
-
-
-int FASTCALL
-IntGetMenuItemByFlag(PMENU_OBJECT MenuObject, UINT uSearchBy, UINT fFlag, 
-                     PMENU_ITEM *MenuItem, PMENU_ITEM *PrevMenuItem)
-{
-  PMENU_ITEM PrevItem = NULL;
-  PMENU_ITEM CurItem = MenuObject->MenuItemList;
-  int p;
-  int ret;
-
-  if(MF_BYPOSITION & fFlag)
-  {
-    p = uSearchBy;
-    while(CurItem && (p > 0))
-    {
-      PrevItem = CurItem;
-      CurItem = CurItem->Next;
-      p--;
-    }
-    if(CurItem)
-    {
-      if(MenuItem) *MenuItem = CurItem;
-      if(PrevMenuItem) *PrevMenuItem = PrevItem;
-    }
-    else
-    {
-      if(MenuItem) *MenuItem = NULL;
-      if(PrevMenuItem) *PrevMenuItem = NULL; /* ? */
-      return -1;
-    }
-
-    return uSearchBy - p;
-  }
-  else
-  {
-    p = 0;
-    while(CurItem)
-    {
-      if(CurItem->wID == uSearchBy)
-      {
-        if(MenuItem) *MenuItem = CurItem;
-        if(PrevMenuItem) *PrevMenuItem = PrevItem;
-        return p;
-      }
-      else if (0 != (CurItem->fType & MF_POPUP))
-      {
-        MenuObject = IntGetMenuObject(CurItem->hSubMenu);
-        if (NULL != MenuObject)
-        {
-          ret = IntGetMenuItemByFlag(MenuObject, uSearchBy, fFlag,
-                                     MenuItem, PrevMenuItem);
-          if (-1 != ret)
-          {
-            IntReleaseMenuObject(MenuObject);
-            return ret;
-          }          
-        }
-        IntReleaseMenuObject(MenuObject);
-      }
-      PrevItem = CurItem;
-      CurItem = CurItem->Next;
-      p++;
-    }
-  }
-  return -1;
-}
-
-
-int FASTCALL
-IntInsertMenuItemToList(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, int pos)
-{
-  PMENU_ITEM CurItem;
-  PMENU_ITEM LastItem = NULL;
-  UINT npos = 0;
-
-  CurItem = MenuObject->MenuItemList;
-  if(pos <= -1)
-  {
-    while(CurItem)
-    {
-      LastItem = CurItem;
-      CurItem = CurItem->Next;
-      npos++;
-    }
-  }
-  else
-  {
-    while(CurItem && (pos > 0))
-    {
-      LastItem = CurItem;
-      CurItem = CurItem->Next;
-      pos--;
-      npos++;
-    }
-  }
-
-  if(CurItem)
-  {
-    if(LastItem)
-    {
-      /* insert the item before CurItem */
-      MenuItem->Next = LastItem->Next;
-      LastItem->Next = MenuItem;
-    }
-    else
-    {
-      /* insert at the beginning */
-      MenuObject->MenuItemList = MenuItem;
-      MenuItem->Next = CurItem;
-    }
-  }
-  else
-  {
-    if(LastItem)
-    {
-      /* append item */
-      LastItem->Next = MenuItem;
-      MenuItem->Next = NULL;
-    }
-    else
-    {
-      /* insert first item */
-      MenuObject->MenuItemList = MenuItem;
-      MenuItem->Next = NULL;
-    }
-  }
-  MenuObject->MenuInfo.MenuItemCount++;
-
-  return npos;
-}
-
-BOOL FASTCALL
-IntGetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
-{
-  UNICODE_STRING Text;
-  NTSTATUS Status;
-
-  lpmii->cch = MenuItem->Text.Length / sizeof(WCHAR);
-  
-  if(lpmii->fMask & MIIM_BITMAP)
-    {
-      lpmii->hbmpItem = MenuItem->hbmpItem;
-    }
-  if(lpmii->fMask & MIIM_CHECKMARKS)
-    {
-      lpmii->hbmpChecked = MenuItem->hbmpChecked;
-      lpmii->hbmpUnchecked = MenuItem->hbmpUnchecked;
-    }
-  if(lpmii->fMask & MIIM_DATA)
-    {
-      lpmii->dwItemData = MenuItem->dwItemData;
-    }
-  if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
-    {
-      lpmii->fType = MenuItem->fType;
-    }
-  if(lpmii->fMask & MIIM_ID)
-    {
-      lpmii->wID = MenuItem->wID;
-    }
-  if(lpmii->fMask & MIIM_STATE)
-    {
-      lpmii->fState = MenuItem->fState;
-    }
-  if(lpmii->fMask & MIIM_SUBMENU)
-    {
-      lpmii->hSubMenu = MenuItem->hSubMenu;
-    }
-  if (0 != (lpmii->fMask & MIIM_STRING) ||
-      0 != (lpmii->fMask & MIIM_TYPE))
-    {
-      Status = MmCopyFromCaller(&Text, lpmii->dwTypeData, sizeof(UNICODE_STRING));
-      if (! NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          return FALSE;
-        }
-      Text.Length = min(Text.MaximumLength, MenuItem->Text.Length);
-      if (0 != Text.Length)
-        {
-          Status = MmCopyToCaller(Text.Buffer, MenuItem->Text.Buffer, Text.Length);
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return FALSE;
-            }
-        }
-      Status = MmCopyToCaller(lpmii->dwTypeData, &Text, sizeof(UNICODE_STRING));
-      if (! NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          return FALSE;
-        }
-    }
-
-  if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
-    {
-      lpmii->Rect = MenuItem->Rect;
-      lpmii->XTab = MenuItem->XTab;
-    }
-  
-  return TRUE;
-}
-
-BOOL FASTCALL
-IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
-{
-  PUNICODE_STRING Source;
-  UINT copylen = 0;
-  PMENU_OBJECT SubMenuObject;
-  
-  if(!MenuItem || !MenuObject || !lpmii)
-  {
-    return FALSE;
-  }
-
-  MenuItem->fType = lpmii->fType;
-  
-  if(lpmii->fMask & MIIM_BITMAP)
-  {
-    MenuItem->hbmpItem = lpmii->hbmpItem;
-  }
-  if(lpmii->fMask & MIIM_CHECKMARKS)
-  {
-    MenuItem->hbmpChecked = lpmii->hbmpChecked;
-    MenuItem->hbmpUnchecked = lpmii->hbmpUnchecked;
-  }
-  if(lpmii->fMask & MIIM_DATA)
-  {
-    MenuItem->dwItemData = lpmii->dwItemData;
-  }
-  if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
-  {
-    MenuItem->fType = lpmii->fType;
-  }
-  if(lpmii->fMask & MIIM_ID)
-  {
-    MenuItem->wID = lpmii->wID;
-  }
-  if(lpmii->fMask & MIIM_STATE)
-  {
-    /* remove MFS_DEFAULT flag from all other menu items if this item
-       has the MFS_DEFAULT state */
-    if(lpmii->fState & MFS_DEFAULT)
-      IntSetMenuDefaultItem(MenuObject, -1, 0);
-    /* update the menu item state flags */
-    UpdateMenuItemState(MenuItem->fState, lpmii->fState);
-  }
-  
-  if(lpmii->fMask & MIIM_SUBMENU)
-  {
-    MenuItem->hSubMenu = lpmii->hSubMenu;
-    /* Make sure the submenu is marked as a popup menu */
-    if (0 != (MenuItem->fType & MF_POPUP))
-    {
-      SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu);
-      if (NULL != SubMenuObject)
-      {
-        SubMenuObject->MenuInfo.Flags |= MF_POPUP;
-        IntReleaseMenuObject(SubMenuObject);
-      }
-    }
-  }
-  if((lpmii->fMask & (MIIM_TYPE | MIIM_STRING)) && 
-           (MENU_ITEM_TYPE(lpmii->fType) == MF_STRING))
-  {
-    if(lpmii->dwTypeData && lpmii->cch)
-    {
-      Source = (PUNICODE_STRING)lpmii->dwTypeData;
-      FreeMenuText(MenuItem);
-      copylen = min((UINT)Source->MaximumLength, (lpmii->cch + 1) * sizeof(WCHAR));
-      MenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, copylen, TAG_STRING);
-      if(MenuItem->Text.Buffer)
-      {
-        MenuItem->Text.Length = 0;
-        MenuItem->Text.MaximumLength = copylen;
-        RtlCopyUnicodeString(&MenuItem->Text, Source);
-      }
-      else
-      {
-        MenuItem->Text.Length = 0;
-        MenuItem->Text.MaximumLength = 0;
-        MenuItem->Text.Buffer = NULL;
-      }
-    }
-    else
-    {
-      MenuItem->fType |= MF_SEPARATOR;
-      RtlInitUnicodeString(&MenuItem->Text, NULL);
-    }
-  }
-  else
-  {
-    RtlInitUnicodeString(&MenuItem->Text, NULL);
-  }
-
-  if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
-    {
-      MenuItem->Rect = lpmii->Rect;
-      MenuItem->XTab = lpmii->XTab;
-    }
-  
-  return TRUE;
-}
-
-BOOL FASTCALL
-IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
-                  PROSMENUITEMINFO ItemInfo)
-{
-  int pos = (int)uItem;
-  PMENU_ITEM MenuItem;
-  
-  if (MAX_MENU_ITEMS <= MenuObject->MenuInfo.MenuItemCount)
-    {
-      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-      return FALSE;
-    }
-  
-  if (fByPosition)
-    {
-      /* calculate position */
-      if(MenuObject->MenuInfo.MenuItemCount < pos)
-        {
-          pos = MenuObject->MenuInfo.MenuItemCount;
-        }
-    }
-  else
-    {
-      pos = IntGetMenuItemByFlag(MenuObject, uItem, MF_BYCOMMAND, NULL, NULL);
-    }
-  if (pos < -1)
-    {
-      pos = -1;
-    }
-  
-  MenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM);
-  if (NULL == MenuItem)
-    {
-      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-      return FALSE;
-    }
-  
-  MenuItem->fType = MFT_STRING;
-  MenuItem->fState = MFS_ENABLED | MFS_UNCHECKED;
-  MenuItem->wID = 0;
-  MenuItem->hSubMenu = (HMENU)0;
-  MenuItem->hbmpChecked = (HBITMAP)0;
-  MenuItem->hbmpUnchecked = (HBITMAP)0;
-  MenuItem->dwItemData = 0;
-  RtlInitUnicodeString(&MenuItem->Text, NULL);
-  MenuItem->hbmpItem = (HBITMAP)0;  
-
-  if (! IntSetMenuItemInfo(MenuObject, MenuItem, ItemInfo))
-    {
-      ExFreePool(MenuItem);
-      return FALSE;
-    }
-  
-  /* Force size recalculation! */
-  MenuObject->MenuInfo.Height = 0;
-
-  pos = IntInsertMenuItemToList(MenuObject, MenuItem, pos);
-
-  return pos >= 0;
-}
-
-UINT FASTCALL
-IntEnableMenuItem(PMENU_OBJECT MenuObject, UINT uIDEnableItem, UINT uEnable)
-{
-  PMENU_ITEM MenuItem;
-  UINT res = IntGetMenuItemByFlag(MenuObject, uIDEnableItem, uEnable, &MenuItem, NULL);
-  if(!MenuItem || (res == (UINT)-1))
-  {
-    return (UINT)-1;
-  }
-  
-  res = MenuItem->fState & (MF_GRAYED | MF_DISABLED);
-  
-  if(uEnable & MF_DISABLED)
-  {
-    if(!(MenuItem->fState & MF_DISABLED))
-        MenuItem->fState |= MF_DISABLED;
-    if(uEnable & MF_GRAYED)
-    {
-      if(!(MenuItem->fState & MF_GRAYED))
-          MenuItem->fState |= MF_GRAYED;
-    }
-  }
-  else
-  {
-    if(uEnable & MF_GRAYED)
-    {
-      if(!(MenuItem->fState & MF_GRAYED))
-          MenuItem->fState |= MF_GRAYED;
-      if(!(MenuItem->fState & MF_DISABLED))
-          MenuItem->fState |= MF_DISABLED;
-    }
-    else
-    {
-      if(MenuItem->fState & MF_DISABLED)
-          MenuItem->fState ^= MF_DISABLED;
-      if(MenuItem->fState & MF_GRAYED)
-          MenuItem->fState ^= MF_GRAYED;
-    }
-  }
-  
-  return res;
-}
-
-
-DWORD FASTCALL
-IntBuildMenuItemList(PMENU_OBJECT MenuObject, PVOID Buffer, ULONG nMax)
-{
-  DWORD res = 0;
-  UINT sz;
-  ROSMENUITEMINFO mii;
-  PVOID Buf;
-  PMENU_ITEM CurItem = MenuObject->MenuItemList;
-  PWCHAR StrOut;
-  NTSTATUS Status;
-  WCHAR NulByte;
-
-  if (0 != nMax)
-    {
-      if (nMax < MenuObject->MenuInfo.MenuItemCount * sizeof(ROSMENUITEMINFO))
-        {
-          return 0;
-        }
-      StrOut = (PWCHAR)((char *) Buffer + MenuObject->MenuInfo.MenuItemCount
-                                          * sizeof(ROSMENUITEMINFO));
-      nMax -= MenuObject->MenuInfo.MenuItemCount * sizeof(ROSMENUITEMINFO);
-      sz = sizeof(ROSMENUITEMINFO);
-      Buf = Buffer;
-      mii.cbSize = sizeof(ROSMENUITEMINFO);
-      mii.fMask = 0;
-      NulByte = L'\0';
-
-      while (NULL != CurItem)
-        {
-          mii.cch = CurItem->Text.Length / sizeof(WCHAR);
-          mii.dwItemData = CurItem->dwItemData;
-          if (0 != CurItem->Text.Length)
-            {
-              mii.dwTypeData = StrOut;
-            }
-          else
-            {
-              mii.dwTypeData = NULL;
-            }
-          mii.fState = CurItem->fState;
-          mii.fType = CurItem->fType;
-          mii.hbmpChecked = CurItem->hbmpChecked;
-          mii.hbmpItem = CurItem->hbmpItem;
-          mii.hbmpUnchecked = CurItem->hbmpUnchecked;
-          mii.hSubMenu = CurItem->hSubMenu;
-          mii.Rect = CurItem->Rect;
-          mii.XTab = CurItem->XTab;
-
-          Status = MmCopyToCaller(Buf, &mii, sizeof(ROSMENUITEMINFO));
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return 0;
-            }
-          Buf += sizeof(ROSMENUITEMINFO);
-      
-          if (0 != CurItem->Text.Length
-              && (nMax >= CurItem->Text.Length + sizeof(WCHAR)))
-            {
-              /* copy string */
-              Status = MmCopyToCaller(StrOut, CurItem->Text.Buffer,
-                                      CurItem->Text.Length);
-              if (! NT_SUCCESS(Status))
-                {
-                  SetLastNtError(Status);
-                  return 0;
-                }
-              StrOut += CurItem->Text.Length / sizeof(WCHAR);
-              Status = MmCopyToCaller(StrOut, &NulByte, sizeof(WCHAR));
-              if (! NT_SUCCESS(Status))
-                {
-                  SetLastNtError(Status);
-                  return 0;
-                }
-              StrOut++;
-              nMax -= CurItem->Text.Length + sizeof(WCHAR);
-            }
-          else if (0 != CurItem->Text.Length)
-            {
-              break;
-            }
-
-          CurItem = CurItem->Next;
-          res++;
-        }
-    }
-  else
-    {
-      while (NULL != CurItem)
-        {
-          res += sizeof(ROSMENUITEMINFO) + CurItem->Text.Length + sizeof(WCHAR);
-          CurItem = CurItem->Next;
-        }
-    }
-
-  return res;
-}
-
-
-DWORD FASTCALL
-IntCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck)
-{
-  PMENU_ITEM MenuItem;
-  int res = -1;
-
-  if((IntGetMenuItemByFlag(MenuObject, uIDCheckItem, uCheck, &MenuItem, NULL) < 0) || !MenuItem)
-  {
-    return -1;
-  }
-
-  res = (DWORD)(MenuItem->fState & MF_CHECKED);
-  if(uCheck & MF_CHECKED)
-  {
[truncated at 1000 lines; 985 more skipped]

reactos/subsys/win32k/ntuser
message.c 1.71 -> 1.71.4.1
diff -u -r1.71 -r1.71.4.1
--- message.c	3 Jul 2004 17:40:25 -0000	1.71
+++ message.c	15 Jul 2004 20:07:17 -0000	1.71.4.1
@@ -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.71 2004/07/03 17:40:25 navaraf Exp $
+/* $Id: message.c,v 1.71.4.1 2004/07/15 20:07:17 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -26,35 +26,13 @@
  * REVISION HISTORY:
  *       06-06-2001  CSH  Created
  */
-
-/* INCLUDES ******************************************************************/
-
 #include <w32k.h>
 
 #define NDEBUG
 #include <debug.h>
 
-typedef struct
-{
-  UINT uFlags;
-  UINT uTimeout;
-  ULONG_PTR Result;
-} DOSENDMESSAGE, *PDOSENDMESSAGE;
-
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS FASTCALL
-IntInitMessageImpl(VOID)
-{
-  return STATUS_SUCCESS;
-}
-
-NTSTATUS FASTCALL
-IntCleanupMessageImpl(VOID)
-{
-  return STATUS_SUCCESS;
-}
-
 #define MMS_SIZE_WPARAM      -1
 #define MMS_SIZE_WPARAMWCHAR -2
 #define MMS_SIZE_LPARAMSZ    -3
@@ -62,12 +40,6 @@
 #define MMS_FLAG_READ        0x01
 #define MMS_FLAG_WRITE       0x02
 #define MMS_FLAG_READWRITE   (MMS_FLAG_READ | MMS_FLAG_WRITE)
-typedef struct tagMSGMEMORY
-  {
-    UINT Message;
-    UINT Size;
-    INT Flags;
-  } MSGMEMORY, *PMSGMEMORY;
 
 static MSGMEMORY MsgMemory[] =
   {
@@ -85,7 +57,7 @@
     { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE },
   };
 
-static PMSGMEMORY FASTCALL
+PMSGMEMORY FASTCALL
 FindMsgMemory(UINT Msg)
   {
   PMSGMEMORY MsgMemoryEntry;
@@ -104,7 +76,7 @@
   return NULL;
 }
 
-static UINT FASTCALL
+UINT FASTCALL
 MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
 {
   CREATESTRUCTW *Cs;
@@ -281,123 +253,100 @@
 }
 
 
-LRESULT STDCALL
-NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
+BOOL FASTCALL
+IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, PWINDOW_OBJECT MsgWindow,
+                         LPMSG Msg, USHORT *HitTest, BOOL Remove)
 {
-  NTSTATUS Status;
-  NTUSERDISPATCHMESSAGEINFO MsgInfo;
-  PWINDOW_OBJECT WindowObject;
-  LRESULT Result = TRUE;
-
-  Status = MmCopyFromCaller(&MsgInfo, UnsafeMsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
-  if (! NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      return 0;
-    }
-
-  /* Process timer messages. */
-  if (WM_TIMER == MsgInfo.Msg.message && 0 != MsgInfo.Msg.lParam)
+  PWINDOW_OBJECT Window;
+  
+  if(MsgWindow == NULL)
+  {
+    /* let's just eat the message?! */
+    return TRUE;
+  }
+  
+  if(ThreadQueue == Window->MessageQueue &&
+     ThreadQueue->CaptureWindow != Window)
+  {
+    /* only send WM_NCHITTEST messages if we're not capturing the window! */
+    *HitTest = IntSendMessage(Window, WM_NCHITTEST, 0, 
+                              MAKELONG(Msg->pt.x, Msg->pt.y));
+    
+    /* FIXME - make sure the window still exists! */
+    
+    if(*HitTest == (USHORT)HTTRANSPARENT)
     {
-      LARGE_INTEGER LargeTickCount;
-      /* FIXME: Call hooks. */
-
-      /* FIXME: Check for continuing validity of timer. */
-
-      MsgInfo.HandledByKernel = FALSE;
-      KeQueryTickCount(&LargeTickCount);
-      MsgInfo.Proc = (WNDPROC) MsgInfo.Msg.lParam;
-      MsgInfo.Msg.lParam = (LPARAM)LargeTickCount.u.LowPart;
+      PWINDOW_OBJECT DesktopWindow;
+      
+      if((DesktopWindow = IntGetDesktopWindow()))
+      {
+        PWINDOW_OBJECT Wnd;
+        
+        WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd);
+        if(Wnd && (Wnd != Window))
+        {
+          /* post the message to the other window */
+          Msg->hwnd = Wnd->Handle;
+          MsqPostMessage(Wnd->MessageQueue, Msg, FALSE);
+          
+          /* eat the message */
+          return TRUE;
+        }
+      }
     }
-  else if (NULL == MsgInfo.Msg.hwnd)
+  }
+  else
+  {
+    *HitTest = HTCLIENT;
+  }
+  
+  if(IS_BTN_MESSAGE(Msg->message, DOWN))
+  {
+    /* generate double click messages, if necessary */
+    if ((((*HitTest) != HTCLIENT) || 
+        (IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS)) &&
+        MsqIsDblClk(Msg, Remove))
     {
-      MsgInfo.HandledByKernel = TRUE;
-      Result = 0;
+      Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN;
     }
-  else
+  }
+  
+  if(Msg->message != WM_MOUSEWHEEL)
+  {
+    
+    if ((*HitTest) != HTCLIENT)
     {
-      /* Get the window object. */
-      WindowObject = IntGetWindowObject(MsgInfo.Msg.hwnd);
-      if (NULL == WindowObject)
-        {
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          MsgInfo.HandledByKernel = TRUE;
-          Result = 0;
-        }
+      Msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
+      if((Msg->message == WM_NCRBUTTONUP) && 
+         (((*HitTest) == HTCAPTION) || ((*HitTest) == HTSYSMENU)))
+      {
+        Msg->message = WM_CONTEXTMENU;
+        Msg->wParam = (WPARAM)Window->Handle;
+      }
       else
-        {
-          if (WindowObject->OwnerThread != PsGetCurrentThread())
-            {
-              IntReleaseWindowObject(WindowObject);
-              DPRINT1("Window doesn't belong to the calling thread!\n");
-              MsgInfo.HandledByKernel = TRUE;
-              Result = 0;
-            }
-          else
-            {
-              /* FIXME: Call hook procedures. */
-
-              MsgInfo.HandledByKernel = FALSE;
-              Result = 0;
-              if (0xFFFF0000 != ((DWORD) WindowObject->WndProcW & 0xFFFF0000))
-                {
-                  if (0xFFFF0000 != ((DWORD) WindowObject->WndProcA & 0xFFFF0000))
-                    {
-                      /* Both Unicode and Ansi winprocs are real, use whatever
-                         usermode prefers */
-                      MsgInfo.Proc = (MsgInfo.Ansi ? WindowObject->WndProcA
-                                      : WindowObject->WndProcW);
-                    }
-                  else
-                    {
-                      /* Real Unicode winproc */
-                      MsgInfo.Ansi = FALSE;
-                      MsgInfo.Proc = WindowObject->WndProcW;
-                    }
-                }
-              else
-                {
-                  /* Must have real Ansi winproc */
-                  MsgInfo.Ansi = TRUE;
-                  MsgInfo.Proc = WindowObject->WndProcA;
-                }
-            }
-          IntReleaseWindowObject(WindowObject);
-        }
+      {
+        Msg->wParam = *HitTest;
+      }
+      Msg->lParam = MAKELONG(Msg->pt.x, Msg->pt.y);
     }
-  Status = MmCopyToCaller(UnsafeMsgInfo, &MsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
-  if (! NT_SUCCESS(Status))
+    else if(ThreadQueue->MoveSize == NULL &&
+            ThreadQueue->MenuOwner == NULL)
     {
-      SetLastNtError(Status);
-      return 0;
+      /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */
+      Msg->lParam = MAKELONG(
+        Msg->pt.x - (WORD)Window->ClientRect.left,
+        Msg->pt.y - (WORD)Window->ClientRect.top);
     }
-  
-  return Result;
-}
-
-
-BOOL STDCALL
-NtUserTranslateMessage(LPMSG lpMsg,
-		       HKL dwhkl)
-{
-  NTSTATUS Status;
-  MSG SafeMsg;
-
-  Status = MmCopyFromCaller(&SafeMsg, lpMsg, sizeof(MSG));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
   }
-
-  return IntTranslateKbdMessage(&SafeMsg, dwhkl);
+  
+  return FALSE;
 }
 
 
 VOID FASTCALL
-IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg)
+IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJECT Window)
 {
-  if(!Msg->hwnd || ThreadQueue->CaptureWindow)
+  if(!Window || ThreadQueue->CaptureWindow)
   {
     return;
   }
@@ -406,12 +355,12 @@
   {
     case WM_MOUSEMOVE:
     {
-      IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
+      IntSendMessage(Window, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
       break;
     }
     case WM_NCMOUSEMOVE:
     {
-      IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
+      IntSendMessage(Window, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
       break;
     }
     case WM_LBUTTONDOWN:
@@ -434,8 +383,8 @@
       wParam = (WPARAM)(CurInfo->ButtonsDown);
       ObDereferenceObject(InputWindowStation);
       
-      IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam);
-      IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
+      IntSendMessage(Window, WM_MOUSEMOVE, wParam, Msg->lParam);
+      IntSendMessage(Window, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
       break;
     }
     case WM_NCLBUTTONDOWN:
@@ -447,17 +396,19 @@
     case WM_NCRBUTTONDBLCLK:
     case WM_NCXBUTTONDBLCLK:
     {
-      IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam);
-      IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
+      IntSendMessage(Window, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam);
+      IntSendMessage(Window, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
       break;
     }
   }
 }
 
+
 BOOL FASTCALL
 IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJECT MsgWindow, 
                        USHORT *HitTest)
 {
+  PWINDOW_OBJECT Parent;
   ULONG Result;
   
   if(*HitTest == (USHORT)HTTRANSPARENT)
@@ -466,7 +417,10 @@
     return TRUE;
   }
   
-  Result = IntSendMessage(MsgWindow->Self, WM_MOUSEACTIVATE, (WPARAM)NtUserGetParent(MsgWindow->Self), (LPARAM)MAKELONG(*HitTest, Msg->message));
+  Parent = IntGetParent(MsgWindow);
+  
+  Result = IntSendMessage(MsgWindow, WM_MOUSEACTIVATE, (WPARAM)(Parent ? Parent->Handle : 0), (LPARAM)MAKELONG(*HitTest, Msg->message));
+  /* FIXME - make sure the window still exists */
   switch (Result)
   {
     case MA_NOACTIVATEANDEAT:
@@ -474,112 +428,68 @@
     case MA_NOACTIVATE:
       break;
     case MA_ACTIVATEANDEAT:
-      IntMouseActivateWindow(MsgWindow);
+      IntMouseActivateWindow(IntGetDesktopWindow(), MsgWindow);
       return TRUE;
     default:
       /* MA_ACTIVATE */
-      IntMouseActivateWindow(MsgWindow);
+      IntMouseActivateWindow(IntGetDesktopWindow(), MsgWindow);
       break;
   }
   
   return FALSE;
 }
 
-BOOL FASTCALL
-IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *HitTest, BOOL Remove)
+LRESULT FASTCALL
+IntDispatchMessage(PNTUSERDISPATCHMESSAGEINFO MsgInfo, PWINDOW_OBJECT Window)
 {
-  PWINDOW_OBJECT Window;
-  
-  if(!(Window = IntGetWindowObject(Msg->hwnd)))
-  {
-    /* let's just eat the message?! */
-    return TRUE;
-  }
-  
-  if(ThreadQueue == Window->MessageQueue &&
-     ThreadQueue->CaptureWindow != Window->Self)
+  if((MsgInfo->Msg.message == WM_TIMER || MsgInfo->Msg.message == WM_SYSTIMER) &&
+     MsgInfo->Msg.lParam != 0)
   {
-    /* only send WM_NCHITTEST messages if we're not capturing the window! */
-    *HitTest = IntSendMessage(Window->Self, WM_NCHITTEST, 0, 
-                              MAKELONG(Msg->pt.x, Msg->pt.y));
+    LARGE_INTEGER LargeTickCount;
     
-    if(*HitTest == (USHORT)HTTRANSPARENT)
-    {
-      PWINDOW_OBJECT DesktopWindow;
-      HWND hDesktop = IntGetDesktopWindow();
-      
-      if((DesktopWindow = IntGetWindowObject(hDesktop)))
-      {
-        PWINDOW_OBJECT Wnd;
-        
-        WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd);
-        if(Wnd)
-        {
-          if(Wnd != Window)
-          {
-            /* post the message to the other window */
-            Msg->hwnd = Wnd->Self;
-            MsqPostMessage(Wnd->MessageQueue, Msg, FALSE);
-            
-            /* eat the message */
-            IntReleaseWindowObject(Wnd);
-            IntReleaseWindowObject(Window);
-            IntReleaseWindowObject(DesktopWindow);
-            return TRUE;
-          }
-	  IntReleaseWindowObject(Wnd); 
-        }
-        
-        IntReleaseWindowObject(DesktopWindow);
-      }
-    }
-  }
-  else
-  {
-    *HitTest = HTCLIENT;
+    /* FIXME - call hooks? */
+    MsgInfo->HandledByKernel = FALSE;
+    KeQueryTickCount(&LargeTickCount);
+    MsgInfo->Proc = (WNDPROC) MsgInfo->Msg.lParam;
+    MsgInfo->Msg.lParam = (LPARAM)LargeTickCount.u.LowPart;
+    /* FIXME - We should propably handle WM_SYSTIMER messages in kmode first (for carets etc)
+               and then pass to umode */
+    return 0;
   }
   
-  if(IS_BTN_MESSAGE(Msg->message, DOWN))
+  if(Window == NULL)
   {
-    /* generate double click messages, if necessary */
-    if ((((*HitTest) != HTCLIENT) || 
-        (IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS)) &&
-        MsqIsDblClk(Msg, Remove))
-    {
-      Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN;
-    }
+    /* Nothing to do for messages to threads, no need to dispatch them */
+    MsgInfo->HandledByKernel = TRUE;
+    return 0;
   }
   
-  if(Msg->message != WM_MOUSEWHEEL)
+  /* FIXME - call hooks? */
+  
+  MsgInfo->HandledByKernel = FALSE;
+  if(((DWORD) Window->WndProcW & 0xFFFF0000) != 0xFFFF0000)
   {
-    
-    if ((*HitTest) != HTCLIENT)
+    if(((DWORD) Window->WndProcA & 0xFFFF0000) != 0xFFFF0000)
     {
-      Msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
-      if((Msg->message == WM_NCRBUTTONUP) && 
-         (((*HitTest) == HTCAPTION) || ((*HitTest) == HTSYSMENU)))
-      {
-        Msg->message = WM_CONTEXTMENU;
-        Msg->wParam = (WPARAM)Window->Self;
-      }
-      else
-      {
-        Msg->wParam = *HitTest;
-      }
-      Msg->lParam = MAKELONG(Msg->pt.x, Msg->pt.y);
+      /* Both Unicode and Ansi winprocs are real, use whatever
+         usermode prefers */
+      MsgInfo->Proc = (MsgInfo->Ansi ? Window->WndProcA : Window->WndProcW);
     }
-    else if(ThreadQueue->MoveSize == NULL &&
-            ThreadQueue->MenuOwner == NULL)
+    else
     {
-      /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */
-      Msg->lParam = MAKELONG(
-        Msg->pt.x - (WORD)Window->ClientRect.left,
-        Msg->pt.y - (WORD)Window->ClientRect.top);
+      /* Real Unicode winproc */
+      MsgInfo->Ansi = FALSE;
+      MsgInfo->Proc = Window->WndProcW;
     }
   }
+  else
+  {
+    /* Must have real Ansi winproc */
+    MsgInfo->Ansi = TRUE;
+    MsgInfo->Proc = Window->WndProcA;
+  }
   
-  IntReleaseWindowObject(Window);
-  return FALSE;
+  return 0;
 }
 
 
@@ -588,10 +498,10 @@
  */
 BOOL FASTCALL
 IntPeekMessage(PUSER_MESSAGE Msg,
-                HWND Wnd,
-                UINT MsgFilterMin,
-                UINT MsgFilterMax,
-                UINT RemoveMsg)
+               PWINDOW_OBJECT FilterWindow,
+               UINT MsgFilterMin,
+               UINT MsgFilterMax,
+               UINT RemoveMsg)
 {
   LARGE_INTEGER LargeTickCount;
   PUSER_MESSAGE_QUEUE ThreadQueue;
@@ -639,7 +549,7 @@
   Present = MsqFindMessage(ThreadQueue,
                            FALSE,
                            RemoveMessages,
-                           Wnd,
+                           FilterWindow,
                            MsgFilterMin,
                            MsgFilterMax,
                            &Message);
@@ -657,7 +567,7 @@
   Present = MsqFindMessage(ThreadQueue,
                            TRUE,
                            RemoveMessages,
-                           Wnd,
+                           FilterWindow,
                            MsgFilterMin,
                            MsgFilterMax,
                            &Message);
@@ -675,7 +585,7 @@
   while (MsqDispatchOneSentMessage(ThreadQueue));
 
   /* Check for paint messages. */
-  if (IntGetPaintMessage(Wnd, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages))
+  if (IntGetPaintMessage(FilterWindow, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages))
   {
     Msg->FreeLParam = FALSE;
     return TRUE;
@@ -685,33 +595,32 @@
   
   if(Present)
   {
+    PWINDOW_OBJECT MsgWindow;
+    
     MessageFound:
     
+    MsgWindow = NULL;
     if(RemoveMessages)
     {
-      PWINDOW_OBJECT MsgWindow = NULL;;
-      
-      if(Msg->Msg.hwnd && (MsgWindow = IntGetWindowObject(Msg->Msg.hwnd)) &&
+      if(Msg->Msg.hwnd && (MsgWindow = IntGetUserObject(WINDOW, Msg->Msg.hwnd)) &&
          Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST)
       {
         USHORT HitTest;
         
-        if(IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE))
+        if(IntTranslateMouseMessage(ThreadQueue, MsgWindow, &Msg->Msg, &HitTest, TRUE))
           /* FIXME - check message filter again, if the message doesn't match anymore,
                      search again */
         {
-          IntReleaseWindowObject(MsgWindow);
           /* eat the message, search again */
           goto CheckMessages;
         }
         if(ThreadQueue->CaptureWindow == NULL)
         {
-          IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
+          IntSendHitTestMessages(ThreadQueue, &Msg->Msg, MsgWindow);
           if((Msg->Msg.message != WM_MOUSEMOVE && Msg->Msg.message != WM_NCMOUSEMOVE) &&
              IS_BTN_MESSAGE(Msg->Msg.message, DOWN) &&
              IntActivateWindowMouse(ThreadQueue, &Msg->Msg, MsgWindow, &HitTest))
           {
-            IntReleaseWindowObject(MsgWindow);
             /* eat the message, search again */
             goto CheckMessages;
           }
@@ -719,20 +628,16 @@
       }
       else
       {
-        IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
-      }
-      
-      if(MsgWindow)
-      {
-        IntReleaseWindowObject(MsgWindow);
+        IntSendHitTestMessages(ThreadQueue, &Msg->Msg, MsgWindow);
       }
       
       return TRUE;
     }
     
     USHORT HitTest;
-    if((Msg->Msg.hwnd && Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST) &&
-       IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, FALSE))
+    if((Msg->Msg.hwnd && (MsgWindow = IntGetUserObject(WINDOW, Msg->Msg.hwnd)) &&
+        Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST) &&
+       IntTranslateMouseMessage(ThreadQueue, MsgWindow, &Msg->Msg, &HitTest, FALSE))
       /* FIXME - check message filter again, if the message doesn't match anymore,
                  search again */
     {
@@ -746,96 +651,9 @@
   return Present;
 }
 
-BOOL STDCALL
-NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
-                  HWND Wnd,
-                  UINT MsgFilterMin,
-                  UINT MsgFilterMax,
-                  UINT RemoveMsg)
-{
-  NTSTATUS Status;
-  BOOL Present;
-  NTUSERGETMESSAGEINFO Info;
-  PWINDOW_OBJECT Window;
-  PMSGMEMORY MsgMemoryEntry;
-  PVOID UserMem;
-  UINT Size;
-  USER_MESSAGE Msg;
-
-  /* Validate input */
-  if (NULL != Wnd)
-    {
-      Window = IntGetWindowObject(Wnd);
-      if (NULL == Window)
-        {
-          Wnd = NULL;
-        }
-      else
-        {
-          IntReleaseWindowObject(Window);
-        }
-    }
-
-  if (MsgFilterMax < MsgFilterMin)
-    {
-      MsgFilterMin = 0;
-      MsgFilterMax = 0;
-    }
-
-  Present = IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, RemoveMsg);
-  if (Present)
-    {
-      Info.Msg = Msg.Msg;
-      /* See if this message type is present in the table */
-      MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
-      if (NULL == MsgMemoryEntry)
-        {
-          /* Not present, no copying needed */
-          Info.LParamSize = 0;
-        }
-      else
-        {
-          /* Determine required size */
-          Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam,
-                               Info.Msg.lParam);
-          /* Allocate required amount of user-mode memory */
-          Info.LParamSize = Size;
-          UserMem = NULL;
-          Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem, 0,
-                                           &Info.LParamSize, MEM_COMMIT, PAGE_READWRITE);
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return (BOOL) -1;
-            }
-          /* Transfer lParam data to user-mode mem */
-          Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size);
-          if (! NT_SUCCESS(Status))
-            {
-              ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
-                                  &Info.LParamSize, MEM_DECOMMIT);
-              SetLastNtError(Status);
-              return (BOOL) -1;
-            }
-          Info.Msg.lParam = (LPARAM) UserMem;
-        }
-      if (Msg.FreeLParam && 0 != Msg.Msg.lParam)
-        {
-          ExFreePool((void *) Msg.Msg.lParam);
-        }
-      Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO));
-      if (! NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          return (BOOL) -1;
-        }
-    }
-
-  return Present;
-}
 
-static BOOL FASTCALL
-IntWaitMessage(HWND Wnd,
+BOOL FASTCALL
+IntWaitMessage(PWINDOW_OBJECT Window,
                 UINT MsgFilterMin,
                 UINT MsgFilterMax)
 {
@@ -847,7 +665,7 @@
 
   do
     {
-      if (IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_NOREMOVE))
+      if (IntPeekMessage(&Msg, Window, MsgFilterMin, MsgFilterMax, PM_NOREMOVE))
 	{
 	  return TRUE;
 	}
@@ -862,124 +680,34 @@
   return FALSE;
 }
 
-BOOL STDCALL
-NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
-		 HWND Wnd,
-		 UINT MsgFilterMin,
-		 UINT MsgFilterMax)
-/*
- * FUNCTION: Get a message from the calling thread's message queue.
- * ARGUMENTS:
- *      UnsafeMsg - Pointer to the structure which receives the returned message.
- *      Wnd - Window whose messages are to be retrieved.
- *      MsgFilterMin - Integer value of the lowest message value to be
- *                     retrieved.
- *      MsgFilterMax - Integer value of the highest message value to be
- *                     retrieved.
- */
-{
-  BOOL GotMessage;
-  NTUSERGETMESSAGEINFO Info;
-  NTSTATUS Status;
-  PWINDOW_OBJECT Window;
-  PMSGMEMORY MsgMemoryEntry;
-  PVOID UserMem;
-  UINT Size;
-  USER_MESSAGE Msg;
-
-  /* Validate input */
-  if (NULL != Wnd)
-    {
-      Window = IntGetWindowObject(Wnd);
-      if(!Window)
-        Wnd = NULL;
-      else
-        IntReleaseWindowObject(Window);
-    }
-  if (MsgFilterMax < MsgFilterMin)
-    {
-      MsgFilterMin = 0;
-      MsgFilterMax = 0;
-    }
 
+BOOL FASTCALL
+IntGetMessage(PUSER_MESSAGE Msg, PWINDOW_OBJECT FilterWindow,
+              UINT MsgFilterMin, UINT MsgFilterMax, BOOL *GotMessage)
+{
+  ASSERT(Msg);
+  
+  /* Fix the filter */
+  if(MsgFilterMax < MsgFilterMin)
+  {
+    MsgFilterMin = 0;
+    MsgFilterMax = 0;
+  }
+  
   do
+  {
+    *GotMessage = IntPeekMessage(Msg, FilterWindow, MsgFilterMin, MsgFilterMax, PM_REMOVE);
+    if(!(*GotMessage))
     {
-      GotMessage = IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_REMOVE);
-      if (GotMessage)
-	{
-          Info.Msg = Msg.Msg;
-          /* See if this message type is present in the table */
-          MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
-          if (NULL == MsgMemoryEntry)
-            {
-              /* Not present, no copying needed */
-              Info.LParamSize = 0;
-            }
-          else
-            {
-              /* Determine required size */
-              Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam,
-                                   Info.Msg.lParam);
-              /* Allocate required amount of user-mode memory */
-              Info.LParamSize = Size;
-              UserMem = NULL;
-              Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem, 0,
-                                               &Info.LParamSize, MEM_COMMIT, PAGE_READWRITE);
-
-              if (! NT_SUCCESS(Status))
-                {
-                  SetLastNtError(Status);
-                  return (BOOL) -1;
-                }
-              /* Transfer lParam data to user-mode mem */
-              Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size);
-              if (! NT_SUCCESS(Status))
-                {
-                  ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
-                                      &Info.LParamSize, MEM_DECOMMIT);
-                  SetLastNtError(Status);
-                  return (BOOL) -1;
-                }
-              Info.Msg.lParam = (LPARAM) UserMem;
-            }
-          if (Msg.FreeLParam && 0 != Msg.Msg.lParam)
-            {
-              ExFreePool((void *) Msg.Msg.lParam);
-            }
-	  Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO));
-	  if (! NT_SUCCESS(Status))
-	    {
-	      SetLastNtError(Status);
-	      return (BOOL) -1;
-	    }
-	}
-      else
-	{
-	  IntWaitMessage(Wnd, MsgFilterMin, MsgFilterMax);
-	}
+      IntWaitMessage(FilterWindow, MsgFilterMin, MsgFilterMax);
     }
-  while (! GotMessage);
-
-  return WM_QUIT != Info.Msg.message;
+  } while(!GotMessage);
+  
+  return WM_QUIT != Msg->Msg.message;
 }
 
-DWORD
-STDCALL
-NtUserMessageCall(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6)
-{
-  UNIMPLEMENTED
 
-  return 0;
-}
-
-static NTSTATUS FASTCALL
+NTSTATUS FASTCALL
 CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
 {
   NTSTATUS Status;
@@ -1035,7 +763,7 @@
   return STATUS_SUCCESS;
 }
 
-static NTSTATUS FASTCALL
+NTSTATUS FASTCALL
 CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
 {
   NTSTATUS Status;
@@ -1073,175 +801,50 @@
   return STATUS_SUCCESS;
 }
 
-BOOL STDCALL
-NtUserPostMessage(HWND Wnd,
-		  UINT Msg,
-		  WPARAM wParam,
-		  LPARAM lParam)
-{
-  PWINDOW_OBJECT Window;
-  MSG UserModeMsg, KernelModeMsg;
-  LARGE_INTEGER LargeTickCount;
-  NTSTATUS Status;
-  PMSGMEMORY MsgMemoryEntry;
-
-  if (WM_QUIT == Msg)
-    {
-      MsqPostQuitMessage(PsGetWin32Thread()->MessageQueue, wParam);
-    }
-  else if (Wnd == HWND_BROADCAST)
-    {
-      HWND *List;
-      PWINDOW_OBJECT DesktopWindow;
-      ULONG i;
-
-      DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-      List = IntWinListChildren(DesktopWindow);
-      IntReleaseWindowObject(DesktopWindow);
-      if (List != NULL)
-        {
-          for (i = 0; List[i]; i++)
-            NtUserPostMessage(List[i], Msg, wParam, lParam);
-          ExFreePool(List);
-        }      
-    }
-  else
-    {
-      PSYSTEM_CURSORINFO CurInfo;
-      Window = IntGetWindowObject(Wnd);
-      if (NULL == Window)
-        {
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          return FALSE;
-        }
-
-      UserModeMsg.hwnd = Wnd;
-      UserModeMsg.message = Msg;
-      UserModeMsg.wParam = wParam;
-      UserModeMsg.lParam = lParam;
-      MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
-      Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
-      if (! NT_SUCCESS(Status))
-        {
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return FALSE;
-        }
-      CurInfo = IntGetSysCursorInfo(PsGetWin32Process()->WindowStation);
-      KernelModeMsg.pt.x = CurInfo->x;
-      KernelModeMsg.pt.y = CurInfo->y;
-      KeQueryTickCount(&LargeTickCount);
-      KernelModeMsg.time = LargeTickCount.u.LowPart;
-      MsqPostMessage(Window->MessageQueue, &KernelModeMsg,
-                     NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam);
-      IntReleaseWindowObject(Window);
-    }
-
-  return TRUE;
-}
-
-BOOL STDCALL
-NtUserPostThreadMessage(DWORD idThread,
-			UINT Msg,
-			WPARAM wParam,
-			LPARAM lParam)
-{
-  MSG UserModeMsg, KernelModeMsg;
-  PETHREAD peThread;
-  PW32THREAD pThread;
-  NTSTATUS Status;
-  PMSGMEMORY MsgMemoryEntry;
-
-  Status = PsLookupThreadByThreadId((void *)idThread,&peThread);
-  
-  if( Status == STATUS_SUCCESS ) {
-    pThread = peThread->Win32Thread;
-    if( !pThread || !pThread->MessageQueue )
-      {
-	ObDereferenceObject( peThread );
-	return FALSE;
-      }
-
-    UserModeMsg.hwnd = NULL;
-    UserModeMsg.message = Msg;
-    UserModeMsg.wParam = wParam;
-    UserModeMsg.lParam = lParam;
-    MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
-    Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
-    if (! NT_SUCCESS(Status))
-      {
-        ObDereferenceObject( peThread );
-	SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        return FALSE;
-      }
-    MsqPostMessage(pThread->MessageQueue, &KernelModeMsg,
-                   NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam);
-    ObDereferenceObject( peThread );
-    return TRUE;
-  } else {
-    SetLastNtError( Status );
-    return FALSE;
-  }
-}
-
-DWORD STDCALL
-NtUserQuerySendMessage(DWORD Unknown0)
-{
-  UNIMPLEMENTED;
-
-  return 0;
-}
-
 LRESULT FASTCALL
-IntSendMessage(HWND hWnd,
+IntSendMessage(PWINDOW_OBJECT Window,
                UINT Msg,
                WPARAM wParam,
                LPARAM lParam)
 {
   ULONG_PTR Result = 0;
-  if(IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
+  if(IntSendMessageTimeout(Window, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
   {
     return (LRESULT)Result;
   }
   return 0;
 }
 
[truncated at 1000 lines; 418 more skipped]

reactos/subsys/win32k/ntuser
metric.c 1.21 -> 1.21.12.1
diff -u -r1.21 -r1.21.12.1
--- metric.c	14 May 2004 23:57:32 -0000	1.21
+++ metric.c	15 Jul 2004 20:07:18 -0000	1.21.12.1
@@ -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: metric.c,v 1.21 2004/05/14 23:57:32 weiden Exp $
+/* $Id: metric.c,v 1.21.12.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -26,28 +26,28 @@
  * REVISION HISTORY:
  *       06-06-2001  CSH  Created
  */
-
-/* INCLUDES ******************************************************************/
-
 #include <w32k.h>
 
 #define NDEBUG
 #include <debug.h>
 
-/* FUNCTIONS *****************************************************************/
 
-/* FIXME:  Alot of thse values should NOT be hardcoded but they are */
-ULONG STDCALL
-NtUserGetSystemMetrics(ULONG Index)
+INT FASTCALL
+IntGetSystemMetrics(INT nIndex)
 {
-  NTSTATUS Status;
+  PW32PROCESS W32Process = PsGetWin32Process();
   PWINSTATION_OBJECT WinStaObject;
-  PWINDOW_OBJECT DesktopWindow;
-  ULONG Width, Height, Result;
-
-  Result = 0;
-  switch (Index)
-    {
+  
+  WinStaObject = (W32Process != NULL ? W32Process->WindowStation : NULL);
+#ifdef DBG
+  if(WinStaObject == NULL)
+  {
+    DPRINT1("GetSystemMetrics: The Window Station for this process is inaccessible!\n");
+  }
+#endif
+  
+  switch (nIndex)
+  {
     case SM_ARRANGE:
       return(8);
     case SM_CLEANBOOT:
@@ -68,31 +68,25 @@
     case SM_SWAPBUTTON:
     {
       PSYSTEM_CURSORINFO CurInfo;
-      Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if (!NT_SUCCESS(Status))
-        return 0xFFFFFFFF;
+      if(WinStaObject == NULL)
+      {
+	return 0;
+      }
       
       CurInfo = IntGetSysCursorInfo(WinStaObject);
-      switch(Index)
+      ASSERT(CurInfo);
+      
+      switch(nIndex)
       {
         case SM_CXDOUBLECLK:
-          Result = CurInfo->DblClickWidth;
-          break;
+          return CurInfo->DblClickWidth;
         case SM_CYDOUBLECLK:
-          Result = CurInfo->DblClickWidth;
-          break;
+          return CurInfo->DblClickWidth;
         case SM_SWAPBUTTON:
-          Result = (UINT)CurInfo->SwapButtons;
-          break;
+          return (UINT)CurInfo->SwapButtons;
       }
-      
-      ObDereferenceObject(WinStaObject);
-      return Result;
+      return 0;
     }
-    
     case SM_CXDRAG:
     case SM_CYDRAG:
       return(2);
@@ -104,9 +98,9 @@
       return(4);
     case SM_CXFULLSCREEN:
       /* FIXME: shouldn't we take borders etc into account??? */
-      return NtUserGetSystemMetrics(SM_CXSCREEN);
+      return IntGetSystemMetrics(SM_CXSCREEN);
     case SM_CYFULLSCREEN:
-      return NtUserGetSystemMetrics(SM_CYSCREEN);
+      return IntGetSystemMetrics(SM_CYSCREEN);
     case SM_CXHSCROLL:
     case SM_CYHSCROLL:
       return(16);
@@ -120,18 +114,18 @@
     case SM_CYICONSPACING:
       return(64);
     case SM_CXMAXIMIZED:
-      return(NtUserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
-                                                          pixels greater than
-                                                          the screen width */
+      return(IntGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
+                                                       pixels greater than
+                                                       the screen width */
     case SM_CYMAXIMIZED:
-      return(NtUserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
-                                                           pixels less than 
-                                                           the screen height, 
-                                                           taskbar maybe? */
+      return(IntGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
+                                                        pixels less than 
+                                                        the screen height, 
+                                                        taskbar maybe? */
     case SM_CXMAXTRACK:
-      return(NtUserGetSystemMetrics(SM_CYSCREEN) + 12);
+      return(IntGetSystemMetrics(SM_CYSCREEN) + 12);
     case SM_CYMAXTRACK:
-      return(NtUserGetSystemMetrics(SM_CYSCREEN) + 12);
+      return(IntGetSystemMetrics(SM_CYSCREEN) + 12);
     case SM_CXMENUCHECK:
     case SM_CYMENUCHECK:
       return(13);
@@ -156,7 +150,12 @@
       return(27);
     case SM_CXSCREEN:
     case SM_CYSCREEN:
-      DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+    {
+      ULONG Width, Height;
+      PWINDOW_OBJECT DesktopWindow;
+      
+      /* FIXME - make sure we have the lock */
+      DesktopWindow = IntGetDesktopWindow();
       if (NULL != DesktopWindow)
 	  {
 	    Width = DesktopWindow->WindowRect.right;
@@ -167,8 +166,8 @@
 	    Width = 640;
 	    Height = 480;
 	  }
-      IntReleaseWindowObject(DesktopWindow);
-      return SM_CXSCREEN == Index ? Width : Height;
+      return (SM_CXSCREEN == nIndex ? Width : Height);
+    }
     case SM_CXSIZE:
     case SM_CYSIZE:
       return(18);
@@ -204,9 +203,8 @@
     case SM_SHOWSOUNDS:        
     case SM_SLOWMACHINE:       
       return(0);
-    default:
-      return(0xFFFFFFFF);
-    }
+  }
+  
+  return 0xFFFFFFFF;
 }
 
-/* EOF */

reactos/subsys/win32k/ntuser
misc.c 1.83 -> 1.83.2.1
diff -u -r1.83 -r1.83.2.1
--- misc.c	12 Jul 2004 20:09:35 -0000	1.83
+++ misc.c	15 Jul 2004 20:07:18 -0000	1.83.2.1
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.83 2004/07/12 20:09:35 gvg Exp $
+/* $Id: misc.c,v 1.83.2.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -31,7 +31,8 @@
   }
 }
 
-PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() {
+PUSER_MESSAGE_QUEUE FASTCALL
+W32kGetPrimitiveMessageQueue(VOID) {
   extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
   return pmPrimitiveMessageQueue;
 }
@@ -76,11 +77,11 @@
   }
 
   ObDereferenceObject(Process);
-
+  
   Request.Type = CSRSS_REGISTER_LOGON_PROCESS;
   Request.Data.RegisterLogonProcessRequest.ProcessId = ProcessId;
   Request.Data.RegisterLogonProcessRequest.Register = Register;
-
+  
   Status = CsrNotify(&Request, &Reply);
   if (! NT_SUCCESS(Status))
   {
@@ -91,513 +92,7 @@
   return TRUE;
 }
 
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
-NtUserCallNoParam(DWORD Routine)
-{
-  DWORD Result = 0;
-
-  switch(Routine)
-  {
-    case NOPARAM_ROUTINE_REGISTER_PRIMITIVE:
-      W32kRegisterPrimitiveMessageQueue();
-      Result = (DWORD)TRUE;
-      break;
-    
-    case NOPARAM_ROUTINE_DESTROY_CARET:
-      Result = (DWORD)IntDestroyCaret(PsGetCurrentThread()->Win32Thread);
-      break;
-    
-    case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP:
-      Result = (DWORD)IntInitMessagePumpHook();
-      break;
-
-    case NOPARAM_ROUTINE_UNINIT_MESSAGE_PUMP:
-      Result = (DWORD)IntUninitMessagePumpHook();
-      break;
-    
-    case NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO:
-      Result = (DWORD)MsqGetMessageExtraInfo();
-      break;
-    
-    case NOPARAM_ROUTINE_ANYPOPUP:
-      Result = (DWORD)IntAnyPopup();
-      break;
-
-    case NOPARAM_ROUTINE_CSRSS_INITIALIZED:
-      Result = (DWORD)CsrInit();
-      break;
-    
-    default:
-      DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine);
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      break;
-  }
-  return Result;
-}
-
-/*
- * @implemented
- */
-DWORD
-STDCALL
-NtUserCallOneParam(
-  DWORD Param,
-  DWORD Routine)
-{
-  switch(Routine)
-  {
-    case ONEPARAM_ROUTINE_GETMENU:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
-      
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        return FALSE;
-      }
-      
-      Result = (DWORD)WindowObject->IDMenu;
-      
-      IntReleaseWindowObject(WindowObject);
-      return Result;
-    }
-      
-    case ONEPARAM_ROUTINE_ISWINDOWUNICODE:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
-      
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        return FALSE;
-      }
-      Result = WindowObject->Unicode;
-      IntReleaseWindowObject(WindowObject);
-      return Result;
-    }
-      
-    case ONEPARAM_ROUTINE_WINDOWFROMDC:
-      return (DWORD)IntWindowFromDC((HDC)Param);
-      
-    case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
-      
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        return FALSE;
-      }
-      
-      Result = WindowObject->ContextHelpId;
-      
-      IntReleaseWindowObject(WindowObject);
-      return Result;
-    }
-    
-    case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON:
-    {
-      PWINSTATION_OBJECT WinStaObject;
-      NTSTATUS Status;
-      DWORD Result;
-      
-      Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if (!NT_SUCCESS(Status))
-        return (DWORD)FALSE;
-
-      Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param);
-
-      ObDereferenceObject(WinStaObject);
-      return Result;
-    }
-    
-    case ONEPARAM_ROUTINE_SWITCHCARETSHOWING:
-      return (DWORD)IntSwitchCaretShowing((PVOID)Param);
-    
-    case ONEPARAM_ROUTINE_SETCARETBLINKTIME:
-      return (DWORD)IntSetCaretBlinkTime((UINT)Param);
-
-    case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
-      return (DWORD)IntEnumClipboardFormats((UINT)Param);
-    
-    case ONEPARAM_ROUTINE_GETWINDOWINSTANCE:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
-      
-      if(!(WindowObject = IntGetWindowObject((HWND)Param)))
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        return FALSE;
-      }
-      
-      Result = (DWORD)WindowObject->Instance;
-      IntReleaseWindowObject(WindowObject);
-      return Result;
-    }
-    
-    case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO:
-      return (DWORD)MsqSetMessageExtraInfo((LPARAM)Param);
-    
-    case ONEPARAM_ROUTINE_GETCURSORPOSITION:
-    {
-      PSYSTEM_CURSORINFO CurInfo;
-      PWINSTATION_OBJECT WinStaObject;
-      NTSTATUS Status;
-      POINT Pos;
-      
-      if(!Param)
-        return (DWORD)FALSE;
-      Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if (!NT_SUCCESS(Status))
-        return (DWORD)FALSE;
-      
-      CurInfo = IntGetSysCursorInfo(WinStaObject);
-      /* FIXME - check if process has WINSTA_READATTRIBUTES */
-      Pos.x = CurInfo->x;
-      Pos.y = CurInfo->y;
-      
-      Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT));
-      if(!NT_SUCCESS(Status))
-      {
-        ObDereferenceObject(WinStaObject);
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      
-      ObDereferenceObject(WinStaObject);
-      
-      return (DWORD)TRUE;
-    }
-    
-    case ONEPARAM_ROUTINE_ISWINDOWINDESTROY:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
-      
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        return FALSE;
-      }
-      
-      Result = (DWORD)IntIsWindowInDestroy(WindowObject);
-      
-      IntReleaseWindowObject(WindowObject);
-      return Result;
-    }
-    
-    case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING:
-    {
-      BOOL Enable;
-      PW32PROCESS Process = PsGetWin32Process();
-      
-      if(Process != NULL)
-      {
-        Enable = (BOOL)(Param != 0);
-        
-        if(Enable)
-        {
-          Process->Flags &= ~W32PF_NOWINDOWGHOSTING;
-        }  
-        else
-        {
-          Process->Flags |= W32PF_NOWINDOWGHOSTING;
-        }
-        
-        return TRUE;
-      }
-      
-      return FALSE;
-    }
-  }
-  DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n", 
-          Routine, Param);
-  SetLastWin32Error(ERROR_INVALID_PARAMETER);
-  return 0;
-}
-
 
-/*
- * @implemented
- */
-DWORD
-STDCALL
-NtUserCallTwoParam(
-  DWORD Param1,
-  DWORD Param2,
-  DWORD Routine)
-{
-  NTSTATUS Status;
-  PWINDOW_OBJECT WindowObject;
-  
-  switch(Routine)
-  {
-    case TWOPARAM_ROUTINE_SETDCPENCOLOR:
-    {
-      return (DWORD)IntSetDCColor((HDC)Param1, OBJ_PEN, (COLORREF)Param2);
-    }
-    case TWOPARAM_ROUTINE_SETDCBRUSHCOLOR:
-    {
-      return (DWORD)IntSetDCColor((HDC)Param1, OBJ_BRUSH, (COLORREF)Param2);
-    }
-    case TWOPARAM_ROUTINE_GETDCCOLOR:
-    {
-      return (DWORD)IntGetDCColor((HDC)Param1, (ULONG)Param2);
-    }
-    case TWOPARAM_ROUTINE_GETWINDOWRGNBOX:
-    {
-      DWORD Ret;
-      RECT rcRect;
-      Ret = (DWORD)IntGetWindowRgnBox((HWND)Param1, &rcRect);
-      Status = MmCopyToCaller((PVOID)Param2, &rcRect, sizeof(RECT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return ERROR;
-      }
-      return Ret;
-    }
-    case TWOPARAM_ROUTINE_GETWINDOWRGN:
-    {
-      return (DWORD)IntGetWindowRgn((HWND)Param1, (HRGN)Param2);
-    }
-    case TWOPARAM_ROUTINE_SETMENUBARHEIGHT:
-    {
-      DWORD Ret;
-      PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
-      if(!MenuObject)
-        return 0;
-      
-      if(Param2 > 0)
-      {
-        Ret = (MenuObject->MenuInfo.Height == (int)Param2);
-        MenuObject->MenuInfo.Height = (int)Param2;
-      }
-      else
-        Ret = (DWORD)MenuObject->MenuInfo.Height;
-      IntReleaseMenuObject(MenuObject);
-      return Ret;
-    }
-    case TWOPARAM_ROUTINE_SETMENUITEMRECT:
-    {
-      BOOL Ret;
-      SETMENUITEMRECT smir;
-      PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
-      if(!MenuObject)
-        return 0;
-      
-      if(!NT_SUCCESS(MmCopyFromCaller(&smir, (PVOID)Param2, sizeof(SETMENUITEMRECT))))
-      {
-        IntReleaseMenuObject(MenuObject);
-        return 0;
-      }
-      
-      Ret = IntSetMenuItemRect(MenuObject, smir.uItem, smir.fByPosition, &smir.rcRect);
-      
-      IntReleaseMenuObject(MenuObject);
-      return (DWORD)Ret;
-    }
-    
-    case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
-    {
-      PUSER_MESSAGE_QUEUE MsgQueue = PsGetCurrentThread()->Win32Thread->MessageQueue;
-      
-      ASSERT(MsgQueue);
-      return (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2);
-    }
-    
-    case TWOPARAM_ROUTINE_ENABLEWINDOW:
-	  UNIMPLEMENTED
-      return 0;
-
-    case TWOPARAM_ROUTINE_UNKNOWN:
-	  UNIMPLEMENTED
-	  return 0;
-
-    case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS:
-	  UNIMPLEMENTED
-	  return 0;
-
-    case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW:
-	  UNIMPLEMENTED
-	  return 0;
-
-    case TWOPARAM_ROUTINE_VALIDATERGN:
-      return (DWORD)NtUserValidateRgn((HWND) Param1, (HRGN) Param2);
-      
-    case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID:
-      WindowObject = IntGetWindowObject((HWND)Param1);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_HANDLE);
-        return (DWORD)FALSE;
-      }
-      
-      WindowObject->ContextHelpId = Param2;
-      
-      IntReleaseWindowObject(WindowObject);
-      return (DWORD)TRUE;
-    
-    case TWOPARAM_ROUTINE_SETCARETPOS:
-      return (DWORD)IntSetCaretPos((int)Param1, (int)Param2);
-    
-    case TWOPARAM_ROUTINE_GETWINDOWINFO:
-    {
-      WINDOWINFO wi;
-      DWORD Ret;
-      
-      if(!(WindowObject = IntGetWindowObject((HWND)Param1)))
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        return FALSE;
-      }
-      
-#if 0
-      /*
-       * According to WINE, Windows' doesn't check the cbSize field
-       */
-      
-      Status = MmCopyFromCaller(&wi.cbSize, (PVOID)Param2, sizeof(wi.cbSize));
-      if(!NT_SUCCESS(Status))
-      {
-        IntReleaseWindowObject(WindowObject);
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      
-      if(wi.cbSize != sizeof(WINDOWINFO))
-      {
-        IntReleaseWindowObject(WindowObject);
-        SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        return FALSE;
-      }
-#endif
-      
-      if((Ret = (DWORD)IntGetWindowInfo(WindowObject, &wi)))
-      {
-        Status = MmCopyToCaller((PVOID)Param2, &wi, sizeof(WINDOWINFO));
-        if(!NT_SUCCESS(Status))
-        {
-          IntReleaseWindowObject(WindowObject);
-          SetLastNtError(Status);
-          return FALSE;
-        }
-      }
-      
-      IntReleaseWindowObject(WindowObject);
-      return Ret;
-    }
-    
-    case TWOPARAM_ROUTINE_REGISTERLOGONPROC:
-      return (DWORD)IntRegisterLogonProcess(Param1, (BOOL)Param2);
-    
-  }
-  DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
-          Routine, Param1, Param2);
-  SetLastWin32Error(ERROR_INVALID_PARAMETER);
-  return 0;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-NtUserCallHwndLock(
-  HWND hWnd,
-  DWORD Routine)
-{
-   BOOL Ret = 0;
-   PWINDOW_OBJECT Window;
-
-   Window = IntGetWindowObject(hWnd);
-   if (Window == 0)
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return FALSE;
-   }
-
-   /* FIXME: Routine can be 0x53 - 0x5E */
-   switch (Routine)
-   {
-      case HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS:
-         /* FIXME */
-         break;
-
-      case HWNDLOCK_ROUTINE_DRAWMENUBAR:
-         /* FIXME */
-         break;
-
-      case HWNDLOCK_ROUTINE_REDRAWFRAME:
-         /* FIXME */
-         break;
-
-      case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW:
-         Ret = IntSetForegroundWindow(Window);
-         break;
-
-      case HWNDLOCK_ROUTINE_UPDATEWINDOW:
-         /* FIXME */
-         break;
-   }
-
-   IntReleaseWindowObject(Window);
-
-   return Ret;
-}
-
-HWND
-STDCALL
-NtUserCallHwndOpt(
-  HWND Param,
-  DWORD Routine)
-{
-   switch (Routine)
-   {
-      case HWNDOPT_ROUTINE_SETPROGMANWINDOW:
-         /* FIXME */
-         break;
-
-      case HWNDOPT_ROUTINE_SETTASKMANWINDOW:
-         /* FIXME */
-         break;
-   }
-
-   return 0;
-}
-
-/*
- * @unimplemented
- */
-DWORD STDCALL
-NtUserGetThreadState(
-  DWORD Routine)
-{
-   switch (Routine)
-   {
-      case 0:
-         return (DWORD)IntGetThreadFocusWindow();
-   }
-   return 0;
-}
 
 VOID FASTCALL
 IntGetFontMetricSetting(LPWSTR lpValueName, PLOGFONTW font) 
@@ -629,7 +124,7 @@
    }
 }
 
-ULONG FASTCALL
+BOOL FASTCALL
 IntSystemParametersInfo(
   UINT uiAction,
   UINT uiParam,
@@ -637,7 +132,7 @@
   UINT fWinIni)
 {
   PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
+  PW32PROCESS W32Process = PsGetWin32Process();
 
   static BOOL bInitialized = FALSE;
   static LOGFONTW IconFont;
@@ -659,19 +154,20 @@
     IntGetFontMetricSetting(L"IconFont", &IconFont);
     
     pMetrics.iBorderWidth = 1;
-    pMetrics.iScrollWidth = NtUserGetSystemMetrics(SM_CXVSCROLL);
-    pMetrics.iScrollHeight = NtUserGetSystemMetrics(SM_CYHSCROLL);
-    pMetrics.iCaptionWidth = NtUserGetSystemMetrics(SM_CXSIZE);
-    pMetrics.iCaptionHeight = NtUserGetSystemMetrics(SM_CYSIZE);
-    pMetrics.iSmCaptionWidth = NtUserGetSystemMetrics(SM_CXSMSIZE);
-    pMetrics.iSmCaptionHeight = NtUserGetSystemMetrics(SM_CYSMSIZE);
-    pMetrics.iMenuWidth = NtUserGetSystemMetrics(SM_CXMENUSIZE);
-    pMetrics.iMenuHeight = NtUserGetSystemMetrics(SM_CYMENUSIZE);
+    pMetrics.iScrollWidth = IntGetSystemMetrics(SM_CXVSCROLL);
+    pMetrics.iScrollHeight = IntGetSystemMetrics(SM_CYHSCROLL);
+    pMetrics.iCaptionWidth = IntGetSystemMetrics(SM_CXSIZE);
+    pMetrics.iCaptionHeight = IntGetSystemMetrics(SM_CYSIZE);
+    pMetrics.iSmCaptionWidth = IntGetSystemMetrics(SM_CXSMSIZE);
+    pMetrics.iSmCaptionHeight = IntGetSystemMetrics(SM_CYSMSIZE);
+    pMetrics.iMenuWidth = IntGetSystemMetrics(SM_CXMENUSIZE);
+    pMetrics.iMenuHeight = IntGetSystemMetrics(SM_CYMENUSIZE);
     pMetrics.cbSize = sizeof(LPNONCLIENTMETRICSW);
     
     bInitialized = TRUE;
   }
   
+  WinStaObject = (W32Process != NULL ? W32Process->WindowStation : NULL);
   switch(uiAction)
   {
     case SPI_SETDOUBLECLKWIDTH:
@@ -680,15 +176,7 @@
     {
       PSYSTEM_CURSORINFO CurInfo;
       
-      Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return (DWORD)FALSE;
-      }
+      ASSERT(WinStaObject);
       
       CurInfo = IntGetSysCursorInfo(WinStaObject);
       switch(uiAction)
@@ -709,7 +197,6 @@
       
       /* FIXME save the value to the registry */
       
-      ObDereferenceObject(WinStaObject);
       return TRUE;
     }
     case SPI_SETWORKAREA:
@@ -752,18 +239,20 @@
     }
     case SPI_GETGRADIENTCAPTIONS:
     {
+#if 0
       HDC hDC;
       BOOL Ret = GradientCaptions;
       
       hDC = IntGetScreenDC();
       if(hDC)
       {
-        Ret = (NtGdiGetDeviceCaps(hDC, BITSPIXEL) > 8) && Ret;
+        Ret = Ret && (NtGdiGetDeviceCaps(hDC, BITSPIXEL) > 8);
         
         ASSERT(pvParam);
         *((PBOOL)pvParam) = Ret;
         return TRUE;
       }
+#endif
       return FALSE;
     }
     case SPI_SETFONTSMOOTHING:
@@ -822,305 +311,6 @@
   return FALSE;
 }
 
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserSystemParametersInfo(
-  UINT uiAction,
-  UINT uiParam,
-  PVOID pvParam,
-  UINT fWinIni)
-{
-  NTSTATUS Status;
-
-  switch(uiAction)
-  {
-    case SPI_SETDOUBLECLKWIDTH:
-    case SPI_SETDOUBLECLKHEIGHT:
-    case SPI_SETDOUBLECLICKTIME:
-    case SPI_SETGRADIENTCAPTIONS:
-    case SPI_SETFONTSMOOTHING:
-    case SPI_SETFOCUSBORDERHEIGHT:
-    case SPI_SETFOCUSBORDERWIDTH:
-    {
-      return (DWORD)IntSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
-    }
-    case SPI_SETWORKAREA:
-    {
-      RECT rc;
-      Status = MmCopyFromCaller(&rc, (PRECT)pvParam, sizeof(RECT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      return (DWORD)IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni);
-    }
-    case SPI_GETWORKAREA:
-    {
-      RECT rc;
-      
-      if(!IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni))
-      {
-        return FALSE;
-      }
-      
-      Status = MmCopyToCaller((PRECT)pvParam, &rc, sizeof(RECT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      return TRUE;
-    }
-    case SPI_GETFONTSMOOTHING:
-    case SPI_GETGRADIENTCAPTIONS:
-    case SPI_GETFOCUSBORDERHEIGHT:
-    case SPI_GETFOCUSBORDERWIDTH:
-    {
-      BOOL Ret;
-      
-      if(!IntSystemParametersInfo(uiAction, uiParam, &Ret, fWinIni))
-      {
-        return FALSE;
-      }
-      
-      Status = MmCopyToCaller(pvParam, &Ret, sizeof(BOOL));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      return TRUE;
-    }
-    case SPI_GETICONTITLELOGFONT:
-    {
-      LOGFONTW IconFont;
-      
-      if(!IntSystemParametersInfo(uiAction, uiParam, &IconFont, fWinIni))
-      {
-        return FALSE;
-      }
-      
-      Status = MmCopyToCaller(pvParam, &IconFont, sizeof(LOGFONTW));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      return TRUE;
-    }
-    case SPI_GETNONCLIENTMETRICS:
-    {
-      NONCLIENTMETRICSW metrics;
-      
-      Status = MmCopyFromCaller(&metrics.cbSize, pvParam, sizeof(UINT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      if((metrics.cbSize != sizeof(NONCLIENTMETRICSW)) ||
-         (uiParam != sizeof(NONCLIENTMETRICSW)))
-      {
-        SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        return FALSE;
-      }
-      
-      if(!IntSystemParametersInfo(uiAction, uiParam, &metrics, fWinIni))
-      {
-        return FALSE;
-      }
-      
-      Status = MmCopyToCaller(pvParam, &metrics.cbSize, sizeof(NONCLIENTMETRICSW));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return FALSE;
-      }
-      return TRUE;
-    }
-  }
-  return FALSE;
-}
-
-UINT
-STDCALL
-NtUserGetDoubleClickTime(VOID)
-{
-  UINT Result;
-  NTSTATUS Status;
-  PWINSTATION_OBJECT WinStaObject;
-  PSYSTEM_CURSORINFO CurInfo;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                          KernelMode,
-                                          0,
-                                          &WinStaObject);
-  if (!NT_SUCCESS(Status))
-    return (DWORD)FALSE;
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  Result = CurInfo->DblClickSpeed;
-      
-  ObDereferenceObject(WinStaObject);
-  return Result;
-}
-
-BOOL
-STDCALL
-NtUserGetGUIThreadInfo(
-  DWORD idThread,
-  LPGUITHREADINFO lpgui)
-{
-  NTSTATUS Status;
-  PTHRDCARETINFO CaretInfo;
-  GUITHREADINFO SafeGui;
-  PDESKTOP_OBJECT Desktop;
-  PUSER_MESSAGE_QUEUE MsgQueue;
-  PETHREAD Thread = NULL;
-  
-  Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  if(SafeGui.cbSize != sizeof(GUITHREADINFO))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return FALSE;
-  }
-  
-  if(idThread)
-  {
-    Status = PsLookupThreadByThreadId((PVOID)idThread, &Thread);
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastWin32Error(ERROR_ACCESS_DENIED);
-      return FALSE;
-    }
-    Desktop = Thread->Win32Thread->Desktop;
-  }
-  else
-  {
-    /* get the foreground thread */
-    PW32THREAD W32Thread = PsGetCurrentThread()->Win32Thread;
-    Desktop = W32Thread->Desktop;
-    if(Desktop)
-    {
-      MsgQueue = Desktop->ActiveMessageQueue;
-      if(MsgQueue)
-      {
-        Thread = MsgQueue->Thread;
-      }
-    }
-  }
-  
-  if(!Thread || !Desktop)
-  {
-    if(idThread && Thread)
-      ObDereferenceObject(Thread);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-  
-  MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue;
-  CaretInfo = MsgQueue->CaretInfo;
-  
-  SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
-  if(MsgQueue->MenuOwner)
-    SafeGui.flags |= GUI_INMENUMODE | MsgQueue->MenuState;
-  if(MsgQueue->MoveSize)
-    SafeGui.flags |= GUI_INMOVESIZE;
-  
-  /* FIXME add flag GUI_16BITTASK */
-  
-  SafeGui.hwndActive = MsgQueue->ActiveWindow;
-  SafeGui.hwndFocus = MsgQueue->FocusWindow;
-  SafeGui.hwndCapture = MsgQueue->CaptureWindow;
-  SafeGui.hwndMenuOwner = MsgQueue->MenuOwner;
-  SafeGui.hwndMoveSize = MsgQueue->MoveSize;
-  SafeGui.hwndCaret = CaretInfo->hWnd;
-  
-  SafeGui.rcCaret.left = CaretInfo->Pos.x;
-  SafeGui.rcCaret.top = CaretInfo->Pos.y;
-  SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
-  SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
-  
-  if(idThread)
-    ObDereferenceObject(Thread);
-  
-  Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-
-DWORD
-STDCALL
-NtUserGetGuiResources(
-  HANDLE hProcess,
-  DWORD uiFlags)
-{
-  PEPROCESS Process;
-  PW32PROCESS W32Process;
-  NTSTATUS Status;
-  DWORD Ret = 0;
-  
-  Status = ObReferenceObjectByHandle(hProcess,
-                                     PROCESS_QUERY_INFORMATION,
-                                     PsProcessType,
-                                     ExGetPreviousMode(),
-                                     (PVOID*)&Process,
-                                     NULL);
-  
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return 0;
-  }
-  
-  W32Process = Process->Win32Process;
-  if(!W32Process)
-  {
-    ObDereferenceObject(Process);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-  
-  switch(uiFlags)
-  {
-    case GR_GDIOBJECTS:
-    {
-      Ret = (DWORD)W32Process->GDIObjects;
-      break;
-    }
-    case GR_USEROBJECTS:
-    {
-      Ret = (DWORD)W32Process->UserObjects;
-      break;
-    }
-    default:
-    {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      break;
-    }
-  }
-  
-  ObDereferenceObject(Process);
-
-  return Ret;
-}
-
 NTSTATUS FASTCALL
 IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
                          PUNICODE_STRING Source)
@@ -1247,4 +437,4 @@
     }
 }
 
-/* EOF */
+

reactos/subsys/win32k/ntuser
msgqueue.c 1.100 -> 1.100.12.1
diff -u -r1.100 -r1.100.12.1
--- msgqueue.c	22 May 2004 17:51:08 -0000	1.100
+++ msgqueue.c	15 Jul 2004 20:07:18 -0000	1.100.12.1
@@ -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: msgqueue.c,v 1.100 2004/05/22 17:51:08 weiden Exp $
+/* $Id: msgqueue.c,v 1.100.12.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -173,72 +173,24 @@
 BOOL FASTCALL
 MsqIsDblClk(LPMSG Msg, BOOL Remove)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  PSYSTEM_CURSORINFO CurInfo;
-  NTSTATUS Status;
-  LONG dX, dY;
-  BOOL Res;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-                                          KernelMode,
-                                          0,
-                                          &WinStaObject);
-  if (!NT_SUCCESS(Status))
-  {
-    return FALSE;
-  }
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) && 
-        ((Msg->time - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed);
-  if(Res)
-  {
-    
-    dX = CurInfo->LastBtnDownX - Msg->pt.x;
-    dY = CurInfo->LastBtnDownY - Msg->pt.y;
-    if(dX < 0) dX = -dX;
-    if(dY < 0) dY = -dY;
-    
-    Res = (dX <= CurInfo->DblClickWidth) &&
-          (dY <= CurInfo->DblClickHeight);
-  }
-
-  if(Remove)
-  {
-    if (Res)
-    {
-      CurInfo->LastBtnDown = 0;
-      CurInfo->LastBtnDownX = Msg->pt.x;
-      CurInfo->LastBtnDownY = Msg->pt.y;
-      CurInfo->LastClkWnd = NULL;
-    }
-    else
-    {
-      CurInfo->LastBtnDownX = Msg->pt.x;
-      CurInfo->LastBtnDownY = Msg->pt.y;
-      CurInfo->LastClkWnd = (HANDLE)Msg->hwnd;
-      CurInfo->LastBtnDown = Msg->time;
-    }
-  }
-  
-  ObDereferenceObject(WinStaObject);
-  return Res;
+   /* FIXME */
+   return FALSE;
 }
 
 BOOL STATIC STDCALL
-MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT FilterLow, UINT FilterHigh,
+MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT FilterWindow, UINT FilterLow, UINT FilterHigh,
 			 PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed, 
 			 PWINDOW_OBJECT ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue)
 {
   USHORT Msg = Message->Msg.message;
-  PWINDOW_OBJECT Window = NULL;
-  HWND CaptureWin;
+  PWINDOW_OBJECT CaptureWin, Window = NULL;
   
   CaptureWin = IntGetCaptureWindow();
   if (CaptureWin == NULL)
   {
     if(Msg == WM_MOUSEWHEEL)
     {
-      Window = IntGetWindowObject(IntGetFocusWindow());
+      Window = IntGetFocusWindow();
     }
     else
     {
@@ -246,7 +198,6 @@
       if(Window == NULL)
       {
         Window = ScopeWin;
-        IntReferenceWindowObject(Window);
       }
     }
   }
@@ -254,7 +205,7 @@
   {
     /* FIXME - window messages should go to the right window if no buttons are
                pressed */
-    Window = IntGetWindowObject(CaptureWin);
+    Window = CaptureWin;
   }
 
   if (Window == NULL)
@@ -314,7 +265,7 @@
     
     KeSetEvent(&Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
     *Freed = FALSE;
-    IntReleaseWindowObject(Window);
+    
     return(FALSE);
   }
   
@@ -322,7 +273,7 @@
   
   *ScreenPoint = Message->Msg.pt;
   
-  if((hWnd != NULL && Window->Self != hWnd) ||
+  if((FilterWindow != NULL && Window != FilterWindow) ||
      ((FilterLow != 0 || FilterLow != 0) && (Msg < FilterLow || Msg > FilterHigh)))
   {
     /* Reject the message because it doesn't match the filter */
@@ -357,13 +308,12 @@
       IntUnLockHardwareMessageQueue(Window->MessageQueue);
     }
     
-    IntReleaseWindowObject(Window);
     *Freed = FALSE;
     return(FALSE);
   }
   
   /* FIXME - only assign if removing? */
-  Message->Msg.hwnd = Window->Self;
+  Message->Msg.hwnd = Window->Handle;
   Message->Msg.message = Msg;
   Message->Msg.lParam = MAKELONG(Message->Msg.pt.x, Message->Msg.pt.y);
   
@@ -396,13 +346,12 @@
     }
   }
   
-  IntReleaseWindowObject(Window);
   *Freed = FALSE;
   return(TRUE);
 }
 
 BOOL STDCALL
-MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
+MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT FilterWindow,
 		       UINT FilterLow, UINT FilterHigh, BOOL Remove,
 		       PUSER_MESSAGE* Message)
 {
@@ -433,7 +382,7 @@
     }
   while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
 
-  DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+  DesktopWindow = IntGetDesktopWindow();
 
   /* Process messages in the message queue itself. */
   IntLockHardwareMessageQueue(MessageQueue);
@@ -446,7 +395,7 @@
       if (Current->Msg.message >= WM_MOUSEFIRST &&
 	  Current->Msg.message <= WM_MOUSELAST)
 	{
-	  Accept = MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
+	  Accept = MsqTranslateMouseMessage(MessageQueue, FilterWindow, FilterLow, FilterHigh,
 					    Current, Remove, &Freed, 
 					    DesktopWindow, &ScreenPoint, FALSE);
 	  if (Accept)
@@ -458,7 +407,6 @@
 	      IntUnLockHardwareMessageQueue(MessageQueue);
               IntUnLockSystemHardwareMessageQueueLock(FALSE);
 	      *Message = Current;
-	      IntReleaseWindowObject(DesktopWindow);
 	      return(TRUE);
 	    }
 
@@ -511,7 +459,7 @@
 	{
 	  const ULONG ActiveStamp = HardwareMessageQueueStamp;
 	  /* Translate the message. */
-	  Accept = MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
+	  Accept = MsqTranslateMouseMessage(MessageQueue, FilterWindow, FilterLow, FilterHigh,
 					    Current, Remove, &Freed, 
 					    DesktopWindow, &ScreenPoint, TRUE);
 	  if (Accept)
@@ -547,7 +495,6 @@
 		}
 	      IntUnLockSystemHardwareMessageQueueLock(FALSE);
 	      *Message = Current;
-	      IntReleaseWindowObject(DesktopWindow);
 	      return(TRUE);
 	    }
 	  /* If the contents of the queue changed then restart processing. */
@@ -558,7 +505,7 @@
 	    }
 	}
     }
-  IntReleaseWindowObject(DesktopWindow);
+  
   /* Check if the system message queue is now empty. */
   IntLockSystemMessageQueue(OldIrql);
   if (SystemMessageQueueCount == 0 && IsListEmpty(&HardwareMessageQueueHead))
@@ -586,7 +533,7 @@
   Msg.lParam = lParam;
   /* FIXME: Initialize time and point. */
   
-  FocusMessageQueue = IntGetFocusMessageQueue();
+  FocusMessageQueue = IntGetActiveMessageQueue();
   if( !IntGetScreenDC() ) {
     if( W32kGetPrimitiveMessageQueue() ) {
       MsqPostMessage(W32kGetPrimitiveMessageQueue(), &Msg, FALSE);
@@ -598,9 +545,9 @@
 	return;
       }
     
-    if (FocusMessageQueue->FocusWindow != (HWND)0)
+    if (FocusMessageQueue->FocusWindow != NULL)
       {
-	Msg.hwnd = FocusMessageQueue->FocusWindow;
+	Msg.hwnd = FocusMessageQueue->FocusWindow->Handle;
         DPRINT("Msg.hwnd = %x\n", Msg.hwnd);
 	MsqPostMessage(FocusMessageQueue, &Msg, FALSE);
       }
@@ -612,14 +559,15 @@
 }
 
 VOID FASTCALL
-MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
+MsqPostHotKeyMessage(PVOID Thread, PWINDOW_OBJECT Window, WPARAM wParam, LPARAM lParam)
 {
-  PWINDOW_OBJECT Window;
   PW32THREAD Win32Thread;
   PW32PROCESS Win32Process;
   MSG Mesg;
   NTSTATUS Status;
 
+  ASSERT(Window);
+
   Status = ObReferenceObjectByPointer (Thread,
 				       THREAD_ALL_ACCESS,
 				       PsThreadType,
@@ -641,15 +589,7 @@
       return;
     }
 
-  Status = ObmReferenceObjectByHandle(Win32Process->WindowStation->HandleTable,
-                                      hWnd, otWindow, (PVOID*)&Window);
-  if (!NT_SUCCESS(Status))
-    {
-      ObDereferenceObject ((PETHREAD)Thread);
-      return;
-    }
-
-  Mesg.hwnd = hWnd;
+  Mesg.hwnd = Window->Handle;
   Mesg.message = WM_HOTKEY;
   Mesg.wParam = wParam;
   Mesg.lParam = lParam;
@@ -658,7 +598,7 @@
 //      KeQueryTickCount(&LargeTickCount);
 //      Mesg.time = LargeTickCount.u.LowPart;
   MsqPostMessage(Window->MessageQueue, &Mesg, FALSE);
-  ObmDereferenceObject(Window);
+  
   ObDereferenceObject (Thread);
 
 //  IntLockMessageQueue(pThread->MessageQueue);
@@ -726,6 +666,7 @@
 BOOLEAN FASTCALL
 MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
 {
+  PWINDOW_OBJECT Window;
   PUSER_SENT_MESSAGE Message;
   PLIST_ENTRY Entry;
   LRESULT Result;
@@ -750,12 +691,19 @@
   
   IntUnLockMessageQueue(MessageQueue);
   
+  Window = IntGetUserObject(WINDOW, Message->Msg.hwnd);
+  ASSERT(Window);
+  
+  ObmReferenceObject(Window);
+  
   /* Call the window procedure. */
-  Result = IntSendMessage(Message->Msg.hwnd,
+  Result = IntSendMessage(Window,
                           Message->Msg.message,
                           Message->Msg.wParam,
                           Message->Msg.lParam);
   
+  ObmDereferenceObject(Window);
+  
   /* remove the message from the local dispatching list, because it doesn't need
      to be cleaned up on thread termination anymore */
   IntLockMessageQueue(MessageQueue);
@@ -833,7 +781,7 @@
 
 NTSTATUS FASTCALL
 MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-	       HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
+	       PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam,
                UINT uTimeout, BOOL Block, ULONG_PTR *uResult)
 {
   PUSER_SENT_MESSAGE Message;
@@ -846,6 +794,8 @@
 
   if(!(Message = ExAllocatePoolWithTag(PagedPool, sizeof(USER_SENT_MESSAGE), TAG_USRMSG)))
   {
+    /* FIXME - bail from the global lock here! */
+    
     DPRINT1("MsqSendMessage(): Not enough memory to allocate a message");
     return STATUS_INSUFFICIENT_RESOURCES;
   }
@@ -860,7 +810,7 @@
   /* FIXME - increase reference counter of sender's message queue here */
   
   Result = 0;
-  Message->Msg.hwnd = Wnd;
+  Message->Msg.hwnd = Window->Handle;
   Message->Msg.message = Msg;
   Message->Msg.wParam = wParam;
   Message->Msg.lParam = lParam;
@@ -869,6 +819,8 @@
   Message->SenderQueue = ThreadQueue;
   Message->CompletionCallback = NULL;
   
+  /* FIXME - bail from the global lock here! */
+  
   IntReferenceMessageQueue(MessageQueue);
   
   /* add it to the list of pending messages */
@@ -1032,11 +984,11 @@
   IntUnLockMessageQueue(MessageQueue);
 }
 
-BOOLEAN STDCALL
+BOOLEAN FASTCALL
 MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
 	       IN BOOLEAN Hardware,
 	       IN BOOLEAN Remove,
-	       IN HWND Wnd,
+	       IN PWINDOW_OBJECT FilterWindow,
 	       IN UINT MsgFilterLow,
 	       IN UINT MsgFilterHigh,
 	       OUT PUSER_MESSAGE* Message)
@@ -1047,7 +999,7 @@
 
   if (Hardware)
     {
-      return(MsqPeekHardwareMessage(MessageQueue, Wnd,
+      return(MsqPeekHardwareMessage(MessageQueue, FilterWindow,
 				    MsgFilterLow, MsgFilterHigh,
 				    Remove, Message));
     }
@@ -1059,7 +1011,7 @@
     {
       CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
 					 ListEntry);
-      if ((Wnd == 0 || Wnd == CurrentMessage->Msg.hwnd) &&
+      if ((FilterWindow == NULL || FilterWindow->Handle == CurrentMessage->Msg.hwnd) &&
 	  ((MsgFilterLow == 0 && MsgFilterHigh == 0) ||
 	   (MsgFilterLow <= CurrentMessage->Msg.message &&
 	    MsgFilterHigh >= CurrentMessage->Msg.message)))
@@ -1272,41 +1224,38 @@
   return MessageQueue->ExtraInfo;
 }
 
-HWND FASTCALL
-MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd)
+PWINDOW_OBJECT FASTCALL
+MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, PWINDOW_OBJECT Window)
 {
-  HWND Prev;
+  PWINDOW_OBJECT *Change;
   
   switch(Type)
   {
     case MSQ_STATE_CAPTURE:
-      Prev = MessageQueue->CaptureWindow;
-      MessageQueue->CaptureWindow = hWnd;
-      return Prev;
+      Change = &MessageQueue->CaptureWindow;
+      break;
     case MSQ_STATE_ACTIVE:
-      Prev = MessageQueue->ActiveWindow;
-      MessageQueue->ActiveWindow = hWnd;
-      return Prev;
+      Change = &MessageQueue->ActiveWindow;
+      break;
     case MSQ_STATE_FOCUS:
-      Prev = MessageQueue->FocusWindow;
-      MessageQueue->FocusWindow = hWnd;
-      return Prev;
+      Change = &MessageQueue->FocusWindow;
+      break;
     case MSQ_STATE_MENUOWNER:
-      Prev = MessageQueue->MenuOwner;
-      MessageQueue->MenuOwner = hWnd;
-      return Prev;
+      Change = &MessageQueue->MenuOwner;
+      break;
     case MSQ_STATE_MOVESIZE:
-      Prev = MessageQueue->MoveSize;
-      MessageQueue->MoveSize = hWnd;
-      return Prev;
+      Change = &MessageQueue->MoveSize;
+      break;
     case MSQ_STATE_CARET:
       ASSERT(MessageQueue->CaretInfo);
-      Prev = MessageQueue->CaretInfo->hWnd;
-      MessageQueue->CaretInfo->hWnd = hWnd;
-      return Prev;
+      Change = &MessageQueue->CaretInfo->Window;
+      break;
+    default:
+      DPRINT1("Attempted to change invalid (0x%x) message queue state window!\n", Type);
+      return NULL;
   }
   
-  return NULL;
+  return (PWINDOW_OBJECT)InterlockedExchange((LONG*)Change, (LONG)Window);
 }
 
 /* EOF */

reactos/subsys/win32k/ntuser
painting.c 1.84 -> 1.84.2.1
diff -u -r1.84 -r1.84.2.1
--- painting.c	9 Jul 2004 20:13:00 -0000	1.84
+++ painting.c	15 Jul 2004 20:07:18 -0000	1.84.2.1
@@ -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: painting.c,v 1.84 2004/07/09 20:13:00 navaraf Exp $
+ *  $Id: painting.c,v 1.84.2.1 2004/07/15 20:07:18 weiden Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -27,22 +27,18 @@
  *       06/06/2001   Created (?)
  *       18/11/2003   Complete rewrite
  */
-
-/* INCLUDES ******************************************************************/
-
 #include <w32k.h>
 
 #define NDEBUG
-#include <win32k/debug1.h>
-
-#define DCX_USESTYLE 0x10000
+#include <win32k/debug.h>
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
 VOID FASTCALL
 IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion)
 {
-   PWINDOW_OBJECT ParentWindow = IntGetParentObject(Child), OldWindow;
+   PWINDOW_OBJECT OldWindow;
+   PWINDOW_OBJECT ParentWindow = Child->Parent;
 
    while (ParentWindow)
    {
@@ -68,8 +64,7 @@
          IntUnLockWindowUpdate(ParentWindow);
       }
       OldWindow = ParentWindow;
-      ParentWindow = IntGetParentObject(ParentWindow);
-      IntReleaseWindowObject(OldWindow);
+      ParentWindow = ParentWindow->Parent;
    }
 }
 
@@ -83,8 +78,9 @@
 IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
 {
   HDC hDC;
-  HWND hWnd = Window->Self;
   HRGN TempRegion;
+  
+  ASSERT(Window);
 
   if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
     {
@@ -104,7 +100,11 @@
           Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
           MsqDecPaintCountQueue(Window->MessageQueue);
           IntUnLockWindowUpdate(Window);
-          IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
+          IntSendMessage(Window, WM_NCPAINT, (WPARAM)TempRegion, 0);
+          if(!IntIsWindow(Window))
+          {
+            return;
+          }
         }
 
       if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND)
@@ -112,15 +112,19 @@
           if (Window->UpdateRegion)
             {
               IntValidateParent(Window, Window->UpdateRegion);
-              hDC = NtUserGetDCEx(hWnd, 0, DCX_CACHE | DCX_USESTYLE |
+              hDC = IntGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE |
                                            DCX_INTERSECTUPDATE);
               if (hDC != NULL)
                 {
-                  if (IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0))
+                  if (IntSendMessage(Window, WM_ERASEBKGND, (WPARAM)hDC, 0))
                     {
                       Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
                     }
-                  NtUserReleaseDC(hWnd, hDC);
+		  IntReleaseDC(Window, hDC);
+		  if(!IntIsWindow(Window))
+		  {
+		    return;
+		  }
                 }
             }
         }
@@ -130,7 +134,11 @@
           if (Window->UpdateRegion != NULL ||
               Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
             {
-              IntSendMessage(hWnd, WM_PAINT, 0, 0);
+              IntSendMessage(Window, WM_PAINT, 0, 0);
+              if(!IntIsWindow(Window))
+              {
+                return;
+              }
               IntLockWindowUpdate(Window);
               if (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
                 {
@@ -149,7 +157,7 @@
    * Check that the window is still valid at this point
    */
 
-  if (! IntIsWindow(hWnd))
+  if (! IntIsWindow(Window))
     {
       return;
     }
@@ -160,21 +168,15 @@
   if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
       ((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
     {
-      HWND *List, *phWnd;
-
-      if ((List = IntWinListChildren(Window)))
+      PWINDOW_OBJECT Current;
+      
+      for(Current = Window->FirstChild; Current != NULL; Current = Current->NextSibling)
+      {
+        if(Current->Style & WS_VISIBLE)
         {
-          for (phWnd = List; *phWnd; ++phWnd)
-            {
-              Window = IntGetWindowObject(*phWnd);
-              if (Window && (Window->Style & WS_VISIBLE))
-                {
-                  IntPaintWindows(Window, Flags);
-                  IntReleaseWindowObject(Window);
-                }
-            }
-          ExFreePool(List);
+          IntPaintWindows(Window, Flags);
         }
+      }
     }
 }
 
@@ -342,34 +344,23 @@
    if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
        ((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
    {
-      HWND *List, *phWnd;
       PWINDOW_OBJECT Child;
-
-      if ((List = IntWinListChildren(Window)))
+      
+      for(Child = Window->FirstChild; Child != NULL; Child = Child->NextSibling)
       {
-         for (phWnd = List; *phWnd; ++phWnd)
-         {
-            Child = IntGetWindowObject(*phWnd);
-            if(!Child)
-            {
-              continue;
-            }
-            if (Child->Style & WS_VISIBLE)
-            {
-               /*
-                * Recursive call to update children UpdateRegion
-                */
-               HRGN hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
-               NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
-               NtGdiOffsetRgn(hRgnTemp,
-                  Window->WindowRect.left - Child->WindowRect.left,
-                  Window->WindowRect.top - Child->WindowRect.top);
-               IntInvalidateWindows(Child, hRgnTemp, Flags);
-               NtGdiDeleteObject(hRgnTemp);
-            }
-            IntReleaseWindowObject(Child);
-         }
-         ExFreePool(List);
+        if(Child->Style & WS_VISIBLE)
+        {
+          /*
+           * Recursive call to update children UpdateRegion
+           */
+          HRGN hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
+          NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
+          NtGdiOffsetRgn(hRgnTemp,
+                         Window->WindowRect.left - Child->WindowRect.left,
+                         Window->WindowRect.top - Child->WindowRect.top);
+          IntInvalidateWindows(Child, hRgnTemp, Flags);
+          NtGdiDeleteObject(hRgnTemp);
+        }
       }
    }
 
@@ -411,21 +402,16 @@
 BOOL FASTCALL
 IntIsWindowDrawable(PWINDOW_OBJECT Window)
 {
-   PWINDOW_OBJECT Old, Wnd = Window;
+   PWINDOW_OBJECT Wnd;
    
-   IntReferenceWindowObject(Wnd);
-   do
+   for(Wnd = Window; Wnd != NULL; Wnd = IntGetParentObject(Wnd))
    {
       if (!(Wnd->Style & WS_VISIBLE) ||
           ((Wnd->Style & WS_MINIMIZE) && (Wnd != Window)))
       {
-         IntReleaseWindowObject(Wnd);
          return FALSE;
       }
-      Old = Wnd;
-      Wnd = IntGetParentObject(Wnd);
-      IntReleaseWindowObject(Old);
-   } while(Wnd);
+   }
 
    return TRUE;
 }
@@ -438,8 +424,7 @@
  */
 
 BOOL FASTCALL
-IntRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn,
-   ULONG Flags)
+IntRedrawWindow(PWINDOW_OBJECT Window, LPRECT UpdateRect, HRGN UpdateRgn, UINT Flags)
 {
    HRGN hRgn = NULL;
 
@@ -528,86 +513,72 @@
    return TRUE;
 }
 
-BOOL FASTCALL
-IntIsWindowDirty(PWINDOW_OBJECT Window)
+PWINDOW_OBJECT STDCALL
+IntFindWindowToRepaint(PWINDOW_OBJECT Parent, PW32THREAD Thread)
 {
-   return (Window->Style & WS_VISIBLE) &&
-      ((Window->UpdateRegion != NULL) ||
-       (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) ||
-       (Window->Flags & WINDOWOBJECT_NEED_NCPAINT));
-}
-
-HWND STDCALL
-IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
-{
-   PWINDOW_OBJECT Window;
    PWINDOW_OBJECT Child;
-   HWND hFoundWnd = NULL;
+   PWINDOW_OBJECT FoundWnd = NULL;
 
-   Window = IntGetWindowObject(hWnd);
-   if (Window == NULL)
-      return NULL;
+   ASSERT(Parent);
 
-   if (IntIsWindowDirty(Window) && 
-       IntWndBelongsToThread(Window, Thread))
+   if (IntIsWindowDirty(Parent) && 
+       IntWndBelongsToThread(Parent, Thread))
    {
-      IntReleaseWindowObject(Window);
-      return hWnd;
+      return Parent;
    }
 
-   IntLockRelatives(Window);
-   for (Child = Window->FirstChild; Child; Child = Child->NextSibling)
+   for (Child = Parent->FirstChild; Child; Child = Child->NextSibling)
    {
       if (IntIsWindowDirty(Child) &&
           IntWndBelongsToThread(Child, Thread))
       {
-         hFoundWnd = Child->Self;
+         FoundWnd = Child;
          break;
       }
    }
-   IntUnLockRelatives(Window);
 
-   if (hFoundWnd == NULL)
+   if (FoundWnd != NULL)
    {
-      HWND *List;
-      INT i;
+     return FoundWnd;
+   }
 
-      List = IntWinListChildren(Window);
-      if (List != NULL)
+   for (Child = Parent->FirstChild; Child; Child = Child->NextSibling)
+   {
+      if ((FoundWnd = IntFindWindowToRepaint(Child, Thread)))
       {
-         for (i = 0; List[i]; i++)
-         {
-            hFoundWnd = IntFindWindowToRepaint(List[i], Thread);
-            if (hFoundWnd != NULL)
-               break;
-         }
-         ExFreePool(List);
+         break;
       }
    }
 
-   IntReleaseWindowObject(Window);
-
-   return hFoundWnd;
+   return FoundWnd;
 }
 
 BOOL FASTCALL
-IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax,
+IntGetPaintMessage(PWINDOW_OBJECT Window, UINT MsgFilterMin, UINT MsgFilterMax,
                    PW32THREAD Thread, MSG *Message, BOOL Remove)
 {
-   PWINDOW_OBJECT Window;
+   PWINDOW_OBJECT RepaintWnd;
+   
    PUSER_MESSAGE_QUEUE MessageQueue = (PUSER_MESSAGE_QUEUE)Thread->MessageQueue;
 
    if (!MessageQueue->PaintPosted)
+   {
       return FALSE;
+   }
 
-   if (hWnd)
-      Message->hwnd = IntFindWindowToRepaint(hWnd, PsGetWin32Thread());
+   if (Window)
+   {
+      RepaintWnd = IntFindWindowToRepaint(Window, PsGetWin32Thread());
+   }
    else
-      Message->hwnd = IntFindWindowToRepaint(IntGetDesktopWindow(), PsGetWin32Thread());
+   {
+      RepaintWnd = IntFindWindowToRepaint(IntGetDesktopWindow(), PsGetWin32Thread());
+   }
+   Message->hwnd = (RepaintWnd ? RepaintWnd->Handle : NULL);
 
-   if (Message->hwnd == NULL)
+   if (RepaintWnd == NULL)
    {
-      if (NULL == hWnd)
+      if (NULL == Window)
       {
          DPRINT1("PAINTING BUG: Thread marked as containing dirty windows, but no dirty windows found!\n");
          IntLockMessageQueue(MessageQueue);
@@ -618,24 +589,23 @@
       return FALSE;
    }
 
-   Window = IntGetWindowObject(Message->hwnd);
-   if (Window != NULL)
+   if (RepaintWnd != NULL)
    {
-      IntLockWindowUpdate(Window);
-      if (0 != (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
+      IntLockWindowUpdate(RepaintWnd);
+      if (0 != (RepaintWnd->Flags & WINDOWOBJECT_NEED_NCPAINT)
           && ((0 == MsgFilterMin && 0 == MsgFilterMax) ||
               (MsgFilterMin <= WM_NCPAINT &&
                WM_NCPAINT <= MsgFilterMax)))
       {
          Message->message = WM_NCPAINT;
-         Message->wParam = (WPARAM)Window->NCUpdateRegion;
+         Message->wParam = (WPARAM)RepaintWnd->NCUpdateRegion;
          Message->lParam = 0;
          if (Remove)
          {
-            IntValidateParent(Window, Window->NCUpdateRegion);
-            Window->NCUpdateRegion = NULL;
-            Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
-            MsqDecPaintCountQueue(Window->MessageQueue);
+            IntValidateParent(RepaintWnd, RepaintWnd->NCUpdateRegion);
+            RepaintWnd->NCUpdateRegion = NULL;
+            RepaintWnd->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
+            MsqDecPaintCountQueue(RepaintWnd->MessageQueue);
          }
       } else if ((0 == MsgFilterMin && 0 == MsgFilterMax) ||
                  (MsgFilterMin <= WM_PAINT &&
@@ -643,44 +613,45 @@
       {
          Message->message = WM_PAINT;
          Message->wParam = Message->lParam = 0;
-         if (Remove && Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
+         if (Remove && RepaintWnd->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
          {
-            Window->Flags &= ~WINDOWOBJECT_NEED_INTERNALPAINT;
-            if (Window->UpdateRegion == NULL)
+            RepaintWnd->Flags &= ~WINDOWOBJECT_NEED_INTERNALPAINT;
+            if (RepaintWnd->UpdateRegion == NULL)
             {
-               MsqDecPaintCountQueue(Window->MessageQueue);
+               MsqDecPaintCountQueue(RepaintWnd->MessageQueue);
             }
          }
       }
-      IntUnLockWindowUpdate(Window);
+      IntUnLockWindowUpdate(RepaintWnd);
 
-      IntReleaseWindowObject(Window);
       return TRUE;
    }
 
    return FALSE;
 }
 
-HWND FASTCALL
-IntFixCaret(HWND hWnd, LPRECT lprc, UINT flags)
+PWINDOW_OBJECT FASTCALL
+IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags)
 {
-   PDESKTOP_OBJECT Desktop;
+   PUSER_MESSAGE_QUEUE ActiveQueue;
    PTHRDCARETINFO CaretInfo;
-   HWND hWndCaret;
 
-   Desktop = PsGetCurrentThread()->Win32Thread->Desktop;
-   CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo;
-   hWndCaret = CaretInfo->hWnd;
-   if (hWndCaret == hWnd ||
-       ((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(hWnd, hWndCaret)))
+   if(!(ActiveQueue = IntGetActiveMessageQueue()))
+   {
+     return NULL;
+   }
+   
+   CaretInfo = ActiveQueue->CaretInfo;
+   if (CaretInfo != NULL && (CaretInfo->Window == Window ||
+                             ((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window, CaretInfo->Window))))
    {
       POINT pt, FromOffset, ToOffset, Offset;
       RECT rcCaret;
       
       pt.x = CaretInfo->Pos.x;
       pt.y = CaretInfo->Pos.y;
-      IntGetClientOrigin(hWndCaret, &FromOffset);
-      IntGetClientOrigin(hWnd, &ToOffset);
+      IntGetClientOrigin(CaretInfo->Window, &FromOffset);
+      IntGetClientOrigin(Window, &ToOffset);
       Offset.x = FromOffset.x - ToOffset.x;
       Offset.y = FromOffset.y - ToOffset.y;
       rcCaret.left = pt.x;
@@ -689,44 +660,29 @@
       rcCaret.bottom = pt.y + CaretInfo->Size.cy;
       if (NtGdiIntersectRect(lprc, lprc, &rcCaret))
       {
-         NtUserHideCaret(0);
+         #if 0
+	 IntHideCaret(0);
+	 #endif
          lprc->left = pt.x;
          lprc->top = pt.y;
-         return hWndCaret;
+         return CaretInfo->Window;
       }
    }
 
-   return 0;
+   return NULL;
 }
 
-/* PUBLIC FUNCTIONS ***********************************************************/
-
-/*
- * NtUserBeginPaint
- *
- * Status
- *    @implemented
- */
-
-HDC STDCALL
-NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs)
+HDC FASTCALL
+IntBeginPaint(PWINDOW_OBJECT Window, PAINTSTRUCT* lPs)
 {
-   PWINDOW_OBJECT Window;
+   ASSERT(Window);
 
-   if (!(Window = IntGetWindowObject(hWnd)))
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return NULL;
-   }
-
-   NtUserHideCaret(hWnd);
+   #if 0
+   IntHideCaret(hWnd);
+   #endif
 
-   lPs->hdc = NtUserGetDCEx(hWnd, 0, DCX_INTERSECTUPDATE | DCX_WINDOWPAINT |
-      DCX_USESTYLE);
-
-   if (!lPs->hdc)
+   if (!(lPs->hdc = IntGetDCEx(Window, 0, DCX_INTERSECTUPDATE | DCX_WINDOWPAINT | DCX_USESTYLE)))
    {
-      IntReleaseWindowObject(Window);
       return NULL;
    }
 
@@ -745,111 +701,41 @@
    }
    else
    {
-      NtUserGetClientRect(Window->Self, &lPs->rcPaint);
+      IntGetClientRect(Window, &lPs->rcPaint);
    }
    IntUnLockWindowUpdate(Window);
 
    if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND)
    {
       Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
-      lPs->fErase = !IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)lPs->hdc, 0);
+      lPs->fErase = !IntSendMessage(Window, WM_ERASEBKGND, (WPARAM)lPs->hdc, 0);
    }
    else
    {
       lPs->fErase = FALSE;
    }
 
-   IntReleaseWindowObject(Window);
-
    return lPs->hdc;
 }
 
-/*
- * NtUserEndPaint
- *
- * Status
- *    @implemented
- */
-
-BOOL STDCALL
-NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs)
+BOOL FASTCALL
+IntEndPaint(PWINDOW_OBJECT Window, CONST PAINTSTRUCT* lPs)
 {
-   NtUserReleaseDC(hWnd, lPs->hdc);
-   NtUserShowCaret(hWnd);
+   IntReleaseDC(Window, lPs->hdc);
+   #if 0
+   IntShowCaret(Window);
+   #endif
 
    return TRUE;
 }
 
-/*
- * NtUserInvalidateRect
- *
- * Status
- *    @implemented
- */
-
-DWORD STDCALL
-NtUserInvalidateRect(HWND hWnd, CONST RECT *Rect, BOOL Erase)
-{
-   return NtUserRedrawWindow(hWnd, Rect, 0, RDW_INVALIDATE | (Erase ? RDW_ERASE : 0));
-}
-
-/*
- * NtUserInvalidateRgn
- *
- * Status
- *    @implemented
- */
 
-DWORD STDCALL
-NtUserInvalidateRgn(HWND hWnd, HRGN Rgn, BOOL Erase)
+INT FASTCALL
+IntGetUpdateRgn(PWINDOW_OBJECT Window, HRGN hRgn, BOOL bErase)
 {
-   return NtUserRedrawWindow(hWnd, NULL, Rgn, RDW_INVALIDATE | (Erase ? RDW_ERASE : 0));
-}
-
-/*
- * NtUserValidateRgn
- *
- * Status
- *    @implemented
- */
-
-BOOL STDCALL
-NtUserValidateRgn(HWND hWnd, HRGN hRgn)
-{
-   return NtUserRedrawWindow(hWnd, NULL, hRgn, RDW_VALIDATE | RDW_NOCHILDREN);
-}
-
-/*
- * NtUserUpdateWindow
- *
- * Status
- *    @implemented
- */
- 
-BOOL STDCALL
-NtUserUpdateWindow(HWND hWnd)
-{
-   return NtUserRedrawWindow(hWnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN);
-}
-
-/*
- * NtUserGetUpdateRgn
- *
- * Status
- *    @implemented
- */
-
-INT STDCALL
-NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
-{
-   PWINDOW_OBJECT Window;
    int RegionType;
-
-   if (!(Window = IntGetWindowObject(hWnd)))
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return ERROR;
-   }
+   
+   ASSERT(Window);
     
    if (Window->UpdateRegion == NULL)
    {
@@ -864,30 +750,23 @@
          Window->WindowRect.top - Window->ClientRect.top);
    }
 
-   IntReleaseWindowObject(Window);
-
    if (bErase && RegionType != NULLREGION && RegionType != ERROR)
    {
-      NtUserRedrawWindow(hWnd, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN);
+      IntRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN);
    }
   
    return RegionType;
 }
 
-/*
- * NtUserGetUpdateRect
- *
- * Status
- *    @implemented
- */
 
-BOOL STDCALL
-NtUserGetUpdateRect(HWND Wnd, LPRECT UnsafeRect, BOOL Erase)
+BOOL FASTCALL
+IntGetUpdateRect(PWINDOW_OBJECT Window, LPRECT Rect, BOOL Erase)
 {
-  RECT Rect;
   HRGN Rgn;
   PROSRGNDATA RgnData;
-  NTSTATUS Status;
+
+  ASSERT(Window);
+  ASSERT(Rect);
 
   Rgn = NtGdiCreateRectRgn(0, 0, 0, 0);
   if (NULL == Rgn)
@@ -896,7 +775,8 @@
       SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
       return FALSE;
     }
-  NtUserGetUpdateRgn(Wnd, Rgn, Erase);
+  
+  IntGetUpdateRgn(Window, Rgn, Erase);
   RgnData = RGNDATA_LockRgn(Rgn);
   if (NULL == RgnData)
     {
@@ -904,7 +784,7 @@
       SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
       return FALSE;
     }
-  if (ERROR == UnsafeIntGetRgnBox(RgnData, &Rect))
+  if (ERROR == UnsafeIntGetRgnBox(RgnData, Rect))
     {
       RGNDATA_UnlockRgn(Rgn);
       NtGdiDeleteObject(Rgn);
@@ -914,78 +794,13 @@
   RGNDATA_UnlockRgn(Rgn);
   NtGdiDeleteObject(Rgn);
 
-  if (UnsafeRect != NULL)
-    {
-      Status = MmCopyToCaller(UnsafeRect, &Rect, sizeof(RECT));
-      if (! NT_SUCCESS(Status))
-        {
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return FALSE;
-        }
-    }
-
-  return Rect.left < Rect.right && Rect.top < Rect.bottom;
-}
-
-/*
- * NtUserRedrawWindow
- *
- * Status
- *    @implemented
- */
-
-BOOL STDCALL
-NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
-   UINT flags)
-{
-   RECT SafeUpdateRect;
-   NTSTATUS Status;
-   PWINDOW_OBJECT Wnd;
-
-   if (!(Wnd = IntGetWindowObject(hWnd ? hWnd : IntGetDesktopWindow())))
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return FALSE;
-   }
-
-   if (lprcUpdate != NULL)
-   {
-      Status = MmCopyFromCaller(&SafeUpdateRect, (PRECT)lprcUpdate,
-         sizeof(RECT));
-
-      if (!NT_SUCCESS(Status))
-      {
-         SetLastWin32Error(ERROR_INVALID_PARAMETER);
-         IntReleaseWindowObject(Wnd);
-         return FALSE;
-      }
-   }
-
-   Status = IntRedrawWindow(Wnd, NULL == lprcUpdate ? NULL : &SafeUpdateRect,
-      hrgnUpdate, flags);
-
-   if (!NT_SUCCESS(Status))
-   {
-      /* IntRedrawWindow fails only in case that flags are invalid */
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      IntReleaseWindowObject(Wnd);
-      return FALSE;
-   }
- 
-   IntReleaseWindowObject(Wnd);
-   return TRUE;
+  return ((Rect->left < Rect->right) && (Rect->top < Rect->bottom));
 }
 
-/*
- * NtUserScrollDC
- *
- * Status
- *    @implemented
- */
 
-DWORD STDCALL
-NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
-   const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
+DWORD FASTCALL
+IntScrollDC(HDC hDC, INT dx, INT dy, LPRECT lprcScroll,
+            LPRECT lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
 {
    RECT rSrc, rClipped_src, rClip, rDst, offset;
    PDC DC;
@@ -1081,32 +896,27 @@
    return TRUE;
 }
 
-/*
- * NtUserScrollWindowEx
- *
- * Status
- *    @implemented
- */
 
-DWORD STDCALL
-NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *rect,
-   const RECT *clipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
+DWORD FASTCALL
+IntScrollWindowEx(PWINDOW_OBJECT Window, INT dx, INT dy, LPRECT rect,
+                  LPRECT clipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
 {
    RECT rc, cliprc, caretrc;
    INT Result;
-   PWINDOW_OBJECT Window;
+   PWINDOW_OBJECT CaretWindow;
    HDC hDC;
    HRGN hrgnTemp;
-   HWND hwndCaret;
-   BOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
+   BOOL bUpdate;
    BOOL bOwnRgn = TRUE;
 
-   Window = IntGetWindowObject(hWnd);
-   if (!Window || !IntIsWindowDrawable(Window))
+   ASSERT(Window);
+   
+   if (!IntIsWindowDrawable(Window))
    {
-      IntReleaseWindowObject(Window);
       return ERROR;
    }
+   
+   bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
 
    IntGetClientRect(Window, &rc);
    if (rect)
@@ -1124,18 +934,18 @@
    }
 
    caretrc = rc;
-   hwndCaret = IntFixCaret(hWnd, &caretrc, flags);
+   CaretWindow = IntFixCaret(Window, &caretrc, flags);
 
    if (hrgnUpdate)
       bOwnRgn = FALSE;
    else if (bUpdate)
       hrgnUpdate = NtGdiCreateRectRgn(0, 0, 0, 0);
 
-   hDC = NtUserGetDCEx(hWnd, 0, DCX_CACHE | DCX_USESTYLE);
+   hDC = IntGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE);
    if (hDC)
    {
-      NtUserScrollDC(hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate);
-      NtUserReleaseDC(hWnd, hDC);
+      IntScrollDC(hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate);
+      IntReleaseDC(Window, hDC);
    }
 
    /* 
@@ -1144,60 +954,56 @@
     */
 
    hrgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
-   Result = NtUserGetUpdateRgn(hWnd, hrgnTemp, FALSE);
+   Result = IntGetUpdateRgn(Window, hrgnTemp, FALSE);
    if (Result != NULLREGION)
    {
       HRGN hrgnClip = UnsafeIntCreateRectRgnIndirect(&cliprc);
       NtGdiOffsetRgn(hrgnTemp, dx, dy);
       NtGdiCombineRgn(hrgnTemp, hrgnTemp, hrgnClip, RGN_AND);
-      NtUserRedrawWindow(hWnd, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE);
+      IntRedrawWindow(Window, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE);
       NtGdiDeleteObject(hrgnClip);
    }
    NtGdiDeleteObject(hrgnTemp);
 
    if (flags & SW_SCROLLCHILDREN)
    {
-      HWND *List = IntWinListChildren(Window);
-      if (List)
+      PWINDOW_OBJECT Current;
+      RECT r, dummy;
+      POINT ClientOrigin;
+      
+      for(Current = Window->FirstChild; Current != NULL; Current = Current->NextSibling)
       {
-         int i;
-         RECT r, dummy;
-         POINT ClientOrigin;
-
-         for (i = 0; List[i]; i++)
-         {
-            NtUserGetWindowRect(List[i], &r);
-            IntGetClientOrigin(hWnd, &ClientOrigin);
-            r.left -= ClientOrigin.x;
-            r.top -= ClientOrigin.y;
-            r.right -= ClientOrigin.x;
-            r.bottom -= ClientOrigin.y;
-            if (!rect || NtGdiIntersectRect(&dummy, &r, &rc))
-               WinPosSetWindowPos(List[i], 0, r.left + dx, r.top + dy, 0, 0,
-                                  SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
-                                  SWP_NOREDRAW);
-         }
-         ExFreePool(List);
+        r = Current->WindowRect;
+        IntGetClientOrigin(Window, &ClientOrigin);
+        r.left -= ClientOrigin.x;
+        r.top -= ClientOrigin.y;
+        r.right -= ClientOrigin.x;
+        r.bottom -= ClientOrigin.y;
+        if(!rect || NtGdiIntersectRect(&dummy, &r, &rc))
+        {
+          WinPosSetWindowPos(Current, 0, r.left + dx, r.top + dy, 0, 0,
+                             SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
+                             SWP_NOREDRAW);
+        }
       }
    }
 
    if (flags & (SW_INVALIDATE | SW_ERASE))
-      NtUserRedrawWindow(hWnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
-                         ((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
-                         ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
+      IntRedrawWindow(Window, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
+                      ((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
+                      ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
 
    if (bOwnRgn && hrgnUpdate)
       NtGdiDeleteObject(hrgnUpdate);
    
-   if (hwndCaret)
+   if (CaretWindow != NULL)
    {
-      IntSetCaretPos(caretrc.left + dx, caretrc.top + dy);
-      NtUserShowCaret(hwndCaret);
+      #if 0
+      IntSetCaretPos(CaretWindow.left + dx, caretrc.top + dy);
+      IntShowCaret(hwndCaret);
+      #endif
    }
-
-   IntReleaseWindowObject(Window);
     
    return Result;
 }
 
-/* EOF */

reactos/subsys/win32k/ntuser
prop.c 1.11 -> 1.11.12.1
diff -u -r1.11 -r1.11.12.1
--- prop.c	10 May 2004 17:07:18 -0000	1.11
+++ prop.c	15 Jul 2004 20:07:18 -0000	1.11.12.1
@@ -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: prop.c,v 1.11 2004/05/10 17:07:18 weiden Exp $
+/* $Id: prop.c,v 1.11.12.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -60,135 +60,6 @@
   return(NULL);
 }
 
-NTSTATUS STDCALL
-NtUserBuildPropList(HWND hWnd,
-		    LPVOID Buffer,
-		    DWORD BufferSize,
-		    DWORD *Count)
-{
-  PWINDOW_OBJECT WindowObject;
-  PPROPERTY Property;
-  PLIST_ENTRY ListEntry;
-  PROPLISTITEM listitem, *li;
-  NTSTATUS Status;
-  DWORD Cnt = 0;
-  
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
-  {
-    return STATUS_INVALID_HANDLE;
-  }
-  
-  if(Buffer)
-  {
-    if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
-    {
-      IntReleaseWindowObject(WindowObject);
-      return STATUS_INVALID_PARAMETER;
-    }
-    
-    /* copy list */
-    IntLockWindowProperties(WindowObject);
-    
-    li = (PROPLISTITEM *)Buffer;
-    ListEntry = WindowObject->PropListHead.Flink;
-    while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &WindowObject->PropListHead))
-    {
-      Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
-      listitem.Atom = Property->Atom;
-      listitem.Data = Property->Data;
-      
-      Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
-      if(!NT_SUCCESS(Status))
-      {
-        IntUnLockWindowProperties(WindowObject);
-        IntReleaseWindowObject(WindowObject);
-        return Status;
-      }
-      
-      BufferSize -= sizeof(PROPLISTITEM);
-      Cnt++;
-      li++;
-      ListEntry = ListEntry->Flink;
-    }
-    
-    IntUnLockWindowProperties(WindowObject);
-  }
-  else
-  {
-    IntLockWindowProperties(WindowObject);
-    Cnt = WindowObject->PropListItems * sizeof(PROPLISTITEM);
-    IntUnLockWindowProperties(WindowObject);
-  }
-  
-  IntReleaseWindowObject(WindowObject);
-  
-  if(Count)
-  {
-    Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
-    if(!NT_SUCCESS(Status))
-    {
-      return Status;
-    }
-  }
-  
-  return STATUS_SUCCESS;
-}
-
-HANDLE STDCALL
-NtUserRemoveProp(HWND hWnd, ATOM Atom)
-{
-  PWINDOW_OBJECT WindowObject;
-  PPROPERTY Prop;
-  HANDLE Data;
-
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return NULL;
-  }
-  
-  IntLockWindowProperties(WindowObject);
-  Prop = IntGetProp(WindowObject, Atom);
-  
-  if (Prop == NULL)
-    {
-      IntUnLockWindowProperties(WindowObject);
-      IntReleaseWindowObject(WindowObject);
-      return(NULL);
-    }
-  Data = Prop->Data;
-  RemoveEntryList(&Prop->PropListEntry);
-  ExFreePool(Prop);
-  WindowObject->PropListItems--;
-  IntUnLockWindowProperties(WindowObject);
-  IntReleaseWindowObject(WindowObject);
-  return(Data);
-}
-
-HANDLE STDCALL
-NtUserGetProp(HWND hWnd, ATOM Atom)
-{
-  PWINDOW_OBJECT WindowObject;
-  PPROPERTY Prop;
-  HANDLE Data = NULL;
-
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-  
-  IntLockWindowProperties(WindowObject);
-  Prop = IntGetProp(WindowObject, Atom);
-  if (Prop != NULL)
-  {
-    Data = Prop->Data;
-  }
-  IntUnLockWindowProperties(WindowObject);
-  IntReleaseWindowObject(WindowObject);
-  return(Data);
-}
-
 BOOL FASTCALL
 IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data)
 {
@@ -212,25 +83,4 @@
   return TRUE;
 }
 
-
-BOOL STDCALL
-NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
-{
-  PWINDOW_OBJECT WindowObject;
-  BOOL ret;
-
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-  
-  IntLockWindowProperties(WindowObject);
-  ret = IntSetProp(WindowObject, Atom, Data);
-  IntUnLockWindowProperties(WindowObject);
-  
-  IntReleaseWindowObject(WindowObject);
-  return ret;
-}
-
 /* EOF */

reactos/subsys/win32k/ntuser
scrollbar.c 1.34 -> 1.34.4.1
diff -u -r1.34 -r1.34.4.1
--- scrollbar.c	3 Jul 2004 17:40:25 -0000	1.34
+++ scrollbar.c	15 Jul 2004 20:07:18 -0000	1.34.4.1
@@ -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: scrollbar.c,v 1.34 2004/07/03 17:40:25 navaraf Exp $
+/* $Id: scrollbar.c,v 1.34.4.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -73,7 +73,7 @@
       lprect->left = ClientRect.left - WindowRect.left;
       lprect->top = ClientRect.bottom - WindowRect.top;
       lprect->right = ClientRect.right - WindowRect.left;
-      lprect->bottom = lprect->top + NtUserGetSystemMetrics (SM_CYHSCROLL);
+      lprect->bottom = lprect->top + IntGetSystemMetrics (SM_CYHSCROLL);
       vertical = FALSE;
       break;
 
@@ -81,12 +81,12 @@
       if(Window->ExStyle & WS_EX_LEFTSCROLLBAR)
       {
         lprect->right = ClientRect.left - WindowRect.left;
-        lprect->left = lprect->right - NtUserGetSystemMetrics(SM_CXVSCROLL);
+        lprect->left = lprect->right - IntGetSystemMetrics(SM_CXVSCROLL);
       }
       else
       {
         lprect->left = ClientRect.right - WindowRect.left;
-        lprect->right = lprect->left + NtUserGetSystemMetrics(SM_CXVSCROLL);
+        lprect->right = lprect->left + IntGetSystemMetrics(SM_CXVSCROLL);
       }
       lprect->top = ClientRect.top - WindowRect.top;
       lprect->bottom = ClientRect.bottom - WindowRect.top;
@@ -99,14 +99,13 @@
       break;
 
     default:
-      IntReleaseWindowObject(Window);
       return FALSE;
     }
 
   return vertical;
 }
 
-BOOL FASTCALL
+static BOOL FASTCALL
 IntCalculateThumb(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi, LPSCROLLINFO psi)
 {
   INT Thumb, ThumbBox, ThumbPos, cxy, mx;
@@ -115,23 +114,23 @@
   switch(idObject)
   {
     case SB_HORZ:
-      Thumb = NtUserGetSystemMetrics(SM_CXHSCROLL);
+      Thumb = IntGetSystemMetrics(SM_CXHSCROLL);
       cxy = psbi->rcScrollBar.right - psbi->rcScrollBar.left;
       break;
     case SB_VERT:
-      Thumb = NtUserGetSystemMetrics(SM_CYVSCROLL);
+      Thumb = IntGetSystemMetrics(SM_CYVSCROLL);
       cxy = psbi->rcScrollBar.bottom - psbi->rcScrollBar.top;
       break;
     case SB_CTL:
       IntGetClientRect (Window, &ClientRect);
       if(Window->Style & SBS_VERT)
       {
-        Thumb = NtUserGetSystemMetrics(SM_CYVSCROLL);
+        Thumb = IntGetSystemMetrics(SM_CYVSCROLL);
         cxy = ClientRect.bottom - ClientRect.top;
       }
       else
       {
-        Thumb = NtUserGetSystemMetrics(SM_CXHSCROLL);
+        Thumb = IntGetSystemMetrics(SM_CXHSCROLL);
         cxy = ClientRect.right - ClientRect.left;
       }
       break;
@@ -150,7 +149,7 @@
   }
   else
   {
-    ThumbBox = psi->nPage ? MINTRACKTHUMB : NtUserGetSystemMetrics(SM_CXHTHUMB);
+    ThumbBox = psi->nPage ? MINTRACKTHUMB : IntGetSystemMetrics(SM_CXHTHUMB);
     cxy -= (2 * Thumb);
     if(cxy >= ThumbBox)
     {
@@ -197,7 +196,7 @@
   IntCalculateThumb(Window, wBar, sbi, psi);
 }
 
-static BOOL FASTCALL
+BOOL FASTCALL
 IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi)
 {
   UINT Mask;
@@ -250,7 +249,7 @@
   return TRUE;
 }
 
-static DWORD FASTCALL
+DWORD FASTCALL
 IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
 {
   /*
@@ -369,7 +368,7 @@
             }
           else if ((nBar != SB_CTL) && bChangeParams)
             {
-              NtUserShowScrollBar(Window->Self, nBar, FALSE);
+	      IntShowScrollBar(Window, nBar, FALSE);
               return Info->nPos;
             }
         }
@@ -378,7 +377,7 @@
 /*         new_flags = 0;*/
           if ((nBar != SB_CTL) && bChangeParams)
             {
-              NtUserShowScrollBar(Window->Self, nBar, TRUE);
+	      IntShowScrollBar(Window, nBar, TRUE);
             }
         }
 
@@ -456,13 +455,13 @@
   Size = 3 * (sizeof(WINDOW_SCROLLINFO));
   if(!(Window->Scroll = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO)))
   {
-    DPRINT1("Unable to allocate memory for scrollbar information for window 0x%x\n", Window->Self);
+    DPRINT1("Unable to allocate memory for scrollbar information for window 0x%x\n", Window->Handle);
     return FALSE;
   }
   
   RtlZeroMemory(Window->Scroll, Size);
 
-  Result = WinPosGetNonClientSize(Window->Self,
+  Result = WinPosGetNonClientSize(Window,
 				  &Window->WindowRect,
 				  &Window->ClientRect);
   
@@ -496,7 +495,7 @@
   return FALSE;
 }
 
-BOOL STDCALL
+BOOL FASTCALL
 IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows)
 {
   BOOL Chg = FALSE;
@@ -534,121 +533,24 @@
   return Chg;
 }
 
-
-BOOL
-STDCALL
-NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
-{
-  NTSTATUS Status;
-  SCROLLBARINFO sbi;
-  PWINDOW_OBJECT Window;
-  BOOL Ret;
-
-  Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO));
-  if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO)))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-
-  Window = IntGetWindowObject(hWnd);
-
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-
-  Ret = IntGetScrollBarInfo(Window, idObject, &sbi);
-
-  Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    Ret = FALSE;
-  }
-  IntReleaseWindowObject(Window);
-  return Ret;
-}
-
-
-BOOL
-STDCALL
-NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
-{
-  NTSTATUS Status;
-  PWINDOW_OBJECT Window;
-  SCROLLINFO psi;
-  DWORD sz;
-  BOOL Ret;
-  
-  Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT));
-  if(!NT_SUCCESS(Status) || 
-     !((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos))))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  sz = psi.cbSize;
-  Status = MmCopyFromCaller(&psi, lpsi, sz);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  Window = IntGetWindowObject(hwnd);
-
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-
-  Ret = IntGetScrollInfo(Window, fnBar, &psi);
-  
-  IntReleaseWindowObject(Window);
-  
-  Status = MmCopyToCaller(lpsi, &psi, sz);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  return Ret;
-}
-
-
-BOOL
-STDCALL
-NtUserEnableScrollBar(
-  HWND hWnd, 
-  UINT wSBflags, 
-  UINT wArrows)
+BOOL FASTCALL
+IntEnableWindowScrollBar(PWINDOW_OBJECT Window, 
+                         UINT wSBflags, 
+                         UINT wArrows)
 {
-  PWINDOW_OBJECT Window;
   PSCROLLBARINFO InfoV = NULL, InfoH = NULL;
   BOOL Chg = FALSE;
   
-  Window = IntGetWindowObject(hWnd);
-
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
+  ASSERT(Window);
   
   if(wSBflags == SB_CTL)
   {
     /* FIXME */
-    IntReleaseWindowObject(Window);
     return FALSE;
   }
   
   if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags))
   {
-    IntReleaseWindowObject(Window);
     SetLastWin32Error(ERROR_INVALID_PARAMETER);
     DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags);
     return FALSE;
@@ -656,7 +558,6 @@
   
   if(!IntCreateScrollBars(Window))
     {
-      IntReleaseWindowObject(Window);
       return FALSE;
     }
   
@@ -672,7 +573,6 @@
       InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
       break;
     default:
-      IntReleaseWindowObject(Window);
       return FALSE;
   }
   
@@ -684,37 +584,24 @@
 
   //if(Chg && (Window->Style & WS_VISIBLE))
     /* FIXME - repaint scrollbars */
-
-  IntReleaseWindowObject(Window);
+  
   return TRUE;
 }
 
-BOOL
-STDCALL
-NtUserSetScrollBarInfo(
-  HWND hwnd,
-  LONG idObject,
-  SETSCROLLBARINFO *info)
+BOOL FASTCALL
+IntSetScrollBarInfo(PWINDOW_OBJECT Window,
+                    LONG idObject,
+                    SETSCROLLBARINFO *info)
 {
-  PWINDOW_OBJECT Window;
-  SETSCROLLBARINFO Safeinfo;
   PSCROLLBARINFO sbi;
   LPSCROLLINFO psi;
-  NTSTATUS Status;
   LONG Obj;
   
-  Window = IntGetWindowObject(hwnd);
-
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
+  ASSERT(Window);
   
   Obj = SBOBJ_TO_SBID(idObject);
   if(!SBID_IS_VALID(Obj))
   {
-    IntReleaseWindowObject(Window);
     SetLastWin32Error(ERROR_INVALID_PARAMETER);
     DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", Obj);
     return FALSE;
@@ -722,76 +609,26 @@
 
   if(!IntCreateScrollBars(Window))
     {
-      IntReleaseWindowObject(Window);
       return FALSE;
     }
   
-  Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    IntReleaseWindowObject(Window);
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
   sbi = IntGetScrollbarInfoFromWindow(Window, Obj);
   psi = IntGetScrollInfoFromWindow(Window, Obj);
   
-  psi->nTrackPos = Safeinfo.nTrackPos;
-  sbi->reserved = Safeinfo.reserved;
-  RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate));
+  psi->nTrackPos = info->nTrackPos;
+  sbi->reserved = info->reserved;
+  RtlCopyMemory(&sbi->rgstate, &info->rgstate, sizeof(info->rgstate));
   
-  IntReleaseWindowObject(Window);
   return TRUE;
 }
 
-DWORD
-STDCALL
-NtUserSetScrollInfo(
-  HWND hwnd, 
-  int fnBar, 
-  LPCSCROLLINFO lpsi, 
-  BOOL bRedraw)
-{
-  PWINDOW_OBJECT Window;
-  NTSTATUS Status;
-  SCROLLINFO ScrollInfo;
-  DWORD Ret;
-  
-  Window = IntGetWindowObject(hwnd);
-
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return 0;
-  }
-  
-  Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos));
-  if(!NT_SUCCESS(Status))
-  {
-    IntReleaseWindowObject(Window);
-    SetLastNtError(Status);
-    return 0;
-  }
-  
-  Ret = IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw);
-  IntReleaseWindowObject(Window);
-  
-  return Ret;
-}
-
 /* Ported from WINE20020904 (SCROLL_ShowScrollBar) */
-DWORD STDCALL
-NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow)
+DWORD FASTCALL
+IntShowScrollBar(PWINDOW_OBJECT Window, int wBar, DWORD bShow)
 {
    DWORD Style, OldStyle;
-   PWINDOW_OBJECT Window = IntGetWindowObject(hWnd);
-
-   if (!Window)
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return FALSE;
-   }
+   
+   ASSERT(Window);
    
    switch(wBar)
    {
@@ -808,14 +645,12 @@
        Style = 0;
        break;
      default:
-       IntReleaseWindowObject(Window);
        SetLastWin32Error(ERROR_INVALID_PARAMETER);
        return FALSE;
    }
    
   if(!IntCreateScrollBars(Window))
     {
-      IntReleaseWindowObject(Window);
       return FALSE;
     }
 
@@ -823,8 +658,7 @@
    {
       IntUpdateSBInfo(Window, SB_CTL);
       
-      WinPosShowWindow(hWnd, bShow ? SW_SHOW : SW_HIDE);
-      IntReleaseWindowObject(Window);
+      WinPosShowWindow(Window, bShow ? SW_SHOW : SW_HIDE);
       return TRUE;
    }
    
@@ -844,13 +678,11 @@
      if(Window->Style & WS_VISIBLE)
      {
        /* Frame has been changed, let the window redraw itself */
-       WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
+       WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
           SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
      }
    }
    
-   IntReleaseWindowObject(Window);
    return TRUE;
 }
 
-/* EOF */

reactos/subsys/win32k/ntuser
stubs.c 1.45 -> 1.45.12.1
diff -u -r1.45 -r1.45.12.1
--- stubs.c	29 Apr 2004 20:26:35 -0000	1.45
+++ stubs.c	15 Jul 2004 20:07:18 -0000	1.45.12.1
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.45 2004/04/29 20:26:35 weiden Exp $
+/* $Id: stubs.c,v 1.45.12.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -8,29 +8,1453 @@
  * REVISION HISTORY:
  *       04-06-2001  CSH  Created
  */
-#include <ddk/ntddk.h>
-#include <windows.h>
+#include <w32k.h>
 
 #define NDEBUG
 #include <debug.h>
 
+#ifdef UNIMPLEMENTED
+#undef UNIMPLEMENTED
+#define UNIMPLEMENTED DbgPrint("%s() in %s:%i UNIMPLEMENTED!\n", __FUNCTION__, __FILE__, __LINE__);
+#endif
+
+/*
+ * Cursors and Icons
+ */
+
+DWORD
+STDCALL
+NtUserGetCursorFrameInfo(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+BOOL
+STDCALL
+NtUserClipCursor(
+  RECT *UnsafeRect)
+{
+   UNIMPLEMENTED;
+   return TRUE;
+}
+
+BOOL
+STDCALL
+NtUserSetSystemCursor(
+  HCURSOR hcur,
+  DWORD id)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+BOOL
+STDCALL
+NtUserSetCursorIconContents(HANDLE Handle,
+                            PICONINFO IconInfo)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * Accelerators
+ */
+
+int
+STDCALL
+NtUserCopyAcceleratorTable(
+  HACCEL Table,
+  LPACCEL Entries,
+  int EntriesCount)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+HACCEL
+STDCALL
+NtUserCreateAcceleratorTable(
+  LPACCEL Entries,
+  SIZE_T EntriesCount)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+BOOLEAN
+STDCALL
+NtUserDestroyAcceleratorTable(
+  HACCEL Table)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+int
+STDCALL
+NtUserTranslateAccelerator(
+  HWND Window,
+  HACCEL Table,
+  LPMSG Message)
+{
+   UNIMPLEMENTED;
+   return 0;
+} 
+
+/*
+ * Carets
+ */
+
+BOOL
+STDCALL
+NtUserCreateCaret(
+  HWND hWnd,
+  HBITMAP hBitmap,
+  int nWidth,
+  int nHeight)
+{
+  return FALSE;
+}
+
+UINT
+STDCALL
+NtUserGetCaretBlinkTime(VOID)
+{
+  return 0;
+}
+
+BOOL
+STDCALL
+NtUserGetCaretPos(
+  LPPOINT lpPoint)
+{
+  return FALSE;
+}
+
+BOOL
+STDCALL
+NtUserHideCaret(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+BOOL
+STDCALL
+NtUserShowCaret(
+  HWND hWnd)
+{
+  return FALSE;
+}
+
+/*
+ * Classes
+ */
+
+DWORD STDCALL
+NtUserGetClassInfo(
+   HINSTANCE hInstance,
+   LPCWSTR lpClassName,
+   LPWNDCLASSEXW lpWndClassEx,
+   BOOL Ansi,
+   DWORD unknown3)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserGetClassName (
+  HWND hWnd,
+  LPWSTR lpClassName,
+  ULONG nMaxCount)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserGetWOWClass(DWORD Unknown0,
+		  DWORD Unknown1)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserSetClassWord(DWORD Unknown0,
+		   DWORD Unknown1,
+		   DWORD Unknown2)
+{
+   UNIMPLEMENTED;
+   return(0);
+}
+
+BOOL STDCALL
+NtUserUnregisterClass(
+   LPCWSTR ClassNameOrAtom,
+	 HINSTANCE hInstance,
+	 DWORD Unknown)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * Clipboard
+ */
+
+BOOL STDCALL
+NtUserOpenClipboard(HWND hWnd, DWORD Unknown1)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+BOOL STDCALL
+NtUserCloseClipboard(VOID)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+HWND STDCALL
+NtUserGetOpenClipboardWindow(VOID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+BOOL STDCALL
+NtUserChangeClipboardChain(HWND hWndRemove, HWND hWndNewNext)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserCountClipboardFormats(VOID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserEmptyClipboard(VOID)
+{
+   UNIMPLEMENTED;
+   return TRUE;
+}
+
+HANDLE STDCALL
+NtUserGetClipboardData(UINT uFormat, DWORD Unknown1)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+INT STDCALL
+NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
+   INT cchMaxCount)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+HWND STDCALL
+NtUserGetClipboardOwner(VOID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserGetClipboardSequenceNumber(VOID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+HWND STDCALL
+NtUserGetClipboardViewer(VOID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+INT STDCALL
+NtUserGetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+BOOL STDCALL
+NtUserIsClipboardFormatAvailable(UINT format)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+HANDLE STDCALL
+NtUserSetClipboardData(UINT uFormat, HANDLE hMem, DWORD Unknown2)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+HWND STDCALL
+NtUserSetClipboardViewer(HWND hWndNewViewer)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+/*
+ * Hooks
+ */
+
+LRESULT
+STDCALL
+NtUserCallNextHookEx(
+  HHOOK Hook,
+  int Code,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWindowsHookAW(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+HHOOK
+STDCALL
+NtUserSetWindowsHookEx(
+  HINSTANCE Mod,
+  PUNICODE_STRING UnsafeModuleName,
+  DWORD ThreadId,
+  int HookId,
+  HOOKPROC HookProc,
+  BOOL Ansi)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD
+STDCALL
+NtUserSetWinEventHook(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6,
+  DWORD Unknown7)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+BOOL
+STDCALL
+NtUserUnhookWindowsHookEx(
+  HHOOK Hook)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+DWORD
+STDCALL
+NtUserUnhookWinEvent(
+  DWORD Unknown0)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+/*
+ * Hot keys
+ */
+
+BOOL STDCALL
+NtUserRegisterHotKey(HWND hWnd,
+		     int id,
+		     UINT fsModifiers,
+		     UINT vk)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserUnregisterHotKey(HWND hWnd,
+		       int id)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * Menus
+ */
+
+DWORD
+STDCALL
+NtUserBuildMenuItemList(
+ HMENU hMenu,
+ VOID* Buffer,
+ ULONG nBufSize,
+ DWORD Reserved)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+DWORD STDCALL
+NtUserCheckMenuItem(
+  HMENU hmenu,
+  UINT uIDCheckItem,
+  UINT uCheck)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+HMENU STDCALL
+NtUserCreateMenu(BOOL PopupMenu)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserDeleteMenu(
+  HMENU hMenu,
+  UINT uPosition,
+  UINT uFlags)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserDestroyMenu(
+  HMENU hMenu)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+UINT STDCALL
+NtUserEnableMenuItem(
+  HMENU hMenu,
+  UINT uIDEnableItem,
+  UINT uEnable)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+DWORD STDCALL
+NtUserInsertMenuItem(
+  HMENU hMenu,
+  UINT uItem,
+  BOOL fByPosition,
+  LPCMENUITEMINFOW UnsafeItemInfo)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserEndMenu(VOID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+UINT STDCALL
+NtUserGetMenuDefaultItem(
+  HMENU hMenu,
+  UINT fByPos,
+  UINT gmdiFlags)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserGetMenuBarInfo(
+  HWND hwnd,
+  LONG idObject,
+  LONG idItem,
+  PMENUBARINFO pmbi)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+UINT STDCALL
+NtUserGetMenuIndex(
+  HMENU hMenu,
+  UINT wID)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserGetMenuItemRect(
+  HWND hWnd,
+  HMENU hMenu,
+  UINT uItem,
+  LPRECT lprcItem)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserHiliteMenuItem(
+  HWND hwnd,
+  HMENU hmenu,
+  UINT uItemHilite,
+  UINT uHilite)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL
+STDCALL
+NtUserMenuInfo(
+ HMENU Menu,
+ PROSMENUINFO UnsafeMenuInfo,
+ BOOL SetOrGet)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+int STDCALL
+NtUserMenuItemFromPoint(
+  HWND Wnd,
+  HMENU Menu,
+  DWORD X,
+  DWORD Y)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL
+STDCALL
+NtUserMenuItemInfo(
+ HMENU Menu,
+ UINT Item,
+ BOOL ByPosition,
+ PROSMENUITEMINFO UnsafeItemInfo,
+ BOOL SetOrGet)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserRemoveMenu(
+  HMENU hMenu,
+  UINT uPosition,
+  UINT uFlags)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserSetMenuContextHelpId(
+  HMENU hmenu,
+  DWORD dwContextHelpId)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserSetMenuDefaultItem(
+  HMENU hMenu,
+  UINT uItem,
+  UINT fByPos)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserSetMenuFlagRtoL(
+  HMENU hMenu)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+DWORD STDCALL
+NtUserThunkedMenuInfo(
+  HMENU hMenu,
+  LPCMENUINFO lpcmi)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+DWORD STDCALL
+NtUserThunkedMenuItemInfo(
+  HMENU hMenu,
+  UINT uItem,
+  BOOL fByPosition,
+  BOOL bInsert,
+  LPMENUITEMINFOW lpmii,
+  PUNICODE_STRING lpszCaption)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserTrackPopupMenuEx(
+  HMENU hmenu,
+  UINT fuFlags,
+  int x,
+  int y,
+  HWND hwnd,
+  LPTPMPARAMS lptpm)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * Messages
+ */
+
+
+DWORD
+STDCALL
+NtUserMessageCall(
+  DWORD Unknown0,
+  DWORD Unknown1,
+  DWORD Unknown2,
+  DWORD Unknown3,
+  DWORD Unknown4,
+  DWORD Unknown5,
+  DWORD Unknown6)
+{
+  UNIMPLEMENTED;
+  return 0;
+}
+
+
+BOOL STDCALL
+NtUserPostMessage(HWND Wnd,
+		  UINT Msg,
+		  WPARAM wParam,
+		  LPARAM lParam)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserPostThreadMessage(DWORD idThread,
+			UINT Msg,
+			WPARAM wParam,
+			LPARAM lParam)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+DWORD STDCALL
+NtUserQuerySendMessage(DWORD Unknown0)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+LRESULT STDCALL
+NtUserSendMessageTimeout(HWND hWnd,
+			 UINT Msg,
+			 WPARAM wParam,
+			 LPARAM lParam,
+			 UINT uFlags,
+			 UINT uTimeout,
+			 ULONG_PTR *uResult,
+	                 PNTUSERSENDMESSAGEINFO UnsafeInfo)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+LRESULT STDCALL
+NtUserSendMessage(HWND Wnd,
+		  UINT Msg,
+		  WPARAM wParam,
+		  LPARAM lParam,
+                  PNTUSERSENDMESSAGEINFO UnsafeInfo)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserSendMessageCallback(HWND hWnd,
+			  UINT Msg,
+			  WPARAM wParam,
+			  LPARAM lParam,
+			  SENDASYNCPROC lpCallBack,
+			  ULONG_PTR dwData)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL STDCALL
+NtUserSendNotifyMessage(HWND hWnd,
+			UINT Msg,
+			WPARAM wParam,
+			LPARAM lParam)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+DWORD STDCALL
+NtUserGetQueueStatus(BOOL ClearChanges)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+/*
+ * Painting
+ */
+
+
+BOOL STDCALL
+NtUserUpdateWindow(HWND hWnd)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL STDCALL
+NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
+   UINT flags)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * Scroll
+ */
+
+DWORD STDCALL
+NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
+   const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+DWORD STDCALL
+NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *rect,
+   const RECT *clipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL
+STDCALL
+NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL
+STDCALL
+NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+BOOL
+STDCALL
+NtUserEnableScrollBar(
+  HWND hWnd, 
+  UINT wSBflags, 
+  UINT wArrows)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+BOOL
+STDCALL
+NtUserSetScrollBarInfo(
+  HWND hwnd,
+  LONG idObject,
+  SETSCROLLBARINFO *info)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+DWORD
+STDCALL
+NtUserSetScrollInfo(
+  HWND hwnd, 
+  int fnBar, 
+  LPCSCROLLINFO lpsi, 
+  BOOL bRedraw)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+DWORD STDCALL
+NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+/*
+ * Properties
+ */
+
+NTSTATUS STDCALL
+NtUserBuildPropList(HWND hWnd,
+		    LPVOID Buffer,
+		    DWORD BufferSize,
+		    DWORD *Count)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+HANDLE STDCALL
+NtUserRemoveProp(HWND hWnd, ATOM Atom)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+HANDLE STDCALL
+NtUserGetProp(HWND hWnd, ATOM Atom)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+BOOL STDCALL
+NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * Timers
+ */
+
+UINT_PTR
+STDCALL
+NtUserSetTimer
+(
+ HWND hWnd,
+ UINT_PTR nIDEvent,
+ UINT uElapse,
+ TIMERPROC lpTimerFunc
+)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL
+STDCALL
+NtUserKillTimer
+(
+ HWND hWnd,
+ UINT_PTR uIDEvent
+)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+
+UINT_PTR
+STDCALL
+NtUserSetSystemTimer(
+ HWND hWnd,
+ UINT_PTR nIDEvent,
+ UINT uElapse,
+ TIMERPROC lpTimerFunc
+)
+{
+   UNIMPLEMENTED;
+   return 0;
+}
+
+
+BOOL
+STDCALL
+NtUserKillSystemTimer(
+ HWND hWnd,
+ UINT_PTR uIDEvent
+)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
+/*
+ * WinPos
+ */
+
+BOOL
+STDCALL
+NtUserGetMinMaxInfo(
+  HWND hwnd,
+  MINMAXINFO *MinMaxInfo,
+  BOOL SendMessage)
+{
+   UNIMPLEMENTED;
+   return FALSE;
+}
+
[truncated at 1000 lines; 512 more skipped]

reactos/subsys/win32k/ntuser
timer.c 1.33 -> 1.33.4.1
diff -u -r1.33 -r1.33.4.1
--- timer.c	29 Jun 2004 23:45:31 -0000	1.33
+++ timer.c	15 Jul 2004 20:07:18 -0000	1.33.4.1
@@ -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: timer.c,v 1.33 2004/06/29 23:45:31 navaraf Exp $
+/* $Id: timer.c,v 1.33.4.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -85,7 +85,7 @@
 
 //must hold mutex while calling this
 PMSG_TIMER_ENTRY FASTCALL
-IntRemoveTimer(HWND hWnd, UINT_PTR IDEvent, HANDLE ThreadID, BOOL SysTimer)
+IntRemoveTimer(PWINDOW_OBJECT Window, UINT_PTR IDEvent, HANDLE ThreadID, BOOL SysTimer)
 {
   PMSG_TIMER_ENTRY MsgTimer;
   PLIST_ENTRY EnumEntry;
@@ -97,7 +97,7 @@
     MsgTimer = CONTAINING_RECORD(EnumEntry, MSG_TIMER_ENTRY, ListEntry);
     EnumEntry = EnumEntry->Flink;
       
-    if (MsgTimer->Msg.hwnd == hWnd && 
+    if (MsgTimer->Msg.hwnd == (Window ? Window->Handle : NULL) && 
         MsgTimer->Msg.wParam == (WPARAM)IDEvent &&
         MsgTimer->ThreadID == ThreadID &&
         (MsgTimer->Msg.message == WM_SYSTIMER) == SysTimer)
@@ -148,7 +148,7 @@
  * NOTE: It doesn't kill the timer. It just removes them from the list.
  */
 VOID FASTCALL
-RemoveTimersWindow(HWND Wnd)
+RemoveTimersWindow(PWINDOW_OBJECT Window)
 {
   PMSG_TIMER_ENTRY MsgTimer;
   PLIST_ENTRY EnumEntry;
@@ -161,7 +161,7 @@
     MsgTimer = CONTAINING_RECORD(EnumEntry, MSG_TIMER_ENTRY, ListEntry);
     EnumEntry = EnumEntry->Flink;
     
-    if (MsgTimer->Msg.hwnd == Wnd)
+    if (MsgTimer->Msg.hwnd == Window->Handle)
     {
       RemoveEntryList(&MsgTimer->ListEntry);
       ExFreePool(MsgTimer);
@@ -173,20 +173,19 @@
 
 
 UINT_PTR FASTCALL
-IntSetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, BOOL SystemTimer)
+IntSetTimer(PWINDOW_OBJECT WindowObject, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, BOOL SystemTimer)
 {
   PMSG_TIMER_ENTRY MsgTimer = NULL;
   PMSG_TIMER_ENTRY NewTimer;
   LARGE_INTEGER CurrentTime;
-  PWINDOW_OBJECT WindowObject;
   HANDLE ThreadID;
   UINT_PTR Ret = 0;
- 
+  
   ThreadID = PsGetCurrentThreadId();
   KeQuerySystemTime(&CurrentTime);
   IntLockTimerList();
   
-  if((hWnd == NULL) && !SystemTimer)
+  if((WindowObject == NULL) && !SystemTimer)
   {
     /* find a free, window-less timer id */
     nIDEvent = RtlFindClearBitsAndSet(&WindowLessTimersBitMap, 1, HintIndex);
@@ -201,7 +200,6 @@
   }
   else
   {
-    WindowObject = IntGetWindowObject(hWnd);
     if(!WindowObject)
     {
       IntUnLockTimerList();
@@ -209,17 +207,15 @@
       return 0;
     }
     
-    if(WindowObject->OwnerThread != PsGetCurrentThread())
+    if(WindowObject->MessageQueue->Thread != PsGetCurrentThread())
     {
       IntUnLockTimerList();
-      IntReleaseWindowObject(WindowObject);
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return 0;
     }
-    IntReleaseWindowObject(WindowObject);
     
     /* remove timer if already in the queue */
-    MsgTimer = IntRemoveTimer(hWnd, nIDEvent, ThreadID, SystemTimer); 
+    MsgTimer = IntRemoveTimer(WindowObject, nIDEvent, ThreadID, SystemTimer); 
   }
   
   #if 1
@@ -260,7 +256,7 @@
       return 0;
     }
     
-    NewTimer->Msg.hwnd = hWnd;
+    NewTimer->Msg.hwnd = (WindowObject ? WindowObject->Handle : NULL);
     NewTimer->Msg.message = (SystemTimer ? WM_SYSTIMER : WM_TIMER);
     NewTimer->Msg.wParam = (WPARAM)nIDEvent;
     NewTimer->Msg.lParam = (LPARAM)lpTimerFunc;
@@ -284,15 +280,14 @@
 
 
 BOOL FASTCALL
-IntKillTimer(HWND hWnd, UINT_PTR uIDEvent, BOOL SystemTimer)
+IntKillTimer(PWINDOW_OBJECT WindowObject, UINT_PTR uIDEvent, BOOL SystemTimer)
 {
   PMSG_TIMER_ENTRY MsgTimer;
-  PWINDOW_OBJECT WindowObject;
   
   IntLockTimerList();
   
   /* window-less timer? */
-  if((hWnd == NULL) && !SystemTimer)
+  if((WindowObject == NULL) && !SystemTimer)
   {
     if(!RtlAreBitsSet(&WindowLessTimersBitMap, uIDEvent - 1, 1))
     {
@@ -305,24 +300,21 @@
   }
   else
   {
-    WindowObject = IntGetWindowObject(hWnd);
     if(!WindowObject)
     {
       IntUnLockTimerList(); 
       SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       return FALSE;
     }
-    if(WindowObject->OwnerThread != PsGetCurrentThread())
+    if(WindowObject->MessageQueue->Thread != PsGetCurrentThread())
     {
       IntUnLockTimerList();
-      IntReleaseWindowObject(WindowObject);
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return FALSE;
     }
-    IntReleaseWindowObject(WindowObject);
   }
   
-  MsgTimer = IntRemoveTimer(hWnd, uIDEvent, PsGetCurrentThreadId(), SystemTimer);
+  MsgTimer = IntRemoveTimer(WindowObject, uIDEvent, PsGetCurrentThreadId(), SystemTimer);
   
   IntUnLockTimerList();
   
@@ -473,54 +465,3 @@
   return Status;
 }
 
-
-UINT_PTR
-STDCALL
-NtUserSetTimer
-(
- HWND hWnd,
- UINT_PTR nIDEvent,
- UINT uElapse,
- TIMERPROC lpTimerFunc
-)
-{
-  return IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, FALSE);
-}
-
-
-BOOL
-STDCALL
-NtUserKillTimer
-(
- HWND hWnd,
- UINT_PTR uIDEvent
-)
-{
-  return IntKillTimer(hWnd, uIDEvent, FALSE);
-}
-
-
-UINT_PTR
-STDCALL
-NtUserSetSystemTimer(
- HWND hWnd,
- UINT_PTR nIDEvent,
- UINT uElapse,
- TIMERPROC lpTimerFunc
-)
-{
-  return IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, TRUE);
-}
-
-
-BOOL
-STDCALL
-NtUserKillSystemTimer(
- HWND hWnd,
- UINT_PTR uIDEvent
-)
-{
-  return IntKillTimer(hWnd, uIDEvent, TRUE);
-}
-
-/* EOF */

reactos/subsys/win32k/ntuser
vis.c 1.29 -> 1.29.12.1
diff -u -r1.29 -r1.29.12.1
--- vis.c	14 May 2004 16:48:47 -0000	1.29
+++ vis.c	15 Jul 2004 20:07:18 -0000	1.29.12.1
@@ -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: vis.c,v 1.29 2004/05/14 16:48:47 navaraf Exp $
+ * $Id: vis.c,v 1.29.12.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -77,9 +77,7 @@
     * our window.
     */
 
-   PreviousWindow = Window;
-   CurrentWindow = IntGetParentObject(Window);
-   while (CurrentWindow)
+   while ((CurrentWindow = IntGetParentObject(Window)))
    {
       if (!(CurrentWindow->Style & WS_VISIBLE))
       {
@@ -93,7 +91,6 @@
       if ((PreviousWindow->Style & WS_CLIPSIBLINGS) ||
           (PreviousWindow == Window && ClipSiblings))
       {
-         IntLockRelatives(CurrentWindow);
          CurrentSibling = CurrentWindow->FirstChild;
          while (CurrentSibling != NULL && CurrentSibling != PreviousWindow)
          {
@@ -112,19 +109,14 @@
             }
             CurrentSibling = CurrentSibling->NextSibling;
          }
-         IntUnLockRelatives(CurrentWindow);
       }
 
-      PreviousWindow = CurrentWindow;
       CurrentWindow = IntGetParentObject(CurrentWindow);
-      IntReleaseWindowObject(PreviousWindow);
    }
 
    if (ClipChildren)
    {
-      IntLockRelatives(Window);
-      CurrentWindow = Window->FirstChild;
-      while (CurrentWindow)
+      for (CurrentWindow = Window->FirstChild; CurrentWindow != NULL; CurrentWindow = CurrentWindow->NextSibling)
       {
          if (CurrentWindow->Style & WS_VISIBLE)
          {
@@ -139,9 +131,7 @@
             NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
             NtGdiDeleteObject(ClipRgn);
          }
-         CurrentWindow = CurrentWindow->NextSibling;
       }
-      IntUnLockRelatives(Window);
    }
    
    if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
@@ -176,7 +166,6 @@
      IntRedrawWindow(Parent, NULL, Temp,
                      RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | 
                      RDW_ALLCHILDREN);
-     IntReleaseWindowObject(Parent);
    }
    NtGdiDeleteObject(Temp);
 }

reactos/subsys/win32k/ntuser
windc.c 1.66 -> 1.66.12.1
diff -u -r1.66 -r1.66.12.1
--- windc.c	10 May 2004 17:07:18 -0000	1.66
+++ windc.c	15 Jul 2004 20:07:18 -0000	1.66.12.1
@@ -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: windc.c,v 1.66 2004/05/10 17:07:18 weiden Exp $
+/* $Id: windc.c,v 1.66.12.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -34,8 +34,6 @@
 #define NDEBUG
 #include <debug.h>
 
-#define DCX_USESTYLE 0x10000
-
 /* GLOBALS *******************************************************************/
 
 /* NOTE - I think we should store this per window station (including gdi objects) */
@@ -44,18 +42,6 @@
 static PDCE FirstDce = NULL;
 static HDC defaultDCstate;
 
-#if 0
-
-#define DCE_LockList() \
-  ExAcquireFastMutex(&DceListLock)
-#define DCE_UnlockList() \
-  ExReleaseFastMutex(&DceListLock)
-
-#else
-#define DCE_LockList()
-#define DCE_UnlockList()
-#endif
-
 #define DCX_CACHECOMPAREMASK (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | \
                               DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)
 
@@ -67,56 +53,23 @@
   ExInitializeFastMutex(&DceListLock);
 }
 
-HRGN STDCALL
-DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags)
+HRGN FASTCALL
+DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, PWINDOW_OBJECT Child, ULONG CFlags)
 {
-  PWINDOW_OBJECT Window;
   HRGN VisRgn;
 
-  Window = IntGetWindowObject(hWnd);
-
-  if (NULL == Window)
-    {
-      return NULL;
-    }
+  ASSERT(Window);
 
   VisRgn = VIS_ComputeVisibleRegion(Window,
                                     0 == (Flags & DCX_WINDOW),
                                     0 != (Flags & DCX_CLIPCHILDREN),
                                     0 != (Flags & DCX_CLIPSIBLINGS));
 
-  IntReleaseWindowObject(Window);
-
   return VisRgn;
 }
 
-/*
- * NtUserGetWindowDC
- *
- * The NtUserGetWindowDC function retrieves the device context (DC) for the
- * entire window, including title bar, menus, and scroll bars. A window device
- * context permits painting anywhere in a window, because the origin of the
- * device context is the upper-left corner of the window instead of the client
- * area. 
- *
- * Status
- *    @implemented
- */
-
-DWORD STDCALL
-NtUserGetWindowDC(HWND hWnd)
-{
-   return (DWORD)NtUserGetDCEx(hWnd, 0, DCX_USESTYLE | DCX_WINDOW);
-}
-
-HDC STDCALL
-NtUserGetDC(HWND hWnd)
-{
-   return NtUserGetDCEx(hWnd, NULL, NULL == hWnd ? DCX_CACHE | DCX_WINDOW : DCX_USESTYLE);
-}
-
 PDCE FASTCALL
-DceAllocDCE(HWND hWnd, DCE_TYPE Type)
+DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type)
 {
   HDCE DceHandle;
   DCE* Dce;
@@ -131,37 +84,32 @@
   Dce = DCEOBJ_LockDCE(DceHandle);
   /* No real locking, just get the pointer */
   DCEOBJ_UnlockDCE(DceHandle);
-  Dce->Self = DceHandle;
+  Dce->Handle = DceHandle;
   Dce->hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL);
   if (NULL == defaultDCstate)
     {
       defaultDCstate = NtGdiGetDCState(Dce->hDC);
       GDIOBJ_SetOwnership(defaultDCstate, NULL);
     }
-  Dce->hwndCurrent = hWnd;
+  Dce->CurrentWindow = Window;
   Dce->hClipRgn = NULL;
-  DCE_LockList();
+  
   Dce->next = FirstDce;
   FirstDce = Dce;
-  DCE_UnlockList();
 
   if (Type != DCE_CACHE_DC)
     {
       Dce->DCXFlags = DCX_DCEBUSY;
-      if (hWnd != NULL)
+      if (Window != NULL)
 	{
-	  PWINDOW_OBJECT WindowObject;
-
-	  WindowObject = IntGetWindowObject(hWnd);
-	  if (WindowObject->Style & WS_CLIPCHILDREN)
+	  if (Window->Style & WS_CLIPCHILDREN)
 	    {
 	      Dce->DCXFlags |= DCX_CLIPCHILDREN;
 	    }
-	  if (WindowObject->Style & WS_CLIPSIBLINGS)
+	  if (Window->Style & WS_CLIPSIBLINGS)
 	    {
 	      Dce->DCXFlags |= DCX_CLIPSIBLINGS;
 	    }
-	  IntReleaseWindowObject(WindowObject);
 	}
     }
   else
@@ -249,7 +197,7 @@
 	  /* don't keep around invalidated entries
 	   * because SetDCState() disables hVisRgn updates
 	   * by removing dirty bit. */
-	  dce->hwndCurrent = 0;
+	  dce->CurrentWindow = NULL;
 	  dce->DCXFlags &= DCX_CACHE;
 	  dce->DCXFlags |= DCX_DCEEMPTY;
 	}
@@ -285,7 +233,7 @@
       {
          DcxFlags = Flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW);
       }
-      hRgnVisible = DceGetVisRgn(Parent->Self, DcxFlags, Window->Self, Flags);
+      hRgnVisible = DceGetVisRgn(Parent, DcxFlags, Window, Flags);
       if (hRgnVisible == NULL)
       {
          hRgnVisible = NtGdiCreateRectRgn(0, 0, 0, 0);
@@ -310,11 +258,10 @@
    }
    else if (Window == NULL)
    {
-      DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+      DesktopWindow = IntGetDesktopWindow();
       if (NULL != DesktopWindow)
       {
-         hRgnVisible = UnsafeIntCreateRectRgnIndirect(&DesktopWindow->WindowRect);
-         IntReleaseWindowObject(DesktopWindow);
+         hRgnVisible = UnsafeIntCreateRectRgnIndirect(&DesktopWindow->WindowRect);;
       }
       else
       {
@@ -323,7 +270,7 @@
    }
    else
    {
-      hRgnVisible = DceGetVisRgn(Window->Self, Flags, 0, 0);
+      hRgnVisible = DceGetVisRgn(Window, Flags, 0, 0);
    }
 
 noparent:
@@ -346,23 +293,18 @@
    }
 }
 
-HDC STDCALL
-NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags)
+HDC FASTCALL
+IntGetDCEx(PWINDOW_OBJECT Window, HRGN ClipRegion, ULONG Flags)
 {
-  PWINDOW_OBJECT Window, Parent;
+  PWINDOW_OBJECT Parent;
   ULONG DcxFlags;
   DCE* Dce;
   BOOL UpdateVisRgn = TRUE;
   BOOL UpdateClipOrigin = FALSE;
 
-  if (NULL == hWnd)
+  if (NULL == Window)
     {
       Flags &= ~DCX_USESTYLE;
-      Window = NULL;
-    }
-  else if (NULL == (Window = IntGetWindowObject(hWnd)))
-    {
-      return(0);
     }
 
   if (NULL == Window || NULL == Window->Dce)
@@ -373,6 +315,8 @@
 
   if (Flags & DCX_USESTYLE)
     {
+      /* Window is always != NULL here! */
+      
       Flags &= ~(DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP);
 
       if (Window->Style & WS_CLIPSIBLINGS)
@@ -410,7 +354,7 @@
       Flags = (Flags & ~DCX_CLIPCHILDREN) | DCX_CACHE;
     }
 
-  Parent = (Window ? IntGetParentObject(Window) : NULL);
+  Parent = (Window ? Window->Parent : NULL);
   
   if (NULL == Window || !(Window->Style & WS_CHILD) || NULL == Parent)
     {
@@ -429,9 +373,6 @@
             }
         }
     }
-
-  if(Parent)
-    IntReleaseWindowObject(Parent);
   
   DcxFlags = Flags & DCX_CACHECOMPAREMASK;
 
@@ -439,8 +380,6 @@
     {
       DCE* DceEmpty = NULL;
       DCE* DceUnused = NULL;
-      
-      DCE_LockList();
 
       for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
 	{
@@ -451,7 +390,7 @@
 		{
 		  DceEmpty = Dce;
 		}
-	      else if (Dce->hwndCurrent == hWnd &&
+	      else if (Dce->CurrentWindow == Window &&
 		       ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags))
 		{
 #if 0 /* FIXME */
@@ -462,8 +401,6 @@
 		}
 	    }
 	}
-
-      DCE_UnlockList();
       
       if (Dce == NULL)
 	{
@@ -474,16 +411,16 @@
 	{
 	  Dce = DceAllocDCE(NULL, DCE_CACHE_DC);
 	}
-      else if (! GDIOBJ_OwnedByCurrentProcess(Dce->Self))
+      else if (! GDIOBJ_OwnedByCurrentProcess(Dce-> Handle))
         {
-          GDIOBJ_SetOwnership(Dce->Self, PsGetCurrentProcess());
+          GDIOBJ_SetOwnership(Dce->Handle, PsGetCurrentProcess());
           DC_SetOwnership(Dce->hDC, PsGetCurrentProcess());
         }
     }
   else
     {
       Dce = Window->Dce;
-      if (NULL != Dce && Dce->hwndCurrent == hWnd)
+      if (NULL != Dce && Dce->CurrentWindow == Window)
         {
           UpdateVisRgn = FALSE; /* updated automatically, via DCHook() */
         }
@@ -494,12 +431,10 @@
 
   if (NULL == Dce)
     {
-      if(NULL != Window)
-        IntReleaseWindowObject(Window);
       return(NULL);
     }
 
-  Dce->hwndCurrent = hWnd;
+  Dce->CurrentWindow = Window;
   Dce->DCXFlags = DcxFlags | (Flags & DCX_WINDOWPAINT) | DCX_DCEBUSY;
 
   if (0 == (Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && NULL != ClipRegion)
@@ -578,11 +513,6 @@
       DceUpdateVisRgn(Dce, Window, Flags);
     }
 
-  if (NULL != Window)
-    {
-      IntReleaseWindowObject(Window);
-    }
-
   return(Dce->hDC);
 }
 
@@ -591,7 +521,7 @@
 {
   PDCE PrevInList;
   
-  DCE_LockList();
+  /* FIXME - check global lock */
   
   if (Dce == FirstDce)
     {
@@ -610,41 +540,36 @@
 	}
       assert(NULL != PrevInList);
     }
-
-  DCE_UnlockList();
   
   return NULL != PrevInList;
 }
 
-HWND FASTCALL
+PWINDOW_OBJECT FASTCALL
 IntWindowFromDC(HDC hDc)
 {
   DCE *Dce;
   
-  DCE_LockList();
   for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
   {
     if(Dce->hDC == hDc)
     {
-      DCE_UnlockList();
-      return Dce->hwndCurrent;
+      return Dce->CurrentWindow;
     }
   }
-  DCE_UnlockList();
   return 0;
 }
 
-INT STDCALL
-NtUserReleaseDC(HWND hWnd, HDC hDc)
+INT FASTCALL
+IntReleaseDC(PWINDOW_OBJECT Window, HDC hDc)
 {
   DCE *dce;
   INT nRet = 0;
-
-  DCE_LockList();
+  
+  ASSERT(Window);
   
   dce = FirstDce;
 
-  DPRINT("%p %p\n", hWnd, hDc);
+  DPRINT("%p %p\n", Window->Handle, hDc);
 
   while (dce && (dce->hDC != hDc))
     {
@@ -656,8 +581,6 @@
       nRet = DceReleaseDC(dce);
     }
 
-  DCE_UnlockList();
-
   return nRet;
 }
 
@@ -687,7 +610,7 @@
       NtGdiDeleteObject(dce->hClipRgn);
     }
 
-  hDce = dce->Self;
+  hDce = dce->Handle;
   DCEOBJ_FreeDCE(hDce);
 
   return ret;
@@ -703,13 +626,11 @@
 DceFreeWindowDCE(PWINDOW_OBJECT Window)
 {
   DCE *pDCE;
-
-  DCE_LockList();
   
   pDCE = FirstDce;
   while (pDCE)
     {
-      if (pDCE->hwndCurrent == Window->Self)
+      if (pDCE->CurrentWindow == Window)
         {
           if (pDCE == Window->Dce) /* owned or Class DCE*/
             {
@@ -722,7 +643,7 @@
               else if (pDCE->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN))	/* Class DCE*/
 		{
                   DceDeleteClipRgn(pDCE);
-                  pDCE->hwndCurrent = 0;
+                  pDCE->CurrentWindow = NULL;
                 }
             }
           else
@@ -736,29 +657,26 @@
                    * We should change this to DPRINT when ReactOS is more stable
                    * (for 1.0?).
                    */
-                  DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->Self);
+                  DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->Handle);
                   DceReleaseDC(pDCE);
                 }
 
               pDCE->DCXFlags &= DCX_CACHE;
               pDCE->DCXFlags |= DCX_DCEEMPTY;
-              pDCE->hwndCurrent = 0;
+              pDCE->CurrentWindow = NULL;
             }
         }
       pDCE = pDCE->next;
     }
-    DCE_UnlockList();
 }
 
 void FASTCALL
 DceEmptyCache()
 {
-  DCE_LockList();
   while (FirstDce != NULL)
     {
       DceFreeDCE(FirstDce);
     }
-  DCE_UnlockList();
 }
 
 VOID FASTCALL 
@@ -772,39 +690,22 @@
     {
       return;
     }
-
-  DCE_LockList();
   
   pDCE = FirstDce;
   while (pDCE)
     {
       if (0 == (pDCE->DCXFlags & DCX_DCEEMPTY))
         {
-          if (Window->Self == pDCE->hwndCurrent)
-            {
-              CurrentWindow = Window;
-            }
-          else
-            {
-              CurrentWindow = IntGetWindowObject(pDCE->hwndCurrent);
-              if (NULL == CurrentWindow)
-                {
-                  pDCE = pDCE->next;
-                  continue;
-                }
-            }
-          dc = DC_LockDc(pDCE->hDC);
+          CurrentWindow = pDCE->CurrentWindow;
+          
+	  dc = DC_LockDc(pDCE->hDC);
           if (dc == NULL)
             {
-              if (Window->Self != pDCE->hwndCurrent)
-                {
-                  IntReleaseWindowObject(CurrentWindow);
-                }
               pDCE = pDCE->next;
               continue;
             }
           if ((0 != DeltaX || 0 != DeltaY)
-              && (Window == CurrentWindow || IntIsChildWindow(Window->Self, CurrentWindow->Self)))
+              && IntIsChildWindow(Window, CurrentWindow))
             {
               dc->w.DCOrgX += DeltaX;
               dc->w.DCOrgY += DeltaY;
@@ -820,17 +721,10 @@
           DC_UnlockDc(pDCE->hDC);
 
           DceUpdateVisRgn(pDCE, CurrentWindow, pDCE->DCXFlags);
-
-          if (Window->Self != pDCE->hwndCurrent)
-            {
-              IntReleaseWindowObject(CurrentWindow);
-            }
         }
       
       pDCE = pDCE->next;
     }
-  
-  DCE_UnlockList();
 }
 
 /* EOF */

reactos/subsys/win32k/ntuser
window.c 1.244 -> 1.244.2.1
diff -u -r1.244 -r1.244.2.1
--- window.c	14 Jul 2004 21:52:23 -0000	1.244
+++ window.c	15 Jul 2004 20:07:18 -0000	1.244.2.1
@@ -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: window.c,v 1.244 2004/07/14 21:52:23 sedwards Exp $
+/* $Id: window.c,v 1.244.2.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -26,7 +26,6 @@
  * REVISION HISTORY:
  *       06-06-2001  CSH  Created
  */
-/* INCLUDES ******************************************************************/
 #include <w32k.h>
 
 static WndProcHandle *WndProcHandlesArray = 0;
@@ -71,136 +70,26 @@
 
 /* HELPER FUNCTIONS ***********************************************************/
 
-/*
- * IntIsWindow
- *
- * The function determines whether the specified window handle identifies
- * an existing window. 
- *
- * Parameters
- *    hWnd 
- *       Handle to the window to test. 
- *
- * Return Value
- *    If the window handle identifies an existing window, the return value
- *    is TRUE. If the window handle does not identify an existing window,
- *    the return value is FALSE. 
- */
-
-BOOL FASTCALL
-IntIsWindow(HWND hWnd)
-{
-   PWINDOW_OBJECT Window;
-
-   if (!(Window = IntGetWindowObject(hWnd)))
-      return FALSE;
-   
-   IntReleaseWindowObject(Window);
-   return TRUE;
-}
-
-/*
- * IntGetProcessWindowObject
- *
- * Get window object from handle of specified process.
- */
-
-PWINDOW_OBJECT FASTCALL
-IntGetProcessWindowObject(PW32PROCESS ProcessData, HWND hWnd)
-{
-   PWINDOW_OBJECT WindowObject;
-   NTSTATUS Status;
-
-   Status = ObmReferenceObjectByHandle(ProcessData->WindowStation->HandleTable,
-      hWnd, otWindow, (PVOID*)&WindowObject);
-   if (!NT_SUCCESS(Status))
-   {
-      return NULL;
-   }
-   return WindowObject;
-}
-
 
 PWINDOW_OBJECT FASTCALL
 IntGetParent(PWINDOW_OBJECT Wnd)
 {
-  HWND hWnd;
-  
   if (Wnd->Style & WS_POPUP)
   {
-    IntLockRelatives(Wnd);
-    hWnd = Wnd->Owner;
-    IntUnLockRelatives(Wnd);
-    return IntGetWindowObject(hWnd);
+    return Wnd->Owner;
   }
   else if (Wnd->Style & WS_CHILD) 
   {
-    IntLockRelatives(Wnd);
-    hWnd = Wnd->Parent;
-    IntUnLockRelatives(Wnd);
-    return IntGetWindowObject(hWnd);
+    return Wnd->Parent;
   }
 
   return NULL;
 }
 
-
-PWINDOW_OBJECT FASTCALL
-IntGetParentObject(PWINDOW_OBJECT Wnd)
-{
-  HWND hParent;
-  
-  IntLockRelatives(Wnd);
-  hParent = Wnd->Parent;
-  IntUnLockRelatives(Wnd);
-  return IntGetWindowObject(hParent);
-}
-
-/*
- * IntWinListChildren
- *
- * Compile a list of all child window handles from given window.
- *
- * Remarks
- *    This function is similar to Wine WIN_ListChildren. The caller
- *    must free the returned list with ExFreePool.
- */
-
-HWND* FASTCALL
-IntWinListChildren(PWINDOW_OBJECT Window)
-{
-   PWINDOW_OBJECT Child;
-   HWND *List;
-   UINT Index, NumChildren = 0;
-
-   IntLockRelatives(Window);
-
-   for (Child = Window->FirstChild; Child; Child = Child->NextSibling)
-      ++NumChildren;
-  
-   List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), TAG_WINLIST);
-   if(!List)
-   {
-     DPRINT1("Failed to allocate memory for children array\n");
-     IntUnLockRelatives(Window);
-     SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-     return NULL;
-   }
-   for (Child = Window->FirstChild, Index = 0;
-        Child != NULL;
-        Child = Child->NextSibling, ++Index)
-      List[Index] = Child->Self;
-   List[Index] = NULL;
-
-   IntUnLockRelatives(Window);
-
-   return List;
-}
-
 /***********************************************************************
  *           IntSendDestroyMsg
  */
-static void IntSendDestroyMsg(HWND Wnd)
+static void IntSendDestroyMsg(PWINDOW_OBJECT Window)
 {
 #if 0 /* FIXME */
   GUITHREADINFO info;
@@ -217,7 +106,7 @@
   /*
    * Send the WM_DESTROY to the window.
    */
-  IntSendMessage(Wnd, WM_DESTROY, 0, 0);
+  IntSendMessage(Window, WM_DESTROY, 0, 0);
 
   /*
    * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
@@ -252,63 +141,60 @@
  *
  * Destroy storage associated to a window. "Internals" p.358
  */
-static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window,
-                                PW32PROCESS ProcessData,
-                                PW32THREAD ThreadData,
-                                BOOLEAN SendMessages)
+BOOL FASTCALL
+IntDestroyWindow(PWINDOW_OBJECT Window,
+                 PW32PROCESS ProcessData,
+                 PW32THREAD ThreadData,
+                 BOOL SendMessages)
 {
-  HWND *Children;
-  HWND *ChildHandle;
   PWINDOW_OBJECT Child;
+  #if 0
   PMENU_OBJECT Menu;
+  #endif
   BOOL BelongsToThreadData;
   
   ASSERT(Window);
-
-  RemoveTimersWindow(Window->Self);
   
-  IntLockThreadWindows(Window->OwnerThread->Win32Thread);
+  IntReferenceWindowObject(Window);
+  
+  RemoveTimersWindow(Window);
+  
   if(Window->Status & WINDOWSTATUS_DESTROYING)
   {
-    IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
+    IntReleaseWindowObject(Window);
     DPRINT("Tried to call IntDestroyWindow() twice\n");
-    return 0;
+    return FALSE;
   }
   Window->Status |= WINDOWSTATUS_DESTROYING;
   /* remove the window already at this point from the thread window list so we
      don't get into trouble when destroying the thread windows while we're still
      in IntDestroyWindow() */
   RemoveEntryList(&Window->ThreadListEntry);
-  IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
   
   BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
   
   if(SendMessages)
   {
     /* Send destroy messages */
-    IntSendDestroyMsg(Window->Self);
+    IntSendDestroyMsg(Window);
   }
 
   /* free child windows */
-  Children = IntWinListChildren(Window);
-  if (Children)
+  for(Child = Window->FirstChild; Child != NULL; Child = Child->NextSibling)
+  {
+    /* FIXME - Do this a safer way, make sure the windows don't get unlinked
+               while doing this loop and also make sure that no new windows
+               get linked into the list! */
+    if(!IntWndBelongsToThread(Child, ThreadData))
     {
-      for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
-        {
-          if ((Child = IntGetWindowObject(*ChildHandle)))
-            {
-              if(!IntWndBelongsToThread(Child, ThreadData))
-              {
-                /* send WM_DESTROY messages to windows not belonging to the same thread */
-                IntSendDestroyMsg(Child->Self);
-              }
-              else
-                IntDestroyWindow(Child, ProcessData, ThreadData, SendMessages);
-              IntReleaseWindowObject(Child);
-            }
-        }
-      ExFreePool(Children);
+      /* send WM_DESTROY messages to windows not belonging to the same thread */
+      IntSendDestroyMsg(Child);
     }
+    else
+    {
+      IntDestroyWindow(Child, ProcessData, ThreadData, SendMessages);
+    }
+  }
 
   if (SendMessages)
     {      
@@ -324,21 +210,29 @@
        * Send the WM_NCDESTROY to the window being destroyed.
        */
       if(BelongsToThreadData)
-        IntSendMessage(Window->Self, WM_NCDESTROY, 0, 0);
+      {
+        IntSendMessage(Window, WM_NCDESTROY, 0, 0);
+      }
     }
 
+  /* remove references in the message queue */
+  InterlockedCompareExchangePointer(&Window->MessageQueue->FocusWindow, NULL, Window);
+  InterlockedCompareExchangePointer(&Window->MessageQueue->ActiveWindow, NULL, Window);
+  InterlockedCompareExchangePointer(&Window->MessageQueue->CaptureWindow, NULL, Window);
+  InterlockedCompareExchangePointer(&Window->MessageQueue->MoveSize, NULL, Window);
+  InterlockedCompareExchangePointer(&Window->MessageQueue->MenuOwner, NULL, Window);
+
   /* reset shell window handles */
   if(ProcessData->WindowStation)
   {
-    if (Window->Self == ProcessData->WindowStation->ShellWindow)
-      ProcessData->WindowStation->ShellWindow = NULL;
-
-    if (Window->Self == ProcessData->WindowStation->ShellListView)
-      ProcessData->WindowStation->ShellListView = NULL;
+    InterlockedCompareExchangePointer(&ProcessData->WindowStation->ShellWindow, NULL, Window);
+    InterlockedCompareExchangePointer(&ProcessData->WindowStation->ShellListView, NULL, Window);
   }
   
+  #if 0
   /* Unregister hot keys */
   UnregisterWindowHotKeys (Window);
+  #endif
 
   /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
 
@@ -353,21 +247,7 @@
   TIMER_RemoveWindowTimers(Window->Self);
 #endif
   
-  if (!(Window->Style & WS_CHILD) && Window->IDMenu
-      && (Menu = IntGetMenuObject((HMENU)Window->IDMenu)))
-    {
-	IntDestroyMenuObject(Menu, TRUE, TRUE);
-	Window->IDMenu = 0;
-	IntReleaseMenuObject(Menu);
-    }
-  
-  if(Window->SystemMenu
-     && (Menu = IntGetMenuObject(Window->SystemMenu)))
-  {
-    IntDestroyMenuObject(Menu, TRUE, TRUE);
-    Window->SystemMenu = (HMENU)0;
-    IntReleaseMenuObject(Menu);
-  }
+  /* FIXME - delete menus and system menu */
   
   DceFreeWindowDCE(Window);    /* Always do this to catch orphaned DCs */
 #if 0 /* FIXME */
@@ -377,20 +257,15 @@
   
   IntUnlinkWindow(Window);
   
-  IntReferenceWindowObject(Window);
-  ObmCloseHandle(ProcessData->WindowStation->HandleTable, Window->Self);
+  ObmDeleteObject(ProcessData->WindowStation->HandleTable, Window);
   
   IntDestroyScrollBars(Window);
   
-  IntLockThreadWindows(Window->OwnerThread->Win32Thread);
   Window->Status |= WINDOWSTATUS_DESTROYED;
   /* don't remove the WINDOWSTATUS_DESTROYING bit */
-  IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
   
   /* remove the window from the class object */
-  IntLockClassWindows(Window->Class);
   RemoveEntryList(&Window->ClassListEntry);
-  IntUnLockClassWindows(Window->Class);
   
   /* dereference the class */
   ClassDereferenceObject(Window->Class);
@@ -403,6 +278,9 @@
   
   RtlFreeUnicodeString(&Window->WindowName);
   
+  /* remove the reference to the window station that had been increased in CreateWindow */
+  ObDereferenceObject(ProcessData->WindowStation);
+  
   IntReleaseWindowObject(Window);
 
   return 0;
@@ -413,20 +291,20 @@
 {
   if(HAS_DLGFRAME(WindowObject->Style, WindowObject->ExStyle) && !(WindowObject->Style & WS_MINIMIZE))
   {
-    *cx = NtUserGetSystemMetrics(SM_CXDLGFRAME);
-    *cy = NtUserGetSystemMetrics(SM_CYDLGFRAME);
+    *cx = IntGetSystemMetrics(SM_CXDLGFRAME);
+    *cy = IntGetSystemMetrics(SM_CYDLGFRAME);
   }
   else
   {
     if(HAS_THICKFRAME(WindowObject->Style, WindowObject->ExStyle)&& !(WindowObject->Style & WS_MINIMIZE))
     {
-      *cx = NtUserGetSystemMetrics(SM_CXFRAME);
-      *cy = NtUserGetSystemMetrics(SM_CYFRAME);
+      *cx = IntGetSystemMetrics(SM_CXFRAME);
+      *cy = IntGetSystemMetrics(SM_CYFRAME);
     }
     else if(HAS_THINFRAME(WindowObject->Style, WindowObject->ExStyle))
     {
-      *cx = NtUserGetSystemMetrics(SM_CXBORDER);
-      *cy = NtUserGetSystemMetrics(SM_CYBORDER);
+      *cx = IntGetSystemMetrics(SM_CXBORDER);
+      *cy = IntGetSystemMetrics(SM_CYBORDER);
     }
     else
     {
@@ -443,77 +321,13 @@
   pwi->rcClient = WindowObject->ClientRect;
   pwi->dwStyle = WindowObject->Style;
   pwi->dwExStyle = WindowObject->ExStyle;
-  pwi->dwWindowStatus = (NtUserGetForegroundWindow() == WindowObject->Self); /* WS_ACTIVECAPTION */
+  pwi->dwWindowStatus = (IntGetForegroundWindow() == WindowObject); /* WS_ACTIVECAPTION */
   IntGetWindowBorderMeasures(WindowObject, &pwi->cxWindowBorders, &pwi->cyWindowBorders);
   pwi->atomWindowType = (WindowObject->Class ? WindowObject->Class->Atom : 0);
   pwi->wCreatorVersion = 0x400; /* FIXME - return a real version number */
   return TRUE;
 }
 
-static BOOL FASTCALL
-IntSetMenu(
-   PWINDOW_OBJECT WindowObject,
-   HMENU Menu,
-   BOOL *Changed)
-{
-  PMENU_OBJECT OldMenuObject, NewMenuObject = NULL;
-
-  *Changed = (WindowObject->IDMenu != (UINT) Menu);
-  if (! *Changed)
-    {
-      return TRUE;
-    }
-
-  if (0 != WindowObject->IDMenu)
-    {
-      OldMenuObject = IntGetMenuObject((HMENU) WindowObject->IDMenu);
-      ASSERT(NULL == OldMenuObject || OldMenuObject->MenuInfo.Wnd == WindowObject->Self);
-    }
-  else
-    {
-      OldMenuObject = NULL;
-    }
-
-  if (NULL != Menu)
-    {
-      NewMenuObject = IntGetMenuObject(Menu);
-      if (NULL == NewMenuObject)
-        {
-          if (NULL != OldMenuObject)
-            {
-              IntReleaseMenuObject(OldMenuObject);
-            }
-          SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-          return FALSE;
-        }
-      if (NULL != NewMenuObject->MenuInfo.Wnd)
-        {
-          /* Can't use the same menu for two windows */
-          if (NULL != OldMenuObject)
-            {
-              IntReleaseMenuObject(OldMenuObject);
-            }
-          SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-          return FALSE;
-        }
- 
-    }
-
-  WindowObject->IDMenu = (UINT) Menu;
-  if (NULL != NewMenuObject)
-    {
-      NewMenuObject->MenuInfo.Wnd = WindowObject->Self;
-      IntReleaseMenuObject(NewMenuObject);
-    }
-  if (NULL != OldMenuObject)
-    {
-      OldMenuObject->MenuInfo.Wnd = NULL;
-      IntReleaseMenuObject(OldMenuObject);
-    }
-
-  return TRUE;
-}
-
 
 /* INTERNAL ******************************************************************/
 
@@ -527,10 +341,13 @@
   PWINDOW_OBJECT *List, *pWnd;
   ULONG Cnt = 0;
 
+  ASSERT(Thread);
+
   Win32Thread = Thread->Win32Thread;
   Win32Process = Thread->ThreadsProcess->Win32Process;
   
-  IntLockThreadWindows(Win32Thread);
+  /* FIXME - acquire lock */
+  
   Current = Win32Thread->WindowListHead.Flink;
   while (Current != &(Win32Thread->WindowListHead))
   {
@@ -544,7 +361,8 @@
     if(!List)
     {
       DPRINT("Not enough memory to allocate window handle list\n");
-      IntUnLockThreadWindows(Win32Thread);
+      
+      /* FIXME - unlock */
       return;
     }
     pWnd = List;
@@ -556,19 +374,23 @@
       pWnd++;
       Current = Current->Flink;
     }
-    IntUnLockThreadWindows(Win32Thread);
     *pWnd = NULL;
     
+    /* FIXME - unlock */
+    
     for(pWnd = List; *pWnd; pWnd++)
     {
-      NtUserDestroyWindow((*pWnd)->Self);
+      IntDestroyWindow(*pWnd, Win32Process, Win32Thread, FALSE /* FIXME - send messages? */);
+      /* FIXME - what happens here if the application calls ExitThread()/ExitProcess() ??? */
       IntReleaseWindowObject(*pWnd);
     }
     ExFreePool(List);
     return;
   }
-  
-  IntUnLockThreadWindows(Win32Thread);
+  else
+  {
+    /* FIXME - unlock */
+  }
 }
 
 
@@ -590,217 +412,53 @@
 }
 
 
-#if 0
-HWND FASTCALL
-IntGetFocusWindow(VOID)
-{
-  PUSER_MESSAGE_QUEUE Queue;
-  PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
-
-  if( !pdo )
-	return NULL;
-
-  Queue = (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
-
-  if (Queue == NULL)
-      return(NULL);
-  else
-      return(Queue->FocusWindow);
-}
-#endif
-
-PMENU_OBJECT FASTCALL
-IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu)
-{
-  PMENU_OBJECT MenuObject, NewMenuObject, SysMenuObject, ret = NULL;
-  PW32PROCESS W32Process;
-  HMENU NewMenu, SysMenu;
-  ROSMENUITEMINFO ItemInfo;
-
-  if(bRevert)
-  {
-    W32Process = PsGetWin32Process();
-    
-    if(!W32Process->WindowStation)
-      return NULL;
-      
-    if(WindowObject->SystemMenu)
-    {
-      MenuObject = IntGetMenuObject(WindowObject->SystemMenu);
-      if(MenuObject)
-      {
-        IntDestroyMenuObject(MenuObject, FALSE, TRUE);
-        WindowObject->SystemMenu = (HMENU)0;
-        IntReleaseMenuObject(MenuObject);
-      }
-    }
-      
-    if(W32Process->WindowStation->SystemMenuTemplate)
-    {
-      /* clone system menu */
-      MenuObject = IntGetMenuObject(W32Process->WindowStation->SystemMenuTemplate);
-      if(!MenuObject)
-        return NULL;
-
-      NewMenuObject = IntCloneMenu(MenuObject);
-      if(NewMenuObject)
-      {
-        WindowObject->SystemMenu = NewMenuObject->MenuInfo.Self;
-        NewMenuObject->MenuInfo.Flags |= MF_SYSMENU;
-        NewMenuObject->MenuInfo.Wnd = WindowObject->Self;
-        ret = NewMenuObject;
-        //IntReleaseMenuObject(NewMenuObject);
-      }
-      IntReleaseMenuObject(MenuObject);
-    }
-    else
-    {
-      SysMenu = NtUserCreateMenu(FALSE);
-      if (NULL == SysMenu)
-      {
-        return NULL;
-      }
-      SysMenuObject = IntGetMenuObject(SysMenu);
-      if (NULL == SysMenuObject)
-      {
-        NtUserDestroyMenu(SysMenu);
-        return NULL;
-      }
-      SysMenuObject->MenuInfo.Flags |= MF_SYSMENU;
-      SysMenuObject->MenuInfo.Wnd = WindowObject->Self;
-      NewMenu = IntLoadSysMenuTemplate();
-      if(!NewMenu)
-      {
-        IntReleaseMenuObject(SysMenuObject);
-        NtUserDestroyMenu(SysMenu);
-        return NULL;
-      }
-      MenuObject = IntGetMenuObject(NewMenu);
-      if(!MenuObject)
-      {
-        IntReleaseMenuObject(SysMenuObject);
-        NtUserDestroyMenu(SysMenu);
-        return NULL;
-      }
-      
-      NewMenuObject = IntCloneMenu(MenuObject);
-      if(NewMenuObject)
-      {
-        NewMenuObject->MenuInfo.Flags |= MF_SYSMENU | MF_POPUP;
-        IntReleaseMenuObject(NewMenuObject);
-	NtUserSetMenuDefaultItem(NewMenuObject->MenuInfo.Self, SC_CLOSE, FALSE);
-
-        ItemInfo.cbSize = sizeof(MENUITEMINFOW);
-        ItemInfo.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;
-        ItemInfo.fType = MF_POPUP;
-        ItemInfo.fState = MFS_ENABLED;
-        ItemInfo.dwTypeData = NULL;
-        ItemInfo.cch = 0;
-        ItemInfo.hSubMenu = NewMenuObject->MenuInfo.Self;
-        IntInsertMenuItem(SysMenuObject, (UINT) -1, TRUE, &ItemInfo);
-
-        WindowObject->SystemMenu = SysMenuObject->MenuInfo.Self;
-
-        ret = SysMenuObject;
-      }
-      IntDestroyMenuObject(MenuObject, FALSE, TRUE);
-      IntReleaseMenuObject(MenuObject);
-    }
-    if(RetMenu)
-      return ret;
-    else
-      return NULL;
-  }
-  else
-  {
-    if(WindowObject->SystemMenu)
-      return IntGetMenuObject((HMENU)WindowObject->SystemMenu);
-    else
-      return NULL;
-  }
-}
-
-
 BOOL FASTCALL
-IntIsChildWindow(HWND Parent, HWND Child)
+IntIsChildWindow(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Child)
 {
-  PWINDOW_OBJECT BaseWindow, Window, Old;
-  
-  if(!(BaseWindow = IntGetWindowObject(Child)))
-  {
-    return FALSE;
-  }
+  PWINDOW_OBJECT Window;
   
-  Window = BaseWindow;
+  Window = Child;
   while (Window)
   {
-    if (Window->Self == Parent)
+    if (Window == Parent)
     {
-      if(Window != BaseWindow)
-        IntReleaseWindowObject(Window);
-      IntReleaseWindowObject(BaseWindow);
-      return(TRUE);
+      /* FIXME - really return TRUE?! */
+      return TRUE;
     }
     if(!(Window->Style & WS_CHILD))
     {
-      if(Window != BaseWindow)
-        IntReleaseWindowObject(Window);
       break;
     }
-    Old = Window;
+    
     Window = IntGetParentObject(Window);
-    if(Old != BaseWindow)
-      IntReleaseWindowObject(Old);
   }
   
-  IntReleaseWindowObject(BaseWindow);
   return(FALSE);  
 }
 
 BOOL FASTCALL
-IntIsWindowVisible(HWND hWnd)
+IntIsWindowVisible(PWINDOW_OBJECT Wnd)
 {
-  PWINDOW_OBJECT BaseWindow, Window, Old;
+  PWINDOW_OBJECT Window;
   
-  if(!(BaseWindow = IntGetWindowObject(hWnd)))
-  {
-    return FALSE;
-  }
+  ASSERT(Wnd);
   
-  Window = BaseWindow;
+  Window = Wnd;
   while(Window)
   {
-    if(!(Window->Style & WS_CHILD))
-    {
-      break;
-    }
     if(!(Window->Style & WS_VISIBLE))
     {
-      if(Window != BaseWindow)
-        IntReleaseWindowObject(Window);
-      IntReleaseWindowObject(BaseWindow);
       return FALSE;
     }
-    Old = Window;
-    Window = IntGetParentObject(Window);
-    if(Old != BaseWindow)
-      IntReleaseWindowObject(Old);
-  }
-  
-  if(Window)
-  {
-    if(Window->Style & WS_VISIBLE)
+    if(!(Window->Style & WS_CHILD))
     {
-      if(Window != BaseWindow)
-        IntReleaseWindowObject(Window);
-      IntReleaseWindowObject(BaseWindow);
-      return TRUE;
+      break;
     }
-    if(Window != BaseWindow)
-      IntReleaseWindowObject(Window);
+    
+    Window = IntGetParentObject(Window);
   }
-  IntReleaseWindowObject(BaseWindow);
-  return FALSE;
+  
+  return (Window && (Window->Style & WS_VISIBLE));
 }
 
 
@@ -814,149 +472,114 @@
 {
   PWINDOW_OBJECT Parent;
   
-  IntLockRelatives(Wnd);
-  Wnd->Parent = WndParent->Self;
+  Wnd->Parent = WndParent;
   if ((Wnd->PrevSibling = WndPrevSibling))
   {
     /* link after WndPrevSibling */
     if ((Wnd->NextSibling = WndPrevSibling->NextSibling))
+    {
       Wnd->NextSibling->PrevSibling = Wnd;
-    else if ((Parent = IntGetWindowObject(Wnd->Parent)))
+    }
+    else if ((Parent = IntGetParentObject(Wnd)))
     {
-      IntLockRelatives(Parent);
-      if(Parent->LastChild == WndPrevSibling) 
+      if(Parent->LastChild == WndPrevSibling)
+      { 
         Parent->LastChild = Wnd;
-      IntUnLockRelatives(Parent);
-      IntReleaseWindowObject(Parent);
+      }
     }
     Wnd->PrevSibling->NextSibling = Wnd;
   }
   else
   {
     /* link at top */
-    Parent = IntGetWindowObject(Wnd->Parent);
-    if ((Wnd->NextSibling = WndParent->FirstChild)) 
+    Parent = IntGetParentObject(Wnd);
+    if ((Wnd->NextSibling = WndParent->FirstChild))
+    { 
       Wnd->NextSibling->PrevSibling = Wnd;
+    }
     else if (Parent)
     {
-      IntLockRelatives(Parent);
       Parent->LastChild = Wnd;
       Parent->FirstChild = Wnd;
-      IntUnLockRelatives(Parent);
-      IntReleaseWindowObject(Parent);
-      IntUnLockRelatives(Wnd);
       return;
     }
     if(Parent)
     {
-      IntLockRelatives(Parent);
       Parent->FirstChild = Wnd;
-      IntUnLockRelatives(Parent);
-      IntReleaseWindowObject(Parent);
     }
   }
-  IntUnLockRelatives(Wnd);
 }
 
-HWND FASTCALL
-IntSetOwner(HWND hWnd, HWND hWndNewOwner)
+PWINDOW_OBJECT FASTCALL
+IntSetOwner(PWINDOW_OBJECT Window, PWINDOW_OBJECT NewOwner)
 {
-  PWINDOW_OBJECT Wnd, WndOldOwner, WndNewOwner;
-  HWND ret;
-  
-  Wnd = IntGetWindowObject(hWnd);
-  if(!Wnd)
-    return NULL;
-  
-  IntLockRelatives(Wnd);
-  WndOldOwner = IntGetWindowObject(Wnd->Owner);
-  if (WndOldOwner)
-  {
-     ret = WndOldOwner->Self;
-     IntReleaseWindowObject(WndOldOwner);
-  }
-  else
-  {
-     ret = 0;
-  }
-  
-  if((WndNewOwner = IntGetWindowObject(hWndNewOwner)))
-  {
-    Wnd->Owner = hWndNewOwner;
-    IntReleaseWindowObject(WndNewOwner);
-  }
-  else
-    Wnd->Owner = NULL;
-  
-  IntUnLockRelatives(Wnd);
-  IntReleaseWindowObject(Wnd);
-  return ret;
+  ASSERT(Window);
+  return (PWINDOW_OBJECT)InterlockedExchange((LONG*)&Window->Owner, (LONG)NewOwner);
 }
 
 PWINDOW_OBJECT FASTCALL
-IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
+IntSetParent(PWINDOW_OBJECT Window, PWINDOW_OBJECT WndNewParent)
 {
    PWINDOW_OBJECT WndOldParent, Sibling, InsertAfter;
-   HWND hWnd, hWndNewParent, hWndOldParent;
    BOOL WasVisible;
+   #if 0
    BOOL MenuChanged;
+   #endif
    
-   ASSERT(Wnd);
+   ASSERT(Window);
    ASSERT(WndNewParent);
    
-   hWnd = Wnd->Self;
-   hWndNewParent = WndNewParent->Self;
-
    /*
     * Windows hides the window first, then shows it again
     * including the WM_SHOWWINDOW messages and all
     */
-   WasVisible = WinPosShowWindow(hWnd, SW_HIDE);
+   WasVisible = WinPosShowWindow(Window, SW_HIDE);
 
    /* Validate that window and parent still exist */
-   if (!IntIsWindow(hWnd) || !IntIsWindow(hWndNewParent))
+   if (!IntIsWindow(Window) || !IntIsWindow(WndNewParent))
+   {
       return NULL;
+   }
 
    /* Window must belong to current process */
-   if (Wnd->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+   if (!IntWndBelongsToThread(Window, PsGetWin32Thread()))
+   {
       return NULL;
+   }
 
-   WndOldParent = IntGetParentObject(Wnd);
-   hWndOldParent = (WndOldParent ? WndOldParent->Self : NULL);
+   WndOldParent = IntGetParentObject(Window);
 
    if (WndNewParent != WndOldParent)
    {
-      IntUnlinkWindow(Wnd);
+      IntUnlinkWindow(Window);
       InsertAfter = NULL;
-      if (0 == (Wnd->ExStyle & WS_EX_TOPMOST))
+      if (0 == (Window->ExStyle & WS_EX_TOPMOST))
       {
         /* Not a TOPMOST window, put after TOPMOSTs of new parent */
-        IntLockRelatives(WndNewParent);
         Sibling = WndNewParent->FirstChild;
         while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
         {
           InsertAfter = Sibling;
           Sibling = Sibling->NextSibling;
         }
-        IntUnLockRelatives(WndNewParent);
       }
       if (NULL == InsertAfter)
       {
-        IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
+        IntLinkWindow(Window, WndNewParent, InsertAfter /*prev sibling*/);
       }
       else
       {
-        IntReferenceWindowObject(InsertAfter);
-        IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
-        IntReleaseWindowObject(InsertAfter);
+        IntLinkWindow(Window, WndNewParent, InsertAfter /*prev sibling*/);
       }
 
-      if (WndNewParent->Self != IntGetDesktopWindow()) /* a child window */
+      if (WndNewParent != IntGetDesktopWindow()) /* a child window */
       {
-         if (!(Wnd->Style & WS_CHILD))
+         if (!(Window->Style & WS_CHILD))
          {
             //if ( Wnd->Menu ) DestroyMenu ( Wnd->menu );
-            IntSetMenu(Wnd, NULL, &MenuChanged);
+            #if 0
+	    IntSetMenu(Window, NULL, &MenuChanged);
+	    #endif
          }
       }
    }
@@ -966,7 +589,7 @@
     * in the z-order and send the expected WM_WINDOWPOSCHANGING and
     * WM_WINDOWPOSCHANGED notification messages.
     */
-   WinPosSetWindowPos(hWnd, (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST),
+   WinPosSetWindowPos(Window, (0 == (Window->ExStyle & WS_EX_TOPMOST) ? WINDOW_TOP : WINDOW_TOPMOST),
                       0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
                                 | (WasVisible ? SWP_SHOWWINDOW : 0));
 
@@ -979,47 +602,14 @@
     * Validate that the old parent still exist, since it migth have been
     * destroyed during the last callbacks to user-mode 
     */
-   if(WndOldParent)
+   if(WndOldParent && IntIsWindow(WndOldParent->Handle))
    {
-     if(!IntIsWindow(WndOldParent->Self))
-     {
-       IntReleaseWindowObject(WndOldParent);
-       return NULL;
-     }
-     
-     /* don't dereference the window object here, it must be done by the caller
-        of IntSetParent() */
      return WndOldParent;
    }
+   
    return NULL;
 }
 
-BOOL FASTCALL
-IntSetSystemMenu(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject)
-{
-  PMENU_OBJECT OldMenuObject;
-  if(WindowObject->SystemMenu)
-  {
-    OldMenuObject = IntGetMenuObject(WindowObject->SystemMenu);
-    if(OldMenuObject)
-    {
-      OldMenuObject->MenuInfo.Flags &= ~ MF_SYSMENU;
-      IntReleaseMenuObject(OldMenuObject);
-    }
-  }
-  
-  if(MenuObject)
-  {
-    /* FIXME check window style, propably return FALSE ? */
-    WindowObject->SystemMenu = MenuObject->MenuInfo.Self;
-    MenuObject->MenuInfo.Flags |= MF_SYSMENU;
-  }
-  else
-    WindowObject->SystemMenu = (HMENU)0;
-  
-  return TRUE;
-}
-
 
 /* unlink the window from siblings and parent. children are kept in place. */
 VOID FASTCALL
@@ -1027,11 +617,7 @@
 {
   PWINDOW_OBJECT WndParent;
   
-  IntLockRelatives(Wnd);
-  if((WndParent = IntGetWindowObject(Wnd->Parent)))
-  {
-    IntLockRelatives(WndParent);
-  }
+  WndParent = IntGetParentObject(Wnd);
[truncated at 1000 lines; 3479 more skipped]

reactos/subsys/win32k/ntuser
winpos.c 1.120 -> 1.120.2.1
diff -u -r1.120 -r1.120.2.1
--- winpos.c	14 Jul 2004 21:45:05 -0000	1.120
+++ winpos.c	15 Jul 2004 20:07:18 -0000	1.120.2.1
@@ -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: winpos.c,v 1.120 2004/07/14 21:45:05 navaraf Exp $
+/* $Id: winpos.c,v 1.120.2.1 2004/07/15 20:07:18 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -50,52 +50,23 @@
 /* FUNCTIONS *****************************************************************/
 
 BOOL FASTCALL
-IntGetClientOrigin(HWND hWnd, LPPOINT Point)
+IntGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point)
 {
-  PWINDOW_OBJECT WindowObject;
-  
-  WindowObject = IntGetWindowObject((hWnd ? hWnd : IntGetDesktopWindow()));
-  if (WindowObject == NULL)
-    {
-      Point->x = Point->y = 0;
-      return FALSE;
-    }
-  Point->x = WindowObject->ClientRect.left;
-  Point->y = WindowObject->ClientRect.top;
-  
-  IntReleaseWindowObject(WindowObject);
-  return TRUE;
-}
-
-BOOL STDCALL
-NtUserGetClientOrigin(HWND hWnd, LPPOINT Point)
-{
-  BOOL Ret;
-  POINT pt;
-  NTSTATUS Status;
-  
-  if(!Point)
+  if(Window == NULL)
   {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return FALSE;
+    Window = IntGetDesktopWindow();
   }
   
-  Ret = IntGetClientOrigin(hWnd, &pt);
-  
-  if(!Ret)
+  if(Window == NULL)
   {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
+     Point->x = Point->y = 0;
+     return FALSE;
   }
   
-  Status = MmCopyToCaller(Point, &pt, sizeof(POINT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
+  Point->x = Window->ClientRect.left;
+  Point->y = Window->ClientRect.top;
   
-  return Ret;
+  return TRUE;
 }
 
 /*******************************************************************
@@ -106,63 +77,45 @@
 VOID FASTCALL
 WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
 {
-  PWINDOW_OBJECT Wnd, Old;
+  PWINDOW_OBJECT Wnd;
   int TryTopmost;
   
   if (!Window || IntIsDesktopWindow(Window))
   {
-    IntSetFocusMessageQueue(NULL);
+    IntSetActiveMessageQueue(NULL);
     return;
   }
+  
   Wnd = Window;
   for(;;)
   {
-    HWND *List, *phWnd;
+    PWINDOW_OBJECT Child;
     
-    Old = Wnd;
-    Wnd = IntGetParentObject(Wnd);
-    if(Old != Window)
+    if(!(Wnd = IntGetParent(Wnd)))
     {
-      IntReleaseWindowObject(Old);
-    }
-    if(!Wnd)
-    {
-      IntSetFocusMessageQueue(NULL);
+      IntSetActiveMessageQueue(NULL);
       return;
     }
     
-    if((List = IntWinListChildren(Wnd)))
+    for(TryTopmost = 0; TryTopmost <= 1; TryTopmost++)
     {
-      for(TryTopmost = 0; TryTopmost <= 1; TryTopmost++)
+      for(Child = Wnd->FirstChild; Child != NULL; Child = Child->NextSibling)
       {
-        for(phWnd = List; *phWnd; phWnd++)
+        if(Child == Window)
         {
-          PWINDOW_OBJECT Child;
-        
-          if((*phWnd) == Window->Self)
-          {
-            continue;
-          }
+          /* skip own window */
+	  continue;
+        }
         
-          if((Child = IntGetWindowObject(*phWnd)))
-          {
-            if(((! TryTopmost && (0 == (Child->ExStyle & WS_EX_TOPMOST)))
-                || (TryTopmost && (0 != (Child->ExStyle & WS_EX_TOPMOST))))
-               && IntSetForegroundWindow(Child))
+	if(((! TryTopmost && (0 == (Child->ExStyle & WS_EX_TOPMOST)))
+            || (TryTopmost && (0 != (Child->ExStyle & WS_EX_TOPMOST))))
+           && IntSetForegroundWindow(Child))
             {
-              ExFreePool(List);
-              IntReleaseWindowObject(Wnd);
-              IntReleaseWindowObject(Child);
               return;
             }
-            IntReleaseWindowObject(Child);
-          }
-        }
       }
-      ExFreePool(List);
     }
   }
-  IntReleaseWindowObject(Wnd);
 }
 
 VOID STATIC FASTCALL
@@ -182,14 +135,13 @@
       RECT WorkArea;
       PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; /* Or rather get it from the window? */
       
-      Parent = IntGetParentObject(WindowObject);
+      Parent = IntGetParent(WindowObject);
       if(Parent)
       {
         if(IntIsDesktopWindow(Parent))
           IntGetDesktopWorkArea(Desktop, &WorkArea);
         else
           WorkArea = Parent->ClientRect;
-        IntReleaseWindowObject(Parent);
       }
       else
         IntGetDesktopWorkArea(Desktop, &WorkArea);
@@ -197,7 +149,7 @@
       WindowObject->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
       if(!WindowObject->InternalPos)
       {
-        DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", WindowObject->Self);
+        DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", WindowObject->Handle);
         return NULL;
       }
       WindowObject->InternalPos->NormalRect = WindowObject->WindowRect;
@@ -219,7 +171,7 @@
     {
       WindowObject->InternalPos->NormalRect = *RestoreRect;
     }
-  return(WindowObject->InternalPos);
+  return WindowObject->InternalPos;
 }
 
 UINT FASTCALL
@@ -238,7 +190,7 @@
     {
       if (WindowObject->Style & WS_MINIMIZE)
 	{
-	  if (!IntSendMessage(WindowObject->Self, WM_QUERYOPEN, 0, 0))
+	  if (!IntSendMessage(WindowObject, WM_QUERYOPEN, 0, 0))
 	    {
 	      return(SWP_NOSIZE | SWP_NOMOVE);
 	    }
@@ -368,7 +320,7 @@
   
   WinPosFillMinMaxInfoStruct(Window, &MinMax);
   
-  IntSendMessage(Window->Self, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
+  IntSendMessage(Window, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
 
   MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
 				MinMax.ptMinTrackSize.x);
@@ -420,13 +372,55 @@
     }
 }
 
+VOID STATIC FASTCALL
+InternalWindowPosToWinPosStructure(PWINDOWPOS WinPos, PINTERNAL_WINDOWPOS WindowPos)
+{
+  /* convert the PWINDOW_OBJECTs to HWNDs or HWND_* constants */
+  WinPos->hwnd = (HWNDValidateWindowObject(WindowPos->Window) ? WindowPos->Window->Handle : WindowPos->Window);
+  WinPos->hwndInsertAfter = (HWNDValidateWindowObject(WindowPos->InsertAfter) ? WindowPos->InsertAfter->Handle : WindowPos->InsertAfter);
+  WinPos->x = WinPos->x;
+  WinPos->y = WinPos->y;
+  WinPos->cx = WinPos->cx;
+  WinPos->cy = WinPos->cy;
+  WinPos->flags = WinPos->flags;
+}
+
+VOID STATIC FASTCALL
+WinPosToInternalWindowPosStructure(PINTERNAL_WINDOWPOS WindowPos, PWINDOWPOS WinPos)
+{
+  /* convert the HWNDs to PWINDOW_OBJECTs or WINDOW_* constants */
+  if(HWNDValidateWindowObject(WinPos->hwnd))
+  {
+    WindowPos->Window = IntGetUserObject(WINDOW, WinPos->hwnd);
+  }
+  else
+  {
+    WindowPos->Window = (PWINDOW_OBJECT)WinPos->hwnd;
+  }
+  if(HWNDValidateWindowObject(WinPos->hwndInsertAfter))
+  {
+    WindowPos->InsertAfter = IntGetUserObject(WINDOW, WinPos->hwndInsertAfter);
+  }
+  else
+  {
+    WindowPos->InsertAfter = (PWINDOW_OBJECT)WinPos->hwndInsertAfter;
+  }
+  WindowPos->x = WinPos->x;
+  WindowPos->y = WinPos->y;
+  WindowPos->cx = WinPos->cx;
+  WindowPos->cy = WinPos->cy;
+  WindowPos->flags = WinPos->flags;
+}
+
 LONG STATIC FASTCALL
-WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
+WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PINTERNAL_WINDOWPOS WinPos,
 		   RECT* WindowRect, RECT* ClientRect)
 {
   PWINDOW_OBJECT Parent;
   UINT wvrFlags = 0;
 
+  ASSERT(Window);
+
   /* Send WM_NCCALCSIZE message to get new client area */
   if ((WinPos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE)
     {
@@ -436,8 +430,8 @@
       params.rgrc[0] = *WindowRect;
       params.rgrc[1] = Window->WindowRect;
       params.rgrc[2] = Window->ClientRect;
-      Parent = IntGetParentObject(Window);
-      if (0 != (Window->Style & WS_CHILD) && Parent)
+      Parent = IntGetParent(Window);
+      if (0 != (Window->Style & WS_CHILD) && Parent != NULL)
 	{
 	  NtGdiOffsetRect(&(params.rgrc[0]), - Parent->ClientRect.left,
 	                      - Parent->ClientRect.top);
@@ -447,9 +441,10 @@
 	                      - Parent->ClientRect.top);
 	}
       params.lppos = &winposCopy;
-      winposCopy = *WinPos;
+      
+      InternalWindowPosToWinPosStructure(&winposCopy, WinPos);
 
-      wvrFlags = IntSendMessage(Window->Self, WM_NCCALCSIZE, TRUE, (LPARAM) &params);
+      wvrFlags = IntSendMessage(Window, WM_NCCALCSIZE, TRUE, (LPARAM) &params);
 
       /* If the application send back garbage, ignore it */
       if (params.rgrc[0].left <= params.rgrc[0].right &&
@@ -479,8 +474,6 @@
 	{
           WinPos->flags &= ~SWP_NOCLIENTSIZE;
 	}
-	  if(Parent)
-	    IntReleaseWindowObject(Parent);
     }
   else
     {
@@ -497,7 +490,7 @@
 
 BOOL FASTCALL
 WinPosDoWinPosChanging(PWINDOW_OBJECT WindowObject,
-		       PWINDOWPOS WinPos,
+		       PINTERNAL_WINDOWPOS WinPos,
 		       PRECT WindowRect,
 		       PRECT ClientRect)
 {
@@ -505,7 +498,10 @@
 
   if (!(WinPos->flags & SWP_NOSENDCHANGING))
     {
-      IntSendMessage(WindowObject->Self, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
+      WINDOWPOS winposCopy;
+      InternalWindowPosToWinPosStructure(&winposCopy, WinPos);
+      IntSendMessage(WindowObject, WM_WINDOWPOSCHANGING, 0, (LPARAM) &winposCopy);
+      WinPosToInternalWindowPosStructure(WinPos, &winposCopy);
     }
   
   *WindowRect = WindowObject->WindowRect;
@@ -520,23 +516,23 @@
   if (!(WinPos->flags & SWP_NOMOVE))
     {
       PWINDOW_OBJECT Parent;
+      
       X = WinPos->x;
       Y = WinPos->y;
-      Parent = IntGetParentObject(WindowObject);
-      if ((0 != (WindowObject->Style & WS_CHILD)) && Parent)
+      
+      if ((0 != (WindowObject->Style & WS_CHILD)) && (Parent = IntGetParent(WindowObject)))
 	{
 	  X += Parent->ClientRect.left;
 	  Y += Parent->ClientRect.top;
 	}
-	  if(Parent)
-	    IntReleaseWindowObject(Parent);
+	
       WindowRect->left = X;
       WindowRect->top = Y;
       WindowRect->right += X - WindowObject->WindowRect.left;
       WindowRect->bottom += Y - WindowObject->WindowRect.top;
       NtGdiOffsetRect(ClientRect,
-        X - WindowObject->WindowRect.left,
-        Y - WindowObject->WindowRect.top);
+                      X - WindowObject->WindowRect.left,
+                      Y - WindowObject->WindowRect.top);
     }
 
   WinPos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
@@ -548,79 +544,78 @@
  * Fix Z order taking into account owned popups -
  * basically we need to maintain them above the window that owns them
  */
-HWND FASTCALL
-WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
+PWINDOW_OBJECT FASTCALL
+WinPosDoOwnedPopups(PWINDOW_OBJECT Window, PWINDOW_OBJECT InsertAfter)
 {
-   HWND *List = NULL;
-   HWND Owner = NtUserGetWindow(hWnd, GW_OWNER);
-   LONG Style = NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE);
-   PWINDOW_OBJECT DesktopWindow, ChildObject;
-   int i;
+   LONG Style;
+   PWINDOW_OBJECT DesktopWindow, Current;
+   BOOL Searched = FALSE;
 
-   if ((Style & WS_POPUP) && Owner)
+   ASSERT(Window);
+   
+   Style = Window->Style;
+
+   if ((Style & WS_POPUP) && Window->Owner)
    {
       /* Make sure this popup stays above the owner */
-      HWND hWndLocalPrev = HWND_TOPMOST;
+      PWINDOW_OBJECT LocalPrev = WINDOW_TOPMOST;
 
-      if (hWndInsertAfter != HWND_TOPMOST)
+      if (InsertAfter != WINDOW_TOPMOST)
       {
-         DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-         List = IntWinListChildren(DesktopWindow);
-         IntReleaseWindowObject(DesktopWindow);
-         if (List != NULL)
+	 DesktopWindow = IntGetDesktopWindow();
+         
+         for(Current = DesktopWindow->FirstChild; Current != NULL;
+             Current = Current->NextSibling)
          {
-            for (i = 0; List[i]; i++)
-            {
-               if (List[i] == Owner) break;
-               if (HWND_TOP == hWndInsertAfter)
-               {
-                 ChildObject = IntGetWindowObject(List[i]);
-                 if (NULL != ChildObject)
-                 {
-                   if (0 == (ChildObject->ExStyle & WS_EX_TOPMOST))
-                   {
-                     IntReleaseWindowObject(ChildObject);
-                     break;
-                   }
-                   IntReleaseWindowObject(ChildObject);
-                 }
-               }
-               if (List[i] != hWnd) hWndLocalPrev = List[i];
-               if (hWndLocalPrev == hWndInsertAfter) break;
-            }
-            hWndInsertAfter = hWndLocalPrev;
+           Searched = TRUE;
+           
+	   if(Current == Window->Owner)
+           {
+             break;
+           }
+           if(WINDOW_TOP == InsertAfter)
+           {
+             if (0 == (Current->ExStyle & WS_EX_TOPMOST))
+             {
+               break;
+             }
+           }
+           if(Current != Window)
+           {
+             LocalPrev = Current;
+           }
+           if(LocalPrev == InsertAfter)
+           {
+             break;
+           }
          }
       }
    }
    else if (Style & WS_CHILD)
    {
-      return hWndInsertAfter;
+      return InsertAfter;
    }
 
-   if (!List)
-   {
-      DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-      List = IntWinListChildren(DesktopWindow);
-      IntReleaseWindowObject(DesktopWindow);
-   }
-   if (List != NULL)
+   if (!Searched)
    {
-      for (i = 0; List[i]; i++)
+      for(Current = DesktopWindow->FirstChild; Current != NULL;
+          Current = Current->NextSibling)
       {
-         if (List[i] == hWnd)
-            break;
-         if ((NtUserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) &&
-             NtUserGetWindow(List[i], GW_OWNER) == hWnd)
-         {
-            WinPosSetWindowPos(List[i], hWndInsertAfter, 0, 0, 0, 0,
-               SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
-            hWndInsertAfter = List[i];
-         }
+        if(Current == Window)
+        {
+          break;
+        }
+        
+        if(Current->Style & WS_POPUP && Current->Owner == Window)
+        {
+          WinPosSetWindowPos(Current, InsertAfter, 0, 0, 0, 0,
+                             SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
+	  InsertAfter = Current;
+        }
       }
-      ExFreePool(List);
    }
 
-   return hWndInsertAfter;
+   return InsertAfter;
 }
 
 /***********************************************************************
@@ -644,12 +639,10 @@
    Window->ClientRect.top += MoveY;
    Window->ClientRect.bottom += MoveY;
    
-   IntLockRelatives(Window);
    for(Child = Window->FirstChild; Child; Child = Child->NextSibling)
    {
      WinPosInternalMoveWindow(Child, MoveX, MoveY);
    }
-   IntUnLockRelatives(Window);
 }
 
 /*
@@ -659,7 +652,7 @@
  */
 
 BOOL FASTCALL
-WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
+WinPosFixupFlags(PWINDOW_OBJECT Window, INTERNAL_WINDOWPOS *WinPos)
 {
    if (Window->Style & WS_VISIBLE)
    {
@@ -689,7 +682,7 @@
       WinPos->flags |= SWP_NOMOVE;    
    }
 
-   if (WinPos->hwnd == NtUserGetForegroundWindow())
+   if (WinPos->Window == IntGetForegroundWindow())
    {
       WinPos->flags |= SWP_NOACTIVATE;   /* Already active */
    }
@@ -700,8 +693,8 @@
       if (!(WinPos->flags & SWP_NOACTIVATE)) 
       {
          WinPos->flags &= ~SWP_NOZORDER;
-         WinPos->hwndInsertAfter = (0 != (Window->ExStyle & WS_EX_TOPMOST) ?
-                                    HWND_TOPMOST : HWND_TOP);
+         WinPos->InsertAfter = (0 != (Window->ExStyle & WS_EX_TOPMOST) ?
+                                WINDOW_TOPMOST : WINDOW_TOP);
          return TRUE;
       }
    }
@@ -710,51 +703,50 @@
    if (!(WinPos->flags & SWP_NOZORDER))
    {
       /* Fix sign extension */
-      if (WinPos->hwndInsertAfter == (HWND)0xffff)
+      if (WinPos->InsertAfter == (PWINDOW_OBJECT)0xffff)
       {
-         WinPos->hwndInsertAfter = HWND_TOPMOST;
+         WinPos->InsertAfter = WINDOW_TOPMOST;
       }
-      else if (WinPos->hwndInsertAfter == (HWND)0xfffe)
+      else if (WinPos->InsertAfter == (PWINDOW_OBJECT)0xfffe)
       {
-         WinPos->hwndInsertAfter = HWND_NOTOPMOST;
+         WinPos->InsertAfter = WINDOW_NOTOPMOST;
       }
 
-      if (WinPos->hwndInsertAfter == HWND_NOTOPMOST)
+      if (WinPos->InsertAfter == WINDOW_NOTOPMOST)
       {
-         WinPos->hwndInsertAfter = HWND_TOP;
+         WinPos->InsertAfter = WINDOW_TOP;
       }
-      else if (HWND_TOP == WinPos->hwndInsertAfter
+      else if (WINDOW_TOP == WinPos->InsertAfter
                && 0 != (Window->ExStyle & WS_EX_TOPMOST))
       {
          /* Keep it topmost when it's already topmost */
-         WinPos->hwndInsertAfter = HWND_TOPMOST;
+         WinPos->InsertAfter = WINDOW_TOPMOST;
       }
 
       /* hwndInsertAfter must be a sibling of the window */
-      if (HWND_TOPMOST != WinPos->hwndInsertAfter
-          && HWND_TOP != WinPos->hwndInsertAfter
-          && HWND_NOTOPMOST != WinPos->hwndInsertAfter
-          && HWND_BOTTOM != WinPos->hwndInsertAfter)
-      {
-         PWINDOW_OBJECT Parent = IntGetParentObject(Window);
-         if (NtUserGetAncestor(WinPos->hwndInsertAfter, GA_PARENT) !=
-             (Parent ? Parent->Self : NULL))
+      if (WINDOW_TOPMOST != WinPos->InsertAfter
+          && WINDOW_TOP != WinPos->InsertAfter
+          && WINDOW_NOTOPMOST != WinPos->InsertAfter
+          && WINDOW_BOTTOM != WinPos->InsertAfter)
+      {
+         /* WARNING!!! The handle values in WinPos are NOT handles, they're PWINDOW_OBJECTs! */
+         
+	 if ((WinPos->InsertAfter ? IntGetParent(WinPos->InsertAfter) : NULL) != IntGetParent(Window->Parent))
          {
-            if(Parent)
-              IntReleaseWindowObject(Parent);
             return FALSE;
          }
          else
          {
-            if(Parent)
-              IntReleaseWindowObject(Parent);
             /*
              * We don't need to change the Z order of hwnd if it's already
              * inserted after hwndInsertAfter or when inserting hwnd after
              * itself.
              */
-            if ((WinPos->hwnd == WinPos->hwndInsertAfter) ||
-                (WinPos->hwnd == NtUserGetWindow(WinPos->hwndInsertAfter, GW_HWNDNEXT)))
+            
+            /* WARNING!!! The handle values in WinPos are NOT handles, they're PWINDOW_OBJECTs! */
+            
+            if ((WinPos->Window == WinPos->InsertAfter) ||
+                (WinPos->Window == (WinPos->InsertAfter ? (WinPos->InsertAfter)->NextSibling : NULL)))
             {
                WinPos->flags |= SWP_NOZORDER;
             }
@@ -767,11 +759,10 @@
 
 /* x and y are always screen relative */
 BOOLEAN FASTCALL
-WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx,
+WinPosSetWindowPos(PWINDOW_OBJECT Window, PWINDOW_OBJECT InsertAfter, INT x, INT y, INT cx,
 		   INT cy, UINT flags)
 {
-   PWINDOW_OBJECT Window;
-   WINDOWPOS WinPos;
+   INTERNAL_WINDOWPOS WinPos;
    RECT NewWindowRect;
    RECT NewClientRect;
    PROSRGNDATA VisRgn;
@@ -789,25 +780,20 @@
 
    /* FIXME: Get current active window from active queue. */
 
-   Window = IntGetWindowObject(Wnd);
-   if (!Window)
-   {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return FALSE;
-   }
+   ASSERT(Window);
 
    /*
     * Only allow CSRSS to mess with the desktop window
     */
-   if (Wnd == IntGetDesktopWindow() &&
-       Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+   if (Window == IntGetDesktopWindow() &&
+       Window->MessageQueue->Thread->ThreadsProcess != PsGetCurrentProcess())
    {
       IntReleaseWindowObject(Window);
       return FALSE;
    }
 
-   WinPos.hwnd = Wnd;
-   WinPos.hwndInsertAfter = WndInsertAfter;
+   WinPos.Window = Window;
+   WinPos.InsertAfter = InsertAfter;
    WinPos.x = x;
    WinPos.y = y;
    WinPos.cx = cx;
@@ -817,26 +803,28 @@
    WinPosDoWinPosChanging(Window, &WinPos, &NewWindowRect, &NewClientRect);
 
    /* Fix up the flags. */
-   if (!WinPosFixupFlags(&WinPos, Window))
+   
+   /* WARNING!!! The handle values in the WINDOWPOS are wither HWND_* constants
+                 of PWINDOW_OBJECTs! They're not Handles! */
+   
+   if (!WinPosFixupFlags(Window, &WinPos))
    {
-      IntReleaseWindowObject(Window);
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return FALSE;
    }
 
    /* Does the window still exist? */
-   if (!IntIsWindow(WinPos.hwnd))
+   if (!IntIsWindow(Window))
    {
-      IntReleaseWindowObject(Window);
       SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       return FALSE;
    }
 
    if ((WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) !=
-       SWP_NOZORDER &&
-       NtUserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow())
+       SWP_NOZORDER && (HWNDValidateWindowObject(WinPos.Window) ? WinPos.Window->Parent == IntGetDesktopWindow() : FALSE))
    {
-      WinPos.hwndInsertAfter = WinPosDoOwnedPopups(WinPos.hwnd, WinPos.hwndInsertAfter);
+      /* WARNING!!! The handle values in WinPos are NOT handles, they're PWINDOW_OBJECTs! */
+      WinPos.InsertAfter = WinPosDoOwnedPopups(WinPos.Window, WinPos.InsertAfter);
    }
   
    /* Compute the visible region before the window position is changed */
@@ -864,49 +852,41 @@
    WvrFlags = WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect);
 
    /* Relink windows. (also take into account shell window in hwndShellWindow) */
-   if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != NtUserGetShellWindow())
+   if (!(WinPos.flags & SWP_NOZORDER) && WinPos.Window != IntGetShellWindow())
    {
       PWINDOW_OBJECT ParentWindow;
       PWINDOW_OBJECT Sibling;
       PWINDOW_OBJECT InsertAfterWindow;
 
-      if ((ParentWindow = IntGetParentObject(Window)))
+      if ((ParentWindow = IntGetParent(Window)))
       {
-         if (HWND_TOPMOST == WinPos.hwndInsertAfter)
+         if (WINDOW_TOPMOST == WinPos.InsertAfter)
          {
             InsertAfterWindow = NULL;
          }
-         else if (HWND_TOP == WinPos.hwndInsertAfter
-                  || HWND_NOTOPMOST == WinPos.hwndInsertAfter)
+         else if (WINDOW_TOP == WinPos.InsertAfter
+                  || WINDOW_NOTOPMOST == WinPos.InsertAfter)
          {
             InsertAfterWindow = NULL;
-            IntLockRelatives(ParentWindow);
+            
             Sibling = ParentWindow->FirstChild;
             while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
             {
                InsertAfterWindow = Sibling;
                Sibling = Sibling->NextSibling;
             }
-            if (NULL != InsertAfterWindow)
-            {
-              IntReferenceWindowObject(InsertAfterWindow);
-            }
-            IntUnLockRelatives(ParentWindow);
          }
-         else if (WinPos.hwndInsertAfter == HWND_BOTTOM)
+         else if (WinPos.InsertAfter == WINDOW_BOTTOM)
          {
-            IntLockRelatives(ParentWindow);
-            if(ParentWindow->LastChild)
+            InsertAfterWindow = NULL;
+            
+	    if(ParentWindow->LastChild)
             {
-               IntReferenceWindowObject(ParentWindow->LastChild);
                InsertAfterWindow = ParentWindow->LastChild;
             }
-            else
-              InsertAfterWindow = NULL;
-            IntUnLockRelatives(ParentWindow);
          }
          else
-            InsertAfterWindow = IntGetWindowObject(WinPos.hwndInsertAfter);
+            InsertAfterWindow = (HWNDValidateWindowObject(WinPos.InsertAfter) ? WinPos.InsertAfter : NULL);
          /* Do nothing if hwndInsertAfter is HWND_BOTTOM and Window is already
             the last window */
          if (InsertAfterWindow != Window)
@@ -914,9 +894,8 @@
              IntUnlinkWindow(Window);
              IntLinkWindow(Window, ParentWindow, InsertAfterWindow);
          }
-         if (InsertAfterWindow != NULL)
-            IntReleaseWindowObject(InsertAfterWindow);
-         if ((HWND_TOPMOST == WinPos.hwndInsertAfter)
+         
+         if ((WINDOW_TOPMOST == WinPos.InsertAfter)
              || (0 != (Window->ExStyle & WS_EX_TOPMOST)
                  && NULL != Window->PrevSibling
                  && 0 != (Window->PrevSibling->ExStyle & WS_EX_TOPMOST))
@@ -929,8 +908,6 @@
          {
             Window->ExStyle &= ~ WS_EX_TOPMOST;
          }
-         
-         IntReleaseWindowObject(ParentWindow);
       }
    }
 
@@ -1069,14 +1046,14 @@
          HRGN ClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
 
          NtGdiCombineRgn(ClipRgn, CopyRgn, NULL, RGN_COPY);
-         Dc = NtUserGetDCEx(Wnd, ClipRgn, DCX_WINDOW | DCX_CACHE |
-            DCX_INTERSECTRGN | DCX_CLIPSIBLINGS);
+         Dc = IntGetDCEx(Window, ClipRgn, DCX_WINDOW | DCX_CACHE |
+                         DCX_INTERSECTRGN | DCX_CLIPSIBLINGS);
          NtGdiBitBlt(Dc,
             CopyRect.left, CopyRect.top, CopyRect.right - CopyRect.left,
             CopyRect.bottom - CopyRect.top, Dc,
             CopyRect.left + (OldWindowRect.left - NewWindowRect.left),
             CopyRect.top + (OldWindowRect.top - NewWindowRect.top), SRCCOPY);
-         NtUserReleaseDC(Wnd, Dc);
+         IntReleaseDC(Window, Dc);
          IntValidateParent(Window, CopyRgn);
       }
       else if(VisRgn)
@@ -1151,7 +1128,7 @@
    {
       if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
       {
-         IntSendMessage(WinPos.hwnd, WM_CHILDACTIVATE, 0, 0);
+         IntSendMessage(Window, WM_CHILDACTIVATE, 0, 0);
       }
       else
       {
@@ -1159,8 +1136,14 @@
       }
    }
 
-   if ((WinPos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE)
-      IntSendMessage(WinPos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM) &WinPos);
+   if ((WinPos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE &&
+        HWNDValidateWindowObject(WinPos.Window))
+   {
+      WINDOWPOS wp;
+      InternalWindowPosToWinPosStructure(&wp, &WinPos);
+      IntSendMessage(WinPos.Window, WM_WINDOWPOSCHANGED, 0, (LPARAM) &wp);
+      WinPosToInternalWindowPosStructure(&WinPos, &wp);
+   }
 
    IntReleaseWindowObject(Window);
 
@@ -1168,12 +1151,14 @@
 }
 
 LRESULT FASTCALL
-WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect)
+WinPosGetNonClientSize(PWINDOW_OBJECT Window, RECT* WindowRect, RECT* ClientRect)
 {
   LRESULT Result;
 
   *ClientRect = *WindowRect;
-  Result = IntSendMessage(Wnd, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect);
+  Result = IntSendMessage(Window, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect);
+
+  /* FIXME - return if the window doesn't exist anymore */
 
   FixClientRect(ClientRect, WindowRect);
 
@@ -1181,25 +1166,15 @@
 }
 
 BOOLEAN FASTCALL
-WinPosShowWindow(HWND Wnd, INT Cmd)
+WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
 {
   BOOLEAN WasVisible;
-  PWINDOW_OBJECT Window;
-  NTSTATUS Status;
   UINT Swp = 0;
   RECT NewPos;
   BOOLEAN ShowFlag;
 //  HRGN VisibleRgn;
 
-  Status = 
-    ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
-			       Wnd,
-			       otWindow,
-			       (PVOID*)&Window);
-  if (!NT_SUCCESS(Status))
-    {
-      return(FALSE);
-    }
+  ASSERT(Window);
   
   WasVisible = (Window->Style & WS_VISIBLE) != 0;
 
@@ -1209,7 +1184,6 @@
       {
 	if (!WasVisible)
 	  {
-	    ObmDereferenceObject(Window);
 	    return(FALSE);
 	  }
 	Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE |
@@ -1280,7 +1254,7 @@
   ShowFlag = (Cmd != SW_HIDE);
   if (ShowFlag != WasVisible)
     {
-      IntSendMessage(Wnd, WM_SHOWWINDOW, ShowFlag, 0);
+      IntSendMessage(Window, WM_SHOWWINDOW, ShowFlag, 0);
       /* 
        * FIXME: Need to check the window wasn't destroyed during the 
        * window procedure. 
@@ -1294,8 +1268,8 @@
       Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
     }
 
-  WinPosSetWindowPos(Window->Self, 0 != (Window->ExStyle & WS_EX_TOPMOST)
-                                   ? HWND_TOPMOST : HWND_TOP,
+  WinPosSetWindowPos(Window, (0 != (Window->ExStyle & WS_EX_TOPMOST))
+                                   ? WINDOW_TOPMOST : WINDOW_TOP,
                      NewPos.left, NewPos.top, NewPos.right, NewPos.bottom, LOWORD(Swp));
 
   if (Cmd == SW_HIDE)
@@ -1305,16 +1279,16 @@
        * asynchronously.
        */
 
-      if (Window->Self == NtUserGetActiveWindow())
+      if (Window == IntGetActiveWindow())
         {
           WinPosActivateOtherWindow(Window);
         }
 
       /* Revert focus to parent */
-      if (Wnd == IntGetThreadFocusWindow() ||
-          IntIsChildWindow(Wnd, IntGetThreadFocusWindow()))
+      if (Window == IntGetThreadFocusWindow() ||
+          IntIsChildWindow(Window, IntGetThreadFocusWindow()))
         {
-          NtUserSetFocus(Window->Parent);
+          IntSetFocus(Window->Parent);
         }
     }
 
@@ -1334,12 +1308,12 @@
 	  wParam = SIZE_MINIMIZED;
 	}
 
-      IntSendMessage(Wnd, WM_SIZE, wParam,
+      IntSendMessage(Window, WM_SIZE, wParam,
                      MAKELONG(Window->ClientRect.right - 
                               Window->ClientRect.left,
                               Window->ClientRect.bottom -
                               Window->ClientRect.top));
-      IntSendMessage(Wnd, WM_MOVE, 0,
+      IntSendMessage(Window, WM_MOVE, 0,
                      MAKELONG(Window->ClientRect.left,
                               Window->ClientRect.top));
     }
@@ -1352,7 +1326,6 @@
     }
 */
 
-  ObmDereferenceObject(Window);
   return(WasVisible);
 }
 
@@ -1362,71 +1335,59 @@
    PWINDOW_OBJECT* Window, USHORT *HitTest)
 {
    PWINDOW_OBJECT Current;
-   HWND *List, *phWnd;
 
-   if ((List = IntWinListChildren(ScopeWin)))
+   for(Current = ScopeWin->FirstChild; Current != NULL; Current = Current->NextSibling)
    {
-      for (phWnd = List; *phWnd; ++phWnd)
-      {
-         if (!(Current = IntGetWindowObject(*phWnd)))
-            continue;
-      
-         if (!(Current->Style & WS_VISIBLE))
-         {
-            IntReleaseWindowObject(Current);
-	    continue;
-         }
-
-         if ((Current->Style & (WS_POPUP | WS_CHILD | WS_DISABLED)) ==
-             (WS_CHILD | WS_DISABLED))
-         {
-            IntReleaseWindowObject(Current);
-            continue;
-         }
-
-         if (!IntPtInWindow(Current, Point->x, Point->y))
-         {
-            IntReleaseWindowObject(Current);
-            continue;
-         }
-
-         if (*Window)
-	    IntReleaseWindowObject(*Window);
-         *Window = Current;
-
-         if (Current->Style & WS_MINIMIZE)
-         {
-            *HitTest = HTCAPTION;
-            break;
-         }
-
-         if (Current->Style & WS_DISABLED)
-         {
-            *HitTest = HTERROR;
-            break;
-         }
-        
-         if (OnlyHitTests && (Current->MessageQueue == OnlyHitTests))
-         {
-            *HitTest = IntSendMessage(Current->Self, WM_NCHITTEST, 0,
-                                      MAKELONG(Point->x, Point->y));
-            if ((*HitTest) == (USHORT)HTTRANSPARENT)
-               continue;
-         }
-         else
-            *HitTest = HTCLIENT;
-        
-         if (Point->x >= Current->ClientRect.left &&
-             Point->x < Current->ClientRect.right &&
-             Point->y >= Current->ClientRect.top &&
-             Point->y < Current->ClientRect.bottom)
-         {
-            WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest);
-         }        
+     if (!(Current->Style & WS_VISIBLE))
+     {
+        IntReleaseWindowObject(Current);
+        continue;
+     }
+
+     if ((Current->Style & (WS_POPUP | WS_CHILD | WS_DISABLED)) ==
+         (WS_CHILD | WS_DISABLED))
+     {
+        continue;
+     }
+
+     if (!IntPtInWindow(Current, Point->x, Point->y))
+     {
+        continue;
+     }
[truncated at 1000 lines; 119 more skipped]

reactos/subsys/win32k/ntuser
winsta.c 1.64 -> 1.64.8.1
diff -u -r1.64 -r1.64.8.1
--- winsta.c	20 Jun 2004 00:45:37 -0000	1.64
+++ winsta.c	15 Jul 2004 20:07:18 -0000	1.64.8.1
@@ -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: winsta.c,v 1.64 2004/06/20 00:45:37 navaraf Exp $
+ *  $Id: winsta.c,v 1.64.8.1 2004/07/15 20:07:18 weiden Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -378,7 +378,7 @@
    WindowStationObject->HandleTable = ObmCreateHandleTable();
    if (!WindowStationObject->HandleTable)
    {
-      DPRINT("Failed creating handle table\n");
+      DPRINT1("Failed creating handle table\n");
       ExFreePool(CurInfo);
       ExFreePool(WindowStationName.Buffer);
       /* FIXME - Delete window station object */
@@ -386,8 +386,9 @@
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       return 0;
    }
-  
+   #if 0
    InitHotKeys(WindowStationObject);
+   #endif
   
    ExInitializeFastMutex(&CurInfo->CursorMutex);
    CurInfo->Enabled = FALSE;
@@ -409,12 +410,6 @@
    
    WindowStationObject->SystemCursor = CurInfo;
   
-   if (!IntSetupCurIconHandles(WindowStationObject))
-   {
-       DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");
-       /* FIXME: Complain more loudly? */
-   }
-  
    DPRINT("Window station successfully created (%wZ)\n", &WindowStationName);
    ExFreePool(WindowStationName.Buffer);
 
@@ -541,12 +536,6 @@
       return FALSE;
    }
 
-   #if 0
-   /* FIXME - free the cursor information when actually deleting the object!! */
-   ASSERT(Object->SystemCursor);
-   ExFreePool(Object->SystemCursor);
-   #endif
-
    ObDereferenceObject(Object);
 
    DPRINT("Closing window station handle (0x%X)\n", hWinSta);
@@ -820,7 +809,7 @@
 
    if (!NT_SUCCESS(Status)) 
    {
-      DPRINT("Validation of window station handle (0x%X) failed\n", 
+      DPRINT1("Validation of window station handle (0x%X) failed\n", 
          hWindowStation);
       return FALSE;
    }
@@ -835,6 +824,7 @@
       if (Win32Process->WindowStation != NULL)
          ObDereferenceObject(Win32Process->WindowStation);
       Win32Process->WindowStation = Object;
+      DbgPrint("Window Station is set!\n");
    }
 
    SET_PROCESS_WINDOW_STATION(hWindowStation);

reactos/subsys/win32k/objects
cursoricon.c 1.63 -> 1.63.2.1
diff -u -r1.63 -r1.63.2.1
--- cursoricon.c	9 Jul 2004 20:09:35 -0000	1.63
+++ cursoricon.c	15 Jul 2004 20:07:19 -0000	1.63.2.1
@@ -16,36 +16,19 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: cursoricon.c,v 1.63 2004/07/09 20:09:35 navaraf Exp $ */
+/* $Id: cursoricon.c,v 1.63.2.1 2004/07/15 20:07:19 weiden Exp $ */
 #include <w32k.h>
 
-PCURICON_OBJECT FASTCALL
-IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle)
-{
-   PCURICON_OBJECT Object;
-   NTSTATUS Status;
-
-   Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable,
-      Handle, otCursorIcon, (PVOID*)&Object);
-   if (!NT_SUCCESS(Status))
-   {
-      return NULL;
-   }
-   return Object;
-}
-
 #define COLORCURSORS_ALLOWED FALSE
-HCURSOR FASTCALL
-IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
-   BOOL ForceChange)
+PCURSOR_OBJECT FASTCALL
+IntSetCursor(PCURSOR_OBJECT NewCursor, BOOL ForceChange)
 {
    BITMAPOBJ *BitmapObj;
    SURFOBJ *SurfObj;
    PDEVINFO DevInfo;
    PBITMAPOBJ MaskBmpObj = NULL;
    PSYSTEM_CURSORINFO CurInfo;
-   PCURICON_OBJECT OldCursor;
-   HCURSOR Ret = (HCURSOR)0;
+   PCURSOR_OBJECT OldCursor;
    HBITMAP hColor = (HBITMAP)0;
    HBITMAP hMask = 0;
    SURFOBJ *soMask = NULL, *soColor = NULL;
@@ -53,29 +36,25 @@
    RECTL PointerRect;
    HDC Screen;
   
-   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   CurInfo = IntGetSysCursorInfo(PsGetWin32Process()->WindowStation);
    OldCursor = CurInfo->CurrentCursorObject;
-   if (OldCursor)
-   {
-      Ret = (HCURSOR)OldCursor->Self;
-   }
-  
+   
    if (!ForceChange && OldCursor == NewCursor)
    {
-      return Ret;
+      return OldCursor;
    }
   
    {
       if(!(Screen = IntGetScreenDC()))
       {
-        return (HCURSOR)0;
+        return NULL;
       }
       /* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
       PDC dc = DC_LockDc(Screen);
 
       if (!dc)
       {
-         return Ret;
+         return OldCursor;
       }
   
       BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
@@ -93,19 +72,19 @@
            GDIDEV(SurfObj)->MovePointer(SurfObj, -1, -1, &PointerRect);
          SetPointerRect(CurInfo, &PointerRect);
       }
-
+      
       GDIDEV(SurfObj)->PointerStatus = SPS_ACCEPT_NOEXCLUDE;
 
       CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
       CurInfo->ShowingCursor = 0;
       BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
-      return Ret;
+      return OldCursor;
    }
   
    if (!NewCursor)
    {
       BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
-      return Ret;
+      return OldCursor;
    }
 
    /* TODO: Fixme. Logic is screwed above */
@@ -119,8 +98,7 @@
       if (maskBpp != 1)
       {
          DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n");
-         BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
-         return Ret;
+         return OldCursor;
       }
       
       if ((DevInfo->flGraphicsCaps2 & GCAPS2_ALPHACURSOR) && 
@@ -151,7 +129,7 @@
           {
             RECTL DestRect = {0, 0, MaskBmpObj->SurfObj.sizlBitmap.cx, MaskBmpObj->SurfObj.sizlBitmap.cy};
             POINTL SourcePoint = {0, 0};
-
+            
             /*
              * NOTE: For now we create the cursor in top-down bitmap,
              * because VMware driver rejects it otherwise. This should
@@ -181,16 +159,14 @@
     if (GDIDEVFUNCS(SurfObj).SetPointerShape)
     {
       GDIDEV(SurfObj)->PointerStatus =
-         GDIDEVFUNCS(SurfObj).SetPointerShape(
-                                                        SurfObj, soMask, soColor, XlateObj,
-                                                        NewCursor->IconInfo.xHotspot,
-                                                        NewCursor->IconInfo.yHotspot,
-                                                        CurInfo->x, 
-                                                        CurInfo->y, 
-                                                        &PointerRect,
-                                                        SPS_CHANGE);
-      DPRINT("SetCursor: DrvSetPointerShape() returned %x\n",
-         GDIDEV(SurfObj)->PointerStatus);
+        GDIDEVFUNCS(SurfObj).SetPointerShape(SurfObj, soMask, soColor, XlateObj,
+                                             NewCursor->IconInfo.xHotspot,
+                                             NewCursor->IconInfo.yHotspot,
+                                             CurInfo->x, 
+                                             CurInfo->y, 
+                                             &PointerRect,
+                                             SPS_CHANGE);
+      DPRINT("SetCursor: DrvSetPointerShape() returned %x\n", GDIDEV(SurfObj)->PointerStatus);
     }
     else
     {
@@ -232,67 +208,60 @@
     }
     
     if(GDIDEV(SurfObj)->PointerStatus == SPS_ERROR)
+    {
       DPRINT1("SetCursor: DrvSetPointerShape() returned SPS_ERROR\n");
+    }
   
-  return Ret;
+  return OldCursor;
 }
 
+typedef struct _INT_FINDEXISTINGCURSOR
+{
+  HMODULE hModule;
+  HRSRC hRsrc;
+  LONG cx;
+  LONG cy;
+} INT_FINDEXISTINGCURSOR, *PINT_FINDEXISTINGCURSOR;
+
 BOOL FASTCALL
-IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject)
+_FindExistingCursorObjectCallBack(PCURSOR_OBJECT CursorObject, PINT_FINDEXISTINGCURSOR FindData)
 {
-  return TRUE;
+  if(CursorObject->hModule == FindData->hModule && CursorObject->hRsrc == FindData->hRsrc &&
+     (FindData->cx == 0 || (FindData->cx == CursorObject->Size.cx && FindData->cy == CursorObject->Size.cy)))
+  {
+    /* We found the right object */
+    return TRUE;
+  }
+  
+  return FALSE;
 }
 
-PCURICON_OBJECT FASTCALL
-IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule, 
-                             HRSRC hRsrc, LONG cx, LONG cy)
+PCURSOR_OBJECT FASTCALL
+IntFindExistingCursorObject(HMODULE hModule, HRSRC hRsrc, LONG cx, LONG cy)
 {
-  PUSER_HANDLE_TABLE HandleTable;
-  PLIST_ENTRY CurrentEntry;
-  PUSER_HANDLE_BLOCK Current;
-  PCURICON_OBJECT Object;
-  ULONG i;
-  
-  HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->HandleTable;
-  ObmpLockHandleTable(HandleTable);
+  INT_FINDEXISTINGCURSOR fec;
   
-  CurrentEntry = HandleTable->ListHead.Flink;
-  while(CurrentEntry != &HandleTable->ListHead)
-  {
-    Current = CONTAINING_RECORD(CurrentEntry, USER_HANDLE_BLOCK, ListEntry);
-    for(i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
-    {
-      Object = (PCURICON_OBJECT)Current->Handles[i].ObjectBody;
-      if(Object && (ObmReferenceObjectByPointer(Object, otCursorIcon) == STATUS_SUCCESS))
-      {
-        if((Object->hModule == hModule) && (Object->hRsrc == hRsrc))
-        {
-          if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy)))
-          {
-	    ObmDereferenceObject(Object);
-	    continue;
-          }
-          ObmpUnlockHandleTable(HandleTable);
-          return Object;
-        }
-        ObmDereferenceObject(Object);
-      }
-    }
-    CurrentEntry = CurrentEntry->Flink;
-  }
+  fec.hModule = hModule;
+  fec.hRsrc = hRsrc;
+  fec.cx = cx;
+  fec.cy = cy;
   
-  ObmpUnlockHandleTable(HandleTable);
-  return NULL;
+  return (PCURSOR_OBJECT)ObmEnumHandles(PsGetWin32Process()->WindowStation->HandleTable,
+                                        otCURSOR, &fec, (PFNENUMHANDLESPROC)_FindExistingCursorObjectCallBack);
 }
 
-PCURICON_OBJECT FASTCALL
-IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
+PCURSOR_OBJECT FASTCALL
+IntCreateCursorObject(HANDLE *Handle)
 {
-  PCURICON_OBJECT Object;
-  HANDLE Handle;
+  PCURSOR_OBJECT Object;
   PW32PROCESS Win32Process;
   
-  Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT));
+  ASSERT(Handle);
+  
+  Win32Process = PsGetWin32Process();
+  
+  Object = (PCURSOR_OBJECT)ObmCreateObject(Win32Process->WindowStation->HandleTable, 
+                                           Handle, otCURSOR, sizeof(CURSOR_OBJECT));
   
   if(!Object)
   {
@@ -300,45 +269,41 @@
     return FALSE;
   }
   
-  Win32Process = PsGetWin32Process();
-  
   IntLockProcessCursorIcons(Win32Process);
   InsertTailList(&Win32Process->CursorIconListHead, &Object->ListEntry);
   IntUnLockProcessCursorIcons(Win32Process);
   
-  Object->Self = Handle;
+  Object->Handle = *Handle;
   Object->Process = PsGetWin32Process();
   
   return Object;
 }
 
 BOOL FASTCALL
-IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL RemoveFromProcess)
+IntDestroyCursorObject(PCURSOR_OBJECT Object, BOOL RemoveFromProcess)
 {
   PSYSTEM_CURSORINFO CurInfo;
-  PCURICON_OBJECT Object;
   HBITMAP bmpMask, bmpColor;
-  NTSTATUS Status;
-  BOOL Ret;
+  PW32PROCESS Win32Process;
   
-  Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object);
-  if(!NT_SUCCESS(Status))
-  {
-    return FALSE;
-  }
+  Win32Process = PsGetWin32Process();
   
-  if (Object->Process != PsGetWin32Process())
+  ASSERT(Object);
+  
+  if (Object->Process != Win32Process)
   {
-    ObmDereferenceObject(Object);
     return FALSE;
   }
 
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
+  CurInfo = IntGetSysCursorInfo(Win32Process->WindowStation);
 
+  ObmReferenceObject(Object);
+  ObmDeleteObject(Win32Process->WindowStation->HandleTable, Object);
+  
   if (CurInfo->CurrentCursorObject == Object)
   {
     /* Hide the cursor if we're destroying the current cursor */
-    IntSetCursor(WinStaObject, NULL, TRUE);
+    IntSetCursor(NULL, TRUE);
   }
   
   bmpMask = Object->IconInfo.hbmMask;
@@ -351,747 +316,162 @@
     IntUnLockProcessCursorIcons(Object->Process);
   }
   
-  Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Handle));
-  
   /* delete bitmaps */
   if(bmpMask)
     NtGdiDeleteObject(bmpMask);
   if(bmpColor)
     NtGdiDeleteObject(bmpColor);
-
+  
   ObmDereferenceObject(Object);
   
-  return Ret;
+  return TRUE;
 }
 
 VOID FASTCALL
 IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process)
 {
   PWINSTATION_OBJECT WinStaObject;
-  PCURICON_OBJECT Current;
+  PCURSOR_OBJECT Current;
   PLIST_ENTRY CurrentEntry, NextEntry;
   
   if(!(WinStaObject = Win32Process->WindowStation))
     return;
   
+  /* FIXME - we have to lock the environment here! */
+  
   IntLockProcessCursorIcons(Win32Process);
   CurrentEntry = Win32Process->CursorIconListHead.Flink;
   while(CurrentEntry != &Win32Process->CursorIconListHead)
   {
     NextEntry = CurrentEntry->Flink;
-    Current = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
+    Current = CONTAINING_RECORD(CurrentEntry, CURSOR_OBJECT, ListEntry);
     RemoveEntryList(&Current->ListEntry);
-    IntDestroyCurIconObject(WinStaObject, Current->Self, FALSE);
+    IntDestroyCursorObject(Current, FALSE);
     CurrentEntry = NextEntry;
   }
   IntUnLockProcessCursorIcons(Win32Process);
 }
 
-/*
- * @implemented
- */
-HANDLE
-STDCALL
-NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect)
-{
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  PBITMAPOBJ bmp;
-  NTSTATUS Status;
-  HANDLE Ret;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
-  
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return (HANDLE)0;
-  }
-  
-  CurIconObject = IntCreateCurIconHandle(WinStaObject);
-  if(CurIconObject)
-  {
-    Ret = CurIconObject->Self;
-    
-    if(IconInfo)
-    {
-      Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
-      if(NT_SUCCESS(Status))
-      {
-        if(Indirect)
-        {
-          CurIconObject->IconInfo.hbmMask = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmMask);
-          CurIconObject->IconInfo.hbmColor = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmColor);
-        }
-        if(CurIconObject->IconInfo.hbmColor && 
-          (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor)))
-        {
-          CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-          CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
-          BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
-        }
-        else
-        {
-          if(CurIconObject->IconInfo.hbmMask && 
-            (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask)))
-          {
-            CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-            CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
-            BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmMask);
-          }
-        }
-      }
-      else
-      {
-        SetLastNtError(Status);
-        /* FIXME - Don't exit here */
-      }
-    }
-    
-    ObDereferenceObject(WinStaObject);
-    return Ret;
-  }
-
-  SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-  ObDereferenceObject(WinStaObject);
-  return (HANDLE)0;
-}
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetCursorIconInfo(
-  HANDLE Handle,
-  PICONINFO IconInfo)
+VOID FASTCALL
+IntGetCursorIconInfo(PCURSOR_OBJECT Cursor, PICONINFO IconInfo)
 {
-  ICONINFO ii;
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  BOOL Ret = FALSE;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
+  ASSERT(Cursor);
   
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
+  *IconInfo = Cursor->IconInfo;
   
-  CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
-  if(CurIconObject)
-  {
-    if(IconInfo)
-    {
-      RtlCopyMemory(&ii, &CurIconObject->IconInfo, sizeof(ICONINFO));
-      
-      /* Copy bitmaps */
-      ii.hbmMask = BITMAPOBJ_CopyBitmap(ii.hbmMask);
-      ii.hbmColor = BITMAPOBJ_CopyBitmap(ii.hbmColor);      
-      
-      /* Copy fields */
-      Status = MmCopyToCaller(IconInfo, &ii, sizeof(ICONINFO));
-      if(NT_SUCCESS(Status))
-        Ret = TRUE;
-      else
-        SetLastNtError(Status);
-    }
-    else
-    {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    }
-    
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    return Ret;
-  }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  return FALSE;
+  IconInfo->hbmMask = BITMAPOBJ_CopyBitmap(Cursor->IconInfo.hbmMask);
+  IconInfo->hbmColor = BITMAPOBJ_CopyBitmap(Cursor->IconInfo.hbmColor);
 }
 
 
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetCursorIconSize(
-  HANDLE Handle,
-  BOOL *fIcon,
-  SIZE *Size)
+BOOL FASTCALL
+IntGetCursorIconSize(PCURSOR_OBJECT Cursor,
+                     BOOL *fIcon,
+                     SIZE *Size)
 {
-  PCURICON_OBJECT CurIconObject;
   PBITMAPOBJ bmp;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  BOOL Ret = FALSE;
-  SIZE SafeSize;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
-  
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
-  if(CurIconObject)
-  {
-    /* Copy fields */
-    Status = MmCopyToCaller(fIcon, &CurIconObject->IconInfo.fIcon, sizeof(BOOL));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      goto done;
-    }
-    
-    bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
-    if(!bmp)
-      goto done;
-
-    SafeSize.cx = bmp->SurfObj.sizlBitmap.cx;
-    SafeSize.cy = bmp->SurfObj.sizlBitmap.cy;
-    Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE));
-    if(NT_SUCCESS(Status))
-      Ret = TRUE;
-    else
-      SetLastNtError(Status);
-    
-    BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
-    
-    done:
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    return Ret;
-  }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
-NtUserGetCursorFrameInfo(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetCursorInfo(
-  PCURSORINFO pci)
-{
-  CURSORINFO SafeCi;
-  PSYSTEM_CURSORINFO CurInfo;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  PCURICON_OBJECT CursorObject;
-  
-  Status = MmCopyFromCaller(&SafeCi.cbSize, pci, sizeof(DWORD));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
+  HBITMAP hbmp;
   
-  if(SafeCi.cbSize != sizeof(CURSORINFO))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return FALSE;
-  }
+  ASSERT(Cursor);
+  ASSERT(fIcon);
+  ASSERT(Size);
   
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
+  *fIcon = Cursor->IconInfo.fIcon;
   
-  if(!NT_SUCCESS(Status))
+  hbmp = (Cursor->IconInfo.hbmColor != NULL ? Cursor->IconInfo.hbmColor : Cursor->IconInfo.hbmMask);
+  if(hbmp == NULL || !(bmp = BITMAPOBJ_LockBitmap(hbmp)))
   {
-    SetLastNtError(Status);
+    DPRINT1("Unable to lock bitmap 0x%x for cursor/icon 0x%x\n", hbmp, Cursor->Handle);
     return FALSE;
   }
   
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
+  Size->cx = bmp->SurfObj.sizlBitmap.cx;
+  Size->cy = (hbmp != Cursor->IconInfo.hbmMask ? bmp->SurfObj.sizlBitmap.cy : bmp->SurfObj.sizlBitmap.cy / 2);
   
-  SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0);
-  SafeCi.hCursor = (CursorObject ? (HCURSOR)CursorObject->Self : (HCURSOR)0);
-  SafeCi.ptScreenPos.x = CurInfo->x;
-  SafeCi.ptScreenPos.y = CurInfo->y;
+  BITMAPOBJ_UnlockBitmap(hbmp);
   
-  Status = MmCopyToCaller(pci, &SafeCi, sizeof(CURSORINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    ObDereferenceObject(WinStaObject);
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  
-  ObDereferenceObject(WinStaObject);
   return TRUE;
 }
 
 
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserClipCursor(
-  RECT *UnsafeRect)
+BOOL FASTCALL
+IntGetCursorInfo(PCURSORINFO pci)
 {
-  /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
-  
-  PWINSTATION_OBJECT WinStaObject;
   PSYSTEM_CURSORINFO CurInfo;
-  RECT Rect;
-  PWINDOW_OBJECT DesktopWindow = NULL;
-
-  NTSTATUS Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				       KernelMode,
-				       0,
-				       &WinStaObject);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT1("Validation of window station handle (0x%X) failed\n",
-      PROCESS_WINDOW_STATION());
-    SetLastNtError(Status);
-    return FALSE;
-  }
-
-  if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
-  {
-    ObDereferenceObject(WinStaObject);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return FALSE;
-  }
-  
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  if(WinStaObject->ActiveDesktop)
-    DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
-  
-  if((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
-     && DesktopWindow)
-  {
-    MOUSEINPUT mi;
-    
-    CurInfo->CursorClipInfo.IsClipped = TRUE;
-    CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
-    CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
-    CurInfo->CursorClipInfo.Right = min(Rect.right - 1, DesktopWindow->WindowRect.right - 1);
-    CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->WindowRect.bottom - 1);
-    IntReleaseWindowObject(DesktopWindow);
-    
-    mi.dx = CurInfo->x;
-    mi.dy = CurInfo->y;
-    mi.mouseData = 0;
-    mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
-    mi.time = 0;
-    mi.dwExtraInfo = 0;
-    IntMouseInput(&mi);
-    
-    return TRUE;
-  }
-  
-  CurInfo->CursorClipInfo.IsClipped = FALSE;
-  ObDereferenceObject(WinStaObject);
-  
-  return TRUE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserDestroyCursorIcon(
-  HANDLE Handle,
-  DWORD Unknown)
-{
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
+  PWINSTATION_OBJECT WinSta;
+  PCURSOR_OBJECT CursorObject;
   
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
-  
-  if(!NT_SUCCESS(Status))
+  if(!(WinSta = PsGetWin32Process()->WindowStation))
   {
-    SetLastNtError(Status);
+    DPRINT1("GetCursorInfo: Process isn't attached to a window station!\n");
     return FALSE;
   }
   
-  if(IntDestroyCurIconObject(WinStaObject, Handle, TRUE))
-  {
-    ObDereferenceObject(WinStaObject);
-    return TRUE;
-  }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  return FALSE;
-}
-
-
-/*
- * @implemented
- */
-HICON
-STDCALL
-NtUserFindExistingCursorIcon(
-  HMODULE hModule,
-  HRSRC hRsrc,
-  LONG cx,
-  LONG cy)
-{
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  HANDLE Ret = (HANDLE)0;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
+  CurInfo = IntGetSysCursorInfo(WinSta);
+  CursorObject = CurInfo->CurrentCursorObject;
   
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return Ret;
-  }
+  pci->flags = ((CurInfo->ShowingCursor && CursorObject != NULL) ? CURSOR_SHOWING : 0);
+  pci->hCursor = (CursorObject != NULL ? (HCURSOR)CursorObject->Handle : (HCURSOR)0);
+  pci->ptScreenPos.x = CurInfo->x;
+  pci->ptScreenPos.y = CurInfo->y;
   
-  CurIconObject = IntFindExistingCurIconObject(WinStaObject, hModule, hRsrc, cx, cy);
-  if(CurIconObject)
-  {
-    Ret = CurIconObject->Self;
-    
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    return Ret;
-  }
-  
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  return (HANDLE)0;
+  return TRUE;
 }
 
 
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetClipCursor(
-  RECT *lpRect)
+VOID FASTCALL
+IntGetClipCursor(RECT *lpRect)
 {
   /* FIXME - check if process has WINSTA_READATTRIBUTES */
   PSYSTEM_CURSORINFO CurInfo;
-  PWINSTATION_OBJECT WinStaObject;
-  RECT Rect;
-  NTSTATUS Status;
   
-  if(!lpRect)
-    return FALSE;
-
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-	       KernelMode,
-	       0,
-	       &WinStaObject);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT("Validation of window station handle (0x%X) failed\n",
-      PROCESS_WINDOW_STATION());
-    SetLastNtError(Status);
-    return FALSE;
-  }
+  ASSERT(lpRect);
   
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
+  CurInfo = IntGetSysCursorInfo(PsGetWin32Process()->WindowStation);
   if(CurInfo->CursorClipInfo.IsClipped)
   {
-    Rect.left = CurInfo->CursorClipInfo.Left;
-    Rect.top = CurInfo->CursorClipInfo.Top;
-    Rect.right = CurInfo->CursorClipInfo.Right;
-    Rect.bottom = CurInfo->CursorClipInfo.Bottom;
+    lpRect->left = CurInfo->CursorClipInfo.Left;
+    lpRect->top = CurInfo->CursorClipInfo.Top;
+    lpRect->right = CurInfo->CursorClipInfo.Right;
+    lpRect->bottom = CurInfo->CursorClipInfo.Bottom;
   }
   else
   {
-    Rect.left = 0;
-    Rect.top = 0;
-    Rect.right = NtUserGetSystemMetrics(SM_CXSCREEN);
-    Rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN);
+    lpRect->left = 0;
+    lpRect->top = 0;
+    lpRect->right = IntGetSystemMetrics(SM_CXSCREEN);
+    lpRect->bottom = IntGetSystemMetrics(SM_CYSCREEN);
   }
-  
-  Status = MmCopyToCaller((PRECT)lpRect, &Rect, sizeof(RECT));
-  if(!NT_SUCCESS(Status))
-  {
-    ObDereferenceObject(WinStaObject);
-    SetLastNtError(Status);
-    return FALSE;
-  }
-    
-  ObDereferenceObject(WinStaObject);
-  
-  return TRUE;
-}
-
-
-/*
- * @implemented
- */
-HCURSOR
-STDCALL
-NtUserSetCursor(
-  HCURSOR hCursor)
-{
-  PCURICON_OBJECT CurIconObject;
-  HICON OldCursor = (HCURSOR)0;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return (HCURSOR)0;
-  }
-  
-  CurIconObject = IntGetCurIconObject(WinStaObject, hCursor);
-  if(CurIconObject)
-  {
-    OldCursor = IntSetCursor(WinStaObject, CurIconObject, FALSE);
-    IntReleaseCurIconObject(CurIconObject);
-  }
-  else
-    SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  
-  ObDereferenceObject(WinStaObject);
-  return OldCursor;
 }
 
 
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserSetCursorIconContents(
-  HANDLE Handle,
-  PICONINFO IconInfo)
+VOID FASTCALL
+IntSetCursorIconData(PCURSOR_OBJECT Cursor, BOOL *fIcon, POINT *Hotspot,
+                     HMODULE hModule, HRSRC hRsrc, HRSRC hGroupRsrc)
 {
-  PCURICON_OBJECT CurIconObject;
-  PBITMAPOBJ bmp;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  BOOL Ret = FALSE;
-  
-  Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
-				                               KernelMode,
-				                               0,
-				                               &WinStaObject);
+  ASSERT(Cursor);
   
-  if(!NT_SUCCESS(Status))
+  if(fIcon)
   {
-    SetLastNtError(Status);
-    return FALSE;
+    Cursor->IconInfo.fIcon = *fIcon;
   }
-  
-  CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
-  if(CurIconObject)
+  if(Hotspot)
   {
-    /* Copy fields */
-    Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      goto done;
-    }
-    
-    bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
-    if(bmp)
-    {
-      CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-      CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
-      BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
-    }
-    else
-    {
-      bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask);
-      if(!bmp)
-        goto done;
-      
-      CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-      CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
-      
-      BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmMask);
-    }
-    
-    Ret = TRUE;
-    
-    done:
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    return Ret;
+    Cursor->IconInfo.xHotspot = Hotspot->x;
+    Cursor->IconInfo.yHotspot = Hotspot->y;
   }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  return FALSE;
-}
-
-
-/*
- * @implemented
[truncated at 1000 lines; 401 more skipped]
CVSspam 0.2.8