Author: hbelusca
Date: Wed Oct 31 00:26:38 2012
New Revision: 57653
URL: 
http://svn.reactos.org/svn/reactos?rev=57653&view=rev
Log:
Synchronize with trunk's revision r57652.
Added:
    branches/ros-csrss/dll/opengl/glu32/
      - copied from r57633, trunk/reactos/dll/opengl/glu32/
    branches/ros-csrss/win32ss/user/ntuser/cursoricon_new.c
      - copied unchanged from r57652, trunk/reactos/win32ss/user/ntuser/cursoricon_new.c
    branches/ros-csrss/win32ss/user/user32/windows/cursoricon_new.c
      - copied unchanged from r57652,
trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c
Modified:
    branches/ros-csrss/   (props changed)
    branches/ros-csrss/dll/win32/kernel32/k32.h
    branches/ros-csrss/drivers/hid/hidparse/   (props changed)
    branches/ros-csrss/drivers/usb/usbhub/   (props changed)
    branches/ros-csrss/win32ss/CMakeLists.txt
    branches/ros-csrss/win32ss/gdi/ntgdi/misc.h
    branches/ros-csrss/win32ss/include/ntuser.h
    branches/ros-csrss/win32ss/user/ntuser/callproc.c
    branches/ros-csrss/win32ss/user/ntuser/clipboard.c
    branches/ros-csrss/win32ss/user/ntuser/cursoricon.c
    branches/ros-csrss/win32ss/user/ntuser/cursoricon.h
    branches/ros-csrss/win32ss/user/ntuser/hook.c
    branches/ros-csrss/win32ss/user/ntuser/msgqueue.c
    branches/ros-csrss/win32ss/user/ntuser/object.c
    branches/ros-csrss/win32ss/user/ntuser/object.h
    branches/ros-csrss/win32ss/user/ntuser/painting.c
    branches/ros-csrss/win32ss/user/ntuser/winsta.c
    branches/ros-csrss/win32ss/user/user32/CMakeLists.txt
    branches/ros-csrss/win32ss/user/user32/misc/exticon.c
    branches/ros-csrss/win32ss/user/user32/misc/object.c
Propchange: branches/ros-csrss/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 31 00:26:38 2012
@@ -13,4 +13,4 @@
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
 /branches/wlan-bringup:54809-54998
-/trunk/reactos:57561-57641
+/trunk/reactos:57561-57652
Modified: branches/ros-csrss/dll/win32/kernel32/k32.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/k3…
==============================================================================
--- branches/ros-csrss/dll/win32/kernel32/k32.h [iso-8859-1] (original)
+++ branches/ros-csrss/dll/win32/kernel32/k32.h [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -41,7 +41,6 @@
 #include <win/basemsg.h>
 #include <win/conmsg.h>
 #include <win/winmsg.h>
-//#include <csr/csrss.h> // FIXME: data header.
 /* C Headers */
 #include <ctype.h>
Propchange: branches/ros-csrss/drivers/hid/hidparse/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 31 00:26:38 2012
@@ -18,5 +18,5 @@
/branches/usb-bringup/drivers/hid/hidparse:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
 /branches/usb-bringup-trunk/drivers/hid/hidparse:55020-55543,55548-55554
 /branches/wlan-bringup/drivers/hid/hidparse:54809-54998
-/trunk/reactos/drivers/hid/hidparse:57561-57599
+/trunk/reactos/drivers/hid/hidparse:57561-57633
 /trunk/reactos/drivers/usb/hidparse:48236-51323
Propchange: branches/ros-csrss/drivers/usb/usbhub/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 31 00:26:38 2012
@@ -27,4 +27,4 @@
 /branches/usb-bringup-trunk/drivers/usb/usbhub:55524-55543,55548-55554
 /branches/wlan-bringup/drivers/usb/usbhub:54809-54998
 /branches/wlan-bringup/drivers/usb/usbhub_new:54809-54998
-/trunk/reactos/drivers/usb/usbhub:57561-57629
+/trunk/reactos/drivers/usb/usbhub:57561-57633
Modified: branches/ros-csrss/win32ss/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/CMakeLists.tx…
==============================================================================
--- branches/ros-csrss/win32ss/CMakeLists.txt [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/CMakeLists.txt [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -1,5 +1,6 @@
 set(USE_DIBLIB FALSE)
+set(USE_NEW_CURSORICON FALSE)
 # Give WIN32 subsystem its own project.
 PROJECT(WIN32SS)
@@ -103,7 +104,6 @@
     user/ntuser/class.c
     user/ntuser/clipboard.c
     user/ntuser/csr.c
-    user/ntuser/cursoricon.c
     user/ntuser/defwnd.c
     user/ntuser/desktop.c
     user/ntuser/display.c
@@ -190,6 +190,13 @@
         ${GENDIB_FILES})
 endif()
+if(USE_NEW_CURSORICON)
+    add_definitions(-DNEW_CURSORICON)
+    list(APPEND SOURCE user/ntuser/cursoricon_new.c)
+else()
+    list(APPEND SOURCE user/ntuser/cursoricon.c)
+endif()
+
 if(ARCH STREQUAL "i386")
 list(APPEND SOURCE
     gdi/dib/i386/dib24bpp_hline.s
Modified: branches/ros-csrss/win32ss/gdi/ntgdi/misc.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/gdi/ntgdi/mis…
==============================================================================
--- branches/ros-csrss/win32ss/gdi/ntgdi/misc.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/gdi/ntgdi/misc.h [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -163,6 +163,6 @@
 #define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \
     for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \
          (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \
-         &(cursor)->field != (list) && ((&((cursor)->field)) !=
NULL); \
+         &(cursor)->field != (list); \
          (cursor) = (cursor2), \
          (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field))
Modified: branches/ros-csrss/win32ss/include/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/include/ntuse…
==============================================================================
--- branches/ros-csrss/win32ss/include/ntuser.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/include/ntuser.h [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -200,7 +200,6 @@
   struct _DESKTOP *rpdesk;
   /* ReactOS */
   LIST_ENTRY     Chain;      /* Hook chain entry */
-  struct _ETHREAD* Thread;   /* Thread owning the hook */
   HOOKPROC       Proc;       /* Hook function */
   BOOLEAN        Ansi;       /* Is it an Ansi hook? */
   UNICODE_STRING ModuleName; /* Module name for global hooks */
@@ -2739,14 +2738,24 @@
   HANDLE Handle,
   PICONINFO IconInfo);
-#if 0 // Correct type.
+#ifdef NEW_CURSORICON
 BOOL
 NTAPI
 NtUserSetCursorIconData(
-  HCURSOR hCursor,
-  PUNICODE_STRING ModuleName,
-  PUNICODE_STRING ResourceName,
-  PCURSORDATA pCursorData);
+  _In_ HCURSOR hCursor,
+  _In_ HINSTANCE hinst,
+  _In_ HRSRC hrsrc,
+  _In_ PICONINFO pii);
+#else
+BOOL
+NTAPI
+NtUserSetCursorIconData(
+  HANDLE Handle,
+  PBOOL fIcon,
+  POINT *Hotspot,
+  HMODULE hModule,
+  HRSRC hRsrc,
+  HRSRC hGroupRsrc);
 #endif
 DWORD
@@ -3361,16 +3370,6 @@
   IN HWND hWnd,
   IN DWORD dwFlags);
-BOOL
-NTAPI
-NtUserSetCursorIconData(
-  HANDLE Handle,
-  PBOOL fIcon,
-  POINT *Hotspot,
-  HMODULE hModule,
-  HRSRC hRsrc,
-  HRSRC hGroupRsrc);
-
 typedef struct _SETSCROLLBARINFO
 {
   int nTrackPos;
Modified: branches/ros-csrss/win32ss/user/ntuser/callproc.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/callproc.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/callproc.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -45,6 +45,9 @@
         NewCallProc->wType |= Unicode ? UserGetCPDA2U : UserGetCPDU2A ;
         NewCallProc->spcpdNext = NULL;
     }
+
+    /* Release the extra reference (UserCreateObject added 2 references) */
+    UserDereferenceObject(NewCallProc);
     return NewCallProc;
 }
Modified: branches/ros-csrss/win32ss/user/ntuser/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/clipboard.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/clipboard.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -211,6 +211,9 @@
     /* Add the clipboard data */
     IntAddFormatedData(pWinStaObj, CF_DIB, hMem, TRUE, TRUE);
+    /* Release the extra reference (UserCreateObject added 2 references) */
+    UserDereferenceObject(pClipboardData);
+
 cleanup:
     UserReleaseDC(NULL, hdc, FALSE);
 }
