ReactOS 0.4.17-dev-37-g0bfb40d
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 3473 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 1158 of file window.c.

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

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

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

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

◆ co_UserDestroyWindow()

BOOLEAN co_UserDestroyWindow ( PVOID  Object)

Definition at line 2865 of file window.c.

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

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

◆ co_UserFreeWindow()

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

Definition at line 575 of file window.c.

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

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

◆ co_UserSetParent()

HWND FASTCALL co_UserSetParent ( HWND  hWndChild,
HWND  hWndNewParent 
)

Definition at line 1295 of file window.c.

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

4034{
4035 return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4036}
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3836

Referenced by DesktopWindowProc(), and NtUserSetWindowWord().

◆ co_UserSetWindowLongPtr()

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

Definition at line 4039 of file window.c.

4040{
4041 return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
4042}

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserWnd  )

◆ DefSetText()

BOOL APIENTRY DefSetText ( PWND  Wnd,
PCWSTR  WindowText 
)

Definition at line 4385 of file window.c.

4386{
4388 BOOL Ret = FALSE;
4389
4390 RtlInitUnicodeString(&UnicodeString, WindowText);
4391
4392 if (UnicodeString.Length != 0)
4393 {
4394 if (Wnd->strName.MaximumLength > 0 &&
4396 {
4397 ASSERT(Wnd->strName.Buffer != NULL);
4398
4400 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4404 }
4405 else
4406 {
4407 PWCHAR buf;
4408 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4409 buf = Wnd->strName.Buffer;
4410 Wnd->strName.Buffer = NULL;
4411 if (buf != NULL)
4412 {
4414 }
4415
4418 if (Wnd->strName.Buffer != NULL)
4419 {
4420 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4426 }
4427 else
4428 {
4430 goto Exit;
4431 }
4432 }
4433 }
4434 else
4435 {
4436 Wnd->strName.Length = 0;
4437 if (Wnd->strName.Buffer != NULL)
4438 Wnd->strName.Buffer[0] = L'\0';
4439 }
4440
4441 // FIXME: HAX! Windows does not do this in here!
4442 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4443 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4444 /* Send shell notifications */
4445 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4446 {
4447 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4448 }
4449
4450 Ret = TRUE;
4451Exit:
4453 return Ret;
4454}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
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
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
short WCHAR
Definition: pedump.c:58
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
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64

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

◆ IntBuildHwndList()

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

Definition at line 1422 of file window.c.

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

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

◆ IntCheckFrameEdge()

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

Definition at line 3825 of file window.c.

3826{
3828 return TRUE;
3829 else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3830 return TRUE;
3831 else
3832 return FALSE;
3833}
const DWORD ExStyle
Definition: appswitch.c:73
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_DLGFRAME
Definition: pedump.c:626
#define WS_EX_STATICEDGE
Definition: winuser.h:403

Referenced by co_IntSetWindowLongPtr().

◆ IntCreateWindow()

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

Definition at line 1805 of file window.c.

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

2831{
2832 HWND* List;
2833 HWND* phWnd;
2834 PWND pWnd;
2836
2838 if (!List)
2839 return;
2840
2841 for (phWnd = List; *phWnd; ++phWnd)
2842 {
2843 pWnd = ValidateHwndNoErr(*phWnd);
2844 if (pWnd == NULL)
2845 continue;
2846 ASSERT(pWnd->spwndOwner == Window);
2847 ASSERT(pWnd != Window);
2848
2849 WndSetOwner(pWnd, NULL);
2851 {
2852 UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2854 UserDerefObjectCo(pWnd); // Temp HACK?
2855 }
2856 else
2857 {
2858 ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2859 }
2860 }
2861
2863}
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:97
HWND *FASTCALL IntWinListOwnedPopups(PWND Window)
Definition: window.c:316

Referenced by co_UserDestroyWindow().

◆ IntEnableWindow()

BOOL FASTCALL IntEnableWindow ( HWND  hWnd,
BOOL  bEnable 
)

Definition at line 221 of file window.c.

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

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

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

Definition at line 3073 of file window.c.

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

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

Referenced by co_UserCreateWindowEx().

◆ IntFreeHwndList()

VOID FASTCALL IntFreeHwndList ( PWINDOWLIST  pwlTarget)

Definition at line 1467 of file window.c.

1468{
1469 PWINDOWLIST pwl, *ppwl;
1470
1471 for (ppwl = &gpwlList; *ppwl; ppwl = &(*ppwl)->pNextList)
1472 {
1473 if (*ppwl != pwlTarget)
1474 continue;
1475
1476 *ppwl = pwlTarget->pNextList;
1477
1478 if (gpwlCache)
1479 {
1480 if (WL_CAPACITY(pwlTarget) > WL_CAPACITY(gpwlCache))
1481 {
1482 pwl = gpwlCache;
1483 gpwlCache = pwlTarget;
1485 }
1486 else
1487 {
1489 }
1490 }
1491 else
1492 {
1493 gpwlCache = pwlTarget;
1494 }
1495
1496 break;
1497 }
1498}
#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 352 of file window.c.

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

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

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

Referenced by WinPosFixupFlags().

◆ IntGetWindowContextHelpId()

DWORD FASTCALL IntGetWindowContextHelpId ( PWND  pWnd)

Definition at line 439 of file window.c.

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

Referenced by IntDefWindowProc().

◆ IntGetWindowObject()

PWND FASTCALL IntGetWindowObject ( HWND  hWnd)

Definition at line 75 of file window.c.

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

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

◆ IntGetWindowProc()

WNDPROC FASTCALL IntGetWindowProc ( PWND  pWnd,
BOOL  Ansi 
)

Definition at line 782 of file window.c.

784{
785 INT i;
786 PCLS Class;
787 WNDPROC gcpd, Ret = 0;
788
790
791 Class = pWnd->pcls;
792
794 {
795 for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
796 {
797 if (GETPFNSERVER(i) == pWnd->lpfnWndProc)
798 {
799 if (Ansi)
800 Ret = GETPFNCLIENTA(i);
801 else
802 Ret = GETPFNCLIENTW(i);
803 }
804 }
805 return Ret;
806 }
807
808 if (Class->fnid == FNID_EDIT)
809 Ret = pWnd->lpfnWndProc;
810 else
811 {
812 Ret = pWnd->lpfnWndProc;
813
814 if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
815 {
816 if (Ansi)
817 {
818 if (GETPFNCLIENTW(Class->fnid) == pWnd->lpfnWndProc)
819 Ret = GETPFNCLIENTA(Class->fnid);
820 }
821 else
822 {
823 if (GETPFNCLIENTA(Class->fnid) == pWnd->lpfnWndProc)
824 Ret = GETPFNCLIENTW(Class->fnid);
825 }
826 }
827 if ( Ret != pWnd->lpfnWndProc)
828 return Ret;
829 }
830 if ( Ansi == !!(pWnd->state & WNDS_ANSIWINDOWPROC) )
831 return Ret;
832
833 gcpd = (WNDPROC)UserGetCPD(
834 pWnd,
836 (ULONG_PTR)Ret);
837
838 return (gcpd ? gcpd : Ret);
839}
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 1373 of file window.c.

1374{
1375 PWINDOWLIST pwlOld, pwlNew;
1376 SIZE_T ibOld, ibNew;
1377
1378#define GROW_COUNT 8
1379 pwlOld = *ppwl;
1380 ibOld = (LPBYTE)pwlOld->phwndLast - (LPBYTE)pwlOld;
1381 ibNew = ibOld + GROW_COUNT * sizeof(HWND);
1382#undef GROW_COUNT
1383 pwlNew = IntReAllocatePoolWithTag(PagedPool, pwlOld, ibOld, ibNew, USERTAG_WINDOWLIST);
1384 if (!pwlNew)
1385 return FALSE;
1386
1387 pwlNew->phwndLast = (HWND *)((LPBYTE)pwlNew + ibOld);
1388 pwlNew->phwndEnd = (HWND *)((LPBYTE)pwlNew + ibNew);
1389 *ppwl = pwlNew;
1390 return TRUE;
1391}
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 929 of file window.c.

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

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

◆ IntIsTopLevelWindow()

BOOL FASTCALL IntIsTopLevelWindow ( PWND  pWnd)

Definition at line 360 of file window.c.

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

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntIsWindow()

◆ IntIsWindowVisible()

BOOL FASTCALL IntIsWindowVisible ( PWND  Wnd)

Definition at line 190 of file window.c.

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

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

◆ IntLinkHwnd()

VOID FASTCALL IntLinkHwnd ( PWND  Wnd,
HWND  hWndPrev 
)

Definition at line 985 of file window.c.

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

950{
951 if (Wnd == WndInsertAfter)
952 {
953 ERR("Trying to link window 0x%p to itself\n", Wnd);
954 ASSERT(WndInsertAfter != Wnd);
955 return;
956 }
957
958 WndSetPrev(Wnd, WndInsertAfter);
959 if (Wnd->spwndPrev)
960 {
961 /* Link after WndInsertAfter */
962 ASSERT(Wnd != WndInsertAfter->spwndNext);
963 WndSetNext(Wnd, WndInsertAfter->spwndNext);
964 if (Wnd->spwndNext)
965 WndSetPrev(Wnd->spwndNext, Wnd);
966
967 ASSERT(Wnd != Wnd->spwndPrev);
968 WndSetNext(Wnd->spwndPrev, Wnd);
969 }
970 else
971 {
972 /* Link at the top */
973 ASSERT(Wnd != Wnd->spwndParent->spwndChild);
974 WndSetNext(Wnd, Wnd->spwndParent->spwndChild);
975 if (Wnd->spwndNext)
976 WndSetPrev(Wnd->spwndNext, Wnd);
977
978 WndSetChild(Wnd->spwndParent, Wnd);
979 }
980}
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 1393 of file window.c.

1394{
1395 ASSERT(!WL_IS_BAD(pwl));
1396
1397 for (; pwnd; pwnd = pwnd->spwndNext)
1398 {
1399 if (!pwl->pti || pwl->pti == pwnd->head.pti)
1400 {
1401 *(pwl->phwndLast) = UserHMGetHandle(pwnd);
1402 ++(pwl->phwndLast);
1403
1404 if (pwl->phwndLast == pwl->phwndEnd && !IntGrowHwndList(&pwl))
1405 break;
1406 }
1407
1408 if ((dwFlags & IACE_CHILDREN) && pwnd->spwndChild)
1409 {
1410 pwl = IntPopulateHwndList(pwl, pwnd->spwndChild, IACE_CHILDREN | IACE_LIST);
1411 if (WL_IS_BAD(pwl))
1412 break;
1413 }
1414
1415 if (!(dwFlags & IACE_LIST))
1416 break;
1417 }
1418
1419 return pwl;
1420}
BOOL FASTCALL IntGrowHwndList(PWINDOWLIST *ppwl)
Definition: window.c:1373
#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 1085 of file window.c.

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

Referenced by IntSetOwner().

◆ IntReAllocatePoolWithTag()

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

Definition at line 24 of file window.c.

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

Referenced by IntGrowHwndList().

◆ IntRemoveTrackMouseEvent()

VOID FASTCALL IntRemoveTrackMouseEvent ( PDESKTOP  pDesk)

Definition at line 355 of file mouse.c.

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

Referenced by IntSendDestroyMsg().

◆ IntSendDestroyMsg()

static void IntSendDestroyMsg ( HWND  hWnd)
static

Definition at line 462 of file window.c.

463{
464 PTHREADINFO ti;
465 PWND Window;
466
469
470 if (Window)
471 {
472 /*
473 * Look whether the focus is within the tree of windows
474 * we will be destroying.
475 */
476 // Rule #1
477 if ( ti->MessageQueue->spwndActive == Window || // Fixes CORE-106 RegSvr32 exit and return focus to CMD.
478 (ti->MessageQueue->spwndActive == NULL && ti->MessageQueue == IntGetFocusMessageQueue()) )
479 {
481 }
482
483 /* Fixes CMD properties closing and returning focus to CMD */
484 if (ti->MessageQueue->spwndFocus == Window)
485 {
486 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
487 {
488 co_UserSetFocus(Window->spwndParent);
489 }
490 else
491 {
493 }
494 }
495
496 if (ti->MessageQueue->CaretInfo.hWnd == UserHMGetHandle(Window))
497 {
499 }
500
501 /* If the window being destroyed is currently tracked... */
502 if (ti->rpdesk && ti->rpdesk->spwndTrack == Window)
503 {
505 }
506 }
507
508 /* If the window being destroyed is the current clipboard owner... */
509 if (ti->ppi->prpwinsta != NULL && Window == ti->ppi->prpwinsta->spwndClipOwner)
510 {
511 /* ... make it release the clipboard */
513 }
514
515 /* Send the WM_DESTROY to the window */
517
518 /*
519 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
520 * make sure that the window still exists when we come back.
521 */
522 if (IntIsWindow(hWnd))
523 {
524 HWND* pWndArray;
525 int i;
526
527 if (!(pWndArray = IntWinListChildren( Window ))) return;
528
529 for (i = 0; pWndArray[i]; i++)
530 {
531 if (IntIsWindow( pWndArray[i] )) IntSendDestroyMsg( pWndArray[i] );
532 }
534 }
535 else
536 {
537 TRACE("destroyed itself while in WM_DESTROY!\n");
538 }
539}
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 1689 of file window.c.

1690{
1691 PWND Parent;
1692
1693 if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD &&
1694 !(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY))
1695 {
1696 Parent = pWindow->spwndParent;
1698 {
1700 UserRefObjectCo(Parent, &Ref);
1703 MAKEWPARAM( msg, pWindow->IDMenu),
1704 (LPARAM)UserHMGetHandle(pWindow) );
1706 }
1707 }
1708}
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:88
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define WM_PARENTNOTIFY
Definition: winuser.h:1831

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntSetOwner()

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

