ReactOS 0.4.16-dev-1204-gb627a42
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 3478 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:2594
#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:308
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#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 3841 of file window.c.

3842{
3844 PWINSTATION_OBJECT WindowStation;
3845 LONG_PTR OldValue;
3847
3849 {
3850 return 0;
3851 }
3852
3853 if ((INT)Index >= 0)
3854 {
3855 if ((Index + Size) > Window->cbwndExtra)
3856 {
3858 return 0;
3859 }
3860
3861 PVOID Address = (PUCHAR)(&Window[1]) + Index;
3862
3863#ifdef _WIN64
3864 if (Size == sizeof(LONG))
3865 {
3866 OldValue = ReadUnalignedU32(Address);
3867 WriteUnalignedU32(Address, NewValue);
3868 }
3869 else
3870#endif
3871 {
3872 OldValue = ReadUnalignedUlongPtr(Address);
3873 /*
3874 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3875 {
3876 OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi);
3877 if (!OldValue) return 0;
3878 }
3879 */
3881 }
3882
3883 }
3884 else
3885 {
3886#ifdef _WIN64
3887 if (Size == sizeof(LONG))
3888 {
3889 if ((Index != GWL_STYLE) &&
3890 (Index != GWL_EXSTYLE) &&
3891 (Index != GWL_ID) &&
3892 (Index != GWL_USERDATA))
3893 {
3894 ERR("NtUserSetWindowLong(): Index requires pointer size: %lu\n", Index);
3896 return 0;
3897 }
3898 }
3899#endif
3900
3901 switch (Index)
3902 {
3903 case GWL_EXSTYLE: // LONG
3904 OldValue = (LONG) Window->ExStyle;
3905 Style.styleOld = OldValue;
3906 Style.styleNew = NewValue;
3907
3908 co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style);
3909
3910 /*
3911 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3912 */
3913 WindowStation = Window->head.pti->rpdesk->rpwinstaParent;
3914 if(WindowStation)
3915 {
3916 if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
3917 Style.styleNew &= ~WS_EX_TOPMOST;
3918 }
3919 /* WS_EX_WINDOWEDGE depends on some other styles */
3920 if (IntCheckFrameEdge(Window->style, NewValue))
3921 Style.styleNew |= WS_EX_WINDOWEDGE;
3922 else
3923 Style.styleNew &= ~WS_EX_WINDOWEDGE;
3924
3925 if (!(Window->ExStyle & WS_EX_LAYERED))
3926 {
3928 }
3929
3930 Window->ExStyle = (DWORD)Style.styleNew;
3931
3932 co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
3933 break;
3934
3935 case GWL_STYLE: // LONG
3936 OldValue = (LONG) Window->style;
3937 Style.styleOld = OldValue;
3938 Style.styleNew = NewValue;
3939
3940 if (!bAlter)
3941 co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
3942
3943 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3944 if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS;
3945 /* WS_MINIMIZE can't be reset */
3946 if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE;
3947 /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
3948 if (IntCheckFrameEdge(NewValue, Window->ExStyle))
3949 Window->ExStyle |= WS_EX_WINDOWEDGE;
3950 else
3951 Window->ExStyle &= ~WS_EX_WINDOWEDGE;
3952
3953 if ((OldValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3954 {
3955 if ((NewValue & (WS_CHILD | WS_POPUP)) != WS_CHILD)
3956 {
3958 ERR("IDMenu going null! %d\n",Window->IDMenu);
3959 Window->IDMenu = 0; // Window->spmenu = 0;
3960 }
3961 }
3962 else
3963 {
3964 if ((NewValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3965 {
3966 PMENU pMenu = UserGetMenuObject(UlongToHandle(Window->IDMenu));
3967 Window->state &= ~WNDS_HASMENU;
3968 if (pMenu)
3969 {
3970 ERR("IDMenu released 0x%p\n",pMenu);
3971 // ROS may not hold a lock after setting menu to window. But it should!
3972 //IntReleaseMenuObject(pMenu);
3973 }
3974 }
3975 }
3976
3977 if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE)
3978 {
3979 if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--;
3980 if (Style.styleNew & WS_VISIBLE) Window->head.pti->cVisWindows++;
3982 }
3983 Window->style = (DWORD)Style.styleNew;
3984
3985 if (!bAlter)
3986 co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
3987 break;
3988
3989 case GWLP_WNDPROC: // LONG_PTR
3990 {
3991 if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
3992 Window->fnid & FNID_FREED)
3993 {
3995 return 0;
3996 }
3997 OldValue = (LONG_PTR)IntSetWindowProc(Window,
3998 (WNDPROC)NewValue,
3999 Ansi);
4000 break;
4001 }
4002
4003 case GWLP_HINSTANCE: // LONG_PTR
4004 OldValue = (LONG_PTR) Window->hModule;
4005 Window->hModule = (HINSTANCE) NewValue;
4006 break;
4007
4008 case GWLP_HWNDPARENT: // LONG_PTR
4009 Parent = Window->spwndParent;
4011 OldValue = (LONG_PTR)IntSetOwner(UserHMGetHandle(Window), (HWND)NewValue);
4012 else
4013 OldValue = (LONG_PTR)co_UserSetParent(UserHMGetHandle(Window), (HWND)NewValue);
4014 break;
4015
4016 case GWLP_ID: // LONG
4017 OldValue = (LONG) Window->IDMenu;
4018 Window->IDMenu = (UINT) NewValue;
4019 break;
4020
4021 case GWLP_USERDATA: // LONG or LONG_PTR
4022 OldValue = Window->dwUserData;
4023 Window->dwUserData = NewValue;
4024 break;
4025
4026 default:
4027 ERR("NtUserSetWindowLong(): Unsupported index %lu\n", Index);
4029 OldValue = 0;
4030 break;
4031 }
4032 }
4033
4034 return OldValue;
4035}
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:73
HWND hWnd
Definition: settings.c:17
#define UlongToHandle(ul)
Definition: basetsd.h:97
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
__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:4533
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:3830
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
LONG_PTR LPARAM
Definition: windef.h:208
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#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:2982
#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 2180 of file window.c.

2185{
2186 ULONG style;
2187 PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
2188 HWND hWnd, hWndParent, hWndOwner, hwndInsertAfter;
2189 PWINSTATION_OBJECT WinSta;
2190 PCLS Class = NULL;
2191 SIZE Size;
2192 POINT MaxSize, MaxPos, MinTrack, MaxTrack;
2193 CBT_CREATEWNDW * pCbtCreate;
2195 USER_REFERENCE_ENTRY ParentRef, Ref;
2196 PTHREADINFO pti;
2197 DWORD dwShowMode = SW_SHOW;
2198 CREATESTRUCTW *pCsw = NULL;
2199 PVOID pszClass = NULL, pszName = NULL;
2200 PWND ret = NULL;
2201
2202 /* Get the current window station and reference it */
2203 pti = GetW32ThreadInfo();
2204 if (pti == NULL || pti->rpdesk == NULL)
2205 {
2206 ERR("Thread is not attached to a desktop! Cannot create window (%wZ)\n", ClassName);
2207 return NULL; // There is nothing to cleanup.
2208 }
2209 WinSta = pti->rpdesk->rpwinstaParent;
2211
2212 pCsw = NULL;
2213 pCbtCreate = NULL;
2214
2215 /* Get the class and reference it */
2216 Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
2217 if(!Class)
2218 {
2220 ERR("Failed to find class %wZ\n", ClassName);
2221 goto cleanup;
2222 }
2223
2224 /* Now find the parent and the owner window */
2225 hWndParent = UserHMGetHandle(pti->rpdesk->pDeskInfo->spwnd);
2226 hWndOwner = NULL;
2227
2228 if (Cs->hwndParent == HWND_MESSAGE)
2229 {
2230 Cs->hwndParent = hWndParent = UserHMGetHandle(pti->rpdesk->spwndMessage);
2231 }
2232 else if (Cs->hwndParent)
2233 {
2234 if ((Cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
2235 hWndOwner = Cs->hwndParent;
2236 else
2237 hWndParent = Cs->hwndParent;
2238 }
2239 else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2240 {
2241 ERR("Cannot create a child window (%wZ) without a parent\n", ClassName);
2243 goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
2244 }
2246 (IS_INTRESOURCE(Cs->lpszClass) ||
2247 Cs->lpszClass != (LPCWSTR)MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]) ||
2248 _wcsicmp(Cs->lpszClass, L"Message") != 0))
2249 {
2250 if (pti->ppi->dwLayout & LAYOUT_RTL)
2251 {
2253 }
2254 }
2255
2256 ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
2257 OwnerWindow = hWndOwner ? UserGetWindowObject(hWndOwner): NULL;
2258
2259 if (hWndParent && !ParentWindow)
2260 {
2261 ERR("Got invalid parent window handle for %wZ\n", ClassName);
2262 goto cleanup;
2263 }
2264 else if (hWndOwner && !OwnerWindow)
2265 {
2266 ERR("Got invalid owner window handle for %wZ\n", ClassName);
2267 ParentWindow = NULL;
2268 goto cleanup;
2269 }
2270
2271 if(OwnerWindow)
2272 {
2273 if (IntIsDesktopWindow(OwnerWindow)) OwnerWindow = NULL;
2274 else if (ParentWindow && !IntIsDesktopWindow(ParentWindow))
2275 {
2276 ERR("an owned window must be created as top-level\n");
2278 goto cleanup;
2279 }
2280 else /* owner must be a top-level window */
2281 {
2282 while ((OwnerWindow->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !IntIsDesktopWindow(OwnerWindow->spwndParent))
2283 OwnerWindow = OwnerWindow->spwndParent;
2284 }
2285 }
2286
2287 /* Fix the position and the size of the window */
2288 if (ParentWindow)
2289 {
2290 UserRefObjectCo(ParentWindow, &ParentRef);
2291 IntFixWindowCoordinates(Cs, ParentWindow, &dwShowMode);
2292 }
2293
2294 /* Allocate and initialize the new window */
2296 WindowName,
2297 Class,
2298 ParentWindow,
2299 OwnerWindow,
2300 acbiBuffer,
2301 NULL,
2302 dwVer );
2303 if(!Window)
2304 {
2305 ERR("IntCreateWindow(%wZ) failed\n", ClassName);
2306 goto cleanup;
2307 }
2308
2310 hwndInsertAfter = HWND_TOP;
2311
2312 UserRefObjectCo(Window, &Ref);
2314 ObDereferenceObject(WinSta);
2315
2316 /* NCCREATE, WM_NCCALCSIZE and Hooks need the original values */
2317 Cs->lpszName = (LPCWSTR) WindowName;
2318 Cs->lpszClass = (LPCWSTR) ClassName;
2319
2321 if ( ISITHOOKED(WH_CBT) || (pti->rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)) )
2322 {
2323 // Allocate the calling structures Justin Case this goes Global.
2326 if (!pCsw || !pCbtCreate)
2327 {
2328 ERR("UserHeapAlloc() failed!\n");
2329 goto cleanup;
2330 }
2331
2332 if (!IntMsgCreateStructW( Window, pCsw, Cs, &pszClass, &pszName ) )
2333 {
2334 ERR("IntMsgCreateStructW() failed!\n");
2335 goto cleanup;
2336 }
2337
2338 pCbtCreate->lpcs = pCsw;
2339 pCbtCreate->hwndInsertAfter = hwndInsertAfter;
2340
2343 if (Result != 0)
2344 {
2345 ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
2346 goto cleanup;
2347 }
2348 // Write back changes.
2349 Cs->cx = pCsw->cx;
2350 Cs->cy = pCsw->cy;
2351 Cs->x = pCsw->x;
2352 Cs->y = pCsw->y;
2353 hwndInsertAfter = pCbtCreate->hwndInsertAfter;
2354 }
2355
2356 if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2357 {
2358 if (ParentWindow != co_GetDesktopWindow(Window))
2359 {
2360 Cs->x += ParentWindow->rcClient.left;
2361 Cs->y += ParentWindow->rcClient.top;
2362 }
2363 }
2364
2365 /* Send the WM_GETMINMAXINFO message */
2366 Size.cx = Cs->cx;
2367 Size.cy = Cs->cy;
2368
2369 if ((Cs->style & WS_THICKFRAME) || !(Cs->style & (WS_POPUP | WS_CHILD)))
2370 {
2371 co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack, &MaxTrack);
2372 if (Size.cx > MaxTrack.x) Size.cx = MaxTrack.x;
2373 if (Size.cy > MaxTrack.y) Size.cy = MaxTrack.y;
2374 if (Size.cx < MinTrack.x) Size.cx = MinTrack.x;
2375 if (Size.cy < MinTrack.y) Size.cy = MinTrack.y;
2376 }
2377
2378 Window->rcWindow.left = Cs->x;
2379 Window->rcWindow.top = Cs->y;
2380 Window->rcWindow.right = Cs->x + Size.cx;
2381 Window->rcWindow.bottom = Cs->y + Size.cy;
2382 /*
2383 if (0 != (Window->style & WS_CHILD) && ParentWindow)
2384 {
2385 ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2386 RECTL_vOffsetRect(&Window->rcWindow,
2387 ParentWindow->rcClient.left,
2388 ParentWindow->rcClient.top);
2389 }
2390 */
2391 /* correct child window coordinates if mirroring on parent is enabled */
2392 if (ParentWindow != NULL)
2393 {
2394 if ( ((Cs->style & WS_CHILD) == WS_CHILD) &&
2395 ((ParentWindow->ExStyle & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL))
2396 {
2397 Window->rcWindow.right = ParentWindow->rcClient.right - (Window->rcWindow.left - ParentWindow->rcClient.left);
2398 Window->rcWindow.left = Window->rcWindow.right - Size.cx;
2399 }
2400 }
2401
2402 Window->rcClient = Window->rcWindow;
2403
2404 if (Window->spwndNext || Window->spwndPrev)
2405 {
2406 ERR("Window 0x%p has been linked too early!\n", Window);
2407 }
2408
2409 if (!(Window->state2 & WNDS2_WIN31COMPAT))
2410 {
2411 if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN))
2412 Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
2413 }
2414
2415 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2416 {
2418 {
2419 if (pti != ParentWindow->head.pti)
2420 {
2421 //ERR("CreateWindow Parent in.\n");
2422 UserAttachThreadInput(pti, ParentWindow->head.pti, TRUE);
2423 }
2424 }
2425 }
2426
2427 /* Send the NCCREATE message */
2429 if (!Result)
2430 {
2431 ERR("co_UserCreateWindowEx(%wZ): NCCREATE message failed\n", ClassName);
2432 goto cleanup;
2433 }
2434
2435 /* Link the window */
2436 if (ParentWindow != NULL)
2437 {
2438 /* Link the window into the siblings list */
2439 if ((Cs->style & (WS_CHILD | WS_MAXIMIZE)) == WS_CHILD)
2441 else
2442 IntLinkHwnd(Window, hwndInsertAfter);
2443 }
2444
2445 /* Create the IME window for pWnd */
2447 {
2448 PWND pwndDefaultIme = co_IntCreateDefaultImeWindow(Window, Window->hModule);
2449 UserAssignmentLock((PVOID*)&pti->spwndDefaultIme, pwndDefaultIme);
2450
2451 if (pwndDefaultIme)
2452 {
2453 HWND hImeWnd;
2455 UserRefObjectCo(pwndDefaultIme, &Ref);
2456
2457 hImeWnd = UserHMGetHandle(pwndDefaultIme);
2458
2460
2461 if (pti->pClientInfo->CI_flags & CI_IMMACTIVATE)
2462 {
2463 HKL hKL = pti->KeyboardLayout->hkl;
2465 pti->pClientInfo->CI_flags &= ~CI_IMMACTIVATE;
2466 }
2467
2468 UserDerefObjectCo(pwndDefaultIme);
2469 }
2470 }
2471
2472 /* Send the WM_NCCALCSIZE message */
2473 {
2474 // RECT rc;
2475 MaxPos.x = Window->rcWindow.left;
2476 MaxPos.y = Window->rcWindow.top;
2477
2478 Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
2479 //rc = Window->rcWindow;
2480 //Result = co_IntSendMessageNoWait(UserHMGetHandle(Window), WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2481 //Window->rcClient = rc;
2482
2483 RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
2484 MaxPos.y - Window->rcWindow.top);
2485 }
2486
2487 /* Send the WM_CREATE message. */
2489 if (Result == (LRESULT)-1)
2490 {
2491 ERR("co_UserCreateWindowEx(%wZ): WM_CREATE message failed\n", ClassName);
2492 goto cleanup;
2493 }
2494
2495 /* Send the EVENT_OBJECT_CREATE event */
2496 IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2497
2498 /* By setting the flag below it can be examined to determine if the window
2499 was created successfully and a valid pwnd was passed back to caller since
2500 from here the function has to succeed. */
2502
2503 /* Send the WM_SIZE and WM_MOVE messages. */
2504 if (!(Window->state & WNDS_SENDSIZEMOVEMSGS))
2505 {
2507 }
2508
2509 /* Show or maybe minimize or maximize the window. */
2510
2512 if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2513 {
2514 RECTL NewPos;
2515 UINT SwFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
2516
2517 SwFlag = co_WinPosMinMaximize(Window, SwFlag, &NewPos);
2518 SwFlag |= SWP_NOZORDER|SWP_FRAMECHANGED; /* Frame always gets changed */
2519 if (!(style & WS_VISIBLE) || (style & WS_CHILD) || UserGetActiveWindow() ||
2520 (Window->ExStyle & WS_EX_NOACTIVATE))
2521 {
2522 SwFlag |= SWP_NOACTIVATE;
2523 }
2524 co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
2525 NewPos.right, NewPos.bottom, SwFlag);
2526 }
2527
2528 /* Send the WM_PARENTNOTIFY message */
2530
2531 /* Notify the shell that a new window was created */
2532 if (Window->spwndOwner == NULL ||
2533 !(Window->spwndOwner->style & WS_VISIBLE) ||
2534 (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW))
2535 {
2536 if (UserIsDesktopWindow(Window->spwndParent) &&
2537 (Window->style & WS_VISIBLE) &&
2538 (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
2539 (Window->ExStyle & WS_EX_APPWINDOW)))
2540 {
2542 }
2543 }
2544
2545 /* Initialize and show the window's scrollbars */
2546 if (Window->style & WS_VSCROLL)
2547 {
2549 }
2550 if (Window->style & WS_HSCROLL)
2551 {
2553 }
2554
2555 /* Show the new window */
2556 if (Cs->style & WS_VISIBLE)
2557 {
2558 if (Window->style & WS_MAXIMIZE)
2559 dwShowMode = SW_SHOW;
2560 else if (Window->style & WS_MINIMIZE)
2561 dwShowMode = SW_SHOWMINIMIZED;
2562
2563 co_WinPosShowWindow(Window, dwShowMode);
2564
2565 if (Window->ExStyle & WS_EX_MDICHILD)
2566 {
2567 ASSERT(ParentWindow);
2568 if(!ParentWindow)
2569 goto cleanup;
2571 /* ShowWindow won't activate child windows */
2573 }
2574 }
2575
2576 if (Class->atomClassName == gaGuiConsoleWndClass)
2577 {
2578 /* Count only console windows manually */
2580 }
2581
2582 /* Set the hotkey */
2583 if (!(Window->style & (WS_POPUP | WS_CHILD)) || (Window->ExStyle & WS_EX_APPWINDOW))
2584 {
2585 if (pti->ppi->dwHotkey)
2586 {
2588 pti->ppi->dwHotkey = 0; /* Only the first suitable window gets the hotkey */
2589 }
2590 }
2591
2592 TRACE("co_UserCreateWindowEx(%wZ): Created window %p\n", ClassName, hWnd);
2593 ret = Window;
2594
2595cleanup:
2596 if (!ret)
2597 {
2598 TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2599 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2600 if (Window)
2602 else if (Class)
2604 }
2605
2606 if (pCsw) ExFreePoolWithTag(pCsw, TAG_HOOK);
2607 if (pCbtCreate) ExFreePoolWithTag(pCbtCreate, TAG_HOOK);
2608 if (pszName) UserHeapFree(pszName);
2609 if (pszClass) UserHeapFree(pszClass);
2610
2611 if (Window)
2612 {
2614 }
2615 if (ParentWindow) UserDerefObjectCo(ParentWindow);
2616
2617 // See CORE-13717, not setting error on success.
2618 if (ret)
2620
2621 return ret;
2622}
Arabic default style
Definition: afstyles.h:94
#define ERROR_SUCCESS
Definition: deptool.c:10
static void cleanup(void)
Definition: main.c:1335
#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:1432
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: immdev.h:116
#define IMS_ACTIVATELAYOUT
Definition: immdev.h:111
#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
#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(PWND pwndTarget, HINSTANCE hInst)
Definition: ime.c:1960
BOOL FASTCALL IntWantImeWindow(PWND pwndTarget)
Definition: ime.c:1920
UINT FASTCALL co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT *NewPos)
Definition: winpos.c:2436
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2387
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:2402
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
#define L(x)
Definition: ntvdm.h:50
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:852
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
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:3051
HWND hwndInsertAfter
Definition: winuser.h:3052
LPCWSTR lpszClass
Definition: winuser.h:3041
LPCWSTR lpszName
Definition: winuser.h:3040
HINSTANCE hInstance
Definition: winuser.h:3032
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
#define WM_IME_SYSTEM
Definition: undocuser.h:62
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
int ret
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:1709
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:1808
void FASTCALL IntFixWindowCoordinates(CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
Definition: window.c:1714
BOOL FASTCALL IntIsTopLevelWindow(PWND pWnd)
Definition: window.c:361
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2870
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1695
#define IntIsDesktopWindow(WndObj)
Definition: window.h:25
#define MAKEINTATOM(i)
Definition: winbase.h:1504
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:887
#define ERROR_CANNOT_FIND_WND_CLASS
Definition: winerror.h:888
#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:1671
#define WM_CREATE
Definition: winuser.h:1627
#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 IS_INTRESOURCE(i)
Definition: winuser.h:580
#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:1702
#define WM_MDIREFRESHMENU
Definition: winuser.h:1845
#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 2870 of file window.c.

2871{
2872 HWND hWnd;
2873 PWND pwndTemp;
2874 PTHREADINFO ti;
2875 MSG msg;
2876 PWND Window = Object;
2877
2878 ASSERT_REFS_CO(Window); // FIXME: Temp HACK?
2879
2880 /* NtUserDestroyWindow does check if the window has already been destroyed
2881 but co_UserDestroyWindow can be called from more paths which means
2882 that it can also be called for a window that has already been destroyed. */
2884 {
2885 TRACE("Tried to destroy a window twice\n");
2886 return TRUE;
2887 }
2888
2891
2892 TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
2893
2894 /* Check for owner thread */
2895 if (Window->head.pti != ti)
2896 {
2897 /* Check if we are destroying the desktop window */
2898 if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd))
2899 {
2901 return FALSE;
2902 }
2903 }
2904
2905 /* If window was created successfully and it is hooked */
2906 if ((Window->state2 & WNDS2_WMCREATEMSGPROCESSED))
2907 {
2909 {
2910 ERR("Destroy Window WH_CBT Call Hook return!\n");
2911 return FALSE;
2912 }
2913 }
2914
2915 if (Window->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME])
2916 {
2917 if ((Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2918 {
2919 if (Window->spwndOwner)
2920 {
2921 //ERR("DestroyWindow Owner out.\n");
2922 UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE);
2923 }
2924 }
2925 }
2926
2927 /* Inform the parent */
2928 if (Window->style & WS_CHILD)
2929 {
2931 }
2932
2933 if (!Window->spwndOwner && !IntGetParent(Window))
2934 {
2936 }
2937
2938 /* Hide the window */
2939 if (Window->style & WS_VISIBLE)
2940 {
2941 if (Window->style & WS_CHILD)
2942 {
2943 /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2945 }
2946 else
2947 {
2949 }
2950 }
2951
2952 /* Adjust last active */
2953 if ((pwndTemp = Window->spwndOwner))
2954 {
2955 while (pwndTemp->spwndOwner)
2956 pwndTemp = pwndTemp->spwndOwner;
2957
2958 if (pwndTemp->spwndLastActive == Window)
2959 WndSetLastActive(pwndTemp, Window->spwndOwner);
2960 }
2961
2962 if (Window->spwndParent && IntIsWindow(UserHMGetHandle(Window)))
2963 {
2964 if ((Window->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
2965 {
2967 {
2968 //ERR("DestroyWindow Parent out.\n");
2969 UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE);
2970 }
2971 }
2972 }
2973
2974 if (Window->head.pti->MessageQueue->spwndActive == Window)
2975 Window->head.pti->MessageQueue->spwndActive = NULL;
2976 if (Window->head.pti->MessageQueue->spwndFocus == Window)
2977 Window->head.pti->MessageQueue->spwndFocus = NULL;
2978 if (Window->head.pti->MessageQueue->spwndActivePrev == Window)
2979 Window->head.pti->MessageQueue->spwndActivePrev = NULL;
2980 if (Window->head.pti->MessageQueue->spwndCapture == Window)
2981 Window->head.pti->MessageQueue->spwndCapture = NULL;
2982
2983 /*
2984 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2985 */
2986
2987 if (ti->pDeskInfo != NULL)
2988 {
2989 if (ti->pDeskInfo->hShellWindow == hWnd)
2990 {
2991 ERR("Destroying the ShellWindow!\n");
2992 ti->pDeskInfo->hShellWindow = NULL;
2993 }
2994 }
2995
2997
2999 {
3000 return TRUE;
3001 }
3002
3003 /* Recursively destroy owned windows */
3004 if (!(Window->style & WS_CHILD))
3005 {
3007 }
3008
3009 /* Generate mouse move message for the next window */
3010 msg.message = WM_MOUSEMOVE;
3011 msg.wParam = UserGetMouseButtonsState();
3012 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
3013 msg.pt = gpsi->ptCursor;
3015
3016 IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0);
3017
3018 /* Send destroy messages */
3020
3021 /* Destroy the default IME window if necessary */
3022 if (IS_IMM_MODE() && !(ti->TIF_flags & TIF_INCLEANUP) &&
3023 ti->spwndDefaultIme && (ti->spwndDefaultIme != Window) &&
3024 !(Window->state & WNDS_DESTROYED) && !IS_WND_IMELIKE(Window))
3025 {
3026 if (IS_WND_CHILD(Window))
3027 {
3030 }
3031 else
3032 {
3035 }
3036 }
3037
3039 {
3040 return TRUE;
3041 }
3042
3043 /* Destroy the window storage */
3045
3046 return TRUE;
3047}
#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 IntImeCanDestroyDefIME(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2068
BOOL FASTCALL IntImeCanDestroyDefIMEforChild(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2023
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:2834
#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:4084
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1267
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define WM_MOUSEMOVE
Definition: winuser.h:1794
#define SWP_HIDEWINDOW
Definition: winuser.h:1252
#define WM_DESTROY
Definition: winuser.h:1628

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
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:1532
#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:63
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:799
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:1158
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
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:1803
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:1703
#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 4038 of file window.c.

4039{
4040 return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4041}
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3841

Referenced by DesktopWindowProc(), and NtUserSetWindowWord().

◆ co_UserSetWindowLongPtr()

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

Definition at line 4044 of file window.c.

4045{
4046 return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
4047}

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserWnd  )

