1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-09 04:16:08 +00:00

win32u: Use KeUserModeCallback interface for DDE message callbacks.

This commit is contained in:
Jacek Caban 2022-07-09 15:13:42 +02:00 committed by Alexandre Julliard
parent 0826fbbb74
commit d3c57dec71
6 changed files with 87 additions and 19 deletions

View File

@ -477,7 +477,7 @@ BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD
* Unpack a posted DDE message received from another process.
*/
BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size )
const void *buffer, size_t size )
{
UINT_PTR uiLo, uiHi;
HGLOBAL hMem = 0;
@ -491,9 +491,9 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam
ULONGLONG hpack;
/* hMem is being passed */
if (size != sizeof(hpack)) return FALSE;
if (!buffer || !*buffer) return FALSE;
if (!size) return FALSE;
uiLo = *lparam;
memcpy( &hpack, *buffer, size );
memcpy( &hpack, buffer, size );
hMem = unpack_ptr( hpack );
uiHi = (UINT_PTR)hMem;
TRACE("recv dde-ack %Ix mem=%Ix[%Ix]\n", uiLo, uiHi, GlobalSize( hMem ));
@ -509,7 +509,7 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam
case WM_DDE_ADVISE:
case WM_DDE_DATA:
case WM_DDE_POKE:
if ((!buffer || !*buffer) && message != WM_DDE_DATA) return FALSE;
if (!size && message != WM_DDE_DATA) return FALSE;
uiHi = *lparam;
if (size)
{
@ -517,7 +517,7 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam
return FALSE;
if ((ptr = GlobalLock( hMem )))
{
memcpy( ptr, *buffer, size );
memcpy( ptr, buffer, size );
GlobalUnlock( hMem );
}
else
@ -533,11 +533,11 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam
case WM_DDE_EXECUTE:
if (size)
{
if (!buffer || !*buffer) return FALSE;
if (!size) return FALSE;
if (!(hMem = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, size ))) return FALSE;
if ((ptr = GlobalLock( hMem )))
{
memcpy( ptr, *buffer, size );
memcpy( ptr, buffer, size );
GlobalUnlock( hMem );
TRACE( "exec: pairing c=%08Ix s=%p\n", *lparam, hMem );
if (!dde_add_pair( (HGLOBAL)*lparam, hMem ))

View File

@ -134,8 +134,6 @@ static NTSTATUS try_finally( NTSTATUS (CDECL *func)( void *), void *arg,
static const struct user_callbacks user_funcs =
{
NtWaitForMultipleObjects,
post_dde_message,
unpack_dde_message,
try_finally,
};
@ -192,6 +190,12 @@ static NTSTATUS WINAPI User32FreeCachedClipboardData( const struct free_cached_d
return 0;
}
static NTSTATUS WINAPI User32PostDDEMessage( const struct post_dde_message_params *params, ULONG size )
{
return post_dde_message( params->hwnd, params->msg, params->wparam, params->lparam,
params->dest_tid, params->type );
}
static NTSTATUS WINAPI User32RenderSsynthesizedFormat( const struct render_synthesized_format_params *params,
ULONG size )
{
@ -204,6 +208,16 @@ static BOOL WINAPI User32LoadDriver( const WCHAR *path, ULONG size )
return LoadLibraryW( path ) != NULL;
}
static NTSTATUS WINAPI User32UnpackDDEMessage( const struct unpack_dde_message_params *params, ULONG size )
{
struct unpack_dde_message_result *result = params->result;
result->wparam = params->wparam;
result->lparam = params->lparam;
size -= FIELD_OFFSET( struct unpack_dde_message_params, data );
return unpack_dde_message( params->hwnd, params->message, &result->wparam, &result->lparam,
params->data, size );
}
static const void *kernel_callback_table[NtUserCallCount] =
{
User32CallEnumDisplayMonitor,
@ -220,8 +234,10 @@ static const void *kernel_callback_table[NtUserCallCount] =
User32LoadDriver,
User32LoadImage,
User32LoadSysMenu,
User32PostDDEMessage,
User32RegisterBuiltinClasses,
User32RenderSsynthesizedFormat,
User32UnpackDDEMessage,
};

View File

@ -60,7 +60,7 @@ struct tagWND;
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
DWORD type ) DECLSPEC_HIDDEN;
extern BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size ) DECLSPEC_HIDDEN;
const void *buffer, size_t size ) DECLSPEC_HIDDEN;
extern void free_cached_data( UINT format, HANDLE handle ) DECLSPEC_HIDDEN;
extern HANDLE render_synthesized_format( UINT format, UINT from ) DECLSPEC_HIDDEN;

View File

@ -1827,9 +1827,26 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
}
if (info.msg.message >= WM_DDE_FIRST && info.msg.message <= WM_DDE_LAST)
{
if (!user_callbacks->unpack_dde_message( info.msg.hwnd, info.msg.message, &info.msg.wParam,
&info.msg.lParam, &buffer, size ))
continue; /* ignore it */
struct unpack_dde_message_result result;
struct unpack_dde_message_params *params;
void *ret_ptr;
ULONG len;
BOOL ret;
len = FIELD_OFFSET( struct unpack_dde_message_params, data[size] );
if (!(params = malloc( len )))
continue;
params->result = &result;
params->hwnd = info.msg.hwnd;
params->message = info.msg.message;
params->wparam = info.msg.wParam;
params->lparam = info.msg.lParam;
if (size) memcpy( params->data, buffer, size );
ret = KeUserModeCallback( NtUserUnpackDDEMessage, params, len, &ret_ptr, &len );
free( params );
if (!ret) continue; /* ignore it */
info.msg.wParam = result.wparam;
info.msg.lParam = result.lparam;
}
*msg = info.msg;
msg->pt = point_phys_to_win_dpi( info.msg.hwnd, info.msg.pt );
@ -2185,8 +2202,17 @@ static BOOL put_message_in_queue( const struct send_message_info *info, size_t *
}
else if (info->type == MSG_POSTED && info->msg >= WM_DDE_FIRST && info->msg <= WM_DDE_LAST)
{
return user_callbacks && user_callbacks->post_dde_message( info->hwnd, info->msg,
info->wparam, info->lparam, info->dest_tid, info->type );
struct post_dde_message_params params;
void *ret_ptr;
ULONG ret_len;
params.hwnd = info->hwnd;
params.msg = info->msg;
params.wparam = info->wparam;
params.lparam = info->lparam;
params.dest_tid = info->dest_tid;
params.type = info->type;
return KeUserModeCallback( NtUserPostDDEMessage, &params, sizeof(params), &ret_ptr, &ret_len );
}
SERVER_START_REQ( send_message )

