-- v2: server: Get rid of set_class_info request flags. server: Split get_class_info request from set_class_info. win32u: Use get_class_long_size for get_class_word. win32u: Use set_class_long_size for NtUserSetClassWord. win32u: Simplify setting extra class info in set_class_long.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 3f241501e83..13d4f0aae66 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -775,7 +775,7 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size ) return ret; }
-static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT size, BOOL ansi ) +static ULONG_PTR set_class_long_size( HWND hwnd, INT offset, LONG_PTR newval, UINT size, BOOL ansi ) { ULONG_PTR retval = 0; HICON small_icon = 0; @@ -788,19 +788,8 @@ static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT si if (set_server_info( hwnd, offset, newval, size )) { void *ptr = (char *)(class + 1) + offset; - if ( size == sizeof(LONG) ) - { - DWORD retdword; - LONG newlong = newval; - memcpy( &retdword, ptr, sizeof(DWORD) ); - memcpy( ptr, &newlong, sizeof(LONG) ); - retval = retdword; - } - else - { - memcpy( &retval, ptr, sizeof(ULONG_PTR) ); - memcpy( ptr, &newval, sizeof(LONG_PTR) ); - } + memcpy( &retval, ptr, size ); + memcpy( ptr, &newval, size ); } } else switch(offset) @@ -848,7 +837,7 @@ static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT si /* someone beat us, restart */ release_class_ptr( class ); NtUserDestroyCursor( small_icon, 0 ); - return set_class_long( hwnd, offset, newval, size, ansi ); + return set_class_long_size( hwnd, offset, newval, size, ansi ); } } if (class->hIconSmIntern) NtUserDestroyCursor( class->hIconSmIntern, 0 ); @@ -878,7 +867,7 @@ static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT si /* someone beat us, restart */ release_class_ptr( class ); NtUserDestroyCursor( small_icon, 0 ); - return set_class_long( hwnd, offset, newval, size, ansi ); + return set_class_long_size( hwnd, offset, newval, size, ansi ); } } if (class->hIconSmIntern) NtUserDestroyCursor( class->hIconSmIntern, 0 ); @@ -916,7 +905,7 @@ static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT si */ DWORD WINAPI NtUserSetClassLong( HWND hwnd, INT offset, LONG newval, BOOL ansi ) { - return set_class_long( hwnd, offset, newval, sizeof(LONG), ansi ); + return set_class_long_size( hwnd, offset, newval, sizeof(LONG), ansi ); }
/*********************************************************************** @@ -924,7 +913,7 @@ DWORD WINAPI NtUserSetClassLong( HWND hwnd, INT offset, LONG newval, BOOL ansi ) */ ULONG_PTR WINAPI NtUserSetClassLongPtr( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi ) { - return set_class_long( hwnd, offset, newval, sizeof(LONG_PTR), ansi ); + return set_class_long_size( hwnd, offset, newval, sizeof(LONG_PTR), ansi ); }
/***********************************************************************
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 13d4f0aae66..f48732763ae 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -921,30 +921,7 @@ ULONG_PTR WINAPI NtUserSetClassLongPtr( HWND hwnd, INT offset, LONG_PTR newval, */ WORD WINAPI NtUserSetClassWord( HWND hwnd, INT offset, WORD newval ) { - CLASS *class; - WORD retval = 0; - - if (offset < 0) return NtUserSetClassLong( hwnd, offset, (DWORD)newval, TRUE ); - - if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; - - SERVER_START_REQ( set_class_info ) - { - req->window = wine_server_user_handle( hwnd ); - req->flags = SET_CLASS_EXTRA; - req->extra_offset = offset; - req->extra_size = sizeof(newval); - memcpy( &req->extra_value, &newval, sizeof(newval) ); - if (!wine_server_call_err( req )) - { - void *ptr = (char *)(class + 1) + offset; - memcpy( &retval, ptr, sizeof(retval) ); - memcpy( ptr, &newval, sizeof(newval) ); - } - } - SERVER_END_REQ; - release_class_ptr( class ); - return retval; + return set_class_long_size( hwnd, offset, newval, sizeof(WORD), TRUE ); }
static ULONG_PTR get_class_long_size( HWND hwnd, INT offset, UINT size, BOOL ansi )
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index f48732763ae..62d858fc0e9 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -1063,34 +1063,7 @@ ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi )
WORD get_class_word( HWND hwnd, INT offset ) { - CLASS *class; - WORD retvalue = 0; - - if (offset < 0) return get_class_long( hwnd, offset, TRUE ); - - if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; - - if (class == OBJ_OTHER_PROCESS) - { - SERVER_START_REQ( set_class_info ) - { - req->window = wine_server_user_handle( hwnd ); - req->flags = 0; - req->extra_offset = offset; - req->extra_size = sizeof(retvalue); - if (!wine_server_call_err( req )) - memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) ); - } - SERVER_END_REQ; - return retvalue; - } - - if (offset <= class->cbClsExtra - sizeof(WORD)) - memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) ); - else - RtlSetLastWin32Error( ERROR_INVALID_INDEX ); - release_class_ptr( class ); - return retvalue; + return get_class_long_size( hwnd, offset, sizeof(WORD), TRUE ); }
BOOL needs_ime_window( HWND hwnd )
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 39 +++++---------------------------------- server/class.c | 36 ++++++++++++++++++++++++++++++++++++ server/protocol.def | 9 +++++++++ 3 files changed, 50 insertions(+), 34 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 62d858fc0e9..c919f65f8c6 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -933,15 +933,14 @@ static ULONG_PTR get_class_long_size( HWND hwnd, INT offset, UINT size, BOOL ans
if (class == OBJ_OTHER_PROCESS) { - SERVER_START_REQ( set_class_info ) + SERVER_START_REQ( get_class_info ) { req->window = wine_server_user_handle( hwnd ); - req->flags = 0; - req->extra_offset = (offset >= 0) ? offset : -1; - req->extra_size = (offset >= 0) ? size : 0; + req->offset = offset; + req->size = size; if (!wine_server_call_err( req )) { - switch(offset) + switch (offset) { case GCLP_HBRBACKGROUND: case GCLP_HCURSOR: @@ -950,37 +949,9 @@ static ULONG_PTR get_class_long_size( HWND hwnd, INT offset, UINT size, BOOL ans case GCLP_WNDPROC: case GCLP_MENUNAME: FIXME( "offset %d not supported on other process window %p\n", offset, hwnd ); - RtlSetLastWin32Error( ERROR_INVALID_HANDLE ); - break; - case GCL_STYLE: - retvalue = reply->old_style; - break; - case GCL_CBWNDEXTRA: - retvalue = reply->old_win_extra; - break; - case GCL_CBCLSEXTRA: - retvalue = reply->old_extra; - break; - case GCLP_HMODULE: - retvalue = (ULONG_PTR)wine_server_get_ptr( reply->old_instance ); - break; - case GCW_ATOM: - retvalue = reply->old_atom; break; default: - if (offset >= 0) - { - if (size == sizeof(DWORD)) - { - DWORD retdword; - memcpy( &retdword, &reply->old_extra_value, sizeof(DWORD) ); - retvalue = retdword; - } - else - memcpy( &retvalue, &reply->old_extra_value, - sizeof(ULONG_PTR) ); - } - else RtlSetLastWin32Error( ERROR_INVALID_INDEX ); + retvalue = reply->info; break; } } diff --git a/server/class.c b/server/class.c index 3b2d38a3bfd..f468f8ce506 100644 --- a/server/class.c +++ b/server/class.c @@ -284,3 +284,39 @@ DECL_HANDLER(set_class_info) if (req->flags & SET_CLASS_EXTRA) memcpy( class->extra_bytes + req->extra_offset, &req->extra_value, req->extra_size ); } + + +/* get some information in a class */ +DECL_HANDLER(get_class_info) +{ + struct window_class *class; + + if (!(class = get_window_class( req->window ))) return; + + switch (req->offset) + { + case GCLP_HBRBACKGROUND: + case GCLP_HCURSOR: + case GCLP_HICON: + case GCLP_HICONSM: + case GCLP_WNDPROC: + case GCLP_MENUNAME: + /* not supported */ + set_win32_error( ERROR_INVALID_HANDLE ); + break; + case GCL_STYLE: reply->info = class->style; break; + case GCL_CBWNDEXTRA: reply->info = class->win_extra; break; + case GCL_CBCLSEXTRA: reply->info = class->nb_extra_bytes; break; + case GCLP_HMODULE: reply->info = class->instance; break; + case GCW_ATOM: reply->info = class->atom; break; + default: + if (req->size > sizeof(reply->info) || req->offset < 0 || + req->offset > class->nb_extra_bytes - (int)req->size) + { + set_win32_error( ERROR_INVALID_INDEX ); + return; + } + memcpy( &reply->info, class->extra_bytes + req->offset, req->size ); + break; + } +} diff --git a/server/protocol.def b/server/protocol.def index 3ed29335a1a..acdad54aa6d 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -3277,6 +3277,15 @@ enum caret_state #define SET_CLASS_INSTANCE 0x0008 #define SET_CLASS_EXTRA 0x0010
+/* Get some information in a class */ +@REQ(get_class_info) + user_handle_t window; /* handle to the window */ + int offset; /* offset of the info */ + data_size_t size; /* size of the info value to read */ +@REPLY + lparam_t info; /* current class info value */ +@END +
/* Open the clipboard */ @REQ(open_clipboard)
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 43 ++++++------------------------- server/class.c | 62 ++++++++++++++++++++++----------------------- server/protocol.def | 29 +++++---------------- 3 files changed, 46 insertions(+), 88 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index c919f65f8c6..6148fb6821d 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -711,14 +711,13 @@ INT WINAPI NtUserGetClassName( HWND hwnd, BOOL real, UNICODE_STRING *name ) { ATOM atom = 0;
- SERVER_START_REQ( set_class_info ) + SERVER_START_REQ( get_class_info ) { req->window = wine_server_user_handle( hwnd ); - req->flags = 0; - req->extra_offset = -1; - req->extra_size = 0; - if (!wine_server_call_err( req )) - atom = reply->old_atom; + req->offset = GCW_ATOM; + req->size = sizeof(atom); + wine_server_call_err( req ); + atom = reply->info; } SERVER_END_REQ;
@@ -740,35 +739,9 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size ) SERVER_START_REQ( set_class_info ) { req->window = wine_server_user_handle( hwnd ); - req->extra_offset = -1; - switch(offset) - { - case GCL_STYLE: - req->flags = SET_CLASS_STYLE; - req->style = newval; - break; - case GCL_CBWNDEXTRA: - req->flags = SET_CLASS_WINEXTRA; - req->win_extra = newval; - break; - case GCLP_HMODULE: - req->flags = SET_CLASS_INSTANCE; - req->instance = wine_server_client_ptr( (void *)newval ); - break; - default: - assert( offset >= 0 ); - req->flags = SET_CLASS_EXTRA; - req->extra_offset = offset; - req->extra_size = size; - if ( size == sizeof(LONG) ) - { - LONG newlong = newval; - memcpy( &req->extra_value, &newlong, sizeof(LONG) ); - } - else - memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) ); - break; - } + req->offset = offset; + req->size = size; + req->new_info = newval; ret = !wine_server_call_err( req ); } SERVER_END_REQ; diff --git a/server/class.c b/server/class.c index f468f8ce506..2a520bded17 100644 --- a/server/class.c +++ b/server/class.c @@ -244,45 +244,45 @@ DECL_HANDLER(set_class_info)
if (!class) return;
- if (req->flags && class->process != current->process) + if (class->process != current->process) { set_error( STATUS_ACCESS_DENIED ); return; }
- if (req->extra_size > sizeof(req->extra_value) || - req->extra_offset < -1 || - req->extra_offset > class->nb_extra_bytes - (int)req->extra_size) - { - set_win32_error( ERROR_INVALID_INDEX ); - return; - } - if ((req->flags & SET_CLASS_WINEXTRA) && (req->win_extra < 0 || req->win_extra > 4096)) - { - set_error( STATUS_INVALID_PARAMETER ); - return; - } - if (req->extra_offset != -1) - { - memcpy( &reply->old_extra_value, class->extra_bytes + req->extra_offset, req->extra_size ); - } - else if (req->flags & SET_CLASS_EXTRA) + switch (req->offset) { + case GCL_STYLE: + reply->old_info = class->style; + class->style = req->new_info; + break; + case GCL_CBWNDEXTRA: + if (req->new_info > 4096) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } + reply->old_info = class->win_extra; + class->win_extra = req->new_info; + break; + case GCL_CBCLSEXTRA: set_win32_error( ERROR_INVALID_INDEX ); - return; + break; + case GCLP_HMODULE: + reply->old_info = class->instance; + class->instance = req->new_info; + break; + default: + if (req->size > sizeof(req->new_info) || req->offset < 0 || + req->offset > class->nb_extra_bytes - (int)req->size) + { + set_win32_error( ERROR_INVALID_INDEX ); + return; + } + memcpy( &reply->old_info, class->extra_bytes + req->offset, req->size ); + memcpy( class->extra_bytes + req->offset, &req->new_info, req->size ); + break; } - - reply->old_atom = class->atom; - reply->old_style = class->style; - reply->old_extra = class->nb_extra_bytes; - reply->old_win_extra = class->win_extra; - reply->old_instance = class->instance; - - if (req->flags & SET_CLASS_STYLE) class->style = req->style; - if (req->flags & SET_CLASS_WINEXTRA) class->win_extra = req->win_extra; - if (req->flags & SET_CLASS_INSTANCE) class->instance = req->instance; - if (req->flags & SET_CLASS_EXTRA) memcpy( class->extra_bytes + req->extra_offset, - &req->extra_value, req->extra_size ); }
diff --git a/server/protocol.def b/server/protocol.def index acdad54aa6d..b87b7d6515a 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -3254,28 +3254,13 @@ enum caret_state
/* Set some information in a class */ @REQ(set_class_info) - user_handle_t window; /* handle to the window */ - unsigned int flags; /* flags for info to set (see below) */ - atom_t atom; /* class atom */ - unsigned int style; /* class style */ - int win_extra; /* number of window extra bytes */ - mod_handle_t instance; /* module instance */ - int extra_offset; /* offset to set in extra bytes */ - data_size_t extra_size; /* size to set in extra bytes */ - lparam_t extra_value; /* value to set in extra bytes */ -@REPLY - unsigned int old_style; /* previous class style */ - atom_t old_atom; /* previous class base atom */ - mod_handle_t old_instance; /* previous module instance */ - lparam_t old_extra_value; /* old value in extra bytes */ - int old_extra; /* previous number of class extra bytes */ - int old_win_extra; /* previous number of window extra bytes */ -@END -#define SET_CLASS_ATOM 0x0001 -#define SET_CLASS_STYLE 0x0002 -#define SET_CLASS_WINEXTRA 0x0004 -#define SET_CLASS_INSTANCE 0x0008 -#define SET_CLASS_EXTRA 0x0010 + user_handle_t window; /* handle to the window */ + int offset; /* offset of the info */ + data_size_t size; /* size of the info value to write */ + lparam_t new_info; /* new class info value */ +@REPLY + lparam_t old_info; /* previous class info value */ +@END
/* Get some information in a class */ @REQ(get_class_info)