@@ -302,6 +305,9 @@
             *((LCID*)pMemObj->Data) = NtCurrentTeb()->CurrentLocale;
             IntAddFormatedData(pWinStaObj, CF_LOCALE, hMem, TRUE, TRUE);
         }
+
+        /* Release the extra reference (UserCreateObject added 2 references) */
+        UserDereferenceObject(pMemObj);
     }
     /* Add CF_TEXT. Note: it is synthesized in user32.dll */
@@ -1099,6 +1105,9 @@
     }
     _SEH2_END;
+    /* Release the extra reference (UserCreateObject added 2 references) */
+    UserDereferenceObject(pMemObj);
+
     /* If we failed to copy data, remove handle */
     if (!pMemObj)
     {
Modified: branches/ros-csrss/win32ss/user/ntuser/cursoricon.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -234,55 +234,54 @@
 }
 BOOLEAN FASTCALL
-IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, BOOL ProcessCleanup)
+IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi)
 {
     PSYSTEM_CURSORINFO CurInfo;
     HBITMAP bmpMask, bmpColor;
-    BOOLEAN Ret;
+    BOOLEAN Ret, bListEmpty, bFound = FALSE;
     PCURICON_PROCESS Current = NULL;
-    PPROCESSINFO W32Process = PsGetCurrentProcessWin32Process();
-
-    /* Private objects can only be destroyed by their own process */
-    if (NULL == CurIcon->hModule)
-    {
-        ASSERT(CurIcon->ProcessList.Flink->Flink == &CurIcon->ProcessList);
-        Current = CONTAINING_RECORD(CurIcon->ProcessList.Flink, CURICON_PROCESS,
ListEntry);
-        if (Current->Process != W32Process)
-        {
-            ERR("Trying to destroy private icon/cursor of another process\n");
-            return FALSE;
-        }
-    }
-    else if (! ProcessCleanup)
-    {
-        TRACE("Trying to destroy shared icon/cursor\n");
-        return FALSE;
-    }
+
+    /* For handles created without any data (error handling) */
+    if(IsListEmpty(&CurIcon->ProcessList))
+        goto emptyList;
     /* Now find this process in the list of processes referencing this object and
        remove it from that list */
     LIST_FOR_EACH(Current, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry)
     {
-        if (Current->Process == W32Process)
-        {
-            RemoveEntryList(&Current->ListEntry);
+        if (Current->Process == ppi)
+        {
+            bFound = TRUE;
+            bListEmpty = RemoveEntryList(&Current->ListEntry);
             break;
         }
     }
+
+    if(!bFound)
+    {
+        /* This object doesn't belong to this process */
+        EngSetLastError(ERROR_INVALID_HANDLE);
+        return FALSE;
+    }
     ExFreeToPagedLookasideList(pgProcessLookasideList, Current);
     /* If there are still processes referencing this object we can't destroy it yet
*/
-    if (! IsListEmpty(&CurIcon->ProcessList))
-    {
+    if (!bListEmpty)
+    {
+        if(CurIcon->head.ppi == ppi)
+        {
+            /* Set the first process of the list as owner */
+            Current = CONTAINING_RECORD(CurIcon->ProcessList.Flink, CURICON_PROCESS,
ListEntry);
+            UserSetObjectOwner(CurIcon, otCursorIcon, Current->Process);
+        }
+        UserDereferenceObject(CurIcon);
         return TRUE;
     }
-
-    if (! ProcessCleanup)
-    {
-        RemoveEntryList(&CurIcon->ListEntry);
-    }
+emptyList:
+    /* Remove it from the list */
+    RemoveEntryList(&CurIcon->ListEntry);
     CurInfo = IntGetSysCursorInfo();
@@ -320,33 +319,13 @@
 IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
 {
     PCURICON_OBJECT CurIcon, tmp;
-    PCURICON_PROCESS ProcessData;
-
+
+    /* Run through the list of icon objects */
     LIST_FOR_EACH_SAFE(CurIcon, tmp, &gCurIconList, CURICON_OBJECT, ListEntry)
     {
         UserReferenceObject(CurIcon);
-        //    if(NT_SUCCESS(UserReferenceObjectByPointer(Object, otCursorIcon)))
-        {
-            LIST_FOR_EACH(ProcessData, &CurIcon->ProcessList, CURICON_PROCESS,
ListEntry)
-            {
-                if (Win32Process == ProcessData->Process)
-                {
-                    RemoveEntryList(&CurIcon->ListEntry);
-                    IntDestroyCurIconObject(CurIcon, TRUE);
-                    CurIcon = NULL;
-                    break;
-                }
-            }
-
-//         UserDereferenceObject(Object);
-        }
-
-        if (CurIcon)
-        {
-            UserDereferenceObject(CurIcon);
-        }
-    }
-
+        IntDestroyCurIconObject(CurIcon, Win32Process);
+    }
 }
@@ -649,7 +628,7 @@
         RETURN(FALSE);
     }
-    ret = IntDestroyCurIconObject(CurIcon, FALSE);
+    ret = IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process());
     /* Note: IntDestroyCurIconObject will remove our reference for us! */
     RETURN(ret);
