2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: Window properties
24 * FILE: subsys/win32k/ntuser/prop.c
25 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
27 * 06-06-2001 CSH Created
29 /* INCLUDES ******************************************************************/
36 typedef struct _PROPLISTITEM
41 PROPLISTITEM
, *PPROPLISTITEM
;
44 /* STATIC FUNCTIONS **********************************************************/
46 /* FUNCTIONS *****************************************************************/
50 IntGetProp(PWINDOW_OBJECT Window
, ATOM Atom
)
52 PLIST_ENTRY ListEntry
;
55 ListEntry
= Window
->PropListHead
.Flink
;
56 while (ListEntry
!= &Window
->PropListHead
)
58 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
59 if (Property
->Atom
== Atom
)
63 ListEntry
= ListEntry
->Flink
;
69 NtUserBuildPropList(HWND hWnd
,
74 PWINDOW_OBJECT Window
;
76 PLIST_ENTRY ListEntry
;
77 PROPLISTITEM listitem
, *li
;
80 DECLARE_RETURN(NTSTATUS
);
82 DPRINT("Enter NtUserBuildPropList\n");
85 if (!(Window
= UserGetWindowObject(hWnd
)))
87 RETURN( STATUS_INVALID_HANDLE
);
92 if(!BufferSize
|| (BufferSize
% sizeof(PROPLISTITEM
) != 0))
94 RETURN( STATUS_INVALID_PARAMETER
);
98 li
= (PROPLISTITEM
*)Buffer
;
99 ListEntry
= Window
->PropListHead
.Flink
;
100 while((BufferSize
>= sizeof(PROPLISTITEM
)) && (ListEntry
!= &Window
->PropListHead
))
102 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
103 listitem
.Atom
= Property
->Atom
;
104 listitem
.Data
= Property
->Data
;
106 Status
= MmCopyToCaller(li
, &listitem
, sizeof(PROPLISTITEM
));
107 if(!NT_SUCCESS(Status
))
112 BufferSize
-= sizeof(PROPLISTITEM
);
115 ListEntry
= ListEntry
->Flink
;
121 Cnt
= Window
->PropListItems
* sizeof(PROPLISTITEM
);
126 Status
= MmCopyToCaller(Count
, &Cnt
, sizeof(DWORD
));
127 if(!NT_SUCCESS(Status
))
133 RETURN( STATUS_SUCCESS
);
136 DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_
);
142 NtUserRemoveProp(HWND hWnd
, ATOM Atom
)
144 PWINDOW_OBJECT Window
;
147 DECLARE_RETURN(HANDLE
);
149 DPRINT("Enter NtUserRemoveProp\n");
150 UserEnterExclusive();
152 if (!(Window
= UserGetWindowObject(hWnd
)))
157 Prop
= IntGetProp(Window
, Atom
);
164 RemoveEntryList(&Prop
->PropListEntry
);
166 Window
->PropListItems
--;
171 DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_
);
177 NtUserGetProp(HWND hWnd
, ATOM Atom
)
179 PWINDOW_OBJECT Window
;
182 DECLARE_RETURN(HANDLE
);
184 DPRINT("Enter NtUserGetProp\n");
187 if (!(Window
= UserGetWindowObject(hWnd
)))
192 Prop
= IntGetProp(Window
, Atom
);
201 DPRINT("Leave NtUserGetProp, ret=%i\n",_ret_
);
208 IntSetProp(PWINDOW_OBJECT Wnd
, ATOM Atom
, HANDLE Data
)
212 Prop
= IntGetProp(Wnd
, Atom
);
216 Prop
= ExAllocatePoolWithTag(PagedPool
, sizeof(PROPERTY
), TAG_WNDPROP
);
222 InsertTailList(&Wnd
->PropListHead
, &Prop
->PropListEntry
);
223 Wnd
->PropListItems
++;
232 NtUserSetProp(HWND hWnd
, ATOM Atom
, HANDLE Data
)
234 PWINDOW_OBJECT Window
;
235 DECLARE_RETURN(BOOL
);
237 DPRINT("Enter NtUserSetProp\n");
238 UserEnterExclusive();
240 if (!(Window
= UserGetWindowObject(hWnd
)))
245 RETURN( IntSetProp(Window
, Atom
, Data
));
248 DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_
);