win32u: Use syscall interface for NtUserMessageCall and NtUserTrackPopupMenuEx.

try_finally() hack is no longer needed. We don't expect exceptions
from unixlib code and client callbacks' exceptions are not propagated
anyway.
This commit is contained in:
Jacek Caban 2022-07-09 17:29:57 +02:00 committed by Alexandre Julliard
parent b3fddeb8e4
commit e52e42b875
8 changed files with 33 additions and 63 deletions

View file

@ -1198,7 +1198,6 @@ static struct unix_funcs unix_funcs =
NtUserInvalidateRgn,
NtUserIsClipboardFormatAvailable,
NtUserMapVirtualKeyEx,
NtUserMessageCall,
NtUserMoveWindow,
NtUserOpenClipboard,
NtUserPeekMessage,
@ -1245,7 +1244,6 @@ static struct unix_funcs unix_funcs =
NtUserSystemParametersInfoForDpi,
NtUserToUnicodeEx,
NtUserTrackMouseEvent,
NtUserTrackPopupMenuEx,
NtUserTranslateAccelerator,
NtUserTranslateMessage,
NtUserUnregisterClass,

View file

@ -4053,14 +4053,7 @@ static UINT find_item_by_key( HWND owner, HMENU hmenu, WCHAR key, BOOL force_men
return -1;
}
static BOOL seh_release_capture;
static void CALLBACK finally_release_capture( BOOL __normal )
{
if (seh_release_capture) set_capture_window( 0, GUI_INMENUMODE, NULL );
}
static BOOL track_menu_impl( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, const RECT *rect )
static BOOL track_menu( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, const RECT *rect )
{
BOOL enter_idle_sent = FALSE;
int executed_menu_id = -1;
@ -4103,8 +4096,6 @@ static BOOL track_menu_impl( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, c
if ((flags & TPM_POPUPMENU) && menu->nItems == 0)
return FALSE;
seh_release_capture = TRUE;
while (!exit_menu)
{
if (!(menu = unsafe_menu_ptr( mt.hCurrentMenu ))) break;
@ -4308,7 +4299,6 @@ static BOOL track_menu_impl( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, c
else mt.trackFlags &= ~TF_SKIPREMOVE;
}
seh_release_capture = FALSE;
set_capture_window( 0, GUI_INMENUMODE, NULL );
/* If dropdown is still painted and the close box is clicked on
@ -4344,36 +4334,6 @@ static BOOL track_menu_impl( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, c
return executed_menu_id;
}
/* FIXME: this is an ugly hack to work around unixlib exceptions limitations.
* For this to work properly we need recursive exception handlers capable of
* catching exceptions from client callbacks. We probably need to actually
* run on Unix stack first, so we need a hack for now. */
struct track_menu_params
{
HMENU handle;
UINT flags;
int x;
int y;
HWND hwnd;
const RECT *rect;
};
static NTSTATUS CDECL track_menu_proc( void *arg )
{
struct track_menu_params *params = arg;
return track_menu_impl( params->handle, params->flags, params->x, params->y,
params->hwnd, params->rect );
}
static BOOL track_menu( HMENU handle, UINT flags, int x, int y, HWND hwnd, const RECT *rect )
{
struct track_menu_params params =
{ .handle = handle, .flags = flags, .x = x, .y = y, .hwnd = hwnd, .rect = rect };
if (!user_callbacks)
return track_menu_impl( handle, flags, x, y, hwnd, rect );
return user_callbacks->try_finally( track_menu_proc, &params, finally_release_capture );
}
static BOOL init_tracking( HWND hwnd, HMENU handle, BOOL is_popup, UINT flags )
{
struct menu *menu;

View file

@ -163,6 +163,7 @@ static void * const syscalls[] =
NtUserKillTimer,
NtUserLockWindowUpdate,
NtUserMenuItemFromPoint,
NtUserMessageCall,
NtUserMsgWaitForMultipleObjectsEx,
NtUserNotifyWinEvent,
NtUserOpenDesktop,
@ -187,6 +188,7 @@ static void * const syscalls[] =
NtUserSetWindowsHookEx,
NtUserThunkedMenuInfo,
NtUserThunkedMenuItemInfo,
NtUserTrackPopupMenuEx,
NtUserUnhookWinEvent,
NtUserUnhookWindowsHookEx,
NtUserUpdateInputContext,

View file

@ -1079,7 +1079,7 @@
@ stdcall NtUserMapVirtualKeyEx(long long long)
@ stub NtUserMarkWindowForRawMouse
@ stdcall -syscall NtUserMenuItemFromPoint(long long long long)
@ stdcall NtUserMessageCall(long long long long long long long)
@ stdcall -syscall NtUserMessageCall(long long long long long long long)
@ stub NtUserMinInitialize
@ stub NtUserMinMaximize
@ stub NtUserModifyUserStartupInfoFlags
@ -1278,7 +1278,7 @@
@ stdcall -syscall NtUserThunkedMenuItemInfo(long long long long ptr ptr)
@ stdcall NtUserToUnicodeEx(long long ptr ptr long long long)
@ stdcall NtUserTrackMouseEvent(ptr)
@ stdcall NtUserTrackPopupMenuEx(long long long long long ptr)
@ stdcall -syscall NtUserTrackPopupMenuEx(long long long long long ptr)
@ stub NtUserTransformPoint
@ stub NtUserTransformRect
@ stdcall NtUserTranslateAccelerator(long long ptr)

View file

@ -262,8 +262,6 @@ struct unix_funcs
BOOL (WINAPI *pNtUserInvalidateRgn)( HWND hwnd, HRGN hrgn, BOOL erase );
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,
void *result_info, DWORD type, BOOL ansi );
BOOL (WINAPI *pNtUserMoveWindow)( HWND hwnd, INT x, INT y, INT cx, INT cy, BOOL repaint );
BOOL (WINAPI *pNtUserOpenClipboard)( HWND hwnd, ULONG unk );
BOOL (WINAPI *pNtUserPeekMessage)( MSG *msg_out, HWND hwnd, UINT first, UINT last, UINT flags );
@ -320,8 +318,6 @@ struct unix_funcs
INT (WINAPI *pNtUserToUnicodeEx)( UINT virt, UINT scan, const BYTE *state,
WCHAR *str, int size, UINT flags, HKL layout );
BOOL (WINAPI *pNtUserTrackMouseEvent)( TRACKMOUSEEVENT *info );
BOOL (WINAPI *pNtUserTrackPopupMenuEx)( HMENU handle, UINT flags, INT x, INT y, HWND hwnd,
TPMPARAMS *params );
INT (WINAPI *pNtUserTranslateAccelerator)( HWND hwnd, HACCEL accel, MSG *msg );
BOOL (WINAPI *pNtUserTranslateMessage)( const MSG *msg, UINT flags );
BOOL (WINAPI *pNtUserUnregisterClass)( UNICODE_STRING *name, HINSTANCE instance,

View file

@ -1103,13 +1103,6 @@ UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout )
return unix_funcs->pNtUserMapVirtualKeyEx( code, type, layout );
}
LRESULT WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
void *result_info, DWORD type, BOOL ansi )
{
if (!unix_funcs) return 0;
return unix_funcs->pNtUserMessageCall( hwnd, msg, wparam, lparam, result_info, type, ansi );
}
BOOL WINAPI NtUserOpenClipboard( HWND hwnd, ULONG unk )
{
if (!unix_funcs) return FALSE;
@ -1388,13 +1381,6 @@ BOOL WINAPI NtUserTrackMouseEvent( TRACKMOUSEEVENT *info )
return unix_funcs->pNtUserTrackMouseEvent( info );
}
BOOL WINAPI NtUserTrackPopupMenuEx( HMENU handle, UINT flags, INT x, INT y, HWND hwnd,
TPMPARAMS *params )
{
if (!unix_funcs) return FALSE;
return unix_funcs->pNtUserTrackPopupMenuEx( handle, flags, x, y, hwnd, params );
}
INT WINAPI NtUserTranslateAccelerator( HWND hwnd, HACCEL accel, MSG *msg )
{
if (!unix_funcs) return 0;

View file

@ -150,6 +150,7 @@
SYSCALL_ENTRY( NtUserKillTimer ) \
SYSCALL_ENTRY( NtUserLockWindowUpdate ) \
SYSCALL_ENTRY( NtUserMenuItemFromPoint ) \
SYSCALL_ENTRY( NtUserMessageCall ) \
SYSCALL_ENTRY( NtUserMsgWaitForMultipleObjectsEx ) \
SYSCALL_ENTRY( NtUserNotifyWinEvent ) \
SYSCALL_ENTRY( NtUserOpenDesktop ) \
@ -174,6 +175,7 @@
SYSCALL_ENTRY( NtUserSetWindowsHookEx ) \
SYSCALL_ENTRY( NtUserThunkedMenuInfo ) \
SYSCALL_ENTRY( NtUserThunkedMenuItemInfo ) \
SYSCALL_ENTRY( NtUserTrackPopupMenuEx ) \
SYSCALL_ENTRY( NtUserUnhookWinEvent ) \
SYSCALL_ENTRY( NtUserUnhookWindowsHookEx ) \
SYSCALL_ENTRY( NtUserUpdateInputContext ) \

View file

@ -836,6 +836,20 @@ NTSTATUS WINAPI wow64_NtUserMenuItemFromPoint( UINT *args )
return NtUserMenuItemFromPoint( hwnd, handle, x, y );
}
NTSTATUS WINAPI wow64_NtUserMessageCall( UINT *args )
{
HWND hwnd = get_handle( &args );
UINT msg = get_ulong( &args );
UINT wparam = get_ulong( &args );
UINT lparam = get_ulong( &args );
void *result_info = get_ptr( &args );
UINT type = get_ulong ( &args );
BOOL ansi = get_ulong( &args );
FIXME( "%p %x %x %x %p %x %x\n", hwnd, msg, wparam, lparam, result_info, type, ansi );
return 0;
}
NTSTATUS WINAPI wow64_NtUserMsgWaitForMultipleObjectsEx( UINT *args )
{
DWORD count = get_ulong( &args );
@ -1151,6 +1165,18 @@ NTSTATUS WINAPI wow64_NtUserThunkedMenuItemInfo( UINT *args )
unicode_str_32to64( &str, str32 ));
}
NTSTATUS WINAPI wow64_NtUserTrackPopupMenuEx( UINT *args )
{
HMENU handle = get_handle( &args );
UINT flags = get_ulong( &args );
int x = get_ulong( &args );
int y = get_ulong( &args );
HWND hwnd = get_handle( &args );
TPMPARAMS *params = get_ptr( &args );
return NtUserTrackPopupMenuEx( handle, flags, x, y, hwnd, params );
}
NTSTATUS WINAPI wow64_NtUserUnhookWinEvent( UINT *args )
{
HWINEVENTHOOK handle = get_handle( &args );