Modified: branches/ros-csrss/win32ss/user/ntuser/cursoricon.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/cursoricon.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/cursoricon.h [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -7,6 +7,31 @@
   LIST_ENTRY ListEntry;
   PPROCESSINFO Process;
 } CURICON_PROCESS, *PCURICON_PROCESS;
+
+#ifdef NEW_CURSORICON
+typedef struct _CURICON_FRAME
+{
+    HBITMAP hbmMask;
+    HBITMAP hbmColor;
+    HBITMAP hbmAlpha;
+} CURICON_FRAME, *PCURICON_FRAME;
+
+typedef struct _CURICON_OBJECT
+{
+  PROCMARKHEAD head;
+  LIST_ENTRY ListEntry;
+  HANDLE Self;
+  LIST_ENTRY ProcessList;
+  HMODULE hModule;
+  HRSRC hRsrc;
+  SIZE Size;
+  BYTE Shadow;
+  BOOL bIcon;
+  POINTL ptlHotspot;
+  CURICON_FRAME aFrame[1];
+} CURICON_OBJECT, *PCURICON_OBJECT;
+
+#else
 typedef struct _CURICON_OBJECT
 {
@@ -21,6 +46,7 @@
   BYTE Shadow;
   ICONINFO IconInfo;
 } CURICON_OBJECT, *PCURICON_OBJECT;
