Commit d8c807ba authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Use KeUserModeCallback interface for CopyImage.

Its implementation doesn't seem to be exposed from win32u and it generally fits well in user space. It will be also useful for drivers. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 4af9ac67
...@@ -159,7 +159,6 @@ static void CDECL free_win_ptr( WND *win ) ...@@ -159,7 +159,6 @@ static void CDECL free_win_ptr( WND *win )
static const struct user_callbacks user_funcs = static const struct user_callbacks user_funcs =
{ {
CopyImage,
EndMenu, EndMenu,
ImmProcessKey, ImmProcessKey,
ImmTranslateMessage, ImmTranslateMessage,
...@@ -176,6 +175,12 @@ static const struct user_callbacks user_funcs = ...@@ -176,6 +175,12 @@ static const struct user_callbacks user_funcs =
unregister_imm, unregister_imm,
}; };
static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, ULONG size )
{
HANDLE ret = CopyImage( params->hwnd, params->type, params->dx, params->dy, params->flags );
return HandleToUlong( ret );
}
static NTSTATUS WINAPI User32FreeCachedClipboardData( const struct free_cached_data_params *params, static NTSTATUS WINAPI User32FreeCachedClipboardData( const struct free_cached_data_params *params,
ULONG size ) ULONG size )
{ {
...@@ -202,6 +207,7 @@ static const void *kernel_callback_table[NtUserCallCount] = ...@@ -202,6 +207,7 @@ static const void *kernel_callback_table[NtUserCallCount] =
User32CallWinEventHook, User32CallWinEventHook,
User32CallWindowProc, User32CallWindowProc,
User32CallWindowsHook, User32CallWindowsHook,
User32CopyImage,
User32FreeCachedClipboardData, User32FreeCachedClipboardData,
User32LoadDriver, User32LoadDriver,
User32RegisterBuiltinClasses, User32RegisterBuiltinClasses,
......
...@@ -444,11 +444,11 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam ...@@ -444,11 +444,11 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam
class->hbrBackground = wc->hbrBackground; class->hbrBackground = wc->hbrBackground;
class->winproc = alloc_winproc( wc->lpfnWndProc, ansi ); class->winproc = alloc_winproc( wc->lpfnWndProc, ansi );
if (client_menu_name) class->menu_name = *client_menu_name; if (client_menu_name) class->menu_name = *client_menu_name;
if (wc->hIcon && !wc->hIconSm && user_callbacks) if (wc->hIcon && !wc->hIconSm)
class->hIconSmIntern = user_callbacks->pCopyImage( wc->hIcon, IMAGE_ICON, class->hIconSmIntern = CopyImage( wc->hIcon, IMAGE_ICON,
get_system_metrics( SM_CXSMICON ), get_system_metrics( SM_CXSMICON ),
get_system_metrics( SM_CYSMICON ), get_system_metrics( SM_CYSMICON ),
LR_COPYFROMRESOURCE ); LR_COPYFROMRESOURCE );
release_class_ptr( class ); release_class_ptr( class );
return atom; return atom;
} }
...@@ -699,20 +699,20 @@ static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT si ...@@ -699,20 +699,20 @@ static ULONG_PTR set_class_long( HWND hwnd, INT offset, LONG_PTR newval, UINT si
NtUserDestroyCursor( class->hIconSmIntern, 0 ); NtUserDestroyCursor( class->hIconSmIntern, 0 );
class->hIconSmIntern = NULL; class->hIconSmIntern = NULL;
} }
if (newval && !class->hIconSm && user_callbacks) if (newval && !class->hIconSm)
class->hIconSmIntern = user_callbacks->pCopyImage( (HICON)newval, IMAGE_ICON, class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
get_system_metrics( SM_CXSMICON ), get_system_metrics( SM_CXSMICON ),
get_system_metrics( SM_CYSMICON ), get_system_metrics( SM_CYSMICON ),
LR_COPYFROMRESOURCE ); LR_COPYFROMRESOURCE );
class->hIcon = (HICON)newval; class->hIcon = (HICON)newval;
break; break;
case GCLP_HICONSM: case GCLP_HICONSM:
retval = (ULONG_PTR)class->hIconSm; retval = (ULONG_PTR)class->hIconSm;
if (retval && !newval && class->hIcon && user_callbacks) if (retval && !newval && class->hIcon)
class->hIconSmIntern = user_callbacks->pCopyImage( class->hIcon, IMAGE_ICON, class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
get_system_metrics( SM_CXSMICON ), get_system_metrics( SM_CXSMICON ),
get_system_metrics( SM_CYSMICON ), get_system_metrics( SM_CYSMICON ),
LR_COPYFROMRESOURCE ); LR_COPYFROMRESOURCE );
else if (newval && class->hIconSmIntern) else if (newval && class->hIconSmIntern)
{ {
NtUserDestroyCursor( class->hIconSmIntern, 0 ); NtUserDestroyCursor( class->hIconSmIntern, 0 );
......
...@@ -786,3 +786,18 @@ ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param ) ...@@ -786,3 +786,18 @@ ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param )
} }
return ret; return ret;
} }
/******************************************************************************
* CopyImage (win32u.so)
*/
HANDLE WINAPI CopyImage( HANDLE hwnd, UINT type, INT dx, INT dy, UINT flags )
{
void *ret_ptr;
ULONG ret_len;
NTSTATUS ret;
struct copy_image_params params =
{ .hwnd = hwnd, .type = type, .dx = dx, .dy = dy, .flags = flags };
ret = KeUserModeCallback( NtUserCopyImage, &params, sizeof(params), &ret_ptr, &ret_len );
return UlongToHandle( ret );
}
...@@ -123,11 +123,11 @@ static HICON set_window_icon( HWND hwnd, WPARAM type, HICON icon ) ...@@ -123,11 +123,11 @@ static HICON set_window_icon( HWND hwnd, WPARAM type, HICON icon )
{ {
case ICON_SMALL: case ICON_SMALL:
ret = win->hIconSmall; ret = win->hIconSmall;
if (ret && !icon && win->hIcon && user_callbacks) if (ret && !icon && win->hIcon)
{ {
win->hIconSmall2 = user_callbacks->pCopyImage( win->hIcon, IMAGE_ICON, win->hIconSmall2 = CopyImage( win->hIcon, IMAGE_ICON,
get_system_metrics( SM_CXSMICON ), get_system_metrics( SM_CXSMICON ),
get_system_metrics( SM_CYSMICON ), 0 ); get_system_metrics( SM_CYSMICON ), 0 );
} }
else if (icon && win->hIconSmall2) else if (icon && win->hIconSmall2)
{ {
...@@ -144,11 +144,11 @@ static HICON set_window_icon( HWND hwnd, WPARAM type, HICON icon ) ...@@ -144,11 +144,11 @@ static HICON set_window_icon( HWND hwnd, WPARAM type, HICON icon )
NtUserDestroyCursor( win->hIconSmall2, 0 ); NtUserDestroyCursor( win->hIconSmall2, 0 );
win->hIconSmall2 = NULL; win->hIconSmall2 = NULL;
} }
if (icon && !win->hIconSmall && user_callbacks) if (icon && !win->hIconSmall)
{ {
win->hIconSmall2 = user_callbacks->pCopyImage( icon, IMAGE_ICON, win->hIconSmall2 = CopyImage( icon, IMAGE_ICON,
get_system_metrics( SM_CXSMICON ), get_system_metrics( SM_CXSMICON ),
get_system_metrics( SM_CYSMICON ), 0 ); get_system_metrics( SM_CYSMICON ), 0 );
} }
win->hIcon = icon; win->hIcon = icon;
break; break;
......
...@@ -32,7 +32,6 @@ struct hardware_msg_data; ...@@ -32,7 +32,6 @@ struct hardware_msg_data;
struct user_callbacks struct user_callbacks
{ {
HANDLE (WINAPI *pCopyImage)( HANDLE, UINT, INT, INT, UINT );
BOOL (WINAPI *pEndMenu)(void); BOOL (WINAPI *pEndMenu)(void);
BOOL (WINAPI *pImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD); BOOL (WINAPI *pImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD);
BOOL (WINAPI *pImmTranslateMessage)(HWND, UINT, WPARAM, LPARAM); BOOL (WINAPI *pImmTranslateMessage)(HWND, UINT, WPARAM, LPARAM);
......
...@@ -32,6 +32,7 @@ enum ...@@ -32,6 +32,7 @@ enum
NtUserCallWinEventHook, NtUserCallWinEventHook,
NtUserCallWinProc, NtUserCallWinProc,
NtUserCallWindowsHook, NtUserCallWindowsHook,
NtUserCopyImage,
NtUserFreeCachedClipboardData, NtUserFreeCachedClipboardData,
NtUserLoadDriver, NtUserLoadDriver,
NtUserRegisterBuiltinClasses, NtUserRegisterBuiltinClasses,
...@@ -146,6 +147,16 @@ struct win_hook_params ...@@ -146,6 +147,16 @@ struct win_hook_params
WCHAR module[MAX_PATH]; WCHAR module[MAX_PATH];
}; };
/* NtUserCopyMessage params */
struct copy_image_params
{
HANDLE hwnd;
UINT type;
INT dx;
INT dy;
UINT flags;
};
/* NtUserFreeCachedClipboardData params */ /* NtUserFreeCachedClipboardData params */
struct free_cached_data_params struct free_cached_data_params
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment