user32: Move support for posting a DDE message to win32u.

This commit is contained in:
Alexandre Julliard 2024-11-19 15:49:06 +01:00
parent c66b27557d
commit 95bab1b106
6 changed files with 71 additions and 36 deletions

View file

@ -333,10 +333,9 @@ static HGLOBAL dde_get_pair(HGLOBAL shm)
* *
* Post a DDE message * Post a DDE message
*/ */
NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, DWORD type ) NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid )
{ {
void* ptr = NULL; struct post_dde_message_call_params params = { .dest_tid = dest_tid };
int size = 0;
UINT_PTR uiLo, uiHi; UINT_PTR uiLo, uiHi;
LPARAM lp; LPARAM lp;
HGLOBAL hunlock = 0; HGLOBAL hunlock = 0;
@ -364,8 +363,8 @@ NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DW
{ {
hpack = pack_ptr( h ); hpack = pack_ptr( h );
/* send back the value of h on the other side */ /* send back the value of h on the other side */
ptr = &hpack; params.ptr = &hpack;
size = sizeof(hpack); params.size = sizeof(hpack);
lp = uiLo; lp = uiLo;
TRACE( "send dde-ack %Ix %08Ix => %p\n", uiLo, uiHi, h ); TRACE( "send dde-ack %Ix %08Ix => %p\n", uiLo, uiHi, h );
} }
@ -382,10 +381,10 @@ NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DW
case WM_DDE_POKE: case WM_DDE_POKE:
if (uiLo) if (uiLo)
{ {
size = GlobalSize( (HGLOBAL)uiLo ) ; params.size = GlobalSize( (HGLOBAL)uiLo ) ;
if ((msg == WM_DDE_ADVISE && size < sizeof(DDEADVISE)) || if ((msg == WM_DDE_ADVISE && params.size < sizeof(DDEADVISE)) ||
(msg == WM_DDE_DATA && size < FIELD_OFFSET(DDEDATA, Value)) || (msg == WM_DDE_DATA && params.size < FIELD_OFFSET(DDEDATA, Value)) ||
(msg == WM_DDE_POKE && size < FIELD_OFFSET(DDEPOKE, Value))) (msg == WM_DDE_POKE && params.size < FIELD_OFFSET(DDEPOKE, Value)))
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
else if (msg != WM_DDE_DATA) return STATUS_INVALID_PARAMETER; else if (msg != WM_DDE_DATA) return STATUS_INVALID_PARAMETER;
@ -393,23 +392,23 @@ NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DW
lp = uiHi; lp = uiHi;
if (uiLo) if (uiLo)
{ {
if ((ptr = GlobalLock( (HGLOBAL)uiLo) )) if ((params.ptr = GlobalLock( (HGLOBAL)uiLo) ))
{ {
DDEDATA *dde_data = ptr; DDEDATA *dde_data = params.ptr;
TRACE("unused %d, fResponse %d, fRelease %d, fDeferUpd %d, fAckReq %d, cfFormat %d\n", TRACE("unused %d, fResponse %d, fRelease %d, fDeferUpd %d, fAckReq %d, cfFormat %d\n",
dde_data->unused, dde_data->fResponse, dde_data->fRelease, dde_data->unused, dde_data->fResponse, dde_data->fRelease,
dde_data->reserved, dde_data->fAckReq, dde_data->cfFormat); dde_data->reserved, dde_data->fAckReq, dde_data->cfFormat);
hunlock = (HGLOBAL)uiLo; hunlock = (HGLOBAL)uiLo;
} }
} }
TRACE( "send ddepack %u %Ix\n", size, uiHi ); TRACE( "send ddepack %u %Ix\n", params.size, uiHi );
break; break;
case WM_DDE_EXECUTE: case WM_DDE_EXECUTE:
if (lparam) if (lparam)
{ {
if ((ptr = GlobalLock( (HGLOBAL)lparam) )) if ((params.ptr = GlobalLock( (HGLOBAL)lparam) ))
{ {
size = GlobalSize( (HGLOBAL)lparam ); params.size = GlobalSize( (HGLOBAL)lparam );
/* so that the other side can send it back on ACK */ /* so that the other side can send it back on ACK */
lp = lparam; lp = lparam;
hunlock = (HGLOBAL)lparam; hunlock = (HGLOBAL)lparam;
@ -417,20 +416,9 @@ NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DW
} }
break; break;
} }
SERVER_START_REQ( send_message )
{ res = NtUserMessageCall( hwnd, msg, wparam, lp, &params, NtUserPostDdeCall, FALSE );
req->id = dest_tid; if (!res) FreeDDElParam( msg, lparam );
req->type = type;
req->flags = 0;
req->win = wine_server_user_handle( hwnd );
req->msg = msg;
req->wparam = wparam;
req->lparam = lp;
req->timeout = TIMEOUT_INFINITE;
if (size) wine_server_add_data( req, ptr, size );
if (!(res = wine_server_call( req ))) FreeDDElParam( msg, lparam );
}
SERVER_END_REQ;
if (hunlock) GlobalUnlock(hunlock); if (hunlock) GlobalUnlock(hunlock);
return res; return res;

View file

@ -126,7 +126,7 @@ static NTSTATUS WINAPI User32PostDDEMessage( void *args, ULONG size )
{ {
const struct post_dde_message_params *params = args; const struct post_dde_message_params *params = args;
return post_dde_message( params->hwnd, params->msg, params->wparam, params->lparam, return post_dde_message( params->hwnd, params->msg, params->wparam, params->lparam,
params->dest_tid, params->type ); params->dest_tid );
} }
static NTSTATUS WINAPI User32RenderSsynthesizedFormat( void *args, ULONG size ) static NTSTATUS WINAPI User32RenderSsynthesizedFormat( void *args, ULONG size )

View file

@ -46,8 +46,7 @@ struct wm_char_mapping_data
extern HMODULE user32_module; extern HMODULE user32_module;
extern NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, extern NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid );
DWORD type );
extern BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, extern BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
const void *buffer, size_t size ); const void *buffer, size_t size );
extern void free_cached_data( UINT format, HANDLE handle ); extern void free_cached_data( UINT format, HANDLE handle );