Definition at line 1117 of file window.c.

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

Referenced by co_IntSetWindowLongPtr().

◆ IntSetStyle()

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

Definition at line 144 of file window.c.

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

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

◆ IntSetWindowProc()

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

Definition at line 842 of file window.c.

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

Referenced by co_IntSetWindowLongPtr().

◆ IntShowOwnedPopups()

BOOL FASTCALL IntShowOwnedPopups ( PWND  OwnerWnd,
BOOL  fShow 
)

Definition at line 4662 of file window.c.

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

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

◆ IntUnlinkWindow()

VOID FASTCALL IntUnlinkWindow ( PWND  Wnd)

Definition at line 1355 of file window.c.

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

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

◆ IntValidateOwnerDepth()

BOOL FASTCALL IntValidateOwnerDepth ( PWND  Wnd,
PWND  Owner 
)

Definition at line 368 of file window.c.

369{
370 INT Depth = 1;
371 for (;;)
372 {
373 if ( !Owner ) return gNestedWindowLimit >= Depth;
374 if (Owner == Wnd) break;
375 Owner = Owner->spwndOwner;
376 Depth++;
377 }
378 return FALSE;
379}
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 275 of file window.c.

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

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

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

Referenced by IntDestroyOwnedWindows(), and IntShowOwnedPopups().

