2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Window properties
5 * FILE: win32ss/user/ntuser/prop.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
10 DBG_DEFAULT_CHANNEL(UserProp
);
12 /* STATIC FUNCTIONS **********************************************************/
19 _In_ BOOLEAN SystemProp
)
21 PLIST_ENTRY ListEntry
;
24 WORD SystemFlag
= SystemProp
? PROPERTY_FLAG_SYSTEM
: 0;
26 NT_ASSERT(UserIsEntered());
27 ListEntry
= Window
->PropListHead
.Flink
;
29 for (i
= 0; i
< Window
->PropListItems
; i
++)
31 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
32 ListEntry
= ListEntry
->Flink
;
34 if (Property
->Atom
== Atom
&&
35 (Property
->fs
& PROPERTY_FLAG_SYSTEM
) == SystemFlag
)
40 NT_ASSERT(ListEntry
== &Window
->PropListHead
);
49 _In_ BOOLEAN SystemProp
)
53 NT_ASSERT(UserIsEntered());
54 Prop
= IntGetProp(Window
, Atom
, SystemProp
);
55 return Prop
? Prop
->Data
: NULL
;
64 _In_ BOOLEAN SystemProp
)
69 NT_ASSERT(UserIsEnteredExclusive());
70 Prop
= IntGetProp(Window
, Atom
, SystemProp
);
77 RemoveEntryList(&Prop
->PropListEntry
);
79 Window
->PropListItems
--;
90 _In_ BOOLEAN SystemProp
)
94 NT_ASSERT(UserIsEnteredExclusive());
95 Prop
= IntGetProp(Window
, Atom
, SystemProp
);
98 Prop
= UserHeapAlloc(sizeof(PROPERTY
));
104 Prop
->fs
= SystemProp
? PROPERTY_FLAG_SYSTEM
: 0;
105 InsertTailList(&Window
->PropListHead
, &Prop
->PropListEntry
);
106 Window
->PropListItems
++;
115 UserRemoveWindowProps(
118 PLIST_ENTRY ListEntry
;
121 NT_ASSERT(UserIsEnteredExclusive());
122 while (!IsListEmpty(&Window
->PropListHead
))
124 ListEntry
= Window
->PropListHead
.Flink
;
125 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
126 RemoveEntryList(&Property
->PropListEntry
);
127 UserHeapFree(Property
);
128 Window
->PropListItems
--;
133 /* FUNCTIONS *****************************************************************/
139 _Out_writes_bytes_to_opt_(BufferSize
, *Count
* sizeof(PROPLISTITEM
)) LPVOID Buffer
,
140 _In_ DWORD BufferSize
,
141 _Out_opt_ DWORD
*Count
)
145 PLIST_ENTRY ListEntry
;
146 PROPLISTITEM listitem
, *li
;
150 TRACE("Enter NtUserBuildPropList\n");
153 Window
= UserGetWindowObject(hWnd
);
156 Status
= STATUS_INVALID_HANDLE
;
162 if (!BufferSize
|| (BufferSize
% sizeof(PROPLISTITEM
) != 0))
164 Status
= STATUS_INVALID_PARAMETER
;
169 li
= (PROPLISTITEM
*)Buffer
;
170 ListEntry
= Window
->PropListHead
.Flink
;
171 while ((BufferSize
>= sizeof(PROPLISTITEM
)) &&
172 (ListEntry
!= &Window
->PropListHead
))
174 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
175 ListEntry
= ListEntry
->Flink
;
176 if (!(Property
->fs
& PROPERTY_FLAG_SYSTEM
))
178 listitem
.Atom
= Property
->Atom
;
179 listitem
.Data
= Property
->Data
;
181 Status
= MmCopyToCaller(li
, &listitem
, sizeof(PROPLISTITEM
));
182 if (!NT_SUCCESS(Status
))
187 BufferSize
-= sizeof(PROPLISTITEM
);
196 /* FIXME: This counts user and system props */
197 Cnt
= Window
->PropListItems
* sizeof(PROPLISTITEM
);
202 Status
= MmCopyToCaller(Count
, &Cnt
, sizeof(DWORD
));
203 if (!NT_SUCCESS(Status
))
209 Status
= STATUS_SUCCESS
;
212 TRACE("Leave NtUserBuildPropList, ret=%lx\n", Status
);
227 TRACE("Enter NtUserRemoveProp\n");
228 UserEnterExclusive();
230 Window
= UserGetWindowObject(hWnd
);
236 Data
= UserRemoveProp(Window
, Atom
, FALSE
);
239 TRACE("Leave NtUserRemoveProp, ret=%p\n", Data
);
255 TRACE("Enter NtUserSetProp\n");
256 UserEnterExclusive();
258 Window
= UserGetWindowObject(hWnd
);
265 Ret
= UserSetProp(Window
, Atom
, Data
, FALSE
);
268 TRACE("Leave NtUserSetProp, ret=%i\n", Ret
);