update for HEAD-2003091401
[reactos.git] / subsys / win32k / ntuser / prop.c
index 758987d..ba7cbed 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ *  ReactOS W32 Subsystem
+ *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 /* $Id$
  *
  * COPYRIGHT:        See COPYING in the top level directory
@@ -28,8 +46,8 @@
 
 /* FUNCTIONS *****************************************************************/
 
-PPROPERTY
-W32kGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom)
+PPROPERTY FASTCALL
+IntGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom)
 {
   PLIST_ENTRY ListEntry;
   PPROPERTY Property;
@@ -65,22 +83,22 @@ NtUserRemoveProp(HWND hWnd, ATOM Atom)
   PPROPERTY Prop;
   HANDLE Data;
 
-  WindowObject = W32kGetWindowObject(hWnd);
-  if (WindowObject == NULL)
-    {
-      return(NULL);
-    }
+  if (!(WindowObject = IntGetWindowObject(hWnd)))
+  {
+    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+    return NULL;
+  }
 
-  Prop = W32kGetProp(WindowObject, Atom);
+  Prop = IntGetProp(WindowObject, Atom);
   if (Prop == NULL)
     {
-      W32kReleaseWindowObject(WindowObject);
+      IntReleaseWindowObject(WindowObject);
       return(NULL);
     }
   Data = Prop->Data;
   RemoveEntryList(&Prop->PropListEntry);
   ExFreePool(Prop);
-  W32kReleaseWindowObject(WindowObject);
+  IntReleaseWindowObject(WindowObject);
   return(Data);
 }
 
@@ -91,46 +109,65 @@ NtUserGetProp(HWND hWnd, ATOM Atom)
   PPROPERTY Prop;
   HANDLE Data = NULL;
 
-  WindowObject = W32kGetWindowObject(hWnd);
-  if (WindowObject == NULL)
-    {
-      return(FALSE);
-    }
+  IntAcquireWinLockShared();
 
-  Prop = W32kGetProp(WindowObject, Atom);
+  if (!(WindowObject = IntGetWindowObject(hWnd)))
+  {
+    IntReleaseWinLock();
+    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+    return FALSE;
+  }
+
+  Prop = IntGetProp(WindowObject, Atom);
   if (Prop != NULL)
-    {
-      Data = Prop->Data;
-    }
-  W32kReleaseWindowObject(WindowObject);
+  {
+    Data = Prop->Data;
+  }
+  
+  IntReleaseWinLock();
+
   return(Data);
 }
 
-BOOL STDCALL
-NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
+BOOL FASTCALL
+IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data)
 {
-  PWINDOW_OBJECT WindowObject;
   PPROPERTY Prop;
 
-  WindowObject = W32kGetWindowObject(hWnd);
-  if (WindowObject == NULL)
-    {
-      return(FALSE);
-    }
+  Prop = IntGetProp(Wnd, Atom);
 
-  Prop = W32kGetProp(WindowObject, Atom);
   if (Prop == NULL)
-    {
-      Prop = ExAllocatePool(PagedPool, sizeof(PROPERTY));
-      if (Prop == NULL)
-       {
-         W32kReleaseWindowObject(WindowObject);
-         return(FALSE);
-       }
-      Prop->Atom = Atom;
-      InsertTailList(&WindowObject->PropListHead, &Prop->PropListEntry);
-    }
+  {
+    Prop = ExAllocatePool(PagedPool, sizeof(PROPERTY));
+    if (Prop == NULL) return FALSE;
+    Prop->Atom = Atom;
+    InsertTailList(&Wnd->PropListHead, &Prop->PropListEntry);
+  }
+
   Prop->Data = Data;
-  W32kReleaseWindowObject(WindowObject);
-  return(TRUE);
+  return TRUE;
 }
+
+
+BOOL STDCALL
+NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
+{
+  PWINDOW_OBJECT Wnd;
+  BOOL ret;
+
+  IntAcquireWinLockExclusive();
+
+  if (!(Wnd = IntGetWindowObject(hWnd)))
+  {
+    IntReleaseWinLock();
+    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+    return FALSE;
+  }
+
+  ret = IntSetProp(Wnd, Atom, Data);
+
+  IntReleaseWinLock();
+  return ret;
+}
+
+/* EOF */