+#endif
 typedef struct _CURSORACCELERATION_INFO
 {
Modified: branches/ros-csrss/win32ss/user/ntuser/hook.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/h…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/hook.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/hook.c [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -250,8 +250,8 @@
     BOOL Block = FALSE;
     ULONG_PTR uResult = 0;
-    if (Hook->Thread)
-       pti = Hook->Thread->Tcb.Win32Thread;
+    if (Hook->ptiHooked)
+       pti = Hook->ptiHooked;
     else
        pti = Hook->head.pti;
@@ -990,9 +990,9 @@
     PLIST_ENTRY pLastHead, pElem;
     PTHREADINFO pti;
-    if (Hook->Thread)
-    {
-       pti = ((PTHREADINFO)Hook->Thread->Tcb.Win32Thread);
+    if (Hook->ptiHooked)
+    {
+       pti = Hook->ptiHooked;
        pLastHead = &pti->aphkStart[HOOKID_TO_INDEX(HookId)];
     }
     else
@@ -1035,9 +1035,9 @@
     HookId = Hook->HookId;
-    if (Hook->Thread) // Local
-    {
-       pti = ((PTHREADINFO)Hook->Thread->Tcb.Win32Thread);
+    if (Hook->ptiHooked) // Local
+    {
+       pti = Hook->ptiHooked;
        IntFreeHook( Hook);
@@ -1496,8 +1496,6 @@
        ptiHook = Thread->Tcb.Win32Thread;
-       ObDereferenceObject(Thread);
-
        if ( ptiHook->rpdesk != pti->rpdesk) // gptiCurrent->rpdesk)
        {
           ERR("Local hook wrong desktop HookId: %d\n",HookId);
@@ -1577,7 +1575,6 @@
     }
     Hook->ihmod   = (INT)Mod; // Module Index from atom table, Do this for now.
-    Hook->Thread  = Thread; /* Set Thread, Null is Global. */
     Hook->HookId  = HookId;
     Hook->rpdesk  = ptiHook->rpdesk;
     Hook->phkNext = NULL; /* Dont use as a chain! Use link lists for chaining. */
@@ -1684,6 +1681,7 @@
 CLEANUP:
     TRACE("Leave NtUserSetWindowsHookEx, ret=%i\n",_ret_);
+    if (Thread) ObDereferenceObject(Thread);
     UserLeave();
     END_CLEANUP;
 }
Modified: branches/ros-csrss/win32ss/user/ntuser/msgqueue.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/msgqueue.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/msgqueue.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -145,6 +145,15 @@
         if (NewCursor)
         {
             /* Call GDI to set the new screen cursor */
+#ifdef NEW_CURSORICON
+            GreSetPointerShape(hdcScreen,
+                               NewCursor->aFrame[0].hbmMask,
+                               NewCursor->aFrame[0].hbmColor,
+                               NewCursor->ptlHotspot.x,
+                               NewCursor->ptlHotspot.y,
+                               gpsi->ptCursor.x,
+                               gpsi->ptCursor.y);
+#else
             GreSetPointerShape(hdcScreen,
                                NewCursor->IconInfo.hbmMask,
                                NewCursor->IconInfo.hbmColor,
@@ -152,6 +161,7 @@
                                NewCursor->IconInfo.yHotspot,
                                gpsi->ptCursor.x,
                                gpsi->ptCursor.y);
+#endif
         }
         else /* Note: OldCursor != NewCursor so we have to hide cursor */
         {
@@ -571,13 +581,23 @@
                if(CurInfo->CurrentCursorObject != MessageQueue->CursorObject)
                {
                    /* Call GDI to set the new screen cursor */
+#ifdef NEW_CURSORICON
                    GreSetPointerShape(hdcScreen,
+
MessageQueue->CursorObject->aFrame[0].hbmMask,
+
MessageQueue->CursorObject->aFrame[0].hbmColor,
+                                      MessageQueue->CursorObject->ptlHotspot.x,
+                                      MessageQueue->CursorObject->ptlHotspot.y,
+                                      gpsi->ptCursor.x,
+                                      gpsi->ptCursor.y);
+#else
+                    GreSetPointerShape(hdcScreen,
                                       MessageQueue->CursorObject->IconInfo.hbmMask,
MessageQueue->CursorObject->IconInfo.hbmColor,
MessageQueue->CursorObject->IconInfo.xHotspot,
MessageQueue->CursorObject->IconInfo.yHotspot,
                                       gpsi->ptCursor.x,
                                       gpsi->ptCursor.y);
+#endif
                } else
                    GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y);
            }
Modified: branches/ros-csrss/win32ss/user/ntuser/object.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/o…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/object.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/object.c [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -516,6 +516,38 @@
     return object;
 }
+VOID
+FASTCALL
+UserSetObjectOwner(PVOID obj, USER_OBJECT_TYPE type, PVOID owner)
+{
+    PUSER_HANDLE_ENTRY entry = handle_to_entry(gHandleTable, ((PHEAD)obj)->h );
+    PPROCESSINFO ppi, oldppi;
+
+    /* This must be called with a valid object */
+    ASSERT(entry);
+
+    /* For now, only supported for CursorIcon object */
+    switch(type)
+    {
+        case otCursorIcon:
+            ppi = (PPROCESSINFO)owner;
+            entry->pi = ppi;
+            oldppi = ((PPROCMARKHEAD)obj)->ppi;
+            ((PPROCMARKHEAD)obj)->ppi = ppi;
+            break;
+        default:
+            ASSERT(FALSE);
+            return;
+    }
+
+    oldppi->UserHandleCount--;
+    ppi->UserHandleCount++;
+#if DBG
+    oldppi->DbgHandleCount[type]--;
+    ppi->DbgHandleCount[type]++;
+#endif
+}
+
 /*
  * NtUserValidateHandleSecure
  *
Modified: branches/ros-csrss/win32ss/user/ntuser/object.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/o…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/object.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/object.h [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -40,6 +40,7 @@
 BOOL FASTCALL UserCreateHandleTable(VOID);
 BOOL FASTCALL UserObjectInDestroy(HANDLE);
 void DbgUserDumpHandleTable();
+VOID FASTCALL UserSetObjectOwner(PVOID obj, USER_OBJECT_TYPE type, PVOID owner);
 static __inline VOID
 UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Modified: branches/ros-csrss/win32ss/user/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/p…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/painting.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/painting.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -2003,6 +2003,7 @@
          LONG x = Rect.left - cx/2 + 1 + (Rect.bottom - Rect.top)/2; // this is really
what Window does
          LONG y = (Rect.top + Rect.bottom)/2 - cy/2; // center
          UserDrawIconEx(hDc, x, y, pIcon, cx, cy, 0, NULL, DI_NORMAL);
+         UserDereferenceObject(pIcon);
       }
    }
Modified: branches/ros-csrss/win32ss/user/ntuser/winsta.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/w…
==============================================================================
--- branches/ros-csrss/win32ss/user/ntuser/winsta.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/ntuser/winsta.c [iso-8859-1] Wed Oct 31 00:26:38 2012
@@ -526,7 +526,7 @@
        if (hWinSta == UserGetProcessWindowStation())
        {
-        ERR("Attempted to close process window station");
+        ERR("Attempted to close process window station\n");
                return FALSE;
        }
@@ -612,19 +612,13 @@
    /* try windowstation */
    TRACE("Trying to open window station 0x%x\n", hObject);
-   Status = IntValidateWindowStationHandle(
+   Status = ObReferenceObjectByHandle(
                hObject,
+               0,
+               ExWindowStationObjectType,
                UserMode,
-               0,
-               &WinStaObject);
-
-
-   if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_TYPE_MISMATCH)
-   {
-      TRACE("Failed: 0x%x\n", Status);
-      SetLastNtError(Status);
-      return FALSE;
-   }
+               (PVOID*)&WinStaObject,
+               NULL);
    if (Status == STATUS_OBJECT_TYPE_MISMATCH)
    {
@@ -635,13 +629,15 @@
                   UserMode,
                   0,
                   &DesktopObject);
-      if (!NT_SUCCESS(Status))
-      {
-         TRACE("Failed: 0x%x\n", Status);
-         SetLastNtError(Status);
-         return FALSE;
-      }
-   }
+   }
+
+   if (!NT_SUCCESS(Status))
+   {
+      ERR("Failed: 0x%x\n", Status);
+      SetLastNtError(Status);
+      return FALSE;
+   }
+
    TRACE("WinSta or Desktop opened!!\n");
    /* get data */
