ReactOS 0.4.16-dev-2279-gc890759
window.c File Reference
#include <win32k.h>
#include <immdev.h>
#include <unaligned.h>
Include dependency graph for window.c:

Go to the source code of this file.

Classes

struct  HEADCOMBO
 
struct  _WND2CBOX
 
struct  LB_DESCR
 
struct  _WND2LB
 

Macros

#define GROW_COUNT   8
 
#define INITIAL_COUNT   32
 
#define IS_DEFAULT(x)   ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
 
#define CBF_BUTTONDOWN   0x0002
 
#define GWLP_CONSOLE_LEADER_PID   0
 
#define GWLP_CONSOLE_LEADER_TID   4
 

Typedefs

typedef struct HEADCOMBOLPHEADCOMBO
 
typedef struct _WND2CBOX WND2CBOX
 
typedef struct _WND2CBOXPWND2CBOX
 
typedef struct _WND2LB WND2LB
 
typedef struct _WND2LBPWND2LB
 

Functions

 DBG_DEFAULT_CHANNEL (UserWnd)
 
PVOID FASTCALL IntReAllocatePoolWithTag (POOL_TYPE PoolType, PVOID pOld, SIZE_T cbOld, SIZE_T cbNew, ULONG Tag)
 
BOOL FASTCALL UserUpdateUiState (PWND Wnd, WPARAM wParam)
 
PWND FASTCALL IntGetWindowObject (HWND hWnd)
 
PWND FASTCALL VerifyWnd (PWND pWnd)
 
PWND FASTCALL ValidateHwndNoErr (HWND hWnd)
 
PWND FASTCALL UserGetWindowObject (HWND hWnd)
 
ULONG FASTCALL IntSetStyle (PWND pwnd, ULONG set_bits, ULONG clear_bits)
 
BOOL FASTCALL IntIsWindow (HWND hWnd)
 
BOOL FASTCALL IntIsWindowVisible (PWND Wnd)
 
PWND FASTCALL IntGetParent (PWND Wnd)
 
BOOL FASTCALL IntEnableWindow (HWND hWnd, BOOL bEnable)
 
HWND *FASTCALL IntWinListChildren (PWND Window)
 
static BOOL IntWndIsDefaultIme (_In_ PWND Window)
 
HWND *FASTCALL IntWinListOwnedPopups (PWND Window)
 
PWND FASTCALL IntGetNonChildAncestor (PWND pWnd)
 
BOOL FASTCALL IntIsTopLevelWindow (PWND pWnd)
 
BOOL FASTCALL IntValidateOwnerDepth (PWND Wnd, PWND Owner)
 
HWND FASTCALL IntGetWindow (HWND hWnd, UINT uCmd)
 
DWORD FASTCALL IntGetWindowContextHelpId (PWND pWnd)
 
VOID FASTCALL IntRemoveTrackMouseEvent (PDESKTOP pDesk)
 
static void IntSendDestroyMsg (HWND hWnd)
 
static VOID UserFreeWindowInfo (PTHREADINFO ti, PWND Wnd)
 
