2008-07-09 03:29:43 +00:00
|
|
|
/*
|
2002-09-04 18:09:31 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: Window properties
|
2015-10-10 13:48:08 +00:00
|
|
|
* FILE: win32ss/user/ntuser/prop.c
|
2002-09-04 18:09:31 +00:00
|
|
|
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
*/
|
2014-12-18 08:11:25 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2011-08-21 12:38:52 +00:00
|
|
|
DBG_DEFAULT_CHANNEL(UserProp);
|
2002-09-04 18:09:31 +00:00
|
|
|
|
2005-09-06 23:29:54 +00:00
|
|
|
/* STATIC FUNCTIONS **********************************************************/
|
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
PPROPERTY
|
|
|
|
FASTCALL
|
|
|
|
IntGetProp(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ PWND Window,
|
2015-10-10 19:50:05 +00:00
|
|
|
_In_ ATOM Atom,
|
|
|
|
_In_ BOOLEAN SystemProp)
|
2002-09-04 18:09:31 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PLIST_ENTRY ListEntry;
|
|
|
|
PPROPERTY Property;
|
|
|
|
UINT i;
|
2015-10-10 19:50:05 +00:00
|
|
|
WORD SystemFlag = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
|
2015-10-10 13:06:57 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
NT_ASSERT(UserIsEntered());
|
2015-10-10 13:06:57 +00:00
|
|
|
ListEntry = Window->PropListHead.Flink;
|
|
|
|
|
|
|
|
for (i = 0; i < Window->PropListItems; i++)
|
|
|
|
{
|
|
|
|
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
|
2015-10-10 19:50:05 +00:00
|
|
|
ListEntry = ListEntry->Flink;
|
2015-10-10 13:06:57 +00:00
|
|
|
|
2015-10-10 19:50:05 +00:00
|
|
|
if (Property->Atom == Atom &&
|
|
|
|
(Property->fs & PROPERTY_FLAG_SYSTEM) == SystemFlag)
|
2015-10-10 13:06:57 +00:00
|
|
|
{
|
2015-10-10 19:50:05 +00:00
|
|
|
return Property;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-10 19:50:05 +00:00
|
|
|
NT_ASSERT(ListEntry == &Window->PropListHead);
|
|
|
|
return NULL;
|
2002-09-04 18:09:31 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 21:46:30 +00:00
|
|
|
HANDLE
|
|
|
|
FASTCALL
|
2015-10-10 13:06:57 +00:00
|
|
|
UserGetProp(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ PWND Window,
|
2015-10-10 19:50:05 +00:00
|
|
|
_In_ ATOM Atom,
|
|
|
|
_In_ BOOLEAN SystemProp)
|
2013-10-11 21:46:30 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PPROPERTY Prop;
|
2015-10-10 13:48:08 +00:00
|
|
|
|
|
|
|
NT_ASSERT(UserIsEntered());
|
2015-10-10 19:50:05 +00:00
|
|
|
Prop = IntGetProp(Window, Atom, SystemProp);
|
2015-10-10 13:06:57 +00:00
|
|
|
return Prop ? Prop->Data : NULL;
|
2013-10-11 21:46:30 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
_Success_(return)
|
2015-10-10 14:43:25 +00:00
|
|
|
HANDLE
|
2015-10-10 13:06:57 +00:00
|
|
|
FASTCALL
|
2015-10-10 17:56:09 +00:00
|
|
|
UserRemoveProp(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ PWND Window,
|
2015-10-10 19:50:05 +00:00
|
|
|
_In_ ATOM Atom,
|
|
|
|
_In_ BOOLEAN SystemProp)
|
2009-07-22 04:11:06 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PPROPERTY Prop;
|
2015-10-10 14:43:25 +00:00
|
|
|
HANDLE Data;
|
2015-10-10 13:06:57 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
NT_ASSERT(UserIsEnteredExclusive());
|
2015-10-10 19:50:05 +00:00
|
|
|
Prop = IntGetProp(Window, Atom, SystemProp);
|
2015-10-10 13:06:57 +00:00
|
|
|
if (Prop == NULL)
|
|
|
|
{
|
2015-10-10 14:43:25 +00:00
|
|
|
return NULL;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 14:43:25 +00:00
|
|
|
Data = Prop->Data;
|
2015-10-10 13:06:57 +00:00
|
|
|
RemoveEntryList(&Prop->PropListEntry);
|
|
|
|
UserHeapFree(Prop);
|
|
|
|
Window->PropListItems--;
|
2015-10-10 14:43:25 +00:00
|
|
|
return Data;
|
2009-07-22 04:11:06 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
_Success_(return)
|
2015-10-10 13:06:57 +00:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
2015-10-10 17:56:09 +00:00
|
|
|
UserSetProp(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ PWND Window,
|
|
|
|
_In_ ATOM Atom,
|
2015-10-10 19:50:05 +00:00
|
|
|
_In_ HANDLE Data,
|
|
|
|
_In_ BOOLEAN SystemProp)
|
2009-07-22 04:11:06 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PPROPERTY Prop;
|
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
NT_ASSERT(UserIsEnteredExclusive());
|
2015-10-10 19:50:05 +00:00
|
|
|
Prop = IntGetProp(Window, Atom, SystemProp);
|
2015-10-10 13:06:57 +00:00
|
|
|
if (Prop == NULL)
|
|
|
|
{
|
|
|
|
Prop = UserHeapAlloc(sizeof(PROPERTY));
|
|
|
|
if (Prop == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
Prop->Atom = Atom;
|
2015-10-10 19:50:05 +00:00
|
|
|
Prop->fs = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
|
2015-10-10 13:48:08 +00:00
|
|
|
InsertTailList(&Window->PropListHead, &Prop->PropListEntry);
|
|
|
|
Window->PropListItems++;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Prop->Data = Data;
|
|
|
|
return TRUE;
|
2009-07-22 04:11:06 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
2015-10-10 17:56:09 +00:00
|
|
|
UserRemoveWindowProps(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ PWND Window)
|
2013-10-16 00:11:23 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PLIST_ENTRY ListEntry;
|
|
|
|
PPROPERTY Property;
|
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
NT_ASSERT(UserIsEnteredExclusive());
|
2015-10-10 13:06:57 +00:00
|
|
|
while (!IsListEmpty(&Window->PropListHead))
|
|
|
|
{
|
|
|
|
ListEntry = Window->PropListHead.Flink;
|
|
|
|
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
|
|
|
|
RemoveEntryList(&Property->PropListEntry);
|
|
|
|
UserHeapFree(Property);
|
|
|
|
Window->PropListItems--;
|
|
|
|
}
|
|
|
|
return;
|
2013-10-16 00:11:23 +00:00
|
|
|
}
|
|
|
|
|
2009-07-22 04:11:06 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
NTSTATUS
|
|
|
|
APIENTRY
|
|
|
|
NtUserBuildPropList(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ HWND hWnd,
|
|
|
|
_Out_writes_bytes_to_opt_(BufferSize, *Count * sizeof(PROPLISTITEM)) LPVOID Buffer,
|
|
|
|
_In_ DWORD BufferSize,
|
|
|
|
_Out_opt_ DWORD *Count)
|
2002-09-04 18:09:31 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PWND Window;
|
|
|
|
PPROPERTY Property;
|
|
|
|
PLIST_ENTRY ListEntry;
|
2020-08-08 05:05:22 +00:00
|
|
|
PROPLISTITEM listitem = { 0 }, *li;
|
2015-10-10 13:06:57 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
DWORD Cnt = 0;
|
|
|
|
|
|
|
|
TRACE("Enter NtUserBuildPropList\n");
|
|
|
|
UserEnterShared();
|
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Window = UserGetWindowObject(hWnd);
|
|
|
|
if (Window == NULL)
|
2015-10-10 13:06:57 +00:00
|
|
|
{
|
2015-10-10 13:48:08 +00:00
|
|
|
Status = STATUS_INVALID_HANDLE;
|
|
|
|
goto Exit;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Buffer)
|
|
|
|
{
|
|
|
|
if (!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
|
|
|
|
{
|
2015-10-10 13:48:08 +00:00
|
|
|
Status = STATUS_INVALID_PARAMETER;
|
|
|
|
goto Exit;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy list */
|
|
|
|
li = (PROPLISTITEM *)Buffer;
|
|
|
|
ListEntry = Window->PropListHead.Flink;
|
|
|
|
while ((BufferSize >= sizeof(PROPLISTITEM)) &&
|
|
|
|
(ListEntry != &Window->PropListHead))
|
|
|
|
{
|
|
|
|
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
|
2015-10-10 19:50:05 +00:00
|
|
|
ListEntry = ListEntry->Flink;
|
|
|
|
if (!(Property->fs & PROPERTY_FLAG_SYSTEM))
|
2015-10-10 13:06:57 +00:00
|
|
|
{
|
2015-10-10 19:50:05 +00:00
|
|
|
listitem.Atom = Property->Atom;
|
|
|
|
listitem.Data = Property->Data;
|
|
|
|
|
|
|
|
Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferSize -= sizeof(PROPLISTITEM);
|
|
|
|
Cnt++;
|
|
|
|
li++;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-10 19:50:05 +00:00
|
|
|
/* FIXME: This counts user and system props */
|
2015-10-10 13:06:57 +00:00
|
|
|
Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Count)
|
|
|
|
{
|
|
|
|
Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2015-10-10 13:48:08 +00:00
|
|
|
goto Exit;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Status = STATUS_SUCCESS;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Exit:
|
|
|
|
TRACE("Leave NtUserBuildPropList, ret=%lx\n", Status);
|
2015-10-10 13:06:57 +00:00
|
|
|
UserLeave();
|
2015-10-10 13:48:08 +00:00
|
|
|
|
|
|
|
return Status;
|
2002-09-04 18:09:31 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
HANDLE
|
|
|
|
APIENTRY
|
|
|
|
NtUserRemoveProp(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ HWND hWnd,
|
|
|
|
_In_ ATOM Atom)
|
2002-09-04 18:09:31 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PWND Window;
|
2015-10-10 13:48:08 +00:00
|
|
|
HANDLE Data = NULL;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
TRACE("Enter NtUserRemoveProp\n");
|
|
|
|
UserEnterExclusive();
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Window = UserGetWindowObject(hWnd);
|
|
|
|
if (Window == NULL)
|
2015-10-10 13:06:57 +00:00
|
|
|
{
|
2015-10-10 13:48:08 +00:00
|
|
|
goto Exit;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 19:50:05 +00:00
|
|
|
Data = UserRemoveProp(Window, Atom, FALSE);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Exit:
|
|
|
|
TRACE("Leave NtUserRemoveProp, ret=%p\n", Data);
|
2015-10-10 13:06:57 +00:00
|
|
|
UserLeave();
|
2015-10-10 13:48:08 +00:00
|
|
|
|
|
|
|
return Data;
|
2002-09-04 18:09:31 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserSetProp(
|
2015-10-10 13:48:08 +00:00
|
|
|
_In_ HWND hWnd,
|
|
|
|
_In_ ATOM Atom,
|
|
|
|
_In_ HANDLE Data)
|
2003-08-02 16:32:18 +00:00
|
|
|
{
|
2015-10-10 13:06:57 +00:00
|
|
|
PWND Window;
|
2015-10-10 13:48:08 +00:00
|
|
|
BOOL Ret;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 13:06:57 +00:00
|
|
|
TRACE("Enter NtUserSetProp\n");
|
|
|
|
UserEnterExclusive();
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Window = UserGetWindowObject(hWnd);
|
|
|
|
if (Window == NULL)
|
2015-10-10 13:06:57 +00:00
|
|
|
{
|
2015-10-10 13:48:08 +00:00
|
|
|
Ret = FALSE;
|
|
|
|
goto Exit;
|
2015-10-10 13:06:57 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 19:50:05 +00:00
|
|
|
Ret = UserSetProp(Window, Atom, Data, FALSE);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2015-10-10 13:48:08 +00:00
|
|
|
Exit:
|
|
|
|
TRACE("Leave NtUserSetProp, ret=%i\n", Ret);
|
2015-10-10 13:06:57 +00:00
|
|
|
UserLeave();
|
2015-10-10 13:48:08 +00:00
|
|
|
|
|
|
|
return Ret;
|
2003-08-02 16:32:18 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|