◆ IntWndIsDefaultIme()

static BOOL IntWndIsDefaultIme ( _In_ PWND  Window)
static

Definition at line 307 of file window.c.

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

Referenced by IntWinListOwnedPopups().

◆ NtUserAlterWindowStyle()

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

Definition at line 4100 of file window.c.

4101{
4102 LONG ret;
4103
4105
4106 if (hWnd == IntGetDesktopWindow())
4107 {
4109 UserLeave();
4110 return 0;
4111 }
4112
4113 ret = co_IntSetWindowLongPtr(hWnd, Index, NewValue, FALSE, sizeof(LONG), TRUE);
4114
4115 UserLeave();
4116
4117 return ret;
4118}
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247

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

1523{
1525 ULONG dwCount = 0;
1526
1527 if (pcHwndNeeded == NULL)
1529
1531
1532 if (hwndParent || !dwThreadId)
1533 {
1536
1537 if(!hwndParent)
1538 {
1539 if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop()))
1540 {
1542 goto Quit;
1543 }
1544
1545 if(hDesktop)
1546 {
1548 UserMode,
1549 0,
1550 &Desktop);
1551 if(!NT_SUCCESS(Status))
1552 {
1554 goto Quit;
1555 }
1556 }
1557 hwndParent = Desktop->DesktopWindow;
1558 }
1559 else
1560 {
1561 hDesktop = 0;
1562 }
1563
1565 (Window = Parent->spwndChild))
1566 {
1567 BOOL bGoDown = TRUE;
1568
1570 while(TRUE)
1571 {
1572 if (bGoDown)
1573 {
1574 if (dwCount++ < cHwnd && phwndList)
1575 {
1576 _SEH2_TRY
1577 {
1578 ProbeForWrite(phwndList, sizeof(HWND), 1);
1579 *phwndList = UserHMGetHandle(Window);
1580 phwndList++;
1581 }
1583 {
1585 }
1586 _SEH2_END
1587 if(!NT_SUCCESS(Status))
1588 {
1589 break;
1590 }
1591 }
1592 if (Window->spwndChild && bChildren)
1593 {
1594 Window = Window->spwndChild;
1595 continue;
1596 }
1597 bGoDown = FALSE;
1598 }
1599 if (Window->spwndNext)
1600 {
1601 Window = Window->spwndNext;
1602 bGoDown = TRUE;
1603 continue;
1604 }
1605 Window = Window->spwndParent;
1606 if (Window == Parent)
1607 {
1608 break;
1609 }
1610 }
1611 }
1612
1613 if(hDesktop)
1614 {
1616 }
1617 }
1618 else // Build EnumThreadWindows list!
1619 {
1621 PTHREADINFO W32Thread;
1622 PWND Window;
1623 HWND *List = NULL;
1624
1626 if (!NT_SUCCESS(Status))
1627 {
1628 ERR("Thread Id is not valid!\n");
1630 goto Quit;
1631 }
1632 if (!(W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread))
1633 {
1635 TRACE("Tried to enumerate windows of a non gui thread\n");
1637 goto Quit;
1638 }
1639
1640 // Do not use Thread link list due to co_UserFreeWindow!!!
1641 // Current = W32Thread->WindowListHead.Flink;
1642 // Fixes Api:CreateWindowEx tests!!!
1644 if (List)
1645 {
1646 int i;
1647 for (i = 0; List[i]; i++)
1648 {
1650 if (Window && Window->head.pti == W32Thread)
1651 {
1652 if (dwCount < cHwnd && phwndList)
1653 {
1654 _SEH2_TRY
1655 {
1656 ProbeForWrite(phwndList, sizeof(HWND), 1);
1657 *phwndList = UserHMGetHandle(Window);
1658 phwndList++;
1659 }
1661 {
1663 }
1664 _SEH2_END
1665 if (!NT_SUCCESS(Status))
1666 {
1667 ERR("Failure to build window list!\n");
1668 break;
1669 }
1670 }
1671 dwCount++;
1672 }
1673 }
1675 }
1676
1678 }
1679
1680 *pcHwndNeeded = dwCount;
1682
1683Quit:
1685 UserLeave();
1686 return Status;
1687}
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:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define STATUS_SUCCESS
Definition: shellext.h:65
KTHREAD Tcb
Definition: pstypes.h:1187
PVOID Win32Thread
Definition: ketypes.h:1994
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1279
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1402
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 2680 of file window.c.

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

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

