mostly naming changes
Modified: branches/win32k rewrite attempt/win32k/eng/window.c
Modified: branches/win32k rewrite attempt/win32k/include/accelerator.h
Modified: branches/win32k rewrite attempt/win32k/include/cursoricon.h
Modified: branches/win32k rewrite attempt/win32k/include/hook.h
Modified: branches/win32k rewrite attempt/win32k/include/ntuser.h
Modified: branches/win32k rewrite attempt/win32k/include/object.h
Modified: branches/win32k rewrite attempt/win32k/include/userfuncs.h
Modified: branches/win32k rewrite attempt/win32k/include/win32.h
Modified: branches/win32k rewrite attempt/win32k/include/window.h
Modified: branches/win32k rewrite attempt/win32k/include/winpos.h
Modified: branches/win32k rewrite attempt/win32k/ntuser/accelerator.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/callback.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/caret.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/class.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/cursoricon.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/desktop.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/focus.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/hook.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/hotkey.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/input.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/menu.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/message.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/misc.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/monitor.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/msgqueue.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/ntuser.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/object.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/painting.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/prop.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/scrollbar.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/timer.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/vis.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/windc.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/window.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/winpos.c
Modified: branches/win32k rewrite attempt/win32k/ntuser/winsta.c
Modified: branches/win32k rewrite attempt/win32k/objects/color.c
Modified: branches/win32k rewrite attempt/win32k/objects/dc.c

Modified: branches/win32k rewrite attempt/win32k/eng/window.c
--- branches/win32k rewrite attempt/win32k/eng/window.c	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/eng/window.c	2005-09-02 20:45:56 UTC (rev 17607)
@@ -210,7 +210,8 @@
          pso, hwnd, pfn, fl, iPixelFormat);
 
   /* Get window object */