@@ -713,8 +709,13 @@
    if (DesktopObject != NULL)
       ObDereferenceObject(DesktopObject);
-   SetLastNtError(Status);
-   return NT_SUCCESS(Status);
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return FALSE;
+   }
+
+   return TRUE;
 }
 /*
Modified: branches/ros-csrss/win32ss/user/user32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/C…
==============================================================================
--- branches/ros-csrss/win32ss/user/user32/CMakeLists.txt [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/user32/CMakeLists.txt [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -41,7 +41,7 @@
     windows/caret.c
     windows/class.c
     windows/clipboard.c
-    windows/cursoricon.c
+#   windows/cursoricon.c
     windows/dc.c
     windows/defwnd.c
     windows/dialog.c
@@ -64,6 +64,12 @@
     user32.rc
     ${CMAKE_CURRENT_BINARY_DIR}/user32.def)
+if(USE_NEW_CURSORICON)
+    list(APPEND SOURCE windows/cursoricon_new.c)
+else()
+    list(APPEND SOURCE windows/cursoricon.c)
+endif()
+
 add_library(user32 SHARED ${SOURCE})
 set_module_type(user32 win32dll UNICODE)
Modified: branches/ros-csrss/win32ss/user/user32/misc/exticon.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/m…
==============================================================================
--- branches/ros-csrss/win32ss/user/user32/misc/exticon.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/user32/misc/exticon.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -29,30 +29,6 @@
 /* Start of Hack section */
 WINE_DEFAULT_DEBUG_CHANNEL(icon);
