Module: wine Branch: master Commit: 0528f37fdd9b11cc95d074bb9e261d5127cb6ec3 URL: https://source.winehq.org/git/wine.git/?a=commit;h=0528f37fdd9b11cc95d074bb9...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Apr 19 15:34:44 2022 +0200
win32u: Move NtUserFindWindowEx implementation from user32.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/win.c | 61 ++++++++----------------------------------------- dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/window.c | 49 +++++++++++++++++++++++++++++++++++++++ dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 16 +++++++++++++ include/ntuser.h | 2 ++ 7 files changed, 80 insertions(+), 52 deletions(-)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 511aa363af7..99ee93adba7 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -738,65 +738,24 @@ BOOL WINAPI OpenIcon( HWND hwnd ) /*********************************************************************** * FindWindowExW (USER32.@) */ -HWND WINAPI FindWindowExW( HWND parent, HWND child, LPCWSTR className, LPCWSTR title ) +HWND WINAPI FindWindowExW( HWND parent, HWND child, const WCHAR *class, const WCHAR *title ) { - HWND *list; - HWND retvalue = 0; - int i = 0, len = 0; - WCHAR *buffer = NULL; - - if (!parent && child) parent = GetDesktopWindow(); - else if (parent == HWND_MESSAGE) parent = get_hwnd_message_parent(); - - if (title) - { - len = lstrlenW(title) + 1; /* one extra char to check for chars beyond the end */ - if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return 0; - } - - if (className) - { - UNICODE_STRING str; - if (IS_INTRESOURCE(className)) - { - str.Buffer = (WCHAR *)className; - str.Length = str.MaximumLength = 0; - } - else RtlInitUnicodeString( &str, className ); - list = list_window_children( 0, parent, &str, 0 ); - } - else list = list_window_children( 0, parent, NULL, 0 ); - if (!list) goto done; + UNICODE_STRING class_str, title_str;
- if (child) - { - child = WIN_GetFullHandle( child ); - while (list[i] && list[i] != child) i++; - if (!list[i]) goto done; - i++; /* start from next window */ - } + if (title) RtlInitUnicodeString( &title_str, title );
- if (title) + if (class) { - while (list[i]) + if (IS_INTRESOURCE(class)) { - if (NtUserInternalGetWindowText( list[i], buffer, len + 1 )) - { - if (!wcsicmp( buffer, title )) break; - } - else - { - if (!title[0]) break; - } - i++; + class_str.Buffer = (WCHAR *)class; + class_str.Length = class_str.MaximumLength = 0; } + else RtlInitUnicodeString( &class_str, class ); } - retvalue = list[i];
- done: - HeapFree( GetProcessHeap(), 0, list ); - HeapFree( GetProcessHeap(), 0, buffer ); - return retvalue; + return NtUserFindWindowEx( parent, child, class ? &class_str : NULL, + title ? &title_str : NULL, 0 ); }
diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index 437fe6d0758..f88b8fa30da 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -116,6 +116,7 @@ static void * const syscalls[] = NtUserCreateWindowStation, NtUserDestroyAcceleratorTable, NtUserFindExistingCursorIcon, + NtUserFindWindowEx, NtUserGetAncestor, NtUserGetAtomName, NtUserGetClassName, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index afb413f8726..98bfbb33a2d 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -882,7 +882,7 @@ @ stdcall NtUserExcludeUpdateRgn(long long) @ stub NtUserFillWindow @ stdcall -syscall NtUserFindExistingCursorIcon(ptr ptr ptr) -@ stub NtUserFindWindowEx +@ stdcall -syscall NtUserFindWindowEx(long long ptr ptr long) @ stdcall NtUserFlashWindowEx(ptr) @ stub NtUserForceWindowToDpiForTest @ stub NtUserFrostCrashedWindow diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 1026b706832..93d92c60de6 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2513,6 +2513,55 @@ NTSTATUS WINAPI NtUserBuildHwndList( HDESK desktop, ULONG unk2, ULONG unk3, ULON return STATUS_SUCCESS; }
+/*********************************************************************** + * NtUserFindWindowEx (USER32.@) + */ +HWND WINAPI NtUserFindWindowEx( HWND parent, HWND child, UNICODE_STRING *class, UNICODE_STRING *title, + ULONG unk ) +{ + HWND *list; + HWND retvalue = 0; + int i = 0, len = 0, title_len; + WCHAR *buffer = NULL; + + if (!parent && child) parent = get_desktop_window(); + else if (parent == HWND_MESSAGE) parent = get_hwnd_message_parent(); + + if (title) + { + len = title->Length / sizeof(WCHAR) + 1; /* one extra char to check for chars beyond the end */ + if (!(buffer = malloc( (len + 1) * sizeof(WCHAR) ))) return 0; + } + + if (!(list = list_window_children( 0, parent, class, 0 ))) goto done; + + if (child) + { + child = get_full_window_handle( child ); + while (list[i] && list[i] != child) i++; + if (!list[i]) goto done; + i++; /* start from next window */ + } + + if (title) + { + while (list[i]) + { + title_len = NtUserInternalGetWindowText( list[i], buffer, len + 1 ); + if (title_len * sizeof(WCHAR) == title->Length && + (!title_len || !wcsnicmp( buffer, title->Buffer, title_len ))) + break; + i++; + } + } + retvalue = list[i]; + + done: + free( list ); + free( buffer ); + return retvalue; +} + /* Retrieve the window text from the server. */ static data_size_t get_server_window_text( HWND hwnd, WCHAR *text, data_size_t count ) { diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index c4e4f7ac219..c1d41c2be43 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -103,6 +103,7 @@ SYSCALL_ENTRY( NtUserCreateWindowStation ) \ SYSCALL_ENTRY( NtUserDestroyAcceleratorTable ) \ SYSCALL_ENTRY( NtUserFindExistingCursorIcon ) \ + SYSCALL_ENTRY( NtUserFindWindowEx ) \ SYSCALL_ENTRY( NtUserGetAncestor ) \ SYSCALL_ENTRY( NtUserGetAtomName ) \ SYSCALL_ENTRY( NtUserGetClassName ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 2af398cfed9..d916680660a 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -259,6 +259,22 @@ NTSTATUS WINAPI wow64_NtUserBuildHwndList( UINT *args ) return status; }
+NTSTATUS WINAPI wow64_NtUserFindWindowEx( UINT *args ) +{ + HWND parent = get_handle( &args ); + HWND child = get_handle( &args ); + UNICODE_STRING32 *class32 = get_ptr( &args ); + UNICODE_STRING32 *title32 = get_ptr( &args ); + ULONG unk = get_ulong( &args ); + + UNICODE_STRING class, title; + HWND ret; + + ret = NtUserFindWindowEx( parent, child, unicode_str_32to64( &class, class32 ), + unicode_str_32to64( &title, title32 ), unk ); + return HandleToUlong( ret ); +} + NTSTATUS WINAPI wow64_NtUserInternalGetWindowText( UINT *args ) { HWND hwnd = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 8eafd78beef..879eed4bf79 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -458,6 +458,8 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode, INT WINAPI NtUserExcludeUpdateRgn( HDC hdc, HWND hwnd ); HICON WINAPI NtUserFindExistingCursorIcon( UNICODE_STRING *module, UNICODE_STRING *res_name, void *desc ); +HWND WINAPI NtUserFindWindowEx( HWND parent, HWND child, UNICODE_STRING *class, + UNICODE_STRING *title, ULONG unk ); BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info ); HWND WINAPI NtUserGetAncestor( HWND hwnd, UINT type ); SHORT WINAPI NtUserGetAsyncKeyState( INT key );