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 **********************************************************/
20 PLIST_ENTRY ListEntry
;
24 NT_ASSERT(UserIsEntered());
25 ListEntry
= Window
->PropListHead
.Flink
;
27 for (i
= 0; i
< Window
->PropListItems
; i
++)
29 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
31 if (ListEntry
== NULL
)
33 ERR("Corrupted (or uninitialized?) property list for window %p. Prop count %u. Atom %u.\n",
34 Window
, Window
->PropListItems
, Atom
);
38 if (Property
->Atom
== Atom
)
42 ListEntry
= ListEntry
->Flink
;
55 NT_ASSERT(UserIsEntered());
56 Prop
= IntGetProp(Window
, Atom
);
57 return Prop
? Prop
->Data
: NULL
;
69 NT_ASSERT(UserIsEnteredExclusive());
70 Prop
= IntGetProp(Window
, Atom
);
76 RemoveEntryList(&Prop
->PropListEntry
);
78 Window
->PropListItems
--;
92 NT_ASSERT(UserIsEnteredExclusive());
93 Prop
= IntGetProp(Window
, Atom
);
96 Prop
= UserHeapAlloc(sizeof(PROPERTY
));
102 InsertTailList(&Window
->PropListHead
, &Prop
->PropListEntry
);
103 Window
->PropListItems
++;
115 PLIST_ENTRY ListEntry
;
118 NT_ASSERT(UserIsEnteredExclusive());
119 while (!IsListEmpty(&Window
->PropListHead
))
121 ListEntry
= Window
->PropListHead
.Flink
;
122 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
123 RemoveEntryList(&Property
->PropListEntry
);
124 UserHeapFree(Property
);
125 Window
->PropListItems
--;
130 /* FUNCTIONS *****************************************************************/
136 _Out_writes_bytes_to_opt_(BufferSize
, *Count
* sizeof(PROPLISTITEM
)) LPVOID Buffer
,
137 _In_ DWORD BufferSize
,
138 _Out_opt_ DWORD
*Count
)
142 PLIST_ENTRY ListEntry
;
143 PROPLISTITEM listitem
, *li
;
147 TRACE("Enter NtUserBuildPropList\n");
150 Window
= UserGetWindowObject(hWnd
);
153 Status
= STATUS_INVALID_HANDLE
;
159 if (!BufferSize
|| (BufferSize
% sizeof(PROPLISTITEM
) != 0))
161 Status
= STATUS_INVALID_PARAMETER
;
166 li
= (PROPLISTITEM
*)Buffer
;
167 ListEntry
= Window
->PropListHead
.Flink
;
168 while ((BufferSize
>= sizeof(PROPLISTITEM
)) &&
169 (ListEntry
!= &Window
->PropListHead
))
171 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
172 listitem
.Atom
= Property
->Atom
;
173 listitem
.Data
= Property
->Data
;
175 Status
= MmCopyToCaller(li
, &listitem
, sizeof(PROPLISTITEM
));
176 if (!NT_SUCCESS(Status
))
181 BufferSize
-= sizeof(PROPLISTITEM
);
184 ListEntry
= ListEntry
->Flink
;
190 Cnt
= Window
->PropListItems
* sizeof(PROPLISTITEM
);
195 Status
= MmCopyToCaller(Count
, &Cnt
, sizeof(DWORD
));
196 if (!NT_SUCCESS(Status
))
202 Status
= STATUS_SUCCESS
;
205 TRACE("Leave NtUserBuildPropList, ret=%lx\n", Status
);
221 TRACE("Enter NtUserRemoveProp\n");
222 UserEnterExclusive();
224 Window
= UserGetWindowObject(hWnd
);
230 Prop
= IntGetProp(Window
, Atom
);
237 RemoveEntryList(&Prop
->PropListEntry
);
239 Window
->PropListItems
--;
242 TRACE("Leave NtUserRemoveProp, ret=%p\n", Data
);
258 TRACE("Enter NtUserSetProp\n");
259 UserEnterExclusive();
261 Window
= UserGetWindowObject(hWnd
);
268 Ret
= IntSetProp(Window
, Atom
, Data
);
271 TRACE("Leave NtUserSetProp, ret=%i\n", Ret
);