-  Window = IntGetWindowObject(hwnd);
+  //FIXME: user lock?????
+  Window = UserGetWindowObject(hwnd);
   if (Window == NULL)
     {
       return NULL;
@@ -262,11 +263,16 @@
 {
   WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
   PWINDOW_OBJECT Window;
+  BOOL inUser;
 
   DPRINT("EngDeleteWnd: pwo = 0x%x\n", pwo);
 
   /* Get window object */
-  Window = IntGetWindowObject(WndObjInt->Hwnd);
+  inUser = UserIsEntered();
+  if (!inUser){
+     UserEnterShared();
+  }
+  Window = UserGetWindowObject(WndObjInt->Hwnd);
   if (Window == NULL)
     {
       DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n");
@@ -277,6 +283,9 @@
       /* Remove object from window */
       RemoveEntryList(&WndObjInt->ListEntry);
     }
+  if (!inUser){
+     UserLeave();
+  }
 
   /* Free resources */
   IntEngDeleteClipRegion(WndObjInt->ClientClipObj);

Modified: branches/win32k rewrite attempt/win32k/include/accelerator.h
--- branches/win32k rewrite attempt/win32k/include/accelerator.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/accelerator.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -13,7 +13,6 @@
       {
          /*---------- USER_OBJECT_HDR --------------*/
          HACCEL hSelf; /* want typesafe handle */
-         LONG refs_placeholder;
          BYTE flags_placeholder;
          /*---------- USER_OBJECT_HDR --------------*/
 

Modified: branches/win32k rewrite attempt/win32k/include/cursoricon.h
--- branches/win32k rewrite attempt/win32k/include/cursoricon.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/cursoricon.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -18,7 +18,6 @@
       {
          /*---------- USER_OBJECT_HDR --------------*/
          HCURSOR hSelf; /* want typesafe handle */
-         LONG refs_placeholder;
          BYTE flags_placeholder;
          /*---------- USER_OBJECT_HDR --------------*/
 

Modified: branches/win32k rewrite attempt/win32k/include/hook.h
--- branches/win32k rewrite attempt/win32k/include/hook.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/hook.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -7,7 +7,6 @@
 {
 /*---------- USER_OBJECT_HDR --------------*/
   HHOOK hSelf;
-  LONG refs;
   BYTE hdrFlags;
 /*---------- USER_OBJECT_HDR --------------*/
    

Modified: branches/win32k rewrite attempt/win32k/include/ntuser.h
--- branches/win32k rewrite attempt/win32k/include/ntuser.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/ntuser.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -5,18 +5,25 @@
 typedef struct _USER_OBJECT_HDR
 {
    HANDLE hSelf;
-   LONG refs;
    BYTE flags;
+
 } USER_OBJECT_HDR, *PUSER_OBJECT_HDR;
 
 
 typedef struct _USER_REFERENCE_ENTRY
 {
    SINGLE_LIST_ENTRY Entry;
-   PUSER_OBJECT_HDR hdr;
+   PUSER_OBJECT_HDR* ppHdr;
 } USER_REFERENCE_ENTRY, *PUSER_REFERENCE_ENTRY;
 
+/* ul = user lock */
+#define ulShared 1
+#define ulExclusive 2
 
+/* unused for now... */
+//#define ASSERT_LOCK(type) ASSERT(PsGetWin32Thread()->LockType >= type)
+#define ASSERT_LOCK(type)
+
 extern char* _file;
 extern DWORD _line;
 extern DWORD _locked;
@@ -28,35 +35,14 @@
 #define CLEANUP /*unreachable*/ ASSERT(FALSE); _cleanup_
 #define END_CLEANUP return _ret_;
 
-#if 0
 
-#define UserEnterShared() { \
- UUserEnterShared(); ASSERT(InterlockedIncrement(&_locked) > 0); \
- }
- #define UserEnterExclusive() {\
-  UUserEnterExclusive(); ASSERT(InterlockedIncrement(&_locked) > 0); \
-  }
-
-#define UserLeave() { ASSERT(InterlockedDecrement(&_locked) >= 0);  \
- UUserLeave(); }
-
-#endif
-
-
 VOID FASTCALL UserStackTrace();
 
-#define UserEnterShared() \
-{ \
-   DPRINT1("try lock, %s, %i (%i)\n",__FILE__,__LINE__, _locked); \
-   ASSERT(UserLock.Owner != KeGetCurrentThread()); \
-   UUserEnterShared(); \
-   ASSERT(InterlockedIncrement(&_locked) == 1 /*> 0*/); \
-   DPRINT("got lock, %s, %i (%i)\n",__FILE__,__LINE__, _locked); \
-}
+#define UserEnterShared() UserEnterExclusive()
 
 #define UserEnterExclusive() \
 { \
-  /* DPRINT1("try lock, %s, %i (%i)\n",__FILE__,__LINE__, _locked);*/ \
+  /* DPRINT1("try xlock, %s, %i (%i)\n",__FILE__,__LINE__, _locked);*/ \
    if (UserLock.Owner == KeGetCurrentThread()){ \
       DPRINT1("file %s, line %i\n",_file, _line); \
       ASSERT(FALSE); \
@@ -83,27 +69,11 @@
 
 
 
-#define GetWnd(hwnd) IntGetWindowObject(hwnd)
+#define GetWnd(hwnd) UserGetWindowObject(hwnd)
 
 
 
 
-#if 0
-#define IntLockUserShared() {if(_locked){ DPRINT1("last %s, %i\n",_file,_line);} \
- IIntLockUserShared(); \
-  _locked++; _file = __FILE__; _line = __LINE__; \
-  }
-  
- #define IntUserEnterExclusive() {if(_locked){ DPRINT1("last %s, %i\n",_file,_line);} \
-  IIntUserEnterExclusive(); \
-  _locked++; _file = __FILE__; _line = __LINE__; \
-  }
-
-
-#define IntUserLeave() { if(!_locked){ DPRINT1("not locked %s, %i\n",__FILE__,__LINE__);} \
- _locked--; IIntUserLeave(); }
-#endif
-
 NTSTATUS FASTCALL InitUserImpl(VOID);
 VOID FASTCALL UninitUser(VOID);
 VOID FASTCALL UUserEnterShared(VOID);

Modified: branches/win32k rewrite attempt/win32k/include/object.h
--- branches/win32k rewrite attempt/win32k/include/object.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/object.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -6,6 +6,26 @@
 #include <win32k/pen.h>
 
 
+typedef struct _VOLATILE_OBJECT_ENTRY
+{
+   PUSER_OBJECT_HDR hdr;
+   PUSER_HANDLE_ENTRY handle_entry;
+   WORD recycle_count;
+   WORD objType;
+   SINGLE_LIST_ENTRY link;
+} VOLATILE_OBJECT_ENTRY, *PVOLATILE_OBJECT_ENTRY;
+
+
+typedef struct _OBJECT_ENTRY
+{
+   PUSER_OBJECT_HDR hdr;
+   PUSER_HANDLE_ENTRY handle_entry;
+   WORD generation;
+   WORD type;
+} OBJECT_ENTRY, *POBJECT_ENTRY;
+
+
+
 #define USER_OBJ_DESTROYING         (0x1)
 #define USER_OBJ_DESTROYED          (0x2)
 

Modified: branches/win32k rewrite attempt/win32k/include/userfuncs.h
--- branches/win32k rewrite attempt/win32k/include/userfuncs.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/userfuncs.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -12,7 +12,7 @@
 #define UserGetCurrentQueue() (&PsGetWin32Thread()->Queue)
 
 #define UserGetForegroundWThread() (QUEUE_2_WTHREAD(gInputDesktop->ActiveQueue))
-#define UserGetForegroundQueue() (gInputDesktop->ActiveQueue)
+#define UserGetForegroundQueue() (gInputDesktop ? gInputDesktop->ActiveQueue : NULL)
 #define UserSetForegroundQueue(q) (gInputDesktop->ActiveQueue = (q))
 
 
@@ -33,44 +33,28 @@
 
 /******************** OBJECT.C ***************/
 
-BOOLEAN FASTCALL UserSetCheckDestroy(PUSER_OBJECT_HDR hdr);
-
-VOID FASTCALL UserDestroyObject(PUSER_OBJECT_HDR obj);
-
 /******************** HANDLE.C ***************/
 
 extern USER_HANDLE_TABLE gHandleTable;
 
 PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle );
 
