prop: simplify refcounting, naming changes
Modified: trunk/reactos/subsys/win32k/include/prop.h
Modified: trunk/reactos/subsys/win32k/ntuser/prop.c

Modified: trunk/reactos/subsys/win32k/include/prop.h
--- trunk/reactos/subsys/win32k/include/prop.h	2005-09-06 23:21:40 UTC (rev 17710)
+++ trunk/reactos/subsys/win32k/include/prop.h	2005-09-06 23:29:54 UTC (rev 17711)
@@ -8,11 +8,5 @@
   ATOM Atom;
 } PROPERTY, *PPROPERTY;
 
-BOOL FASTCALL
-IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data);
-
-PPROPERTY FASTCALL
-IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom);
-
 #endif /* _WIN32K_PROP_H */
 

Modified: trunk/reactos/subsys/win32k/ntuser/prop.c
--- trunk/reactos/subsys/win32k/ntuser/prop.c	2005-09-06 23:21:40 UTC (rev 17710)
+++ trunk/reactos/subsys/win32k/ntuser/prop.c	2005-09-06 23:29:54 UTC (rev 17711)
@@ -39,16 +39,20 @@
   HANDLE Data;
 } PROPLISTITEM, *PPROPLISTITEM;
 
+
+/* STATIC FUNCTIONS **********************************************************/
+
 /* FUNCTIONS *****************************************************************/
 
+static
 PPROPERTY FASTCALL
-IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom)
+IntGetProp(PWINDOW_OBJECT Window, ATOM Atom)
 {
   PLIST_ENTRY ListEntry;
   PPROPERTY Property;
 
-  ListEntry = WindowObject->PropListHead.Flink;
-  while (ListEntry != &WindowObject->PropListHead)
+  ListEntry = Window->PropListHead.Flink;
+  while (ListEntry != &Window->PropListHead)
     {
       Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
       if (Property->Atom == Atom)
@@ -66,7 +70,7 @@
 		    DWORD BufferSize,
 		    DWORD *Count)
 {
-  PWINDOW_OBJECT WindowObject;
+  PWINDOW_OBJECT Window;
   PPROPERTY Property;
   PLIST_ENTRY ListEntry;
   PROPLISTITEM listitem, *li;
@@ -77,7 +81,7 @@
   DPRINT("Enter NtUserBuildPropList\n");
   UserEnterShared();
 
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
+  if (!(Window = UserGetWindowObject(hWnd)))
   {
     RETURN( STATUS_INVALID_HANDLE);
   }
@@ -86,14 +90,13 @@
   {
     if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
     {
-      IntReleaseWindowObject(WindowObject);
       RETURN( STATUS_INVALID_PARAMETER);
     }
 
     /* copy list */
     li = (PROPLISTITEM *)Buffer;
-    ListEntry = WindowObject->PropListHead.Flink;
-    while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &WindowObject->PropListHead))
+    ListEntry = Window->PropListHead.Flink;
+    while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &Window->PropListHead))
     {
       Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
       listitem.Atom = Property->Atom;
@@ -102,7 +105,6 @@
       Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
       if(!NT_SUCCESS(Status))
       {
-        IntReleaseWindowObject(WindowObject);
         RETURN( Status);
       }
 
@@ -115,11 +117,9 @@
   }
   else
   {
-    Cnt = WindowObject->PropListItems * sizeof(PROPLISTITEM);
+    Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
   }
 
-  IntReleaseWindowObject(WindowObject);
-
   if(Count)
   {
     Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
@@ -140,7 +140,7 @@
 HANDLE STDCALL
 NtUserRemoveProp(HWND hWnd, ATOM Atom)
 {
-  PWINDOW_OBJECT WindowObject;
+  PWINDOW_OBJECT Window;
   PPROPERTY Prop;
   HANDLE Data;
   DECLARE_RETURN(HANDLE);
@@ -148,24 +148,22 @@
   DPRINT("Enter NtUserRemoveProp\n");
   UserEnterExclusive();
 
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
+  if (!(Window = UserGetWindowObject(hWnd)))
   {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
     RETURN( NULL);
   }
 
-  Prop = IntGetProp(WindowObject, Atom);
+  Prop = IntGetProp(Window, Atom);
 
   if (Prop == NULL)
     {
-      IntReleaseWindowObject(WindowObject);
       RETURN(NULL);
     }
   Data = Prop->Data;
   RemoveEntryList(&Prop->PropListEntry);
   ExFreePool(Prop);
-  WindowObject->PropListItems--;
-  IntReleaseWindowObject(WindowObject);
+  Window->PropListItems--;
+
   RETURN(Data);
   
 CLEANUP:
@@ -177,7 +175,7 @@
 HANDLE STDCALL
 NtUserGetProp(HWND hWnd, ATOM Atom)
 {
-  PWINDOW_OBJECT WindowObject;
+  PWINDOW_OBJECT Window;
   PPROPERTY Prop;
   HANDLE Data = NULL;
   DECLARE_RETURN(HANDLE);
@@ -185,18 +183,17 @@
   DPRINT("Enter NtUserGetProp\n");
   UserEnterShared();
 
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
+  if (!(Window = UserGetWindowObject(hWnd)))
   {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
     RETURN( FALSE);
   }
 
-  Prop = IntGetProp(WindowObject, Atom);
+  Prop = IntGetProp(Window, Atom);
   if (Prop != NULL)
   {
     Data = Prop->Data;
   }
-  IntReleaseWindowObject(WindowObject);
+
   RETURN(Data);
   
 CLEANUP:
@@ -205,6 +202,7 @@
   END_CLEANUP;
 }
 
+static
 BOOL FASTCALL
 IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data)
 {
@@ -232,23 +230,18 @@
 BOOL STDCALL
 NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
 {
-  PWINDOW_OBJECT WindowObject;
-  BOOL ret;
+  PWINDOW_OBJECT Window;
   DECLARE_RETURN(BOOL);
   
   DPRINT("Enter NtUserSetProp\n");
   UserEnterExclusive();
 
-  if (!(WindowObject = IntGetWindowObject(hWnd)))
+  if (!(Window = UserGetWindowObject(hWnd)))
   {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
     RETURN( FALSE);
   }
 
-  ret = IntSetProp(WindowObject, Atom, Data);
-
-  IntReleaseWindowObject(WindowObject);
-  RETURN( ret);
+  RETURN( IntSetProp(Window, Atom, Data));
   
 CLEANUP:
   DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_);