From 95bab1b1065d9cc562356869e4d8c4e3c716b5d0 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 19 Nov 2024 15:49:06 +0100 Subject: [PATCH] user32: Move support for posting a DDE message to win32u. --- dlls/user32/message.c | 44 ++++++++++++++------------------------ dlls/user32/user_main.c | 2 +- dlls/user32/user_private.h | 3 +-- dlls/win32u/message.c | 31 +++++++++++++++++++++++++-- dlls/wow64win/user.c | 18 ++++++++++++++-- include/ntuser.h | 9 +++++++- 6 files changed, 71 insertions(+), 36 deletions(-) diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 7374b22d7b4..5d6cbfb0a03 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -333,10 +333,9 @@ static HGLOBAL dde_get_pair(HGLOBAL shm) * * 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; - int size = 0; + struct post_dde_message_call_params params = { .dest_tid = dest_tid }; UINT_PTR uiLo, uiHi; LPARAM lp; HGLOBAL hunlock = 0; @@ -364,8 +363,8 @@ NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DW { hpack = pack_ptr( h ); /* send back the value of h on the other side */ - ptr = &hpack; - size = sizeof(hpack); + params.ptr = &hpack; + params.size = sizeof(hpack); lp = uiLo; 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: if (uiLo) { - size = GlobalSize( (HGLOBAL)uiLo ) ; - if ((msg == WM_DDE_ADVISE && size < sizeof(DDEADVISE)) || - (msg == WM_DDE_DATA && size < FIELD_OFFSET(DDEDATA, Value)) || - (msg == WM_DDE_POKE && size < FIELD_OFFSET(DDEPOKE, Value))) + params.size = GlobalSize( (HGLOBAL)uiLo ) ; + if ((msg == WM_DDE_ADVISE && params.size < sizeof(DDEADVISE)) || + (msg == WM_DDE_DATA && params.size < FIELD_OFFSET(DDEDATA, Value)) || + (msg == WM_DDE_POKE && params.size < FIELD_OFFSET(DDEPOKE, Value))) 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; 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", dde_data->unused, dde_data->fResponse, dde_data->fRelease, dde_data->reserved, dde_data->fAckReq, dde_data->cfFormat); hunlock = (HGLOBAL)uiLo; } } - TRACE( "send ddepack %u %Ix\n", size, uiHi ); + TRACE( "send ddepack %u %Ix\n", params.size, uiHi ); break; case WM_DDE_EXECUTE: 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 */ lp = lparam; hunlock = (HGLOBAL)lparam; @@ -417,20 +416,9 @@ NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DW } break; } - SERVER_START_REQ( send_message ) - { - req->id = dest_tid; - 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; + + res = NtUserMessageCall( hwnd, msg, wparam, lp, ¶ms, NtUserPostDdeCall, FALSE ); + if (!res) FreeDDElParam( msg, lparam ); if (hunlock) GlobalUnlock(hunlock); return res; diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index ea869485c0a..7c76459a0ad 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -126,7 +126,7 @@ static NTSTATUS WINAPI User32PostDDEMessage( void *args, ULONG size ) { const struct post_dde_message_params *params = args; 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 ) diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 5d94c411450..f8b08bcdb13 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -46,8 +46,7 @@ struct wm_char_mapping_data extern HMODULE user32_module; -extern NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, - DWORD type ); +extern NTSTATUS post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid ); extern BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, const void *buffer, size_t size ); extern void free_cached_data( UINT format, HANDLE handle ); diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 43650146f8e..f66a769258c 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -34,7 +34,6 @@ #include "dbt.h" #include "dde.h" #include "immdev.h" -#include "wine/server.h" #include "wine/debug.h" 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.lparam = info->lparam; params.dest_tid = info->dest_tid; - params.type = info->type; res = KeUserModeCallback( NtUserPostDDEMessage, ¶ms, sizeof(params), &ret_ptr, &ret_len ); goto done; } @@ -3396,6 +3394,32 @@ done: 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 * @@ -4447,6 +4471,9 @@ LRESULT WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa case NtUserDragDropCall: return drag_drop_call( hwnd, msg, wparam, lparam, result_info ); + case NtUserPostDdeCall: + return post_dde_message_call( hwnd, msg, wparam, lparam, result_info ); + default: FIXME( "%p %x %lx %lx %p %x %x\n", hwnd, msg, (long)wparam, lparam, result_info, (int)type, ansi ); } diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 1479e76ba00..3932fda5bbf 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1395,7 +1395,6 @@ static NTSTATUS WINAPI wow64_NtUserPostDDEMessage( void *arg, ULONG size ) LONG wparam; LONG lparam; DWORD dest_tid; - DWORD type; } params32; params32.hwnd = HandleToUlong( params->hwnd ); @@ -1403,7 +1402,6 @@ static NTSTATUS WINAPI wow64_NtUserPostDDEMessage( void *arg, ULONG size ) params32.wparam = params->wparam; params32.lparam = params->lparam; params32.dest_tid = params->dest_tid; - params32.type = params->type; return dispatch_callback( NtUserPostDDEMessage, ¶ms32, sizeof(params32) ); } @@ -3676,6 +3674,22 @@ NTSTATUS WINAPI wow64_NtUserMessageCall( UINT *args ) return status; } 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, ¶ms, type, ansi ); + } } return message_call_32to64( hwnd, msg, wparam, lparam, result_info, type, ansi ); diff --git a/include/ntuser.h b/include/ntuser.h index 384729f8157..6aca0fee7ea 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -279,7 +279,6 @@ struct post_dde_message_params WPARAM wparam; LPARAM lparam; DWORD dest_tid; - DWORD type; }; /* NtUserRenderSynthesizedFormat params */ @@ -398,6 +397,7 @@ enum NtUserImeDriverCall = 0x0305, NtUserSystemTrayCall = 0x0306, NtUserDragDropCall = 0x0307, + NtUserPostDdeCall = 0x0308, }; /* NtUserThunkedMenuItemInfo codes */ @@ -428,6 +428,13 @@ struct send_message_callback_params ULONG_PTR data; }; +struct post_dde_message_call_params +{ + void *ptr; + UINT size; + DWORD dest_tid; +}; + /* color index used to retrieve system 55aa brush */ #define COLOR_55AA_BRUSH 0x100