+#define VOLATILE_OBJECTS_LIST SINGLE_LIST_ENTRY __object_list__ = {NULL};
+   
+   
+#define UserLinkVolatileObject(obj) UserLinkVolatileObject2(&obj->hdr, &__object_list__, (PVOLATILE_OBJECT_ENTRY)_alloca(sizeof(VOLATILE_OBJECT_ENTRY)))
+#define UserValidateVolatileObjects()  UserValidateVolatileObjects2(&__object_list__)
 
-#include <malloc.h>
+VOID FASTCALL UserLinkVolatileObject2(PUSER_OBJECT_HDR hdr, PSINGLE_LIST_ENTRY list, PVOLATILE_OBJECT_ENTRY e);
+BOOLEAN FASTCALL UserValidateVolatileObjects2(PSINGLE_LIST_ENTRY list);
 
+#define UserGetEntry(obj) UserGetEntry2(&(obj)->hdr)
+#define UserValidateEntry(obj) UserValidateEntry2(&(obj))
 
-#define UserReferenceObject(obj) (obj->hdr.refs++)
 
-#define UserDereferenceObject(obj){ \
-   if (--obj->hdr.refs == 0 && obj->hdr.flags & USER_OBJ_DESTROYING && !(obj->hdr.flags & USER_OBJ_DESTROYED)){ \
-      UserDestroyObject(&obj->hdr); \
-   } \
-}
+inline OBJECT_ENTRY FASTCALL UserGetEntry2(PUSER_OBJECT_HDR hdr);
+inline BOOLEAN FASTCALL UserValidateEntry2(POBJECT_ENTRY e);
 
-
-#define UserReferenceObjectCo(obj){ \
-   PUSER_REFERENCE_ENTRY ref = (PUSER_REFERENCE_ENTRY)_alloca(sizeof(USER_REFERENCE_ENTRY)); \
-   obj->hdr.refs++; \
-   ref->hdr = &obj->hdr; \
-   PushEntryList(&PsGetWin32Thread()->UserObjReferencesStack, &ref->Entry); \
-}
-
-#define UserDereferenceObjectCo(obj){ \
-   PSINGLE_LIST_ENTRY entry = PopEntryList(&PsGetWin32Thread()->UserObjReferencesStack); \
-   PUSER_REFERENCE_ENTRY ref = CONTAINING_RECORD(entry, USER_REFERENCE_ENTRY, Entry); \
-   ASSERT(&obj->hdr == ref->hdr); \
-   if (--ref->hdr->refs == 0 && obj->hdr.flags & USER_OBJ_DESTROYING && !(obj->hdr.flags & USER_OBJ_DESTROYED)) { \
-      UserDestroyObject(ref->hdr); \
-   } \
-}
    
 VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes);
 HANDLE UserAllocHandle(PUSER_HANDLE_TABLE ht, PVOID object, USER_OBJECT_TYPE type );
@@ -90,7 +74,7 @@
 /************* CALLBACK.C *****************/
 
 LRESULT STDCALL