LRESULT co_UserFreeWindow (PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
 
WNDPROC FASTCALL IntGetWindowProc (PWND pWnd, BOOL Ansi)
 
static WNDPROC IntSetWindowProc (PWND pWnd, WNDPROC NewWndProc, BOOL Ansi)
 
BOOL FASTCALL IntIsChildWindow (PWND Parent, PWND BaseWindow)
 
VOID FASTCALL IntLinkWindow (PWND Wnd, PWND WndInsertAfter)
 
VOID FASTCALL IntLinkHwnd (PWND Wnd, HWND hWndPrev)
 
VOID FASTCALL IntProcessOwnerSwap (PWND Wnd, PWND WndNewOwner, PWND WndOldOwner)
 
static HWND FASTCALL IntSetOwner (HWND hWnd, HWND hWndNewOwner)
 
PWND FASTCALL co_IntSetParent (PWND Wnd, PWND WndNewParent)
 
HWND FASTCALL co_UserSetParent (HWND hWndChild, HWND hWndNewParent)
 
VOID FASTCALL IntUnlinkWindow (PWND Wnd)
 
BOOL FASTCALL IntGrowHwndList (PWINDOWLIST *ppwl)
 
PWINDOWLIST FASTCALL IntPopulateHwndList (PWINDOWLIST pwl, PWND pwnd, DWORD dwFlags)
 
PWINDOWLIST FASTCALL IntBuildHwndList (PWND pwnd, DWORD dwFlags, PTHREADINFO pti)
 
VOID FASTCALL IntFreeHwndList (PWINDOWLIST pwlTarget)
 
NTSTATUS NTAPI NtUserBuildHwndList (HDESK hDesktop, HWND hwndParent, BOOLEAN bChildren, ULONG dwThreadId, ULONG cHwnd, HWND *phwndList, ULONG *pcHwndNeeded)
 
static void IntSendParentNotify (PWND pWindow, UINT msg)
 
void FASTCALL IntFixWindowCoordinates (CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
 
PWND FASTCALL IntCreateWindow (CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated, DWORD dwVer)
 
PWND FASTCALL co_UserCreateWindowEx (CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer, DWORD dwVer)
 
NTSTATUS NTAPI ProbeAndCaptureLargeString (OUT PLARGE_STRING plstrSafe, IN PLARGE_STRING plstrUnsafe)
 
HWND NTAPI NtUserCreateWindowEx (DWORD dwExStyle, PLARGE_STRING plstrClassName, PLARGE_STRING plstrClsVersion, PLARGE_STRING plstrWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam, DWORD dwFlags, PVOID acbiBuffer)
 
VOID FASTCALL IntDestroyOwnedWindows (PWND Window)
 
BOOLEAN co_UserDestroyWindow (PVOID Object)
 
BOOLEAN APIENTRY NtUserDestroyWindow (HWND Wnd)
 
HWND FASTCALL IntFindWindow (PWND Parent, PWND ChildAfter, RTL_ATOM ClassAtom, PUNICODE_STRING WindowName)
 
HWND APIENTRY NtUserFindWindowEx (HWND hwndParent, HWND hwndChildAfter, PUNICODE_STRING ucClassName, PUNICODE_STRING ucWindowName, DWORD dwUnknown)
 
PWND FASTCALL UserGetAncestor (_In_ PWND pWnd, _In_ UINT uType)
 
HWND APIENTRY NtUserGetAncestor (_In_ HWND hWnd, _In_ UINT uType)
 
BOOL APIENTRY NtUserGetComboBoxInfo (HWND hWnd, PCOMBOBOXINFO pcbi)
 
DWORD APIENTRY NtUserGetListBoxInfo (HWND hWnd)
 
HWND APIENTRY NtUserSetParent (HWND hWndChild, HWND hWndNewParent)
 
HWND FASTCALL UserGetShellWindow (VOID)
 
BOOL APIENTRY NtUserSetShellWindowEx (HWND hwndShell, HWND hwndListView)
 
static BOOL FASTCALL IntCheckFrameEdge (ULONG Style, ULONG ExStyle)
 
static LONG_PTR co_IntSetWindowLongPtr (HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
 
LONG FASTCALL co_UserSetWindowLong (HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 
LONG_PTR FASTCALL co_UserSetWindowLongPtr (HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi)
 
LONG APIENTRY NtUserSetWindowLong (HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 
DWORD APIENTRY NtUserAlterWindowStyle (HWND hWnd, DWORD Index, LONG NewValue)
 
WORD APIENTRY NtUserSetWindowWord (HWND hWnd, INT Index, WORD NewValue)
 
DWORD_PTR APIENTRY NtUserQueryWindow (HWND hWnd, DWORD Index)
 
UINT APIENTRY NtUserRegisterWindowMessage (PUNICODE_STRING MessageNameUnsafe)
 
BOOL APIENTRY NtUserSetWindowFNID (HWND hWnd, WORD fnID)
 
BOOL APIENTRY DefSetText (PWND Wnd, PCWSTR WindowText)
 
BOOL APIENTRY NtUserDefSetText (HWND hWnd, PLARGE_STRING WindowText)
 
INT APIENTRY NtUserInternalGetWindowText (HWND hWnd, LPWSTR lpString, INT nMaxCount)
 
BOOL FASTCALL IntShowOwnedPopups (PWND OwnerWnd, BOOL fShow)
 

Variables

INT gNestedWindowLimit = 50
 
PWINDOWLIST gpwlList = NULL
 
PWINDOWLIST gpwlCache = NULL
 

Macro Definition Documentation

◆ CBF_BUTTONDOWN

#define CBF_BUTTONDOWN   0x0002

Definition at line 3481 of file window.c.

◆ GROW_COUNT

#define GROW_COUNT   8

◆ GWLP_CONSOLE_LEADER_PID

#define GWLP_CONSOLE_LEADER_PID   0

◆ GWLP_CONSOLE_LEADER_TID

#define GWLP_CONSOLE_LEADER_TID   4

◆ INITIAL_COUNT

#define INITIAL_COUNT   32

◆ IS_DEFAULT

#define IS_DEFAULT (   x)    ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)

Typedef Documentation

◆ LPHEADCOMBO

◆ PWND2CBOX

◆ PWND2LB

typedef struct _WND2LB * PWND2LB

◆ WND2CBOX

◆ WND2LB

Function Documentation

◆ co_IntSetParent()

PWND FASTCALL co_IntSetParent ( PWND  Wnd,
PWND  WndNewParent 
)

Definition at line 1159 of file window.c.

1160{
1161 PWND WndOldParent, pWndExam;
1162 BOOL WasVisible;
1163 POINT pt;
1164 int swFlags = SWP_NOSIZE|SWP_NOZORDER;
1165
1166 ASSERT(Wnd);
1167 ASSERT(WndNewParent);
1168 ASSERT_REFS_CO(Wnd);
1169 ASSERT_REFS_CO(WndNewParent);
1170
1171 if (Wnd == Wnd->head.rpdesk->spwndMessage)
1172 {
1174 return NULL;
1175 }
1176
1177 /* Some applications try to set a child as a parent */
1178 if (IntIsChildWindow(Wnd, WndNewParent))
1179 {
1180 TRACE("IntSetParent try to set a child as a parent.\n");
1182 return NULL;
1183 }
1184
1185 pWndExam = WndNewParent; // Load parent Window to examine.
1186 // Now test for set parent to parent hit.
1187 while (pWndExam)
1188 {
1189 if (Wnd == pWndExam)
1190 {
1191 TRACE("IntSetParent Failed Test for set parent to parent!\n");
1193 return NULL;
1194 }
1195 pWndExam = pWndExam->spwndParent;
1196 }
1197
1198 /*
1199 * Windows hides the window first, then shows it again
1200 * including the WM_SHOWWINDOW messages and all
1201 */
1202 WasVisible = co_WinPosShowWindow(Wnd, SW_HIDE);
1203
1204 /* Window must belong to current process */
1205 if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process())
1206 {
1207 ERR("IntSetParent Window must belong to current process!\n");
1208 return NULL;
1209 }
1210
1211 WndOldParent = Wnd->spwndParent;
1212
1213 if ( WndOldParent &&
1214 WndOldParent->ExStyle & WS_EX_LAYOUTRTL)
1215 pt.x = Wnd->rcWindow.right;
1216 else
1217 pt.x = Wnd->rcWindow.left;
1218 pt.y = Wnd->rcWindow.top;
1219
1220 IntScreenToClient(WndOldParent, &pt);
1221
1222 if (WndOldParent) UserReferenceObject(WndOldParent); /* Caller must deref */
1223
1224 /* Even if WndNewParent == WndOldParent continue because the
1225 * child window (Wnd) should be moved to the top of the z-order */
1226
1227 /* Unlink the window from the siblings list */
1228 IntUnlinkWindow(Wnd);
1229 Wnd->ExStyle2 &= ~WS_EX2_LINKED;
1230
1231 /* Set the new parent */
1232 WndSetParent(Wnd, WndNewParent);
1233
1234 if (Wnd->style & WS_CHILD &&
1235 Wnd->spwndOwner &&
1236 Wnd->spwndOwner->ExStyle & WS_EX_TOPMOST)
1237 {
1238 ERR("SetParent Top Most from Pop up\n");
1239 Wnd->ExStyle |= WS_EX_TOPMOST;
1240 }
1241
1242 /* Link the window with its new siblings */
1243 IntLinkHwnd(Wnd,
1244 ((0 == (Wnd->ExStyle & WS_EX_TOPMOST) &&
1245 UserIsDesktopWindow(WndNewParent)) ? HWND_TOP : HWND_TOPMOST));
1246
1247 if ( WndNewParent == co_GetDesktopWindow(Wnd) &&
1248 !(Wnd->style & WS_CLIPSIBLINGS) )
1249 {
1250 Wnd->style |= WS_CLIPSIBLINGS;
1251 DceResetActiveDCEs(Wnd);
1252 }
1253
1254 /* if parent belongs to a different thread and the window isn't */
1255 /* top-level, attach the two threads */
1256 if ((Wnd->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1257 {
1258 if ( Wnd->spwndParent != co_GetDesktopWindow(Wnd))
1259 {
1260 if (WndOldParent && (Wnd->head.pti != WndOldParent->head.pti))
1261 {
1262 //ERR("SetParent Old out.\n");
1263 UserAttachThreadInput(Wnd->head.pti, WndOldParent->head.pti, FALSE);
1264 }
1265 }
1266 if ( WndNewParent != co_GetDesktopWindow(Wnd))
1267 {
1268 if (Wnd->head.pti != WndNewParent->head.pti)
1269 {
1270 //ERR("SetParent New in.\n");
1271 UserAttachThreadInput(Wnd->head.pti, WndNewParent->head.pti, TRUE);
1272 }
1273 }
1274 }
1275
1276 if (UserIsMessageWindow(WndOldParent) || UserIsMessageWindow(WndNewParent))
1277 swFlags |= SWP_NOACTIVATE;
1278
1279 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE, Wnd ,OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
1280 /*
1281 * SetParent additionally needs to make hwnd the top window
1282 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1283 * WM_WINDOWPOSCHANGED notification messages.
1284 */
1285 //ERR("IntSetParent SetWindowPos 1\n");
1287 (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST),
1288 pt.x, pt.y, 0, 0, swFlags);
1289 //ERR("IntSetParent SetWindowPos 2 X %d Y %d\n",pt.x, pt.y);
1290 if (WasVisible) co_WinPosShowWindow(Wnd, SW_SHOWNORMAL);
1291
1292 return WndOldParent;
1293}
#define ERR(fmt,...)
Definition: precomp.h:57
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:816
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WEF_SETBYWNDPTI
Definition: ntuser.h:236
#define ASSERT(a)
Definition: mode.c:44
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1792
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:213
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2622
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define TRACE(s)
Definition: solgame.cpp:4
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
Definition: ntuser.h:694
DWORD ExStyle
Definition: ntuser.h:704
DWORD ExStyle2
Definition: ntuser.h:745
struct _WND * spwndOwner
Definition: ntuser.h:715
THRDESKHEAD head
Definition: ntuser.h:695
DWORD style
Definition: ntuser.h:706
RECT rcWindow
Definition: ntuser.h:716
struct _WND * spwndParent
Definition: ntuser.h:713
LONG right
Definition: windef.h:108
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1383
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:197
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:178
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1357
BOOL FASTCALL IntIsChildWindow(PWND Parent, PWND BaseWindow)
Definition: window.c:930
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:986
static VOID WndSetParent(_Inout_ PWND pwnd, _In_opt_ PWND pwndParent)
Definition: window.h:157
#define OBJID_WINDOW
Definition: winable.h:15
#define CHILDID_SELF
Definition: winable.h:14
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define SW_HIDE
Definition: winuser.h:779
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define HWND_TOPMOST
Definition: winuser.h:1219
#define SWP_NOSIZE
Definition: winuser.h:1256
#define HWND_TOP
Definition: winuser.h:1218
#define SWP_NOZORDER
Definition: winuser.h:1258

Referenced by co_UserSetParent().

◆ co_IntSetWindowLongPtr()

static LONG_PTR co_IntSetWindowLongPtr ( HWND  hWnd,
DWORD  Index,
LONG_PTR  NewValue,
BOOL  Ansi,
ULONG  Size,
BOOL  bAlter 
)
static

Definition at line 3844 of file window.c.

3845{
3847 PWINSTATION_OBJECT WindowStation;
3848 LONG_PTR OldValue;
3850
3852 {
3853 return 0;
3854 }
3855
3856 if ((INT)Index >= 0)
3857 {
3858 if ((Index + Size) > Window->cbwndExtra)
3859 {
3861 return 0;
3862 }
3863
3864 PVOID Address = (PUCHAR)(&Window[1]) + Index;
3865
3866#ifdef _WIN64
3867 if (Size == sizeof(LONG))
3868 {
3869 OldValue = ReadUnalignedU32(Address);
3870 WriteUnalignedU32(Address, NewValue);
3871 }
3872 else
3873#endif
3874 {
3875 OldValue = ReadUnalignedUlongPtr(Address);
3876 /*
3877 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3878 {
3879 OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi);
3880 if (!OldValue) return 0;
3881 }
3882 */
3884 }
3885
3886 }
3887 else
3888 {
3889#ifdef _WIN64
3890 if (Size == sizeof(LONG))
3891 {
3892 if ((Index != GWL_STYLE) &&
3893 (Index != GWL_EXSTYLE) &&
3894 (Index != GWL_ID) &&
3895 (Index != GWL_USERDATA))
3896 {
3897 ERR("NtUserSetWindowLong(): Index requires pointer size: %lu\n", Index);
3899 return 0;
3900 }
3901 }
3902#endif
3903
3904 switch (Index)
3905 {
3906 case GWL_EXSTYLE: // LONG
3907 OldValue = (LONG) Window->ExStyle;
3908 Style.styleOld = OldValue;
3909 Style.styleNew = NewValue;
3910
3911 co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style);
3912
3913 /*
3914 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3915 */
3916 WindowStation = Window->head.pti->rpdesk->rpwinstaParent;
3917 if(WindowStation)
3918 {
3919 if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
3920 Style.styleNew &= ~WS_EX_TOPMOST;
3921 }
3922 /* WS_EX_WINDOWEDGE depends on some other styles */
3923 if (IntCheckFrameEdge(Window->style, NewValue))
3924 Style.styleNew |= WS_EX_WINDOWEDGE;
3925 else
3926 Style.styleNew &= ~WS_EX_WINDOWEDGE;
3927
3928 if (!(Window->ExStyle & WS_EX_LAYERED))
3929 {
3931 }
3932
3933 Window->ExStyle = (DWORD)Style.styleNew;
3934
3935 co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
3936 break;
3937
3938 case GWL_STYLE: // LONG
3939 OldValue = (LONG) Window->style;
3940 Style.styleOld = OldValue;
3941 Style.styleNew = NewValue;
3942
3943 if (!bAlter)
3944 co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
3945
3946 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3947 if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS;
3948 /* WS_MINIMIZE can't be reset */
3949 if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE;
3950 /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
3951 if (IntCheckFrameEdge(NewValue, Window->ExStyle))
3952 Window->ExStyle |= WS_EX_WINDOWEDGE;
3953 else
3954 Window->ExStyle &= ~WS_EX_WINDOWEDGE;
3955
3956 if ((OldValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3957 {
3958 if ((NewValue & (WS_CHILD | WS_POPUP)) != WS_CHILD)
3959 {
3961 ERR("IDMenu going null! %d\n",Window->IDMenu);
3962 Window->IDMenu = 0; // Window->spmenu = 0;
3963 }
3964 }
3965 else
3966 {
3967 if ((NewValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3968 {
3969 PMENU pMenu = UserGetMenuObject(UlongToHandle(Window->IDMenu));
3970 Window->state &= ~WNDS_HASMENU;
3971 if (pMenu)
3972 {
3973 ERR("IDMenu released 0x%p\n",pMenu);
3974 // ROS may not hold a lock after setting menu to window. But it should!
3975 //IntReleaseMenuObject(pMenu);
3976 }
3977 }
3978 }
3979
3980 if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE)
3981 {
3982 if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--;
3983 if (Style.styleNew & WS_VISIBLE) Window->head.pti->cVisWindows++;
3985 }
3986 Window->style = (DWORD)Style.styleNew;
3987
3988 if (!bAlter)
3989 co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
3990 break;
3991
3992 case GWLP_WNDPROC: // LONG_PTR
3993 {
3994 if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
3995 Window->fnid & FNID_FREED)
3996 {
3998 return 0;
3999 }
4000 OldValue = (LONG_PTR)IntSetWindowProc(Window,
4001 (WNDPROC)NewValue,
4002 Ansi);
4003 break;
4004 }
4005
4006 case GWLP_HINSTANCE: // LONG_PTR
4007 OldValue = (LONG_PTR) Window->hModule;
4008 Window->hModule = (HINSTANCE) NewValue;
4009 break;
4010
4011 case GWLP_HWNDPARENT: // LONG_PTR
4012 Parent = Window->spwndParent;
4014 OldValue = (LONG_PTR)IntSetOwner(UserHMGetHandle(Window), (HWND)NewValue);
4015 else
4016 OldValue = (LONG_PTR)co_UserSetParent(UserHMGetHandle(Window), (HWND)NewValue);
4017 break;
4018
4019 case GWLP_ID: // LONG
4020 OldValue = (LONG) Window->IDMenu;
4021 Window->IDMenu = (UINT) NewValue;
4022 break;
4023
4024 case GWLP_USERDATA: // LONG or LONG_PTR
4025 OldValue = Window->dwUserData;
4026 Window->dwUserData = NewValue;
4027 break;
4028
4029 default:
4030 ERR("NtUserSetWindowLong(): Unsupported index %lu\n", Index);
4032 OldValue = 0;
4033 break;
4034 }
4035 }
4036
4037 return OldValue;
4038}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
const DWORD Style
Definition: appswitch.c:72
HWND hWnd
Definition: settings.c:17
#define UlongToHandle(ul)
Definition: basetsd.h:91
HANDLE HWND
Definition: compat.h:19
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define FNID_FREED
Definition: ntuser.h:900
BOOL FASTCALL SetLayeredStatus(PWND pWnd, BYTE set)
Definition: layered.c:34
if(dx< 0)
Definition: linetemp.h:194
LONG_PTR LPARAM
Definition: minwindef.h:175
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
static WCHAR Address[46]
Definition: ping.c:68
Definition: window.c:28
HANDLE ShellListView
Definition: winsta.h:44
HANDLE ShellWindow
Definition: winsta.h:43
#define LONG_PTR
Definition: treelist.c:79
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT
Definition: typedefs.h:58
unsigned char * PUCHAR
Definition: typedefs.h:53
#define WriteUnalignedUlongPtr
Definition: unaligned.h:142
__forceinline unsigned long ReadUnalignedU32(const unsigned long *p)
Definition: unaligned.h:76
#define ReadUnalignedUlongPtr
Definition: unaligned.h:141
__forceinline void WriteUnalignedU32(unsigned long *p, unsigned long val)
Definition: unaligned.h:111
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1391
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1495
HWND FASTCALL co_UserSetParent(HWND hWndChild, HWND hWndNewParent)
Definition: window.c:1297
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124
static BOOL FASTCALL IntCheckFrameEdge(ULONG Style, ULONG ExStyle)
Definition: window.c:3833
static WNDPROC IntSetWindowProc(PWND pWnd, WNDPROC NewWndProc, BOOL Ansi)
Definition: window.c:843
static HWND FASTCALL IntSetOwner(HWND hWnd, HWND hWndNewOwner)
Definition: window.c:1118
#define ERROR_INVALID_INDEX
Definition: winerror.h:1239
#define GWL_USERDATA
Definition: winuser.h:872
#define GWL_ID
Definition: winuser.h:870
#define GWLP_HINSTANCE
Definition: winuser.h:867
#define GWLP_HWNDPARENT
Definition: winuser.h:869
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define WS_EX_LAYERED
Definition: winuser.h:389
#define GWLP_ID
Definition: winuser.h:871
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3008
#define GWL_STYLE
Definition: winuser.h:863
#define GWL_EXSTYLE
Definition: winuser.h:862

Referenced by co_UserSetWindowLong(), co_UserSetWindowLongPtr(), NtUserAlterWindowStyle(), and NtUserSetWindowLong().

◆ co_UserCreateWindowEx()

PWND FASTCALL co_UserCreateWindowEx ( CREATESTRUCTW Cs,
PUNICODE_STRING  ClassName,
PLARGE_STRING  WindowName,
PVOID  acbiBuffer,
DWORD  dwVer 
)

Definition at line 2183 of file window.c.

2188{
2189 ULONG style;
2190 PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
2191 HWND hWnd, hWndParent, hWndOwner, hwndInsertAfter;
2192 PWINSTATION_OBJECT WinSta;
2193 PCLS Class = NULL;
2194 SIZE Size;
2195 POINT MaxSize, MaxPos, MinTrack, MaxTrack;
2196 CBT_CREATEWNDW * pCbtCreate;
2198 USER_REFERENCE_ENTRY ParentRef, Ref;
2199 PTHREADINFO pti;
2200 DWORD dwShowMode = SW_SHOW;
2201 CREATESTRUCTW *pCsw = NULL;
2202 PVOID pszClass = NULL, pszName = NULL;
2203 PWND ret = NULL;
2204
2205 /* Get the current window station and reference it */
2206 pti = GetW32ThreadInfo();
2207 if (pti == NULL || pti->rpdesk == NULL)
2208 {
2209 ERR("Thread is not attached to a desktop! Cannot create window (%wZ)\n", ClassName);
2210 return NULL; // There is nothing to cleanup.
2211 }
2212 WinSta = pti->rpdesk->rpwinstaParent;
2214
2215 pCsw = NULL;
2216 pCbtCreate = NULL;
2217
2218 /* Get the class and reference it */
2219 Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
2220 if(!Class)
2221 {
2223 ERR("Failed to find class %wZ\n", ClassName);
2224 goto cleanup;
2225 }
2226
2227 /* Now find the parent and the owner window */
2228 hWndParent = UserHMGetHandle(pti->rpdesk->pDeskInfo->spwnd);
2229 hWndOwner = NULL;
2230
2231 if (Cs->hwndParent == HWND_MESSAGE)
2232 {
2233 Cs->hwndParent = hWndParent = UserHMGetHandle(pti->rpdesk->spwndMessage);
2234 }
2235 else if (Cs->hwndParent)
2236 {
2237 if ((Cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
2238 hWndOwner = Cs->hwndParent;
2239 else
2240 hWndParent = Cs->hwndParent;
2241 }
2242 else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2243 {
2244 ERR("Cannot create a child window (%wZ) without a parent\n", ClassName);
2246 goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
2247 }
2249 (IS_INTRESOURCE(Cs->lpszClass) ||
2250 Cs->lpszClass != (LPCWSTR)MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]) ||
2251 _wcsicmp(Cs->lpszClass, L"Message") != 0))
2252 {
2253 if (pti->ppi->dwLayout & LAYOUT_RTL)
2254 {
2256 }
2257 }
2258
2259 ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
2260 OwnerWindow = hWndOwner ? UserGetWindowObject(hWndOwner): NULL;
2261
2262 if (hWndParent && !ParentWindow)
2263 {
2264 ERR("Got invalid parent window handle for %wZ\n", ClassName);
2265 goto cleanup;
2266 }
2267 else if (hWndOwner && !OwnerWindow)
2268 {
2269 ERR("Got invalid owner window handle for %wZ\n", ClassName);
2270 ParentWindow = NULL;
2271 goto cleanup;
2272 }
2273
2274 if(OwnerWindow)
2275 {
2276 if (IntIsDesktopWindow(OwnerWindow)) OwnerWindow = NULL;
2277 else if (ParentWindow && !IntIsDesktopWindow(ParentWindow))
2278 {
2279 ERR("an owned window must be created as top-level\n");
2281 goto cleanup;
2282 }
2283 else /* owner must be a top-level window */
2284 {
2285 while ((OwnerWindow->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !IntIsDesktopWindow(OwnerWindow->spwndParent))
2286 OwnerWindow = OwnerWindow->spwndParent;
2287 }
2288 }
2289
2290 /* Fix the position and the size of the window */
2291 if (ParentWindow)
2292 {
2293 UserRefObjectCo(ParentWindow, &ParentRef);
2294 IntFixWindowCoordinates(Cs, ParentWindow, &dwShowMode);
2295 }
2296
2297 /* Allocate and initialize the new window */
2299 WindowName,
2300 Class,
2301 ParentWindow,
2302 OwnerWindow,
2303 acbiBuffer,
2304 NULL,
2305 dwVer );
2306 if(!Window)
2307 {
2308 ERR("IntCreateWindow(%wZ) failed\n", ClassName);
2309 goto cleanup;
2310 }
2311
2313 hwndInsertAfter = HWND_TOP;
2314
2315 UserRefObjectCo(Window, &Ref);
2317 ObDereferenceObject(WinSta);
2318
2319 /* NCCREATE, WM_NCCALCSIZE and Hooks need the original values */
2320 Cs->lpszName = (LPCWSTR) WindowName;
2321 Cs->lpszClass = (LPCWSTR) ClassName;
2322
2324 if ( ISITHOOKED(WH_CBT) || (pti->rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)) )
2325 {
2326 // Allocate the calling structures Justin Case this goes Global.
2329 if (!pCsw || !pCbtCreate)
2330 {
2331 ERR("UserHeapAlloc() failed!\n");
2332 goto cleanup;
2333 }
2334
2335 if (!IntMsgCreateStructW( Window, pCsw, Cs, &pszClass, &pszName ) )
2336 {
2337 ERR("IntMsgCreateStructW() failed!\n");
2338 goto cleanup;
2339 }
2340
2341 pCbtCreate->lpcs = pCsw;
2342 pCbtCreate->hwndInsertAfter = hwndInsertAfter;
2343
2346 if (Result != 0)
2347 {
2348 ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
2349 goto cleanup;
2350 }
2351 // Write back changes.
2352 Cs->cx = pCsw->cx;
2353 Cs->cy = pCsw->cy;
2354 Cs->x = pCsw->x;
2355 Cs->y = pCsw->y;
2356 hwndInsertAfter = pCbtCreate->hwndInsertAfter;
2357 }
2358
2359 if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2360 {
2361 if (ParentWindow != co_GetDesktopWindow(Window))
2362 {
2363 Cs->x += ParentWindow->rcClient.left;
2364 Cs->y += ParentWindow->rcClient.top;
2365 }
2366 }
2367
2368 /* Send the WM_GETMINMAXINFO message */
2369 Size.cx = Cs->cx;
2370 Size.cy = Cs->cy;
2371
2372 if ((Cs->style & WS_THICKFRAME) || !(Cs->style & (WS_POPUP | WS_CHILD)))
2373 {
2374 co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack, &MaxTrack);
2375 if (Size.cx > MaxTrack.x) Size.cx = MaxTrack.x;
2376 if (Size.cy > MaxTrack.y) Size.cy = MaxTrack.y;
2377 if (Size.cx < MinTrack.x) Size.cx = MinTrack.x;
2378 if (Size.cy < MinTrack.y) Size.cy = MinTrack.y;
2379 }
2380
2381 Window->rcWindow.left = Cs->x;
2382 Window->rcWindow.top = Cs->y;
2383 Window->rcWindow.right = Cs->x + Size.cx;
2384 Window->rcWindow.bottom = Cs->y + Size.cy;
2385 /*
2386 if (0 != (Window->style & WS_CHILD) && ParentWindow)
2387 {
2388 ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2389 RECTL_vOffsetRect(&Window->rcWindow,
2390 ParentWindow->rcClient.left,
2391 ParentWindow->rcClient.top);
2392 }
2393 */
2394 /* correct child window coordinates if mirroring on parent is enabled */
2395 if (ParentWindow != NULL)
2396 {
2397 if ( ((Cs->style & WS_CHILD) == WS_CHILD) &&
2398 ((ParentWindow->ExStyle & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL))
2399 {
2400 Window->rcWindow.right = ParentWindow->rcClient.right - (Window->rcWindow.left - ParentWindow->rcClient.left);
2401 Window->rcWindow.left = Window->rcWindow.right - Size.cx;
2402 }
2403 }
2404
2405 Window->rcClient = Window->rcWindow;
2406
2407 if (Window->spwndNext || Window->spwndPrev)
2408 {
2409 ERR("Window 0x%p has been linked too early!\n", Window);
2410 }
2411
2412 if (!(Window->state2 & WNDS2_WIN31COMPAT))
2413 {
2414 if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN))
2415 Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
2416 }
2417
2418 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2419 {
2421 {
2422 if (pti != ParentWindow->head.pti)
2423 {
2424 //ERR("CreateWindow Parent in.\n");
2425 UserAttachThreadInput(pti, ParentWindow->head.pti, TRUE);
2426 }
2427 }
2428 }
2429
2430 /* Send the NCCREATE message */
2432 if (!Result)
2433 {
2434 ERR("co_UserCreateWindowEx(%wZ): NCCREATE message failed\n", ClassName);
2435 goto cleanup;
2436 }
2437
2438 /* Link the window */
2439 if (ParentWindow != NULL)
2440 {
2441 /* Link the window into the siblings list */
2442 if ((Cs->style & (WS_CHILD | WS_MAXIMIZE)) == WS_CHILD)
2444 else
2445 IntLinkHwnd(Window, hwndInsertAfter);
2446 }
2447
2448 /* Create the IME window for pWnd */
2450 {
2451 PWND pwndDefaultIme = co_IntCreateDefaultImeWindow(Window, Window->hModule);
2452 UserAssignmentLock((PVOID*)&pti->spwndDefaultIme, pwndDefaultIme);
2453
2454 if (pwndDefaultIme)
2455 {
2456 HWND hImeWnd;
2458 UserRefObjectCo(pwndDefaultIme, &Ref);
2459
2460 hImeWnd = UserHMGetHandle(pwndDefaultIme);
2461
2463
2464 if (pti->pClientInfo->CI_flags & CI_IMMACTIVATE)
2465 {
2466 HKL hKL = pti->KeyboardLayout->hkl;
2468 pti->pClientInfo->CI_flags &= ~CI_IMMACTIVATE;
2469 }
2470
2471 UserDerefObjectCo(pwndDefaultIme);
2472 }
2473 }
2474
2475 /* Send the WM_NCCALCSIZE message */
2476 {
2477 // RECT rc;
2478 MaxPos.x = Window->rcWindow.left;
2479 MaxPos.y = Window->rcWindow.top;
2480
2481 Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
2482 //rc = Window->rcWindow;
2483 //Result = co_IntSendMessageNoWait(UserHMGetHandle(Window), WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2484 //Window->rcClient = rc;
2485
2486 RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
2487 MaxPos.y - Window->rcWindow.top);
2488 }
2489
2490 /* Send the WM_CREATE message. */
2492 if (Result == (LRESULT)-1)
2493 {
2494 ERR("co_UserCreateWindowEx(%wZ): WM_CREATE message failed\n", ClassName);
2495 goto cleanup;
2496 }
2497
2498 /* Send the EVENT_OBJECT_CREATE event */
2499 IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2500
2501 /* By setting the flag below it can be examined to determine if the window
2502 was created successfully and a valid pwnd was passed back to caller since
2503 from here the function has to succeed. */
2505
2506 /* Send the WM_SIZE and WM_MOVE messages. */
2507 if (!(Window->state & WNDS_SENDSIZEMOVEMSGS))
2508 {
2510 }
2511
2512 /* Show or maybe minimize or maximize the window. */
2513
2515 if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2516 {
2517 RECTL NewPos;
2518 UINT SwFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
2519
2520 SwFlag = co_WinPosMinMaximize(Window, SwFlag, &NewPos);
2521 SwFlag |= SWP_NOZORDER|SWP_FRAMECHANGED; /* Frame always gets changed */
2522 if (!(style & WS_VISIBLE) || (style & WS_CHILD) || UserGetActiveWindow() ||
2523 (Window->ExStyle & WS_EX_NOACTIVATE))
2524 {
2525 SwFlag |= SWP_NOACTIVATE;
2526 }
2527 co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
2528 NewPos.right, NewPos.bottom, SwFlag);
2529 }
2530
2531 /* Send the WM_PARENTNOTIFY message */
2533
2534 /* Notify the shell that a new window was created */
2535 if (Window->spwndOwner == NULL ||
2536 !(Window->spwndOwner->style & WS_VISIBLE) ||
2537 (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW))
2538 {
2539 if (UserIsDesktopWindow(Window->spwndParent) &&
2540 (Window->style & WS_VISIBLE) &&
2541 (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
2542 (Window->ExStyle & WS_EX_APPWINDOW)))
2543 {
2545 }
2546 }
2547
2548 /* Initialize and show the window's scrollbars */
2549 if (Window->style & WS_VSCROLL)
2550 {
2552 }
2553 if (Window->style & WS_HSCROLL)
2554 {
2556 }
2557
2558 /* Show the new window */
2559 if (Cs->style & WS_VISIBLE)
2560 {
2561 if (Window->style & WS_MAXIMIZE)
2562 dwShowMode = SW_SHOW;
2563 else if (Window->style & WS_MINIMIZE)
2564 dwShowMode = SW_SHOWMINIMIZED;
2565
2566 co_WinPosShowWindow(Window, dwShowMode);
2567
2568 if (Window->ExStyle & WS_EX_MDICHILD)
2569 {
2570 ASSERT(ParentWindow);
2571 if(!ParentWindow)
2572 goto cleanup;
2574 /* ShowWindow won't activate child windows */
2576 }
2577 }
2578
2579 if (Class->atomClassName == gaGuiConsoleWndClass)
2580 {
2581 /* Count only console windows manually */
2583 }
2584
2585 /* Set the hotkey */
2586 if (!(Window->style & (WS_POPUP | WS_CHILD)) || (Window->ExStyle & WS_EX_APPWINDOW))
2587 {
2588 if (pti->ppi->dwHotkey)
2589 {
2591 pti->ppi->dwHotkey = 0; /* Only the first suitable window gets the hotkey */
2592 }
2593 }
2594
2595 TRACE("co_UserCreateWindowEx(%wZ): Created window %p\n", ClassName, hWnd);
2596 ret = Window;
2597
2598cleanup:
2599 if (!ret)
2600 {
2601 TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2602 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2603 if (Window)
2605 else if (Class)
2607 }
2608
2609 if (pCsw) ExFreePoolWithTag(pCsw, TAG_HOOK);
2610 if (pCbtCreate) ExFreePoolWithTag(pCbtCreate, TAG_HOOK);
2611 if (pszName) UserHeapFree(pszName);
2612 if (pszClass) UserHeapFree(pszClass);
2613
2614 if (Window)
2615 {
2617 }
2618 if (ParentWindow) UserDerefObjectCo(ParentWindow);
2619
2620 // See CORE-13717, not setting error on success.
2621 if (ret)
2623
2624 return ret;
2625}
Arabic default style
Definition: afstyles.h:94
#define ERROR_SUCCESS
Definition: deptool.c:10
static void cleanup(void)
Definition: main.c:1335
#define IS_INTRESOURCE(x)
Definition: loader.c:613
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1431
VOID FASTCALL co_IntUserManualGuiCheck(BOOL Create)
Definition: guicheck.c:77
#define ISITHOOKED(HookId)
Definition: hook.h:6
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
PSERVERINFO gpsi
Definition: imm.c:18
#define IMS_LOADTHREADLAYOUT
Definition: imm32_undoc.h:54
#define IMS_ACTIVATELAYOUT
Definition: imm32_undoc.h:48
#define WM_IME_SYSTEM
Definition: imm32_undoc.h:32
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:649
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:807
#define CI_IMMACTIVATE
Definition: ntuser.h:306
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:670
#define IS_IMM_MODE()
Definition: ntuser.h:1212
#define ICLS_DESKTOP
Definition: ntuser.h:929
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:609
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
UINT_PTR HKL
Definition: msctf.idl:125
#define KernelMode
Definition: asm.h:38
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1102
PWND FASTCALL co_IntCreateDefaultImeWindow(_In_ PWND pwndTarget, _In_ HINSTANCE hInst)
Definition: ime.c:2055
BOOL FASTCALL IntWantImeWindow(_In_ PWND pwndTarget)
Definition: ime.c:2015
UINT FASTCALL co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT *NewPos)
Definition: winpos.c:2437
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2388
UINT FASTCALL co_WinPosGetMinMaxInfo(PWND Window, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
Definition: winpos.c:940
void FASTCALL co_WinPosSendSizeMove(PWND Wnd)
Definition: winpos.c:2403
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:43
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:381
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_THICKFRAME
Definition: pedump.c:630
DWORD FASTCALL co_UserShowScrollBar(PWND, int, BOOL, BOOL)
Definition: scrollbar.c:863
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
Definition: ntuser.h:566
DWORD dwHotkey
Definition: win32.h:270
DWORD dwLayout
Definition: win32.h:280
PPROCESSINFO ppi
Definition: win32.h:88
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
struct tagKL * KeyboardLayout
Definition: win32.h:90
struct _DESKTOP * rpdesk
Definition: win32.h:92
struct _WND * spwndDefaultIme
Definition: win32.h:131
Definition: object.h:4
LPCREATESTRUCTW lpcs
Definition: winuser.h:3077
HWND hwndInsertAfter
Definition: winuser.h:3078
LPCWSTR lpszClass
Definition: winuser.h:3067
LPCWSTR lpszName
Definition: winuser.h:3066
HINSTANCE hInstance
Definition: winuser.h:3058
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1060
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:21
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
BOOL FASTCALL IntMsgCreateStructW(PWND, CREATESTRUCTW *, CREATESTRUCTW *, PVOID *, PVOID *)
Definition: message.c:646
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:820
PCLS IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread)
Definition: class.c:1450
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1706
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:839
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
#define TAG_HOOK
Definition: tags.h:5
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:145
PWND FASTCALL IntCreateWindow(CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated, DWORD dwVer)
Definition: window.c:1811
void FASTCALL IntFixWindowCoordinates(CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
Definition: window.c:1717
BOOL FASTCALL IntIsTopLevelWindow(PWND pWnd)
Definition: window.c:361
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2873
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1695
#define IntIsDesktopWindow(WndObj)
Definition: window.h:25
#define MAKEINTATOM(i)
Definition: winbase.h:1220
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:1232
#define ERROR_CANNOT_FIND_WND_CLASS
Definition: winerror.h:1233
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define HWND_MESSAGE
Definition: winuser.h:1221
#define SWP_FRAMECHANGED
Definition: winuser.h:1251
#define WM_SETHOTKEY
Definition: winuser.h:1680
#define WM_CREATE
Definition: winuser.h:1636
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define SW_MINIMIZE
Definition: winuser.h:787
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1266
#define SB_VERT
Definition: winuser.h:553
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WS_EX_NOACTIVATE
Definition: winuser.h:395
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define WH_CBT
Definition: winuser.h:35
#define HCBT_CREATEWND
Definition: winuser.h:58
#define WM_NCCREATE
Definition: winuser.h:1711
#define WM_MDIREFRESHMENU
Definition: winuser.h:1854
#define SW_SHOWMINIMIZED
Definition: winuser.h:782
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define SW_SHOW
Definition: winuser.h:786
#define SW_MAXIMIZE
Definition: winuser.h:783
#define CS_PARENTDC
Definition: winuser.h:664
#define HWND_BOTTOM
Definition: winuser.h:1216
#define SB_HORZ
Definition: winuser.h:552
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
#define ObDereferenceObject
Definition: obfuncs.h:203
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by co_IntCreateDefaultImeWindow(), MENU_InitPopup(), and NtUserCreateWindowEx().

◆ co_UserDestroyWindow()

BOOLEAN co_UserDestroyWindow ( PVOID  Object)

Definition at line 2873 of file window.c.

2874{
2875 HWND hWnd;
2876 PWND pwndTemp;
2877 PTHREADINFO ti;
2878 MSG msg;
2879 PWND Window = Object;
2880
2881 ASSERT_REFS_CO(Window); // FIXME: Temp HACK?
2882
2883 /* NtUserDestroyWindow does check if the window has already been destroyed
2884 but co_UserDestroyWindow can be called from more paths which means
2885 that it can also be called for a window that has already been destroyed. */
2887 {
2888 TRACE("Tried to destroy a window twice\n");
2889 return TRUE;
2890 }
2891
2894
2895 TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
2896
2897 /* Check for owner thread */
2898 if (Window->head.pti != ti)
2899 {
2900 /* Check if we are destroying the desktop window */
2901 if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd))
2902 {
2904 return FALSE;
2905 }
2906 }
2907
2908 /* If window was created successfully and it is hooked */
2909 if ((Window->state2 & WNDS2_WMCREATEMSGPROCESSED))
2910 {
2912 {
2913 ERR("Destroy Window WH_CBT Call Hook return!\n");
2914 return FALSE;
2915 }
2916 }
2917
2918 if (Window->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME])
2919 {
2920 if ((Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2921 {
2922 if (Window->spwndOwner)
2923 {
2924 //ERR("DestroyWindow Owner out.\n");
2925 UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE);
2926 }
2927 }
2928 }
2929
2930 /* Inform the parent */
2931 if (Window->style & WS_CHILD)
2932 {
2934 }
2935
2936 if (!Window->spwndOwner && !IntGetParent(Window))
2937 {
2939 }
2940
2941 /* Hide the window */
2942 if (Window->style & WS_VISIBLE)
2943 {
2944 if (Window->style & WS_CHILD)
2945 {
2946 /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2948 }
2949 else
2950 {
2952 }
2953 }
2954
2955 /* Adjust last active */
2956 if ((pwndTemp = Window->spwndOwner))
2957 {
2958 while (pwndTemp->spwndOwner)
2959 pwndTemp = pwndTemp->spwndOwner;
2960
2961 if (pwndTemp->spwndLastActive == Window)
2962 WndSetLastActive(pwndTemp, Window->spwndOwner);
2963 }
2964
2965 if (Window->spwndParent && IntIsWindow(UserHMGetHandle(Window)))
2966 {
2967 if ((Window->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
2968 {
2970 {
2971 //ERR("DestroyWindow Parent out.\n");
2972 UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE);
2973 }
2974 }
2975 }
2976
2977 if (Window->head.pti->MessageQueue->spwndActive == Window)
2978 Window->head.pti->MessageQueue->spwndActive = NULL;
2979 if (Window->head.pti->MessageQueue->spwndFocus == Window)
2980 Window->head.pti->MessageQueue->spwndFocus = NULL;
2981 if (Window->head.pti->MessageQueue->spwndActivePrev == Window)
2982 Window->head.pti->MessageQueue->spwndActivePrev = NULL;
2983 if (Window->head.pti->MessageQueue->spwndCapture == Window)
2984 Window->head.pti->MessageQueue->spwndCapture = NULL;
2985
2986 /*
2987 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2988 */
2989
2990 if (ti->pDeskInfo != NULL)
2991 {
2992 if (ti->pDeskInfo->hShellWindow == hWnd)
2993 {
2994 ERR("Destroying the ShellWindow!\n");
2995 ti->pDeskInfo->hShellWindow = NULL;
2996 }
2997 }
2998
3000
3002 {
3003 return TRUE;
3004 }
3005
3006 /* Recursively destroy owned windows */
3007 if (!(Window->style & WS_CHILD))
3008 {
3010 }
3011
3012 /* Generate mouse move message for the next window */
3013 msg.message = WM_MOUSEMOVE;
3014 msg.wParam = UserGetMouseButtonsState();
3015 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
3016 msg.pt = gpsi->ptCursor;
3018
3019 IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0);
3020
3021 /* Send destroy messages */
3023
3024 /* Destroy the default IME window if necessary */
3025 if (IS_IMM_MODE() && !(ti->TIF_flags & TIF_INCLEANUP) &&
3026 ti->spwndDefaultIme && (ti->spwndDefaultIme != Window) &&
3027 !(Window->state & WNDS_DESTROYED) && !IS_WND_IMELIKE(Window))
3028 {
3029 if (IS_WND_CHILD(Window))
3030 {
3033 }
3034 else
3035 {
3038 }
3039 }
3040
3042 {
3043 return TRUE;
3044 }
3045
3046 /* Destroy the window storage */
3048
3049 return TRUE;
3050}
#define msg(x)
Definition: auth_time.c:54
VOID FASTCALL IntEngWindowChanged(_In_ struct _WND *Window, _In_ FLONG flChanged)
#define ICLS_IME
Definition: ntuser.h:927
#define TIF_INCLEANUP
Definition: ntuser.h:263
#define WNDS_DESTROYED
Definition: ntuser.h:636
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
BOOL FASTCALL IntImeCanDestroyDefIMEforChild(_In_ PWND pImeWnd, _In_ PWND pwndTarget)
Definition: ime.c:2121
BOOL FASTCALL IntImeCanDestroyDefIME(_In_ PWND pImeWnd, _In_ PWND pwndTarget)
Definition: ime.c:2168
FLONG TIF_flags
Definition: win32.h:95
struct _WND * spwndLastActive
Definition: ntuser.h:739
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define DF_DESTROYED
Definition: desktop.h:50
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:206
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:576
static void IntSendDestroyMsg(HWND hWnd)
Definition: window.c:463
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:178
VOID FASTCALL IntDestroyOwnedWindows(PWND Window)
Definition: window.c:2837
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:114
#define IS_WND_CHILD(pWnd)
Definition: window.h:108
static VOID WndSetLastActive(_Inout_ PWND pwnd, _In_opt_ PWND pwndLastActive)
Definition: window.h:185
#define WOC_DELETE
Definition: winddi.h:1269
#define MAKELPARAM(l, h)
Definition: winuser.h:4110
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1267
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define SWP_HIDEWINDOW
Definition: winuser.h:1252
#define WM_DESTROY
Definition: winuser.h:1637

