- Separate system-defined from user-defined window properties. The values stored by win32k/user32 must not interfere with those stored by applications. Fixes various applications (e.g. PeaZip) randomly getting their window properties overwritten by the system
CORE-3897 #resolve

svn path=/trunk/; revision=69494
This commit is contained in:
Thomas Faber 2015-10-10 19:50:05 +00:00
parent 09e3698afb
commit 8b6a867b02
15 changed files with 84 additions and 72 deletions

View file

@ -104,7 +104,7 @@ IntEngWindowChanged(
ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL);
Clip = UserGetProp(Window, AtomWndObj);
Clip = UserGetProp(Window, AtomWndObj, TRUE);
if (!Clip)
{
return;
@ -208,7 +208,7 @@ EngCreateWnd(
Clip->PixelFormat = iPixelFormat;
/* associate object with window */
UserSetProp(Window, AtomWndObj, Clip);
UserSetProp(Window, AtomWndObj, Clip, TRUE);
++gcountPWO;
TRACE("EngCreateWnd: SUCCESS: %p!\n", WndObjUser);
@ -253,7 +253,7 @@ EngDeleteWnd(
else
{
/* Remove object from window */
UserRemoveProp(Window, AtomWndObj);
UserRemoveProp(Window, AtomWndObj, TRUE);
}
--gcountPWO;

View file

@ -1029,6 +1029,8 @@ typedef struct _PROPLISTITEM
HANDLE Data;
} PROPLISTITEM, *PPROPLISTITEM;
#define PROPERTY_FLAG_SYSTEM 1
typedef struct _PROPERTY
{
LIST_ENTRY PropListEntry;

View file

@ -339,7 +339,7 @@ IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
if (pMsg->message == WM_DDE_TERMINATE)
{
pddeProp = (PDDE_PROP)UserGetProp(pWnd, AtomDDETrack);
pddeProp = (PDDE_PROP)UserGetProp(pWnd, AtomDDETrack, TRUE);
if (pddeProp)
{
pWndClient = UserGetWindowObject((HWND)pMsg->wParam);
@ -348,7 +348,7 @@ IntDdeGetMessageHook(PMSG pMsg, LONG_PTR ExtraInfo)
ERR("DDE Get Client WM_DDE_TERMINATE\n");
}
UserRemoveProp(pWnd, AtomDDETrack);
UserRemoveProp(pWnd, AtomDDETrack, TRUE);
ExFreePoolWithTag(pddeProp, USERTAG_DDE1);
}
return TRUE;
@ -419,7 +419,7 @@ IntDdeSendMessageHook(PWND pWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
pddeProp->spwnd = pWndServer;
pddeProp->spwndPartner = pWnd;
UserSetProp(pWndServer, AtomDDETrack, (HANDLE)pddeProp);
UserSetProp(pWndServer, AtomDDETrack, (HANDLE)pddeProp, TRUE);
}
return TRUE;
}

View file

@ -441,8 +441,8 @@ DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
EngSetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
hIconSmall = UserGetProp(pWnd, gpsi->atomIconSmProp);
hIcon = UserGetProp(pWnd, gpsi->atomIconProp);
hIconSmall = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE);
hIcon = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
hIconOld = wParam == ICON_BIG ? hIcon : hIconSmall;
@ -460,8 +460,8 @@ DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
break;
}
UserSetProp(pWnd, gpsi->atomIconProp, hIcon);
UserSetProp(pWnd, gpsi->atomIconSmProp, hIconSmall);
UserSetProp(pWnd, gpsi->atomIconProp, hIcon, TRUE);
UserSetProp(pWnd, gpsi->atomIconSmProp, hIconSmall, TRUE);
if ((pWnd->style & WS_CAPTION ) == WS_CAPTION)
UserPaintCaption(pWnd, DC_ICON);
@ -481,11 +481,11 @@ DefWndGetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
switch(wParam)
{
case ICON_BIG:
hIconRet = UserGetProp(pWnd, gpsi->atomIconProp);
hIconRet = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
break;
case ICON_SMALL:
case ICON_SMALL2:
hIconRet = UserGetProp(pWnd, gpsi->atomIconSmProp);
hIconRet = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE);
break;
default:
break;