View File

@ -33,10 +33,6 @@ struct hardware_msg_data;
struct user_callbacks
{
NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
DWORD type );
BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size );
NTSTATUS (CDECL *try_finally)( NTSTATUS (CDECL *func)( void *), void *arg,
void (CALLBACK *finally_func)( BOOL ));
};

View File

@ -42,8 +42,10 @@ enum
NtUserLoadDriver,
NtUserLoadImage,
NtUserLoadSysMenu,
NtUserPostDDEMessage,
NtUserRegisterBuiltinClasses,
NtUserRenderSynthesizedFormat,
NtUserUnpackDDEMessage,
/* win16 hooks */
NtUserCallFreeIcon,
NtUserThunkLock,
@ -218,6 +220,17 @@ struct load_sys_menu_params
BOOL mdi;
};
/* NtUserPostDDEMessage params */
struct post_dde_message_params
{
HWND hwnd;
UINT msg;
WPARAM wparam;
LPARAM lparam;
DWORD dest_tid;
DWORD type;
};
/* NtUserRenderSynthesizedFormat params */
struct render_synthesized_format_params
{
@ -225,6 +238,23 @@ struct render_synthesized_format_params
UINT from;
};
/* NtUserUnpackDDEMessage params */
struct unpack_dde_message_result
{
WPARAM wparam;
LPARAM lparam;
};
struct unpack_dde_message_params
{
struct unpack_dde_message_result *result; /* FIXME: Use NtCallbackReturn instead */
HWND hwnd;
UINT message;
WPARAM wparam;
LPARAM lparam;
char data[1];
};
/* process DPI awareness contexts */
#define NTUSER_DPI_UNAWARE 0x00006010
#define NTUSER_DPI_SYSTEM_AWARE 0x00006011