Referenced by co_UserCreateWindowEx(), co_UserDestroyWindow(), handle_internal_message(), IntDefWindowProc(), IntDesktopObjectDelete(), IntDestroyOwnedWindows(), IntTrackPopupMenuEx(), MENU_HideSubPopups(), MENU_TrackMenu(), NtUserDestroyWindow(), and NtUserDisableThreadIme().

◆ co_UserFreeWindow()

LRESULT co_UserFreeWindow ( PWND  Window,
PPROCESSINFO  ProcessData,
PTHREADINFO  ThreadData,
BOOLEAN  SendMessages 
)

Definition at line 576 of file window.c.

580{
581 HWND *Children;
582 HWND *ChildHandle;
583 PWND Child;
584 PMENU Menu;
585 BOOLEAN BelongsToThreadData;
587
588 ASSERT(Window);
589
590 if(Window->state2 & WNDS2_INDESTROY)
591 {
592 TRACE("Tried to call co_UserFreeWindow() twice\n");
593 return 0;
594 }
595 Window->state2 |= WNDS2_INDESTROY;
596 Window->style &= ~WS_VISIBLE;
597 Window->head.pti->cVisWindows--;
598
599 /* remove the window already at this point from the thread window list so we
600 don't get into trouble when destroying the thread windows while we're still
601 in co_UserFreeWindow() */
602 if (!IsListEmpty(&Window->ThreadListEntry))
603 RemoveEntryList(&Window->ThreadListEntry);
604
605 BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
606
608
609 /* free child windows */
610 Children = IntWinListChildren(Window);
611 if (Children)
612 {
613 for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
614 {
615 if ((Child = IntGetWindowObject(*ChildHandle)))
616 {
618 {
619 /* send WM_DESTROY messages to windows not belonging to the same thread */
621 }
622 else
623 co_UserFreeWindow(Child, ProcessData, ThreadData, SendMessages);
624
626 }
627 }
629 }
630
631 if (SendMessages)
632 {
633 /*
634 * Clear the update region to make sure no WM_PAINT messages will be
635 * generated for this window while processing the WM_NCDESTROY.
636 */
640 if (BelongsToThreadData)
642 }
643
645
647
648 /* Unregister hot keys */
650
651 /* flush the message queue */
653
654 /* from now on no messages can be sent to this window anymore */
655 Window->state |= WNDS_DESTROYED;
656 Window->fnid |= FNID_FREED;
657
658 /* don't remove the WINDOWSTATUS_DESTROYING bit */
659
660 /* reset shell window handles */
661 if (ThreadData->rpdesk)
662 {
663 if (UserHMGetHandle(Window) == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
664 ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
665
666 if (UserHMGetHandle(Window) == ThreadData->rpdesk->rpwinstaParent->ShellListView)
667 ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
668 }
669
670 if (ThreadData->spwndDefaultIme &&
671 ThreadData->spwndDefaultIme->spwndOwner == Window)
672 {
673 WndSetOwner(ThreadData->spwndDefaultIme, NULL);
674 }
675
676 if (IS_IMM_MODE() && Window == ThreadData->spwndDefaultIme)
677 {
678 UserAssignmentUnlock((PVOID*)&(ThreadData->spwndDefaultIme));
679 }
680
681 /* Fixes dialog test_focus breakage due to r66237. */
682 if (ThreadData->MessageQueue->spwndFocus == Window)
683 ThreadData->MessageQueue->spwndFocus = NULL;
684
685 if (ThreadData->MessageQueue->spwndActive == Window)
686 ThreadData->MessageQueue->spwndActive = NULL;
687
688 if (ThreadData->MessageQueue->spwndCapture == Window)
689 {
691 }
692
694 if ( Window->hrgnUpdate != NULL || Window->state & WNDS_INTERNALPAINT )
695 {
696 MsqDecPaintCountQueue(Window->head.pti);
697 if (Window->hrgnUpdate > HRGN_WINDOW && GreIsHandleValid(Window->hrgnUpdate))
698 {
700 GreDeleteObject(Window->hrgnUpdate);
701 }
702 Window->hrgnUpdate = NULL;
703 Window->state &= ~WNDS_INTERNALPAINT;
704 }
705
707 {
709 }
710
711 if ( ((Window->style & (WS_CHILD|WS_POPUP)) != WS_CHILD) &&
712 Window->IDMenu &&
713 (Menu = UserGetMenuObject((HMENU)Window->IDMenu)))
714 {
715 TRACE("UFW: IDMenu %p\n",Window->IDMenu);
717 Window->IDMenu = 0;
718 }
719
720 if (Window->SystemMenu
721 && (Menu = UserGetMenuObject(Window->SystemMenu)))
722 {
724 Window->SystemMenu = (HMENU)0;
725 }
726
727 DceFreeWindowDCE(Window); /* Always do this to catch orphaned DCs */
728
730
731 if (Window->PropListItems)
732 {
734 TRACE("Window->PropListItems %lu\n",Window->PropListItems);
735 ASSERT(Window->PropListItems==0);
736 }
737
738 /* Kill any reference to linked windows. Prev & Next are taken care of in IntUnlinkWindow */
743
744 UserRefObjectCo(Window, &Ref);
746
748
749 if (Window->pcls->atomClassName == gaGuiConsoleWndClass)
750 {
751 /* Count only console windows manually */
753 }
754
755 /* dereference the class */
756 NT_ASSERT(Window->head.pti != NULL);
758 Window->head.pti->pDeskInfo,
759 Window->head.pti->ppi);
760 Window->pcls = NULL;
761
762 if (Window->hrgnClip)
763 {
765 GreDeleteObject(Window->hrgnClip);
766 Window->hrgnClip = NULL;
767 }
768 Window->head.pti->cWindows--;
769
770// ASSERT(Window != NULL);
771 UserFreeWindowInfo(Window->head.pti, Window);
772
775
776 return 0;
777}
unsigned char BOOLEAN
Definition: actypes.h:127
void FASTCALL DceFreeWindowDCE(PWND)
Definition: windc.c:686
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
BOOL FASTCALL IntReleaseCapture(VOID)
Definition: focus.c:1530
#define WNDS_SENDNCPAINT
Definition: ntuser.h:616
#define WNDS_INTERNALPAINT
Definition: ntuser.h:617
@ TYPE_WINDOW
Definition: ntuser.h:41
#define WNDS2_INDESTROY
Definition: ntuser.h:648
#define HRGN_WINDOW
Definition: ntuser.h:361
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:614
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND Window)
Definition: msgqueue.c:798
VOID FASTCALL MsqDecPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:508
@ WM_ASYNC_DESTROYWINDOW
Definition: msgqueue.h:120
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
BOOL FASTCALL IntDestroyScrollBars(PWND)
Definition: scrollbar.c:810
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:895
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1165
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1153
BOOL FASTCALL IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask)
Definition: region.c:2459
VOID FASTCALL UserClipboardFreeWindow(PWND pWindow)
Definition: clipboard.c:414
BOOL IntDeRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1800
VOID FASTCALL UnregisterWindowHotKeys(PWND pWnd)
Definition: hotkey.c:105
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:621
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
Definition: object.c:860
VOID FASTCALL UserRemoveWindowProps(_In_ PWND Window)
Definition: prop.c:115
#define USERTAG_WINDOWLIST
Definition: tags.h:298
BOOL FASTCALL DestroyTimersForWindow(PTHREADINFO pti, PWND Window)
Definition: timer.c:528
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:276
static VOID UserFreeWindowInfo(PTHREADINFO ti, PWND Wnd)
Definition: window.c:543
PWND FASTCALL IntGetWindowObject(HWND hWnd)
Definition: window.c:75
static VOID WndSetOwner(_Inout_ PWND pwnd, _In_opt_ PWND pwndOwner)
Definition: window.h:150
static VOID WndSetChild(_Inout_ PWND pwnd, _In_opt_ PWND pwndChild)
Definition: window.h:164
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:32
#define RDW_NOINTERNALPAINT
Definition: winuser.h:1228
#define RDW_NOCHILDREN
Definition: winuser.h:1233
#define WM_NCDESTROY
Definition: winuser.h:1712
#define RDW_NOFRAME
Definition: winuser.h:1227
#define RDW_NOERASE
Definition: winuser.h:1226
#define RDW_VALIDATE
Definition: winuser.h:1229
#define NT_ASSERT
Definition: rtlfuncs.h:3327

Referenced by co_UserDestroyWindow(), co_UserFreeWindow(), and handle_internal_message().

◆ co_UserSetParent()

HWND FASTCALL co_UserSetParent ( HWND  hWndChild,
HWND  hWndNewParent 
)

Definition at line 1297 of file window.c.

1298{
1299 PWND Wnd = NULL, WndParent = NULL, WndOldParent;
1300 HWND hWndOldParent = NULL;
1301 USER_REFERENCE_ENTRY Ref, ParentRef;
1302
1303 if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent))
1304 {
1306 return NULL;
1307 }
1308
1310 {
1311 ERR("UserSetParent Access Denied!\n");
1313 return NULL;
1314 }
1315
1316 if (hWndNewParent)
1317 {
1318 if (!(WndParent = UserGetWindowObject(hWndNewParent)))
1319 {
1320 ERR("UserSetParent Bad New Parent!\n");
1321 return NULL;
1322 }
1323 }
1324 else
1325 {
1326 if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow())))
1327 {
1328 return NULL;
1329 }
1330 }
1331
1332 if (!(Wnd = UserGetWindowObject(hWndChild)))
1333 {
1334 ERR("UserSetParent Bad Child!\n");
1335 return NULL;
1336 }
1337
1338 UserRefObjectCo(Wnd, &Ref);
1339 UserRefObjectCo(WndParent, &ParentRef);
1340 //ERR("Enter co_IntSetParent\n");
1341 WndOldParent = co_IntSetParent(Wnd, WndParent);
1342 //ERR("Leave co_IntSetParent\n");
1343 UserDerefObjectCo(WndParent);
1344 UserDerefObjectCo(Wnd);
1345
1346 if (WndOldParent)
1347 {
1348 hWndOldParent = UserHMGetHandle(WndOldParent);
1349 UserDereferenceObject(WndOldParent);
1350 }
1351
1352 return hWndOldParent;
1353}
HWND hWndChild[NUM_TABS]
Definition: main.h:74
PWND FASTCALL co_IntSetParent(PWND Wnd, PWND WndNewParent)
Definition: window.c:1159
#define IntIsBroadcastHwnd(hWnd)
Definition: window.h:28

Referenced by co_IntSetWindowLongPtr(), and NtUserSetParent().

◆ co_UserSetWindowLong()

LONG FASTCALL co_UserSetWindowLong ( HWND  hWnd,
DWORD  Index,
LONG  NewValue,
BOOL  Ansi 
)

Definition at line 4041 of file window.c.

4042{
4043 return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4044}
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3844

Referenced by DesktopWindowProc(), and NtUserSetWindowWord().

◆ co_UserSetWindowLongPtr()

LONG_PTR FASTCALL co_UserSetWindowLongPtr ( HWND  hWnd,
DWORD  Index,
LONG_PTR  NewValue,
BOOL  Ansi 
)

Definition at line 4047 of file window.c.

4048{
4049 return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
4050}

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserWnd  )

◆ DefSetText()

BOOL APIENTRY DefSetText ( PWND  Wnd,
PCWSTR  WindowText 
)

Definition at line 4393 of file window.c.

4394{
4396 BOOL Ret = FALSE;
4397
4398 RtlInitUnicodeString(&UnicodeString, WindowText);
4399
4400 if (UnicodeString.Length != 0)
4401 {
4402 if (Wnd->strName.MaximumLength > 0 &&
4403 UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4404 {
4405 ASSERT(Wnd->strName.Buffer != NULL);
4406
4407 Wnd->strName.Length = UnicodeString.Length;
4408 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4410 UnicodeString.Buffer,
4411 UnicodeString.Length);
4412 }
4413 else
4414 {
4415 PWCHAR buf;
4416 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4417 buf = Wnd->strName.Buffer;
4418 Wnd->strName.Buffer = NULL;
4419 if (buf != NULL)
4420 {
4422 }
4423
4425 UnicodeString.Length + sizeof(UNICODE_NULL));
4426 if (Wnd->strName.Buffer != NULL)
4427 {
4428 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4430 UnicodeString.Buffer,
4431 UnicodeString.Length);
4432 Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4433 Wnd->strName.Length = UnicodeString.Length;
4434 }
4435 else
4436 {
4438 goto Exit;
4439 }
4440 }
4441 }
4442 else
4443 {
4444 Wnd->strName.Length = 0;
4445 if (Wnd->strName.Buffer != NULL)
4446 Wnd->strName.Buffer[0] = L'\0';
4447 }
4448
4449 // FIXME: HAX! Windows does not do this in here!
4450 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4451 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4452 /* Send shell notifications */
4453 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4454 {
4455 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4456 }
4457
4458 Ret = TRUE;
4459Exit:
4461 return Ret;
4462}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define UNICODE_NULL
static void Exit(void)
Definition: sock.c:1330
LARGE_UNICODE_STRING strName
Definition: ntuser.h:736
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntDefWindowProc(), RealDefWindowProcA(), and RealDefWindowProcW().

◆ IntBuildHwndList()

PWINDOWLIST FASTCALL IntBuildHwndList ( PWND  pwnd,
DWORD  dwFlags,
PTHREADINFO  pti 
)

Definition at line 1427 of file window.c.

1428{
1429 PWINDOWLIST pwl;
1430 DWORD cbWL;
1431
1432 if (gpwlCache)
1433 {
1434 pwl = gpwlCache;
1435 gpwlCache = NULL;
1436 }
1437 else
1438 {
1439#define INITIAL_COUNT 32
1440 cbWL = sizeof(WINDOWLIST) + (INITIAL_COUNT - 1) * sizeof(HWND);
1442 if (!pwl)
1443 return NULL;
1444
1445 pwl->phwndEnd = &pwl->ahwnd[INITIAL_COUNT];
1446#undef INITIAL_COUNT
1447 }
1448
1449 pwl->pti = pti;
1450 pwl->phwndLast = pwl->ahwnd;
1451 pwl = IntPopulateHwndList(pwl, pwnd, dwFlags);
1452 if (WL_IS_BAD(pwl))
1453 {
1455 return NULL;
1456 }
1457
1458 *(pwl->phwndLast) = HWND_TERMINATOR;
1459
1460 if (dwFlags & 0x8)
1461 {
1462 // TODO:
1463 }
1464
1465 pwl->pti = GetW32ThreadInfo();
1466 pwl->pNextList = gpwlList;
1467 gpwlList = pwl;
1468
1469 return pwl;
1470}
#define PagedPool
Definition: env_spec_w32.h:308
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
HWND * phwndLast
Definition: window.h:88
HWND ahwnd[ANYSIZE_ARRAY]
Definition: window.h:91
struct tagWINDOWLIST * pNextList
Definition: window.h:87
PTHREADINFO pti
Definition: window.h:90
HWND * phwndEnd
Definition: window.h:89
PWINDOWLIST gpwlCache
Definition: window.c:19
PWINDOWLIST FASTCALL IntPopulateHwndList(PWINDOWLIST pwl, PWND pwnd, DWORD dwFlags)
Definition: window.c:1397
#define INITIAL_COUNT
PWINDOWLIST gpwlList
Definition: window.c:18
#define WL_IS_BAD(pwl)
Definition: window.h:97
#define HWND_TERMINATOR
Definition: window.h:83
struct tagWINDOWLIST WINDOWLIST

Referenced by IntAssociateInputContextEx(), IntCheckImeShowStatus(), IntDestroyInputContext(), and IntImeWindowPosChanged().

◆ IntCheckFrameEdge()

static BOOL FASTCALL IntCheckFrameEdge ( ULONG  Style,
ULONG  ExStyle 
)
static

Definition at line 3833 of file window.c.

3834{
3836 return TRUE;
3837 else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3838 return TRUE;
3839 else
3840 return FALSE;
3841}
const DWORD ExStyle
Definition: appswitch.c:73
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_DLGFRAME
Definition: pedump.c:626
#define WS_EX_STATICEDGE
Definition: winuser.h:403

Referenced by co_IntSetWindowLongPtr().

◆ IntCreateWindow()

PWND FASTCALL IntCreateWindow ( CREATESTRUCTW Cs,
PLARGE_STRING  WindowName,
PCLS  Class,
PWND  ParentWindow,
PWND  OwnerWindow,
PVOID  acbiBuffer,
PDESKTOP  pdeskCreated,
DWORD  dwVer 
)

Definition at line 1811 of file window.c.