-coUserCallWindowProc(WNDPROC Proc,
+co_UserCallWindowProc(WNDPROC Proc,
                   BOOLEAN IsAnsiProc,
                   HWND Wnd,
                   UINT Message,
@@ -99,7 +83,7 @@
                   INT lParamBufferSize);
 
 VOID STDCALL
-coUserCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
+co_UserCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
              HWND hWnd,
              UINT Msg,
              ULONG_PTR CompletionCallbackContext,
@@ -107,13 +91,13 @@
 
 
 HMENU STDCALL
-coUserLoadSysMenuTemplate();
+co_UserLoadSysMenuTemplate();
 
 BOOL STDCALL
-coUserLoadDefaultCursors(VOID);
+co_UserLoadDefaultCursors(VOID);
 
 LRESULT STDCALL
-coUserCallHookProc(INT HookId,
+co_UserCallHookProc(INT HookId,
                 INT Code,
                 WPARAM wParam,
                 LPARAM lParam,
@@ -176,7 +160,7 @@
 UserGetActiveDesktop(VOID);
 
 NTSTATUS FASTCALL
-coUserShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height);
+co_UserShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height);
 
 NTSTATUS FASTCALL
 IntHideDesktop(PDESKTOP_OBJECT Desktop);
@@ -203,7 +187,7 @@
 BOOL IntRegisterShellHookWindow(HWND hWnd);
 BOOL IntDeRegisterShellHookWindow(HWND hWnd);
 
-VOID IntShellHookNotify(WPARAM Message, LPARAM lParam);
+VOID co_UserShellHookNotify(WPARAM Message, LPARAM lParam);
 
 #define IntIsActiveDesktop(Desktop) ((Desktop) == (gInputDesktop))
 
@@ -281,17 +265,17 @@
 UserGetThreadFocusWindow();
 
 BOOL FASTCALL
-coUserMouseActivateWindow(PWINDOW_OBJECT Window);
+co_UserMouseActivateWindow(PWINDOW_OBJECT Window);
 BOOL FASTCALL
-coUserSetForegroundWindow(PWINDOW_OBJECT Window);
+co_UserSetForegroundWindow(PWINDOW_OBJECT Window);
 PWINDOW_OBJECT FASTCALL
-coUserSetActiveWindow(PWINDOW_OBJECT Window);
+co_UserSetActiveWindow(PWINDOW_OBJECT Window);
 
 PWINDOW_OBJECT FASTCALL
 UserGetForegroundWindow(VOID);
 
 PWINDOW_OBJECT FASTCALL
-coUserSetFocus(PWINDOW_OBJECT Wnd OPTIONAL);
+co_UserSetFocus(PWINDOW_OBJECT Wnd OPTIONAL);
 
 
 /******************** PAINTING.C ********************************/
@@ -299,12 +283,12 @@
 VOID FASTCALL
 IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion);
 BOOL FASTCALL
-coUserRedrawWindow(PWINDOW_OBJECT Wnd, const RECT* UpdateRect, HRGN UpdateRgn, ULONG Flags);
+co_UserRedrawWindow(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 FASTCALL coUserValidateRgn(PWINDOW_OBJECT hWnd, HRGN hRgn);
+BOOL FASTCALL co_UserValidateRgn(PWINDOW_OBJECT hWnd, HRGN hRgn);
 
 
 #define IntLockWindowUpdate(Window) \
@@ -321,7 +305,7 @@
    const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate);
 
 INT FASTCALL
-coUserGetUpdateRgn(PWINDOW_OBJECT Window, HRGN hRgn, BOOL bErase);
+co_UserGetUpdateRgn(PWINDOW_OBJECT Window, HRGN hRgn, BOOL bErase);
 
 /******************** MESSAGE.C ********************************/
 
@@ -329,7 +313,7 @@
 UserPostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 
 LRESULT FASTCALL
