From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 32 ++++++++++++++++---------------- server/protocol.def | 1 + server/window.c | 14 +++++++------- 3 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index bd70dbff019..5d18913d3c6 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5247,9 +5247,8 @@ void destroy_thread_windows(void) * * Create a window handle with the server. */ -static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, - HINSTANCE instance, BOOL ansi, - DWORD style, DWORD ex_style ) +static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, HINSTANCE class_instance, + HINSTANCE instance, BOOL ansi, DWORD style, DWORD ex_style ) { UINT dpi_context = get_thread_dpi_awareness_context(); HWND handle = 0, full_parent = 0, full_owner = 0; @@ -5259,12 +5258,13 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name,
SERVER_START_REQ( create_window ) { - req->parent = wine_server_user_handle( parent ); - req->owner = wine_server_user_handle( owner ); - req->instance = wine_server_client_ptr( instance ); - req->dpi_context = dpi_context; - req->style = style; - req->ex_style = ex_style; + req->parent = wine_server_user_handle( parent ); + req->owner = wine_server_user_handle( owner ); + req->class_instance = wine_server_client_ptr( class_instance ); + req->instance = wine_server_client_ptr( instance ); + req->dpi_context = dpi_context; + req->style = style; + req->ex_style = ex_style; if (!(req->atom = get_int_atom_value( name )) && name->Length) wine_server_add_data( req, name->Buffer, name->Length ); if (!wine_server_call_err( req )) @@ -5322,6 +5322,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, win->owner = full_owner; win->class = class; win->winproc = get_class_winproc( class ); + win->hInstance = instance; win->cbWndExtra = extra_bytes; list_init( &win->vulkan_surfaces ); set_user_handle_ptr( handle, win ); @@ -5416,8 +5417,8 @@ static void map_dpi_create_struct( CREATESTRUCTW *cs, UINT dpi_to ) HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, UNICODE_STRING *version, UNICODE_STRING *window_name, DWORD style, INT x, INT y, INT cx, INT cy, - HWND parent, HMENU menu, HINSTANCE instance, void *params, - DWORD flags, HINSTANCE client_instance, DWORD unk, BOOL ansi ) + HWND parent, HMENU menu, HINSTANCE class_instance, void *params, + DWORD flags, HINSTANCE instance, DWORD unk, BOOL ansi ) { UINT win_dpi, context; struct window_surface *surface; @@ -5432,7 +5433,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, static const WCHAR messageW[] = {'M','e','s','s','a','g','e'};
cs.lpCreateParams = params; - cs.hInstance = client_instance ? client_instance : instance; + cs.hInstance = instance ? instance : class_instance; cs.hMenu = menu; cs.hwndParent = parent; cs.style = style; @@ -5489,13 +5490,13 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
style = cs.style & ~WS_VISIBLE; ex_style = cs.dwExStyle & ~WS_EX_LAYERED; - if (!(win = create_window_handle( parent, owner, class_name, instance, ansi, style, ex_style ))) + if (!(win = create_window_handle( parent, owner, class_name, class_instance, + cs.hInstance, ansi, style, ex_style ))) return 0; hwnd = win->handle;
/* Fill the window structure */
- win->hInstance = cs.hInstance; win->text = NULL; win->dwStyle = style; win->dwExStyle = ex_style; @@ -5552,10 +5553,9 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, SERVER_START_REQ( set_window_info ) { req->handle = wine_server_user_handle( hwnd ); - req->flags = SET_WIN_STYLE | SET_WIN_EXSTYLE | SET_WIN_INSTANCE | SET_WIN_UNICODE; + req->flags = SET_WIN_STYLE | SET_WIN_EXSTYLE | SET_WIN_UNICODE; req->style = win->dwStyle; req->ex_style = win->dwExStyle; - req->instance = wine_server_client_ptr( win->hInstance ); req->is_unicode = (win->flags & WIN_ISUNICODE) != 0; req->extra_offset = -1; wine_server_call( req ); diff --git a/server/protocol.def b/server/protocol.def index 58c88d34666..e9b311d0eb3 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2544,6 +2544,7 @@ enum message_type user_handle_t parent; /* parent window */ user_handle_t owner; /* owner window */ atom_t atom; /* class atom */ + mod_handle_t class_instance; /* class module instance */ mod_handle_t instance; /* module instance */ unsigned int dpi_context; /* thread DPI context */ unsigned int style; /* window style */ diff --git a/server/window.c b/server/window.c index 6fe5c42928a..c9ee854d37c 100644 --- a/server/window.c +++ b/server/window.c @@ -607,8 +607,8 @@ void post_desktop_message( struct desktop *desktop, unsigned int message, }
/* create a new window structure (note: the window is not linked in the window tree) */ -static struct window *create_window( struct window *parent, struct window *owner, - atom_t atom, mod_handle_t instance ) +static struct window *create_window( struct window *parent, struct window *owner, atom_t atom, + mod_handle_t class_instance, mod_handle_t instance ) { int extra_bytes; struct window *win = NULL; @@ -617,7 +617,7 @@ static struct window *create_window( struct window *parent, struct window *owner
if (!(desktop = get_thread_desktop( current, DESKTOP_CREATEWINDOW ))) return NULL;
- if (!(class = grab_class( current->process, atom, instance, &extra_bytes ))) + if (!(class = grab_class( current->process, atom, class_instance, &extra_bytes ))) { release_object( desktop ); return NULL; @@ -656,7 +656,7 @@ static struct window *create_window( struct window *parent, struct window *owner win->style = 0; win->ex_style = 0; win->id = 0; - win->instance = 0; + win->instance = instance; win->is_unicode = 1; win->is_linked = 0; win->is_layered = 0; @@ -2214,7 +2214,7 @@ DECL_HANDLER(create_window)
atom = cls_name.len ? find_global_atom( NULL, &cls_name ) : req->atom;
- if (!(win = create_window( parent, owner, atom, req->instance ))) return; + if (!(win = create_window( parent, owner, atom, req->class_instance, req->instance ))) return;
if (parent && !is_desktop_window( parent )) dpi_context = parent->shared->dpi_context; @@ -2286,7 +2286,7 @@ DECL_HANDLER(get_desktop_window)
if (!desktop->top_window && req->force) /* create it */ { - if ((desktop->top_window = create_window( NULL, NULL, DESKTOP_ATOM, 0 ))) + if ((desktop->top_window = create_window( NULL, NULL, DESKTOP_ATOM, 0, 0 ))) { detach_window_thread( desktop->top_window ); desktop->top_window->style = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; @@ -2298,7 +2298,7 @@ DECL_HANDLER(get_desktop_window) static const WCHAR messageW[] = {'M','e','s','s','a','g','e'}; static const struct unicode_str name = { messageW, sizeof(messageW) }; atom_t atom = add_global_atom( NULL, &name ); - if (atom && (desktop->msg_window = create_window( NULL, NULL, atom, 0 ))) + if (atom && (desktop->msg_window = create_window( NULL, NULL, atom, 0, 0 ))) { detach_window_thread( desktop->msg_window ); desktop->msg_window->style = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;