1819{
1820 PWND pWnd = NULL;
1821 HWND hWnd;
1822 PTHREADINFO pti;
1823 BOOL MenuChanged;
1824 BOOL bUnicodeWindow;
1825 PCALLPROCDATA pcpd;
1826
1827 pti = pdeskCreated ? gptiDesktopThread : GetW32ThreadInfo();
1828
1829 if (!(Cs->dwExStyle & WS_EX_LAYOUTRTL))
1830 { // Need both here for wine win.c test_CreateWindow.
1831 //if (Cs->hwndParent && ParentWindow)
1832 if (ParentWindow) // It breaks more tests..... WIP.
1833 {
1834 if ( (Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD &&
1835 ParentWindow->ExStyle & WS_EX_LAYOUTRTL &&
1836 !(ParentWindow->ExStyle & WS_EX_NOINHERITLAYOUT) )
1838 }
1839 else
1840 { /*
1841 * Note from MSDN <https://learn.microsoft.com/en-us/previous-versions/aa913269(v=msdn.10)>:
1842 *
1843 * Dialog boxes and message boxes do not inherit layout, so you must
1844 * set the layout explicitly.
1845 */
1846 if ( Class->fnid != FNID_DIALOG )
1847 {
1848 if (pti->ppi->dwLayout & LAYOUT_RTL)
1849 {
1851 }
1852 }
1853 }
1854 }
1855
1856 /* Automatically add WS_EX_WINDOWEDGE */
1857 if ((Cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
1858 ((!(Cs->dwExStyle & WS_EX_STATICEDGE)) &&
1859 (Cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
1861 else
1862 Cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
1863
1864 /* Is it a unicode window? */
1865 bUnicodeWindow =!(Cs->dwExStyle & WS_EX_SETANSICREATOR);
1866 Cs->dwExStyle &= ~WS_EX_SETANSICREATOR;
1867
1868 /* Allocate the new window */
1870 pdeskCreated ? pdeskCreated : pti->rpdesk,
1871 pti,
1872 (PHANDLE)&hWnd,
1874 sizeof(WND) + Class->cbwndExtra);
1875
1876 if (!pWnd)
1877 {
1878 goto AllocError;
1879 }
1880
1881 TRACE("Created window object with handle %p\n", hWnd);
1882
1883 if (pdeskCreated && pdeskCreated->DesktopWindow == NULL )
1884 { /* HACK: Helper for win32csr/desktopbg.c */
1885 /* If there is no desktop window yet, we must be creating it */
1886 TRACE("CreateWindow setting desktop.\n");
1887 pdeskCreated->DesktopWindow = hWnd;
1888 pdeskCreated->pDeskInfo->spwnd = pWnd;
1889 }
1890
1891 /*
1892 * Fill out the structure describing it.
1893 */
1894 /* Remember, pWnd->head is setup in object.c ... */
1895 WndSetParent(pWnd, ParentWindow);
1896 WndSetOwner(pWnd, OwnerWindow);
1897 pWnd->fnid = 0;
1898 WndSetLastActive(pWnd, pWnd);
1899 // Ramp up compatible version sets.
1900 if ( dwVer >= WINVER_WIN31 )
1901 {
1902 pWnd->state2 |= WNDS2_WIN31COMPAT;
1903 if ( dwVer >= WINVER_WINNT4 )
1904 {
1905 pWnd->state2 |= WNDS2_WIN40COMPAT;
1906 if ( dwVer >= WINVER_WIN2K )
1907 {
1908 pWnd->state2 |= WNDS2_WIN50COMPAT;
1909 }
1910 }
1911 }
1912 pWnd->pcls = Class;
1913 pWnd->hModule = Cs->hInstance;
1914 pWnd->style = Cs->style & ~WS_VISIBLE;
1915 pWnd->ExStyle = Cs->dwExStyle;
1916 pWnd->cbwndExtra = pWnd->pcls->cbwndExtra;
1917 pWnd->pActCtx = acbiBuffer;
1918
1919 if (pti->spDefaultImc && Class->atomClassName != gpsi->atomSysClass[ICLS_BUTTON])
1920 pWnd->hImc = UserHMGetHandle(pti->spDefaultImc);
1921
1922 pWnd->InternalPos.MaxPos.x = pWnd->InternalPos.MaxPos.y = -1;
1923 pWnd->InternalPos.IconPos.x = pWnd->InternalPos.IconPos.y = -1;
1924
1925 if (pWnd->spwndParent != NULL && Cs->hwndParent != 0)
1926 {
1927 pWnd->HideFocus = pWnd->spwndParent->HideFocus;
1928 pWnd->HideAccel = pWnd->spwndParent->HideAccel;
1929 }
1930
1932 pWnd->head.pti->cWindows++;
1933
1934 if (Class->spicn && !Class->spicnSm)
1935 {
1936 HICON IconSmHandle = NULL;
1937 if((Class->spicn->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
1939 {
1940 IconSmHandle = co_IntCopyImage(
1941 UserHMGetHandle(Class->spicn),
1942 IMAGE_ICON,
1946 }
1947 if (!IconSmHandle)
1948 {
1949 /* Retry without copying from resource */
1950 IconSmHandle = co_IntCopyImage(
1951 UserHMGetHandle(Class->spicn),
1952 IMAGE_ICON,
1955 0);
1956 }
1957
1958 if (IconSmHandle)
1959 {
1960 Class->spicnSm = UserGetCurIconObject(IconSmHandle);
1961 Class->CSF_flags |= CSF_CACHEDSMICON;
1962 }
1963 }
1964
1965 if (pWnd->pcls->CSF_flags & CSF_SERVERSIDEPROC)
1967
1968 /* BugBoy Comments: Comment below say that System classes are always created
1969 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1970 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1971
1972 No where can I see in code or through testing does the window change back
1973 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1974 see what problems this would cause. */
1975
1976 // Set WndProc from Class.
1977 if (IsCallProcHandle(pWnd->pcls->lpfnWndProc))
1978 {
1980 if (pcpd)
1981 pWnd->lpfnWndProc = pcpd->pfnClientPrevious;
1982 }
1983 else
1984 {
1985 pWnd->lpfnWndProc = pWnd->pcls->lpfnWndProc;
1986 }
1987
1988 // GetWindowProc, test for non server side default classes and set WndProc.
1989 if ( pWnd->pcls->fnid <= FNID_GHOST && pWnd->pcls->fnid >= FNID_BUTTON )
1990 {
1991 if (bUnicodeWindow)
1992 {
1993 if (GETPFNCLIENTA(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1994 pWnd->lpfnWndProc = GETPFNCLIENTW(pWnd->pcls->fnid);
1995 }
1996 else
1997 {
1998 if (GETPFNCLIENTW(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1999 pWnd->lpfnWndProc = GETPFNCLIENTA(pWnd->pcls->fnid);
2000 }
2001 }
2002
2003 // If not an Unicode caller, set Ansi creator bit.
2004 if (!bUnicodeWindow) pWnd->state |= WNDS_ANSICREATOR;
2005
2006 // Clone Class Ansi/Unicode proc type.
2007 if (pWnd->pcls->CSF_flags & CSF_ANSIPROC)
2008 {
2009 pWnd->state |= WNDS_ANSIWINDOWPROC;
2010 pWnd->Unicode = FALSE;
2011 }
2012 else
2013 { /*
2014 * It seems there can be both an Ansi creator and Unicode Class Window
2015 * WndProc, unless the following overriding conditions occur:
2016 */
2017 if ( !bUnicodeWindow &&
2018 ( Class->atomClassName == gpsi->atomSysClass[ICLS_BUTTON] ||
2019 Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOBOX] ||
2020 Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOLBOX] ||
2021 Class->atomClassName == gpsi->atomSysClass[ICLS_DIALOG] ||
2022 Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT] ||
2023 Class->atomClassName == gpsi->atomSysClass[ICLS_IME] ||
2024 Class->atomClassName == gpsi->atomSysClass[ICLS_LISTBOX] ||
2025 Class->atomClassName == gpsi->atomSysClass[ICLS_MDICLIENT] ||
2026 Class->atomClassName == gpsi->atomSysClass[ICLS_STATIC] ) )
2027 { // Override Class and set the window Ansi WndProc.
2028 pWnd->state |= WNDS_ANSIWINDOWPROC;
2029 pWnd->Unicode = FALSE;
2030 }
2031 else
2032 { // Set the window Unicode WndProc.
2033 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
2034 pWnd->Unicode = TRUE;
2035 }
2036 }
2037
2038 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
2039 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
2040 Dont understand why it does this. */
2041 if (Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT])
2042 {
2043 PCALLPROCDATA CallProc;
2044 CallProc = CreateCallProc(pWnd->head.rpdesk, pWnd->lpfnWndProc, pWnd->Unicode , pWnd->head.pti->ppi);
2045
2046 if (!CallProc)
2047 {
2049 ERR("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %p\n", hWnd);
2050 }
2051 else
2052 {
2053 UserAddCallProcToClass(pWnd->pcls, CallProc);
2054 }
2055 }
2056
2058 pWnd->PropListItems = 0;
2059
2060 if ( WindowName->Buffer != NULL && WindowName->Length > 0 )
2061 {
2063 WindowName->Length + sizeof(UNICODE_NULL));
2064 if (pWnd->strName.Buffer == NULL)
2065 {
2066 goto AllocError;
2067 }
2068
2069 RtlCopyMemory(pWnd->strName.Buffer, WindowName->Buffer, WindowName->Length);
2070 pWnd->strName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0';
2071 pWnd->strName.Length = WindowName->Length;
2072 pWnd->strName.MaximumLength = WindowName->Length + sizeof(UNICODE_NULL);
2073 }
2074
2075 /* Correct the window style. */
2076 if ((pWnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2077 {
2078 pWnd->style |= WS_CLIPSIBLINGS;
2079 if (!(pWnd->style & WS_POPUP))
2080 {
2081 pWnd->style |= WS_CAPTION;
2082 }
2083 }
2084
2085 /* WS_EX_WINDOWEDGE depends on some other styles */
2086 if (pWnd->ExStyle & WS_EX_DLGMODALFRAME)
2087 pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2088 else if (pWnd->style & (WS_DLGFRAME | WS_THICKFRAME))
2089 {
2090 if (!((pWnd->ExStyle & WS_EX_STATICEDGE) &&
2091 (pWnd->style & (WS_CHILD | WS_POPUP))))
2092 pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2093 }
2094 else
2095 pWnd->ExStyle &= ~WS_EX_WINDOWEDGE;
2096
2097 if (!(pWnd->style & (WS_CHILD | WS_POPUP)))
2099
2100 /* Set the window menu */
2101 if ((Cs->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2102 {
2103 if (Cs->hMenu)
2104 {
2105 IntSetMenu(pWnd, Cs->hMenu, &MenuChanged);
2106 }
2107 else if (pWnd->pcls->lpszMenuName) // Take it from the parent.
2108 {
2109 UNICODE_STRING MenuName;
2110 HMENU hMenu;
2111
2112 if (IS_INTRESOURCE(pWnd->pcls->lpszMenuName))
2113 {
2114 MenuName.Length = 0;
2115 MenuName.MaximumLength = 0;
2116 MenuName.Buffer = pWnd->pcls->lpszMenuName;
2117 }
2118 else
2119 {
2120 RtlInitUnicodeString( &MenuName, pWnd->pcls->lpszMenuName);
2121 }
2122 hMenu = co_IntCallLoadMenu( pWnd->pcls->hModule, &MenuName);
2123 if (hMenu) IntSetMenu(pWnd, hMenu, &MenuChanged);
2124 }
2125 }
2126 else // Not a child
2127 pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
2128
2129
2130 if ( ParentWindow &&
2131 ParentWindow != ParentWindow->head.rpdesk->spwndMessage &&
2132 ParentWindow != ParentWindow->head.rpdesk->pDeskInfo->spwnd )
2133 {
2134 PWND Owner = IntGetNonChildAncestor(ParentWindow);
2135
2136 if (!IntValidateOwnerDepth(pWnd, Owner))
2137 {
2139 goto Error;
2140 }
2141 if ( pWnd->spwndOwner &&
2142 pWnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
2143 {
2144 pWnd->ExStyle |= WS_EX_TOPMOST;
2145 }
2146 if ( pWnd->spwndOwner &&
2147 Class->atomClassName != gpsi->atomSysClass[ICLS_IME] &&
2148 pti != pWnd->spwndOwner->head.pti)
2149 {
2150 //ERR("CreateWindow Owner in.\n");
2151 UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE);
2152 }
2153 }
2154
2155 /* Insert the window into the thread's window list. */
2157
2158 /* Handle "CS_CLASSDC", it is tested first. */
2159 if ( (pWnd->pcls->style & CS_CLASSDC) && !(pWnd->pcls->pdce) )
2160 { /* One DCE per class to have CLASS. */
2161 pWnd->pcls->pdce = DceAllocDCE( pWnd, DCE_CLASS_DC );
2162 }
2163 else if ( pWnd->pcls->style & CS_OWNDC)
2164 { /* Allocate a DCE for this window. */
2166 }
2167
2168 return pWnd;
2169
2170AllocError:
2171 ERR("IntCreateWindow Allocation Error.\n");
2173Error:
2174 if(pWnd)
2176 return NULL;
2177}
BOOL Error
Definition: chkdsk.c:66
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
static __inline BOOL IsCallProcHandle(IN WNDPROC lpWndProc)
Definition: class.h:13
PDCE FASTCALL DceAllocDCE(PWND Window, DCE_TYPE Type)
Definition: windc.c:86
@ DCE_CLASS_DC
Definition: dce.h:13
@ DCE_WINDOW_DC
Definition: dce.h:14
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ICLS_DIALOG
Definition: ntuser.h:930
#define ICLS_LISTBOX
Definition: ntuser.h:915
#define WNDS2_WIN40COMPAT
Definition: ntuser.h:650
#define ICLS_EDIT
Definition: ntuser.h:913
#define CURSORF_LRSHARED
Definition: ntuser.h:1201
#define ICLS_COMBOBOX
Definition: ntuser.h:917
#define ICLS_STATIC
Definition: ntuser.h:914
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:906
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:904
#define CSF_ANSIPROC
Definition: ntuser.h:557
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:623
#define FNID_BUTTON
Definition: ntuser.h:866
#define CSF_CACHEDSMICON
Definition: ntuser.h:562
struct _WND * PWND
#define FNID_DIALOG
Definition: ntuser.h:869
#define ICLS_COMBOLBOX
Definition: ntuser.h:919
#define ICLS_BUTTON
Definition: ntuser.h:912
struct _WND WND
@ TYPE_CALLPROC
Definition: ntuser.h:47
#define CURSORF_FROMRESOURCE
Definition: ntuser.h:1199
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:556
#define WNDS_ANSICREATOR
Definition: ntuser.h:634
#define FNID_GHOST
Definition: ntuser.h:875
#define ICLS_MDICLIENT
Definition: ntuser.h:918
#define WNDS2_WIN50COMPAT
Definition: ntuser.h:651
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:624
static HICON
Definition: imagelist.c:80
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1629
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define WS_CAPTION
Definition: pedump.c:624
WNDPROC pfnClientPrevious
Definition: ntuser.h:552
PWSTR lpszMenuName
Definition: ntuser.h:588
WNDPROC lpfnWndProc
Definition: ntuser.h:581
INT cbwndExtra
Definition: ntuser.h:583
DWORD CSF_flags
Definition: ntuser.h:573
UINT style
Definition: ntuser.h:580
HINSTANCE hModule
Definition: ntuser.h:584
DWORD fnid
Definition: ntuser.h:570
PVOID pdce
Definition: ntuser.h:572
ULONG Length
Definition: ntuser.h:91
PVOID Buffer
Definition: ntuser.h:94
struct tagIMC * spDefaultImc
Definition: win32.h:132
LIST_ENTRY WindowListHead
Definition: win32.h:155
USHORT MaximumLength
Definition: env_spec_w32.h:370
LIST_ENTRY ThreadListEntry
Definition: ntuser.h:764
PCLS pcls
Definition: ntuser.h:720
UINT Unicode
Definition: ntuser.h:756
ULONG PropListItems
Definition: ntuser.h:724
DWORD state2
Definition: ntuser.h:702
PVOID pActCtx
Definition: ntuser.h:742
DWORD fnid
Definition: ntuser.h:709
UINT HideFocus
Definition: ntuser.h:758
struct _WND::@5412 InternalPos
UINT HideAccel
Definition: ntuser.h:759
LIST_ENTRY PropListHead
Definition: ntuser.h:723
HIMC hImc
Definition: ntuser.h:740
DWORD state
Definition: ntuser.h:701
UINT_PTR IDMenu
Definition: ntuser.h:731
WNDPROC lpfnWndProc
Definition: ntuser.h:718
HINSTANCE hModule
Definition: ntuser.h:708
ULONG cbwndExtra
Definition: ntuser.h:738
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WS_EX_SETANSICREATOR
Definition: undocuser.h:30
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE hModule, PUNICODE_STRING pMenuName)
Definition: callback.c:903
HANDLE FASTCALL co_IntCopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
Definition: callback.c:985
VOID UserAddCallProcToClass(IN OUT PCLS Class, IN PCALLPROCDATA CallProc)
Definition: class.c:428
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
PTHREADINFO gptiDesktopThread
Definition: desktop.c:54
BOOL FASTCALL IntSetMenu(PWND Wnd, HMENU Menu, BOOL *Changed)
Definition: menu.c:5485
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:209
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
BOOL FASTCALL IntValidateOwnerDepth(PWND Wnd, PWND Owner)
Definition: window.c:369
PWND FASTCALL IntGetNonChildAncestor(PWND pWnd)
Definition: window.c:353
#define WINVER_WIN2K
Definition: window.h:56
#define WINVER_WINNT4
Definition: window.h:57
#define WINVER_WIN31
Definition: window.h:58
#define IMAGE_ICON
Definition: winuser.h:212
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1110
#define SM_CYSMICON
Definition: winuser.h:1024
#define SM_CXSMICON
Definition: winuser.h:1023
#define CS_OWNDC
Definition: winuser.h:663
#define CS_CLASSDC
Definition: winuser.h:658
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396

Referenced by co_UserCreateWindowEx(), and IntCreateDesktop().

◆ IntDestroyOwnedWindows()

VOID FASTCALL IntDestroyOwnedWindows ( PWND  Window)

Definition at line 2837 of file window.c.

2838{
2839 HWND* List;
2840 HWND* phWnd;
2841 PWND pWnd;
2843
2845 if (!List)
2846 return;
2847
2848 for (phWnd = List; *phWnd; ++phWnd)
2849 {
2850 pWnd = ValidateHwndNoErr(*phWnd);
2851 if (pWnd == NULL)
2852 continue;
2853 ASSERT(pWnd->spwndOwner == Window);
2854 ASSERT(pWnd != Window);
2855
2856 WndSetOwner(pWnd, NULL);
2858 {
2859 UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2861 UserDerefObjectCo(pWnd); // Temp HACK?
2862 }
2863 else
2864 {
2865 ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2866 }
2867 }
2868
2870}
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:100
HWND *FASTCALL IntWinListOwnedPopups(PWND Window)
Definition: window.c:317

Referenced by co_UserDestroyWindow().

◆ IntEnableWindow()

BOOL FASTCALL IntEnableWindow ( HWND  hWnd,
BOOL  bEnable 
)

Definition at line 222 of file window.c.

223{
224 BOOL Update;
225 PWND pWnd;
226 UINT bIsDisabled;
227
228 if(!(pWnd = UserGetWindowObject(hWnd)))
229 {
230 return FALSE;
231 }
232
233 /* check if updating is needed */
234 bIsDisabled = !!(pWnd->style & WS_DISABLED);
235 Update = bIsDisabled;
236
237 if (bEnable)
238 {
239 IntSetStyle( pWnd, 0, WS_DISABLED );
240 }
241 else
242 {
243 Update = !bIsDisabled;
244
246
247 /* Remove keyboard focus from that window if it had focus */
249 {
250 TRACE("IntEnableWindow SF NULL\n");
252 }
253 IntSetStyle( pWnd, WS_DISABLED, 0 );
254 }
255
256 if (Update)
257 {
258 IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE, pWnd, OBJID_WINDOW, CHILDID_SELF, 0);
260 }
261 // Return nonzero if it was disabled, or zero if it wasn't:
262 return bIsDisabled;
263}
@ Update
Definition: registry.c:565
HWND FASTCALL IntGetThreadFocusWindow(VOID)
Definition: focus.c:43
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1316
#define WS_DISABLED
Definition: pedump.c:621
_In_ BOOL bEnable
Definition: winddi.h:3426
#define WM_ENABLE
Definition: winuser.h:1643
#define WM_CANCELMODE
Definition: winuser.h:1663

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

HWND FASTCALL IntFindWindow ( PWND  Parent,
PWND  ChildAfter,
RTL_ATOM  ClassAtom,
PUNICODE_STRING  WindowName 
)

Definition at line 3081 of file window.c.

3085{
3086 BOOL CheckWindowName;
3087 HWND *List, *phWnd;
3088 HWND Ret = NULL;
3089 UNICODE_STRING CurrentWindowName;
3090
3091 ASSERT(Parent);
3092
3093 CheckWindowName = WindowName->Buffer != 0;
3094
3096 {
3097 phWnd = List;
3098 if(ChildAfter)
3099 {
3100 /* skip handles before and including ChildAfter */
3101 while(*phWnd && (*(phWnd++) != UserHMGetHandle(ChildAfter)))
3102 ;
3103 }
3104
3105 /* search children */
3106 while(*phWnd)
3107 {
3108 PWND Child;
3109 if(!(Child = UserGetWindowObject(*(phWnd++))))
3110 {
3111 continue;
3112 }
3113
3114 /* Do not send WM_GETTEXT messages in the kernel mode version!
3115 The user mode version however calls GetWindowText() which will
3116 send WM_GETTEXT messages to windows belonging to its processes */
3117 if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
3118 {
3119 // FIXME: LARGE_STRING truncated
3120 CurrentWindowName.Buffer = Child->strName.Buffer;
3121 CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
3122 CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
3123 if(!CheckWindowName ||
3124 (Child->strName.Length < 0xFFFF &&
3125 !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
3126 {
3127 Ret = UserHMGetHandle(Child);
3128 break;
3129 }
3130 }
3131 }
3133 }
3134
3135 return Ret;
3136}
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define min(a, b)
Definition: monoChain.cc:55
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:83

Referenced by NtUserFindWindowEx().

◆ IntFixWindowCoordinates()

void FASTCALL IntFixWindowCoordinates ( CREATESTRUCTW Cs,
PWND  ParentWindow,
DWORD dwShowMode 
)

Definition at line 1717 of file window.c.

1718{
1719#define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1720
1721 /* default positioning for overlapped windows */
1722 if(!(Cs->style & (WS_POPUP | WS_CHILD)))
1723 {
1724 PMONITOR pMonitor = NULL;
1725 PRTL_USER_PROCESS_PARAMETERS ProcessParams;
1727
1728 if (ppi && ppi->hMonitor)
1729 pMonitor = UserGetMonitorObject(ppi->hMonitor);
1730 if (!pMonitor)
1731 pMonitor = UserGetPrimaryMonitor();
1732
1733 /* Check if we don't have a monitor attached yet */
1734 if (pMonitor == NULL)
1735 {
1736 Cs->x = Cs->y = 0;
1737 Cs->cx = 800;
1738 Cs->cy = 600;
1739 return;
1740 }
1741
1742 ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
1743
1744 if (IS_DEFAULT(Cs->x))
1745 {
1746 if (!IS_DEFAULT(Cs->y)) *dwShowMode = Cs->y;
1747
1748 if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
1749 {
1750 Cs->x = ProcessParams->StartingX;
1751 Cs->y = ProcessParams->StartingY;
1752 }
1753 else
1754 {
1757 if (Cs->x > ((pMonitor->rcWork.right - pMonitor->rcWork.left) / 4) ||
1758 Cs->y > ((pMonitor->rcWork.bottom - pMonitor->rcWork.top) / 4))
1759 {
1760 /* reset counter and position */
1761 Cs->x = 0;
1762 Cs->y = 0;
1763 pMonitor->cWndStack = 0;
1764 }
1765 pMonitor->cWndStack++;
1766 }
1767 }
1768
1769 if (IS_DEFAULT(Cs->cx))
1770 {
1771 if (ProcessParams->WindowFlags & STARTF_USEPOSITION)
1772 {
1773 Cs->cx = ProcessParams->CountX;
1774 Cs->cy = ProcessParams->CountY;
1775 }
1776 else
1777 {
1778 Cs->cx = (pMonitor->rcWork.right - pMonitor->rcWork.left) * 3 / 4;
1779 Cs->cy = (pMonitor->rcWork.bottom - pMonitor->rcWork.top) * 3 / 4;
1780 }
1781 }
1782 /* neither x nor cx are default. Check the y values .
1783 * In the trace we see Outlook and Outlook Express using
1784 * cy set to CW_USEDEFAULT when opening the address book.
1785 */
1786 else if (IS_DEFAULT(Cs->cy))
1787 {
1788 TRACE("Strange use of CW_USEDEFAULT in nHeight\n");
1789 Cs->cy = (pMonitor->rcWork.bottom - pMonitor->rcWork.top) * 3 / 4;
1790 }
1791 }
1792 else
1793 {
1794 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1795 if(IS_DEFAULT(Cs->x))
1796 {
1797 Cs->x = 0;
1798 Cs->y = 0;
1799 }
1800 if(IS_DEFAULT(Cs->cx))
1801 {
1802 Cs->cx = 0;
1803 Cs->cy = 0;
1804 }
1805 }
1806
1807#undef IS_DEFAULT
1808}
SHORT cWndStack
Definition: monitor.h:22
RECT rcWork
Definition: monitor.h:19
HMONITOR hMonitor
Definition: win32.h:271
LONG bottom
Definition: windef.h:109
PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR hMonitor)
Definition: monitor.c:74
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
#define IS_DEFAULT(x)
#define STARTF_USEPOSITION
Definition: winbase.h:470
#define SM_CYSIZE
Definition: winuser.h:1003
#define SM_CXFRAME
Definition: winuser.h:1005
#define SM_CXSIZE
Definition: winuser.h:1002
#define SM_CYFRAME
Definition: winuser.h:1007
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by co_UserCreateWindowEx().

◆ IntFreeHwndList()

VOID FASTCALL IntFreeHwndList ( PWINDOWLIST  pwlTarget)

Definition at line 1473 of file window.c.

1474{
1475 PWINDOWLIST pwl, *ppwl;
1476
1477 for (ppwl = &gpwlList; *ppwl; ppwl = &(*ppwl)->pNextList)
1478 {
1479 if (*ppwl != pwlTarget)
1480 continue;
1481
1482 *ppwl = pwlTarget->pNextList;
1483
1484 if (gpwlCache)
1485 {
1486 if (WL_CAPACITY(pwlTarget) > WL_CAPACITY(gpwlCache))
1487 {
1488 pwl = gpwlCache;
1489 gpwlCache = pwlTarget;
1491 }
1492 else
1493 {
1495 }
1496 }
1497 else
1498 {
1499 gpwlCache = pwlTarget;
1500 }
1501
1502 break;
1503 }
1504}
#define WL_CAPACITY(pwl)
Definition: window.h:98

Referenced by ExitThreadCallback(), IntAssociateInputContextEx(), IntCheckImeShowStatus(), IntDestroyInputContext(), and IntImeWindowPosChanged().

◆ IntGetNonChildAncestor()

PWND FASTCALL IntGetNonChildAncestor ( PWND  pWnd)

Definition at line 353 of file window.c.

354{
355 while(pWnd && (pWnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
356 pWnd = pWnd->spwndParent;
357 return pWnd;
358}

Referenced by co_IntProcessMouseMessage(), co_IntSetActiveWindow(), and IntCreateWindow().

◆ IntGetParent()

PWND FASTCALL IntGetParent ( PWND  Wnd)

◆ IntGetWindow()

HWND FASTCALL IntGetWindow ( HWND  hWnd,
UINT  uCmd 
)

Definition at line 383 of file window.c.

385{
386 PWND Wnd, FoundWnd;
387 HWND Ret = NULL;
388
389 Wnd = ValidateHwndNoErr(hWnd);
390 if (!Wnd)
391 return NULL;
392
393 FoundWnd = NULL;
394 switch (uCmd)
395 {
396 case GW_OWNER:
397 if (Wnd->spwndOwner != NULL)
398 FoundWnd = Wnd->spwndOwner;
399 break;
400
401 case GW_HWNDFIRST:
402 if(Wnd->spwndParent != NULL)
403 {
404 FoundWnd = Wnd->spwndParent;
405 if (FoundWnd->spwndChild != NULL)
406 FoundWnd = FoundWnd->spwndChild;
407 }
408 break;
409 case GW_HWNDNEXT:
410 if (Wnd->spwndNext != NULL)
411 FoundWnd = Wnd->spwndNext;
412 break;
413
414 case GW_HWNDPREV:
415 if (Wnd->spwndPrev != NULL)
416 FoundWnd = Wnd->spwndPrev;
417 break;
418
419 case GW_CHILD:
420 if (Wnd->spwndChild != NULL)
421 FoundWnd = Wnd->spwndChild;
422 break;
423
424 case GW_HWNDLAST:
425 FoundWnd = Wnd;
426 while ( FoundWnd->spwndNext != NULL)
427 FoundWnd = FoundWnd->spwndNext;
428 break;
429
430 default:
432 break;
433 }
434
435 if (FoundWnd != NULL)
436 Ret = UserHMGetHandle(FoundWnd);
437 return Ret;
438}
struct _WND * spwndPrev
Definition: ntuser.h:712
struct _WND * spwndChild
Definition: ntuser.h:714
struct _WND * spwndNext
Definition: ntuser.h:711
#define ERROR_INVALID_GW_COMMAND
Definition: winerror.h:1269
#define GW_OWNER
Definition: winuser.h:777
#define GW_HWNDFIRST
Definition: winuser.h:775
#define GW_HWNDLAST
Definition: winuser.h:776
#define GW_HWNDNEXT
Definition: winuser.h:772
#define GW_HWNDPREV
Definition: winuser.h:773
#define GW_CHILD
Definition: winuser.h:774

Referenced by WinPosFixupFlags().

◆ IntGetWindowContextHelpId()

DWORD FASTCALL IntGetWindowContextHelpId ( PWND  pWnd)

Definition at line 440 of file window.c.

441{
442 DWORD HelpId;
443
444 do
445 {
447 if (!HelpId) break;
448 pWnd = IntGetParent(pWnd);
449 }
450 while (pWnd && pWnd->fnid != FNID_DESKTOP);
451 return HelpId;
452}
#define HandleToUlong(h)
Definition: basetsd.h:73
#define FNID_DESKTOP
Definition: ntuser.h:862
ATOM atomContextHelpIdProp
Definition: ntuser.h:1067
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46

Referenced by IntDefWindowProc().

◆ IntGetWindowObject()

PWND FASTCALL IntGetWindowObject ( HWND  hWnd)

Definition at line 75 of file window.c.

76{
78
79 if (!hWnd) return NULL;
80
82 if (Window)
83 Window->head.cLockObj++;
84
85 return Window;
86}

Referenced by co_UserFreeWindow(), IntHideDesktop(), and IntSetOwner().

◆ IntGetWindowProc()

WNDPROC FASTCALL IntGetWindowProc ( PWND  pWnd,
BOOL  Ansi 
)

Definition at line 783 of file window.c.

785{
786 INT i;
787 PCLS Class;
788 WNDPROC gcpd, Ret = 0;
789
791
792 Class = pWnd->pcls;
793
795 {
796 for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
797 {
798 if (GETPFNSERVER(i) == pWnd->lpfnWndProc)
799 {
800 if (Ansi)
801 Ret = GETPFNCLIENTA(i);
802 else
803 Ret = GETPFNCLIENTW(i);
804 }
805 }
806 return Ret;
807 }
808
809 if (Class->fnid == FNID_EDIT)
810 Ret = pWnd->lpfnWndProc;
811 else
812 {
813 Ret = pWnd->lpfnWndProc;
814
815 if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
816 {
817 if (Ansi)
818 {
819 if (GETPFNCLIENTW(Class->fnid) == pWnd->lpfnWndProc)
820 Ret = GETPFNCLIENTA(Class->fnid);
821 }
822 else
823 {
824 if (GETPFNCLIENTA(Class->fnid) == pWnd->lpfnWndProc)
825 Ret = GETPFNCLIENTW(Class->fnid);
826 }
827 }
828 if ( Ret != pWnd->lpfnWndProc)
829 return Ret;
830 }
831 if ( Ansi == !!(pWnd->state & WNDS_ANSIWINDOWPROC) )
832 return Ret;
833
834 gcpd = (WNDPROC)UserGetCPD(
835 pWnd,
837 (ULONG_PTR)Ret);
838
839 return (gcpd ? gcpd : Ret);
840}
ULONG_PTR FASTCALL UserGetCPD(PVOID pvClsWnd, GETCPD Flags, ULONG_PTR ProcIn)
Definition: callproc.c:107
#define ULONG_PTR
Definition: config.h:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FNID_SWITCH
Definition: ntuser.h:865
#define FNID_FIRST
Definition: ntuser.h:858
@ UserGetCPDU2A
Definition: ntuser.h:541
@ UserGetCPDWindow
Definition: ntuser.h:543
@ UserGetCPDA2U
Definition: ntuser.h:540
#define GETPFNSERVER(fnid)
Definition: ntuser.h:909
#define FNID_EDIT
Definition: ntuser.h:870
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231

Referenced by IntSetWindowProc().

◆ IntGrowHwndList()

BOOL FASTCALL IntGrowHwndList ( PWINDOWLIST ppwl)

Definition at line 1376 of file window.c.

1377{
1378 PWINDOWLIST pwlOld, pwlNew;
1379 SIZE_T ibOld, ibNew;
1380
1381#define GROW_COUNT 8
1382 pwlOld = *ppwl;
1383 ibOld = (LPBYTE)pwlOld->phwndLast - (LPBYTE)pwlOld;
1384 ibNew = ibOld + GROW_COUNT * sizeof(HWND);
1385#undef GROW_COUNT
1386 pwlNew = IntReAllocatePoolWithTag(PagedPool, pwlOld, ibOld, ibNew, USERTAG_WINDOWLIST);
1387 if (!pwlNew)
1388 return FALSE;
1389
1390 pwlNew->phwndLast = (HWND *)((LPBYTE)pwlNew + ibOld);
1391 pwlNew->phwndEnd = (HWND *)((LPBYTE)pwlNew + ibNew);
1392 *ppwl = pwlNew;
1393 return TRUE;
1394}
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define GROW_COUNT
PVOID FASTCALL IntReAllocatePoolWithTag(POOL_TYPE PoolType, PVOID pOld, SIZE_T cbOld, SIZE_T cbNew, ULONG Tag)
Definition: window.c:24

Referenced by IntPopulateHwndList().

◆ IntIsChildWindow()

BOOL FASTCALL IntIsChildWindow ( PWND  Parent,
PWND  BaseWindow 
)

Definition at line 930 of file window.c.

931{
933 do
934 {
935 if ( Window == NULL || (Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD )
936 return FALSE;
937
938 Window = Window->spwndParent;
939 }
940 while(Parent != Window);
941 return TRUE;
942}
struct tagBaseWindow BaseWindow

Referenced by co_IntFixCaret(), co_IntSetParent(), DceResetActiveDCEs(), IntGetPaintMessage(), and NC_DoNCPaint().

◆ IntIsTopLevelWindow()

BOOL FASTCALL IntIsTopLevelWindow ( PWND  pWnd)

Definition at line 361 of file window.c.

362{
363 if ( pWnd->spwndParent &&
364 pWnd->spwndParent == co_GetDesktopWindow(pWnd) ) return TRUE;
365 return FALSE;
366}

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntIsWindow()

◆ IntIsWindowVisible()

BOOL FASTCALL IntIsWindowVisible ( PWND  Wnd)

Definition at line 191 of file window.c.

192{
193 PWND Temp = Wnd;
194 for (;;)
195 {
196 if (!Temp) return TRUE;
197 if (!(Temp->style & WS_VISIBLE)) break;
198 if (Temp->style & WS_MINIMIZE && Temp != Wnd) break;
199 if (Temp->fnid == FNID_DESKTOP) return TRUE;
200 Temp = Temp->spwndParent;
201 }
202 return FALSE;
203}

Referenced by co_IntSendActivateMessages(), DefWndDoSizeMove(), DefWndPrint(), NC_DoNCPaint(), UserDrawCaptionBar(), and WinPosFixupFlags().

◆ IntLinkHwnd()

VOID FASTCALL IntLinkHwnd ( PWND  Wnd,
HWND  hWndPrev 
)

Definition at line 986 of file window.c.

987{
988 if (hWndPrev == HWND_NOTOPMOST)
989 {
990 if (!(Wnd->ExStyle & WS_EX_TOPMOST) && (Wnd->ExStyle2 & WS_EX2_LINKED))
991 return; /* nothing to do */
992 Wnd->ExStyle &= ~WS_EX_TOPMOST;
993 hWndPrev = HWND_TOP; /* fallback to the HWND_TOP case */
994 }
995
996 IntUnlinkWindow(Wnd); /* unlink it from the previous location */
997
998 if (hWndPrev == HWND_BOTTOM)
999 {
1000 /* Link in the bottom of the list */
1001 PWND WndInsertAfter;
1002
1003 WndInsertAfter = Wnd->spwndParent->spwndChild;
1004 while (WndInsertAfter && WndInsertAfter->spwndNext)
1005 {
1006 WndInsertAfter = WndInsertAfter->spwndNext;
1007 }
1008
1009 IntLinkWindow(Wnd, WndInsertAfter);
1010 Wnd->ExStyle &= ~WS_EX_TOPMOST;
1011 }
1012 else if (hWndPrev == HWND_TOPMOST)
1013 {
1014 /* Link in the top of the list */
1015 IntLinkWindow(Wnd, NULL);
1016 Wnd->ExStyle |= WS_EX_TOPMOST;
1017 }
1018 else if (hWndPrev == HWND_TOP)
1019 {
1020 /* Link it after the last topmost window */
1021 PWND WndInsertBefore;
1022
1023 WndInsertBefore = Wnd->spwndParent->spwndChild;
1024
1025 if (!(Wnd->ExStyle & WS_EX_TOPMOST)) /* put it above the first non-topmost window */
1026 {
1027 while (WndInsertBefore != NULL && WndInsertBefore->spwndNext != NULL)
1028 {
1029 if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST))
1030 break;
1031
1032 if (WndInsertBefore == Wnd->spwndOwner) /* keep it above owner */
1033 {
1034 Wnd->ExStyle |= WS_EX_TOPMOST;
1035 break;
1036 }
1037 WndInsertBefore = WndInsertBefore->spwndNext;
1038 }
1039 }
1040
1041 IntLinkWindow(Wnd, WndInsertBefore ? WndInsertBefore->spwndPrev : NULL);
1042 }
1043 else
1044 {
1045 /* Link it after hWndPrev */
1046 PWND WndInsertAfter;
1047
1048 WndInsertAfter = UserGetWindowObject(hWndPrev);
1049 /* Are we called with an erroneous handle */
1050 if (WndInsertAfter == NULL)
1051 {
1052 /* Link in a default position */
1053 IntLinkHwnd(Wnd, HWND_TOP);
1054 return;
1055 }
1056
1057 if (Wnd == WndInsertAfter)
1058 {
1059 ERR("Trying to link window 0x%p to itself\n", Wnd);
1060 ASSERT(WndInsertAfter != Wnd);
1061 // FIXME: IntUnlinkWindow(Wnd) was already called. Continuing as is seems wrong!
1062 }
1063 else
1064 {
1065 IntLinkWindow(Wnd, WndInsertAfter);
1066 }
1067
1068 /* Fix the WS_EX_TOPMOST flag */
1069 if (!(WndInsertAfter->ExStyle & WS_EX_TOPMOST))
1070 {
1071 Wnd->ExStyle &= ~WS_EX_TOPMOST;
1072 }
1073 else
1074 {
1075 if (WndInsertAfter->spwndNext &&
1076 (WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST))
1077 {
1078 Wnd->ExStyle |= WS_EX_TOPMOST;
1079 }
1080 }
1081 }
1082 Wnd->ExStyle2 |= WS_EX2_LINKED;
1083}
#define WS_EX2_LINKED
Definition: ntuser.h:676
VOID FASTCALL IntLinkWindow(PWND Wnd, PWND WndInsertAfter)
Definition: window.c:947
#define HWND_NOTOPMOST
Definition: winuser.h:1217

Referenced by co_IntSetParent(), co_UserCreateWindowEx(), co_WinPosSetWindowPos(), IntImeSetTopMost(), and IntLinkHwnd().

◆ IntLinkWindow()

VOID FASTCALL IntLinkWindow ( PWND  Wnd,
PWND  WndInsertAfter 
)

Definition at line 947 of file window.c.

951{
952 if (Wnd == WndInsertAfter)
953 {
954 ERR("Trying to link window 0x%p to itself\n", Wnd);
955 ASSERT(WndInsertAfter != Wnd);
956 return;
957 }
958
959 WndSetPrev(Wnd, WndInsertAfter);
960 if (Wnd->spwndPrev)
961 {
962 /* Link after WndInsertAfter */
963 ASSERT(Wnd != WndInsertAfter->spwndNext);
964 WndSetNext(Wnd, WndInsertAfter->spwndNext);
965 if (Wnd->spwndNext)
966 WndSetPrev(Wnd->spwndNext, Wnd);
967
968 ASSERT(Wnd != Wnd->spwndPrev);
969 WndSetNext(Wnd->spwndPrev, Wnd);
970 }
971 else
972 {
973 /* Link at the top */
974 ASSERT(Wnd != Wnd->spwndParent->spwndChild);
975 WndSetNext(Wnd, Wnd->spwndParent->spwndChild);
976 if (Wnd->spwndNext)
977 WndSetPrev(Wnd->spwndNext, Wnd);
978
979 WndSetChild(Wnd->spwndParent, Wnd);
980 }
981}
static VOID WndSetPrev(_Inout_ PWND pwnd, _In_opt_ PWND pwndPrev)
Definition: window.h:178
static VOID WndSetNext(_Inout_ PWND pwnd, _In_opt_ PWND pwndNext)
Definition: window.h:171

Referenced by IntLinkHwnd().

◆ IntPopulateHwndList()

PWINDOWLIST FASTCALL IntPopulateHwndList ( PWINDOWLIST  pwl,
PWND  pwnd,
DWORD  dwFlags 
)

Definition at line 1397 of file window.c.

1398{
1399 ASSERT(!WL_IS_BAD(pwl));
1400
1401 for (; pwnd; pwnd = pwnd->spwndNext)
1402 {
1403 if (!pwl->pti || pwl->pti == pwnd->head.pti)
1404 {
1405 *(pwl->phwndLast) = UserHMGetHandle(pwnd);
1406 ++(pwl->phwndLast);
1407
1408 if (pwl->phwndLast == pwl->phwndEnd && !IntGrowHwndList(&pwl))
1409 break;
1410 }
1411
1412 if ((dwFlags & IACE_CHILDREN) && pwnd->spwndChild)
1413 {
1414 pwl = IntPopulateHwndList(pwl, pwnd->spwndChild, IACE_CHILDREN | IACE_LIST);
1415 if (WL_IS_BAD(pwl))
1416 break;
1417 }
1418
1419 if (!(dwFlags & IACE_LIST))
1420 break;
1421 }
1422
1423 return pwl;
1424}
BOOL FASTCALL IntGrowHwndList(PWINDOWLIST *ppwl)
Definition: window.c:1376
#define IACE_LIST
Definition: window.h:106

Referenced by IntBuildHwndList(), and IntPopulateHwndList().

◆ IntProcessOwnerSwap()

VOID FASTCALL IntProcessOwnerSwap ( PWND  Wnd,
PWND  WndNewOwner,
PWND  WndOldOwner 
)

Definition at line 1086 of file window.c.

1087{
1088 if (WndOldOwner)
1089 {
1090 if (Wnd->head.pti != WndOldOwner->head.pti)
1091 {
1092 if (!WndNewOwner ||
1093 Wnd->head.pti == WndNewOwner->head.pti ||
1094 WndOldOwner->head.pti != WndNewOwner->head.pti )
1095 {
1096 //ERR("ProcessOwnerSwap Old out.\n");
1097 UserAttachThreadInput(Wnd->head.pti, WndOldOwner->head.pti, FALSE);
1098 }
1099 }
1100 }
1101 if (WndNewOwner)
1102 {
1103 if (Wnd->head.pti != WndNewOwner->head.pti)
1104 {
1105 if (!WndOldOwner ||
1106 WndOldOwner->head.pti != WndNewOwner->head.pti )
1107 {
1108 //ERR("ProcessOwnerSwap New in.\n");
1109 UserAttachThreadInput(Wnd->head.pti, WndNewOwner->head.pti, TRUE);
1110 }
1111 }
1112 }
1113 // FIXME: System Tray checks.
1114}

Referenced by IntSetOwner().

◆ IntReAllocatePoolWithTag()

PVOID FASTCALL IntReAllocatePoolWithTag ( POOL_TYPE  PoolType,
PVOID  pOld,
SIZE_T  cbOld,
SIZE_T  cbNew,
ULONG  Tag 
)

Definition at line 24 of file window.c.

30{
32 if (!pNew)
33 return NULL;
34
35 RtlCopyMemory(pNew, pOld, min(cbOld, cbNew));
37 return pNew;
38}
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3821

Referenced by IntGrowHwndList().

◆ IntRemoveTrackMouseEvent()

VOID FASTCALL IntRemoveTrackMouseEvent ( PDESKTOP  pDesk)

Definition at line 355 of file mouse.c.

357{
358 /* Generate a leave message */
359 if (pDesk->dwDTFlags & DF_TME_LEAVE)
360 {
361 UINT uMsg = (pDesk->htEx != HTCLIENT) ? WM_NCMOUSELEAVE : WM_MOUSELEAVE;
362 UserPostMessage(UserHMGetHandle(pDesk->spwndTrack), uMsg, 0, 0);
363 }
364 /* Kill the timer */
365 if (pDesk->dwDTFlags & DF_TME_HOVER)
367
368 /* Reset state */
370 pDesk->spwndTrack = NULL;
371}
#define WM_MOUSELEAVE
Definition: commctrl.h:4992
PWND spwndTrack
Definition: desktop.h:31
DWORD htEx
Definition: desktop.h:32
DWORD dwDTFlags
Definition: desktop.h:12
#define DF_TME_LEAVE
Definition: desktop.h:48
#define DF_TME_HOVER
Definition: desktop.h:47
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1395
BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer)
Definition: timer.c:579
#define ID_EVENT_SYSTIMER_MOUSEHOVER
Definition: timer.h:27
#define HTCLIENT
Definition: winuser.h:2511
#define WM_NCMOUSELEAVE
Definition: winuser.h:1870

Referenced by IntSendDestroyMsg().

◆ IntSendDestroyMsg()

static void IntSendDestroyMsg ( HWND  hWnd)
static

Definition at line 463 of file window.c.

464{
465 PTHREADINFO ti;
466 PWND Window;
467
470
471 if (Window)
472 {
473 /*
474 * Look whether the focus is within the tree of windows
475 * we will be destroying.
476 */
477 // Rule #1
478 if ( ti->MessageQueue->spwndActive == Window || // Fixes CORE-106 RegSvr32 exit and return focus to CMD.
479 (ti->MessageQueue->spwndActive == NULL && ti->MessageQueue == IntGetFocusMessageQueue()) )
480 {
482 }
483
484 /* Fixes CMD properties closing and returning focus to CMD */
485 if (ti->MessageQueue->spwndFocus == Window)
486 {
487 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
488 {
489 co_UserSetFocus(Window->spwndParent);
490 }
491 else
492 {
494 }
495 }
496
497 if (ti->MessageQueue->CaretInfo.hWnd == UserHMGetHandle(Window))
498 {
500 }
501
502 /* If the window being destroyed is currently tracked... */
503 if (ti->rpdesk && ti->rpdesk->spwndTrack == Window)
504 {
506 }
507 }
508
509 /* If the window being destroyed is the current clipboard owner... */
510 if (ti->ppi->prpwinsta != NULL && Window == ti->ppi->prpwinsta->spwndClipOwner)
511 {
512 /* ... make it release the clipboard */
514 }
515
516 /* Send the WM_DESTROY to the window */
518
519 /*
520 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
521 * make sure that the window still exists when we come back.
522 */
523 if (IntIsWindow(hWnd))
524 {
525 HWND* pWndArray;
526 int i;
527
528 if (!(pWndArray = IntWinListChildren( Window ))) return;
529
530 for (i = 0; pWndArray[i]; i++)
531 {
532 if (IntIsWindow( pWndArray[i] )) IntSendDestroyMsg( pWndArray[i] );
533 }
535 }
536 else
537 {
538 TRACE("destroyed itself while in WM_DESTROY!\n");
539 }
540}
VOID FASTCALL co_WinPosActivateOtherWindow(PWND Wnd)
Definition: winpos.c:397
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:267
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
BOOL FASTCALL co_IntDestroyCaret(PTHREADINFO Win32Thread)
Definition: caret.c:159
VOID FASTCALL UserClipboardRelease(PWND pWindow)
Definition: clipboard.c:374
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1324
VOID FASTCALL IntRemoveTrackMouseEvent(PDESKTOP pDesk)
Definition: mouse.c:355

Referenced by co_UserDestroyWindow(), and IntSendDestroyMsg().

◆ IntSendParentNotify()

static void IntSendParentNotify ( PWND  pWindow,
UINT  msg 
)
static

Definition at line 1695 of file window.c.

1696{
1697 PWND Parent;
1698
1699 if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD &&
1700 !(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY))
1701 {
1702 Parent = pWindow->spwndParent;
1704 {
1706 UserRefObjectCo(Parent, &Ref);
1709 MAKEWPARAM( msg, pWindow->IDMenu),
1710 (LPARAM)UserHMGetHandle(pWindow) );
1712 }
1713 }
1714}
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:88
#define MAKEWPARAM(l, h)
Definition: winuser.h:4111
#define WM_PARENTNOTIFY
Definition: winuser.h:1831

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntSetOwner()

static HWND FASTCALL IntSetOwner ( HWND  hWnd,
HWND  hWndNewOwner 
)
static

Definition at line 1118 of file window.c.

1119{
1120 PWND Wnd, WndOldOwner, WndNewOwner;
1121 HWND ret;
1122
1123 Wnd = IntGetWindowObject(hWnd);
1124 if(!Wnd)
1125 return NULL;
1126
1127 WndOldOwner = Wnd->spwndOwner;
1128
1129 ret = WndOldOwner ? UserHMGetHandle(WndOldOwner) : 0;
1130 WndNewOwner = UserGetWindowObject(hWndNewOwner);
1131
1132 if (!WndNewOwner && hWndNewOwner)
1133 {
1135 ret = NULL;
1136 goto Error;
1137 }
1138
1139 /* if parent belongs to a different thread and the window isn't */
1140 /* top-level, attach the two threads */
1141 IntProcessOwnerSwap(Wnd, WndNewOwner, WndOldOwner);
1142
1143 if (IntValidateOwnerDepth(Wnd, WndNewOwner))
1144 {
1145 WndSetOwner(Wnd, WndNewOwner);
1146 }
1147 else
1148 {
1149 IntProcessOwnerSwap(Wnd, WndOldOwner, WndNewOwner);
1151 ret = NULL;
1152 }
1153Error:
1155 return ret;
1156}
VOID FASTCALL IntProcessOwnerSwap(PWND Wnd, PWND WndNewOwner, PWND WndOldOwner)
Definition: window.c:1086

Referenced by co_IntSetWindowLongPtr().

◆ IntSetStyle()

ULONG FASTCALL IntSetStyle ( PWND  pwnd,
ULONG  set_bits,
ULONG  clear_bits 
)

Definition at line 145 of file window.c.

146{
147 ULONG styleOld, styleNew;
148 styleOld = pwnd->style;
149 styleNew = (pwnd->style | set_bits) & ~clear_bits;
150 if (styleNew == styleOld) return styleNew;
151 pwnd->style = styleNew;
152 if ((styleOld ^ styleNew) & WS_VISIBLE) // State Change.
153 {
154 if (styleOld & WS_VISIBLE) pwnd->head.pti->cVisWindows--;
155 if (styleNew & WS_VISIBLE) pwnd->head.pti->cVisWindows++;
156 DceResetActiveDCEs( pwnd );
157 }
158 return styleOld;
159}

Referenced by co_UserCreateWindowEx(), co_UserShowScrollBar(), co_WinPosMinMaximize(), co_WinPosShowWindow(), DefWndDoSizeMove(), IntDefWindowProc(), IntEnableWindow(), and IntForceMinimizeWindow().

◆ IntSetWindowProc()

static WNDPROC IntSetWindowProc ( PWND  pWnd,
WNDPROC  NewWndProc,
BOOL  Ansi 
)
static

Definition at line 843 of file window.c.

846{
847 INT i;
848 PCALLPROCDATA CallProc;
849 PCLS Class;
850 WNDPROC Ret, chWndProc = NULL;
851
852 // Retrieve previous window proc.
853 Ret = IntGetWindowProc(pWnd, Ansi);
854
855 Class = pWnd->pcls;
856
857 if (IsCallProcHandle(NewWndProc))
858 {
859 CallProc = UserGetObject(gHandleTable, NewWndProc, TYPE_CALLPROC);
860 if (CallProc)
861 { // Reset new WndProc.
862 NewWndProc = CallProc->pfnClientPrevious;
863 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
864 Ansi = !!(CallProc->wType & UserGetCPDU2A);
865 }
866 }
867 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
868 for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
869 {
870 if (GETPFNCLIENTW(i) == NewWndProc)
871 {
872 chWndProc = GETPFNSERVER(i);
873 break;
874 }
875 if (GETPFNCLIENTA(i) == NewWndProc)
876 {
877 chWndProc = GETPFNSERVER(i);
878 break;
879 }
880 }
881 // If match, set/reset to Server Side and clear ansi.
882 if (chWndProc)
883 {
884 pWnd->lpfnWndProc = chWndProc;
885 pWnd->Unicode = TRUE;
886 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
888 }
889 else
890 {
891 pWnd->Unicode = !Ansi;
892 // Handle the state change in here.
893 if (Ansi)
894 pWnd->state |= WNDS_ANSIWINDOWPROC;
895 else
896 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
897
899 pWnd->state &= ~WNDS_SERVERSIDEWINDOWPROC;
900
901 if (!NewWndProc) NewWndProc = pWnd->lpfnWndProc;
902
903 if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
904 {
905 if (Ansi)
906 {
907 if (GETPFNCLIENTW(Class->fnid) == NewWndProc)
908 chWndProc = GETPFNCLIENTA(Class->fnid);
909 }
910 else
911 {
912 if (GETPFNCLIENTA(Class->fnid) == NewWndProc)
913 chWndProc = GETPFNCLIENTW(Class->fnid);
914 }
915 }
916 // Now set the new window proc.
917 pWnd->lpfnWndProc = (chWndProc ? chWndProc : NewWndProc);
918 }
919 return Ret;
920}
GETCPD wType
Definition: ntuser.h:553
WNDPROC FASTCALL IntGetWindowProc(PWND pWnd, BOOL Ansi)
Definition: window.c:783

Referenced by co_IntSetWindowLongPtr().

◆ IntShowOwnedPopups()

BOOL FASTCALL IntShowOwnedPopups ( PWND  OwnerWnd,
BOOL  fShow 
)

Definition at line 4670 of file window.c.

4671{
4672 int count = 0;
4673 PWND pWnd;
4674 HWND *win_array;
4675
4676// ASSERT(OwnerWnd);
4677
4678 TRACE("Enter ShowOwnedPopups Show: %s\n", (fShow ? "TRUE" : "FALSE"));
4679
4680 /* NOTE: Popups are not children */
4681 win_array = IntWinListOwnedPopups(OwnerWnd);
4682
4683 if (!win_array)
4684 return TRUE;
4685
4686 while (win_array[count])
4687 count++;
4688 while (--count >= 0)
4689 {
4690 if (!(pWnd = ValidateHwndNoErr( win_array[count] )))
4691 continue;
4692 ASSERT(pWnd->spwndOwner == OwnerWnd);
4693
4694 if (fShow)
4695 {
4696 if (pWnd->state & WNDS_HIDDENPOPUP)
4697 {
4698 /* In Windows, ShowOwnedPopups(TRUE) generates
4699 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4700 * regardless of the state of the owner
4701 */
4703 pWnd->state &= ~WNDS_HIDDENPOPUP;
4704 continue;
4705 }
4706 }
4707 else
4708 {
4709 if (pWnd->style & WS_VISIBLE)
4710 {
4711 /* In Windows, ShowOwnedPopups(FALSE) generates
4712 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4713 * regardless of the state of the owner
4714 */
4716 pWnd->state |= WNDS_HIDDENPOPUP;
4717 continue;
4718 }
4719 }
4720 }
4722 TRACE("Leave ShowOwnedPopups\n");
4723 return TRUE;
4724}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WNDS_HIDDENPOPUP
Definition: ntuser.h:619
#define WM_SHOWWINDOW
Definition: winuser.h:1656
#define SW_PARENTCLOSING
Definition: winuser.h:2478
#define SW_PARENTOPENING
Definition: winuser.h:2480

Referenced by co_WinPosMinMaximize(), co_WinPosShowWindow(), DefWndHandleSysCommand(), and NtUserCallTwoParam().

◆ IntUnlinkWindow()

VOID FASTCALL IntUnlinkWindow ( PWND  Wnd)

Definition at line 1357 of file window.c.

1358{
1359 ASSERT(Wnd != Wnd->spwndNext);
1360 ASSERT(Wnd != Wnd->spwndPrev);
1361
1362 if (Wnd->spwndNext)
1363 WndSetPrev(Wnd->spwndNext, Wnd->spwndPrev);
1364
1365 if (Wnd->spwndPrev)
1366 WndSetNext(Wnd->spwndPrev, Wnd->spwndNext);
1367
1368 if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
1369 WndSetChild(Wnd->spwndParent, Wnd->spwndNext);
1370
1371 WndSetPrev(Wnd, NULL);
1372 WndSetNext(Wnd, NULL);
1373}

Referenced by co_IntSetParent(), co_UserFreeWindow(), IntImeSetTopMost(), and IntLinkHwnd().

◆ IntValidateOwnerDepth()

BOOL FASTCALL IntValidateOwnerDepth ( PWND  Wnd,
PWND  Owner 
)

Definition at line 369 of file window.c.

370{
371 INT Depth = 1;
372 for (;;)
373 {
374 if ( !Owner ) return gNestedWindowLimit >= Depth;
375 if (Owner == Wnd) break;
376 Owner = Owner->spwndOwner;
377 Depth++;
378 }
379 return FALSE;
380}
INT gNestedWindowLimit
Definition: window.c:16
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by IntCreateWindow(), and IntSetOwner().

◆ IntWinListChildren()

HWND *FASTCALL IntWinListChildren ( PWND  Window)

Definition at line 276 of file window.c.

277{
278 PWND Child;
279 HWND *List;
280 UINT Index, NumChildren = 0;
281
282 if (!Window) return NULL;
283
284 for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
285 {
286 ++NumChildren;
287 }
288
289 List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
290 if(!List)
291 {
292 ERR("Failed to allocate memory for children array\n");
294 return NULL;
295 }
296
297 Index = 0;
298 for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
299 {
301 }
302 List[Index] = NULL;
303
304 return List;
305}

Referenced by co_IntPaintWindows(), co_IntSendActivateMessages(), co_IntSendMessageTimeout(), co_UserFreeWindow(), co_WinPosSearchChildren(), IntChildWindowFromPointEx(), IntClientShutdown(), IntDeactivateWindow(), IntFindWindow(), IntRealChildWindowFromPoint(), IntSendDestroyMsg(), NtUserBuildHwndList(), NtUserFindWindowEx(), NtUserMessageCall(), SpiNotifyNCMetricsChanged(), UserPostMessage(), UserRegisterUserApiHook(), UserSendNotifyMessage(), and WinPosDoOwnedPopups().

◆ IntWinListOwnedPopups()

HWND *FASTCALL IntWinListOwnedPopups ( PWND  Window)

Definition at line 317 of file window.c.

318{
320 HWND *List;
321 UINT Index, NumOwned = 0;
322
324 if (!Desktop)
325 return NULL;
326
327 for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
328 {
329 if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
330 ++NumOwned;
331 }
332
333 List = ExAllocatePoolWithTag(PagedPool, (NumOwned + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
334 if (!List)
335 {
336 ERR("Failed to allocate memory for children array\n");
338 return NULL;
339 }
340
341 Index = 0;
342 for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
343 {
344 if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
346 }
347 List[Index] = NULL;
348
349 return List;
350}
static BOOL IntWndIsDefaultIme(_In_ PWND Window)
Definition: window.c:308

Referenced by IntDestroyOwnedWindows(), and IntShowOwnedPopups().

◆ IntWndIsDefaultIme()

static BOOL IntWndIsDefaultIme ( _In_ PWND  Window)
static

Definition at line 308 of file window.c.

309{
310 PTHREADINFO pti = Window->head.pti;
311
312 return (IS_IMM_MODE() && !(pti->TIF_flags & TIF_INCLEANUP) &&
313 Window == pti->spwndDefaultIme);
314}

Referenced by IntWinListOwnedPopups().

◆ NtUserAlterWindowStyle()

DWORD APIENTRY NtUserAlterWindowStyle ( HWND  hWnd,
DWORD  Index,
LONG  NewValue 
)

Definition at line 4108 of file window.c.

4109{
4110 LONG ret;
4111
4113
4114 if (hWnd == IntGetDesktopWindow())
4115 {
4117 UserLeave();
4118 return 0;
4119 }
4120
4121 ret = co_IntSetWindowLongPtr(hWnd, Index, NewValue, FALSE, sizeof(LONG), TRUE);
4122
4123 UserLeave();
4124
4125 return ret;
4126}
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249

Referenced by ButtonWndProc_common().

◆ NtUserBuildHwndList()

NTSTATUS NTAPI NtUserBuildHwndList ( HDESK  hDesktop,
HWND  hwndParent,
BOOLEAN  bChildren,
ULONG  dwThreadId,
ULONG  cHwnd,
HWND phwndList,
ULONG pcHwndNeeded 
)

Definition at line 1521 of file window.c.

1529{
1531 ULONG dwCount = 0;
1532
1533 if (pcHwndNeeded == NULL)
1535
1537
1538 if (hwndParent || !dwThreadId)
1539 {
1542
1543 if(!hwndParent)
1544 {
1545 if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop()))
1546 {
1548 goto Quit;
1549 }
1550
1551 if(hDesktop)
1552 {
1554 UserMode,
1555 0,
1556 &Desktop);
1557 if(!NT_SUCCESS(Status))
1558 {
1560 goto Quit;
1561 }
1562 }
1563 hwndParent = Desktop->DesktopWindow;
1564 }
1565 else
1566 {
1567 hDesktop = 0;
1568 }
1569
1571 (Window = Parent->spwndChild))
1572 {
1573 BOOL bGoDown = TRUE;
1574
1576 while(TRUE)
1577 {
1578 if (bGoDown)
1579 {
1580 if (dwCount++ < cHwnd && phwndList)
1581 {
1582 _SEH2_TRY
1583 {
1584 ProbeForWrite(phwndList, sizeof(HWND), 1);
1585 *phwndList = UserHMGetHandle(Window);
1586 phwndList++;
1587 }
1589 {
1591 }
1592 _SEH2_END
1593 if(!NT_SUCCESS(Status))
1594 {
1595 break;
1596 }
1597 }
1598 if (Window->spwndChild && bChildren)
1599 {
1600 Window = Window->spwndChild;
1601 continue;
1602 }
1603 bGoDown = FALSE;
1604 }
1605 if (Window->spwndNext)
1606 {
1607 Window = Window->spwndNext;
1608 bGoDown = TRUE;
1609 continue;
1610 }
1611 Window = Window->spwndParent;
1612 if (Window == Parent)
1613 {
1614 break;
1615 }
1616 }
1617 }
1618
1619 if(hDesktop)
1620 {
1622 }
1623 }
1624 else // Build EnumThreadWindows list!
1625 {
1627 PTHREADINFO W32Thread;
1628 PWND Window;
1629 HWND *List = NULL;
1630
1632 if (!NT_SUCCESS(Status))
1633 {
1634 ERR("Thread Id is not valid!\n");
1636 goto Quit;
1637 }
1638 if (!(W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread))
1639 {
1641 TRACE("Tried to enumerate windows of a non gui thread\n");
1643 goto Quit;
1644 }
1645
1646 // Do not use Thread link list due to co_UserFreeWindow!!!
1647 // Current = W32Thread->WindowListHead.Flink;
1648 // Fixes Api:CreateWindowEx tests!!!
1650 if (List)
1651 {
1652 int i;
1653 for (i = 0; List[i]; i++)
1654 {
1656 if (Window && Window->head.pti == W32Thread)
1657 {
1658 if (dwCount < cHwnd && phwndList)
1659 {
1660 _SEH2_TRY
1661 {
1662 ProbeForWrite(phwndList, sizeof(HWND), 1);
1663 *phwndList = UserHMGetHandle(Window);
1664 phwndList++;
1665 }
1667 {
1669 }
1670 _SEH2_END
1671 if (!NT_SUCCESS(Status))
1672 {
1673 ERR("Failure to build window list!\n");
1674 break;
1675 }
1676 }
1677 dwCount++;
1678 }
1679 }
1681 }
1682
1684 }
1685
1686 *pcHwndNeeded = dwCount;
1688
1689Quit:
1691 UserLeave();
1692 return Status;
1693}
LONG NTSTATUS
Definition: precomp.h:26
static HWND hwndParent
Definition: cryptui.c:300
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
DWORD dwThreadId
Definition: fdebug.c:31
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define UserMode
Definition: asm.h:39
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:643
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
KTHREAD Tcb
Definition: pstypes.h:1192
PVOID Win32Thread
Definition: ketypes.h:1994
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1279
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1403
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1254

Referenced by enum_windows(), User32EnumWindows(), and WIN_ListChildren().

◆ NtUserCreateWindowEx()

HWND NTAPI NtUserCreateWindowEx ( DWORD  dwExStyle,
PLARGE_STRING  plstrClassName,
PLARGE_STRING  plstrClsVersion,
PLARGE_STRING  plstrWindowName,
DWORD  dwStyle,
int  x,
int  y,
int  nWidth,
int  nHeight,
HWND  hWndParent,
HMENU  hMenu,
HINSTANCE  hInstance,
LPVOID  lpParam,
DWORD  dwFlags,
PVOID  acbiBuffer 
)
Todo:
Allow passing plstrClassName as ANSI.

Definition at line 2686 of file window.c.

2702{
2704 LARGE_STRING lstrWindowName;
2705 LARGE_STRING lstrClassName;
2706 LARGE_STRING lstrClsVersion;
2707 UNICODE_STRING ustrClassName;
2708 UNICODE_STRING ustrClsVersion;
2709 CREATESTRUCTW Cs;
2710 HWND hwnd = NULL;
2711 PWND pwnd;
2712
2713 lstrWindowName.Buffer = NULL;
2714 lstrClassName.Buffer = NULL;
2715 lstrClsVersion.Buffer = NULL;
2716
2717 if ( (dwStyle & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2718 {
2719 /* check hMenu is valid handle */
2720 if (hMenu && !UserGetMenuObject(hMenu))
2721 {
2722 ERR("NtUserCreateWindowEx: Got an invalid menu handle!\n");
2724 return NULL;
2725 }
2726 }
2727
2728 /* Copy the window name to kernel mode */
2729 Status = ProbeAndCaptureLargeString(&lstrWindowName, plstrWindowName);
2730 if (!NT_SUCCESS(Status))
2731 {
2732 ERR("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2734 return NULL;
2735 }
2736
2737 plstrWindowName = &lstrWindowName;
2738
2739 /* Check if the class is an atom */
2740 if (IS_ATOM(plstrClassName))
2741 {
2742 /* It is, pass the atom in the UNICODE_STRING */
2743 ustrClassName.Buffer = (PVOID)plstrClassName;
2744 ustrClassName.Length = 0;
2745 ustrClassName.MaximumLength = 0;
2746 }
2747 else
2748 {
2749 /* It's not, capture the class name */
2750 Status = ProbeAndCaptureLargeString(&lstrClassName, plstrClassName);
2751 if (!NT_SUCCESS(Status))
2752 {
2753 ERR("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2754 /* Set last error, cleanup and return */
2756 goto cleanup;
2757 }
2758
2759 /* We pass it on as a UNICODE_STRING */
2760 ustrClassName.Buffer = lstrClassName.Buffer;
2761 ustrClassName.Length = (USHORT)min(lstrClassName.Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
2762 ustrClassName.MaximumLength = (USHORT)min(lstrClassName.MaximumLength, MAXUSHORT);
2763 }
2764
2765 /* Check if the class version is an atom */
2766 if (IS_ATOM(plstrClsVersion))
2767 {
2768 /* It is, pass the atom in the UNICODE_STRING */
2769 ustrClsVersion.Buffer = (PVOID)plstrClsVersion;
2770 ustrClsVersion.Length = 0;
2771 ustrClsVersion.MaximumLength = 0;
2772 }
2773 else
2774 {
2775 /* It's not, capture the class name */
2776 Status = ProbeAndCaptureLargeString(&lstrClsVersion, plstrClsVersion);
2777 if (!NT_SUCCESS(Status))
2778 {
2779 ERR("NtUserCreateWindowEx: failed to capture plstrClsVersion\n");
2780 /* Set last error, cleanup and return */
2782 goto cleanup;
2783 }
2784
2785 /* We pass it on as a UNICODE_STRING */
2786 ustrClsVersion.Buffer = lstrClsVersion.Buffer;
2787 ustrClsVersion.Length = (USHORT)min(lstrClsVersion.Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
2788 ustrClsVersion.MaximumLength = (USHORT)min(lstrClsVersion.MaximumLength, MAXUSHORT);
2789 }
2790
2791 /* Fill the CREATESTRUCTW */
2792 /* we will keep here the original parameters */
2793 Cs.style = dwStyle;
2794 Cs.lpCreateParams = lpParam;
2795 Cs.hInstance = hInstance;
2796 Cs.hMenu = hMenu;
2798 Cs.cx = nWidth;
2799 Cs.cy = nHeight;
2800 Cs.x = x;
2801 Cs.y = y;
2802 Cs.lpszName = (LPCWSTR) plstrWindowName->Buffer;
2803 Cs.lpszClass = ustrClassName.Buffer;
2804 Cs.dwExStyle = dwExStyle;
2805
2807
2808 /* Call the internal function */
2809 pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer, dwFlags);
2810
2811 if(!pwnd)
2812 {
2813 ERR("co_UserCreateWindowEx failed!\n");
2814 }
2815 hwnd = pwnd ? UserHMGetHandle(pwnd) : NULL;
2816
2817 UserLeave();
2818
2819cleanup:
2820 if (lstrWindowName.Buffer)
2821 {
2822 ExFreePoolWithTag(lstrWindowName.Buffer, TAG_STRING);
2823 }
2824 if (lstrClassName.Buffer)
2825 {
2826 ExFreePoolWithTag(lstrClassName.Buffer, TAG_STRING);
2827 }
2828 if (lstrClsVersion.Buffer)
2829 {
2830 ExFreePoolWithTag(lstrClsVersion.Buffer, TAG_STRING);
2831 }
2832
2833 return hwnd;
2834}
HINSTANCE hInstance
Definition: charmap.c:19
#define IS_ATOM(x)
Definition: class.h:3
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define TAG_STRING
Definition: oslist.h:22
ULONG MaximumLength
Definition: ntuser.h:92
LPVOID lpCreateParams
Definition: winuser.h:3057
void * PVOID
Definition: typedefs.h:50
PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer, DWORD dwVer)
Definition: window.c:2183
NTSTATUS NTAPI ProbeAndCaptureLargeString(OUT PLARGE_STRING plstrSafe, IN PLARGE_STRING plstrUnsafe)
Definition: window.c:2629
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:1227

Referenced by CreateWnd(), User32CreateWindowEx(), and WIN_CreateWindowEx().

◆ NtUserDefSetText()

BOOL APIENTRY NtUserDefSetText ( HWND  hWnd,
PLARGE_STRING  WindowText 
)

Definition at line 4474 of file window.c.

4475{
4476 PWND Wnd;
4477 LARGE_STRING SafeText;
4479 BOOL Ret = TRUE;
4480
4481 TRACE("Enter NtUserDefSetText\n");
4482
4483 if (WindowText != NULL)
4484 {
4485 _SEH2_TRY
4486 {
4487 SafeText = ProbeForReadLargeString(WindowText);
4488 }
4490 {
4491 Ret = FALSE;
4493 }
4494 _SEH2_END;
4495
4496 if (!Ret)
4497 return FALSE;
4498 }
4499 else
4500 return TRUE;
4501
4503
4504 if(!(Wnd = UserGetWindowObject(hWnd)))
4505 {
4506 UserLeave();
4507 return FALSE;
4508 }
4509
4510 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4511 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4512 // Now we know what the bAnsi is for.
4514 if (SafeText.Buffer)
4515 {
4516 _SEH2_TRY
4517 {
4518 if (SafeText.bAnsi)
4519 ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(CHAR));
4520 else
4521 ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(WCHAR));
4523 }
4525 {
4526 Ret = FALSE;
4528 }
4529 _SEH2_END;
4530 if (!Ret) goto Exit;
4531 }
4532
4533 if (UnicodeString.Length != 0)
4534 {
4535 if (Wnd->strName.MaximumLength > 0 &&
4536 UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4537 {
4538 ASSERT(Wnd->strName.Buffer != NULL);
4539
4540 Wnd->strName.Length = UnicodeString.Length;
4541 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4543 UnicodeString.Buffer,
4544 UnicodeString.Length);
4545 }
4546 else
4547 {
4548 PWCHAR buf;
4549 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4550 buf = Wnd->strName.Buffer;
4551 Wnd->strName.Buffer = NULL;
4552 if (buf != NULL)
4553 {
4555 }
4556
4558 UnicodeString.Length + sizeof(UNICODE_NULL));
4559 if (Wnd->strName.Buffer != NULL)
4560 {
4561 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4563 UnicodeString.Buffer,
4564 UnicodeString.Length);
4565 Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4566 Wnd->strName.Length = UnicodeString.Length;
4567 }
4568 else
4569 {
4571 Ret = FALSE;
4572 goto Exit;
4573 }
4574 }
4575 }
4576 else
4577 {
4578 Wnd->strName.Length = 0;
4579 if (Wnd->strName.Buffer != NULL)
4580 Wnd->strName.Buffer[0] = L'\0';
4581 }
4582
4583 // FIXME: HAX! Windows does not do this in here!
4584 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4585 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4586 /* Send shell notifications */
4587 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4588 {
4589 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) hWnd, FALSE); // FIXME Flashing?
4590 }
4591
4592 Ret = TRUE;
4593Exit:
4595 TRACE("Leave NtUserDefSetText, ret=%i\n", Ret);
4596 UserLeave();
4597 return Ret;
4598}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
BOOL NTAPI RtlLargeStringToUnicodeString(PUNICODE_STRING, PLARGE_STRING)
Definition: rtlstr.c:67
ULONG bAnsi
Definition: ntuser.h:93
char CHAR
Definition: xmlstorage.h:175

Referenced by DefSetText().

◆ NtUserDestroyWindow()

BOOLEAN APIENTRY NtUserDestroyWindow ( HWND  Wnd)

Definition at line 3057 of file window.c.

3058{
3059 PWND Window;
3060 BOOLEAN ret = FALSE;
3062
3063 TRACE("Enter NtUserDestroyWindow\n");
3065
3067 if (Window)
3068 {
3069 UserRefObjectCo(Window, &Ref); // FIXME: Dunno if win should be reffed during destroy...
3071 UserDerefObjectCo(Window); // FIXME: Dunno if win should be reffed during destroy...
3072 }
3073
3074 TRACE("Leave NtUserDestroyWindow, ret=%u\n", ret);
3075 UserLeave();
3076 return ret;
3077}

Referenced by DestroyWindow(), and User32DestroyImeUIWindow().

◆ NtUserFindWindowEx()

HWND APIENTRY NtUserFindWindowEx ( HWND  hwndParent,
HWND  hwndChildAfter,
PUNICODE_STRING  ucClassName,
PUNICODE_STRING  ucWindowName,
DWORD  dwUnknown 
)

Definition at line 3163 of file window.c.

3168{
3169 PWND Parent, ChildAfter;
3170 UNICODE_STRING ClassName = {0}, WindowName = {0};
3171 HWND Desktop, Ret = NULL;
3172 BOOL DoMessageWnd = FALSE;
3173 RTL_ATOM ClassAtom = (RTL_ATOM)0;
3174
3175 TRACE("Enter NtUserFindWindowEx\n");
3177
3178 if (ucClassName != NULL || ucWindowName != NULL)
3179 {
3180 _SEH2_TRY
3181 {
3182 if (ucClassName != NULL)
3183 {
3184 ClassName = ProbeForReadUnicodeString(ucClassName);
3185 if (ClassName.Length != 0)
3186 {
3187 ProbeForRead(ClassName.Buffer,
3188 ClassName.Length,
3189 sizeof(WCHAR));
3190 }
3191 else if (!IS_ATOM(ClassName.Buffer))
3192 {
3195 }
3196
3197 if (!IntGetAtomFromStringOrAtom(&ClassName,
3198 &ClassAtom))
3199 {
3202 }
3203 }
3204
3205 if (ucWindowName != NULL)
3206 {
3207 WindowName = ProbeForReadUnicodeString(ucWindowName);
3208 if (WindowName.Length != 0)
3209 {
3210 ProbeForRead(WindowName.Buffer,
3211 WindowName.Length,
3212 sizeof(WCHAR));
3213 }
3214 }
3215 }
3217 {
3219 _SEH2_YIELD(goto Exit); // Return NULL
3220 }
3221 _SEH2_END;
3222
3223 if (ucClassName != NULL)
3224 {
3225 if (ClassName.Length == 0 && ClassName.Buffer != NULL &&
3226 !IS_ATOM(ClassName.Buffer))
3227 {
3229 goto Exit; // Return NULL
3230 }
3231 else if (ClassAtom == (RTL_ATOM)0)
3232 {
3233 /* LastError code was set by IntGetAtomFromStringOrAtom */
3234 goto Exit; // Return NULL
3235 }
3236 }
3237 }
3238
3240
3241 if(hwndParent == NULL)
3242 {
3244 DoMessageWnd = TRUE;
3245 }
3246 else if(hwndParent == HWND_MESSAGE)
3247 {
3249 }
3250
3252 {
3253 goto Exit; // Return NULL
3254 }
3255
3256 ChildAfter = NULL;
3257 if(hwndChildAfter && !(ChildAfter = UserGetWindowObject(hwndChildAfter)))
3258 {
3259 goto Exit; // Return NULL
3260 }
3261
3262 _SEH2_TRY
3263 {
3265 {
3266 HWND *List, *phWnd;
3267 PWND TopLevelWindow;
3268 BOOLEAN CheckWindowName;
3269 BOOLEAN WindowMatches;
3270 BOOLEAN ClassMatches;
3271
3272 /* windows searches through all top-level windows if the parent is the desktop
3273 window */
3274
3276 {
3277 phWnd = List;
3278
3279 if(ChildAfter)
3280 {
3281 /* skip handles before and including ChildAfter */
3282 while(*phWnd && (*(phWnd++) != UserHMGetHandle(ChildAfter)))
3283 ;
3284 }
3285
3286 CheckWindowName = WindowName.Buffer != 0;
3287
3288 /* search children */
3289 while(*phWnd)
3290 {
3291 UNICODE_STRING ustr;
3292
3293 if(!(TopLevelWindow = UserGetWindowObject(*(phWnd++))))
3294 {
3295 continue;
3296 }
3297
3298 /* Do not send WM_GETTEXT messages in the kernel mode version!
3299 The user mode version however calls GetWindowText() which will
3300 send WM_GETTEXT messages to windows belonging to its processes */
3301 ustr.Buffer = TopLevelWindow->strName.Buffer;
3302 ustr.Length = (USHORT)min(TopLevelWindow->strName.Length, MAXUSHORT); // FIXME:LARGE_STRING truncated
3303 ustr.MaximumLength = (USHORT)min(TopLevelWindow->strName.MaximumLength, MAXUSHORT);
3304 WindowMatches = !CheckWindowName ||
3305 (TopLevelWindow->strName.Length < 0xFFFF &&
3306 !RtlCompareUnicodeString(&WindowName, &ustr, TRUE));
3307 ClassMatches = (ClassAtom == (RTL_ATOM)0) ||
3308 ClassAtom == TopLevelWindow->pcls->atomNVClassName;
3309
3310 if (WindowMatches && ClassMatches)
3311 {
3312 Ret = UserHMGetHandle(TopLevelWindow);
3313 break;
3314 }
3315
3316 if (IntFindWindow(TopLevelWindow, NULL, ClassAtom, &WindowName))
3317 {
3318 /* window returns the handle of the top-level window, in case it found
3319 the child window */
3320 Ret = UserHMGetHandle(TopLevelWindow);
3321 break;
3322 }
3323
3324 }
3326 }
3327 }
3328 else
3329 {
3330 TRACE("FindWindowEx: Not Desktop Parent!\n");
3331 Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
3332 }
3333
3334 if (Ret == NULL && DoMessageWnd)
3335 {
3336 PWND MsgWindows;
3337
3338 if((MsgWindows = UserGetWindowObject(IntGetMessageWindow())))
3339 {
3340 Ret = IntFindWindow(MsgWindows, ChildAfter, ClassAtom, &WindowName);
3341 }
3342 }
3343 }
3345 {
3347 Ret = NULL;
3348 }
3349 _SEH2_END;
3350
3351Exit:
3352 TRACE("Leave NtUserFindWindowEx, ret %p\n", Ret);
3353 UserLeave();
3354 return Ret;
3355}
unsigned short RTL_ATOM
Definition: atom.c:42
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
#define _SEH2_LEAVE
Definition: pseh2_64.h:183
#define ProbeForReadUnicodeString(Ptr)
Definition: probe.h:77
ATOM atomNVClassName
Definition: ntuser.h:569
HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
Definition: desktop.c:1438
HWND FASTCALL IntGetMessageWindow(VOID)
Definition: desktop.c:1415
HWND FASTCALL IntFindWindow(PWND Parent, PWND ChildAfter, RTL_ATOM ClassAtom, PUNICODE_STRING WindowName)
Definition: window.c:3081

Referenced by FindWindowExW(), and START_TEST().

◆ NtUserGetAncestor()

HWND APIENTRY NtUserGetAncestor ( _In_ HWND  hWnd,
_In_ UINT  uType 
)

Definition at line 3423 of file window.c.

3424{
3425 PWND Window, pwndAncestor;
3426 HWND hwndAncestor = NULL;
3427
3428 TRACE("Enter NtUserGetAncestor\n");
3430
3432 if (!Window)
3433 goto Quit;
3434
3435 if (!uType || uType > GA_ROOTOWNER)
3436 {
3438 goto Quit;
3439 }
3440
3441 pwndAncestor = UserGetAncestor(Window, uType);
3442 if (pwndAncestor)
3443 hwndAncestor = UserHMGetHandle(pwndAncestor);
3444
3445Quit:
3446 UserLeave();
3447 TRACE("Leave NtUserGetAncestor returning %p\n", hwndAncestor);
3448 return hwndAncestor;
3449}
PWND FASTCALL UserGetAncestor(_In_ PWND pWnd, _In_ UINT uType)
Definition: window.c:3359
#define GA_ROOTOWNER
Definition: winuser.h:2892

Referenced by GetAncestor().

◆ NtUserGetComboBoxInfo()

BOOL APIENTRY NtUserGetComboBoxInfo ( HWND  hWnd,
PCOMBOBOXINFO  pcbi 
)

Definition at line 3487 of file window.c.

3490{
3491 PWND Wnd;
3492 PPROCESSINFO ppi;
3493 BOOL NotSameppi = FALSE;
3494 BOOL Ret = TRUE;
3495
3496 TRACE("Enter NtUserGetComboBoxInfo\n");
3498
3499 if (!(Wnd = UserGetWindowObject(hWnd)))
3500 {
3501 Ret = FALSE;
3502 goto Exit;
3503 }
3504 _SEH2_TRY
3505 {
3506 ProbeForWrite(pcbi, sizeof(COMBOBOXINFO), 1);
3507 }
3509 {
3511 Ret = FALSE;
3512 _SEH2_YIELD(goto Exit);
3513 }
3514 _SEH2_END;
3515
3516 if (pcbi->cbSize < sizeof(COMBOBOXINFO))
3517 {
3519 Ret = FALSE;
3520 goto Exit;
3521 }
3522
3523 // Pass the user pointer, it was already probed.
3525 {
3527 goto Exit;
3528 }
3529
3531 NotSameppi = ppi != Wnd->head.pti->ppi;
3532 if (NotSameppi)
3533 {
3534 KeAttachProcess(&Wnd->head.pti->ppi->peProcess->Pcb);
3535 }
3536
3537 _SEH2_TRY
3538 {
3539 LPHEADCOMBO lphc = ((PWND2CBOX)Wnd)->pCBox;
3540 pcbi->rcItem = lphc->textRect;
3541 pcbi->rcButton = lphc->buttonRect;
3542 pcbi->stateButton = 0;
3543 if (lphc->wState & CBF_BUTTONDOWN)
3545 if (RECTL_bIsEmptyRect(&lphc->buttonRect))
3547 pcbi->hwndCombo = lphc->self;
3548 pcbi->hwndItem = lphc->hWndEdit;
3549 pcbi->hwndList = lphc->hWndLBox;
3550 }
3552 {
3553 Ret = FALSE;
3555 }
3556 _SEH2_END;
3557
3558Exit:
3559 if (NotSameppi) KeDetachProcess();
3560 TRACE("Leave NtUserGetComboBoxInfo, ret=%i\n", Ret);
3561 UserLeave();
3562 return Ret;
3563}
#define FNID_COMBOBOX
Definition: ntuser.h:867
#define BOOL
Definition: nt_native.h:43
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
RECT buttonRect
Definition: comctl32.h:158
RECT textRect
Definition: comctl32.h:157
UINT wState
Definition: comctl32.h:155
HWND hWndLBox
Definition: comctl32.h:154
HWND hWndEdit
Definition: comctl32.h:153
HWND self
Definition: comctl32.h:150
RTL_ATOM atomClassName
Definition: ntuser.h:568
DWORD stateButton
Definition: winuser.h:3814
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
struct _WND2CBOX * PWND2CBOX
#define CBF_BUTTONDOWN
Definition: window.c:3481
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2967
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1970
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2979

Referenced by GetComboBoxInfo().

◆ NtUserGetListBoxInfo()

DWORD APIENTRY NtUserGetListBoxInfo ( HWND  hWnd)

Definition at line 3598 of file window.c.

3600{
3601 PWND Wnd;
3602 PPROCESSINFO ppi;
3603 BOOL NotSameppi = FALSE;
3604 DWORD Ret = 0;
3605
3606 TRACE("Enter NtUserGetListBoxInfo\n");
3608
3609 if (!(Wnd = UserGetWindowObject(hWnd)))
3610 {
3611 goto Exit; // Return 0
3612 }
3613
3614 if ((Wnd->pcls->atomClassName != gpsi->atomSysClass[ICLS_LISTBOX]) && Wnd->fnid != FNID_LISTBOX)
3615 {
3616 Ret = (DWORD)co_IntSendMessage(UserHMGetHandle(Wnd), LB_GETLISTBOXINFO, 0, 0);
3617 goto Exit;
3618 }
3619
3620 // wine lisbox:test_GetListBoxInfo lb_getlistboxinfo = 0, should not send a message!
3622 NotSameppi = ppi != Wnd->head.pti->ppi;
3623 if (NotSameppi)
3624 {
3625 KeAttachProcess(&Wnd->head.pti->ppi->peProcess->Pcb);
3626 }
3627
3628 _SEH2_TRY
3629 {
3630 LB_DESCR *descr = ((PWND2LB)Wnd)->pLBiv;
3631 // See Controls ListBox.c:LB_GETLISTBOXINFO must match...
3632 Ret = descr->page_size;
3633 }
3635 {
3636 Ret = 0;
3638 }
3639 _SEH2_END;
3640
3641Exit:
3642 if (NotSameppi) KeDetachProcess();
3643 TRACE("Leave NtUserGetListBoxInfo, ret=%lu\n", Ret);
3644 UserLeave();
3645 return Ret;
3646}
#define FNID_LISTBOX
Definition: ntuser.h:871
const char * descr
Definition: boot.c:45
struct _WND2LB * PWND2LB

Referenced by GetListBoxInfo().

◆ NtUserInternalGetWindowText()

INT APIENTRY NtUserInternalGetWindowText ( HWND  hWnd,
LPWSTR  lpString,
INT  nMaxCount 
)

Definition at line 4608 of file window.c.

4609{
4610 PWND Wnd;
4612 INT Result = 0;
4613
4614 TRACE("Enter NtUserInternalGetWindowText\n");
4616
4617 if(lpString && (nMaxCount <= 1))
4618 {
4620 goto Exit; // Return 0
4621 }
4622
4623 if(!(Wnd = UserGetWindowObject(hWnd)))
4624 {
4625 goto Exit; // Return 0
4626 }
4627
4628 Result = Wnd->strName.Length / sizeof(WCHAR);
4629 if(lpString)
4630 {
4631 const WCHAR Terminator = L'\0';
4632 INT Copy;
4633 WCHAR *Buffer = (WCHAR*)lpString;
4634
4635 Copy = min(nMaxCount - 1, Result);
4636 if(Copy > 0)
4637 {
4638 Status = MmCopyToCaller(Buffer, Wnd->strName.Buffer, Copy * sizeof(WCHAR));
4639 if(!NT_SUCCESS(Status))
4640 {
4642 Result = 0;
4643 goto Exit;
4644 }
4645 Buffer += Copy;
4646 }
4647
4648 Status = MmCopyToCaller(Buffer, &Terminator, sizeof(WCHAR));
4649 if(!NT_SUCCESS(Status))
4650 {
4652 Result = 0;
4653 goto Exit;
4654 }
4655
4656 Result = Copy;
4657 }
4658
4659Exit:
4660 TRACE("Leave NtUserInternalGetWindowText, ret=%i\n", Result);
4661 UserLeave();
4662 return Result;
4663}
Definition: bufpool.h:45
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:126
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
_In_ int nMaxCount
Definition: winuser.h:4979

Referenced by GetWindowTextA(), GetWindowTextW(), and InternalGetWindowText().

◆ NtUserQueryWindow()

DWORD_PTR APIENTRY NtUserQueryWindow ( HWND  hWnd,
DWORD  Index 
)

Definition at line 4210 of file window.c.

4211{
4212/* Console Leader Process CID Window offsets */
4213#define GWLP_CONSOLE_LEADER_PID 0
4214#define GWLP_CONSOLE_LEADER_TID 4
4215
4216 DWORD_PTR Result = 0;
4217 PWND pWnd, pwndActive;
4218 PTHREADINFO pti, ptiActive;
4219
4220 TRACE("Enter NtUserQueryWindow\n");
4222
4223 if (!(pWnd = UserGetWindowObject(hWnd)))
4224 {
4225 goto Exit; // Return 0
4226 }
4227
4228 switch(Index)
4229 {
4231 {
4232 if ( (pWnd->head.pti->TIF_flags & TIF_CSRSSTHREAD) &&
4234 {
4235 // IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_PID)
4236 Result = (DWORD_PTR)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_PID)));
4237 }
4238 else
4239 {
4241 }
4242 break;
4243 }
4244
4246 {
4247 if ( (pWnd->head.pti->TIF_flags & TIF_CSRSSTHREAD) &&
4249 {
4250 // IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_TID)
4251 Result = (DWORD_PTR)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_TID)));
4252 }
4253 else
4254 {
4256 }
4257 break;
4258 }
4259
4261 Result = (DWORD_PTR)(pWnd->head.pti->MessageQueue->spwndActive ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndActive) : 0);
4262 break;
4263
4264 case QUERY_WINDOW_FOCUS:
4265 Result = (DWORD_PTR)(pWnd->head.pti->MessageQueue->spwndFocus ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndFocus) : 0);
4266 break;
4267
4269 Result = (pWnd->fnid == FNID_GHOST) || MsqIsHung(pWnd->head.pti, MSQ_HUNG);
4270 break;
4271
4273 Result = (DWORD_PTR)pWnd->head.pti->pEThread->Cid.UniqueProcess;
4274 break;
4275
4277 Result = (pWnd->head.pti->MessageQueue == gpqForeground);
4278 break;
4279
4280 case QUERY_WINDOW_DEFAULT_IME: /* default IME window */
4281 if (pWnd->head.pti->spwndDefaultIme)
4282 Result = (DWORD_PTR)UserHMGetHandle(pWnd->head.pti->spwndDefaultIme);
4283 break;
4284
4285 case QUERY_WINDOW_DEFAULT_ICONTEXT: /* default input context handle */
4286 if (pWnd->head.pti->spDefaultImc)
4287 Result = (DWORD_PTR)UserHMGetHandle(pWnd->head.pti->spDefaultImc);
4288 break;
4289
4292 {
4293 pwndActive = gpqForeground->spwndActive;
4295 if (pti->rpdesk == pwndActive->head.rpdesk)
4296 {
4297 ptiActive = pwndActive->head.pti;
4298 if (ptiActive->spwndDefaultIme)
4300 }
4301 }
4302 break;
4303 }
4304
4305Exit:
4306 TRACE("Leave NtUserQueryWindow, ret=%u\n", Result);
4307 UserLeave();
4308 return Result;
4309}
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
#define QUERY_WINDOW_DEFAULT_ICONTEXT
Definition: ntuser.h:2855
#define QUERY_WINDOW_UNIQUE_THREAD_ID
Definition: ntuser.h:2848
#define QUERY_WINDOW_ACTIVE_IME
Definition: ntuser.h:2856
#define TIF_CSRSSTHREAD
Definition: ntuser.h:266
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2850
#define QUERY_WINDOW_ACTIVE
Definition: ntuser.h:2849
#define QUERY_WINDOW_REAL_ID
Definition: ntuser.h:2852
#define QUERY_WINDOW_FOREGROUND
Definition: ntuser.h:2853
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2847
#define QUERY_WINDOW_ISHUNG
Definition: ntuser.h:2851
#define QUERY_WINDOW_DEFAULT_IME
Definition: ntuser.h:2854
#define PCHAR
Definition: match.c:90
BOOL FASTCALL MsqIsHung(PTHREADINFO pti, DWORD TimeOut)
Definition: msgqueue.c:2149
#define MSQ_HUNG
Definition: msgqueue.h:3
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
char * PCHAR
Definition: typedefs.h:51
#define GWLP_CONSOLE_LEADER_PID
#define GWLP_CONSOLE_LEADER_TID
#define IntGetWndThreadId(WndObj)
Definition: window.h:35
#define IntGetWndProcessId(WndObj)
Definition: window.h:38