◆ DefSetText()

BOOL APIENTRY DefSetText ( PWND  Wnd,
PCWSTR  WindowText 
)

Definition at line 4390 of file window.c.

4391{
4393 BOOL Ret = FALSE;
4394
4395 RtlInitUnicodeString(&UnicodeString, WindowText);
4396
4397 if (UnicodeString.Length != 0)
4398 {
4399 if (Wnd->strName.MaximumLength > 0 &&
4400 UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4401 {
4402 ASSERT(Wnd->strName.Buffer != NULL);
4403
4404 Wnd->strName.Length = UnicodeString.Length;
4405 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4407 UnicodeString.Buffer,
4408 UnicodeString.Length);
4409 }
4410 else
4411 {
4412 PWCHAR buf;
4413 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4414 buf = Wnd->strName.Buffer;
4415 Wnd->strName.Buffer = NULL;
4416 if (buf != NULL)
4417 {
4419 }
4420
4422 UnicodeString.Length + sizeof(UNICODE_NULL));
4423 if (Wnd->strName.Buffer != NULL)
4424 {
4425 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4427 UnicodeString.Buffer,
4428 UnicodeString.Length);
4429 Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4430 Wnd->strName.Length = UnicodeString.Length;
4431 }
4432 else
4433 {
4435 goto Exit;
4436 }
4437 }
4438 }
4439 else
4440 {
4441 Wnd->strName.Length = 0;
4442 if (Wnd->strName.Buffer != NULL)
4443 Wnd->strName.Buffer[0] = L'\0';
4444 }
4445
4446 // FIXME: HAX! Windows does not do this in here!
4447 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4448 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4449 /* Send shell notifications */
4450 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4451 {
4452 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4453 }
4454
4455 Ret = TRUE;
4456Exit:
4458 return Ret;
4459}
#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
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
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

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