-
-#include "pshpack1.h"
-
-typedef struct
-{
-    BYTE        bWidth;          /* Width, in pixels, of the image     */
-    BYTE        bHeight;         /* Height, in pixels, of the image    */
-    BYTE        bColorCount;     /* Number of colors in image (0 if >=8bpp) */
-    BYTE        bReserved;       /* Reserved ( must be 0)              */
-    WORD        wPlanes;         /* Color Planes                       */
-    WORD        wBitCount;       /* Bits per pixel                     */
-    DWORD       dwBytesInRes;    /* How many bytes in this resource?   */
-    DWORD       dwImageOffset;   /* Where in the file is this image?   */
-} icoICONDIRENTRY, *LPicoICONDIRENTRY;
-
-typedef struct
-{
-    WORD            idReserved;   /* Reserved (must be 0) */
-    WORD            idType;       /* Resource Type (RES_ICON or RES_CURSOR) */
-    WORD            idCount;      /* How many images */
-    icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
-} icoICONDIR, *LPicoICONDIR;
-
-#include "poppack.h"
 #if 0
 static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry )
Modified: branches/ros-csrss/win32ss/user/user32/misc/object.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/m…
==============================================================================
--- branches/ros-csrss/win32ss/user/user32/misc/object.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/user32/misc/object.c [iso-8859-1] Wed Oct 31 00:26:38
2012
@@ -48,7 +48,8 @@
   LPDWORD lpnLengthNeeded)
 {
   LPWSTR buffer;
-  BOOL ret = TRUE;
+  BOOL ret = FALSE;
+  DWORD LengthNeeded;
   TRACE("GetUserObjectInformationA(%x %d %x %d %x)\n", hObj, nIndex,
          pvInfo, nLength, lpnLengthNeeded);
@@ -65,17 +66,16 @@
   }
   /* get unicode string */
-  if (!GetUserObjectInformationW(hObj, nIndex, buffer, nLength*2, lpnLengthNeeded))
-    ret = FALSE;
-  *lpnLengthNeeded /= 2;
-
-  if (ret)
+  if (GetUserObjectInformationW(hObj, nIndex, buffer, nLength*2, lpnLengthNeeded))
   {
     /* convert string */
-    if (WideCharToMultiByte(CP_THREAD_ACP, 0, buffer, -1,
-                            pvInfo, nLength, NULL, NULL) == 0)
+    LengthNeeded = WideCharToMultiByte(CP_THREAD_ACP, 0, buffer, -1,
+                                       pvInfo, nLength, NULL, NULL);
+
+    if (LengthNeeded != 0)
     {
-      ret = FALSE;
+        *lpnLengthNeeded = LengthNeeded;
+        ret = TRUE;
     }
   }