Referenced by DIALOG_CreateIndirect(), GetRealWindowOwner(), GetWindowThreadProcessId(), ImeWnd_OnImeSetContext(), Imm32IsCrossProcessAccess(), ImmAssociateContext(), ImmAssociateContextEx(), ImmGetDefaultIMEWnd(), ImmGetSaveContext(), IsHungAppWindow(), PostMessageA(), PostMessageW(), TestWindowProcess(), and UserPaintCaption().

◆ NtUserRegisterWindowMessage()

UINT APIENTRY NtUserRegisterWindowMessage ( PUNICODE_STRING  MessageNameUnsafe)

Definition at line 4315 of file window.c.

4316{
4317 UNICODE_STRING SafeMessageName;
4319 UINT Ret = 0;
4320
4321 TRACE("Enter NtUserRegisterWindowMessage\n");
4323
4324 if(MessageNameUnsafe == NULL)
4325 {
4327 goto Exit; // Return 0
4328 }
4329
4330 Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe);
4331 if(!NT_SUCCESS(Status))
4332 {
4334 goto Exit; // Return 0
4335 }
4336
4337 Ret = (UINT)IntAddAtom(SafeMessageName.Buffer);
4338 if (SafeMessageName.Buffer)
4339 ExFreePoolWithTag(SafeMessageName.Buffer, TAG_STRING);
4340
4341Exit:
4342 TRACE("Leave NtUserRegisterWindowMessage, ret=%u\n", Ret);
4343 UserLeave();
4344 return Ret;
4345}
RTL_ATOM FASTCALL IntAddAtom(LPWSTR AtomName)
Definition: useratom.c:13
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
Definition: misc.c:685