◆ IntCheckFrameEdge()

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

Definition at line 3830 of file window.c.

3831{
3833 return TRUE;
3834 else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3835 return TRUE;
3836 else
3837 return FALSE;
3838}
const DWORD ExStyle
Definition: appswitch.c:74
#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 1808 of file window.c.

1816{
1817 PWND pWnd = NULL;
1818 HWND hWnd;
1819 PTHREADINFO pti;
1820 BOOL MenuChanged;
1821 BOOL bUnicodeWindow;
1822 PCALLPROCDATA pcpd;
1823
1824 pti = pdeskCreated ? gptiDesktopThread : GetW32ThreadInfo();
1825
1826 if (!(Cs->dwExStyle & WS_EX_LAYOUTRTL))
1827 { // Need both here for wine win.c test_CreateWindow.
1828 //if (Cs->hwndParent && ParentWindow)
1829 if (ParentWindow) // It breaks more tests..... WIP.
1830 {
1831 if ( (Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD &&
1832 ParentWindow->ExStyle & WS_EX_LAYOUTRTL &&
1833 !(ParentWindow->ExStyle & WS_EX_NOINHERITLAYOUT) )
1835 }
1836 else
1837 { /*
1838 * Note from MSDN <https://learn.microsoft.com/en-us/previous-versions/aa913269(v=msdn.10)>:
1839 *
1840 * Dialog boxes and message boxes do not inherit layout, so you must
1841 * set the layout explicitly.
1842 */
1843 if ( Class->fnid != FNID_DIALOG )
1844 {
1845 if (pti->ppi->dwLayout & LAYOUT_RTL)
1846 {
1848 }
1849 }
1850 }
1851 }
1852
1853 /* Automatically add WS_EX_WINDOWEDGE */
1854 if ((Cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
1855 ((!(Cs->dwExStyle & WS_EX_STATICEDGE)) &&
1856 (Cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
1858 else
1859 Cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
1860
1861 /* Is it a unicode window? */
1862 bUnicodeWindow =!(Cs->dwExStyle & WS_EX_SETANSICREATOR);
1863 Cs->dwExStyle &= ~WS_EX_SETANSICREATOR;
1864
1865 /* Allocate the new window */
1867 pdeskCreated ? pdeskCreated : pti->rpdesk,
1868 pti,
1869 (PHANDLE)&hWnd,
1871 sizeof(WND) + Class->cbwndExtra);
1872
1873 if (!pWnd)
1874 {
1875 goto AllocError;
1876 }
1877
1878 TRACE("Created window object with handle %p\n", hWnd);
1879
1880 if (pdeskCreated && pdeskCreated->DesktopWindow == NULL )
1881 { /* HACK: Helper for win32csr/desktopbg.c */
1882 /* If there is no desktop window yet, we must be creating it */
1883 TRACE("CreateWindow setting desktop.\n");
1884 pdeskCreated->DesktopWindow = hWnd;
1885 pdeskCreated->pDeskInfo->spwnd = pWnd;
1886 }
1887
1888 /*
1889 * Fill out the structure describing it.
1890 */
1891 /* Remember, pWnd->head is setup in object.c ... */
1892 WndSetParent(pWnd, ParentWindow);
1893 WndSetOwner(pWnd, OwnerWindow);
1894 pWnd->fnid = 0;
1895 WndSetLastActive(pWnd, pWnd);
1896 // Ramp up compatible version sets.
1897 if ( dwVer >= WINVER_WIN31 )
1898 {
1899 pWnd->state2 |= WNDS2_WIN31COMPAT;
1900 if ( dwVer >= WINVER_WINNT4 )
1901 {
1902 pWnd->state2 |= WNDS2_WIN40COMPAT;
1903 if ( dwVer >= WINVER_WIN2K )
1904 {
1905 pWnd->state2 |= WNDS2_WIN50COMPAT;
1906 }
1907 }
1908 }
1909 pWnd->pcls = Class;
1910 pWnd->hModule = Cs->hInstance;
1911 pWnd->style = Cs->style & ~WS_VISIBLE;
1912 pWnd->ExStyle = Cs->dwExStyle;
1913 pWnd->cbwndExtra = pWnd->pcls->cbwndExtra;
1914 pWnd->pActCtx = acbiBuffer;
1915
1916 if (pti->spDefaultImc && Class->atomClassName != gpsi->atomSysClass[ICLS_BUTTON])
1917 pWnd->hImc = UserHMGetHandle(pti->spDefaultImc);
1918
1919 pWnd->InternalPos.MaxPos.x = pWnd->InternalPos.MaxPos.y = -1;
1920 pWnd->InternalPos.IconPos.x = pWnd->InternalPos.IconPos.y = -1;
1921
1922 if (pWnd->spwndParent != NULL && Cs->hwndParent != 0)
1923 {
1924 pWnd->HideFocus = pWnd->spwndParent->HideFocus;
1925 pWnd->HideAccel = pWnd->spwndParent->HideAccel;
1926 }
1927
1929 pWnd->head.pti->cWindows++;
1930
1931 if (Class->spicn && !Class->spicnSm)
1932 {
1933 HICON IconSmHandle = NULL;
1934 if((Class->spicn->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
1936 {
1937 IconSmHandle = co_IntCopyImage(
1938 UserHMGetHandle(Class->spicn),
1939 IMAGE_ICON,
1943 }
1944 if (!IconSmHandle)
1945 {
1946 /* Retry without copying from resource */
1947 IconSmHandle = co_IntCopyImage(
1948 UserHMGetHandle(Class->spicn),
1949 IMAGE_ICON,
1952 0);
1953 }
1954
1955 if (IconSmHandle)
1956 {
1957 Class->spicnSm = UserGetCurIconObject(IconSmHandle);
1958 Class->CSF_flags |= CSF_CACHEDSMICON;
1959 }
1960 }
1961
1962 if (pWnd->pcls->CSF_flags & CSF_SERVERSIDEPROC)
1964
1965 /* BugBoy Comments: Comment below say that System classes are always created
1966 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1967 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1968
1969 No where can I see in code or through testing does the window change back
1970 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1971 see what problems this would cause. */
1972
1973 // Set WndProc from Class.
1974 if (IsCallProcHandle(pWnd->pcls->lpfnWndProc))
1975 {
1977 if (pcpd)
1978 pWnd->lpfnWndProc = pcpd->pfnClientPrevious;
1979 }
1980 else
1981 {
1982 pWnd->lpfnWndProc = pWnd->pcls->lpfnWndProc;
1983 }
1984
1985 // GetWindowProc, test for non server side default classes and set WndProc.
1986 if ( pWnd->pcls->fnid <= FNID_GHOST && pWnd->pcls->fnid >= FNID_BUTTON )
1987 {
1988 if (bUnicodeWindow)
1989 {
1990 if (GETPFNCLIENTA(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1991 pWnd->lpfnWndProc = GETPFNCLIENTW(pWnd->pcls->fnid);
1992 }
1993 else
1994 {
1995 if (GETPFNCLIENTW(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1996 pWnd->lpfnWndProc = GETPFNCLIENTA(pWnd->pcls->fnid);
1997 }
1998 }
1999
2000 // If not an Unicode caller, set Ansi creator bit.
2001 if (!bUnicodeWindow) pWnd->state |= WNDS_ANSICREATOR;
2002
2003 // Clone Class Ansi/Unicode proc type.
2004 if (pWnd->pcls->CSF_flags & CSF_ANSIPROC)
2005 {
2006 pWnd->state |= WNDS_ANSIWINDOWPROC;
2007 pWnd->Unicode = FALSE;
2008 }
2009 else
2010 { /*
2011 * It seems there can be both an Ansi creator and Unicode Class Window
2012 * WndProc, unless the following overriding conditions occur:
2013 */
2014 if ( !bUnicodeWindow &&
2015 ( Class->atomClassName == gpsi->atomSysClass[ICLS_BUTTON] ||
2016 Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOBOX] ||
2017 Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOLBOX] ||
2018 Class->atomClassName == gpsi->atomSysClass[ICLS_DIALOG] ||
2019 Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT] ||
2020 Class->atomClassName == gpsi->atomSysClass[ICLS_IME] ||
2021 Class->atomClassName == gpsi->atomSysClass[ICLS_LISTBOX] ||
2022 Class->atomClassName == gpsi->atomSysClass[ICLS_MDICLIENT] ||
2023 Class->atomClassName == gpsi->atomSysClass[ICLS_STATIC] ) )
2024 { // Override Class and set the window Ansi WndProc.
2025 pWnd->state |= WNDS_ANSIWINDOWPROC;
2026 pWnd->Unicode = FALSE;
2027 }
2028 else
2029 { // Set the window Unicode WndProc.
2030 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
2031 pWnd->Unicode = TRUE;
2032 }
2033 }
2034
2035 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
2036 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
2037 Dont understand why it does this. */
2038 if (Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT])
2039 {
2040 PCALLPROCDATA CallProc;
2041 CallProc = CreateCallProc(pWnd->head.rpdesk, pWnd->lpfnWndProc, pWnd->Unicode , pWnd->head.pti->ppi);
2042
2043 if (!CallProc)
2044 {
2046 ERR("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %p\n", hWnd);
2047 }
2048 else
2049 {
2050 UserAddCallProcToClass(pWnd->pcls, CallProc);
2051 }
2052 }
2053
2055 pWnd->PropListItems = 0;
2056
2057 if ( WindowName->Buffer != NULL && WindowName->Length > 0 )
2058 {
2060 WindowName->Length + sizeof(UNICODE_NULL));
2061 if (pWnd->strName.Buffer == NULL)
2062 {
2063 goto AllocError;
2064 }
2065
2066 RtlCopyMemory(pWnd->strName.Buffer, WindowName->Buffer, WindowName->Length);
2067 pWnd->strName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0';
2068 pWnd->strName.Length = WindowName->Length;
2069 pWnd->strName.MaximumLength = WindowName->Length + sizeof(UNICODE_NULL);
2070 }
2071
2072 /* Correct the window style. */
2073 if ((pWnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2074 {
2075 pWnd->style |= WS_CLIPSIBLINGS;
2076 if (!(pWnd->style & WS_POPUP))
2077 {
2078 pWnd->style |= WS_CAPTION;
2079 }
2080 }
2081
2082 /* WS_EX_WINDOWEDGE depends on some other styles */
2083 if (pWnd->ExStyle & WS_EX_DLGMODALFRAME)
2084 pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2085 else if (pWnd->style & (WS_DLGFRAME | WS_THICKFRAME))
2086 {
2087 if (!((pWnd->ExStyle & WS_EX_STATICEDGE) &&
2088 (pWnd->style & (WS_CHILD | WS_POPUP))))
2089 pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2090 }
2091 else
2092 pWnd->ExStyle &= ~WS_EX_WINDOWEDGE;
2093
2094 if (!(pWnd->style & (WS_CHILD | WS_POPUP)))
2096
2097 /* Set the window menu */
2098 if ((Cs->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2099 {
2100 if (Cs->hMenu)
2101 {
2102 IntSetMenu(pWnd, Cs->hMenu, &MenuChanged);
2103 }
2104 else if (pWnd->pcls->lpszMenuName) // Take it from the parent.
2105 {
2106 UNICODE_STRING MenuName;
2107 HMENU hMenu;
2108
2109 if (IS_INTRESOURCE(pWnd->pcls->lpszMenuName))
2110 {
2111 MenuName.Length = 0;
2112 MenuName.MaximumLength = 0;
2113 MenuName.Buffer = pWnd->pcls->lpszMenuName;
2114 }
2115 else
2116 {
2117 RtlInitUnicodeString( &MenuName, pWnd->pcls->lpszMenuName);
2118 }
2119 hMenu = co_IntCallLoadMenu( pWnd->pcls->hModule, &MenuName);
2120 if (hMenu) IntSetMenu(pWnd, hMenu, &MenuChanged);
2121 }
2122 }
2123 else // Not a child
2124 pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
2125
2126
2127 if ( ParentWindow &&
2128 ParentWindow != ParentWindow->head.rpdesk->spwndMessage &&
2129 ParentWindow != ParentWindow->head.rpdesk->pDeskInfo->spwnd )
2130 {
2131 PWND Owner = IntGetNonChildAncestor(ParentWindow);
2132
2133 if (!IntValidateOwnerDepth(pWnd, Owner))
2134 {
2136 goto Error;
2137 }
2138 if ( pWnd->spwndOwner &&
2139 pWnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
2140 {
2141 pWnd->ExStyle |= WS_EX_TOPMOST;
2142 }
2143 if ( pWnd->spwndOwner &&
2144 Class->atomClassName != gpsi->atomSysClass[ICLS_IME] &&
2145 pti != pWnd->spwndOwner->head.pti)
2146 {
2147 //ERR("CreateWindow Owner in.\n");
2148 UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE);
2149 }
2150 }
2151
2152 /* Insert the window into the thread's window list. */
2154
2155 /* Handle "CS_CLASSDC", it is tested first. */
2156 if ( (pWnd->pcls->style & CS_CLASSDC) && !(pWnd->pcls->pdce) )
2157 { /* One DCE per class to have CLASS. */
2158 pWnd->pcls->pdce = DceAllocDCE( pWnd, DCE_CLASS_DC );
2159 }
2160 else if ( pWnd->pcls->style & CS_OWNDC)
2161 { /* Allocate a DCE for this window. */
2163 }
2164
2165 return pWnd;
2166
2167AllocError:
2168 ERR("IntCreateWindow Allocation Error.\n");
2170Error:
2171 if(pWnd)
2173 return NULL;
2174}
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:1621
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
UINT HideAccel
Definition: ntuser.h:759
struct _WND::@5286 InternalPos
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:5475
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:214
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 2834 of file window.c.

2835{
2836 HWND* List;
2837 HWND* phWnd;
2838 PWND pWnd;
2840
2842 if (!List)
2843 return;
2844
2845 for (phWnd = List; *phWnd; ++phWnd)
2846 {
2847 pWnd = ValidateHwndNoErr(*phWnd);
2848 if (pWnd == NULL)
2849 continue;
2850 ASSERT(pWnd->spwndOwner == Window);
2851 ASSERT(pWnd != Window);
2852
2853 WndSetOwner(pWnd, NULL);
2855 {
2856 UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2858 UserDerefObjectCo(pWnd); // Temp HACK?
2859 }
2860 else
2861 {
2862 ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2863 }
2864 }
2865
2867}
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:109
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:41
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1317
#define WS_DISABLED
Definition: pedump.c:621
_In_ BOOL bEnable
Definition: winddi.h:3426
#define WM_ENABLE
Definition: winuser.h:1634
#define WM_CANCELMODE
Definition: winuser.h:1654

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

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

Definition at line 3078 of file window.c.

3082{
3083 BOOL CheckWindowName;
3084 HWND *List, *phWnd;
3085 HWND Ret = NULL;
3086 UNICODE_STRING CurrentWindowName;
3087
3088 ASSERT(Parent);
3089
3090 CheckWindowName = WindowName->Buffer != 0;
3091
3093 {
3094 phWnd = List;
3095 if(ChildAfter)
3096 {
3097 /* skip handles before and including ChildAfter */
3098 while(*phWnd && (*(phWnd++) != UserHMGetHandle(ChildAfter)))
3099 ;
3100 }
3101
3102 /* search children */
3103 while(*phWnd)
3104 {
3105 PWND Child;
3106 if(!(Child = UserGetWindowObject(*(phWnd++))))
3107 {
3108 continue;
3109 }
3110
3111 /* Do not send WM_GETTEXT messages in the kernel mode version!
3112 The user mode version however calls GetWindowText() which will
3113 send WM_GETTEXT messages to windows belonging to its processes */
3114 if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
3115 {
3116 // FIXME: LARGE_STRING truncated
3117 CurrentWindowName.Buffer = Child->strName.Buffer;
3118 CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
3119 CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
3120 if(!CheckWindowName ||
3121 (Child->strName.Length < 0xFFFF &&
3122 !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
3123 {
3124 Ret = UserHMGetHandle(Child);
3125 break;
3126 }
3127 }
3128 }
3130 }
3131
3132 return Ret;
3133}
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 1714 of file window.c.

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

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:4980
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:2494
#define WM_NCMOUSELEAVE
Definition: winuser.h:1861

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 if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD &&
1698 !(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY))
1699 {
1700 if (VerifyWnd(pWindow->spwndParent) && !UserIsDesktopWindow(pWindow->spwndParent))
1701 {
1703 UserRefObjectCo(pWindow->spwndParent, &Ref);
1706 MAKEWPARAM( msg, pWindow->IDMenu),
1707 (LPARAM)UserHMGetHandle(pWindow) );
1709 }
1710 }
1711}
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:88
#define MAKEWPARAM(l, h)
Definition: winuser.h:4085
#define WM_PARENTNOTIFY
Definition: winuser.h:1822

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(), and IntEnableWindow().

◆ 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 4667 of file window.c.

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

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 4105 of file window.c.

4106{
4107 LONG ret;
4108
4110
4111 if (hWnd == IntGetDesktopWindow())
4112 {
4114 UserLeave();
4115 return 0;
4116 }
4117
4118 ret = co_IntSetWindowLongPtr(hWnd, Index, NewValue, FALSE, sizeof(LONG), TRUE);
4119
4120 UserLeave();
4121
4122 return ret;
4123}
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:1104
PVOID Win32Thread
Definition: ketypes.h:2029
#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 2683 of file window.c.

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

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

◆ NtUserDefSetText()

BOOL APIENTRY NtUserDefSetText ( HWND  hWnd,
PLARGE_STRING  WindowText 
)

Definition at line 4471 of file window.c.

4472{
4473 PWND Wnd;
4474 LARGE_STRING SafeText;
4476 BOOL Ret = TRUE;
4477
4478 TRACE("Enter NtUserDefSetText\n");
4479
4480 if (WindowText != NULL)
4481 {
4482 _SEH2_TRY
4483 {
4484 SafeText = ProbeForReadLargeString(WindowText);
4485 }
4487 {
4488 Ret = FALSE;
4490 }
4491 _SEH2_END;
4492
4493 if (!Ret)
4494 return FALSE;
4495 }
4496 else
4497 return TRUE;
4498
4500
4501 if(!(Wnd = UserGetWindowObject(hWnd)))
4502 {
4503 UserLeave();
4504 return FALSE;
4505 }
4506
4507 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4508 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4509 // Now we know what the bAnsi is for.
4511 if (SafeText.Buffer)
4512 {
4513 _SEH2_TRY
4514 {
4515 if (SafeText.bAnsi)
4516 ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(CHAR));
4517 else
4518 ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(WCHAR));
4520 }
4522 {
4523 Ret = FALSE;
4525 }
4526 _SEH2_END;
4527 if (!Ret) goto Exit;
4528 }
4529
4530 if (UnicodeString.Length != 0)
4531 {
4532 if (Wnd->strName.MaximumLength > 0 &&
4533 UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4534 {
4535 ASSERT(Wnd->strName.Buffer != NULL);
4536
4537 Wnd->strName.Length = UnicodeString.Length;
4538 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4540 UnicodeString.Buffer,
4541 UnicodeString.Length);
4542 }
4543 else
4544 {
4545 PWCHAR buf;
4546 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4547 buf = Wnd->strName.Buffer;
4548 Wnd->strName.Buffer = NULL;
4549 if (buf != NULL)
4550 {
4552 }
4553
4555 UnicodeString.Length + sizeof(UNICODE_NULL));
4556 if (Wnd->strName.Buffer != NULL)
4557 {
4558 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4560 UnicodeString.Buffer,
4561 UnicodeString.Length);
4562 Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4563 Wnd->strName.Length = UnicodeString.Length;
4564 }
4565 else
4566 {
4568 Ret = FALSE;
4569 goto Exit;
4570 }
4571 }
4572 }
4573 else
4574 {
4575 Wnd->strName.Length = 0;
4576 if (Wnd->strName.Buffer != NULL)
4577 Wnd->strName.Buffer[0] = L'\0';
4578 }
4579
4580 // FIXME: HAX! Windows does not do this in here!
4581 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4582 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4583 /* Send shell notifications */
4584 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4585 {
4586 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) hWnd, FALSE); // FIXME Flashing?
4587 }
4588
4589 Ret = TRUE;
4590Exit:
4592 TRACE("Leave NtUserDefSetText, ret=%i\n", Ret);
4593 UserLeave();
4594 return Ret;
4595}
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 3054 of file window.c.

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

Referenced by DestroyWindow(), and User32DestroyImeUIWindow().

◆ NtUserFindWindowEx()

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

Definition at line 3160 of file window.c.

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

Referenced by FindWindowExW(), and START_TEST().

◆ NtUserGetAncestor()

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

Definition at line 3420 of file window.c.

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

Referenced by GetAncestor().

◆ NtUserGetComboBoxInfo()

BOOL APIENTRY NtUserGetComboBoxInfo ( HWND  hWnd,
PCOMBOBOXINFO  pcbi 
)

Definition at line 3484 of file window.c.

3487{
3488 PWND Wnd;
3489 PPROCESSINFO ppi;
3490 BOOL NotSameppi = FALSE;
3491 BOOL Ret = TRUE;
3492
3493 TRACE("Enter NtUserGetComboBoxInfo\n");
3495
3496 if (!(Wnd = UserGetWindowObject(hWnd)))
3497 {
3498 Ret = FALSE;
3499 goto Exit;
3500 }
3501 _SEH2_TRY
3502 {
3503 ProbeForWrite(pcbi, sizeof(COMBOBOXINFO), 1);
3504 }
3506 {
3508 Ret = FALSE;
3509 _SEH2_YIELD(goto Exit);
3510 }
3511 _SEH2_END;
3512
3513 if (pcbi->cbSize < sizeof(COMBOBOXINFO))
3514 {
3516 Ret = FALSE;
3517 goto Exit;
3518 }
3519
3520 // Pass the user pointer, it was already probed.
3522 {
3524 goto Exit;
3525 }
3526
3528 NotSameppi = ppi != Wnd->head.pti->ppi;
3529 if (NotSameppi)
3530 {
3531 KeAttachProcess(&Wnd->head.pti->ppi->peProcess->Pcb);
3532 }
3533
3534 _SEH2_TRY
3535 {
3536 LPHEADCOMBO lphc = ((PWND2CBOX)Wnd)->pCBox;
3537 pcbi->rcItem = lphc->textRect;
3538 pcbi->rcButton = lphc->buttonRect;
3539 pcbi->stateButton = 0;
3540 if (lphc->wState & CBF_BUTTONDOWN)
3542 if (RECTL_bIsEmptyRect(&lphc->buttonRect))
3544 pcbi->hwndCombo = lphc->self;
3545 pcbi->hwndItem = lphc->hWndEdit;
3546 pcbi->hwndList = lphc->hWndLBox;
3547 }
3549 {
3550 Ret = FALSE;
3552 }
3553 _SEH2_END;
3554
3555Exit:
3556 if (NotSameppi) KeDetachProcess();
3557 TRACE("Leave NtUserGetComboBoxInfo, ret=%i\n", Ret);
3558 UserLeave();
3559 return Ret;
3560}
#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:3788
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
struct _WND2CBOX * PWND2CBOX
#define CBF_BUTTONDOWN
Definition: window.c:3478
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2941
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1960
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2953

Referenced by GetComboBoxInfo().

◆ NtUserGetListBoxInfo()

DWORD APIENTRY NtUserGetListBoxInfo ( HWND  hWnd)

Definition at line 3595 of file window.c.

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

Referenced by GetListBoxInfo().

◆ NtUserInternalGetWindowText()

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

Definition at line 4605 of file window.c.

4606{
4607 PWND Wnd;
4609 INT Result = 0;
4610
4611 TRACE("Enter NtUserInternalGetWindowText\n");
4613
4614 if(lpString && (nMaxCount <= 1))
4615 {
4617 goto Exit; // Return 0
4618 }
4619
4620 if(!(Wnd = UserGetWindowObject(hWnd)))
4621 {
4622 goto Exit; // Return 0
4623 }
4624
4625 Result = Wnd->strName.Length / sizeof(WCHAR);
4626 if(lpString)
4627 {
4628 const WCHAR Terminator = L'\0';
4629 INT Copy;
4630 WCHAR *Buffer = (WCHAR*)lpString;
4631
4632 Copy = min(nMaxCount - 1, Result);
4633 if(Copy > 0)
4634 {
4635 Status = MmCopyToCaller(Buffer, Wnd->strName.Buffer, Copy * sizeof(WCHAR));
4636 if(!NT_SUCCESS(Status))
4637 {
4639 Result = 0;
4640 goto Exit;
4641 }
4642 Buffer += Copy;
4643 }
4644
4645 Status = MmCopyToCaller(Buffer, &Terminator, sizeof(WCHAR));
4646 if(!NT_SUCCESS(Status))
4647 {
4649 Result = 0;
4650 goto Exit;
4651 }
4652
4653 Result = Copy;
4654 }
4655
4656Exit:
4657 TRACE("Leave NtUserInternalGetWindowText, ret=%i\n", Result);
4658 UserLeave();
4659 return Result;
4660}
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:4953

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

◆ NtUserQueryWindow()

DWORD_PTR APIENTRY NtUserQueryWindow ( HWND  hWnd,
DWORD  Index 
)

Definition at line 4207 of file window.c.

4208{
4209/* Console Leader Process CID Window offsets */
4210#define GWLP_CONSOLE_LEADER_PID 0
4211#define GWLP_CONSOLE_LEADER_TID 4
4212
4213 DWORD_PTR Result = 0;
4214 PWND pWnd, pwndActive;
4215 PTHREADINFO pti, ptiActive;
4216
4217 TRACE("Enter NtUserQueryWindow\n");
4219
4220 if (!(pWnd = UserGetWindowObject(hWnd)))
4221 {
4222 goto Exit; // Return 0
4223 }
4224
4225 switch(Index)
4226 {
4228 {
4229 if ( (pWnd->head.pti->TIF_flags & TIF_CSRSSTHREAD) &&
4231 {
4232 // IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_PID)
4233 Result = (DWORD_PTR)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_PID)));
4234 }
4235 else
4236 {
4238 }
4239 break;
4240 }
4241
4243 {
4244 if ( (pWnd->head.pti->TIF_flags & TIF_CSRSSTHREAD) &&
4246 {
4247 // IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_TID)
4248 Result = (DWORD_PTR)(*((LONG_PTR*)((PCHAR)(pWnd + 1) + GWLP_CONSOLE_LEADER_TID)));
4249 }
4250 else
4251 {
4253 }
4254 break;
4255 }
4256
4258 Result = (DWORD_PTR)(pWnd->head.pti->MessageQueue->spwndActive ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndActive) : 0);
4259 break;
4260
4261 case QUERY_WINDOW_FOCUS:
4262 Result = (DWORD_PTR)(pWnd->head.pti->MessageQueue->spwndFocus ? UserHMGetHandle(pWnd->head.pti->MessageQueue->spwndFocus) : 0);
4263 break;
4264
4266 Result = (pWnd->fnid == FNID_GHOST) || MsqIsHung(pWnd->head.pti, MSQ_HUNG);
4267 break;
4268
4270 Result = (DWORD_PTR)pWnd->head.pti->pEThread->Cid.UniqueProcess;
4271 break;
4272
4274 Result = (pWnd->head.pti->MessageQueue == gpqForeground);
4275 break;
4276
4277 case QUERY_WINDOW_DEFAULT_IME: /* default IME window */
4278 if (pWnd->head.pti->spwndDefaultIme)
4279 Result = (DWORD_PTR)UserHMGetHandle(pWnd->head.pti->spwndDefaultIme);
4280 break;
4281
4282 case QUERY_WINDOW_DEFAULT_ICONTEXT: /* default input context handle */
4283 if (pWnd->head.pti->spDefaultImc)
4284 Result = (DWORD_PTR)UserHMGetHandle(pWnd->head.pti->spDefaultImc);
4285 break;
4286
4289 {
4290 pwndActive = gpqForeground->spwndActive;
4292 if (pti->rpdesk == pwndActive->head.rpdesk)
4293 {
4294 ptiActive = pwndActive->head.pti;
4295 if (ptiActive->spwndDefaultIme)
4297 }
4298 }
4299 break;
4300 }
4301
4302Exit:
4303 TRACE("Leave NtUserQueryWindow, ret=%u\n", Result);
4304 UserLeave();
4305 return Result;
4306}
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
#define QUERY_WINDOW_DEFAULT_ICONTEXT
Definition: ntuser.h:2840
#define QUERY_WINDOW_UNIQUE_THREAD_ID
Definition: ntuser.h:2833
#define QUERY_WINDOW_ACTIVE_IME
Definition: ntuser.h:2841
#define TIF_CSRSSTHREAD
Definition: ntuser.h:266
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2835
#define QUERY_WINDOW_ACTIVE
Definition: ntuser.h:2834
#define QUERY_WINDOW_REAL_ID
Definition: ntuser.h:2837
#define QUERY_WINDOW_FOREGROUND
Definition: ntuser.h:2838
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2832
#define QUERY_WINDOW_ISHUNG
Definition: ntuser.h:2836
#define QUERY_WINDOW_DEFAULT_IME
Definition: ntuser.h:2839
#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 4312 of file window.c.

4313{
4314 UNICODE_STRING SafeMessageName;
4316 UINT Ret = 0;
4317
4318 TRACE("Enter NtUserRegisterWindowMessage\n");
4320
4321 if(MessageNameUnsafe == NULL)
4322 {
4324 goto Exit; // Return 0
4325 }
4326
4327 Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe);
4328 if(!NT_SUCCESS(Status))
4329 {
4331 goto Exit; // Return 0
4332 }
4333
4334 Ret = (UINT)IntAddAtom(SafeMessageName.Buffer);
4335 if (SafeMessageName.Buffer)
4336 ExFreePoolWithTag(SafeMessageName.Buffer, TAG_STRING);
4337
4338Exit:
4339 TRACE("Leave NtUserRegisterWindowMessage, ret=%u\n", Ret);
4340 UserLeave();
4341 return Ret;
4342}
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 3663 of file window.c.

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