◆ NtUserDefSetText()

BOOL APIENTRY NtUserDefSetText ( HWND  hWnd,
PLARGE_STRING  WindowText 
)

Definition at line 4466 of file window.c.

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

Referenced by DefSetText().

◆ NtUserDestroyWindow()

BOOLEAN APIENTRY NtUserDestroyWindow ( HWND  Wnd)

Definition at line 3049 of file window.c.

3050{
3051 PWND Window;
3052 BOOLEAN ret = FALSE;
3054
3055 TRACE("Enter NtUserDestroyWindow\n");
3057
3059 if (Window)
3060 {
3061 UserRefObjectCo(Window, &Ref); // FIXME: Dunno if win should be reffed during destroy...
3063 UserDerefObjectCo(Window); // FIXME: Dunno if win should be reffed during destroy...
3064 }
3065
3066 TRACE("Leave NtUserDestroyWindow, ret=%u\n", ret);
3067 UserLeave();
3068 return ret;
3069}

Referenced by DestroyWindow(), and User32DestroyImeUIWindow().

◆ NtUserFindWindowEx()

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

Definition at line 3155 of file window.c.

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

Referenced by FindWindowExW(), and START_TEST().

◆ NtUserGetAncestor()

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

Definition at line 3415 of file window.c.

3416{
3417 PWND Window, pwndAncestor;
3418 HWND hwndAncestor = NULL;
3419
3420 TRACE("Enter NtUserGetAncestor\n");
3422
3424 if (!Window)
3425 goto Quit;
3426
3427 if (!uType || uType > GA_ROOTOWNER)
3428 {
3430 goto Quit;
3431 }
3432
3433 pwndAncestor = UserGetAncestor(Window, uType);
3434 if (pwndAncestor)
3435 hwndAncestor = UserHMGetHandle(pwndAncestor);
3436
3437Quit:
3438 UserLeave();
3439 TRACE("Leave NtUserGetAncestor returning %p\n", hwndAncestor);
3440 return hwndAncestor;
3441}
PWND FASTCALL UserGetAncestor(_In_ PWND pWnd, _In_ UINT uType)
Definition: window.c:3351
#define GA_ROOTOWNER
Definition: winuser.h:2894

