From: Rémi Bernon rbernon@codeweavers.com
Passing every atom as UNICODE_STRING to win32u. --- dlls/user32/class.c | 31 ++++---------------------- dlls/user32/controls.h | 3 --- dlls/user32/tests/class.c | 46 +++++++++++++++++++-------------------- dlls/win32u/class.c | 20 +++++------------ dlls/win32u/menu.c | 3 ++- 5 files changed, 35 insertions(+), 68 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c index 24e3b1e9200..3b84d0840f3 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -35,29 +35,6 @@ static inline const char *debugstr_us( const UNICODE_STRING *us ) return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) ); }
- -/*********************************************************************** - * get_int_atom_value - */ -ATOM get_int_atom_value( UNICODE_STRING *name ) -{ - const WCHAR *ptr = name->Buffer; - const WCHAR *end = ptr + name->Length / sizeof(WCHAR); - UINT ret = 0; - - if (IS_INTRESOURCE(ptr)) return LOWORD(ptr); - - if (*ptr++ != '#') return 0; - while (ptr < end) - { - if (*ptr < '0' || *ptr > '9') return 0; - ret = ret * 10 + *ptr++ - '0'; - if (ret >= MAXINTATOM) return 0; - } - return ret; -} - - /*********************************************************************** * is_comctl32_class */ @@ -124,8 +101,8 @@ void init_class_name_ansi( UNICODE_STRING *str, const char *name ) { if (IS_INTRESOURCE( name )) { - str->Buffer = (WCHAR *)name; - str->Length = str->MaximumLength = 0; + UINT len = NtUserGetAtomName( (UINT_PTR)name, str ); + str->Length = len * sizeof(WCHAR); } else { @@ -138,8 +115,8 @@ void init_class_name( UNICODE_STRING *str, const WCHAR *name ) { if (IS_INTRESOURCE( name )) { - str->Buffer = (WCHAR *)name; - str->Length = str->MaximumLength = 0; + UINT len = NtUserGetAtomName( (UINT_PTR)name, str ); + str->Length = len * sizeof(WCHAR); } else { diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h index d6dd4c17969..69c8fd9b982 100644 --- a/dlls/user32/controls.h +++ b/dlls/user32/controls.h @@ -78,9 +78,6 @@ extern LRESULT MDIClientWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL); extern LRESULT ScrollBarWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL); extern LRESULT StaticWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL);
-/* Class functions */ -extern ATOM get_int_atom_value( UNICODE_STRING *name ); - /* desktop */ extern BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern );
diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index 4cee5f358d9..e6c841857cf 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -1780,8 +1780,8 @@ static void test_actctx_classes(void)
/* unversioned class redirects to the versioned class now */ check_atom_name_a( class, wc.lpszClassName ); - tmp_class = check_class_info_a_( __FILE__, __LINE__, hinst, MAKEINTRESOURCEA( class ), &wc_versioned, TRUE ); - todo_wine check_atom_name_a( tmp_class, wc_versioned.lpszClassName ); + tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA( class ), &wc_versioned ); + check_atom_name_a( tmp_class, wc_versioned.lpszClassName ); tmp_class = check_class_info_a( hinst, wc.lpszClassName, &wc_versioned ); check_atom_name_a( tmp_class, wc_versioned.lpszClassName ); check_atom_name_a( class_versioned, wc_versioned.lpszClassName ); @@ -1800,7 +1800,7 @@ static void test_actctx_classes(void) ret = UnregisterClassA( wc_versioned.lpszClassName, hinst ); ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); check_atom_name_a( class, wc.lpszClassName ); - todo_wine check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); + check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); check_class_info_a( hinst, wc.lpszClassName, NULL ); check_atom_name_a( class_versioned, NULL ); check_class_info_a( hinst, MAKEINTRESOURCEA( class_versioned ), NULL ); @@ -1847,7 +1847,7 @@ static void test_actctx_classes(void)
/* unversioned class is innaccessible now */ check_atom_name_a( class, wc_leak.lpszClassName ); - todo_wine check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); + check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); check_class_info_a( hinst, wc_leak.lpszClassName, NULL ); check_class_info_a( hinst, wc_leak_versioned.lpszClassName, NULL );
@@ -1856,7 +1856,7 @@ static void test_actctx_classes(void) todo_wine ok( tmp_class == class, "RegisterClassA failed, error %lu\n", GetLastError() ); check_atom_name_a( class, wc_leak.lpszClassName ); tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA( class ), &wc_leak ); - check_atom_name_a( tmp_class, wc_leak.lpszClassName ); + todo_wine check_atom_name_a( tmp_class, wc_leak.lpszClassName ); tmp_class = check_class_info_a( hinst, wc_leak.lpszClassName, &wc_leak ); todo_wine check_atom_name_a( tmp_class, wc_leak.lpszClassName ); tmp_class = check_class_info_a( hinst, wc_leak_versioned.lpszClassName, &wc ); @@ -1866,7 +1866,7 @@ static void test_actctx_classes(void) ret = UnregisterClassA( wc_leak.lpszClassName, hinst ); ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); check_atom_name_a( class, wc_leak.lpszClassName ); - todo_wine check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); + check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); check_class_info_a( hinst, wc_leak.lpszClassName, NULL ); check_class_info_a( hinst, wc_leak_versioned.lpszClassName, NULL );
@@ -1874,24 +1874,24 @@ static void test_actctx_classes(void) ret = UnregisterClassA( wc_leak.lpszClassName, hinst ); ok( !ret, "UnregisterClassA succeeded\n" ); ret = UnregisterClassA( MAKEINTRESOURCEA( class ), hinst ); - todo_wine ok( !ret, "UnregisterClassA succeeded\n" ); - todo_wine check_atom_name_a( class, wc_leak.lpszClassName ); + ok( !ret, "UnregisterClassA succeeded\n" ); + check_atom_name_a( class, wc_leak.lpszClassName ); check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); check_class_info_a( hinst, wc_leak.lpszClassName, NULL ); check_class_info_a( hinst, wc_leak_versioned.lpszClassName, NULL );
ret = DeactivateActCtx( 0, cookie ); ok( ret, "DeactivateActCtx failed, error %lu\n", GetLastError() ); - todo_wine check_atom_name_a( class, wc_leak.lpszClassName ); - todo_wine tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA( class ), &wc_leak ); - todo_wine check_atom_name_a( tmp_class, wc_leak.lpszClassName ); - todo_wine tmp_class = check_class_info_a( hinst, wc_leak.lpszClassName, &wc_leak ); - todo_wine check_atom_name_a( tmp_class, wc_leak.lpszClassName ); + check_atom_name_a( class, wc_leak.lpszClassName ); + tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA( class ), &wc_leak ); + check_atom_name_a( tmp_class, wc_leak.lpszClassName ); + tmp_class = check_class_info_a( hinst, wc_leak.lpszClassName, &wc_leak ); + check_atom_name_a( tmp_class, wc_leak.lpszClassName ); check_class_info_a( hinst, wc_leak_versioned.lpszClassName, NULL );
/* unversioned class can be unregistered now */ ret = UnregisterClassA( MAKEINTRESOURCEA( class ), hinst ); - todo_wine ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); + ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); ret = UnregisterClassA( MAKEINTRESOURCEA( class ), hinst ); ok( !ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); /* base atom name is leaked */ @@ -2042,16 +2042,16 @@ static void test_actctx_classes(void) check_class_info_a( hinst, MAKEINTRESOURCEA(1234), NULL ); check_class_info_a( hinst, wc_integral.lpszClassName, NULL ); class = RegisterClassA( &wc_integral_int ); - ok( class == 1234, "RegisterClassA failed, error %lu\n", GetLastError() ); + todo_wine ok( class == 1234, "RegisterClassA failed, error %lu\n", GetLastError() ); tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA(1234), &wc_integral_int ); - ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); - todo_wine tmp_class = check_class_info_a( hinst, wc_integral.lpszClassName, &wc_integral_int ); + todo_wine ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); + tmp_class = check_class_info_a( hinst, wc_integral.lpszClassName, &wc_integral_int ); todo_wine ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); ret = UnregisterClassA( MAKEINTRESOURCEA( class ), hinst ); ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); class = RegisterClassA( &wc_integral ); todo_wine ok( class == 1234, "RegisterClassA failed, error %lu\n", GetLastError() ); - todo_wine tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA(1234), &wc_integral ); + tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA(1234), &wc_integral ); todo_wine ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); tmp_class = check_class_info_a( hinst, wc_integral.lpszClassName, &wc_integral ); todo_wine ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); @@ -2063,7 +2063,7 @@ static void test_actctx_classes(void) ret = ActivateActCtx( context, &cookie ); ok( ret, "ActivateActCtx failed, error %lu\n", GetLastError() ); ret = UnregisterClassA( MAKEINTRESOURCEA(1234), hinst ); - todo_wine ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); + ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); class = RegisterClassA( &wc_integral ); todo_wine ok( class == 1234, "RegisterClassA failed, error %lu\n", GetLastError() ); ret = UnregisterClassA( wc_integral.lpszClassName, hinst ); @@ -2139,7 +2139,7 @@ static void test_actctx_classes(void) ok( ret, "ActivateActCtx failed, error %lu\n", GetLastError() );
/* unversioned class is innaccessible now */ - todo_wine check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); + check_class_info_a( hinst, MAKEINTRESOURCEA( class ), NULL ); check_class_info_a( hinst, wc_integral.lpszClassName, NULL ); check_class_info_a( hinst, wc_integral_versioned.lpszClassName, NULL );
@@ -2148,7 +2148,7 @@ static void test_actctx_classes(void) todo_wine ok( tmp_class == class, "RegisterClassA failed, error %lu\n", GetLastError() );
tmp_class = check_class_info_a( hinst, MAKEINTRESOURCEA( class ), &wc_integral ); - ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); + todo_wine ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); tmp_class = check_class_info_a( hinst, wc_integral.lpszClassName, &wc_integral ); todo_wine ok( tmp_class == 1234, "GetClassInfoA failed, error %lu\n", GetLastError() ); tmp_class = check_class_info_a( hinst, wc_integral_versioned.lpszClassName, &wc_integral ); @@ -2161,12 +2161,12 @@ static void test_actctx_classes(void) ret = UnregisterClassA( wc_integral.lpszClassName, hinst ); ok( !ret, "UnregisterClassA succeeded\n" ); ret = UnregisterClassA( MAKEINTRESOURCEA( class ), hinst ); - todo_wine ok( !ret, "UnregisterClassA succeeded\n" ); + ok( !ret, "UnregisterClassA succeeded\n" ); ret = DeactivateActCtx( 0, cookie ); ok( ret, "DeactivateActCtx failed, error %lu\n", GetLastError() ); /* unversioned class can be unregistered now */ ret = UnregisterClassA( MAKEINTRESOURCEA( class ), hinst ); - todo_wine ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() ); + ok( ret, "UnregisterClassA failed, error %lu\n", GetLastError() );
/* class info is available by atom, versioned, base names when context is active */ diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index cafd39f7fea..4b1f69bcb41 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -1164,7 +1164,7 @@ BOOL needs_ime_window( HWND hwnd )
static const struct builtin_class_descr desktop_builtin_class = { - .name = MAKEINTRESOURCEA(DESKTOP_CLASS_ATOM), + .name = "#32769", /* DESKTOP_CLASS_ATOM */ .style = CS_DBLCLKS, .proc = NTUSER_WNDPROC_DESKTOP, .brush = (HBRUSH)(COLOR_BACKGROUND + 1), @@ -1204,7 +1204,7 @@ static const struct builtin_class_descr builtin_classes[] = }, /* dialog */ { - .name = MAKEINTRESOURCEA(DIALOG_CLASS_ATOM), + .name = "#32770", /* DIALOG_CLASS_ATOM */ .style = CS_SAVEBITS | CS_DBLCLKS, .proc = NTUSER_WNDPROC_DIALOG, .extra = DLGWINDOWEXTRA, @@ -1212,7 +1212,7 @@ static const struct builtin_class_descr builtin_classes[] = }, /* icon title */ { - .name = MAKEINTRESOURCEA(ICONTITLE_CLASS_ATOM), + .name = "#32772", /* ICONTITLE_CLASS_ATOM */ .proc = NTUSER_WNDPROC_ICONTITLE, .cursor = IDC_ARROW, }, @@ -1233,7 +1233,7 @@ static const struct builtin_class_descr builtin_classes[] = }, /* menu */ { - .name = MAKEINTRESOURCEA(POPUPMENU_CLASS_ATOM), + .name = "#32768", /* POPUPMENU_CLASS_ATOM */ .style = CS_DROPSHADOW | CS_SAVEBITS | CS_DBLCLKS, .proc = NTUSER_WNDPROC_MENU, .extra = sizeof(HMENU), @@ -1290,16 +1290,8 @@ static void register_builtin( const struct builtin_class_descr *descr ) class.hCursor = LoadImageW( 0, (const WCHAR *)descr->cursor, IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE );
- if (IS_INTRESOURCE( descr->name )) - { - name.Buffer = (WCHAR *)descr->name; - name.Length = name.MaximumLength = 0; - } - else - { - asciiz_to_unicode( nameW, descr->name ); - RtlInitUnicodeString( &name, nameW ); - } + asciiz_to_unicode( nameW, descr->name ); + RtlInitUnicodeString( &name, nameW );
if (!NtUserRegisterClassExWOW( &class, &name, &version, &menu_name, 1, 0, NULL ) && class.hCursor) NtUserDestroyCursor( class.hCursor, 0 ); diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c index bce8e0af79b..c3917ab391c 100644 --- a/dlls/win32u/menu.c +++ b/dlls/win32u/menu.c @@ -3324,7 +3324,8 @@ static void init_sys_menu_popup( HMENU hmenu, DWORD style, DWORD class_style )
static BOOL init_popup( HWND owner, HMENU hmenu, UINT flags ) { - UNICODE_STRING class_name = { .Buffer = MAKEINTRESOURCEW( POPUPMENU_CLASS_ATOM ) }; + static const WCHAR atomW[] = {'#','3','2','7','6','8',0}; /* POPUPMENU_CLASS_ATOM */ + UNICODE_STRING class_name = RTL_CONSTANT_STRING(atomW); DWORD ex_style = 0; struct menu *menu;