From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/class.c | 60 ++++++++++++++++++-------------------- dlls/user32/user_private.h | 4 +-- dlls/user32/win.c | 15 +++++++++- 3 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c index c728b992138..156881fe253 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -121,7 +121,7 @@ static BOOL is_builtin_class( const WCHAR *name ) }
-static void init_class_name( UNICODE_STRING *str, const WCHAR *name ) +void init_class_name( UNICODE_STRING *str, const WCHAR *name ) { if (IS_INTRESOURCE( name )) { @@ -194,7 +194,7 @@ static ULONG_PTR set_menu_nameA( HWND hwnd, INT offset, ULONG_PTR newval ) return 0; }
-static void get_class_version( UNICODE_STRING *name, UNICODE_STRING *version, BOOL load ) +void get_class_version( UNICODE_STRING *name, UNICODE_STRING *version, BOOL load ) { ACTCTX_SECTION_KEYED_DATA data = {.cbSize = sizeof(data)}; const WCHAR *class_name = name->Buffer; @@ -570,31 +570,12 @@ BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc ) return ret; }
-ATOM get_class_info( HINSTANCE instance, const WCHAR *class_name, WNDCLASSEXW *info, - UNICODE_STRING *name_str, BOOL ansi ) -{ - UNICODE_STRING name; - ATOM atom; - - init_class_name( &name, class_name ); - get_class_version( &name, NULL, TRUE ); - - if (!(atom = NtUserGetClassInfoEx( instance, &name, info, NULL, ansi ))) - { - TRACE( "%s %p -> not found\n", debugstr_w(class_name), instance ); - SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); - return 0; - } - - if (name_str) *name_str = name; - return atom; -} - /*********************************************************************** * GetClassInfoExA (USER32.@) */ BOOL WINAPI GetClassInfoExA( HINSTANCE instance, const char *class_name, WNDCLASSEXA *wc ) { + UNICODE_STRING name; ATOM atom;
TRACE( "%p %s %p\n", instance, debugstr_a(class_name), wc ); @@ -605,17 +586,25 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE instance, const char *class_name, WNDCLAS return FALSE; }
- if (!instance) instance = user32_module; - if (!IS_INTRESOURCE(class_name)) + if (IS_INTRESOURCE( class_name )) init_class_name( &name, (const WCHAR *)class_name ); + else { WCHAR nameW[MAX_ATOM_LEN + 1]; - if (!MultiByteToWideChar( CP_ACP, 0, class_name, -1, nameW, ARRAY_SIZE( nameW ))) - return FALSE; - atom = get_class_info( instance, nameW, (WNDCLASSEXW *)wc, NULL, TRUE ); + if (!MultiByteToWideChar( CP_ACP, 0, class_name, -1, nameW, ARRAY_SIZE( nameW ))) return FALSE; + RtlInitUnicodeString( &name, nameW ); + } + + get_class_version( &name, NULL, TRUE ); + + if (!instance) instance = user32_module; + if (!(atom = NtUserGetClassInfoEx( instance, &name, (WNDCLASSEXW *)wc, NULL, TRUE ))) + { + TRACE( "%s %p -> not found\n", debugstr_us(&name), instance ); + SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); + return 0; } - else atom = get_class_info( instance, (const WCHAR *)class_name, (WNDCLASSEXW *)wc, NULL, TRUE ); - if (atom) wc->lpszClassName = class_name;
+ wc->lpszClassName = class_name; /* We must return the atom of the class here instead of just TRUE. */ return atom; } @@ -626,6 +615,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE instance, const char *class_name, WNDCLAS */ BOOL WINAPI GetClassInfoExW( HINSTANCE instance, const WCHAR *class_name, WNDCLASSEXW *wc ) { + UNICODE_STRING name; ATOM atom;
TRACE( "%p %s %p\n", instance, debugstr_w(class_name), wc ); @@ -636,10 +626,18 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE instance, const WCHAR *class_name, WNDCLA return FALSE; }
+ init_class_name( &name, class_name ); + get_class_version( &name, NULL, TRUE ); + if (!instance) instance = user32_module; - atom = get_class_info( instance, class_name, wc, NULL, FALSE ); - if (atom) wc->lpszClassName = class_name; + if (!(atom = NtUserGetClassInfoEx( instance, &name, wc, NULL, FALSE ))) + { + TRACE( "%s %p -> not found\n", debugstr_us(&name), instance ); + SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); + return 0; + }
+ wc->lpszClassName = class_name; /* We must return the atom of the class here instead of just TRUE. */ return atom; } diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index a324968400f..8eab66efe31 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -81,8 +81,8 @@ extern INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM extern void winproc_init(void); extern LRESULT dispatch_win_proc_params( struct win_proc_params *params );
-extern ATOM get_class_info( HINSTANCE instance, const WCHAR *name, WNDCLASSEXW *info, - UNICODE_STRING *name_str, BOOL ansi ); +extern void init_class_name( UNICODE_STRING *str, const WCHAR *name ); +extern void get_class_version( UNICODE_STRING *name, UNICODE_STRING *version, BOOL load );
/* kernel callbacks */
diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 08371dd3e16..b1e8842b9e8 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -29,6 +29,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
+static const char *debugstr_us( const UNICODE_STRING *us ) +{ + if (!us) return "<null>"; + return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) ); +}
#ifdef __i386__ /* Some apps pass a non-stdcall proc to EnumChildWindows, @@ -282,7 +287,15 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, WCHAR name_buf[8]; HMENU menu;
- if (!get_class_info( module, className, &info, &class, FALSE )) return FALSE; + init_class_name( &class, className ); + get_class_version( &class, NULL, TRUE ); + + if (!NtUserGetClassInfoEx( module, &class, &info, NULL, FALSE )) + { + TRACE( "%s %p -> not found\n", debugstr_us(&class), module ); + SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); + return FALSE; + }
TRACE("%s %s%s%s ex=%08lx style=%08lx %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n", unicode ? debugstr_w(cs->lpszName) : debugstr_a((LPCSTR)cs->lpszName),