-coUserSendMessage(HWND hWnd,
+co_UserSendMessage(HWND hWnd,
       UINT Msg,
       WPARAM wParam,
       LPARAM lParam);
@@ -337,7 +321,7 @@
 
            
 LRESULT FASTCALL
-coUserSendMessageTimeout(HWND hWnd,
+co_UserSendMessageTimeout(HWND hWnd,
                       UINT Msg,
                       WPARAM wParam,
                       LPARAM lParam,
@@ -352,12 +336,15 @@
 
 /************************ WINDOW.C *****************************/
 
+PWINDOW_OBJECT FASTCALL UserGetWindowObject_UpdateHandle2(HWND* h);
+#define UserGetWindowObject_UpdateHandle(handle) UserGetWindowObject_UpdateHandle2(&(handle))
+
 BOOL FASTCALL
 UserSetSystemMenu(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject);
 
 inline VOID FASTCALL UserFreeWindowObject(PWINDOW_OBJECT Wnd);
 
-PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd);
+inline PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd);
 
 PWINDOW_OBJECT FASTCALL UserCreateWindowObject(ULONG bytes);
 
@@ -368,14 +355,119 @@
 UserGetWindowLong(PWINDOW_OBJECT Wnd, DWORD Index, BOOL Ansi);
 
 LONG FASTCALL
-coUserSetWindowLong(PWINDOW_OBJECT Wnd, DWORD Index, LONG NewValue, BOOL Ansi);
+co_UserSetWindowLong(PWINDOW_OBJECT Wnd, DWORD Index, LONG NewValue, BOOL Ansi);
 
 BOOLEAN FASTCALL
-coUserDestroyWindow(PWINDOW_OBJECT Wnd);
+co_UserDestroyWindow(PWINDOW_OBJECT Wnd);
 
 HWND FASTCALL
-GetHwnd(PWINDOW_OBJECT Wnd);
+GetHwndSafe(PWINDOW_OBJECT Wnd);
 
+#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->ParentWnd == NULL)
+
+#define IntIsBroadcastHwnd(hWnd) \
+  (hWnd == HWND_BROADCAST || hWnd == HWND_TOPMOST)
+
+#if 0
+#define IntWndBelongsToThread(WndObj, W32Thread) \
+  (((WndObj->W32Thread->Thread && WndObj->W32Thread->Thread->Tcb.Win32Thread)) && \
+   (WndObj->W32Thread->Thread->Tcb.Win32Thread == W32Thread))
+#endif
+
+#define IntWndBelongsToThread(WndObj, _W32Thread) (QUEUE_2_WTHREAD((WndObj)->Queue) == (_W32Thread))
+
+
+#define IntGetWndThreadId(WndObj) \
+  WndObj->WThread->Thread->Cid.UniqueThread
+
+#define IntGetWndProcessId(WndObj) \
+  WndObj->WThread->Thread->ThreadsProcess->UniqueProcessId
+
+PWINDOW_OBJECT FASTCALL
+IntGetProcessWindowObject(PW32THREAD Thread, HWND hWnd);
+
+BOOL FASTCALL
+IntIsWindow(HWND hWnd);
+
+PWINDOW_OBJECT* FASTCALL
+UserListChildWnd(PWINDOW_OBJECT Window);
+
+HWND* FASTCALL 
+IntWinListChildren(PWINDOW_OBJECT Window);
+
+NTSTATUS FASTCALL
+InitWindowImpl (VOID);
+
+NTSTATUS FASTCALL
+CleanupWindowImpl (VOID);
+
+VOID FASTCALL
+IntGetClientRect (PWINDOW_OBJECT WindowObject, PRECT Rect);
+
+PWINDOW_OBJECT FASTCALL 
+UserGetActiveWindow(VOID);
+
+BOOL FASTCALL
+UserIsWindowVisible (PWINDOW_OBJECT hWnd);
+
+BOOL FASTCALL
+UserIsChildWindow (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
+UserGetAncestor(PWINDOW_OBJECT Wnd, UINT Type);
+
+PWINDOW_OBJECT FASTCALL
+UserGetParent(PWINDOW_OBJECT Wnd);
+
+inline PWINDOW_OBJECT FASTCALL
+UserGetOwner(PWINDOW_OBJECT Wnd);
+
+INT FASTCALL
+IntGetWindowRgn(HWND hWnd, HRGN hRgn);
+
+INT FASTCALL
+IntGetWindowRgnBox(HWND hWnd, RECT *Rect);
+
+PWINDOW_OBJECT FASTCALL
+UserGetShellWindow();
+
+BOOL FASTCALL
+IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi);
+
+VOID FASTCALL
+IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, UINT *cx, UINT *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);
+
+BOOL FASTCALL
+co_UserShowOwnedPopups( HWND owner, BOOL fShow );
+
 /************************* WINSTA.C ****************************/
 
 inline PWINSTATION_OBJECT FASTCALL UserGetCurrentWinSta();
@@ -441,47 +533,16 @@
 /************************* MENU.C ****************************/
 
 PMENU_OBJECT FASTCALL
-coUserGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu);
+co_UserGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu);
 
-PMENU_OBJECT FASTCALL UserAllocMenuObject(HMENU* h);
-
 inline PMENU_OBJECT FASTCALL UserGetMenuObject(HMENU hMenu);
 
-PMENU_OBJECT FASTCALL
-UserCreateMenu(BOOL PopupMenu);
-
-
-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);
-
 VOID FASTCALL
 UserDestroyMenu(PMENU_OBJECT MenuObject, BOOL bRecurse);
 
-PMENU_OBJECT FASTCALL
-IntCloneMenu(PMENU_OBJECT Source);
-
 BOOL FASTCALL
-UserSetMenuFlagRtoL(PMENU_OBJECT MenuObject);
-
-BOOL FASTCALL
-IntSetMenuContextHelpId(PMENU_OBJECT MenuObject, DWORD dwContextHelpId);
-
-BOOL FASTCALL
-UserGetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi);
-
-BOOL FASTCALL
 IntIsMenu(HMENU hMenu);
 