View file

@ -22,7 +22,7 @@ typedef struct _LRD_PROP
BOOL FASTCALL
GetLayeredStatus(PWND pWnd)
{
PLRD_PROP pLrdProp = UserGetProp(pWnd, AtomLayer);
PLRD_PROP pLrdProp = UserGetProp(pWnd, AtomLayer, TRUE);
if (pLrdProp)
{
return pLrdProp->is_Layered;
@ -33,7 +33,7 @@ GetLayeredStatus(PWND pWnd)
BOOL FASTCALL
SetLayeredStatus(PWND pWnd, BYTE set)
{
PLRD_PROP pLrdProp = UserGetProp(pWnd, AtomLayer);
PLRD_PROP pLrdProp = UserGetProp(pWnd, AtomLayer, TRUE);
if (pLrdProp)
{
pLrdProp->is_Layered = set;
@ -57,7 +57,7 @@ IntSetLayeredWindowAttributes(PWND pWnd,
return FALSE;
}
pLrdProp = UserGetProp(pWnd, AtomLayer);
pLrdProp = UserGetProp(pWnd, AtomLayer, TRUE);
if (!pLrdProp)
{
@ -68,7 +68,7 @@ IntSetLayeredWindowAttributes(PWND pWnd,
return FALSE;
}
RtlZeroMemory(pLrdProp, sizeof(LRD_PROP));
UserSetProp(pWnd, AtomLayer, (HANDLE)pLrdProp);
UserSetProp(pWnd, AtomLayer, (HANDLE)pLrdProp, TRUE);
}
if (pLrdProp)
@ -258,7 +258,7 @@ NtUserGetLayeredWindowAttributes(
goto Exit;
}
pLrdProp = UserGetProp(pWnd, AtomLayer);
pLrdProp = UserGetProp(pWnd, AtomLayer, TRUE);
if (!pLrdProp)
{

View file

@ -606,8 +606,8 @@ PCURICON_OBJECT FASTCALL NC_IconForWindow( PWND pWnd )
//FIXME: This is bad and we should feel bad.
//FIXME: Stop whining over wine code.
hIcon = UserGetProp(pWnd, gpsi->atomIconSmProp);
if (!hIcon) hIcon = UserGetProp(pWnd, gpsi->atomIconProp);
hIcon = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE);
if (!hIcon) hIcon = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
if (!hIcon && pWnd->pcls->spicnSm)
return pWnd->pcls->spicnSm;

View file

@ -1189,7 +1189,7 @@ IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
ASSERT(pfwi);
FlashState = (DWORD)UserGetProp(pWnd, AtomFlashWndState);
FlashState = (DWORD)UserGetProp(pWnd, AtomFlashWndState, TRUE);
if (FlashState == FLASHW_FINISHED)
{
@ -1267,7 +1267,7 @@ IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
IntKillTimer(pWnd, ID_EVENT_SYSTIMER_FLASHWIN, TRUE);
}
UserRemoveProp(pWnd, AtomFlashWndState);
UserRemoveProp(pWnd, AtomFlashWndState, TRUE);
}
else
{ // Have a count and started, set timer.
@ -1305,7 +1305,7 @@ IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
FlashState ^= (FlashState ^ pfwi->dwFlags) & (FLASHW_MASK & ~FLASHW_TIMER);
}
FlashState = MAKELONG(LOWORD(FlashState),uCount);
UserSetProp(pWnd, AtomFlashWndState, (HANDLE) FlashState);
UserSetProp(pWnd, AtomFlashWndState, (HANDLE)FlashState, TRUE);
}
return Ret;
}

View file

@ -15,11 +15,13 @@ PPROPERTY
FASTCALL
IntGetProp(
_In_ PWND Window,
_In_ ATOM Atom)
_In_ ATOM Atom,
_In_ BOOLEAN SystemProp)
{
PLIST_ENTRY ListEntry;
PPROPERTY Property;
UINT i;
WORD SystemFlag = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
NT_ASSERT(UserIsEntered());
ListEntry = Window->PropListHead.Flink;
@ -27,33 +29,29 @@ IntGetProp(
for (i = 0; i < Window->PropListItems; i++)
{
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
if (ListEntry == NULL)
{
ERR("Corrupted (or uninitialized?) property list for window %p. Prop count %u. Atom %u.\n",
Window, Window->PropListItems, Atom);
return NULL;
}
if (Property->Atom == Atom)
{
return(Property);
}
ListEntry = ListEntry->Flink;
if (Property->Atom == Atom &&
(Property->fs & PROPERTY_FLAG_SYSTEM) == SystemFlag)
{
return Property;
}
}
return(NULL);
NT_ASSERT(ListEntry == &Window->PropListHead);
return NULL;
}
HANDLE
FASTCALL
UserGetProp(
_In_ PWND Window,
_In_ ATOM Atom)
_In_ ATOM Atom,
_In_ BOOLEAN SystemProp)
{
PPROPERTY Prop;
NT_ASSERT(UserIsEntered());
Prop = IntGetProp(Window, Atom);
Prop = IntGetProp(Window, Atom, SystemProp);
return Prop ? Prop->Data : NULL;
}
@ -62,13 +60,14 @@ HANDLE
FASTCALL
UserRemoveProp(
_In_ PWND Window,
_In_ ATOM Atom)
_In_ ATOM Atom,
_In_ BOOLEAN SystemProp)
{
PPROPERTY Prop;
HANDLE Data;
NT_ASSERT(UserIsEnteredExclusive());
Prop = IntGetProp(Window, Atom);
Prop = IntGetProp(Window, Atom, SystemProp);
if (Prop == NULL)
{
return NULL;
@ -87,12 +86,13 @@ FASTCALL
UserSetProp(
_In_ PWND Window,
_In_ ATOM Atom,
_In_ HANDLE Data)
_In_ HANDLE Data,
_In_ BOOLEAN SystemProp)
{
PPROPERTY Prop;
NT_ASSERT(UserIsEnteredExclusive());
Prop = IntGetProp(Window, Atom);
Prop = IntGetProp(Window, Atom, SystemProp);
if (Prop == NULL)
{
Prop = UserHeapAlloc(sizeof(PROPERTY));
@ -101,6 +101,7 @@ UserSetProp(
return FALSE;
}
Prop->Atom = Atom;
Prop->fs = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
InsertTailList(&Window->PropListHead, &Prop->PropListEntry);
Window->PropListItems++;
}
@ -171,24 +172,28 @@ NtUserBuildPropList(
(ListEntry != &Window->PropListHead))
{
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
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++;
ListEntry = ListEntry->Flink;
if (!(Property->fs & PROPERTY_FLAG_SYSTEM))
{
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++;
}
}
}
else
{
/* FIXME: This counts user and system props */
Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
}
@ -228,7 +233,7 @@ NtUserRemoveProp(
goto Exit;
}
Data = UserRemoveProp(Window, Atom);
Data = UserRemoveProp(Window, Atom, FALSE);
Exit:
TRACE("Leave NtUserRemoveProp, ret=%p\n", Data);
@ -257,7 +262,7 @@ NtUserSetProp(
goto Exit;
}
Ret = UserSetProp(Window, Atom, Data);
Ret = UserSetProp(Window, Atom, Data, FALSE);
Exit:
TRACE("Leave NtUserSetProp, ret=%i\n", Ret);

View file

@ -4,13 +4,15 @@ HANDLE
FASTCALL
UserGetProp(
_In_ PWND Window,
_In_ ATOM Atom);
_In_ ATOM Atom,
_In_ BOOLEAN SystemProp);
HANDLE
FASTCALL
UserRemoveProp(
_In_ PWND Window,
_In_ ATOM Atom);
_In_ ATOM Atom,
_In_ BOOLEAN SystemProp);
_Success_(return)
BOOL
@ -18,7 +20,8 @@ FASTCALL
UserSetProp(
_In_ PWND Window,
_In_ ATOM Atom,
_In_ HANDLE Data);
_In_ HANDLE Data,
_In_ BOOLEAN SystemProp);
VOID
FASTCALL