View file

@ -34,7 +34,6 @@
#include "dbt.h" #include "dbt.h"
#include "dde.h" #include "dde.h"
#include "immdev.h" #include "immdev.h"
#include "wine/server.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msg); WINE_DEFAULT_DEBUG_CHANNEL(msg);
@ -3368,7 +3367,6 @@ static BOOL put_message_in_queue( const struct send_message_info *info, size_t *
params.wparam = info->wparam; params.wparam = info->wparam;
params.lparam = info->lparam; params.lparam = info->lparam;
params.dest_tid = info->dest_tid; params.dest_tid = info->dest_tid;
params.type = info->type;
res = KeUserModeCallback( NtUserPostDDEMessage, &params, sizeof(params), &ret_ptr, &ret_len ); res = KeUserModeCallback( NtUserPostDDEMessage, &params, sizeof(params), &ret_ptr, &ret_len );
goto done; goto done;
} }
@ -3396,6 +3394,32 @@ done:
return !res; return !res;
} }
/***********************************************************************
* post_dde_message_call
*/
static NTSTATUS post_dde_message_call( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
const struct post_dde_message_call_params *params )
{
NTSTATUS status;
SERVER_START_REQ( send_message )
{
req->id = params->dest_tid;
req->type = MSG_POSTED;
req->flags = 0;
req->win = wine_server_user_handle( hwnd );
req->msg = msg;
req->wparam = wparam;
req->lparam = lparam;
req->timeout = TIMEOUT_INFINITE;
wine_server_add_data( req, params->ptr, params->size );
status = wine_server_call( req );
}
SERVER_END_REQ;
return status;
}
/*********************************************************************** /***********************************************************************
* wait_message_reply * wait_message_reply
* *
@ -4447,6 +4471,9 @@ LRESULT WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
case NtUserDragDropCall: case NtUserDragDropCall:
return drag_drop_call( hwnd, msg, wparam, lparam, result_info ); return drag_drop_call( hwnd, msg, wparam, lparam, result_info );
case NtUserPostDdeCall:
return post_dde_message_call( hwnd, msg, wparam, lparam, result_info );
default: default:
FIXME( "%p %x %lx %lx %p %x %x\n", hwnd, msg, (long)wparam, lparam, result_info, (int)type, ansi ); FIXME( "%p %x %lx %lx %p %x %x\n", hwnd, msg, (long)wparam, lparam, result_info, (int)type, ansi );
} }

View file

@ -1395,7 +1395,6 @@ static NTSTATUS WINAPI wow64_NtUserPostDDEMessage( void *arg, ULONG size )
LONG wparam; LONG wparam;
LONG lparam; LONG lparam;
DWORD dest_tid; DWORD dest_tid;
DWORD type;
} params32; } params32;
params32.hwnd = HandleToUlong( params->hwnd ); params32.hwnd = HandleToUlong( params->hwnd );
@ -1403,7 +1402,6 @@ static NTSTATUS WINAPI wow64_NtUserPostDDEMessage( void *arg, ULONG size )
params32.wparam = params->wparam; params32.wparam = params->wparam;
params32.lparam = params->lparam; params32.lparam = params->lparam;
params32.dest_tid = params->dest_tid; params32.dest_tid = params->dest_tid;
params32.type = params->type;
return dispatch_callback( NtUserPostDDEMessage, &params32, sizeof(params32) ); return dispatch_callback( NtUserPostDDEMessage, &params32, sizeof(params32) );
} }
@ -3676,6 +3674,22 @@ NTSTATUS WINAPI wow64_NtUserMessageCall( UINT *args )
return status; return status;
} }
return NtUserMessageCall( hwnd, msg, wparam, lparam, result_info, type, ansi ); return NtUserMessageCall( hwnd, msg, wparam, lparam, result_info, type, ansi );
case NtUserPostDdeCall:
{
struct
{
ULONG ptr;
UINT size;
DWORD dest_tid;
} *params32 = result_info;
struct post_dde_message_call_params params;
params.ptr = UlongToPtr(params32->ptr);
params.size = params32->size;
params.dest_tid = params32->dest_tid;
return NtUserMessageCall( hwnd, msg, wparam, lparam, &params, type, ansi );
}
} }
return message_call_32to64( hwnd, msg, wparam, lparam, result_info, type, ansi ); return message_call_32to64( hwnd, msg, wparam, lparam, result_info, type, ansi );

View file

@ -279,7 +279,6 @@ struct post_dde_message_params
WPARAM wparam; WPARAM wparam;
LPARAM lparam; LPARAM lparam;
DWORD dest_tid; DWORD dest_tid;
DWORD type;
}; };
/* NtUserRenderSynthesizedFormat params */ /* NtUserRenderSynthesizedFormat params */
@ -398,6 +397,7 @@ enum
NtUserImeDriverCall = 0x0305, NtUserImeDriverCall = 0x0305,
NtUserSystemTrayCall = 0x0306, NtUserSystemTrayCall = 0x0306,
NtUserDragDropCall = 0x0307, NtUserDragDropCall = 0x0307,
NtUserPostDdeCall = 0x0308,
}; };
/* NtUserThunkedMenuItemInfo codes */ /* NtUserThunkedMenuItemInfo codes */
@ -428,6 +428,13 @@ struct send_message_callback_params
ULONG_PTR data; ULONG_PTR data;
}; };
struct post_dde_message_call_params
{
void *ptr;
UINT size;
DWORD dest_tid;
};
/* color index used to retrieve system 55aa brush */ /* color index used to retrieve system 55aa brush */
#define COLOR_55AA_BRUSH 0x100 #define COLOR_55AA_BRUSH 0x100