From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/win32u/ntuser_private.h | 1 - dlls/win32u/window.c | 32 +++++++++++++++++++------------- server/protocol.def | 6 ++++++ server/window.c | 8 +++----- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 6db740c2d75..426d074f935 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -58,7 +58,6 @@ typedef struct tagWND struct win_scroll_bar_info *pScroll; /* Scroll-bar info */ UINT dwStyle; /* Window style (from CreateWindow) */ UINT dwExStyle; /* Extended style (from CreateWindowEx) */ - UINT_PTR wIDmenu; /* ID or hmenu (from CreateWindow) */ UINT helpContext; /* Help context ID */ UINT flags; /* Misc. flags (see below) */ HMENU hSysMenu; /* window's copy of System Menu */ diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 447c7f119dd..56e7093a93a 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1117,15 +1117,21 @@ static LONG_PTR get_window_long_shm( HWND hwnd, UINT offset, UINT size, BOOL int { struct object_lock lock = OBJECT_LOCK_INIT; const window_shm_t *window_shm = NULL; - BOOL valid = FALSE; + BOOL valid = TRUE; LONG_PTR ret = 0; NTSTATUS status; while ((status = get_shared_window( hwnd, &lock, &window_shm )) == STATUS_PENDING) { - valid = size <= window_shm->extra_size && offset <= window_shm->extra_size - size && - (internal || offset >= window_shm->private_size); - if (valid) memcpy( &ret, (char *)window_shm->extra + offset, size ); + switch (offset) + { + case GWLP_ID: ret = window_shm->info.id; break; + default: + valid = size <= window_shm->extra_size && offset <= window_shm->extra_size - size && + (internal || offset >= window_shm->private_size); + if (valid) memcpy( &ret, (char *)window_shm->extra + offset, size ); + break; + } } if (status) { @@ -1172,6 +1178,8 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans { default: if (offset < 0) break; + /* fallthrough */ + case GWLP_ID: return get_window_long_shm( hwnd, offset, size, internal ); case GWLP_HWNDPARENT: { @@ -1199,7 +1207,6 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans return retval; case GWL_EXSTYLE: case GWLP_USERDATA: - case GWLP_ID: case GWLP_HINSTANCE: return 0; case GWLP_WNDPROC: @@ -1235,7 +1242,6 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans case GWLP_USERDATA: retval = win->userdata; break; case GWL_STYLE: retval = win->dwStyle; break; case GWL_EXSTYLE: retval = win->dwExStyle; break; - case GWLP_ID: retval = win->wIDmenu; break; case GWLP_HINSTANCE: retval = (ULONG_PTR)win->hInstance; break; case GWLP_WNDPROC: /* This looks like a hack only for the edit control (see tests). This makes these controls @@ -1268,6 +1274,11 @@ ULONG_PTR get_window_long_ptr( HWND hwnd, INT offset, BOOL ansi ) return get_window_long_size( hwnd, offset, sizeof(LONG_PTR), ansi, FALSE ); } +static HMENU get_window_menu( HWND hwnd ) +{ + return (HMENU)get_window_long_ptr( hwnd, GWLP_ID, FALSE ); +} + /* see GetWindowWord */ static WORD get_window_word( HWND hwnd, INT offset ) { @@ -1502,10 +1513,6 @@ static LONG_PTR set_window_long_internal( HWND hwnd, INT offset, UINT size, win->dwExStyle = newval; retval = oldval; break; - case GWLP_ID: - win->wIDmenu = newval; - retval = oldval; - break; case GWLP_HINSTANCE: win->hInstance = (HINSTANCE)newval; retval = oldval; @@ -5295,7 +5302,7 @@ LRESULT destroy_window( HWND hwnd ) if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS) return 0; if ((win->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD) - menu = (HMENU)win->wIDmenu; + menu = get_window_menu( hwnd ); sys_menu = win->hSysMenu; free_dce( win->dce, hwnd, &drawables ); win->dce = NULL; @@ -5447,7 +5454,7 @@ void destroy_thread_windows(void) /* recycle the WND struct as a destroy_entry struct */ entry = (struct destroy_entry *)win; tmp.handle = win->handle; - if (!is_child) tmp.menu = (HMENU)win->wIDmenu; + if (!is_child) tmp.menu = get_window_menu( handle ); tmp.sys_menu = win->hSysMenu; tmp.current_drawable = win->current_drawable; tmp.unused_drawable = win->unused_drawable; @@ -5744,7 +5751,6 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, win->text = NULL; win->dwStyle = style; win->dwExStyle = ex_style; - win->wIDmenu = 0; win->helpContext = 0; win->pScroll = NULL; win->userdata = 0; diff --git a/server/protocol.def b/server/protocol.def index 44620b18018..973f091ecab 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1063,6 +1063,11 @@ typedef volatile struct char extra[]; /* extra bytes storage */ } class_shm_t; +struct window_info +{ + lparam_t id; /* window id */ +}; + typedef volatile struct { struct obj_locator class; /* object locator for the window class shared object */ @@ -1070,6 +1075,7 @@ typedef volatile struct unsigned int fnid; /* builtin class FNID, or 0 */ data_size_t private_size; /* length of private extra bytes range */ data_size_t extra_size; /* size of the extra info */ + struct window_info info; /* window info (GWLP_*) */ char extra[]; /* extra bytes storage */ } window_shm_t; diff --git a/server/window.c b/server/window.c index ab5b05a5952..1302291be64 100644 --- a/server/window.c +++ b/server/window.c @@ -74,7 +74,6 @@ struct window struct region *update_region; /* update region (relative to window rect) */ unsigned int style; /* window style */ unsigned int ex_style; /* window extended style */ - lparam_t id; /* window id */ mod_handle_t instance; /* creator instance */ unsigned int is_unicode : 1; /* ANSI or unicode */ unsigned int is_linked : 1; /* is it linked into the parent z-order list? */ @@ -658,7 +657,6 @@ static struct window *create_window( struct window *parent, struct window *owner win->update_region = NULL; win->style = 0; win->ex_style = 0; - win->id = 0; win->instance = instance; win->is_unicode = 1; win->is_linked = 0; @@ -686,6 +684,7 @@ static struct window *create_window( struct window *parent, struct window *owner shared->fnid = fnid; shared->private_size = private_size; shared->extra_size = extra_size; + memset( (void *)&shared->info, 0, sizeof(shared->info) ); memset( (void *)shared->extra, 0, extra_size ); } SHARED_WRITE_END; @@ -2407,7 +2406,6 @@ DECL_HANDLER(get_window_info) { case GWL_STYLE: reply->info = win->style; break; case GWL_EXSTYLE: reply->info = win->ex_style; break; - case GWLP_ID: reply->info = win->id; break; case GWLP_HINSTANCE: reply->info = win->instance; break; case GWLP_WNDPROC: reply->info = win->is_unicode; break; case GWLP_USERDATA: reply->info = win->user_data; break; @@ -2461,8 +2459,8 @@ DECL_HANDLER(set_window_info) set_window_ex_style( win, req->new_info ); break; case GWLP_ID: - reply->old_info = win->id; - win->id = req->new_info; + reply->old_info = shared->info.id; + shared->info.id = req->new_info; break; case GWLP_HINSTANCE: reply->old_info = win->instance; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11106