From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/tests/class.c | 6 +++--- server/atom.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index 2249a35d622..f75891bcb3f 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -1904,7 +1904,7 @@ static void test_actctx_classes(void) tmp_hwnd = FindWindowExA( NULL, NULL, MAKEINTRESOURCEA( class ), NULL ); todo_wine ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); tmp_hwnd = FindWindowExA( NULL, NULL, "#1234", NULL ); - todo_wine ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); + ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); tmp_hwnd = FindWindowExA(NULL, NULL, "4.3.2.1!#1234", NULL); ok( tmp_hwnd == NULL, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() );
@@ -1914,7 +1914,7 @@ static void test_actctx_classes(void) tmp_hwnd = FindWindowExA( NULL, NULL, MAKEINTRESOURCEA( class ), NULL ); todo_wine ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); tmp_hwnd = FindWindowExA( NULL, NULL, "#1234", NULL ); - todo_wine ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); + ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); tmp_hwnd = FindWindowExA(NULL, NULL, "4.3.2.1!#1234", NULL); ok( tmp_hwnd == NULL, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); DestroyWindow( hwnd ); @@ -1924,7 +1924,7 @@ static void test_actctx_classes(void) tmp_hwnd = FindWindowExA( NULL, NULL, MAKEINTRESOURCEA( class ), NULL ); todo_wine ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); tmp_hwnd = FindWindowExA( NULL, NULL, "#1234", NULL ); - todo_wine ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); + ok( tmp_hwnd == hwnd, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); tmp_hwnd = FindWindowExA( NULL, NULL, "4.3.2.1!#1234", NULL ); ok( tmp_hwnd == NULL, "FindWindowExA returned %p, error %lu\n", tmp_hwnd, GetLastError() ); DestroyWindow( hwnd ); diff --git a/server/atom.c b/server/atom.c index ff0799f5880..b63f4b75e10 100644 --- a/server/atom.c +++ b/server/atom.c @@ -198,6 +198,24 @@ static void atom_table_destroy( struct object *obj ) free( table->entries ); }
+static atom_t get_int_atom_value( const struct unicode_str *name ) +{ + const WCHAR *ptr = name->str; + const WCHAR *end = ptr + name->len / sizeof(WCHAR); + unsigned int 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 > 0xffff) return 0; + } + return ret; +} + /* find an atom entry in its hash list */ static struct atom_entry *find_atom_entry( struct atom_table *table, const struct unicode_str *str, unsigned short hash ) @@ -228,6 +246,8 @@ static atom_t add_atom( struct atom_table *table, const struct unicode_str *str set_error( STATUS_INVALID_PARAMETER ); return 0; } + if ((atom = get_int_atom_value( str ))) return atom; + if ((entry = find_atom_entry( table, str, hash ))) /* exists already */ { entry->count++; @@ -273,6 +293,7 @@ static void delete_atom( struct atom_table *table, atom_t atom, int if_pinned ) static atom_t find_atom( struct atom_table *table, const struct unicode_str *str ) { struct atom_entry *entry; + atom_t atom;
if (!str->len) { @@ -284,6 +305,8 @@ static atom_t find_atom( struct atom_table *table, const struct unicode_str *str set_error( STATUS_INVALID_PARAMETER ); return 0; } + if ((atom = get_int_atom_value( str ))) return atom; + if (table && (entry = find_atom_entry( table, str, hash_strW( str->str, str->len, table->entries_count )))) return entry->atom; @@ -324,8 +347,11 @@ atom_t find_global_atom( struct winstation *winstation, const struct unicode_str { struct atom_table *table = get_global_table( winstation, 0 ); struct atom_entry *entry; + atom_t atom;
if (!str->len || str->len > MAX_ATOM_LEN || !table) return 0; + if ((atom = get_int_atom_value( str ))) return atom; + if ((entry = find_atom_entry( table, str, hash_strW( str->str, str->len, table->entries_count )))) return entry->atom; return 0;