Referenced by GetAncestor().

◆ NtUserGetComboBoxInfo()

BOOL APIENTRY NtUserGetComboBoxInfo ( HWND  hWnd,
PCOMBOBOXINFO  pcbi 
)

Definition at line 3479 of file window.c.

3482{
3483 PWND Wnd;
3484 PPROCESSINFO ppi;
3485 BOOL NotSameppi = FALSE;
3486 BOOL Ret = TRUE;
3487
3488 TRACE("Enter NtUserGetComboBoxInfo\n");
3490
3491 if (!(Wnd = UserGetWindowObject(hWnd)))
3492 {
3493 Ret = FALSE;
3494 goto Exit;
3495 }
3496 _SEH2_TRY
3497 {
3498 ProbeForWrite(pcbi, sizeof(COMBOBOXINFO), 1);
3499 }
3501 {
3503 Ret = FALSE;
3504 _SEH2_YIELD(goto Exit);
3505 }
3506 _SEH2_END;
3507
3508 if (pcbi->cbSize < sizeof(COMBOBOXINFO))
3509 {
3511 Ret = FALSE;
3512 goto Exit;
3513 }
3514
3515 // Pass the user pointer, it was already probed.
3517 {
3519 goto Exit;
3520 }
3521
3523 NotSameppi = ppi != Wnd->head.pti->ppi;
3524 if (NotSameppi)
3525 {
3526 KeAttachProcess(&Wnd->head.pti->ppi->peProcess->Pcb);
3527 }
3528
3529 _SEH2_TRY
3530 {
3531 LPHEADCOMBO lphc = ((PWND2CBOX)Wnd)->pCBox;
3532 pcbi->rcItem = lphc->textRect;
3533 pcbi->rcButton = lphc->buttonRect;
3534 pcbi->stateButton = 0;
3535 if (lphc->wState & CBF_BUTTONDOWN)
3537 if (RECTL_bIsEmptyRect(&lphc->buttonRect))
3539 pcbi->hwndCombo = lphc->self;
3540 pcbi->hwndItem = lphc->hWndEdit;
3541 pcbi->hwndList = lphc->hWndLBox;
3542 }
3544 {
3545 Ret = FALSE;
3547 }
3548 _SEH2_END;
3549
3550Exit:
3551 if (NotSameppi) KeDetachProcess();
3552 TRACE("Leave NtUserGetComboBoxInfo, ret=%i\n", Ret);
3553 UserLeave();
3554 return Ret;
3555}
#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:3820
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
struct _WND2CBOX * PWND2CBOX
#define CBF_BUTTONDOWN
Definition: window.c:3473
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2972
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1970
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2984