-BOOL FASTCALL
-UserSetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi);
 
 BOOL FASTCALL
 UserMenuItemInfo(
@@ -492,21 +553,8 @@
    BOOL Set
    );
 
-int FASTCALL
-UserGetMenuItemByFlag(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
 UserSetMenu(
    PWINDOW_OBJECT WindowObject,
    HMENU Menu,
@@ -518,11 +566,6 @@
 BOOL FASTCALL
 IntCleanupMenus(PW32PROCESS Win32Process);
 
-BOOL FASTCALL
-IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
-                  PROSMENUITEMINFO ItemInfo);
-
-
 NTSTATUS FASTCALL
 InitMenuImpl(VOID);
 
@@ -532,19 +575,19 @@
 /************************* CARET.C ****************************/
 
 BOOL FASTCALL
-coUserShowCaret(PWINDOW_OBJECT Wnd);
+co_UserShowCaret(PWINDOW_OBJECT Wnd);
 
 BOOL FASTCALL
-coUserSetCaretPos(int X, int Y);
+co_UserSetCaretPos(int X, int Y);
 
 BOOL FASTCALL
-coUserHideCaret(PWINDOW_OBJECT Wnd);
+co_UserHideCaret(PWINDOW_OBJECT Wnd);
 
 BOOL FASTCALL
 UserSwitchCaretShowing(PTHRDCARETINFO Info);
 
 BOOL FASTCALL
-coUserDestroyCaret(PW32THREAD Win32Thread);
+co_UserDestroyCaret(PW32THREAD Win32Thread);
 
 BOOL FASTCALL
 UserSetCaretBlinkTime(UINT uMSeconds);
@@ -554,14 +597,35 @@
 
 /************************* WINPOS.C ****************************/
 
+UINT
+FASTCALL co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent);
+LRESULT FASTCALL
+co_WinPosGetNonClientSize(PWINDOW_OBJECT Wnd, RECT* WindowRect, RECT* ClientRect);
+UINT FASTCALL
+co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
+          POINT* MinTrack, POINT* MaxTrack);
+UINT FASTCALL
+co_WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos);
+BOOLEAN FASTCALL
+co_WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx,
+         INT cy, UINT flags);
+BOOLEAN FASTCALL
+co_WinPosShowWindow(PWINDOW_OBJECT Wnd, INT Cmd);
+USHORT FASTCALL
+co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint,
+            PWINDOW_OBJECT* Window);
+VOID FASTCALL co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window);
 
+PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject,
+                                            POINT *pt, PRECT RestoreRect);
+
 BOOL FASTCALL
 UserGetClientOrigin(PWINDOW_OBJECT hWnd, LPPOINT Point);
 
 /************************* SCROLLBAR.C ****************************/
 
 DWORD FASTCALL
-coUserShowScrollBar(PWINDOW_OBJECT Wnd, int wBar, DWORD bShow);
+co_UserShowScrollBar(PWINDOW_OBJECT Wnd, int wBar, DWORD bShow);
 
 #define IntGetScrollbarInfoFromWindow(Window, i) \
   ((PSCROLLBARINFO)(&((Window)->Scroll + i)->ScrollBarInfo))
@@ -572,7 +636,7 @@
 #define SBOBJ_TO_SBID(Obj) ((Obj) - OBJID_HSCROLL)
 #define SBID_IS_VALID(id)  (id == SB_HORZ || id == SB_VERT || id == SB_CTL)
 
-BOOL FASTCALL coIntCreateScrollBars(PWINDOW_OBJECT Window);
+BOOL FASTCALL co_IntCreateScrollBars(PWINDOW_OBJECT Window);
 BOOL FASTCALL IntDestroyScrollBars(PWINDOW_OBJECT Window);
 
 
@@ -603,7 +667,7 @@
 PHOOK FASTCALL UserCreateHookObject();
 
 PHOOK FASTCALL UserGetHookObject(HHOOK hHook);
-LRESULT FASTCALL coHOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam);
+LRESULT FASTCALL co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam);
 VOID FASTCALL HOOK_DestroyThreadHooks(PETHREAD Thread);
 
 
@@ -724,7 +788,7 @@
 BOOL FASTCALL
 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue);
 NTSTATUS FASTCALL
-coMsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
+co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
           HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
                UINT uTimeout, BOOL Block, BOOL HookMessage,
                ULONG_PTR *uResult);
@@ -738,7 +802,7 @@
 VOID FASTCALL
 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode);
 BOOLEAN STDCALL
-coMsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
+co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
           IN BOOLEAN Hardware,
           IN BOOLEAN Remove,
           IN HWND Wnd,
@@ -756,9 +820,9 @@
 NTSTATUS FASTCALL
 MsqInitializeImpl(VOID);
 BOOLEAN FASTCALL
-coMsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue);
+co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue);
 NTSTATUS FASTCALL
-coMsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter,
+co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter,
                       UINT MsgFilterMin, UINT MsgFilterMax);
 VOID FASTCALL
 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
@@ -774,7 +838,7 @@
 
 
 VOID FASTCALL
-coMsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
 VOID FASTCALL
 MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam);
 VOID FASTCALL
@@ -854,7 +918,7 @@
    BOOLEAN ClipChildren, BOOLEAN ClipSiblings);
 
 VOID FASTCALL
-coVIS_WindowLayoutChanged(PWINDOW_OBJECT Window, HRGN UncoveredRgn);
+co_VIS_WindowLayoutChanged(PWINDOW_OBJECT Window, HRGN UncoveredRgn);
 
 
 /**************************** NTUSER.C ************************/

Modified: branches/win32k rewrite attempt/win32k/include/win32.h
--- branches/win32k rewrite attempt/win32k/include/win32.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/win32.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -28,11 +28,9 @@
 
 typedef struct _W32PROCESS
 {
-//  FAST_MUTEX ClassListLock;
   PEPROCESS Process;
   LIST_ENTRY ClassListHead;
   LIST_ENTRY ExpiredTimersList;
-//  FAST_MUTEX MenuListLock;
   LIST_ENTRY MenuListHead;
   FAST_MUTEX PrivateFontListLock;
   LIST_ENTRY PrivateFontListHead;

Modified: branches/win32k rewrite attempt/win32k/include/window.h
--- branches/win32k rewrite attempt/win32k/include/window.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/window.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -33,7 +33,6 @@
       {
       /*---------- USER_OBJECT_HDR --------------*/
         HWND hSelf; /* typesafe handle */
-        LONG refs_placeholder;
         BYTE hdrFlags_placeholder;
       /*---------- USER_OBJECT_HDR --------------*/
 
@@ -82,8 +81,8 @@
         LIST_ENTRY ThreadListEntry;
         /* Handle to the parent window. */
         PWINDOW_OBJECT ParentWnd;
-        /* Handle to the owner window. */
-        HWND hOwner;
+        /* the owner window. */
+        HWND hOwnerWnd;
         /* DC Entries (DCE) */
         PDCE Dce;
 
@@ -103,7 +102,7 @@
         PUSER_MESSAGE_QUEUE Queue;
         PW32THREAD WThread;
          };
-        HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
+        HWND hLastActiveWnd; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
         PINTERNALPOS InternalPos;
       //  ULONG Status;
         /* counter for tiled child windows */
@@ -122,111 +121,8 @@
 #define WINDOWOBJECT_RESTOREMAX           (0x00000020)
 
 
-#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->ParentWnd == NULL)
-
-#define IntIsBroadcastHwnd(hWnd) \
-  (hWnd == HWND_BROADCAST || hWnd == HWND_TOPMOST)
-
-#if 0
-#define IntWndBelongsToThread(WndObj, W32Thread) \
-  (((WndObj->W32Thread->Thread && WndObj->W32Thread->Thread->Tcb.Win32Thread)) && \
-   (WndObj->W32Thread->Thread->Tcb.Win32Thread == W32Thread))
-#endif
-
-#define IntWndBelongsToThread(WndObj, _W32Thread) (QUEUE_2_WTHREAD((WndObj)->Queue) == (_W32Thread))
-
-
-#define IntGetWndThreadId(WndObj) \
-  WndObj->WThread->Thread->Cid.UniqueThread
-
-#define IntGetWndProcessId(WndObj) \
-  WndObj->WThread->Thread->ThreadsProcess->UniqueProcessId
-
-PWINDOW_OBJECT FASTCALL
-IntGetProcessWindowObject(PW32THREAD Thread, HWND hWnd);
-
-BOOL FASTCALL
-IntIsWindow(HWND hWnd);
-
-PWINDOW_OBJECT* FASTCALL
-UserListChildWnd(PWINDOW_OBJECT Window);
-
-HWND* FASTCALL 
-IntWinListChildren(PWINDOW_OBJECT Window);
-
-NTSTATUS FASTCALL
-InitWindowImpl (VOID);
-
-NTSTATUS FASTCALL
-CleanupWindowImpl (VOID);
-
-VOID FASTCALL
-IntGetClientRect (PWINDOW_OBJECT WindowObject, PRECT Rect);
-
-PWINDOW_OBJECT FASTCALL 
-UserGetActiveWindow(VOID);
-
-BOOL FASTCALL
-UserIsWindowVisible (PWINDOW_OBJECT hWnd);
-
-BOOL FASTCALL
-UserIsChildWindow (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
-UserGetAncestor(PWINDOW_OBJECT Wnd, UINT Type);
-
-PWINDOW_OBJECT FASTCALL
-UserGetParent(PWINDOW_OBJECT Wnd);
-
-PWINDOW_OBJECT FASTCALL
-IntGetOwner(PWINDOW_OBJECT Wnd);
-
-INT FASTCALL
-IntGetWindowRgn(HWND hWnd, HRGN hRgn);
-
-INT FASTCALL
-IntGetWindowRgnBox(HWND hWnd, RECT *Rect);
-
-PWINDOW_OBJECT FASTCALL
-UserGetShellWindow();
-
-BOOL FASTCALL
-IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi);
-
-VOID FASTCALL
-IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, UINT *cx, UINT *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);
-
-BOOL FASTCALL
-coUserShowOwnedPopups( HWND owner, BOOL fShow );
-
 #endif /* _WIN32K_WINDOW_H */
 
 /* EOF */