Referenced by RegisterClipboardFormatA(), RegisterClipboardFormatW(), RegisterWindowMessageA(), and RegisterWindowMessageW().

◆ NtUserSetParent()

HWND APIENTRY NtUserSetParent ( HWND  hWndChild,
HWND  hWndNewParent 
)

Definition at line 3666 of file window.c.

3667{
3668 HWND Ret;
3669
3670 TRACE("Enter NtUserSetParent\n");
3672
3673 /*
3674 Check Parent first from user space, set it here.
3675 */
3676 if (!hWndNewParent)
3677 {
3678 hWndNewParent = IntGetDesktopWindow();
3679 }
3680 else if (hWndNewParent == HWND_MESSAGE)
3681 {
3682 hWndNewParent = IntGetMessageWindow();
3683 }
3684
3685 Ret = co_UserSetParent(hWndChild, hWndNewParent);
3686
3687 TRACE("Leave NtUserSetParent, ret=%p\n", Ret);
3688 UserLeave();
3689 return Ret;
3690}

Referenced by SetParent().

◆ NtUserSetShellWindowEx()

BOOL APIENTRY NtUserSetShellWindowEx ( HWND  hwndShell,
HWND  hwndListView 
)

Definition at line 3733 of file window.c.

3734{
3735 PWINSTATION_OBJECT WinStaObject;
3736 PWND WndShell, WndListView;
3737 BOOL Ret = FALSE;
3740 PTHREADINFO ti;
3741
3742 TRACE("Enter NtUserSetShellWindowEx\n");
3744
3745 if (!(WndShell = UserGetWindowObject(hwndShell)))
3746 {
3747 goto Exit; // Return FALSE
3748 }
3749
3750 if (!(WndListView = UserGetWindowObject(hwndListView)))
3751 {
3752 goto Exit; // Return FALSE
3753 }
3754
3756 UserMode,
3757 0,
3758 &WinStaObject,
3759 0);
3760
3761 if (!NT_SUCCESS(Status))
3762 {
3764 goto Exit; // Return FALSE
3765 }
3766
3767 /*
3768 * Test if we are permitted to change the shell window.
3769 */
3770 if (WinStaObject->ShellWindow)
3771 {
3772 ObDereferenceObject(WinStaObject);
3773 goto Exit; // Return FALSE
3774 }
3775
3776 /*
3777 * Move shell window into background.
3778 */
3779 if (hwndListView && hwndListView != hwndShell)
3780 {
3781 /*
3782 * Disabled for now to get Explorer working.
3783 * -- Filip, 01/nov/2003
3784 */
3785#if 0
3787#endif
3788
3789 if (WndListView->ExStyle & WS_EX_TOPMOST)
3790 {
3791 ObDereferenceObject(WinStaObject);
3792 goto Exit; // Return FALSE
3793 }
3794 }
3795
3796 if (WndShell->ExStyle & WS_EX_TOPMOST)
3797 {
3798 ObDereferenceObject(WinStaObject);
3799 goto Exit; // Return FALSE
3800 }
3801
3802 UserRefObjectCo(WndShell, &Ref);
3803 WndShell->state2 |= WNDS2_BOTTOMMOST;
3805
3806 WinStaObject->ShellWindow = hwndShell;
3807 WinStaObject->ShellListView = hwndListView;
3808
3809 ti = GetW32ThreadInfo();
3810 if (ti->pDeskInfo)
3811 {
3812 ti->pDeskInfo->hShellWindow = hwndShell;
3813 ti->pDeskInfo->spwndShell = WndShell;
3814 ti->pDeskInfo->spwndBkGnd = WndListView;
3815 ti->pDeskInfo->ppiShellProcess = ti->ppi;
3816 }
3817
3819
3820 UserDerefObjectCo(WndShell);
3821
3822 ObDereferenceObject(WinStaObject);
3823 Ret = TRUE;
3824
3825Exit:
3826 TRACE("Leave NtUserSetShellWindowEx, ret=%i\n", Ret);
3827 UserLeave();
3828 return Ret;
3829}
HWND hwndListView
Definition: eventvwr.c:66
#define MOD_CONTROL
Definition: imm.h:185
#define WNDS2_BOTTOMMOST
Definition: ntuser.h:646
NTSTATUS FASTCALL IntValidateWindowStationHandle(HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
Definition: winsta.c:232
BOOL FASTCALL UserRegisterHotKey(PWND pWnd, int id, UINT fsModifiers, UINT vk)
Definition: hotkey.c:451
#define SC_TASKLIST
Definition: winuser.h:2635
#define VK_ESCAPE
Definition: winuser.h:2250

Referenced by SetShellWindow(), and SetShellWindowEx().

◆ NtUserSetWindowFNID()

BOOL APIENTRY NtUserSetWindowFNID ( HWND  hWnd,
WORD  fnID 
)

Definition at line 4351 of file window.c.

4353{
4354 PWND Wnd;
4355 BOOL Ret = FALSE;
4356
4357 TRACE("Enter NtUserSetWindowFNID\n");
4359
4360 if (!(Wnd = UserGetWindowObject(hWnd)))
4361 {
4362 goto Exit; // Return FALSE
4363 }
4364
4365 if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process())
4366 {
4368 goto Exit; // Return FALSE
4369 }
4370
4371 // From user land we only set these.
4372 if (fnID != FNID_DESTROY)
4373 {
4374 /* HACK: The minimum should be FNID_BUTTON, but menu code relies on this */
4375 if (fnID < FNID_FIRST || fnID > FNID_GHOST ||
4376 Wnd->fnid != 0)
4377 {
4379 goto Exit; // Return FALSE
4380 }
4381 }
4382
4383 Wnd->fnid |= fnID;
4384 Ret = TRUE;
4385
4386Exit:
4387 TRACE("Leave NtUserSetWindowFNID\n");
4388 UserLeave();
4389 return Ret;
4390}
#define FNID_DESTROY
Definition: ntuser.h:898