View file

@ -610,7 +610,7 @@ NtUserCallHwnd(
return 0;
}
HelpId = (DWORD)(DWORD_PTR)UserGetProp(Window, gpsi->atomContextHelpIdProp);
HelpId = (DWORD)(DWORD_PTR)UserGetProp(Window, gpsi->atomContextHelpIdProp, TRUE);
UserLeave();
return HelpId;
@ -666,9 +666,9 @@ NtUserCallHwndParam(
}
if ( Param )
UserSetProp(Window, gpsi->atomContextHelpIdProp, (HANDLE)Param);
UserSetProp(Window, gpsi->atomContextHelpIdProp, (HANDLE)Param, TRUE);
else
UserRemoveProp(Window, gpsi->atomContextHelpIdProp);
UserRemoveProp(Window, gpsi->atomContextHelpIdProp, TRUE);
UserLeave();
return TRUE;

View file

@ -967,7 +967,7 @@ UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
if (hWnd && (Wnd = UserGetWindowObject(hWnd)))
{
Clip = (XCLIPOBJ*)UserGetProp(Wnd, AtomWndObj);
Clip = (XCLIPOBJ*)UserGetProp(Wnd, AtomWndObj, TRUE);
if ( Clip && Clip->Hwnd == hWnd )
{

View file

@ -373,7 +373,7 @@ DWORD FASTCALL IntGetWindowContextHelpId( PWND pWnd )
do
{
HelpId = (DWORD)(DWORD_PTR)UserGetProp(pWnd, gpsi->atomContextHelpIdProp);
HelpId = (DWORD)(DWORD_PTR)UserGetProp(pWnd, gpsi->atomContextHelpIdProp, TRUE);
if (!HelpId) break;
pWnd = IntGetParent(pWnd);
}

View file

@ -133,7 +133,7 @@ BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down );
HWND* WIN_ListChildren (HWND hWndparent);
VOID DeleteFrameBrushes(VOID);
BOOL WINAPI GdiValidateHandle(HGDIOBJ);
HANDLE FASTCALL UserGetProp(HWND hWnd, ATOM Atom);
HANDLE FASTCALL UserGetProp(HWND hWnd, ATOM Atom, BOOLEAN SystemProp);
BOOL WINAPI InitializeImmEntryTable(VOID);
/* EOF */

View file

@ -397,11 +397,11 @@ DefWndGetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
switch(wParam)
{
case ICON_BIG:
hIconRet = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconProp);
hIconRet = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconProp, TRUE);
break;
case ICON_SMALL:
case ICON_SMALL2:
hIconRet = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconSmProp);
hIconRet = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconSmProp, TRUE);
break;
default:
break;