Modified: branches/win32k rewrite attempt/win32k/include/winpos.h
--- branches/win32k rewrite attempt/win32k/include/winpos.h	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/include/winpos.h	2005-09-02 20:45:56 UTC (rev 17607)
@@ -14,26 +14,5 @@
     NtGdiPtInRegion((WndObject)->WindowRegion, (INT)((x) - (WndObject)->WindowRect.left), \
                     (INT)((y) - (WndObject)->WindowRect.top))))
 
-UINT
-FASTCALL coWinPosArrangeIconicWindows(PWINDOW_OBJECT parent);
-LRESULT FASTCALL
-coWinPosGetNonClientSize(PWINDOW_OBJECT Wnd, RECT* WindowRect, RECT* ClientRect);
-UINT FASTCALL
-coWinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
-		    POINT* MinTrack, POINT* MaxTrack);
-UINT FASTCALL
-coWinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos);
-BOOLEAN FASTCALL
-coWinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx,
-		   INT cy, UINT flags);
-BOOLEAN FASTCALL
-coWinPosShowWindow(PWINDOW_OBJECT Wnd, INT Cmd);
-USHORT FASTCALL
-coWinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint,
-		      PWINDOW_OBJECT* Window);
-VOID FASTCALL coWinPosActivateOtherWindow(PWINDOW_OBJECT Window);
 
-PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject,
-                                            POINT *pt, PRECT RestoreRect);
-
 #endif /* _WIN32K_WINPOS_H */

Modified: branches/win32k rewrite attempt/win32k/ntuser/accelerator.c
--- branches/win32k rewrite attempt/win32k/ntuser/accelerator.c	2005-09-02 19:05:01 UTC (rev 17606)
+++ branches/win32k rewrite attempt/win32k/ntuser/accelerator.c	2005-09-02 20:45:56 UTC (rev 17607)
@@ -54,6 +54,45 @@
 #define NDEBUG
 #include <debug.h>
 
+
+/* USER OBJECT FUNCTIONS *******************************************************/
+
+BOOLEAN FASTCALL UserDestroyAccel(PACCELERATOR_TABLE Accel)
+{
+   ASSERT_LOCK(ulExclusive);
+   
+   if (Accel->Table != NULL)
+   {
+      ExFreePool(Accel->Table);
+   }
+   
+   UserFreeHandle(&gHandleTable, Accel->hdr.hSelf);
+   UserFree(Accel);
+   
+   return TRUE;
+}
+
+
+PACCELERATOR_TABLE FASTCALL UserCreateAccelObject()
+{
+   PACCELERATOR_TABLE Accel;
+   HACCEL hAccel;
+   
+   ASSERT_LOCK(ulExclusive);
+   
+   Accel = (PACCELERATOR_TABLE)UserAllocZero(sizeof(ACCELERATOR_TABLE));
+   if (!Accel) return NULL;
+
+   hAccel = UserAllocHandle(&gHandleTable, Accel, otAccel);
+   if (!hAccel){
+      UserFree(Accel);
+      return NULL;
+   }
+   Accel->hSelf=hAccel;
+   return Accel;
+}
+
+
 /* FUNCTIONS *****************************************************************/
 
 NTSTATUS FASTCALL
@@ -71,21 +110,19 @@
 int
 STDCALL
 NtUserCopyAcceleratorTable(
-   HACCEL Table,
+   HACCEL hAccel,
    LPACCEL Entries,
    int EntriesCount)
 {
-   PACCELERATOR_TABLE AcceleratorTable;
+   PACCELERATOR_TABLE Accel;
    NTSTATUS Status;
    int Ret;
    DECLARE_RETURN(int);
 
[truncated at 1000 lines; 13185 more skipped]