Referenced by SetParent().

◆ NtUserSetShellWindowEx()

BOOL APIENTRY NtUserSetShellWindowEx ( HWND  hwndShell,
HWND  hwndListView 
)

Definition at line 3730 of file window.c.

3731{
3732 PWINSTATION_OBJECT WinStaObject;
3733 PWND WndShell, WndListView;
3734 BOOL Ret = FALSE;
3737 PTHREADINFO ti;
3738
3739 TRACE("Enter NtUserSetShellWindowEx\n");
3741
3742 if (!(WndShell = UserGetWindowObject(hwndShell)))
3743 {
3744 goto Exit; // Return FALSE
3745 }
3746
3747 if (!(WndListView = UserGetWindowObject(hwndListView)))
3748 {
3749 goto Exit; // Return FALSE
3750 }
3751
3753 UserMode,
3754 0,
3755 &WinStaObject,
3756 0);
3757
3758 if (!NT_SUCCESS(Status))
3759 {
3761 goto Exit; // Return FALSE
3762 }
3763
3764 /*
3765 * Test if we are permitted to change the shell window.
3766 */
3767 if (WinStaObject->ShellWindow)
3768 {
3769 ObDereferenceObject(WinStaObject);
3770 goto Exit; // Return FALSE
3771 }
3772
3773 /*
3774 * Move shell window into background.
3775 */
3776 if (hwndListView && hwndListView != hwndShell)
3777 {
3778 /*
3779 * Disabled for now to get Explorer working.
3780 * -- Filip, 01/nov/2003
3781 */
3782#if 0
3784#endif
3785
3786 if (WndListView->ExStyle & WS_EX_TOPMOST)
3787 {
3788 ObDereferenceObject(WinStaObject);
3789 goto Exit; // Return FALSE
3790 }
3791 }
3792
3793 if (WndShell->ExStyle & WS_EX_TOPMOST)
3794 {
3795 ObDereferenceObject(WinStaObject);
3796 goto Exit; // Return FALSE
3797 }
3798
3799 UserRefObjectCo(WndShell, &Ref);
3800 WndShell->state2 |= WNDS2_BOTTOMMOST;
3802
3803 WinStaObject->ShellWindow = hwndShell;
3804 WinStaObject->ShellListView = hwndListView;
3805
3806 ti = GetW32ThreadInfo();
3807 if (ti->pDeskInfo)
3808 {
3809 ti->pDeskInfo->hShellWindow = hwndShell;
3810 ti->pDeskInfo->spwndShell = WndShell;
3811 ti->pDeskInfo->spwndBkGnd = WndListView;
3812 ti->pDeskInfo->ppiShellProcess = ti->ppi;
3813 }
3814
3816
3817 UserDerefObjectCo(WndShell);
3818
3819 ObDereferenceObject(WinStaObject);
3820 Ret = TRUE;
3821
3822Exit:
3823 TRACE("Leave NtUserSetShellWindowEx, ret=%i\n", Ret);
3824 UserLeave();
3825 return Ret;
3826}
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:2618
#define VK_ESCAPE
Definition: winuser.h:2233