View file

@ -35,12 +35,13 @@
HANDLE
FASTCALL
IntGetProp(HWND hWnd, ATOM Atom)
IntGetProp(HWND hWnd, ATOM Atom, BOOLEAN SystemProp)
{
PLIST_ENTRY ListEntry, temp;
PPROPERTY Property;
PWND pWnd;
int i;
WORD SystemFlag = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
pWnd = ValidateHwnd(hWnd);
if (!pWnd) return NULL;
@ -49,7 +50,8 @@ IntGetProp(HWND hWnd, ATOM Atom)
for (i = 0; i < pWnd->PropListItems; i++ )
{
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
if (Property->Atom == Atom)
if (Property->Atom == Atom &&
(Property->fs & PROPERTY_FLAG_SYSTEM) == SystemFlag)
{
return(Property);
}
@ -61,10 +63,10 @@ IntGetProp(HWND hWnd, ATOM Atom)
HANDLE
FASTCALL
UserGetProp(HWND hWnd, ATOM Atom)
UserGetProp(HWND hWnd, ATOM Atom, BOOLEAN SystemProp)
{
PPROPERTY Prop;
Prop = IntGetProp(hWnd, Atom);
Prop = IntGetProp(hWnd, Atom, SystemProp);
return Prop ? Prop->Data : NULL;
}
@ -383,7 +385,7 @@ GetPropW(HWND hWnd, LPCWSTR lpString)
{
Atom = LOWORD((DWORD_PTR)lpString);
}
Prop = IntGetProp(hWnd, Atom);
Prop = IntGetProp(hWnd, Atom, FALSE);
if (Prop != NULL) Data = Prop->Data;
return Data;
}