fix referencing bug (ros crashed during setup if mousemove) in co_WinPosSearchChildren
Modified: trunk/reactos/subsys/win32k/include/userfuncs.h
Modified: trunk/reactos/subsys/win32k/ntuser/message.c
Modified: trunk/reactos/subsys/win32k/ntuser/object.c
Modified: trunk/reactos/subsys/win32k/ntuser/winpos.c

Modified: trunk/reactos/subsys/win32k/include/userfuncs.h
--- trunk/reactos/subsys/win32k/include/userfuncs.h	2005-09-11 20:41:39 UTC (rev 17808)
+++ trunk/reactos/subsys/win32k/include/userfuncs.h	2005-09-11 21:05:32 UTC (rev 17809)
@@ -14,14 +14,15 @@
    DPRINT1("obj 0x%x dereffed to %i refs\n",_obj_, USER_BODY_TO_HEADER(_obj_)->RefCount-1); \
    ObmDereferenceObject2(_obj_); \
 }
+
 #endif
 
+#define ObmDereferenceObject(_obj_) ObmDereferenceObject2(_obj_)
 
 
 
 
 
-
 #define ASSERT_REFS_CO(_obj_) \
 { \
    LONG ref = USER_BODY_TO_HEADER(_obj_)->RefCount;\
@@ -59,7 +60,7 @@
 
 
 VOID FASTCALL ObmReferenceObject(PVOID obj);
-BOOL FASTCALL ObmDereferenceObject(PVOID obj);
+BOOL FASTCALL ObmDereferenceObject2(PVOID obj);
 
 PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd);
 PVOID FASTCALL

Modified: trunk/reactos/subsys/win32k/ntuser/message.c
--- trunk/reactos/subsys/win32k/ntuser/message.c	2005-09-11 20:41:39 UTC (rev 17808)
+++ trunk/reactos/subsys/win32k/ntuser/message.c	2005-09-11 21:05:32 UTC (rev 17809)
@@ -773,7 +773,7 @@
             USHORT HitTest;
 
             UserRefObjectCo(MsgWindow);
-            
+
             if(co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE))
                /* FIXME - check message filter again, if the message doesn't match anymore,
                           search again */
@@ -782,7 +782,7 @@
                /* eat the message, search again */
                goto CheckMessages;
             }
-            
+
             if(ThreadQueue->CaptureWindow == NULL)
             {
                co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);

Modified: trunk/reactos/subsys/win32k/ntuser/object.c
--- trunk/reactos/subsys/win32k/ntuser/object.c	2005-09-11 20:41:39 UTC (rev 17808)
+++ trunk/reactos/subsys/win32k/ntuser/object.c	2005-09-11 21:05:32 UTC (rev 17809)
@@ -275,7 +275,7 @@
 }
 
 
-BOOL FASTCALL ObmDereferenceObject(PVOID obj)
+BOOL FASTCALL ObmDereferenceObject2(PVOID obj)
 {
    PUSER_OBJECT_HEADER hdr = USER_BODY_TO_HEADER(obj);
 

Modified: trunk/reactos/subsys/win32k/ntuser/winpos.c
--- trunk/reactos/subsys/win32k/ntuser/winpos.c	2005-09-11 20:41:39 UTC (rev 17808)
+++ trunk/reactos/subsys/win32k/ntuser/winpos.c	2005-09-11 21:05:32 UTC (rev 17809)
@@ -1483,20 +1483,23 @@
 }
 #endif
 
+/* wine server: child_window_from_point 
 
+Caller must dereference the "returned" Window
+*/
 static
 VOID FASTCALL
 co_WinPosSearchChildren(
    PWINDOW_OBJECT ScopeWin, 
    PUSER_MESSAGE_QUEUE OnlyHitTests, 
    POINT *Point,
-   PWINDOW_OBJECT* Window, 
+   PWINDOW_OBJECT* Window,    
    USHORT *HitTest
    )
 {
    PWINDOW_OBJECT Current;
    HWND *List, *phWnd;
-
+   
    ASSERT_REFS_CO(ScopeWin);
 
    if ((List = IntWinListChildren(ScopeWin)))
@@ -1517,24 +1520,24 @@
             continue;
          }
 
-         if (!IntPtInWindow(Current, Point->x, Point->y))
+         if (!IntPtInWindow(Current, Point->x, Point->y)) 
          {
-            continue;
+             continue;
          }
-
+        
+         if (*Window) UserDerefObject(*Window);
          *Window = Current;
+         UserRefObject(*Window);
          
          if (Current->Style & WS_MINIMIZE)
          {
             *HitTest = HTCAPTION;
-            UserRefObject(Current);
             break;
          }
 
          if (Current->Style & WS_DISABLED)
          {
             *HitTest = HTERROR;
-            UserRefObject(Current);
             break;
          }
 
@@ -1561,13 +1564,12 @@
             co_WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest);
          }
          
-         UserRefObject(Current);
          UserDerefObjectCo(Current);
 
          break;
       }
       ExFreePool(List);
-   }
+   } 
 }
 
 /* wine: WINPOS_WindowFromPoint */