Referenced by SetShellWindow(), and SetShellWindowEx().

◆ NtUserSetWindowFNID()

BOOL APIENTRY NtUserSetWindowFNID ( HWND  hWnd,
WORD  fnID 
)

Definition at line 4348 of file window.c.

4350{
4351 PWND Wnd;
4352 BOOL Ret = FALSE;
4353
4354 TRACE("Enter NtUserSetWindowFNID\n");
4356
4357 if (!(Wnd = UserGetWindowObject(hWnd)))
4358 {
4359 goto Exit; // Return FALSE
4360 }
4361
4362 if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process())
4363 {
4365 goto Exit; // Return FALSE
4366 }
4367
4368 // From user land we only set these.
4369 if (fnID != FNID_DESTROY)
4370 {
4371 /* HACK: The minimum should be FNID_BUTTON, but menu code relies on this */
4372 if (fnID < FNID_FIRST || fnID > FNID_GHOST ||
4373 Wnd->fnid != 0)
4374 {
4376 goto Exit; // Return FALSE
4377 }
4378 }
4379
4380 Wnd->fnid |= fnID;
4381 Ret = TRUE;
4382
4383Exit:
4384 TRACE("Leave NtUserSetWindowFNID\n");
4385 UserLeave();
4386 return Ret;
4387}
#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 4061 of file window.c.

