Commit in reactos/subsys/win32k on MAIN
include/class.h+14-21.23 -> 1.24
       /window.h+21.58 -> 1.59
ntuser/class.c+17-61.56 -> 1.57
      /window.c+18-41.235 -> 1.236
+51-12
4 modified files
fixed missing class dereferencings and store a list of windows in the class object

reactos/subsys/win32k/include
class.h 1.23 -> 1.24
diff -u -r1.23 -r1.24
--- class.h	17 May 2004 16:38:58 -0000	1.23
+++ class.h	27 May 2004 11:47:42 -0000	1.24
@@ -28,6 +28,9 @@
   BOOL Global;
   LIST_ENTRY ListEntry;
   PCHAR   ExtraData;
+  /* list of windows */
+  FAST_MUTEX ClassWindowsListLock;
+  LIST_ENTRY ClassWindowsListHead;
 } WNDCLASS_OBJECT, *PWNDCLASS_OBJECT;
 
 NTSTATUS FASTCALL
@@ -37,10 +40,19 @@
 CleanupClassImpl(VOID);
 
 #define IntLockProcessClasses(W32Process) \
-  ExAcquireFastMutex(&W32Process->ClassListLock)
+  ExAcquireFastMutex(&(W32Process)->ClassListLock)
 
 #define IntUnLockProcessClasses(W32Process) \
-  ExReleaseFastMutex(&W32Process->ClassListLock)
+  ExReleaseFastMutex(&(W32Process)->ClassListLock)
+
+#define IntLockClassWindows(ClassObj) \
+  ExAcquireFastMutex(&(ClassObj)->ClassWindowsListLock)
+
+#define IntUnLockClassWindows(ClassObj) \
+  ExReleaseFastMutex(&(ClassObj)->ClassWindowsListLock)
+
+#define ClassDereferenceObject(ClassObj) \
+  ObmDereferenceObject(ClassObj)
 
 BOOL FASTCALL
 ClassReferenceClassByAtom(

reactos/subsys/win32k/include
window.h 1.58 -> 1.59
diff -u -r1.58 -r1.59
--- window.h	8 May 2004 12:42:46 -0000	1.58
+++ window.h	27 May 2004 11:47:42 -0000	1.59
@@ -30,6 +30,8 @@
 {
   /* 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. */

reactos/subsys/win32k/ntuser
class.c 1.56 -> 1.57
diff -u -r1.56 -r1.57
--- class.c	23 May 2004 14:04:58 -0000	1.56
+++ class.c	27 May 2004 11:47:42 -0000	1.57
@@ -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.56 2004/05/23 14:04:58 weiden Exp $
+/* $Id: class.c,v 1.57 2004/05/27 11:47:42 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -366,6 +366,9 @@
 		ClassObject->ExtraData = NULL;
 	}
 
+	InitializeListHead(&ClassObject->ClassWindowsListHead);
+	ExInitializeFastMutex(&ClassObject->ClassWindowsListLock);
+
 	return(ClassObject);
 }
 
@@ -690,34 +693,42 @@
 
    if (!ClassReferenceClassByNameOrAtom(&Class, ClassNameOrAtom, hInstance))
    {
+      ObDereferenceObject(WinStaObject);
       SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
       return FALSE;
    }
   
    if (Class->hInstance && Class->hInstance != hInstance)
    {
-      ObmDereferenceObject(Class);
+      ClassDereferenceObject(Class);
+      ObDereferenceObject(WinStaObject);
       SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
       return FALSE;
    }
   
-   if (ObmGetReferenceCount(Class) > 2)
+  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 */
-   ObmDereferenceObject(Class);
+   ClassDereferenceObject(Class);
   
    RemoveEntryList(&Class->ListEntry);
 
    RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Class->Atom);
-   ObDereferenceObject(WinStaObject);
   
    /* Free the object */
-   ObmDereferenceObject(Class);
+   ClassDereferenceObject(Class);
+   
+   ObDereferenceObject(WinStaObject);
   
    return TRUE;
 }

reactos/subsys/win32k/ntuser
window.c 1.235 -> 1.236
diff -u -r1.235 -r1.236
--- window.c	19 May 2004 19:16:47 -0000	1.235
+++ window.c	27 May 2004 11:47:42 -0000	1.236
@@ -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.235 2004/05/19 19:16:47 weiden Exp $
+/* $Id: window.c,v 1.236 2004/05/27 11:47:42 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -387,7 +387,13 @@
   /* don't remove the WINDOWSTATUS_DESTROYING bit */
   IntUnLockThreadWindows(Window->OwnerThread->Win32Thread);
   
-  ObmDereferenceObject(Window->Class);
+  /* remove the window from the class object */
+  IntLockClassWindows(Window->Class);
+  RemoveEntryList(&Window->ClassListEntry);
+  IntUnLockClassWindows(Window->Class);
+  
+  /* dereference the class */
+  ClassDereferenceObject(Window->Class);
   Window->Class = NULL;
   
   if(Window->WindowRegion)
@@ -1509,7 +1515,7 @@
 					  &WinStaObject);
   if (!NT_SUCCESS(Status))
     {
-      ObmDereferenceObject(ClassObject);
+      ClassDereferenceObject(ClassObject);
       RtlFreeUnicodeString(&WindowName);
       if (NULL != ParentWindow)
         {
@@ -1530,7 +1536,7 @@
   if (!WindowObject)
     {
       ObDereferenceObject(WinStaObject);
-      ObmDereferenceObject(ClassObject);
+      ClassDereferenceObject(ClassObject);
       RtlFreeUnicodeString(&WindowName);
       if (NULL != ParentWindow)
         {
@@ -1551,6 +1557,10 @@
    * Fill out the structure describing it.
    */
   WindowObject->Class = ClassObject;
+  IntLockClassWindows(ClassObject);
+  InsertTailList(&ClassObject->ClassWindowsListHead, &WindowObject->ClassListEntry);
+  IntUnLockClassWindows(ClassObject);
+  
   WindowObject->ExStyle = dwExStyle;
   WindowObject->Style = dwStyle & ~WS_VISIBLE;
   DPRINT("1: Style is now %lx\n", WindowObject->Style);
@@ -1690,6 +1700,7 @@
       /* FIXME - Delete window object and remove it from the thread windows list */
       /* FIXME - delete allocated DCE */
       
+      ClassDereferenceObject(ClassObject);
       DPRINT1("CBT-hook returned !0\n");
       return (HWND) NULL;
     }
@@ -1907,6 +1918,7 @@
         {
           IntReleaseWindowObject(ParentWindow);
         }
+      ClassDereferenceObject(ClassObject);
       DPRINT("NtUserCreateWindowEx(): send CREATE message failed.\n");
       return((HWND)0);
     } 
@@ -2463,6 +2475,8 @@
   }
 #endif
   
+  ClassDereferenceObject(ClassObject);
+  
   Cleanup:
   if(ClassName.Length > 0 && ClassName.Buffer)
     ExFreePool(ClassName.Buffer);
CVSspam 0.2.8