From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/user32/user32.spec | 2 +- dlls/user32/user_main.c | 8 ++++++ dlls/user32/win.c | 47 ----------------------------------- dlls/win32u/cursoricon.c | 21 ++++++++++++++++ dlls/win32u/gdiobj.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 1 + dlls/win32u/window.c | 48 ++++++++++++++++++++++++++++++++++++ dlls/win32u/wrappers.c | 7 ++++++ include/ntuser.h | 15 ++++++++++- 10 files changed, 102 insertions(+), 50 deletions(-)
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 8a7387040dc..b41d661ee2a 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -445,7 +445,7 @@ @ stdcall InsertMenuItemA(long long long ptr) @ stdcall InsertMenuItemW(long long long ptr) @ stdcall InsertMenuW(long long long long ptr) -@ stdcall InternalGetWindowIcon(ptr long) +@ stdcall InternalGetWindowIcon(ptr long) NtUserInternalGetWindowIcon @ stdcall InternalGetWindowText(long ptr long) NtUserInternalGetWindowText @ stdcall IntersectRect(ptr ptr ptr) @ stdcall InvalidateRect(long ptr long) diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index d0c1cc616a7..755fc3d578e 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -164,6 +164,13 @@ static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, return HandleToUlong( ret ); }
+static NTSTATUS WINAPI User32LoadImage( const struct load_image_params *params, ULONG size ) +{ + HANDLE ret = LoadImageW( params->hinst, params->name, params->type, + params->dx, params->dy, params->flags ); + return HandleToUlong( ret ); +} + static NTSTATUS WINAPI User32FreeCachedClipboardData( const struct free_cached_data_params *params, ULONG size ) { @@ -193,6 +200,7 @@ static const void *kernel_callback_table[NtUserCallCount] = User32CopyImage, User32FreeCachedClipboardData, User32LoadDriver, + User32LoadImage, User32RegisterBuiltinClasses, User32RenderSsynthesizedFormat, }; diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 7b0fc884402..99753791f09 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -1794,50 +1794,3 @@ BOOL WINAPI SetWindowCompositionAttribute(HWND hwnd, void *data) SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } - -/*********************************************************************** - * InternalGetWindowIcon (USER32.@) - */ -HICON WINAPI InternalGetWindowIcon( HWND hwnd, UINT type ) -{ - WND *win = WIN_GetPtr( hwnd ); - HICON ret; - - TRACE( "hwnd %p, type %#x\n", hwnd, type ); - - if (!win) - { - SetLastError( ERROR_INVALID_WINDOW_HANDLE ); - return 0; - } - if (win == WND_OTHER_PROCESS || win == WND_DESKTOP) - { - if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd ); - return 0; - } - - switch (type) - { - case ICON_BIG: - ret = win->hIcon; - if (!ret) ret = (HICON)GetClassLongPtrW( hwnd, GCLP_HICON ); - break; - - case ICON_SMALL: - case ICON_SMALL2: - ret = win->hIconSmall ? win->hIconSmall : win->hIconSmall2; - if (!ret) ret = (HICON)GetClassLongPtrW( hwnd, GCLP_HICONSM ); - if (!ret) ret = (HICON)GetClassLongPtrW( hwnd, GCLP_HICON ); - break; - - default: - SetLastError( ERROR_INVALID_PARAMETER ); - WIN_ReleasePtr( win ); - return 0; - } - - if (!ret) ret = LoadIconW( 0, (const WCHAR *)IDI_APPLICATION ); - - WIN_ReleasePtr( win ); - return CopyIcon( ret ); -} diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c index e51feb87115..eaafd07e190 100644 --- a/dlls/win32u/cursoricon.c +++ b/dlls/win32u/cursoricon.c @@ -801,3 +801,24 @@ HANDLE WINAPI CopyImage( HANDLE hwnd, UINT type, INT dx, INT dy, UINT flags ) ret = KeUserModeCallback( NtUserCopyImage, ¶ms, sizeof(params), &ret_ptr, &ret_len ); return UlongToHandle( ret ); } + +/****************************************************************************** + * LoadImage (win32u.so) + */ +HANDLE WINAPI LoadImageW( HINSTANCE hinst, const WCHAR *name, UINT type, + INT dx, INT dy, UINT flags ) +{ + void *ret_ptr; + ULONG ret_len; + NTSTATUS ret; + struct load_image_params params = + { .hinst = hinst, .name = name, .type = type, .dx = dx, .dy = dy, .flags = flags }; + + if (HIWORD(name)) + { + ERR( "name %s not supported in Unix modules\n", debugstr_w( name )); + return 0; + } + ret = KeUserModeCallback( NtUserLoadImage, ¶ms, sizeof(params), &ret_ptr, &ret_len ); + return UlongToHandle( ret ); +} diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 7d9adcdec6a..72924bb658a 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1187,6 +1187,7 @@ static struct unix_funcs unix_funcs = NtUserGetUpdatedClipboardFormats, NtUserGetWindowPlacement, NtUserHideCaret, + NtUserInternalGetWindowIcon, NtUserIsClipboardFormatAvailable, NtUserMapVirtualKeyEx, NtUserMessageCall, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 28c839f5901..de500da143b 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1044,7 +1044,7 @@ @ stub NtUserInjectPointerInput @ stub NtUserInjectTouchInput @ stub NtUserInteractiveControlQueryUsage -@ stub NtUserInternalGetWindowIcon +@ stdcall NtUserInternalGetWindowIcon(ptr long) @ stdcall -syscall NtUserInternalGetWindowText(long ptr long) @ stub NtUserInternalToUnicode @ stub NtUserInvalidateRect diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index e72ab8ff1d7..09c800bd777 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -249,6 +249,7 @@ struct unix_funcs BOOL (WINAPI *pNtUserGetUpdatedClipboardFormats)( UINT *formats, UINT size, UINT *out_size ); BOOL (WINAPI *pNtUserGetWindowPlacement)( HWND hwnd, WINDOWPLACEMENT *placement ); BOOL (WINAPI *pNtUserHideCaret)( HWND hwnd ); + HICON (WINAPI *pNtUserInternalGetWindowIcon)( HWND hwnd, UINT type ); BOOL (WINAPI *pNtUserIsClipboardFormatAvailable)( UINT format ); UINT (WINAPI *pNtUserMapVirtualKeyEx)( UINT code, UINT type, HKL layout ); LRESULT (WINAPI *pNtUserMessageCall)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index d09a719185a..08e901cc855 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -4554,6 +4554,54 @@ static BOOL set_window_context_help_id( HWND hwnd, DWORD id ) return TRUE; }
+/*********************************************************************** + * NtUserInternalGetWindowIcon (win32u.@) + */ +HICON WINAPI NtUserInternalGetWindowIcon( HWND hwnd, UINT type ) +{ + WND *win = get_win_ptr( hwnd ); + HICON ret; + + TRACE( "hwnd %p, type %#x\n", hwnd, type ); + + if (!win) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return 0; + } + if (win == WND_OTHER_PROCESS || win == WND_DESKTOP) + { + if (is_window( hwnd )) FIXME( "not supported on other process window %p\n", hwnd ); + return 0; + } + + switch (type) + { + case ICON_BIG: + ret = win->hIcon; + if (!ret) ret = (HICON)get_class_long_ptr( hwnd, GCLP_HICON, FALSE ); + break; + + case ICON_SMALL: + case ICON_SMALL2: + ret = win->hIconSmall ? win->hIconSmall : win->hIconSmall2; + if (!ret) ret = (HICON)get_class_long_ptr( hwnd, GCLP_HICONSM, FALSE ); + if (!ret) ret = (HICON)get_class_long_ptr( hwnd, GCLP_HICON, FALSE ); + break; + + default: + SetLastError( ERROR_INVALID_PARAMETER ); + release_win_ptr( win ); + return 0; + } + release_win_ptr( win ); + + if (!ret) ret = LoadImageW( 0, (const WCHAR *)IDI_APPLICATION, IMAGE_ICON, + 0, 0, LR_SHARED | LR_DEFAULTSIZE ); + + return CopyImage( ret, IMAGE_ICON, 0, 0, 0 ); +} + /*********************************************************************** * send_destroy_message */ diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index e4219ed5648..99e0b9f3d88 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1029,12 +1029,19 @@ BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT *ou return unix_funcs->pNtUserGetUpdatedClipboardFormats( formats, size, out_size ); }
+ BOOL WINAPI NtUserGetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *placement ) { if (!unix_funcs) return FALSE; return unix_funcs->pNtUserGetWindowPlacement( hwnd, placement ); }
+HICON WINAPI NtUserInternalGetWindowIcon( HWND hwnd, UINT type ) +{ + if (!unix_funcs) return 0; + return unix_funcs->pNtUserInternalGetWindowIcon( hwnd, type ); +} + BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format ) { if (!unix_funcs) return FALSE; diff --git a/include/ntuser.h b/include/ntuser.h index 7451d649702..9d9ac0247d1 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -35,6 +35,7 @@ enum NtUserCopyImage, NtUserFreeCachedClipboardData, NtUserLoadDriver, + NtUserLoadImage, NtUserRegisterBuiltinClasses, NtUserRenderSynthesizedFormat, /* win16 hooks */ @@ -147,7 +148,7 @@ struct win_hook_params WCHAR module[MAX_PATH]; };
-/* NtUserCopyMessage params */ +/* NtUserCopyImage params */ struct copy_image_params { HANDLE hwnd; @@ -164,6 +165,17 @@ struct free_cached_data_params HANDLE handle; };
+/* NtUserLoadImage params */ +struct load_image_params +{ + HINSTANCE hinst; + const WCHAR *name; + UINT type; + INT dx; + INT dy; + UINT flags; +}; + /* NtUserRenderSynthesizedFormat params */ struct render_synthesized_format_params { @@ -589,6 +601,7 @@ BOOL WINAPI NtUserHideCaret( HWND hwnd ); NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs *client_procsA, const struct user_client_procs *client_procsW, const void *client_workers, HINSTANCE user_module ); +HICON WINAPI NtUserInternalGetWindowIcon( HWND hwnd, UINT type ); INT WINAPI NtUserInternalGetWindowText( HWND hwnd, WCHAR *text, INT count ); BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format ); BOOL WINAPI NtUserKillTimer( HWND hwnd, UINT_PTR id );