4062{
4063 LONG ret;
4064
4066
4067 if (hWnd == IntGetDesktopWindow())
4068 {
4070 UserLeave();
4071 return 0;
4072 }
4073
4074 ret = (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4075
4076 UserLeave();
4077
4078 return ret;
4079}

Referenced by SetWindowLongA(), and SetWindowLongW().

◆ NtUserSetWindowWord()

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

Definition at line 4136 of file window.c.

4137{
4138 PWND Window;
4139 WORD OldValue;
4140 WORD Ret = 0;
4141
4142 TRACE("Enter NtUserSetWindowWord\n");
4144
4145 if (hWnd == IntGetDesktopWindow())
4146 {
4148 goto Exit; // Return 0
4149 }
4150
4152 {
4153 goto Exit; // Return 0
4154 }
4155
4156 switch (Index)
4157 {
4158 case GWL_ID:
4159 case GWL_HINSTANCE:
4160 case GWL_HWNDPARENT:
4162 goto Exit;
4163
4164 default:
4165 if (Index < 0)
4166 {
4168 goto Exit; // Return 0
4169 }
4170 }
4171
4172 if ((ULONG)Index > (Window->cbwndExtra - sizeof(WORD)))
4173 {
4175 goto Exit; // Return 0
4176 }
4177
4178 OldValue = *((WORD *)((PCHAR)(Window + 1) + Index));
4179 *((WORD *)((PCHAR)(Window + 1) + Index)) = NewValue;
4180
4181 Ret = OldValue;
4182
4183Exit:
4184 TRACE("Leave NtUserSetWindowWord, ret=%u\n", Ret);
4185 UserLeave();
4186 return Ret;
4187}
unsigned short WORD
Definition: ntddk_ex.h:93
LONG FASTCALL co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
Definition: window.c:4038
#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 2626 of file window.c.

2629{
2630 LARGE_STRING lstrTemp;
2631 PVOID pvBuffer = NULL;
2632
2633 _SEH2_TRY
2634 {
2635 /* Probe and copy the string */
2636 ProbeForRead(plstrUnsafe, sizeof(LARGE_STRING), sizeof(ULONG));
2637 lstrTemp = *plstrUnsafe;
2638 }
2640 {
2641 /* Fail */
2643 }
2644 _SEH2_END
2645
2646 if (lstrTemp.Length != 0)
2647 {
2648 /* Allocate a buffer from paged pool */
2649 pvBuffer = ExAllocatePoolWithTag(PagedPool, lstrTemp.Length, TAG_STRING);
2650 if (!pvBuffer)
2651 {
2652 return STATUS_NO_MEMORY;
2653 }
2654
2655 _SEH2_TRY
2656 {
2657 /* Probe and copy the buffer */
2658 ProbeForRead(lstrTemp.Buffer, lstrTemp.Length, sizeof(WCHAR));
2659 RtlCopyMemory(pvBuffer, lstrTemp.Buffer, lstrTemp.Length);
2660 }
2662 {
2663 /* Cleanup and fail */
2664 ExFreePoolWithTag(pvBuffer, TAG_STRING);
2666 }
2667 _SEH2_END
2668 }
2669
2670 /* Set the output string */
2671 plstrSafe->Buffer = pvBuffer;
2672 plstrSafe->Length = lstrTemp.Length;
2673 plstrSafe->MaximumLength = lstrTemp.Length;
2674
2675 return STATUS_SUCCESS;
2676}
#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 3356 of file window.c.

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

Referenced by NtUserGetAncestor().

◆ UserGetShellWindow()

HWND FASTCALL UserGetShellWindow ( VOID  )

Definition at line 3697 of file window.c.

3698{
3699 PWINSTATION_OBJECT WinStaObject;
3700 HWND Ret;
3701
3703 UserMode,
3704 0,
3705 &WinStaObject,
3706 0);
3707
3708 if (!NT_SUCCESS(Status))
3709 {
3711 return NULL;
3712 }
3713
3714 Ret = (HWND)WinStaObject->ShellWindow;
3715
3716 ObDereferenceObject(WinStaObject);
3717 return Ret;
3718}

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:881

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().