Referenced by GetComboBoxInfo().

◆ NtUserGetListBoxInfo()

DWORD APIENTRY NtUserGetListBoxInfo ( HWND  hWnd)

Definition at line 3590 of file window.c.

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

Referenced by GetListBoxInfo().

◆ NtUserInternalGetWindowText()

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

Definition at line 4600 of file window.c.

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

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

◆ NtUserQueryWindow()

DWORD_PTR APIENTRY NtUserQueryWindow ( HWND  hWnd,
DWORD  Index 
)

Definition at line 4202 of file window.c.

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

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

◆ NtUserRegisterWindowMessage()

UINT APIENTRY NtUserRegisterWindowMessage ( PUNICODE_STRING  MessageNameUnsafe)

Definition at line 4307 of file window.c.

4308{
4309 UNICODE_STRING SafeMessageName;
4311 UINT Ret = 0;
4312
4313 TRACE("Enter NtUserRegisterWindowMessage\n");
4315
4316 if(MessageNameUnsafe == NULL)
4317 {
4319 goto Exit; // Return 0
4320 }
4321
4322 Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe);
4323 if(!NT_SUCCESS(Status))
4324 {
4326 goto Exit; // Return 0
4327 }
4328
4329 Ret = (UINT)IntAddAtom(SafeMessageName.Buffer);
4330 if (SafeMessageName.Buffer)
4331 ExFreePoolWithTag(SafeMessageName.Buffer, TAG_STRING);
4332
4333Exit:
4334 TRACE("Leave NtUserRegisterWindowMessage, ret=%u\n", Ret);
4335 UserLeave();
4336 return Ret;
4337}
RTL_ATOM FASTCALL IntAddAtom(LPWSTR AtomName)
Definition: useratom.c:13
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
Definition: misc.c:684

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

