HWND* FASTCALL
IntWinListChildren(PWND Window)
{
- PWND Child;
- HWND *List;
- UINT Index, NumChildren = 0;
+ PWND Child;
+ HWND *List;
+ UINT Index, NumChildren = 0;
- if (!Window) return NULL;
+ if (!Window) return NULL;
- for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
- ++NumChildren;
+ for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
+ {
+ ++NumChildren;
+ }
- List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
- if(!List)
- {
- ERR("Failed to allocate memory for children array\n");
- EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
- for (Child = Window->spwndChild, Index = 0;
- Child != NULL;
- Child = Child->spwndNext, ++Index)
- List[Index] = Child->head.h;
- List[Index] = NULL;
+ List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
+ if(!List)
+ {
+ ERR("Failed to allocate memory for children array\n");
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return NULL;
+ }
+
+ Index = 0;
+ for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
+ {
+ List[Index++] = Child->head.h;
+ }
+ List[Index] = NULL;
+
+ return List;
+}
+
+HWND* FASTCALL
+IntWinListOwnedPopups(PWND Window)
+{
+ PWND Child, Desktop;
+ HWND *List;
+ UINT Index, NumOwned = 0;
+
+ Desktop = co_GetDesktopWindow(Window);
+ if (!Desktop)
+ return NULL;
+
+ for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
+ {
+ if (Child->spwndOwner == Window)
+ ++NumOwned;
+ }
+
+ List = ExAllocatePoolWithTag(PagedPool, (NumOwned + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
+ if (!List)
+ {
+ ERR("Failed to allocate memory for children array\n");
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return NULL;
+ }
+
+ Index = 0;
+ for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
+ {
+ if (Child->spwndOwner == Window)
+ List[Index++] = Child->head.h;
+ }
+ List[Index] = NULL;
- return List;
+ return List;
}
PWND FASTCALL
return HelpId;
}
+
+VOID
+FASTCALL
+IntRemoveTrackMouseEvent(
+ PDESKTOP pDesk);
+
/***********************************************************************
* IntSendDestroyMsg
*/
{
co_IntDestroyCaret(ti);
}
+
+ /* If the window being destroyed is currently tracked... */
+ if (ti->rpdesk->spwndTrack == Window)
+ {
+ IntRemoveTrackMouseEvent(ti->rpdesk);
+ }
}
/* If the window being destroyed is the current clipboard owner... */
MsqDecPaintCountQueue(Window->head.pti);
if (Window->hrgnUpdate > HRGN_WINDOW && GreIsHandleValid(Window->hrgnUpdate))
{
+ IntGdiSetRegionOwner(Window->hrgnUpdate, GDI_OBJ_HMGR_POWNED);
GreDeleteObject(Window->hrgnUpdate);
}
Window->hrgnUpdate = NULL;
}
UserReferenceObject(Window);
- UserDeleteObject(UserHMGetHandle(Window), TYPE_WINDOW);
+ UserMarkObjectDestroy(Window);
IntDestroyScrollBars(Window);
UserFreeWindowInfo(Window->head.pti, Window);
UserDereferenceObject(Window);
+ UserDeleteObject(UserHMGetHandle(Window), TYPE_WINDOW);
return 0;
}
}
////
-/*
- Link the window into siblings list
- children and parent are kept in place.
-*/
+/* Link the window into siblings list. Children and parent are kept in place. */
VOID FASTCALL
IntLinkWindow(
- PWND Wnd,
- PWND WndInsertAfter /* set to NULL if top sibling */
+ PWND Wnd,
+ PWND WndInsertAfter /* Set to NULL if top sibling */
)
{
- if ((Wnd->spwndPrev = WndInsertAfter))
- {
- /* link after WndInsertAfter */
- if ((Wnd->spwndNext = WndInsertAfter->spwndNext))
- Wnd->spwndNext->spwndPrev = Wnd;
+ if (Wnd == WndInsertAfter)
+ {
+ ERR("IntLinkWindow -- Trying to link window 0x%p to itself!!\n", Wnd);
+ return;
+ }
- Wnd->spwndPrev->spwndNext = Wnd;
- }
- else
- {
- /* link at top */
- if ((Wnd->spwndNext = Wnd->spwndParent->spwndChild))
- Wnd->spwndNext->spwndPrev = Wnd;
+ Wnd->spwndPrev = WndInsertAfter;
+ if (Wnd->spwndPrev)
+ {
+ /* Link after WndInsertAfter */
+ ASSERT(Wnd != WndInsertAfter->spwndNext);
+ Wnd->spwndNext = WndInsertAfter->spwndNext;
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd;
+
+ ASSERT(Wnd != Wnd->spwndPrev);
+ Wnd->spwndPrev->spwndNext = Wnd;
+ }
+ else
+ {
+ /* Link at the top */
+ ASSERT(Wnd != Wnd->spwndParent->spwndChild);
+ Wnd->spwndNext = Wnd->spwndParent->spwndChild;
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd;
- Wnd->spwndParent->spwndChild = Wnd;
- }
+ Wnd->spwndParent->spwndChild = Wnd;
+ }
}
/*
{
if (hWndPrev == HWND_NOTOPMOST)
{
- if (!(Wnd->ExStyle & WS_EX_TOPMOST) &&
- (Wnd->ExStyle2 & WS_EX2_LINKED)) return; /* nothing to do */
+ if (!(Wnd->ExStyle & WS_EX_TOPMOST) && (Wnd->ExStyle2 & WS_EX2_LINKED))
+ return; /* nothing to do */
Wnd->ExStyle &= ~WS_EX_TOPMOST;
hWndPrev = HWND_TOP; /* fallback to the HWND_TOP case */
}
PWND WndInsertAfter;
WndInsertAfter = Wnd->spwndParent->spwndChild;
- while( WndInsertAfter && WndInsertAfter->spwndNext)
+ while (WndInsertAfter && WndInsertAfter->spwndNext)
+ {
WndInsertAfter = WndInsertAfter->spwndNext;
+ }
IntLinkWindow(Wnd, WndInsertAfter);
Wnd->ExStyle &= ~WS_EX_TOPMOST;
{
/* Link in the top of the list */
IntLinkWindow(Wnd, NULL);
-
Wnd->ExStyle |= WS_EX_TOPMOST;
}
else if (hWndPrev == HWND_TOP)
{
while (WndInsertBefore != NULL && WndInsertBefore->spwndNext != NULL)
{
- if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST)) break;
+ if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST))
+ break;
+
if (WndInsertBefore == Wnd->spwndOwner) /* keep it above owner */
{
Wnd->ExStyle |= WS_EX_TOPMOST;
WndInsertAfter = UserGetWindowObject(hWndPrev);
/* Are we called with an erroneous handle */
- if(WndInsertAfter == NULL)
+ if (WndInsertAfter == NULL)
{
/* Link in a default position */
IntLinkHwnd(Wnd, HWND_TOP);
return;
}
+ if (Wnd == WndInsertAfter)
+ ERR("IntLinkHwnd -- Trying to link window 0x%p to itself!!\n", Wnd);
IntLinkWindow(Wnd, WndInsertAfter);
/* Fix the WS_EX_TOPMOST flag */
}
else
{
- if(WndInsertAfter->spwndNext &&
- WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST)
+ if (WndInsertAfter->spwndNext &&
+ (WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST))
{
Wnd->ExStyle |= WS_EX_TOPMOST;
}
/* Link the window with its new siblings */
IntLinkHwnd( Wnd,
((0 == (Wnd->ExStyle & WS_EX_TOPMOST) &&
- WndNewParent == UserGetDesktopWindow() ) ? HWND_TOP : HWND_TOPMOST ) );
-
+ UserIsDesktopWindow(WndNewParent) ) ? HWND_TOP : HWND_TOPMOST ) );
}
if ( WndNewParent == co_GetDesktopWindow(Wnd) &&
}
}
- if (WndOldParent == UserGetMessageWindow() || WndNewParent == UserGetMessageWindow())
+ if (UserIsMessageWindow(WndOldParent) || UserIsMessageWindow(WndNewParent))
swFlags |= SWP_NOACTIVATE;
IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE, Wnd ,OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
return( hWndOldParent);
}
-/* Unlink the window from siblings. children and parent are kept in place. */
+/* Unlink the window from siblings. Children and parent are kept in place. */
VOID FASTCALL
IntUnlinkWindow(PWND Wnd)
{
- if (Wnd->spwndNext)
- Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
+ ASSERT(Wnd != Wnd->spwndNext);
+ ASSERT(Wnd != Wnd->spwndPrev);
+
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
- if (Wnd->spwndPrev)
- Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
+ if (Wnd->spwndPrev)
+ Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
- if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
- Wnd->spwndParent->spwndChild = Wnd->spwndNext;
+ if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
+ Wnd->spwndParent->spwndChild = Wnd->spwndNext;
- Wnd->spwndPrev = Wnd->spwndNext = NULL;
+ Wnd->spwndPrev = Wnd->spwndNext = NULL;
}
/* FUNCTIONS *****************************************************************/
PWND Window;
HWND *List = NULL;
- Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
+ Status = PsLookupThreadByThreadId(UlongToHandle(dwThreadId), &Thread);
if (!NT_SUCCESS(Status))
{
ERR("Thread Id is not valid!\n");
if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD &&
!(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY))
{
- if (VerifyWnd(pWindow->spwndParent) && pWindow->spwndParent != UserGetDesktopWindow())
+ if (VerifyWnd(pWindow->spwndParent) && !UserIsDesktopWindow(pWindow->spwndParent))
{
USER_REFERENCE_ENTRY Ref;
UserRefObjectCo(pWindow->spwndParent, &Ref);
}
}
else // Not a child
- pWnd->IDMenu = (UINT) Cs->hMenu;
+ pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
if ( ParentWindow &&
Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
if(!Class)
{
+ EngSetLastError(ERROR_CANNOT_FIND_WND_CLASS);
ERR("Failed to find class %wZ\n", ClassName);
goto cleanup;
}
}
else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
{
- ERR("Cannot create a child window without a parrent!\n");
+ ERR("Cannot create a child window without a parent!\n");
EngSetLastError(ERROR_TLW_WITH_WSCHILD);
goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
}
ERR("Got invalid parent window handle\n");
goto cleanup;
}
+ else if (hWndOwner && !OwnerWindow)
+ {
+ ERR("Got invalid owner window handle\n");
+ ParentWindow = NULL;
+ goto cleanup;
+ }
if(OwnerWindow)
{
IntSendParentNotify(Window, WM_CREATE);
/* Notify the shell that a new window was created */
- if (Window->spwndParent == UserGetDesktopWindow() &&
+ if (UserIsDesktopWindow(Window->spwndParent) &&
Window->spwndOwner == NULL &&
(Window->style & WS_VISIBLE) &&
(!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
}
if (ParentWindow) UserDerefObjectCo(ParentWindow);
+ // See CORE-13717, not setting error on success.
+ if (ret)
+ EngSetLastError(ERROR_SUCCESS);
+
return ret;
}
NTSTATUS Status;
LARGE_STRING lstrWindowName;
LARGE_STRING lstrClassName;
+ LARGE_STRING lstrClsVersion;
UNICODE_STRING ustrClassName;
+ UNICODE_STRING ustrClsVersion;
CREATESTRUCTW Cs;
HWND hwnd = NULL;
PWND pwnd;
lstrWindowName.Buffer = NULL;
lstrClassName.Buffer = NULL;
+ lstrClsVersion.Buffer = NULL;
ASSERT(plstrWindowName);
ustrClassName.MaximumLength = (USHORT)min(lstrClassName.MaximumLength, MAXUSHORT);
}
+ /* Check if the class version is an atom */
+ if (IS_ATOM(plstrClsVersion))
+ {
+ /* It is, pass the atom in the UNICODE_STRING */
+ ustrClsVersion.Buffer = (PVOID)plstrClsVersion;
+ ustrClsVersion.Length = 0;
+ ustrClsVersion.MaximumLength = 0;
+ }
+ else
+ {
+ /* It's not, capture the class name */
+ Status = ProbeAndCaptureLargeString(&lstrClsVersion, plstrClsVersion);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("NtUserCreateWindowEx: failed to capture plstrClsVersion\n");
+ /* Set last error, cleanup and return */
+ SetLastNtError(Status);
+ goto cleanup;
+ }
+
+ /* We pass it on as a UNICODE_STRING */
+ ustrClsVersion.Buffer = lstrClsVersion.Buffer;
+ ustrClsVersion.Length = (USHORT)min(lstrClsVersion.Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
+ ustrClsVersion.MaximumLength = (USHORT)min(lstrClsVersion.MaximumLength, MAXUSHORT);
+ }
+
/* Fill the CREATESTRUCTW */
/* we will keep here the original parameters */
Cs.style = dwStyle;
UserEnterExclusive();
/* Call the internal function */
- pwnd = co_UserCreateWindowEx(&Cs, &ustrClassName, plstrWindowName, acbiBuffer);
+ pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer);
if(!pwnd)
{
{
ExFreePoolWithTag(lstrClassName.Buffer, TAG_STRING);
}
+ if (lstrClsVersion.Buffer)
+ {
+ ExFreePoolWithTag(lstrClsVersion.Buffer, TAG_STRING);
+ }
return hwnd;
}
hWnd = Window->head.h;
ti = PsGetCurrentThreadWin32Thread();
- TRACE("co_UserDestroyWindow \n");
+ TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
/* Check for owner thread */
if ( Window->head.pti != PsGetCurrentThreadWin32Thread())
}
}
- // Adjust last active.
+ /* Adjust last active */
if ((pwndTemp = Window->spwndOwner))
{
while (pwndTemp->spwndOwner)
/* Do not send WM_GETTEXT messages in the kernel mode version!
The user mode version however calls GetWindowText() which will
send WM_GETTEXT messages to windows belonging to its processes */
- if (!ClassAtom || Child->pcls->atomClassName == ClassAtom)
+ if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
{
// FIXME: LARGE_STRING truncated
CurrentWindowName.Buffer = Child->strName.Buffer;
if (!IntGetAtomFromStringOrAtom(&ClassName,
&ClassAtom))
{
+ EngSetLastError(ERROR_CANNOT_FIND_WND_CLASS);
_SEH2_LEAVE;
}
}
(TopLevelWindow->strName.Length < 0xFFFF &&
!RtlCompareUnicodeString(&WindowName, &ustr, TRUE));
ClassMatches = (ClassAtom == (RTL_ATOM)0) ||
- ClassAtom == TopLevelWindow->pcls->atomClassName;
+ ClassAtom == TopLevelWindow->pcls->atomNVClassName;
if (WindowMatches && ClassMatches)
{
}
else
{
- ERR("FindWindowEx: Not Desktop Parent!\n");
+ TRACE("FindWindowEx: Not Desktop Parent!\n");
Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
}
RETURN(FALSE);
}
- if(!(WndListView = UserGetWindowObject(hwndListView)))
+ if (!(WndListView = UserGetWindowObject(hwndListView)))
{
RETURN(FALSE);
}
return FALSE;
}
-static LONG
-co_IntSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi, BOOL bAlter)
+static LONG_PTR
+co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
{
PWND Window, Parent;
PWINSTATION_OBJECT WindowStation;
- LONG OldValue;
+ LONG_PTR OldValue;
STYLESTRUCT Style;
if (!(Window = UserGetWindowObject(hWnd)))
if ((INT)Index >= 0)
{
- if ((Index + sizeof(LONG)) > Window->cbwndExtra)
+ if ((Index + Size) > Window->cbwndExtra)
{
EngSetLastError(ERROR_INVALID_INDEX);
return( 0);
}
- OldValue = *((LONG *)((PCHAR)(Window + 1) + Index));
-/*
- if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
+#ifdef _WIN64
+ if (Size == sizeof(LONG))
{
- OldValue = (LONG)IntSetWindowProc( Wnd,
- (WNDPROC)NewValue,
- Ansi);
- if (!OldValue) return 0;
+ OldValue = *((LONG *)((PCHAR)(Window + 1) + Index));
+ *((LONG*)((PCHAR)(Window + 1) + Index)) = (LONG)NewValue;
}
- */
- *((LONG *)((PCHAR)(Window + 1) + Index)) = NewValue;
+ else
+#endif
+ {
+ OldValue = *((LONG_PTR *)((PCHAR)(Window + 1) + Index));
+ /*
+ if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
+ {
+ OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi);
+ if (!OldValue) return 0;
+ }
+ */
+ *((LONG_PTR*)((PCHAR)(Window + 1) + Index)) = NewValue;
+ }
+
}
else
{
+#ifdef _WIN64
+ if (Size == sizeof(LONG))
+ {
+ if ((Index != GWL_STYLE) &&
+ (Index != GWL_EXSTYLE) &&
+ (Index != GWL_ID) &&
+ (Index != GWL_USERDATA))
+ {
+ ERR("NtUserSetWindowLong(): Index requires pointer size: %lu\n", Index);
+ EngSetLastError(ERROR_INVALID_INDEX);
+ return 0;
+ }
+ }
+#endif
+
switch (Index)
{
- case GWL_EXSTYLE:
+ case GWL_EXSTYLE: // LONG
OldValue = (LONG) Window->ExStyle;
Style.styleOld = OldValue;
Style.styleNew = NewValue;
co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
break;
- case GWL_STYLE:
+ case GWL_STYLE: // LONG
OldValue = (LONG) Window->style;
Style.styleOld = OldValue;
Style.styleNew = NewValue;
if (!bAlter)
co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
- /* WS_CLIPSIBLINGS can't be reset on top-level windows */
- if (Window->spwndParent == UserGetDesktopWindow()) Style.styleNew |= WS_CLIPSIBLINGS;
+ /* WS_CLIPSIBLINGS can't be reset on top-level windows */
+ if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS;
+ /* WS_MINIMIZE can't be reset */
+ if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE;
/* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
if (IntCheckFrameEdge(NewValue, Window->ExStyle))
Window->ExStyle |= WS_EX_WINDOWEDGE;
else
Window->ExStyle &= ~WS_EX_WINDOWEDGE;
+ if ((OldValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+ {
+ if ((NewValue & (WS_CHILD | WS_POPUP)) != WS_CHILD)
+ {
+ //// From child to non-child it should be null already.
+ ERR("IDMenu going null! %d\n",Window->IDMenu);
+ Window->IDMenu = 0; // Window->spmenu = 0;
+ }
+ }
+ else
+ {
+ if ((NewValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+ {
+ PMENU pMenu = UserGetMenuObject(UlongToHandle(Window->IDMenu));
+ Window->state &= ~WNDS_HASMENU;
+ if (pMenu)
+ {
+ ERR("IDMenu released 0x%p\n",pMenu);
+ // ROS may not hold a lock after setting menu to window. But it should!
+ //IntReleaseMenuObject(pMenu);
+ }
+ }
+ }
+
if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE)
{
if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--;
co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
break;
- case GWL_WNDPROC:
+ case GWLP_WNDPROC: // LONG_PTR
{
if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
Window->fnid & FNID_FREED)
EngSetLastError(ERROR_ACCESS_DENIED);
return( 0);
}
- OldValue = (LONG)IntSetWindowProc(Window,
- (WNDPROC)NewValue,
- Ansi);
+ OldValue = (LONG_PTR)IntSetWindowProc(Window,
+ (WNDPROC)NewValue,
+ Ansi);
break;
}
- case GWL_HINSTANCE:
- OldValue = (LONG) Window->hModule;
+ case GWLP_HINSTANCE: // LONG_PTR
+ OldValue = (LONG_PTR) Window->hModule;
Window->hModule = (HINSTANCE) NewValue;
break;
- case GWL_HWNDPARENT:
+ case GWLP_HWNDPARENT: // LONG_PTR
Parent = Window->spwndParent;
if (Parent && (Parent->head.h == IntGetDesktopWindow()))
- OldValue = (LONG) IntSetOwner(Window->head.h, (HWND) NewValue);
+ OldValue = (LONG_PTR) IntSetOwner(Window->head.h, (HWND) NewValue);
else
- OldValue = (LONG) co_UserSetParent(Window->head.h, (HWND) NewValue);
+ OldValue = (LONG_PTR) co_UserSetParent(Window->head.h, (HWND) NewValue);
break;
- case GWL_ID:
+ case GWLP_ID: // LONG
OldValue = (LONG) Window->IDMenu;
Window->IDMenu = (UINT) NewValue;
break;
- case GWL_USERDATA:
+ case GWLP_USERDATA: // LONG or LONG_PTR
OldValue = Window->dwUserData;
Window->dwUserData = NewValue;
break;
return( OldValue);
}
-
LONG FASTCALL
co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
{
- return co_IntSetWindowLong(hWnd, Index, NewValue, Ansi, FALSE);
+ return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
+}
+
+LONG_PTR FASTCALL
+co_UserSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi)
+{
+ return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
}
/*
return 0;
}
- ret = co_IntSetWindowLong(hWnd, Index, NewValue, Ansi, FALSE);
+ ret = (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
UserLeave();
return ret;
}
+#ifdef _WIN64
+LONG_PTR APIENTRY
+NtUserSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi)
+{
+ LONG_PTR ret;
+
+ UserEnterExclusive();
+
+ if (hWnd == IntGetDesktopWindow())
+ {
+ EngSetLastError(STATUS_ACCESS_DENIED);
+ UserLeave();
+ return 0;
+ }
+
+ ret = co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
+
+ UserLeave();
+
+ return ret;
+}
+#endif // _WIN64
+
DWORD APIENTRY
NtUserAlterWindowStyle(HWND hWnd, DWORD Index, LONG NewValue)
{
return 0;
}
- ret = co_IntSetWindowLong(hWnd, Index, NewValue, FALSE, TRUE);
+ ret = co_IntSetWindowLongPtr(hWnd, Index, NewValue, FALSE, sizeof(LONG), TRUE);
UserLeave();
/*
* @implemented
*/
-DWORD APIENTRY
+DWORD_PTR APIENTRY
NtUserQueryWindow(HWND hWnd, DWORD Index)
{
/* Console Leader Process CID Window offsets */
#define GWLP_CONSOLE_LEADER_TID 4
PWND pWnd;
- DWORD Result;
+ DWORD_PTR Result;
DECLARE_RETURN(UINT);
TRACE("Enter NtUserQueryWindow\n");
(pWnd->pcls->atomClassName == gaGuiConsoleWndClass) )
{
// IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_PID)
- Result = (DWORD)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_PID)));
+ Result = (DWORD_PTR)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_PID)));
}
else
{
- Result = (DWORD)IntGetWndProcessId(pWnd);
+ Result = (DWORD_PTR)IntGetWndProcessId(pWnd);
}
break;
}
(pWnd->pcls->atomClassName == gaGuiConsoleWndClass) )
{
// IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_TID)
- Result = (DWORD)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_TID)));
+ Result = (DWORD_PTR)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_TID)));
}
else
{
- Result = (DWORD)IntGetWndThreadId(pWnd);
+ Result = (DWORD_PTR)IntGetWndThreadId(pWnd);
}
break;
}
case QUERY_WINDOW_ACTIVE:
- Result = (DWORD)(pWnd->head.pti->MessageQueue->spwndActive ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndActive) : 0);
+ Result = (DWORD_PTR)(pWnd->head.pti->MessageQueue->spwndActive ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndActive) : 0);
break;
case QUERY_WINDOW_FOCUS:
- Result = (DWORD)(pWnd->head.pti->MessageQueue->spwndFocus ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndFocus) : 0);
+ Result = (DWORD_PTR)(pWnd->head.pti->MessageQueue->spwndFocus ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndFocus) : 0);
break;
case QUERY_WINDOW_ISHUNG:
- Result = (DWORD)MsqIsHung(pWnd->head.pti);
+ Result = (DWORD_PTR)MsqIsHung(pWnd->head.pti);
break;
case QUERY_WINDOW_REAL_ID:
- Result = (DWORD)pWnd->head.pti->pEThread->Cid.UniqueProcess;
+ Result = (DWORD_PTR)pWnd->head.pti->pEThread->Cid.UniqueProcess;
break;
case QUERY_WINDOW_FOREGROUND:
break;
default:
- Result = (DWORD)NULL;
+ Result = 0;
break;
}
// ASSERT(OwnerWnd);
TRACE("Enter ShowOwnedPopups Show: %s\n", (fShow ? "TRUE" : "FALSE"));
- win_array = IntWinListChildren(OwnerWnd);
+
+ /* NOTE: Popups are not children */
+ win_array = IntWinListOwnedPopups(OwnerWnd);
if (!win_array)
return TRUE;
* regardless of the state of the owner
*/
co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING);
+ pWnd->state &= ~WNDS_HIDDENPOPUP;
continue;
}
}
* regardless of the state of the owner
*/
co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
+ pWnd->state |= WNDS_HIDDENPOPUP;
continue;
}
}
-
}
ExFreePoolWithTag(win_array, USERTAG_WINDOWLIST);
TRACE("Leave ShowOwnedPopups\n");