[PATCH 0/7] MR6344: user32: Introduce a generic KeUserDispatchCallback kernel callback.
First part of a series that supersedes https://gitlab.winehq.org/wine/wine/-/merge_requests/1180, based on patches from Torge Matthies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/user.exe16/message.c | 4 ++-- dlls/win32u/cursoricon.c | 14 +++++++------- dlls/win32u/sysparams.c | 2 +- dlls/win32u/win32u_private.h | 2 +- include/ntuser.h | 8 +++++++- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index f88752f832d..227a8c114b0 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -2585,8 +2585,8 @@ HWND create_window16( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE instance, static NTSTATUS WINAPI User16CallFreeIcon( void *args, ULONG size ) { - ULONG *param = args; - GlobalFree16( LOWORD(*param) ); + const struct free_icon_params *params = args; + GlobalFree16( LOWORD(params->param) ); return STATUS_SUCCESS; } diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c index 661ef34c2e0..5f94fb3342e 100644 --- a/dlls/win32u/cursoricon.c +++ b/dlls/win32u/cursoricon.c @@ -41,7 +41,7 @@ struct cursoricon_object { struct user_object obj; /* object header */ struct list entry; /* entry in shared icons list */ - ULONG_PTR param; /* opaque param used by 16-bit code */ + struct free_icon_params params; /* opaque params used by 16-bit code */ UNICODE_STRING module; /* module for icons loaded from resources */ WCHAR *resname; /* resource name for icons loaded from resources */ HRSRC rsrc; /* resource for shared icons */ @@ -179,7 +179,7 @@ static BOOL free_icon_handle( HICON handle ) if (obj == OBJ_OTHER_PROCESS) WARN( "icon handle %p from other process\n", handle ); else if (obj) { - ULONG param = obj->param; + struct free_icon_params params = obj->params; void *ret_ptr; ULONG ret_len; UINT i; @@ -213,7 +213,7 @@ static BOOL free_icon_handle( HICON handle ) } if (!IS_INTRESOURCE( obj->resname )) free( obj->resname ); free( obj ); - if (param) KeUserModeCallback( NtUserCallFreeIcon, ¶m, sizeof(param), &ret_ptr, &ret_len ); + if (params.param) KeUserModeCallback( NtUserCallFreeIcon, ¶ms, sizeof(params), &ret_ptr, &ret_len ); user_driver->pDestroyCursorIcon( handle ); return TRUE; } @@ -685,13 +685,13 @@ ULONG_PTR get_icon_param( HICON handle ) if (obj == OBJ_OTHER_PROCESS) WARN( "icon handle %p from other process\n", handle ); else if (obj) { - ret = obj->param; + ret = obj->params.param; release_user_handle_ptr( obj ); } return ret; } -ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param ) +ULONG_PTR set_icon_param( HICON handle, const struct free_icon_params *params ) { ULONG_PTR ret = 0; struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON ); @@ -699,8 +699,8 @@ ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param ) if (obj == OBJ_OTHER_PROCESS) WARN( "icon handle %p from other process\n", handle ); else if (obj) { - ret = obj->param; - obj->param = param; + ret = obj->params.param; + obj->params = *params; release_user_handle_ptr( obj ); } return ret; diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 5a1b2e12e40..3cb9c7758cb 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -6563,7 +6563,7 @@ ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code return set_caret_pos( arg1, arg2 ); case NtUserCallTwoParam_SetIconParam: - return set_icon_param( UlongToHandle(arg1), arg2 ); + return set_icon_param( UlongToHandle(arg1), UlongToHandle(arg2) ); case NtUserCallTwoParam_SetIMECompositionWindowPos: return set_ime_composition_window_pos( UlongToHandle(arg1), (const POINT *)arg2 ); diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 28801dfd30f..8a84c16208d 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -41,7 +41,7 @@ extern void release_clipboard_owner( HWND hwnd ); extern BOOL process_wine_setcursor( HWND hwnd, HWND window, HCURSOR handle ); extern HICON alloc_cursoricon_handle( BOOL is_icon ); extern ULONG_PTR get_icon_param( HICON handle ); -extern ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param ); +extern ULONG_PTR set_icon_param( HICON handle, const struct free_icon_params *params ); /* dce.c */ extern struct window_surface dummy_surface; diff --git a/include/ntuser.h b/include/ntuser.h index adeb56afe79..b132a1027b5 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1094,9 +1094,15 @@ static inline BOOL NtUserSetCaretPos( int x, int y ) return NtUserCallTwoParam( x, y, NtUserCallTwoParam_SetCaretPos ); } +struct free_icon_params +{ + UINT64 param; +}; + static inline UINT_PTR NtUserSetIconParam( HICON icon, ULONG_PTR param ) { - return NtUserCallTwoParam( HandleToUlong(icon), param, NtUserCallTwoParam_SetIconParam ); + struct free_icon_params params = {.param = param}; + return NtUserCallTwoParam( HandleToUlong(icon), (UINT_PTR)¶ms, NtUserCallTwoParam_SetIconParam ); } static inline BOOL NtUserUnhookWindowsHook( INT id, HOOKPROC proc ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/user.exe16/message.c | 14 +++++--------- dlls/win32u/message.c | 13 +++++++++---- include/ntuser.h | 6 ++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index 227a8c114b0..0334aba28e4 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -2593,15 +2593,11 @@ static NTSTATUS WINAPI User16CallFreeIcon( void *args, ULONG size ) static NTSTATUS WINAPI User16ThunkLock( void *args, ULONG size ) { - DWORD *param = args; - if (size != sizeof(DWORD)) - { - DWORD lock; - ReleaseThunkLock( &lock ); - return NtCallbackReturn( &lock, sizeof(lock), STATUS_SUCCESS ); - } - RestoreThunkLock( *param ); - return STATUS_SUCCESS; + const struct thunk_lock_params *params = args; + DWORD locks = params->locks; + if (params->restore) RestoreThunkLock( locks ); + else ReleaseThunkLock( &locks ); + return NtCallbackReturn( &locks, sizeof(locks), STATUS_SUCCESS ); } diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 73c15defb04..faed9182d4f 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -3049,15 +3049,20 @@ static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout /* wait for message or signaled handle */ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags ) { + struct thunk_lock_params params = {0}; LARGE_INTEGER time; - DWORD ret, lock = 0; + DWORD ret; void *ret_ptr; ULONG ret_len; if (enable_thunk_lock) { - if (!KeUserModeCallback( NtUserThunkLock, NULL, 0, &ret_ptr, &ret_len ) && ret_len == sizeof(lock)) - lock = *(DWORD *)ret_ptr; + if (!KeUserModeCallback( NtUserThunkLock, ¶ms, sizeof(params), &ret_ptr, &ret_len ) && + ret_len == sizeof(params.locks)) + { + params.locks = *(DWORD *)ret_ptr; + params.restore = TRUE; + } } if (user_driver->pProcessEvents( mask )) ret = count - 1; @@ -3077,7 +3082,7 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW if (ret == count - 1) get_user_thread_info()->last_driver_time = NtGetTickCount(); if (enable_thunk_lock) - KeUserModeCallback( NtUserThunkLock, &lock, sizeof(lock), &ret_ptr, &ret_len ); + KeUserModeCallback( NtUserThunkLock, ¶ms, sizeof(params), &ret_ptr, &ret_len ); return ret; } diff --git a/include/ntuser.h b/include/ntuser.h index b132a1027b5..6a6c344e484 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -937,6 +937,12 @@ static inline WORD NtUserEnableDC( HDC hdc ) return NtUserCallOneParam( HandleToUlong(hdc), NtUserCallOneParam_EnableDC ); } +struct thunk_lock_params +{ + BOOL restore; + DWORD locks; +}; + static inline void NtUserEnableThunkLock( BOOL enable ) { NtUserCallOneParam( enable, NtUserCallOneParam_EnableThunkLock ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Rémi Bernon <rbernon(a)codeweavers.com> And use it for User16CallFreeIcon. Based on a patch from Torge Matthies. --- dlls/user.exe16/message.c | 9 --------- dlls/user.exe16/user.c | 13 +++++++++++-- dlls/user32/user_main.c | 8 ++++++++ dlls/win32u/cursoricon.c | 2 +- dlls/wow64win/user.c | 8 ++++---- dlls/wow64win/wow64win_private.h | 4 ++-- include/ntuser.h | 23 ++++++++++++++++++++--- include/wine/unixlib.h | 1 - 8 files changed, 46 insertions(+), 22 deletions(-) diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index 0334aba28e4..fb4950c6121 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -2583,14 +2583,6 @@ HWND create_window16( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE instance, } -static NTSTATUS WINAPI User16CallFreeIcon( void *args, ULONG size ) -{ - const struct free_icon_params *params = args; - GlobalFree16( LOWORD(params->param) ); - return STATUS_SUCCESS; -} - - static NTSTATUS WINAPI User16ThunkLock( void *args, ULONG size ) { const struct thunk_lock_params *params = args; @@ -2618,7 +2610,6 @@ void register_wow_handlers(void) call_dialog_proc_Ato16, }; - callback_table[NtUserCallFreeIcon] = User16CallFreeIcon; callback_table[NtUserThunkLock] = User16ThunkLock; NtUserEnableThunkLock( TRUE ); diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c index ef3ccc8a9da..799e4e35411 100644 --- a/dlls/user.exe16/user.c +++ b/dlls/user.exe16/user.c @@ -26,6 +26,8 @@ #define OEMRESOURCE +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "wine/winuser16.h" #include "windef.h" #include "winbase.h" @@ -287,6 +289,13 @@ static void release_icon_ptr( HICON16 handle, CURSORICONINFO *ptr ) GlobalUnlock16( handle ); } +static NTSTATUS WINAPI free_icon_callback( void *args, ULONG size ) +{ + const struct free_icon_params *params = args; + GlobalFree16( LOWORD(params->param) ); + return STATUS_SUCCESS; +} + static HICON store_icon_32( HICON16 icon16, HICON icon ) { HICON ret = 0; @@ -300,7 +309,7 @@ static HICON store_icon_32( HICON16 icon16, HICON icon ) { memcpy( &ret, (char *)(ptr + 1) + and_size + xor_size, sizeof(ret) ); memcpy( (char *)(ptr + 1) + and_size + xor_size, &icon, sizeof(icon) ); - NtUserSetIconParam( icon, icon16 ); + NtUserSetIconParam( icon, icon16, free_icon_callback ); } release_icon_ptr( icon16, ptr ); } @@ -342,7 +351,7 @@ HICON get_icon_32( HICON16 icon16 ) DeleteObject( iinfo.hbmMask ); DeleteObject( iinfo.hbmColor ); memcpy( (char *)(ptr + 1) + xor_size + and_size, &ret, sizeof(ret) ); - NtUserSetIconParam( ret, icon16 ); + NtUserSetIconParam( ret, icon16, free_icon_callback ); } } release_icon_ptr( icon16, ptr ); diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index ee4dbc190cd..03b88c07bed 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -215,8 +215,16 @@ static NTSTATUS WINAPI User32UnpackDDEMessage( void *args, ULONG size ) return NtCallbackReturn( &result, sizeof(result), STATUS_SUCCESS ); } +static NTSTATUS WINAPI User32CallDispatchCallback( void *args, ULONG size ) +{ + struct dispatch_callback_params *params = args; + ntuser_callback callback = (void *)(UINT_PTR)params->callback; + return callback( params, size ); +} + static KERNEL_CALLBACK_PROC kernel_callback_table[NtUserCallCount] = { + User32CallDispatchCallback, User32CallEnumDisplayMonitor, User32CallSendAsyncCallback, User32CallWinEventHook, diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c index 5f94fb3342e..fedd122eeed 100644 --- a/dlls/win32u/cursoricon.c +++ b/dlls/win32u/cursoricon.c @@ -213,7 +213,7 @@ static BOOL free_icon_handle( HICON handle ) } if (!IS_INTRESOURCE( obj->resname )) free( obj->resname ); free( obj ); - if (params.param) KeUserModeCallback( NtUserCallFreeIcon, ¶ms, sizeof(params), &ret_ptr, &ret_len ); + KeUserDispatchCallback( ¶ms.dispatch, sizeof(params), &ret_ptr, &ret_len ); user_driver->pDestroyCursorIcon( handle ); return TRUE; } diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index db0fed3d97d..f60db58e181 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1445,9 +1445,9 @@ static NTSTATUS WINAPI wow64_NtUserUnpackDDEMessage( void *arg, ULONG size ) return status; } -static NTSTATUS WINAPI wow64_NtUserCallFreeIcon( void *arg, ULONG size ) +static NTSTATUS WINAPI wow64_NtUserCallDispatchCallback( void *arg, ULONG size ) { - return dispatch_callback( NtUserCallFreeIcon, arg, size ); + return dispatch_callback( NtUserCallDispatchCallback, arg, size ); } static NTSTATUS WINAPI wow64_NtUserThunkLock( void *arg, ULONG size ) @@ -1520,9 +1520,10 @@ static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst9( void *arg, ULONG size ) return dispatch_callback( NtUserDriverCallbackFirst + 9, arg, size ); } -user_callback user_callbacks[] = +ntuser_callback user_callbacks[] = { /* user32 callbacks */ + wow64_NtUserCallDispatchCallback, wow64_NtUserCallEnumDisplayMonitor, wow64_NtUserCallSendAsyncCallback, wow64_NtUserCallWinEventHook, @@ -1543,7 +1544,6 @@ user_callback user_callbacks[] = wow64_NtUserRenderSynthesizedFormat, wow64_NtUserUnpackDDEMessage, /* win16 hooks */ - wow64_NtUserCallFreeIcon, wow64_NtUserThunkLock, /* Vulkan support */ wow64_NtUserCallVulkanDebugReportCallback, diff --git a/dlls/wow64win/wow64win_private.h b/dlls/wow64win/wow64win_private.h index a4fa1ad2a06..956e38636a9 100644 --- a/dlls/wow64win/wow64win_private.h +++ b/dlls/wow64win/wow64win_private.h @@ -22,13 +22,13 @@ #define __WOW64WIN_PRIVATE_H #include "../win32u/win32syscalls.h" +#include "ntuser.h" #define SYSCALL_ENTRY(id,name,_args) extern NTSTATUS WINAPI wow64_ ## name( UINT *args ); ALL_SYSCALLS32 #undef SYSCALL_ENTRY -typedef NTSTATUS (WINAPI *user_callback)( void *params, ULONG size ); -extern user_callback user_callbacks[]; +extern ntuser_callback user_callbacks[]; struct object_attr64 { diff --git a/include/ntuser.h b/include/ntuser.h index 6a6c344e484..da7c2e53594 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -34,10 +34,14 @@ # endif #endif +typedef NTSTATUS (WINAPI *ntuser_callback)( void *args, ULONG len ); +NTSYSAPI NTSTATUS KeUserModeCallback( ULONG id, const void *args, ULONG len, void **ret_ptr, ULONG *ret_len ); + /* KernelCallbackTable codes, not compatible with Windows */ enum { /* user32 callbacks */ + NtUserCallDispatchCallback, NtUserCallEnumDisplayMonitor, NtUserCallSendAsyncCallback, NtUserCallWinEventHook, @@ -58,7 +62,6 @@ enum NtUserRenderSynthesizedFormat, NtUserUnpackDDEMessage, /* win16 hooks */ - NtUserCallFreeIcon, NtUserThunkLock, /* Vulkan support */ NtUserCallVulkanDebugReportCallback, @@ -71,6 +74,19 @@ enum NtUserCallCount }; +/* NtUserCallDispatchCallback params */ +struct dispatch_callback_params +{ + UINT64 callback; +}; + +static inline NTSTATUS KeUserDispatchCallback( const struct dispatch_callback_params *params, ULONG len, + void **ret_ptr, ULONG *ret_len ) +{ + if (!params->callback) return STATUS_ENTRYPOINT_NOT_FOUND; + return KeUserModeCallback( NtUserCallDispatchCallback, params, len, ret_ptr, ret_len ); +} + /* TEB thread info, not compatible with Windows */ struct ntuser_thread_info { @@ -1102,12 +1118,13 @@ static inline BOOL NtUserSetCaretPos( int x, int y ) struct free_icon_params { + struct dispatch_callback_params dispatch; UINT64 param; }; -static inline UINT_PTR NtUserSetIconParam( HICON icon, ULONG_PTR param ) +static inline UINT_PTR NtUserSetIconParam( HICON icon, ULONG_PTR param, ntuser_callback callback ) { - struct free_icon_params params = {.param = param}; + struct free_icon_params params = {.dispatch = {.callback = (UINT_PTR)callback}, .param = param}; return NtUserCallTwoParam( HandleToUlong(icon), (UINT_PTR)¶ms, NtUserCallTwoParam_SetIconParam ); } diff --git a/include/wine/unixlib.h b/include/wine/unixlib.h index 9a342fada73..7d8b6c59ab5 100644 --- a/include/wine/unixlib.h +++ b/include/wine/unixlib.h @@ -72,7 +72,6 @@ NTSYSAPI void ntdll_set_exception_jmp_buf( jmp_buf jmp ); NTSYSAPI BOOLEAN KeAddSystemServiceTable( ULONG_PTR *funcs, ULONG_PTR *counters, ULONG limit, BYTE *arguments, ULONG index ); -NTSYSAPI NTSTATUS KeUserModeCallback( ULONG id, const void *args, ULONG len, void **ret_ptr, ULONG *ret_len ); /* wide char string functions */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Rémi Bernon <rbernon(a)codeweavers.com> Based on a patch from Torge Matthies. --- dlls/user.exe16/message.c | 7 ++----- dlls/win32u/message.c | 14 +++++--------- dlls/win32u/sysparams.c | 4 ++-- dlls/win32u/win32u_private.h | 2 +- dlls/wow64win/user.c | 7 ------- include/ntuser.h | 7 +++---- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index fb4950c6121..ab973c4ae7a 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -2583,7 +2583,7 @@ HWND create_window16( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE instance, } -static NTSTATUS WINAPI User16ThunkLock( void *args, ULONG size ) +static NTSTATUS WINAPI thunk_lock_callback( void *args, ULONG size ) { const struct thunk_lock_params *params = args; DWORD locks = params->locks; @@ -2595,7 +2595,6 @@ static NTSTATUS WINAPI User16ThunkLock( void *args, ULONG size ) void register_wow_handlers(void) { - KERNEL_CALLBACK_PROC *callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; static const struct wow_handlers16 handlers16 = { button_proc16, @@ -2610,9 +2609,7 @@ void register_wow_handlers(void) call_dialog_proc_Ato16, }; - callback_table[NtUserThunkLock] = User16ThunkLock; - - NtUserEnableThunkLock( TRUE ); + NtUserEnableThunkLock( thunk_lock_callback ); UserRegisterWowHandlers( &handlers16, &wow_handlers32 ); } diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index faed9182d4f..18c34442660 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -3055,14 +3055,11 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW void *ret_ptr; ULONG ret_len; - if (enable_thunk_lock) + if (!KeUserDispatchCallback( ¶ms.dispatch, sizeof(params), &ret_ptr, &ret_len ) && + ret_len == sizeof(params.locks)) { - if (!KeUserModeCallback( NtUserThunkLock, ¶ms, sizeof(params), &ret_ptr, &ret_len ) && - ret_len == sizeof(params.locks)) - { - params.locks = *(DWORD *)ret_ptr; - params.restore = TRUE; - } + params.locks = *(DWORD *)ret_ptr; + params.restore = TRUE; } if (user_driver->pProcessEvents( mask )) ret = count - 1; @@ -3081,8 +3078,7 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution(); if (ret == count - 1) get_user_thread_info()->last_driver_time = NtGetTickCount(); - if (enable_thunk_lock) - KeUserModeCallback( NtUserThunkLock, ¶ms, sizeof(params), &ret_ptr, &ret_len ); + KeUserDispatchCallback( ¶ms.dispatch, sizeof(params), &ret_ptr, &ret_len ); return ret; } diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 3cb9c7758cb..1106c265402 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -148,7 +148,7 @@ static INT64 last_query_display_time; static pthread_mutex_t display_lock = PTHREAD_MUTEX_INITIALIZER; BOOL decorated_mode = TRUE; -BOOL enable_thunk_lock = FALSE; +UINT64 thunk_lock_callback = 0; #define VIRTUAL_HMONITOR ((HMONITOR)(UINT_PTR)(0x10000 + 1)) static struct monitor virtual_monitor = @@ -6461,7 +6461,7 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code ) return set_dce_flags( UlongToHandle(arg), DCHF_ENABLEDC ); case NtUserCallOneParam_EnableThunkLock: - enable_thunk_lock = arg; + thunk_lock_callback = arg; return 0; case NtUserCallOneParam_EnumClipboardFormats: diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 8a84c16208d..2058d0332f7 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -159,7 +159,7 @@ extern void track_scroll_bar( HWND hwnd, int scrollbar, POINT pt ); /* sysparams.c */ extern BOOL decorated_mode; -extern BOOL enable_thunk_lock; +extern UINT64 thunk_lock_callback; extern HBRUSH get_55aa_brush(void); extern DWORD get_dialog_base_units(void); extern LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, int *height ); diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index f60db58e181..f4b8ca13036 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1450,11 +1450,6 @@ static NTSTATUS WINAPI wow64_NtUserCallDispatchCallback( void *arg, ULONG size ) return dispatch_callback( NtUserCallDispatchCallback, arg, size ); } -static NTSTATUS WINAPI wow64_NtUserThunkLock( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserThunkLock, arg, size ); -} - static NTSTATUS WINAPI wow64_NtUserCallVulkanDebugReportCallback( void *arg, ULONG size ) { return dispatch_callback( NtUserCallVulkanDebugReportCallback, arg, size ); @@ -1543,8 +1538,6 @@ ntuser_callback user_callbacks[] = wow64_NtUserPostDDEMessage, wow64_NtUserRenderSynthesizedFormat, wow64_NtUserUnpackDDEMessage, - /* win16 hooks */ - wow64_NtUserThunkLock, /* Vulkan support */ wow64_NtUserCallVulkanDebugReportCallback, wow64_NtUserCallVulkanDebugUtilsCallback, diff --git a/include/ntuser.h b/include/ntuser.h index da7c2e53594..f46435eb57b 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -61,8 +61,6 @@ enum NtUserPostDDEMessage, NtUserRenderSynthesizedFormat, NtUserUnpackDDEMessage, - /* win16 hooks */ - NtUserThunkLock, /* Vulkan support */ NtUserCallVulkanDebugReportCallback, NtUserCallVulkanDebugUtilsCallback, @@ -955,13 +953,14 @@ static inline WORD NtUserEnableDC( HDC hdc ) struct thunk_lock_params { + struct dispatch_callback_params dispatch; BOOL restore; DWORD locks; }; -static inline void NtUserEnableThunkLock( BOOL enable ) +static inline void NtUserEnableThunkLock( ntuser_callback thunk_lock_callback ) { - NtUserCallOneParam( enable, NtUserCallOneParam_EnableThunkLock ); + NtUserCallOneParam( (UINT_PTR)thunk_lock_callback, NtUserCallOneParam_EnableThunkLock ); } static inline UINT NtUserEnumClipboardFormats( UINT format ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Rémi Bernon <rbernon(a)codeweavers.com> Based on a patch from Torge Matthies. --- dlls/winevulkan/loader.c | 14 +++++++------- dlls/winevulkan/vulkan.c | 13 ++++++++++--- dlls/winevulkan/vulkan_loader.h | 9 +++++++++ dlls/wow64win/user.c | 13 ------------- include/ntuser.h | 3 --- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index 82e0f9d9eb6..24605d82e12 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -327,7 +327,13 @@ static NTSTATUS WINAPI call_vulkan_debug_utils_callback(void *args, ULONG size) static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) { - return !__wine_init_unix_call() && !UNIX_CALL(init, NULL); + struct vk_callback_funcs callback_funcs = + { + .call_vulkan_debug_report_callback = (ULONG_PTR)call_vulkan_debug_report_callback, + .call_vulkan_debug_utils_callback = (ULONG_PTR)call_vulkan_debug_utils_callback, + }; + + return !__wine_init_unix_call() && !UNIX_CALL(init, &callback_funcs); } static BOOL wine_vk_init_once(void) @@ -699,8 +705,6 @@ void WINAPI vkFreeCommandBuffers(VkDevice device, VkCommandPool cmd_pool, uint32 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved) { - KERNEL_CALLBACK_PROC *kernel_callback_table; - TRACE("%p, %lu, %p\n", hinst, reason, reserved); switch (reason) @@ -708,10 +712,6 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved) case DLL_PROCESS_ATTACH: hinstance = hinst; DisableThreadLibraryCalls(hinst); - - kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - kernel_callback_table[NtUserCallVulkanDebugReportCallback] = call_vulkan_debug_report_callback; - kernel_callback_table[NtUserCallVulkanDebugUtilsCallback] = call_vulkan_debug_utils_callback; break; } return TRUE; diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 8e7c094637d..53b567e97d8 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -169,6 +169,8 @@ static uint64_t client_handle_from_host(struct wine_instance *instance, uint64_t return result; } +struct vk_callback_funcs callback_funcs; + static UINT append_string(const char *name, char *strings, UINT *strings_len) { UINT len = name ? strlen(name) + 1 : 0; @@ -244,6 +246,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB ptr = (char *)(params + 1); strings = (char *)params + size; + params->dispatch.callback = callback_funcs.call_vulkan_debug_utils_callback; params->user_callback = object->user_callback; params->user_data = object->user_data; params->severity = severity; @@ -296,7 +299,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB } /* applications should always return VK_FALSE */ - KeUserModeCallback( NtUserCallVulkanDebugUtilsCallback, params, size + strings_len, &ret_ptr, &ret_len ); + KeUserDispatchCallback(¶ms->dispatch, size + strings_len, &ret_ptr, &ret_len); free(params); if (ret_len == sizeof(VkBool32)) return *(VkBool32 *)ret_ptr; @@ -331,6 +334,7 @@ static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, Vk if (!(params = malloc(sizeof(*params) + strings_len))) return VK_FALSE; strings = (char *)(params + 1); + params->dispatch.callback = callback_funcs.call_vulkan_debug_report_callback; params->user_callback = object->user_callback; params->user_data = object->user_data; params->flags = flags; @@ -344,7 +348,7 @@ static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, Vk params->layer_len = append_string(layer_prefix, strings, &strings_len); params->message_len = append_string(message, strings, &strings_len); - KeUserModeCallback(NtUserCallVulkanDebugReportCallback, params, sizeof(*params) + strings_len, &ret_ptr, &ret_len); + KeUserDispatchCallback(¶ms->dispatch, sizeof(*params) + strings_len, &ret_ptr, &ret_len); free(params); if (ret_len == sizeof(VkBool32)) return *(VkBool32 *)ret_ptr; @@ -631,8 +635,10 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de return VK_SUCCESS; } -NTSTATUS init_vulkan(void *args) +NTSTATUS init_vulkan(void *arg) { + const struct vk_callback_funcs *funcs = arg; + vk_funcs = __wine_get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION); if (!vk_funcs) { @@ -640,6 +646,7 @@ NTSTATUS init_vulkan(void *args) return STATUS_UNSUCCESSFUL; } + callback_funcs = *funcs; p_vkCreateInstance = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkCreateInstance"); p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion"); p_vkEnumerateInstanceExtensionProperties = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties"); diff --git a/dlls/winevulkan/vulkan_loader.h b/dlls/winevulkan/vulkan_loader.h index 2b5e734a68b..6d3d30ce615 100644 --- a/dlls/winevulkan/vulkan_loader.h +++ b/dlls/winevulkan/vulkan_loader.h @@ -28,6 +28,7 @@ #include "windef.h" #include "winbase.h" #include "winternl.h" +#include "ntuser.h" #include "wine/debug.h" #include "wine/vulkan.h" #include "wine/unixlib.h" @@ -105,6 +106,12 @@ void *wine_vk_get_device_proc_addr(const char *name); void *wine_vk_get_phys_dev_proc_addr(const char *name); void *wine_vk_get_instance_proc_addr(const char *name); +struct vk_callback_funcs +{ + UINT64 call_vulkan_debug_report_callback; + UINT64 call_vulkan_debug_utils_callback; +}; + /* debug callbacks params */ struct debug_utils_label @@ -130,6 +137,7 @@ struct debug_device_address_binding struct wine_vk_debug_utils_params { + struct dispatch_callback_params dispatch; UINT64 user_callback; /* client pointer */ UINT64 user_data; /* client pointer */ @@ -150,6 +158,7 @@ struct wine_vk_debug_utils_params struct wine_vk_debug_report_params { + struct dispatch_callback_params dispatch; UINT64 user_callback; /* client pointer */ UINT64 user_data; /* client pointer */ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index f4b8ca13036..b473d21617a 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1450,16 +1450,6 @@ static NTSTATUS WINAPI wow64_NtUserCallDispatchCallback( void *arg, ULONG size ) return dispatch_callback( NtUserCallDispatchCallback, arg, size ); } -static NTSTATUS WINAPI wow64_NtUserCallVulkanDebugReportCallback( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserCallVulkanDebugReportCallback, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserCallVulkanDebugUtilsCallback( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserCallVulkanDebugUtilsCallback, arg, size ); -} - static NTSTATUS WINAPI wow64_NtUserCallOpenGLDebugMessageCallback( void *arg, ULONG size ) { return dispatch_callback( NtUserCallOpenGLDebugMessageCallback, arg, size ); @@ -1538,9 +1528,6 @@ ntuser_callback user_callbacks[] = wow64_NtUserPostDDEMessage, wow64_NtUserRenderSynthesizedFormat, wow64_NtUserUnpackDDEMessage, - /* Vulkan support */ - wow64_NtUserCallVulkanDebugReportCallback, - wow64_NtUserCallVulkanDebugUtilsCallback, /* OpenGL support */ wow64_NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ diff --git a/include/ntuser.h b/include/ntuser.h index f46435eb57b..9ce3afdfa63 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -61,9 +61,6 @@ enum NtUserPostDDEMessage, NtUserRenderSynthesizedFormat, NtUserUnpackDDEMessage, - /* Vulkan support */ - NtUserCallVulkanDebugReportCallback, - NtUserCallVulkanDebugUtilsCallback, /* OpenGL support */ NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Rémi Bernon <rbernon(a)codeweavers.com> Based on a patch from Torge Matthies. --- dlls/opengl32/make_opengl | 14 ++++++++++++-- dlls/opengl32/unix_thunks.c | 2 ++ dlls/opengl32/unix_wgl.c | 17 +++++++++++++---- dlls/opengl32/unixlib.h | 10 +++++++++- dlls/opengl32/wgl.c | 12 +++++++----- dlls/wow64win/user.c | 7 ------- include/ntuser.h | 2 -- 7 files changed, 43 insertions(+), 21 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 4c2b2f77167..cbdc88f31d4 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -1027,10 +1027,16 @@ print OUT "#define WIN32_NO_STATUS\n"; print OUT "#include \"windef.h\"\n"; print OUT "#include \"winbase.h\"\n"; print OUT "#include \"winternl.h\"\n"; -print OUT "#include \"wingdi.h\"\n\n"; +print OUT "#include \"wingdi.h\"\n"; +print OUT "#include \"ntuser.h\"\n\n"; print OUT "#include \"wine/wgl.h\"\n"; print OUT "#include \"wine/unixlib.h\"\n\n"; +print OUT "struct process_attach_params\n"; +print OUT "{\n"; +print OUT " UINT64 call_gl_debug_message_callback;\n"; +print OUT "};\n\n"; + foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; @@ -1059,6 +1065,7 @@ print OUT "};\n\n"; print OUT "enum unix_funcs\n"; print OUT "{\n"; +print OUT " unix_process_attach,\n"; print OUT " unix_thread_attach,\n"; print OUT " unix_process_detach,\n"; print OUT " unix_get_pixel_formats,\n"; @@ -1079,8 +1086,9 @@ foreach (sort keys %ext_functions) } print OUT "};\n\n"; -print OUT "struct wine_gl_debug_message_params\n"; +print OUT "struct gl_debug_message_callback_params\n"; print OUT "{\n"; +print OUT " struct dispatch_callback_params dispatch;\n"; print OUT " UINT64 debug_callback; /* client pointer */\n"; print OUT " UINT64 debug_user; /* client pointer */\n"; print OUT " UINT32 source;\n"; @@ -1181,6 +1189,7 @@ print OUT "#ifdef _WIN64\n"; print OUT "WINE_DEFAULT_DEBUG_CHANNEL(opengl);\n"; print OUT "#endif\n\n"; +print OUT "extern NTSTATUS process_attach( void *args );\n"; print OUT "extern NTSTATUS thread_attach( void *args );\n"; print OUT "extern NTSTATUS process_detach( void *args );\n"; print OUT "extern NTSTATUS get_pixel_formats( void *args );\n"; @@ -1228,6 +1237,7 @@ foreach (sort keys %ext_functions) print OUT "const unixlib_entry_t __wine_unix_call_funcs[] =\n"; print OUT "{\n"; +print OUT " &process_attach,\n"; print OUT " &thread_attach,\n"; print OUT " &process_detach,\n"; print OUT " &get_pixel_formats,\n"; diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index ef14887461a..b8b4e5fb908 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -22,6 +22,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(opengl); #endif +extern NTSTATUS process_attach( void *args ); extern NTSTATUS thread_attach( void *args ); extern NTSTATUS process_detach( void *args ); extern NTSTATUS get_pixel_formats( void *args ); @@ -24196,6 +24197,7 @@ static NTSTATUS ext_wglSwapIntervalEXT( void *args ) const unixlib_entry_t __wine_unix_call_funcs[] = { + &process_attach, &thread_attach, &process_detach, &get_pixel_formats, diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index c5c584fc848..6e6fcdf7607 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -50,6 +50,8 @@ static BOOL is_wow64(void) return !!NtCurrentTeb()->WowTebOffset; } +static UINT64 call_gl_debug_message_callback; + static pthread_mutex_t wgl_lock = PTHREAD_MUTEX_INITIALIZER; /* handle management */ @@ -898,7 +900,7 @@ static BOOL wrap_wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user ) { - struct wine_gl_debug_message_params *params; + struct gl_debug_message_callback_params *params; void *ret_ptr; ULONG ret_len; struct wgl_handle *ptr = (struct wgl_handle *)user; @@ -912,8 +914,9 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL return; } - size = offsetof(struct wine_gl_debug_message_params, message[len] ); + size = offsetof(struct gl_debug_message_callback_params, message[len] ); if (!(params = malloc( size ))) return; + params->dispatch.callback = call_gl_debug_message_callback; params->debug_callback = ptr->u.context->debug_callback; params->debug_user = ptr->u.context->debug_user; params->source = source; @@ -923,8 +926,7 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL params->length = length; memcpy( params->message, message, len ); - KeUserModeCallback( NtUserCallOpenGLDebugMessageCallback, params, size, - &ret_ptr, &ret_len ); + KeUserDispatchCallback( ¶ms->dispatch, size, &ret_ptr, &ret_len ); free( params ); } @@ -1148,6 +1150,13 @@ NTSTATUS ext_wglSetPbufferAttribARB( void *args ) return STATUS_SUCCESS; } +NTSTATUS process_attach( void *args ) +{ + struct process_attach_params *params = args; + call_gl_debug_message_callback = params->call_gl_debug_message_callback; + return STATUS_SUCCESS; +} + NTSTATUS thread_attach( void *args ) { TEB *teb = args; diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 46b081e0b18..b754751f33f 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -12,10 +12,16 @@ #include "winbase.h" #include "winternl.h" #include "wingdi.h" +#include "ntuser.h" #include "wine/wgl.h" #include "wine/unixlib.h" +struct process_attach_params +{ + UINT64 call_gl_debug_message_callback; +}; + struct wglCopyContext_params { TEB *teb; @@ -25333,6 +25339,7 @@ struct get_pixel_formats_params enum unix_funcs { + unix_process_attach, unix_thread_attach, unix_process_detach, unix_get_pixel_formats, @@ -28377,8 +28384,9 @@ enum unix_funcs unix_wglSwapIntervalEXT, }; -struct wine_gl_debug_message_params +struct gl_debug_message_callback_params { + struct dispatch_callback_params dispatch; UINT64 debug_callback; /* client pointer */ UINT64 debug_user; /* client pointer */ UINT32 source; diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 6e24e4d5ed1..c6414054ff5 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1880,7 +1880,7 @@ typedef void (WINAPI *gl_debug_message)(GLenum, GLenum, GLuint, GLenum, GLsizei, static NTSTATUS WINAPI call_gl_debug_message_callback( void *args, ULONG size ) { - struct wine_gl_debug_message_params *params = args; + struct gl_debug_message_callback_params *params = args; gl_debug_message callback = (void *)(UINT_PTR)params->debug_callback; const void *user = (void *)(UINT_PTR)params->debug_user; callback( params->source, params->type, params->id, params->severity, @@ -1893,20 +1893,22 @@ static NTSTATUS WINAPI call_gl_debug_message_callback( void *args, ULONG size ) */ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) { - KERNEL_CALLBACK_PROC *kernel_callback_table; + struct process_attach_params params = + { + .call_gl_debug_message_callback = (UINT_PTR)call_gl_debug_message_callback, + }; NTSTATUS status; switch(reason) { case DLL_PROCESS_ATTACH: - if ((status = __wine_init_unix_call())) + if ((status = __wine_init_unix_call()) || + (status = UNIX_CALL( process_attach, ¶ms ))) { ERR( "Failed to load unixlib, status %#lx\n", status ); return FALSE; } - kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_gl_debug_message_callback; /* fallthrough */ case DLL_THREAD_ATTACH: if ((status = UNIX_CALL( thread_attach, NtCurrentTeb() ))) diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index b473d21617a..7c606101a29 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1450,11 +1450,6 @@ static NTSTATUS WINAPI wow64_NtUserCallDispatchCallback( void *arg, ULONG size ) return dispatch_callback( NtUserCallDispatchCallback, arg, size ); } -static NTSTATUS WINAPI wow64_NtUserCallOpenGLDebugMessageCallback( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserCallOpenGLDebugMessageCallback, arg, size ); -} - static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst0( void *arg, ULONG size ) { return dispatch_callback( NtUserDriverCallbackFirst + 0, arg, size ); @@ -1528,8 +1523,6 @@ ntuser_callback user_callbacks[] = wow64_NtUserPostDDEMessage, wow64_NtUserRenderSynthesizedFormat, wow64_NtUserUnpackDDEMessage, - /* OpenGL support */ - wow64_NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ wow64_NtUserDriverCallbackFirst0, wow64_NtUserDriverCallbackFirst1, diff --git a/include/ntuser.h b/include/ntuser.h index 9ce3afdfa63..c8fbe4be57f 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -61,8 +61,6 @@ enum NtUserPostDDEMessage, NtUserRenderSynthesizedFormat, NtUserUnpackDDEMessage, - /* OpenGL support */ - NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ NtUserDriverCallbackFirst, NtUserDriverCallbackLast = NtUserDriverCallbackFirst + 9, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
From: Torge Matthies <tmatthies(a)codeweavers.com> --- dlls/wineandroid.drv/android.h | 1 + dlls/wineandroid.drv/device.c | 3 ++- dlls/wineandroid.drv/dllmain.c | 9 ++------- dlls/wineandroid.drv/init.c | 2 ++ dlls/wineandroid.drv/unixlib.h | 7 +------ 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 850b235f3a1..c48b7c7b121 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -107,6 +107,7 @@ extern NTSTATUS android_java_init( void *arg ); extern NTSTATUS android_java_uninit( void *arg ); extern NTSTATUS android_register_window( void *arg ); extern PNTAPCFUNC register_window_callback; +extern UINT64 start_device_callback; extern unsigned int screen_width; extern unsigned int screen_height; diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index d00ea5da8e8..0c4b77ebb6e 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -1177,7 +1177,8 @@ void start_android_device(void) { void *ret_ptr; ULONG ret_len; - KeUserModeCallback( client_start_device, NULL, 0, &ret_ptr, &ret_len ); + struct dispatch_callback_params params = {.callback = start_device_callback}; + if (KeUserDispatchCallback( ¶ms, sizeof(params), &ret_ptr, &ret_len )) return; if (ret_len == sizeof(thread)) thread = *(HANDLE *)ret_ptr; } diff --git a/dlls/wineandroid.drv/dllmain.c b/dlls/wineandroid.drv/dllmain.c index 58d001886eb..c8495d679f9 100644 --- a/dlls/wineandroid.drv/dllmain.c +++ b/dlls/wineandroid.drv/dllmain.c @@ -116,7 +116,6 @@ static void CALLBACK register_window_callback( ULONG_PTR arg1, ULONG_PTR arg2, U BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) { struct init_params params; - KERNEL_CALLBACK_PROC *callback_table; if (reason != DLL_PROCESS_ATTACH) return TRUE; @@ -124,10 +123,6 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) if (__wine_init_unix_call()) return FALSE; params.register_window_callback = register_window_callback; - if (ANDROID_CALL( init, ¶ms )) return FALSE; - - callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - callback_table[client_start_device] = android_start_device; - - return TRUE; + params.start_device_callback = android_start_device; + return !ANDROID_CALL( init, ¶ms ); } diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index d747ce5d091..d5488388e0d 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -50,6 +50,7 @@ static RECT monitor_rc_work; static int device_init_done; PNTAPCFUNC register_window_callback; +UINT64 start_device_callback; typedef struct { @@ -573,6 +574,7 @@ static HRESULT android_init( void *arg ) pthread_mutexattr_destroy( &attr ); register_window_callback = params->register_window_callback; + start_device_callback = params->start_device_callback; if ((java_vm = *p_java_vm)) /* running under Java */ { diff --git a/dlls/wineandroid.drv/unixlib.h b/dlls/wineandroid.drv/unixlib.h index f1ba25720fd..46c59f8f201 100644 --- a/dlls/wineandroid.drv/unixlib.h +++ b/dlls/wineandroid.drv/unixlib.h @@ -35,6 +35,7 @@ enum android_funcs struct init_params { PNTAPCFUNC register_window_callback; + UINT64 start_device_callback; }; @@ -53,9 +54,3 @@ struct register_window_params UINT_PTR arg2; UINT_PTR arg3; }; - - -enum -{ - client_start_device = NtUserDriverCallbackFirst, -}; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147953 Your paranoid android. === debian11 (build log) === error: patch failed: dlls/user.exe16/message.c:2585 error: patch failed: dlls/win32u/cursoricon.c:41 error: patch failed: dlls/win32u/sysparams.c:6563 error: patch failed: dlls/win32u/win32u_private.h:41 error: patch failed: include/ntuser.h:1094 error: patch failed: dlls/user.exe16/message.c:2593 error: patch failed: dlls/win32u/message.c:3049 error: patch failed: include/ntuser.h:937 error: patch failed: dlls/user.exe16/message.c:2583 error: patch failed: dlls/user.exe16/user.c:26 error: patch failed: dlls/user32/user_main.c:215 error: patch failed: dlls/win32u/cursoricon.c:213 error: patch failed: dlls/wow64win/user.c:1445 error: patch failed: dlls/wow64win/wow64win_private.h:22 error: patch failed: include/ntuser.h:34 error: patch failed: include/wine/unixlib.h:72 error: patch failed: dlls/user.exe16/message.c:2583 error: patch failed: dlls/win32u/message.c:3055 error: patch failed: dlls/win32u/sysparams.c:148 error: patch failed: dlls/win32u/win32u_private.h:159 error: patch failed: dlls/wow64win/user.c:1450 error: patch failed: include/ntuser.h:61 error: patch failed: dlls/winevulkan/loader.c:327 error: patch failed: dlls/winevulkan/vulkan.c:169 error: patch failed: dlls/winevulkan/vulkan_loader.h:28 error: patch failed: dlls/wow64win/user.c:1450 error: patch failed: include/ntuser.h:61 error: patch failed: dlls/opengl32/make_opengl:1027 error: patch failed: dlls/opengl32/unix_thunks.c:22 error: patch failed: dlls/opengl32/unix_wgl.c:50 error: patch failed: dlls/opengl32/unixlib.h:12 error: patch failed: dlls/opengl32/wgl.c:1880 error: patch failed: dlls/wow64win/user.c:1450 error: patch failed: include/ntuser.h:61 Task: Patch failed to apply === debian11b (build log) === error: patch failed: dlls/user.exe16/message.c:2585 error: patch failed: dlls/win32u/cursoricon.c:41 error: patch failed: dlls/win32u/sysparams.c:6563 error: patch failed: dlls/win32u/win32u_private.h:41 error: patch failed: include/ntuser.h:1094 error: patch failed: dlls/user.exe16/message.c:2593 error: patch failed: dlls/win32u/message.c:3049 error: patch failed: include/ntuser.h:937 error: patch failed: dlls/user.exe16/message.c:2583 error: patch failed: dlls/user.exe16/user.c:26 error: patch failed: dlls/user32/user_main.c:215 error: patch failed: dlls/win32u/cursoricon.c:213 error: patch failed: dlls/wow64win/user.c:1445 error: patch failed: dlls/wow64win/wow64win_private.h:22 error: patch failed: include/ntuser.h:34 error: patch failed: include/wine/unixlib.h:72 error: patch failed: dlls/user.exe16/message.c:2583 error: patch failed: dlls/win32u/message.c:3055 error: patch failed: dlls/win32u/sysparams.c:148 error: patch failed: dlls/win32u/win32u_private.h:159 error: patch failed: dlls/wow64win/user.c:1450 error: patch failed: include/ntuser.h:61 error: patch failed: dlls/winevulkan/loader.c:327 error: patch failed: dlls/winevulkan/vulkan.c:169 error: patch failed: dlls/winevulkan/vulkan_loader.h:28 error: patch failed: dlls/wow64win/user.c:1450 error: patch failed: include/ntuser.h:61 error: patch failed: dlls/opengl32/make_opengl:1027 error: patch failed: dlls/opengl32/unix_thunks.c:22 error: patch failed: dlls/opengl32/unix_wgl.c:50 error: patch failed: dlls/opengl32/unixlib.h:12 error: patch failed: dlls/opengl32/wgl.c:1880 error: patch failed: dlls/wow64win/user.c:1450 error: patch failed: include/ntuser.h:61 Task: Patch failed to apply
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6344
participants (3)
-
Marvin -
Rémi Bernon -
Torge Matthies