◆ NtUserSetParent()

HWND APIENTRY NtUserSetParent ( HWND  hWndChild,
HWND  hWndNewParent 
)

Definition at line 3658 of file window.c.

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

Referenced by SetParent().

◆ NtUserSetShellWindowEx()

BOOL APIENTRY NtUserSetShellWindowEx ( HWND  hwndShell,
HWND  hwndListView 
)

Definition at line 3725 of file window.c.

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

Referenced by SetShellWindow(), and SetShellWindowEx().

◆ NtUserSetWindowFNID()

BOOL APIENTRY NtUserSetWindowFNID ( HWND  hWnd,
WORD  fnID 
)

Definition at line 4343 of file window.c.

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

4057{
4058 LONG ret;
4059
4061
4062 if (hWnd == IntGetDesktopWindow())
4063 {
4065 UserLeave();
4066 return 0;
4067 }
4068
4069 ret = (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4070
4071 UserLeave();
4072
4073 return ret;
4074}

Referenced by SetWindowLongA(), and SetWindowLongW().

◆ NtUserSetWindowWord()

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

Definition at line 4131 of file window.c.

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

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

Referenced by NtUserCreateWindowEx().

◆ UserFreeWindowInfo()

static VOID UserFreeWindowInfo ( PTHREADINFO  ti,
PWND  Wnd 
)
static

Definition at line 542 of file window.c.

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

Referenced by co_UserFreeWindow().

◆ UserGetAncestor()

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

Definition at line 3351 of file window.c.

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

Referenced by NtUserGetAncestor().

◆ UserGetShellWindow()

HWND FASTCALL UserGetShellWindow ( VOID  )

Definition at line 3692 of file window.c.

3693{
3694 PWINSTATION_OBJECT WinStaObject;
3695 HWND Ret;
3696
3698 UserMode,
3699 0,
3700 &WinStaObject,
3701 0);
3702
3703 if (!NT_SUCCESS(Status))
3704 {
3706 return NULL;
3707 }
3708
3709 Ret = (HWND)WinStaObject->ShellWindow;
3710
3711 ObDereferenceObject(WinStaObject);
3712 return Ret;
3713}

Referenced by co_WinPosSetWindowPos(), and SpiSetWallpaper().

◆ UserGetWindowObject()

PWND FASTCALL UserGetWindowObject ( HWND  hWnd)

Definition at line 123 of file window.c.

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

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

◆ UserUpdateUiState()

BOOL FASTCALL UserUpdateUiState ( PWND  Wnd,
WPARAM  wParam 
)

Definition at line 40 of file window.c.

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

Referenced by NtUserCallTwoParam().

◆ ValidateHwndNoErr()

PWND FASTCALL ValidateHwndNoErr ( HWND  hWnd)

Definition at line 108 of file window.c.

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

◆ VerifyWnd()

PWND FASTCALL VerifyWnd ( PWND  pWnd)

Definition at line 88 of file window.c.

89{
91
92 if (!pWnd ||
93 (pWnd->state & WNDS_DESTROYED) ||
94 (pWnd->state2 & WNDS2_INDESTROY))
95 {
96 return NULL;
97 }
98
100
102 pWnd = NULL;
103
105 return pWnd;
106}
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:702
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().