Referenced by ButtonWndProc_common(), ComboWndProc_common(), EditWndProc_common(), Ghost_OnCreate(), Ghost_OnNCDestroy(), ImeWndProc_common(), ListBoxWndProc_common(), MDIClientWndProc_common(), MsgWindowProc(), ScrollBarWndProc_common(), StaticWndProc_common(), and SwitchWndProc_common().

◆ NtUserSetWindowLong()

LONG APIENTRY NtUserSetWindowLong ( HWND  hWnd,
DWORD  Index,
LONG  NewValue,
BOOL  Ansi 
)

Definition at line 4064 of file window.c.

4065{
4066 LONG ret;
4067
4069
4070 if (hWnd == IntGetDesktopWindow())
4071 {
4073 UserLeave();
4074 return 0;
4075 }
4076
4077 ret = (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4078
4079 UserLeave();
4080
4081 return ret;
4082}

Referenced by SetWindowLongA(), and SetWindowLongW().

◆ NtUserSetWindowWord()

WORD APIENTRY NtUserSetWindowWord ( HWND  hWnd,
INT  Index,
WORD  NewValue 
)

Definition at line 4139 of file window.c.

4140{
4141 PWND Window;
4142 WORD OldValue;
4143 WORD Ret = 0;
4144
4145 TRACE("Enter NtUserSetWindowWord\n");
4147
4148 if (hWnd == IntGetDesktopWindow())
4149 {
4151 goto Exit; // Return 0
4152 }
4153
4155 {
4156 goto Exit; // Return 0
4157 }
4158
4159 switch (Index)
4160 {
4161 case GWL_ID:
4162 case GWL_HINSTANCE:
4163 case GWL_HWNDPARENT:
4165 goto Exit;
4166
4167 default:
4168 if (Index < 0)
4169 {
4171 goto Exit; // Return 0
4172 }
4173 }
4174
4175 if ((ULONG)Index > (Window->cbwndExtra - sizeof(WORD)))
4176 {
4178 goto Exit; // Return 0
4179 }
4180
4181 OldValue = *((WORD *)((PCHAR)(Window + 1) + Index));
4182 *((WORD *)((PCHAR)(Window + 1) + Index)) = NewValue;
4183
4184 Ret = OldValue;
4185
4186Exit:
4187 TRACE("Leave NtUserSetWindowWord, ret=%u\n", Ret);
4188 UserLeave();
4189 return Ret;
4190}
unsigned short WORD
Definition: ntddk_ex.h:93
LONG FASTCALL co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
Definition: window.c:4041
#define GWL_HINSTANCE
Definition: winuser.h:866
#define GWL_HWNDPARENT
Definition: winuser.h:868

Referenced by SetWindowWord().

◆ ProbeAndCaptureLargeString()

NTSTATUS NTAPI ProbeAndCaptureLargeString ( OUT PLARGE_STRING  plstrSafe,
IN PLARGE_STRING  plstrUnsafe 
)

Definition at line 2629 of file window.c.

2632{
2633 LARGE_STRING lstrTemp;
2634 PVOID pvBuffer = NULL;
2635
2636 _SEH2_TRY
2637 {
2638 /* Probe and copy the string */
2639 ProbeForRead(plstrUnsafe, sizeof(LARGE_STRING), sizeof(ULONG));
2640 lstrTemp = *plstrUnsafe;
2641 }
2643 {
2644 /* Fail */
2646 }
2647 _SEH2_END
2648
2649 if (lstrTemp.Length != 0)
2650 {
2651 /* Allocate a buffer from paged pool */
2652 pvBuffer = ExAllocatePoolWithTag(PagedPool, lstrTemp.Length, TAG_STRING);
2653 if (!pvBuffer)
2654 {
2655 return STATUS_NO_MEMORY;
2656 }
2657
2658 _SEH2_TRY
2659 {
2660 /* Probe and copy the buffer */
2661 ProbeForRead(lstrTemp.Buffer, lstrTemp.Length, sizeof(WCHAR));
2662 RtlCopyMemory(pvBuffer, lstrTemp.Buffer, lstrTemp.Length);
2663 }
2665 {
2666 /* Cleanup and fail */
2667 ExFreePoolWithTag(pvBuffer, TAG_STRING);
2669 }
2670 _SEH2_END
2671 }
2672
2673 /* Set the output string */
2674 plstrSafe->Buffer = pvBuffer;
2675 plstrSafe->Length = lstrTemp.Length;
2676 plstrSafe->MaximumLength = lstrTemp.Length;
2677
2678 return STATUS_SUCCESS;
2679}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51

Referenced by NtUserCreateWindowEx().

◆ UserFreeWindowInfo()

static VOID UserFreeWindowInfo ( PTHREADINFO  ti,
PWND  Wnd 
)
static

Definition at line 543 of file window.c.

544{
546
547 if (!Wnd) return;
548
549 if (ClientInfo->CallbackWnd.pWnd == DesktopHeapAddressToUser(Wnd))
550 {
551 ClientInfo->CallbackWnd.hWnd = NULL;
552 ClientInfo->CallbackWnd.pWnd = NULL;
553 }
554
555 if (Wnd->strName.Buffer != NULL)
556 {
557 Wnd->strName.Length = 0;
558 Wnd->strName.MaximumLength = 0;
560 Wnd->strName.Buffer);
561 Wnd->strName.Buffer = NULL;
562 }
563
564// DesktopHeapFree(Wnd->head.rpdesk, Wnd);
565// WindowObject->hWnd = NULL;
566}
#define GetWin32ClientInfo()
Definition: ntuser.h:352
CLIENT_DATA ClientInfo
static __inline PVOID DesktopHeapAddressToUser(PVOID lpMem)
Definition: desktop.h:308

Referenced by co_UserFreeWindow().

◆ UserGetAncestor()

PWND FASTCALL UserGetAncestor ( _In_ PWND  pWnd,
_In_ UINT  uType 
)

Definition at line 3359 of file window.c.

3360{
3361 PWND WndAncestor, Parent, pwndMessage;
3362 PDESKTOP pDesktop;
3363 PWND pwndDesktop;
3364
3365 pDesktop = pWnd->head.rpdesk;
3366 ASSERT(pDesktop);
3367 ASSERT(pDesktop->pDeskInfo);
3368
3369 pwndDesktop = pDesktop->pDeskInfo->spwnd;
3370 if (pWnd == pwndDesktop)
3371 return NULL;
3372
3373 pwndMessage = pDesktop->spwndMessage;
3374 if (pWnd == pwndMessage)
3375 return NULL;
3376
3377 Parent = pWnd->spwndParent;
3378 if (!Parent)
3379 return NULL;
3380
3381 switch (uType)
3382 {
3383 case GA_PARENT:
3384 return Parent;
3385
3386 case GA_ROOT:
3387 WndAncestor = pWnd;
3388 if (Parent == pwndDesktop)
3389 break;
3390
3391 do
3392 {
3393 if (Parent == pwndMessage)
3394 break;
3395
3396 WndAncestor = Parent;
3397
3398 pDesktop = Parent->head.rpdesk;
3399 ASSERT(pDesktop);
3400 ASSERT(pDesktop->pDeskInfo);
3401
3402 Parent = Parent->spwndParent;
3403 } while (Parent != pDesktop->pDeskInfo->spwnd);
3404 break;
3405
3406 case GA_ROOTOWNER:
3407 WndAncestor = pWnd;
3408 for (PWND pwndNode = IntGetParent(pWnd); pwndNode; pwndNode = IntGetParent(pwndNode))
3409 {
3410 WndAncestor = pwndNode;
3411 }
3412 break;
3413
3414 default:
3415 return NULL;
3416 }
3417
3418 return WndAncestor;
3419}
struct _WND * spwnd
Definition: ntuser.h:137
PWND spwndMessage
Definition: desktop.h:20
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
#define GA_ROOT
Definition: winuser.h:2891
#define GA_PARENT
Definition: winuser.h:2890

Referenced by NtUserGetAncestor().

◆ UserGetShellWindow()

HWND FASTCALL UserGetShellWindow ( VOID  )

Definition at line 3700 of file window.c.

3701{
3702 PWINSTATION_OBJECT WinStaObject;
3703 HWND Ret;
3704
3706 UserMode,
3707 0,
3708 &WinStaObject,
3709 0);
3710
3711 if (!NT_SUCCESS(Status))
3712 {
3714 return NULL;
3715 }
3716
3717 Ret = (HWND)WinStaObject->ShellWindow;
3718
3719 ObDereferenceObject(WinStaObject);
3720 return Ret;
3721}

Referenced by co_WinPosSetWindowPos(), and SpiSetWallpaper().

◆ UserGetWindowObject()

PWND FASTCALL UserGetWindowObject ( HWND  hWnd)

Definition at line 124 of file window.c.

125{
126 PWND Window;
127
128 if (!hWnd)
129 {
131 return NULL;
132 }
133
135 if (!Window || 0 != (Window->state & WNDS_DESTROYED))
136 {
138 return NULL;
139 }
140
141 return Window;
142}
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226

Referenced by CaretSystemTimerProc(), co_IntCallHookProc(), co_IntDoSendMessage(), co_IntGetPeekMessage(), co_IntHideCaret(), co_IntPaintWindows(), co_IntSendActivateMessages(), co_IntSendMessageTimeout(), co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), co_IntSetCaretPos(), co_IntSetWindowLongPtr(), co_MsqInsertMouseMessage(), co_UserCreateWindowEx(), co_UserHideCaret(), co_UserSetCapture(), co_UserSetParent(), DceResetActiveDCEs(), DceUpdateVisRgn(), EngCreateWnd(), EngDeleteWnd(), IntClientShutdown(), IntDdeGetMessageHook(), IntDdePostMessageHook(), IntDdeSendMessageHook(), IntDefWindowProc(), IntDispatchMessage(), IntEnableWindow(), IntFindWindow(), IntGetMenuItemRect(), IntGetWindowObject(), IntIsWindow(), IntLinkHwnd(), IntNtUserSetClassLongPtr(), IntPaintDesktop(), IntScrollWindowEx(), IntSendDestroyMsg(), IntSetOwner(), IntSetTebWndCallback(), IntTrackMouseEvent(), NtGdiUpdateColors(), NtUserBeginPaint(), NtUserBuildHwndList(), NtUserBuildPropList(), NtUserCalcMenuBar(), NtUserCallHwnd(), NtUserCallHwndLock(), NtUserCallHwndParam(), NtUserCallHwndParamLock(), NtUserCallTwoParam(), NtUserChangeClipboardChain(), NtUserChildWindowFromPointEx(), NtUserCreateCaret(), NtUserDeferWindowPos(), NtUserDefSetText(), NtUserDestroyWindow(), NtUserDrawCaptionTemp(), NtUserDrawMenuBarTemp(), NtUserEnableScrollBar(), NtUserEndPaint(), NtUserExcludeUpdateRgn(), NtUserFillWindow(), NtUserFindWindowEx(), NtUserGetAncestor(), NtUserGetClassName(), NtUserGetComboBoxInfo(), NtUserGetControlBrush(), NtUserGetControlColor(), NtUserGetCPD(), NtUserGetDCEx(), NtUserGetInternalWindowPos(), NtUserGetLayeredWindowAttributes(), NtUserGetListBoxInfo(), NtUserGetMenuBarInfo(), NtUserGetMenuItemRect(), NtUserGetScrollBarInfo(), NtUserGetSystemMenu(), NtUserGetTitleBarInfo(), NtUserGetUpdateRect(), NtUserGetUpdateRgn(), NtUserGetWindowPlacement(), NtUserHideCaret(), NtUserHiliteMenuItem(), NtUserInternalGetWindowText(), NtUserKillTimer(), NtUserMenuItemFromPoint(), NtUserMessageCall(), NtUserMinMaximize(), NtUserMonitorFromWindow(), NtUserNotifyWinEvent(), NtUserPaintMenuBar(), NtUserPrintWindow(), NtUserQueryWindow(), NtUserRealChildWindowFromPoint(), NtUserRedrawWindow(), NtUserRegisterHotKey(), NtUserRemoveProp(), NtUserSBGetParms(), NtUserScrollWindowEx(), NtUserSetActiveWindow(), NtUserSetClipboardViewer(), NtUserSetFocus(), NtUserSetInternalWindowPos(), NtUserSetLayeredWindowAttributes(), NtUserSetMenu(), NtUserSetProp(), NtUserSetScrollBarInfo(), NtUserSetScrollInfo(), NtUserSetShellWindowEx(), NtUserSetSystemMenu(), NtUserSetSystemTimer(), NtUserSetTimer(), NtUserSetWindowFNID(), NtUserSetWindowPlacement(), NtUserSetWindowPos(), NtUserSetWindowRgn(), NtUserSetWindowWord(), NtUserShowCaret(), NtUserShowScrollBar(), NtUserShowWindow(), NtUserShowWindowAsync(), NtUserTrackPopupMenuEx(), NtUserTranslateAccelerator(), NtUserTranslateMessage(), NtUserUnregisterHotKey(), NtUserUpdateLayeredWindow(), NtUserWindowFromPoint(), ScrollBarWndProc(), SnapWindow(), SpiNotifyNCMetricsChanged(), SystemTimerProc(), UserGetDesktopWindow(), UserGethWnd(), UserOpenClipboard(), UserPostMessage(), UserRealizePalette(), UserRegisterUserApiHook(), and UserSendNotifyMessage().

◆ UserUpdateUiState()

BOOL FASTCALL UserUpdateUiState ( PWND  Wnd,
WPARAM  wParam 
)

Definition at line 40 of file window.c.

41{
44
45 if (Flags & ~(UISF_HIDEFOCUS | UISF_HIDEACCEL | UISF_ACTIVE))
46 {
48 return FALSE;
49 }
50
51 switch (Action)
52 {
53 case UIS_INITIALIZE:
55 return FALSE;
56
57 case UIS_SET:
58 if (Flags & UISF_HIDEFOCUS)
59 Wnd->HideFocus = TRUE;
60 if (Flags & UISF_HIDEACCEL)
61 Wnd->HideAccel = TRUE;
62 break;
63
64 case UIS_CLEAR:
65 if (Flags & UISF_HIDEFOCUS)
66 Wnd->HideFocus = FALSE;
67 if (Flags & UISF_HIDEACCEL)
68 Wnd->HideAccel = FALSE;
69 break;
70 }
71
72 return TRUE;
73}
WPARAM wParam
Definition: combotst.c:138
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by NtUserCallTwoParam().

◆ ValidateHwndNoErr()

PWND FASTCALL ValidateHwndNoErr ( HWND  hWnd)

Definition at line 108 of file window.c.

109{
110 PWND Window;
111
112 if (!hWnd)
113 return NULL;
114
116 if (!Window || (Window->state & WNDS_DESTROYED))
117 return NULL;
118
119 return Window;
120}
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481

◆ VerifyWnd()

PWND FASTCALL VerifyWnd ( PWND  pWnd)

Definition at line 88 of file window.c.

89{
91
92 if (!pWnd ||
93 (pWnd->state & WNDS_DESTROYED) ||
94 (pWnd->state2 & WNDS2_INDESTROY))
95 {
96 return NULL;
97 }
98
100
102 pWnd = NULL;
103
105 return pWnd;
106}
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:703
ENGAPI ULONG APIENTRY EngGetLastError(VOID)
Definition: error.c:9

Referenced by ActivateOtherWindowMin(), co_IntMakeWindowActive(), co_IntSetActiveWindow(), co_IntSetForegroundMessageQueue(), co_WinPosShowWindow(), IntActivateWindow(), IntDispatchMessage(), IntSendParentNotify(), MENU_TrackMenu(), UserSetActiveWindow(), and VIS_ComputeVisibleRegion().

Variable Documentation

◆ gNestedWindowLimit

INT gNestedWindowLimit = 50

Definition at line 16 of file window.c.

Referenced by IntValidateOwnerDepth().

◆ gpwlCache

PWINDOWLIST gpwlCache = NULL

Definition at line 19 of file window.c.

Referenced by IntBuildHwndList(), IntFreeHwndList(), and UserProcessDestroy().

◆ gpwlList

PWINDOWLIST gpwlList = NULL

Definition at line 18 of file window.c.

Referenced by ExitThreadCallback(), IntBuildHwndList(), and IntFreeHwndList().