Overwatch 2 verifies that every kernel callback that is run, lives in user32. Introduce a callback in user32 that just forwards to the other modules' callbacks.
-- v19: include: Add a comment explaining why all kernel callbacks must be in user32. user32: Remove NtUserDriverCallback* kernel callbacks. winex11.drv: Route kernel callbacks through user32. winex11.drv: Pass a struct to x11drv_ime_set_result. winex11.drv: Pass a struct to x11drv_dnd_post_drop. winemac.drv: Route kernel callbacks through user32. wineandroid.drv: Route kernel callbacks through user32. opengl32: Route kernel callbacks through user32. winevulkan: Route kernel callbacks through user32. user32: Add NtUserDispatchCallback kernel callback. user.exe16: Move kernel callbacks to wow_callbacks.
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/user.exe16/message.c | 20 ++++++++------------ dlls/user.exe16/user_private.h | 2 ++ dlls/user32/controls.h | 2 ++ dlls/user32/user_main.c | 13 +++++++++++++ dlls/user32/winproc.c | 2 ++ 5 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index 203d543ce90..8666f77bb03 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -2581,28 +2581,26 @@ HWND create_window16( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE instance, }
-static void WINAPI User16CallFreeIcon( ULONG *param, ULONG size ) +static void call_free_icon16( HICON16 hIcon ) { - GlobalFree16( LOWORD(*param) ); + GlobalFree16( hIcon ); }
-static DWORD WINAPI User16ThunkLock( DWORD *param, ULONG size ) +static DWORD thunk_lock16( DWORD lock, BOOL release ) { - if (size != sizeof(DWORD)) + if (release) { - DWORD lock; ReleaseThunkLock( &lock ); return lock; } - RestoreThunkLock( *param ); + RestoreThunkLock( lock ); return 0; }
void register_wow_handlers(void) { - void **callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; static const struct wow_handlers16 handlers16 = { button_proc16, @@ -2615,12 +2613,10 @@ void register_wow_handlers(void) create_window16, call_window_proc_Ato16, call_dialog_proc_Ato16, + call_free_icon16, + thunk_lock16 };
- callback_table[NtUserCallFreeIcon] = User16CallFreeIcon; - callback_table[NtUserThunkLock] = User16ThunkLock; - - NtUserEnableThunkLock( TRUE ); - UserRegisterWowHandlers( &handlers16, &wow_handlers32 ); + NtUserEnableThunkLock( TRUE ); } diff --git a/dlls/user.exe16/user_private.h b/dlls/user.exe16/user_private.h index 0805997246b..c3e1d9c9c84 100644 --- a/dlls/user.exe16/user_private.h +++ b/dlls/user.exe16/user_private.h @@ -44,6 +44,8 @@ struct wow_handlers16 HWND (*create_window)(CREATESTRUCTW*,LPCWSTR,HINSTANCE,BOOL); LRESULT (*call_window_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*); LRESULT (*call_dialog_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*); + void (*call_free_icon)(HICON16); + DWORD (*thunk_lock)(DWORD,BOOL); };
struct wow_handlers32 diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h index 613de0af6c2..7da105a9dfc 100644 --- a/dlls/user32/controls.h +++ b/dlls/user32/controls.h @@ -45,6 +45,8 @@ struct wow_handlers16 HWND (*create_window)(CREATESTRUCTW*,LPCWSTR,HINSTANCE,BOOL); LRESULT (*call_window_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*); LRESULT (*call_dialog_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*); + void (*call_free_icon)(WORD); + DWORD (*thunk_lock)(DWORD,BOOL); };
struct wow_handlers32 diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index 56d5849f469..d07eebc082f 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -199,6 +199,17 @@ static NTSTATUS WINAPI User32UnpackDDEMessage( const struct unpack_dde_message_p return TRUE; }
+static void WINAPI User32CallFreeIcon( ULONG *param, ULONG size ) +{ + if (wow_handlers.call_free_icon) + wow_handlers.call_free_icon( LOWORD(*param) ); +} + +static DWORD WINAPI User32ThunkLock( DWORD *param, ULONG size ) +{ + return wow_handlers.thunk_lock( param ? *param : 0, size == sizeof(DWORD) ); +} + static const void *kernel_callback_table[NtUserCallCount] = { User32CallEnumDisplayMonitor, @@ -220,6 +231,8 @@ static const void *kernel_callback_table[NtUserCallCount] = User32PostDDEMessage, User32RenderSsynthesizedFormat, User32UnpackDDEMessage, + User32CallFreeIcon, + User32ThunkLock, };
diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index 9fd35e1d24e..074c1ed7258 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -1453,6 +1453,8 @@ struct wow_handlers16 wow_handlers = WIN_CreateWindowEx, NULL, /* call_window_proc */ NULL, /* call_dialog_proc */ + NULL, /* call_free_icon */ + NULL, /* thunk_lock */ };
static const struct user_client_procs client_procsA =
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/user32/user_main.c | 8 ++++++++ dlls/wow64win/user.c | 6 ++++++ include/ntuser.h | 8 ++++++++ 3 files changed, 22 insertions(+)
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index d07eebc082f..b8d45e9b00a 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "user_private.h" #include "controls.h" #include "imm.h" @@ -199,6 +201,11 @@ static NTSTATUS WINAPI User32UnpackDDEMessage( const struct unpack_dde_message_p return TRUE; }
+static NTSTATUS WINAPI User32DispatchCallback( const struct user32_callback_params *params, ULONG size ) +{ + return ((user32_callback_func)(ULONG_PTR)params->func)( (void*)params, size ); +} + static void WINAPI User32CallFreeIcon( ULONG *param, ULONG size ) { if (wow_handlers.call_free_icon) @@ -231,6 +238,7 @@ static const void *kernel_callback_table[NtUserCallCount] = User32PostDDEMessage, User32RenderSsynthesizedFormat, User32UnpackDDEMessage, + User32DispatchCallback, User32CallFreeIcon, User32ThunkLock, }; diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index e1ce2dd8321..293ff0714dc 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1008,6 +1008,11 @@ static NTSTATUS WINAPI wow64_NtUserUnpackDDEMessage( void *arg, ULONG size ) return TRUE; }
+static NTSTATUS WINAPI wow64_NtUserDispatchCallback( void *arg, ULONG size ) +{ + return dispatch_callback( NtUserDispatchCallback, arg, size ); +} + static NTSTATUS WINAPI wow64_NtUserCallFreeIcon( void *arg, ULONG size ) { return dispatch_callback( NtUserCallFreeIcon, arg, size ); @@ -1108,6 +1113,7 @@ user_callback user_callbacks[] = wow64_NtUserPostDDEMessage, wow64_NtUserRenderSynthesizedFormat, wow64_NtUserUnpackDDEMessage, + wow64_NtUserDispatchCallback, /* win16 hooks */ wow64_NtUserCallFreeIcon, wow64_NtUserThunkLock, diff --git a/include/ntuser.h b/include/ntuser.h index 14e1f3757d4..e1ae81e58df 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -47,6 +47,7 @@ enum NtUserPostDDEMessage, NtUserRenderSynthesizedFormat, NtUserUnpackDDEMessage, + NtUserDispatchCallback, /* win16 hooks */ NtUserCallFreeIcon, NtUserThunkLock, @@ -270,6 +271,13 @@ struct unpack_dde_message_params char data[1]; };
+typedef NTSTATUS (WINAPI *user32_callback_func)( void *args, ULONG len ); + +struct user32_callback_params +{ + UINT64 func; +}; + /* process DPI awareness contexts */ #define NTUSER_DPI_UNAWARE 0x00006010 #define NTUSER_DPI_SYSTEM_AWARE 0x00006011
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winevulkan/loader.c | 40 ++++++++++++++++++-------------- dlls/winevulkan/vulkan.c | 15 ++++++++---- dlls/winevulkan/vulkan_loader.h | 11 +++++++++ dlls/winevulkan/vulkan_private.h | 1 + dlls/wow64win/user.c | 15 ------------ include/ntuser.h | 3 --- 6 files changed, 44 insertions(+), 41 deletions(-)
diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index 19fd240f0cb..7a325d3fd0b 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -230,9 +230,30 @@ VkResult WINAPI vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supported_ver return VK_SUCCESS; }
+static NTSTATUS WINAPI call_vulkan_debug_report_callback( void *args, ULONG len ) +{ + struct wine_vk_debug_report_params *params = + CONTAINING_RECORD( args, struct wine_vk_debug_report_params, cbparams ); + return params->user_callback(params->flags, params->object_type, params->object_handle, params->location, + params->code, params->layer_prefix, params->message, params->user_data); +} + +static NTSTATUS WINAPI call_vulkan_debug_utils_callback( void *args, ULONG len ) +{ + struct wine_vk_debug_utils_params *params = + CONTAINING_RECORD( args, struct wine_vk_debug_utils_params, cbparams ); + return params->user_callback(params->severity, params->message_types, ¶ms->data, params->user_data); +} + 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 = + { + (ULONG_PTR)call_vulkan_debug_report_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) @@ -602,21 +623,8 @@ void WINAPI vkFreeCommandBuffers(VkDevice device, VkCommandPool cmd_pool, uint32 } }
-static BOOL WINAPI call_vulkan_debug_report_callback( struct wine_vk_debug_report_params *params, ULONG size ) -{ - return params->user_callback(params->flags, params->object_type, params->object_handle, params->location, - params->code, params->layer_prefix, params->message, params->user_data); -} - -static BOOL WINAPI call_vulkan_debug_utils_callback( struct wine_vk_debug_utils_params *params, ULONG size ) -{ - return params->user_callback(params->severity, params->message_types, ¶ms->data, params->user_data); -} - BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved) { - void **kernel_callback_table; - TRACE("%p, %lu, %p\n", hinst, reason, reserved);
switch (reason) @@ -624,10 +632,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 1df10cc89a6..211a1e277d6 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -134,6 +134,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB }
/* FIXME: we should pack all referenced structs instead of passing pointers */ + params.cbparams.func = callback_funcs.call_vulkan_debug_utils_callback; params.user_callback = object->user_callback; params.user_data = object->user_data; params.severity = severity; @@ -168,8 +169,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB params.data.pObjects = object_name_infos;
/* applications should always return VK_FALSE */ - result = KeUserModeCallback( NtUserCallVulkanDebugUtilsCallback, ¶ms, sizeof(params), - &ret_ptr, &ret_len ); + result = KeUserModeCallback( NtUserDispatchCallback, ¶ms.cbparams, sizeof(params), &ret_ptr, &ret_len );
free(object_name_infos);
@@ -196,6 +196,7 @@ static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, Vk }
/* FIXME: we should pack all referenced structs instead of passing pointers */ + params.cbparams.func = callback_funcs.call_vulkan_debug_report_callback; params.user_callback = object->user_callback; params.user_data = object->user_data; params.flags = flags; @@ -209,8 +210,7 @@ static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, Vk if (!params.object_handle) params.object_type = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
- return KeUserModeCallback( NtUserCallVulkanDebugReportCallback, ¶ms, sizeof(params), - &ret_ptr, &ret_len ); + return KeUserModeCallback( NtUserDispatchCallback, ¶ms.cbparams, sizeof(params), &ret_ptr, &ret_len ); }
static void wine_vk_physical_device_free(struct wine_phys_dev *phys_dev) @@ -462,8 +462,12 @@ static void wine_vk_device_free(struct wine_device *device) free(device); }
-NTSTATUS init_vulkan(void *args) +struct vk_callback_funcs callback_funcs; + +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) { @@ -471,6 +475,7 @@ NTSTATUS init_vulkan(void *args) return STATUS_UNSUCCESSFUL; }
+ callback_funcs = *funcs; return STATUS_SUCCESS; }
diff --git a/dlls/winevulkan/vulkan_loader.h b/dlls/winevulkan/vulkan_loader.h index 24052c8690d..e90af443369 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" @@ -107,10 +108,18 @@ void *wine_vk_get_device_proc_addr(const char *name) DECLSPEC_HIDDEN; void *wine_vk_get_phys_dev_proc_addr(const char *name) DECLSPEC_HIDDEN; void *wine_vk_get_instance_proc_addr(const char *name) DECLSPEC_HIDDEN;
+struct vk_callback_funcs +{ + UINT64 call_vulkan_debug_report_callback; + UINT64 call_vulkan_debug_utils_callback; +}; + /* debug callbacks params */
struct wine_vk_debug_utils_params { + struct user32_callback_params cbparams; + PFN_vkDebugUtilsMessengerCallbackEXT user_callback; void *user_data;
@@ -121,6 +130,8 @@ struct wine_vk_debug_utils_params
struct wine_vk_debug_report_params { + struct user32_callback_params cbparams; + PFN_vkDebugReportCallbackEXT user_callback; void *user_data;
diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 60e21114940..d1c2bc75217 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -242,6 +242,7 @@ BOOL wine_vk_instance_extension_supported(const char *name) DECLSPEC_HIDDEN;
BOOL wine_vk_is_type_wrapped(VkObjectType type) DECLSPEC_HIDDEN;
+extern struct vk_callback_funcs callback_funcs; NTSTATUS init_vulkan(void *args) DECLSPEC_HIDDEN;
NTSTATUS vk_is_available_instance_function(void *arg) DECLSPEC_HIDDEN; diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 293ff0714dc..061565f2f2c 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1023,18 +1023,6 @@ static NTSTATUS WINAPI wow64_NtUserThunkLock( void *arg, ULONG size ) return dispatch_callback( NtUserThunkLock, arg, size ); }
-static NTSTATUS WINAPI wow64_NtUserCallVulkanDebugReportCallback( void *arg, ULONG size ) -{ - FIXME( "\n" ); - return 0; -} - -static NTSTATUS WINAPI wow64_NtUserCallVulkanDebugUtilsCallback( void *arg, ULONG size ) -{ - FIXME( "\n" ); - return 0; -} - static NTSTATUS WINAPI wow64_NtUserCallOpenGLDebugMessageCallback( void *arg, ULONG size ) { FIXME( "\n" ); @@ -1117,9 +1105,6 @@ user_callback user_callbacks[] = /* win16 hooks */ wow64_NtUserCallFreeIcon, wow64_NtUserThunkLock, - /* Vulkan support */ - wow64_NtUserCallVulkanDebugReportCallback, - wow64_NtUserCallVulkanDebugUtilsCallback, /* OpenGL support */ wow64_NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ diff --git a/include/ntuser.h b/include/ntuser.h index e1ae81e58df..f34a77a6b54 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -51,9 +51,6 @@ enum /* win16 hooks */ NtUserCallFreeIcon, NtUserThunkLock, - /* Vulkan support */ - NtUserCallVulkanDebugReportCallback, - NtUserCallVulkanDebugUtilsCallback, /* OpenGL support */ NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/opengl32/make_opengl | 14 +++++++++++++- dlls/opengl32/unix_thunks.c | 2 ++ dlls/opengl32/unix_wgl.c | 13 +++++++++++-- dlls/opengl32/unixlib.h | 10 ++++++++++ dlls/opengl32/wgl.c | 13 ++++++++----- dlls/wow64win/user.c | 8 -------- include/ntuser.h | 2 -- include/wine/wgl_driver.h | 2 +- 8 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index b1161632f81..2ed9c2a8f39 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -994,10 +994,18 @@ 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 wine_gl_debug_message_params;\n\n"; + +print OUT "struct wglInit_params\n"; +print OUT "{\n"; +print OUT " BOOL (*WINAPI call_opengl_debug_message_callback)( void *args, ULONG len );\n"; +print OUT "};\n\n"; + foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; @@ -1016,6 +1024,7 @@ foreach (sort keys %ext_functions)
print OUT "enum unix_funcs\n"; print OUT "{\n"; +print OUT " unix_wglInit,\n"; print OUT " unix_thread_attach,\n"; print OUT " unix_process_detach,\n"; foreach (sort keys %wgl_functions) @@ -1038,6 +1047,7 @@ print OUT "};\n\n"; print OUT "typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);\n"; print OUT "struct wine_gl_debug_message_params\n"; print OUT "{\n"; +print OUT " struct user32_callback_params cbparams;\n"; print OUT " gl_debug_cb user_callback;\n"; print OUT " const void *user_data;\n"; print OUT "\n"; @@ -1139,6 +1149,7 @@ print OUT "#ifdef _WIN64\n"; print OUT "WINE_DEFAULT_DEBUG_CHANNEL(opengl);\n"; print OUT "#endif\n\n";
+print OUT "extern NTSTATUS wgl_wglInit( void *args ) DECLSPEC_HIDDEN;\n"; print OUT "extern NTSTATUS thread_attach( void *args ) DECLSPEC_HIDDEN;\n"; print OUT "extern NTSTATUS process_detach( void *args ) DECLSPEC_HIDDEN;\n"; foreach (sort keys %wgl_functions) @@ -1185,6 +1196,7 @@ foreach (sort keys %ext_functions)
print OUT "const unixlib_entry_t __wine_unix_call_funcs[] =\n"; print OUT "{\n"; +print OUT " &wgl_wglInit,\n"; print OUT " &thread_attach,\n"; print OUT " &process_detach,\n"; foreach (sort keys %wgl_functions) diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index d90784bc725..e05b951022c 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 wgl_wglInit( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS thread_attach( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS process_detach( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wgl_wglCopyContext( void *args ) DECLSPEC_HIDDEN; @@ -24204,6 +24205,7 @@ static NTSTATUS ext_wglSwapIntervalEXT( void *args )
const unixlib_entry_t __wine_unix_call_funcs[] = { + &wgl_wglInit, &thread_attach, &process_detach, &wgl_wglCopyContext, diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 6c3379b90a2..db0da958247 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -43,6 +43,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
+static BOOL (*WINAPI call_opengl_debug_message_callback)( void *args, ULONG len ); + static pthread_mutex_t wgl_lock = PTHREAD_MUTEX_INITIALIZER;
/* handle management */ @@ -814,6 +816,7 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL { struct wine_gl_debug_message_params params = { + .cbparams = { .func = (ULONG_PTR)call_opengl_debug_message_callback, }, .source = source, .type = type, .id = id, @@ -828,8 +831,7 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL if (!(params.user_callback = ptr->u.context->debug_callback)) return; params.user_data = ptr->u.context->debug_user;
- KeUserModeCallback( NtUserCallOpenGLDebugMessageCallback, ¶ms, sizeof(params), - &ret_ptr, &ret_len ); + KeUserModeCallback( NtUserDispatchCallback, ¶ms.cbparams, sizeof(params), &ret_ptr, &ret_len ); }
static void wrap_glDebugMessageCallback( TEB *teb, GLDEBUGPROC callback, const void *userParam ) @@ -868,6 +870,13 @@ static void wrap_glDebugMessageCallbackARB( TEB *teb, GLDEBUGPROCARB callback, c funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr ); }
+NTSTATUS wgl_wglInit( void *args ) +{ + struct wglInit_params *params = args; + call_opengl_debug_message_callback = params->call_opengl_debug_message_callback; + return STATUS_SUCCESS; +} + NTSTATUS wgl_wglCopyContext( void *args ) { struct wglCopyContext_params *params = args; diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 96e42a39b17..e1b6ec3ad0a 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -12,10 +12,18 @@ #include "winbase.h" #include "winternl.h" #include "wingdi.h" +#include "ntuser.h"
#include "wine/wgl.h" #include "wine/unixlib.h"
+struct wine_gl_debug_message_params; + +struct wglInit_params +{ + BOOL (*WINAPI call_opengl_debug_message_callback)( void *args, ULONG len ); +}; + struct wglCopyContext_params { TEB *teb; @@ -25333,6 +25341,7 @@ struct wglSwapIntervalEXT_params
enum unix_funcs { + unix_wglInit, unix_thread_attach, unix_process_detach, unix_wglCopyContext, @@ -28380,6 +28389,7 @@ enum unix_funcs typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); struct wine_gl_debug_message_params { + struct user32_callback_params cbparams; gl_debug_cb user_callback; const void *user_data;
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index f57f7703409..d499aaba21d 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1270,8 +1270,10 @@ GLboolean WINAPI glUnmapNamedBufferEXT( GLuint buffer ) return gl_unmap_named_buffer( unix_glUnmapNamedBufferEXT, buffer ); }
-static BOOL WINAPI call_opengl_debug_message_callback( struct wine_gl_debug_message_params *params, ULONG size ) +static BOOL WINAPI call_opengl_debug_message_callback( void *args, ULONG len ) { + struct wine_gl_debug_message_params *params = + CONTAINING_RECORD( args, struct wine_gl_debug_message_params, cbparams ); params->user_callback( params->source, params->type, params->id, params->severity, params->length, params->message, params->user_data ); return TRUE; @@ -1282,21 +1284,22 @@ static BOOL WINAPI call_opengl_debug_message_callback( struct wine_gl_debug_mess */ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) { - void **kernel_callback_table; NTSTATUS status;
switch(reason) { case DLL_PROCESS_ATTACH: + { + struct wglInit_params args = { (void*)call_opengl_debug_message_callback }; + if ((status = __wine_init_unix_call())) { ERR( "Failed to load unixlib, status %#lx\n", status ); return FALSE; }
- kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_opengl_debug_message_callback; - /* fallthrough */ + return !UNIX_CALL( wglInit, &args ); + } case DLL_THREAD_ATTACH: if ((status = UNIX_CALL( thread_attach, NtCurrentTeb() ))) { diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 061565f2f2c..2b82071be49 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1023,12 +1023,6 @@ static NTSTATUS WINAPI wow64_NtUserThunkLock( void *arg, ULONG size ) return dispatch_callback( NtUserThunkLock, arg, size ); }
-static NTSTATUS WINAPI wow64_NtUserCallOpenGLDebugMessageCallback( void *arg, ULONG size ) -{ - FIXME( "\n" ); - return 0; -} - static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst0( void *arg, ULONG size ) { return dispatch_callback( NtUserDriverCallbackFirst + 0, arg, size ); @@ -1105,8 +1099,6 @@ user_callback user_callbacks[] = /* win16 hooks */ wow64_NtUserCallFreeIcon, wow64_NtUserThunkLock, - /* OpenGL support */ - wow64_NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ wow64_NtUserDriverCallbackFirst0, wow64_NtUserDriverCallbackFirst1, diff --git a/include/ntuser.h b/include/ntuser.h index f34a77a6b54..d283fe9a39e 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -51,8 +51,6 @@ enum /* win16 hooks */ NtUserCallFreeIcon, NtUserThunkLock, - /* OpenGL support */ - NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ NtUserDriverCallbackFirst, NtUserDriverCallbackLast = NtUserDriverCallbackFirst + 9, diff --git a/include/wine/wgl_driver.h b/include/wine/wgl_driver.h index ed11d8caa0e..919245fa1cf 100644 --- a/include/wine/wgl_driver.h +++ b/include/wine/wgl_driver.h @@ -7,7 +7,7 @@ #define WINE_GLAPI #endif
-#define WINE_WGL_DRIVER_VERSION 23 +#define WINE_WGL_DRIVER_VERSION 24
struct wgl_context; struct wgl_pbuffer;
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/wineandroid.drv/android.h | 1 + dlls/wineandroid.drv/device.c | 4 +++- dlls/wineandroid.drv/dllmain.c | 9 ++------- dlls/wineandroid.drv/init.c | 2 ++ dlls/wineandroid.drv/unixlib.h | 7 +------ 5 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 0d073a63bcc..6ec748630cf 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -118,6 +118,7 @@ extern NTSTATUS android_java_init( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS android_java_uninit( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS android_register_window( void *arg ) DECLSPEC_HIDDEN; extern PNTAPCFUNC register_window_callback; +extern user32_callback_func start_device;
extern unsigned int screen_width DECLSPEC_HIDDEN; extern unsigned int screen_height DECLSPEC_HIDDEN; diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index e50336c779c..84232fdbce6 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -1180,7 +1180,9 @@ void start_android_device(void) { void *ret_ptr; ULONG ret_len; - thread = ULongToHandle( KeUserModeCallback( client_start_device, NULL, 0, &ret_ptr, &ret_len )); + struct user32_callback_params cbparams = { (ULONG_PTR)start_device }; + NTSTATUS ret = KeUserModeCallback( NtUserDispatchCallback, &cbparams, sizeof(cbparams), &ret_ptr, &ret_len ); + thread = ULongToHandle( ret ); }
diff --git a/dlls/wineandroid.drv/dllmain.c b/dlls/wineandroid.drv/dllmain.c index 3f6dbd388eb..19757d6cad3 100644 --- a/dlls/wineandroid.drv/dllmain.c +++ b/dlls/wineandroid.drv/dllmain.c @@ -117,7 +117,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; - void **callback_table;
if (reason == DLL_PROCESS_ATTACH) return TRUE;
@@ -125,12 +124,8 @@ 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 = android_start_device; + return !ANDROID_CALL( init, ¶ms ); }
diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index f2423d96407..85c8010b96e 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -53,6 +53,7 @@ static int device_init_done; static BOOL force_display_devices_refresh;
PNTAPCFUNC register_window_callback; +user32_callback_func start_device;
typedef struct { @@ -587,6 +588,7 @@ static HRESULT android_init( void *arg ) pthread_mutexattr_destroy( &attr );
register_window_callback = params->register_window_callback; + start_device = params->start_device;
if ((java_vm = *p_java_vm)) /* running under Java */ { diff --git a/dlls/wineandroid.drv/unixlib.h b/dlls/wineandroid.drv/unixlib.h index a180e6660c8..5412e8068f5 100644 --- a/dlls/wineandroid.drv/unixlib.h +++ b/dlls/wineandroid.drv/unixlib.h @@ -36,6 +36,7 @@ enum android_funcs struct init_params { PNTAPCFUNC register_window_callback; + user32_callback_func start_device; };
@@ -54,9 +55,3 @@ struct register_window_params UINT_PTR arg2; UINT_PTR arg3; }; - - -enum -{ - client_start_device = NtUserDriverCallbackFirst, -};
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winemac.drv/dllmain.c | 14 +++----------- dlls/winemac.drv/event.c | 15 ++++++++++----- dlls/winemac.drv/image.c | 3 ++- dlls/winemac.drv/macdrv.h | 4 ++-- dlls/winemac.drv/macdrv_main.c | 8 ++++++-- dlls/winemac.drv/unixlib.h | 35 +++++++++++++++++++--------------- dlls/winemac.drv/window.c | 3 ++- 7 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 41e9e908b61..dd89853ecef 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -366,8 +366,7 @@ cleanup: return 0; }
-typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); -static const kernel_callback kernel_callbacks[] = +static const struct macdrv_client_funcs client_funcs = { macdrv_app_icon, macdrv_app_quit_request, @@ -378,13 +377,10 @@ static const kernel_callback kernel_callbacks[] = macdrv_ime_set_text, };
-C_ASSERT(NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func_last); -
static BOOL process_attach(void) { struct init_params params; - void **callback_table;
struct localized_string *str; struct localized_string strings[] = { @@ -410,12 +406,8 @@ static BOOL process_attach(void) for (str = strings; str->id; str++) str->len = LoadStringW(macdrv_module, str->id, (WCHAR *)&str->str, 0); params.strings = strings; - - if (MACDRV_CALL(init, ¶ms)) return FALSE; - - callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - memcpy( callback_table + NtUserDriverCallbackFirst, kernel_callbacks, sizeof(kernel_callbacks) ); - return TRUE; + params.client_funcs = &client_funcs; + return !MACDRV_CALL(init, ¶ms); }
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 5953dc0e0d8..27ec82c8e92 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -162,6 +162,7 @@ static void macdrv_im_set_text(const macdrv_event *event)
size = offsetof(struct ime_set_text_params, text[length]); if (!(params = malloc(size))) return; + params->cbparams.func = (ULONG_PTR)client_funcs.ime_set_text; params->hwnd = HandleToUlong(hwnd); params->data = (UINT_PTR)event->im_set_text.data; params->cursor_pos = event->im_set_text.cursor_pos; @@ -170,7 +171,7 @@ static void macdrv_im_set_text(const macdrv_event *event) if (length) CFStringGetCharacters(event->im_set_text.text, CFRangeMake(0, length), params->text);
- macdrv_client_func(client_func_ime_set_text, params, size); + macdrv_client_func(¶ms->cbparams, sizeof(params)); }
/*********************************************************************** @@ -229,13 +230,14 @@ static BOOL query_drag_drop(macdrv_query *query) return FALSE; }
+ params.cbparams.func = (ULONG_PTR)client_funcs.dnd_query_drop; params.hwnd = HandleToUlong(hwnd); params.effect = drag_operations_to_dropeffects(query->drag_drop.op); params.x = query->drag_drop.x + data->whole_rect.left; params.y = query->drag_drop.y + data->whole_rect.top; params.handle = (UINT_PTR)query->drag_drop.pasteboard; release_win_data(data); - return macdrv_client_func(client_func_dnd_query_drop, ¶ms, sizeof(params)); + return macdrv_client_func(¶ms.cbparams, sizeof(params)); }
/************************************************************************** @@ -244,8 +246,9 @@ static BOOL query_drag_drop(macdrv_query *query) static BOOL query_drag_exited(macdrv_query *query) { struct dnd_query_exited_params params; + params.cbparams.func = (ULONG_PTR)client_funcs.dnd_query_exited; params.hwnd = HandleToUlong(macdrv_get_window_hwnd(query->window)); - return macdrv_client_func(client_func_dnd_query_exited, ¶ms, sizeof(params)); + return macdrv_client_func(¶ms.cbparams, sizeof(params)); }
@@ -265,6 +268,7 @@ static BOOL query_drag_operation(macdrv_query *query) return FALSE; }
+ params.cbparams.func = (ULONG_PTR)client_funcs.dnd_query_drag; params.hwnd = HandleToUlong(hwnd); params.effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops); params.x = query->drag_operation.x + data->whole_rect.left; @@ -272,7 +276,7 @@ static BOOL query_drag_operation(macdrv_query *query) params.handle = (UINT_PTR)query->drag_operation.pasteboard; release_win_data(data);
- effect = macdrv_client_func(client_func_dnd_query_drag, ¶ms, sizeof(params)); + effect = macdrv_client_func(¶ms.cbparams, sizeof(params)); if (!effect) return FALSE;
query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, @@ -297,12 +301,13 @@ BOOL query_ime_char_rect(macdrv_query* query) TRACE_(imm)("win %p/%p himc %p range %ld-%ld\n", hwnd, query->window, himc, range->location, range->length);
+ params.cbparams.func = (ULONG_PTR)client_funcs.ime_query_char_rect; params.hwnd = HandleToUlong(hwnd); params.data = (UINT_PTR)himc; params.result = (UINT_PTR)&result; params.location = range->location; params.length = range->length; - ret = macdrv_client_func(client_func_ime_query_char_rect, ¶ms, sizeof(params)); + ret = macdrv_client_func(¶ms.cbparams, sizeof(params)); *range = CFRangeMake(result.location, result.length); *rect = cgrect_from_rect(result.rect);
diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index 857684db9c2..a21ca353943 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -256,7 +256,8 @@ CFArrayRef create_app_icon_images(void)
TRACE("()\n");
- macdrv_client_func(client_func_app_icon, ¶ms, sizeof(params)); + params.cbparams.func = (ULONG_PTR)client_funcs.app_icon; + macdrv_client_func(¶ms.cbparams, sizeof(params));
if (!icons.count) return NULL;
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 281d49c1e9a..ad944f4cd8f 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -35,6 +35,7 @@ #include "wine/gdi_driver.h" #include "unixlib.h"
+extern struct macdrv_client_funcs client_funcs;
extern BOOL skip_single_buffer_flushes DECLSPEC_HIDDEN; extern BOOL allow_vsync DECLSPEC_HIDDEN; @@ -279,8 +280,7 @@ extern NTSTATUS macdrv_dnd_retain(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_ime_process_text_input(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN;
-extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params, - ULONG size) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_client_func(const struct user32_callback_params *cbparams, ULONG size) DECLSPEC_HIDDEN;
/* user helpers */
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index eeed9a4bcbe..0b70ca2cc50 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -42,6 +42,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
C_ASSERT(NUM_EVENT_TYPES <= sizeof(macdrv_event_mask) * 8);
+struct macdrv_client_funcs client_funcs; + int topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN; int capture_displays_for_fullscreen = 0; BOOL skip_single_buffer_flushes = FALSE; @@ -437,6 +439,8 @@ static NTSTATUS macdrv_init(void *arg) if (status != noErr || !(attributes & sessionHasGraphicAccess)) return STATUS_UNSUCCESSFUL;
+ client_funcs = *params->client_funcs; + init_win_context(); setup_options(); load_strings(params->strings); @@ -597,11 +601,11 @@ BOOL macdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, }
-NTSTATUS macdrv_client_func(enum macdrv_client_funcs id, const void *params, ULONG size) +NTSTATUS macdrv_client_func(const struct user32_callback_params *cbparams, ULONG size) { void *ret_ptr; ULONG ret_len; - return KeUserModeCallback(id, params, size, &ret_ptr, &ret_len); + return KeUserModeCallback(NtUserDispatchCallback, cbparams, size, &ret_ptr, &ret_len); }
diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index 07f0da4a6f3..e699fde0f44 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -79,9 +79,22 @@ struct localized_string UINT64 str; };
+/* driver client callbacks called through NtUserDispatchCallback interface */ +struct macdrv_client_funcs +{ + user32_callback_func app_icon; + user32_callback_func app_quit_request; + user32_callback_func dnd_query_drag; + user32_callback_func dnd_query_drop; + user32_callback_func dnd_query_exited; + user32_callback_func ime_query_char_rect; + user32_callback_func ime_set_text; +}; + struct init_params { struct localized_string *strings; + const struct macdrv_client_funcs *client_funcs; };
/* macdrv_notify_icon params */ @@ -97,19 +110,6 @@ struct quit_result_params int result; };
-/* driver client callbacks exposed with KernelCallbackTable interface */ -enum macdrv_client_funcs -{ - client_func_app_icon = NtUserDriverCallbackFirst, - client_func_app_quit_request, - client_func_dnd_query_drag, - client_func_dnd_query_drop, - client_func_dnd_query_exited, - client_func_ime_query_char_rect, - client_func_ime_set_text, - client_func_last -}; - /* macdrv_app_icon result */ struct app_icon_entry { @@ -129,18 +129,21 @@ struct app_icon_result /* macdrv_app_icon params */ struct app_icon_params { + struct user32_callback_params cbparams; UINT64 result; /* FIXME: Use NtCallbackReturn instead */ };
/* macdrv_app_quit_request params */ struct app_quit_request_params { + struct user32_callback_params cbparams; UINT flags; };
/* macdrv_dnd_query_drag params */ struct dnd_query_drag_params { + struct user32_callback_params cbparams; UINT32 hwnd; UINT32 effect; INT32 x; @@ -151,6 +154,7 @@ struct dnd_query_drag_params /* macdrv_dnd_query_drop params */ struct dnd_query_drop_params { + struct user32_callback_params cbparams; UINT32 hwnd; UINT32 effect; INT32 x; @@ -161,6 +165,7 @@ struct dnd_query_drop_params /* macdrv_dnd_query_exited params */ struct dnd_query_exited_params { + struct user32_callback_params cbparams; UINT32 hwnd; };
@@ -175,6 +180,7 @@ struct ime_query_char_rect_result /* macdrv_ime_query_char_rect params */ struct ime_query_char_rect_params { + struct user32_callback_params cbparams; UINT32 hwnd; UINT32 location; UINT64 data; @@ -185,6 +191,7 @@ struct ime_query_char_rect_params /* macdrv_ime_set_text params */ struct ime_set_text_params { + struct user32_callback_params cbparams; UINT32 hwnd; UINT32 cursor_pos; UINT64 data; @@ -196,5 +203,3 @@ static inline void *param_ptr(UINT64 param) { return (void *)(UINT_PTR)param; } - -C_ASSERT(client_func_last <= NtUserDriverCallbackLast + 1); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 896efb6a68e..61a686dd8a6 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2670,7 +2670,8 @@ void macdrv_app_quit_requested(const macdrv_event *event) if (event->app_quit_requested.reason == QUIT_REASON_LOGOUT) params.flags = ENDSESSION_LOGOFF;
- macdrv_client_func(client_func_app_quit_request, ¶ms, sizeof(params)); + params.cbparams.func = (ULONG_PTR)client_funcs.app_quit_request; + macdrv_client_func(¶ms.cbparams, sizeof(params)); }
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winex11.drv/clipboard.c | 89 ++++++++++++++++++++++++++--------- dlls/winex11.drv/event.c | 28 ++++++----- dlls/winex11.drv/unixlib.h | 5 ++ dlls/winex11.drv/x11drv.h | 6 ++- dlls/winex11.drv/x11drv_dll.h | 2 +- dlls/winex11.drv/xdnd.c | 5 +- 6 files changed, 95 insertions(+), 40 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 959b59825e1..2ee4e4bbc42 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1046,12 +1046,12 @@ static void *import_text_html( Atom type, const void *data, size_t size, size_t
/************************************************************************** - * file_list_to_drop_files + * file_list_to_post_drop_params */ -void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) +struct dnd_post_drop_params *file_list_to_post_drop_params( const void *data, size_t size, size_t *ret_size ) { size_t buf_size = 4096, path_size; - DROPFILES *drop = NULL; + struct dnd_post_drop_params *ret = NULL; const char *ptr; WCHAR *path;
@@ -1063,44 +1063,43 @@ void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size )
if (!path) continue;
- if (!drop) + if (!ret) { - if (!(drop = malloc( buf_size ))) return NULL; + DROPFILES *drop; + if (!(ret = malloc( FIELD_OFFSET( struct dnd_post_drop_params, drop_files[buf_size] ) ))) return NULL; + drop = (void*)ret->drop_files; drop->pFiles = sizeof(*drop); drop->pt.x = drop->pt.y = 0; drop->fNC = FALSE; drop->fWide = TRUE; - *ret_size = sizeof(*drop); + *ret_size = FIELD_OFFSET( struct dnd_post_drop_params, drop_files[sizeof(*drop)] ); }
path_size = (lstrlenW( path ) + 1) * sizeof(WCHAR); if (*ret_size + path_size > buf_size - sizeof(WCHAR)) { void *new_buf; - if (!(new_buf = realloc( drop, buf_size * 2 + path_size ))) + if (!(new_buf = realloc( ret, FIELD_OFFSET( struct dnd_post_drop_params, drop_files[buf_size * 2 + path_size] ) ))) { free( path ); continue; } buf_size = buf_size * 2 + path_size; - drop = new_buf; + ret = new_buf; }
- memcpy( (char *)drop + *ret_size, path, path_size ); + memcpy( (char *)ret + *ret_size, path, path_size ); *ret_size += path_size; }
- if (!drop) return NULL; - *(WCHAR *)((char *)drop + *ret_size) = 0; + if (!ret) return NULL; + *(WCHAR *)((char *)ret + *ret_size) = 0; *ret_size += sizeof(WCHAR); - return drop; + return ret; }
-/************************************************************************** - * uri_list_to_drop_files - */ -void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) +static void *uri_list_to_dos_paths( const void *data, size_t size, size_t *ret_size ) { const char *uriList = data; char *uri; @@ -1110,7 +1109,6 @@ void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) int capacity = 4096; int start = 0; int end = 0; - DROPFILES *dropFiles = NULL;
if (!(out = malloc( capacity * sizeof(WCHAR) ))) return 0;
@@ -1155,9 +1153,28 @@ void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) start = end + 2; end = start; } - if (out && end >= size) + if (out) + out[total] = '\0'; + if (out && end < size) { - *ret_size = sizeof(DROPFILES) + (total + 1) * sizeof(WCHAR); + free( out ); + out = NULL; + } + *ret_size = (total + 1) * sizeof(WCHAR); + return out; +} + + +static void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) +{ + DROPFILES *dropFiles = NULL; + size_t dos_paths_size = 0; + WCHAR *dos_paths; + + dos_paths = uri_list_to_dos_paths( data, size, &dos_paths_size ); + if (dos_paths) + { + *ret_size = sizeof(DROPFILES) + dos_paths_size; if ((dropFiles = malloc( *ret_size ))) { dropFiles->pFiles = sizeof(DROPFILES); @@ -1165,15 +1182,43 @@ void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) dropFiles->pt.y = 0; dropFiles->fNC = 0; dropFiles->fWide = TRUE; - out[total] = '\0'; - memcpy( (char*)dropFiles + dropFiles->pFiles, out, (total + 1) * sizeof(WCHAR) ); + memcpy( (char*)dropFiles + dropFiles->pFiles, dos_paths, dos_paths_size ); } } - free( out ); + free( dos_paths ); return dropFiles; }
+/************************************************************************** + * uri_list_to_post_drop_params + */ +struct dnd_post_drop_params *uri_list_to_post_drop_params( const void *data, size_t size, size_t *ret_size ) +{ + struct dnd_post_drop_params *ret = NULL; + size_t dos_paths_size = 0; + WCHAR *dos_paths; + + dos_paths = uri_list_to_dos_paths( data, size, &dos_paths_size ); + if (dos_paths) + { + *ret_size = FIELD_OFFSET( struct dnd_post_drop_params, drop_files[sizeof(DROPFILES) + dos_paths_size] ); + if ((ret = malloc( *ret_size ))) + { + DROPFILES *dropFiles = (void*)ret->drop_files; + dropFiles->pFiles = sizeof(DROPFILES); + dropFiles->pt.x = 0; + dropFiles->pt.y = 0; + dropFiles->fNC = 0; + dropFiles->fWide = TRUE; + memcpy( (char*)dropFiles + dropFiles->pFiles, dos_paths, dos_paths_size ); + } + } + free( dos_paths ); + return ret; +} + + /************************************************************************** * import_text_uri_list * diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 1ae39eb9edf..55594034a49 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1469,8 +1469,9 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) return hQueryWnd; }
-static void post_drop( HWND hwnd, DROPFILES *drop, ULONG size ) +static void post_drop( HWND hwnd, struct dnd_post_drop_params *params, ULONG size ) { + DROPFILES *drop = (void*)params->drop_files; drop->fWide = HandleToUlong( hwnd ); /* abuse fWide to pass window handle */ x11drv_client_func( client_func_dnd_post_drop, drop, size ); } @@ -1519,14 +1520,14 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if (!aux_long && p_data) /* don't bother if > 64K */ { - DROPFILES *drop; - size_t drop_size; + struct dnd_post_drop_params *params; + size_t params_size;
- drop = file_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size ); - if (drop) + params = file_list_to_post_drop_params( p_data, get_property_size( format, data_length ), ¶ms_size ); + if (params) { - post_drop( hWnd, drop, drop_size ); - free( drop ); + post_drop( hWnd, params, params_size ); + free( params ); } }
@@ -1548,7 +1549,6 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) unsigned long aux_long; unsigned char *p_data = NULL; /* property data */ int x, y; - DROPFILES *drop; int format; union { Atom atom_aux; @@ -1569,11 +1569,13 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
if (!aux_long && p_data) /* don't bother if > 64K */ { - size_t drop_size; - drop = uri_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size ); + struct dnd_post_drop_params *params; + size_t params_size; + params = uri_list_to_post_drop_params( p_data, get_property_size( format, data_length ), ¶ms_size );
- if (drop) + if (params) { + DROPFILES *drop = (void*)params->drop_files; XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux, &x, &y, &u.i, &u.i, &u.u); drop->pt = root_to_virtual_screen( x, y ); @@ -1588,8 +1590,8 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) release_win_data( win_data ); }
- post_drop( hWnd, drop, drop_size ); - free( drop ); + post_drop( hWnd, params, params_size ); + free( params ); } } if (p_data) XFree( p_data ); diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 7dc1d9f0ca7..e7838d43569 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -127,6 +127,11 @@ struct dnd_position_event_params DWORD effect; };
+struct dnd_post_drop_params +{ + char drop_files[1]; +}; + struct systray_change_owner_params { UINT64 event_handle; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 893099489e3..a29d830a2c5 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -663,8 +663,10 @@ extern void change_systray_owner( Display *display, Window systray_window ) DECL extern HWND create_foreign_window( Display *display, Window window ) DECLSPEC_HIDDEN; extern BOOL update_clipboard( HWND hwnd ) DECLSPEC_HIDDEN; extern void init_win_context(void) DECLSPEC_HIDDEN; -extern void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) DECLSPEC_HIDDEN; -extern void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) DECLSPEC_HIDDEN; +extern struct dnd_post_drop_params *file_list_to_post_drop_params( const void *data, size_t size, + size_t *ret_size ) DECLSPEC_HIDDEN; +extern struct dnd_post_drop_params *uri_list_to_post_drop_params( const void *data, size_t size, + size_t *ret_size ) DECLSPEC_HIDDEN;
static inline void mirror_rect( const RECT *window_rect, RECT *rect ) { diff --git a/dlls/winex11.drv/x11drv_dll.h b/dlls/winex11.drv/x11drv_dll.h index 047bb430d39..a2c46848db1 100644 --- a/dlls/winex11.drv/x11drv_dll.h +++ b/dlls/winex11.drv/x11drv_dll.h @@ -29,7 +29,7 @@
extern NTSTATUS WINAPI x11drv_dnd_enter_event( void *params, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI x11drv_dnd_position_event( void *params, ULONG size ) DECLSPEC_HIDDEN; -extern NTSTATUS WINAPI x11drv_dnd_post_drop( void *data, ULONG size ) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI x11drv_dnd_post_drop( void *params, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI x11drv_ime_set_composition_string( void *params, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI x11drv_ime_set_result( void *params, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI x11drv_systray_change_owner( void *params, ULONG size ) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 86a28ad7bb6..0374d6efcd6 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -718,15 +718,16 @@ static IDataObjectVtbl xdndDataObjectVtbl =
static IDataObject XDNDDataObject = { &xdndDataObjectVtbl };
-NTSTATUS WINAPI x11drv_dnd_post_drop( void *data, ULONG size ) +NTSTATUS WINAPI x11drv_dnd_post_drop( void *arg, ULONG size ) { + struct dnd_post_drop_params *params = arg; HDROP handle;
if ((handle = GlobalAlloc( GMEM_SHARE, size ))) { DROPFILES *ptr = GlobalLock( handle ); HWND hwnd; - memcpy( ptr, data, size ); + memcpy( ptr, params->drop_files, size - FIELD_OFFSET( struct dnd_post_drop_params, drop_files[0] ) ); hwnd = UlongToHandle( ptr->fWide ); ptr->fWide = TRUE; GlobalUnlock( handle );
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winex11.drv/ime.c | 6 ++++-- dlls/winex11.drv/unixlib.h | 5 +++++ dlls/winex11.drv/xim.c | 10 +++++----- 3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/winex11.drv/ime.c b/dlls/winex11.drv/ime.c index 9c0894717ad..5d4d4e031cd 100644 --- a/dlls/winex11.drv/ime.c +++ b/dlls/winex11.drv/ime.c @@ -924,9 +924,10 @@ NTSTATUS WINAPI x11drv_ime_set_composition_string( void *param, ULONG size ) return ImeSetCompositionString(FROM_X11, SCS_SETSTR, param, size, NULL, 0); }
-NTSTATUS WINAPI x11drv_ime_set_result( void *params, ULONG len ) +NTSTATUS WINAPI x11drv_ime_set_result( void *arg, ULONG len ) { - WCHAR *lpResult = params; + struct ime_set_result_params *params = arg; + WCHAR *lpResult = params->data; HIMC imc; LPINPUTCONTEXT lpIMC; HIMCC newCompStr; @@ -934,6 +935,7 @@ NTSTATUS WINAPI x11drv_ime_set_result( void *params, ULONG len ) BOOL inComp; HWND focus;
+ len -= FIELD_OFFSET( struct ime_set_result_params, data[0] ); len /= sizeof(WCHAR); if ((focus = GetFocus())) x11drv_ime_update_association( HandleToUlong( focus )); diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index e7838d43569..10cfe82cc51 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -136,3 +136,8 @@ struct systray_change_owner_params { UINT64 event_handle; }; + +struct ime_set_result_params +{ + WCHAR data[1]; +}; diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 9f238e0cb83..ef1ef515047 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -117,16 +117,16 @@ static void X11DRV_ImmSetInternalString(UINT offset, UINT selLength, LPWSTR lpCo
void X11DRV_XIMLookupChars( const char *str, UINT count ) { - WCHAR *output; + struct ime_set_result_params *params; DWORD len;
TRACE("%p %u\n", str, count);
- if (!(output = malloc( count * sizeof(WCHAR) ))) return; - len = ntdll_umbstowcs( str, count, output, count ); + if (!(params = malloc( FIELD_OFFSET( struct ime_set_result_params, data[count] ) ))) return; + len = ntdll_umbstowcs( str, count, params->data, count );
- x11drv_client_func( client_func_ime_set_result, output, len * sizeof(WCHAR) ); - free( output ); + x11drv_client_func( client_func_ime_set_result, params, FIELD_OFFSET( struct ime_set_result_params, data[len] ) ); + free( params ); }
static BOOL xic_preedit_state_notify( XIC xic, XPointer user, XPointer arg )
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winex11.drv/dllmain.c | 15 +++------------ dlls/winex11.drv/event.c | 20 ++++++++++++-------- dlls/winex11.drv/unixlib.h | 34 +++++++++++++++++++--------------- dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/x11drv_main.c | 14 ++++++++++---- dlls/winex11.drv/xim.c | 30 +++++++++++++++++++----------- 6 files changed, 65 insertions(+), 52 deletions(-)
diff --git a/dlls/winex11.drv/dllmain.c b/dlls/winex11.drv/dllmain.c index 500a4a6bc44..4ce8601de9a 100644 --- a/dlls/winex11.drv/dllmain.c +++ b/dlls/winex11.drv/dllmain.c @@ -45,8 +45,7 @@ static NTSTATUS WINAPI x11drv_callback( void *arg, ULONG size ) return callback_funcs[params->id]( params->arg ); }
-typedef NTSTATUS (WINAPI *kernel_callback)( void *params, ULONG size ); -static const kernel_callback kernel_callbacks[] = +static const struct x11drv_client_funcs client_funcs = { x11drv_callback, x11drv_dnd_enter_event, @@ -57,28 +56,20 @@ static const kernel_callback kernel_callbacks[] = x11drv_systray_change_owner, };
-C_ASSERT( NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func_last ); - - BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) { - void **callback_table; struct init_params params = { foreign_window_proc, &show_systray, + &client_funcs, };
if (reason != DLL_PROCESS_ATTACH) return TRUE;
DisableThreadLibraryCalls( instance ); x11drv_module = instance; - if (__wine_init_unix_call()) return FALSE; - if (X11DRV_CALL( init, ¶ms )) return FALSE; - - callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - memcpy( callback_table + NtUserDriverCallbackFirst, kernel_callbacks, sizeof(kernel_callbacks) ); - return TRUE; + return !__wine_init_unix_call() && !X11DRV_CALL( init, ¶ms ); }
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 55594034a49..695e6114a2a 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -503,7 +503,7 @@ DWORD EVENT_x11_time_to_win32_time(Time time) } else { - /* If we got an event in the 'future', then our clock is clearly wrong. + /* If we got an event in the 'future', then our clock is clearly wrong. If we got it more than 10000 ms in the future, then it's most likely that the clock has wrapped. */
@@ -609,8 +609,9 @@ static void handle_manager_message( HWND hwnd, XClientMessageEvent *event )
TRACE( "new owner %lx\n", event->data.l[2] );
+ params.cbparams.func = (ULONG_PTR)client_funcs.systray_change_owner; params.event_handle = (UINT_PTR)event; - x11drv_client_func( client_func_systray_change_owner, ¶ms, sizeof(params) ); + x11drv_client_func( ¶ms.cbparams, sizeof(params) ); } }
@@ -720,7 +721,7 @@ static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event ) { XClientMessageEvent xev; xev = *event; - + TRACE("NET_WM Ping\n"); xev.window = DefaultRootWindow(xev.display); XSendEvent(xev.display, xev.window, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&xev); @@ -1439,7 +1440,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) RECT tempRect;
if (!NtUserIsWindowEnabled(hQueryWnd)) return 0; - + NtUserGetWindowRect(hQueryWnd, &tempRect);
if(!PtInRect(&tempRect, *lpPt)) return 0; @@ -1463,7 +1464,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) }
if(!(NtUserGetWindowLongW( hQueryWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return 0; - + NtUserScreenToClient( hQueryWnd, lpPt );
return hQueryWnd; @@ -1472,8 +1473,9 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) static void post_drop( HWND hwnd, struct dnd_post_drop_params *params, ULONG size ) { DROPFILES *drop = (void*)params->drop_files; + params->cbparams.func = (ULONG_PTR)client_funcs.dnd_post_drop; drop->fWide = HandleToUlong( hwnd ); /* abuse fWide to pass window handle */ - x11drv_client_func( client_func_dnd_post_drop, drop, size ); + x11drv_client_func( ¶ms->cbparams, size ); }
/********************************************************************** @@ -1739,7 +1741,8 @@ static void handle_xdnd_enter_event( HWND hWnd, XClientMessageEvent *event ) xdndtypes, count, &size ); if (data) { - x11drv_client_func( client_func_dnd_enter_event, data, size ); + data->cbparams.func = (ULONG_PTR)client_funcs.dnd_enter_event; + x11drv_client_func( &data->cbparams, size ); free( data ); }
@@ -1790,11 +1793,12 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event ) XClientMessageEvent e; UINT effect;
+ params.cbparams.func = (ULONG_PTR)client_funcs.dnd_position_event; params.hwnd = HandleToUlong( hwnd ); params.point = root_to_virtual_screen( event->data.l[2] >> 16, event->data.l[2] & 0xFFFF ); params.effect = effect = xdnd_action_to_drop_effect( event->data.l[4] );
- effect = x11drv_client_func( client_func_dnd_position_event, ¶ms, sizeof(params) ); + effect = x11drv_client_func( ¶ms.cbparams, sizeof(params) );
TRACE( "actionRequested(%ld) chosen(0x%x) at x(%d),y(%d)\n", event->data.l[4], effect, (int)params.point.x, (int)params.point.y ); diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 10cfe82cc51..98548d25642 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -45,11 +45,24 @@ struct create_desktop_params UINT height; };
+/* driver client callbacks called through NtUserDispatchCallback interface */ +struct x11drv_client_funcs +{ + user32_callback_func callback; + user32_callback_func dnd_enter_event; + user32_callback_func dnd_position_event; + user32_callback_func dnd_post_drop; + user32_callback_func ime_set_composition_string; + user32_callback_func ime_set_result; + user32_callback_func systray_change_owner; +}; + /* x11drv_init params */ struct init_params { WNDPROC foreign_window_proc; BOOL *show_systray; + const struct x11drv_client_funcs *client_funcs; };
struct systray_dock_params @@ -76,21 +89,6 @@ struct xim_preedit_state_params BOOL open; };
-/* driver client callbacks exposed with KernelCallbackTable interface */ -enum x11drv_client_funcs -{ - client_func_callback = NtUserDriverCallbackFirst, - client_func_dnd_enter_event, - client_func_dnd_position_event, - client_func_dnd_post_drop, - client_func_ime_set_composition_string, - client_func_ime_set_result, - client_func_systray_change_owner, - client_func_last -}; - -C_ASSERT( client_func_last <= NtUserDriverCallbackLast + 1 ); - /* simplified interface for client callbacks requiring only a single UINT parameter */ enum client_callback { @@ -107,6 +105,7 @@ enum client_callback /* x11drv_callback params */ struct client_callback_params { + struct user32_callback_params cbparams; UINT id; UINT arg; }; @@ -114,6 +113,7 @@ struct client_callback_params /* x11drv_dnd_enter_event and x11drv_dnd_post_drop params */ struct format_entry { + struct user32_callback_params cbparams; UINT format; UINT size; char data[1]; @@ -122,6 +122,7 @@ struct format_entry /* x11drv_dnd_position_event params */ struct dnd_position_event_params { + struct user32_callback_params cbparams; ULONG hwnd; POINT point; DWORD effect; @@ -129,15 +130,18 @@ struct dnd_position_event_params
struct dnd_post_drop_params { + struct user32_callback_params cbparams; char drop_files[1]; };
struct systray_change_owner_params { + struct user32_callback_params cbparams; UINT64 event_handle; };
struct ime_set_result_params { + struct user32_callback_params cbparams; WCHAR data[1]; }; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a29d830a2c5..96d512cd1b8 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -425,6 +425,7 @@ static inline size_t get_property_size( int format, unsigned long count ) return count * (format / 8); }
+extern struct x11drv_client_funcs client_funcs DECLSPEC_HIDDEN; extern XVisualInfo default_visual DECLSPEC_HIDDEN; extern XVisualInfo argb_visual DECLSPEC_HIDDEN; extern Colormap default_colormap DECLSPEC_HIDDEN; @@ -851,8 +852,7 @@ extern NTSTATUS x11drv_tablet_info( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS x11drv_xim_preedit_state( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS x11drv_xim_reset( void *arg ) DECLSPEC_HIDDEN;
-extern NTSTATUS x11drv_client_func( enum x11drv_client_funcs func, const void *params, - ULONG size ) DECLSPEC_HIDDEN; +extern NTSTATUS x11drv_client_func( const struct user32_callback_params *cbparams, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS x11drv_client_call( enum client_callback func, UINT arg ) DECLSPEC_HIDDEN;
/* GDI helpers */ diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index aa39ecf2228..335609b2a35 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -60,6 +60,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DECLARE_DEBUG_CHANNEL(synchronous); WINE_DECLARE_DEBUG_CHANNEL(winediag);
+struct x11drv_client_funcs client_funcs; + XVisualInfo default_visual = { 0 }; XVisualInfo argb_visual = { 0 }; Colormap default_colormap = None; @@ -668,6 +670,8 @@ static NTSTATUS x11drv_init( void *arg ) dlopen( SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL ); #endif
+ client_funcs = *params->client_funcs; + setup_options();
/* Open display */ @@ -1303,18 +1307,18 @@ done: return status; }
-NTSTATUS x11drv_client_func( enum x11drv_client_funcs id, const void *params, ULONG size ) +NTSTATUS x11drv_client_func( const struct user32_callback_params *cbparams, ULONG size ) { void *ret_ptr; ULONG ret_len; - return KeUserModeCallback( id, params, size, &ret_ptr, &ret_len ); + return KeUserModeCallback( NtUserDispatchCallback, cbparams, size, &ret_ptr, &ret_len ); }
NTSTATUS x11drv_client_call( enum client_callback func, UINT arg ) { - struct client_callback_params params = { .id = func, .arg = arg }; - return x11drv_client_func( client_func_callback, ¶ms, sizeof(params) ); + struct client_callback_params params = { { (ULONG_PTR)client_funcs.callback }, .id = func, .arg = arg }; + return x11drv_client_func( ¶ms.cbparams, sizeof(params) ); }
@@ -1346,11 +1350,13 @@ static NTSTATUS x11drv_wow64_init( void *arg ) { ULONG foreign_window_proc; ULONG show_systray; + ULONG client_funcs; } *params32 = arg; struct init_params params;
params.foreign_window_proc = UlongToPtr( params32->foreign_window_proc ); params.show_systray = UlongToPtr( params32->show_systray ); + params.client_funcs = UlongToPtr( params32->client_funcs ); return x11drv_init( ¶ms ); }
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index ef1ef515047..19d57b7c968 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -44,9 +44,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(xim);
BOOL ximInComposeMode=FALSE;
+struct CompStringType +{ + struct user32_callback_params cbparams; + BYTE data[1]; +}; + /* moved here from imm32 for dll separation */ static DWORD dwCompStringLength = 0; -static LPBYTE CompositionString = NULL; +static struct CompStringType *CompositionString = NULL; static DWORD dwCompStringSize = 0;
#define STYLE_OFFTHESPOT (XIMPreeditArea | XIMStatusArea) @@ -88,13 +94,15 @@ static void X11DRV_ImmSetInternalString(UINT offset, UINT selLength, LPWSTR lpCo unsigned int byte_offset = offset * sizeof(WCHAR); unsigned int byte_selection = selLength * sizeof(WCHAR); int byte_expansion = byte_length - byte_selection; - LPBYTE ptr_new; + size_t new_size = FIELD_OFFSET( struct CompStringType, data[dwCompStringSize + byte_expansion] ); + struct CompStringType *ptr_new; + BYTE *data_ptr;
TRACE("( %i, %i, %p, %d):\n", offset, selLength, lpComp, len );
if (byte_expansion + dwCompStringLength >= dwCompStringSize) { - ptr_new = realloc( CompositionString, dwCompStringSize + byte_expansion ); + ptr_new = realloc( CompositionString, new_size ); if (ptr_new == NULL) { ERR("Couldn't expand composition string buffer\n"); @@ -105,14 +113,14 @@ static void X11DRV_ImmSetInternalString(UINT offset, UINT selLength, LPWSTR lpCo dwCompStringSize += byte_expansion; }
- ptr_new = CompositionString + byte_offset; - memmove(ptr_new + byte_length, ptr_new + byte_selection, + CompositionString->cbparams.func = (ULONG_PTR)client_funcs.ime_set_composition_string; + data_ptr = &CompositionString->data[byte_offset]; + memmove(data_ptr + byte_length, data_ptr + byte_selection, dwCompStringLength - byte_offset - byte_selection); - if (lpComp) memcpy(ptr_new, lpComp, byte_length); + if (lpComp) memcpy(data_ptr, lpComp, byte_length); dwCompStringLength += byte_expansion;
- x11drv_client_func( client_func_ime_set_composition_string, - CompositionString, dwCompStringLength ); + x11drv_client_func( &CompositionString->cbparams, new_size ); }
void X11DRV_XIMLookupChars( const char *str, UINT count ) @@ -123,9 +131,10 @@ void X11DRV_XIMLookupChars( const char *str, UINT count ) TRACE("%p %u\n", str, count);
if (!(params = malloc( FIELD_OFFSET( struct ime_set_result_params, data[count] ) ))) return; + params->cbparams.func = (ULONG_PTR)client_funcs.ime_set_result; len = ntdll_umbstowcs( str, count, params->data, count );
- x11drv_client_func( client_func_ime_set_result, params, FIELD_OFFSET( struct ime_set_result_params, data[len] ) ); + x11drv_client_func( ¶ms->cbparams, FIELD_OFFSET( struct ime_set_result_params, data[len] ) ); free( params ); }
@@ -170,8 +179,7 @@ static int xic_preedit_done( XIC xic, XPointer user, XPointer arg ) TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg );
ximInComposeMode = FALSE; - if (dwCompStringSize) - free( CompositionString ); + free( CompositionString ); dwCompStringSize = 0; dwCompStringLength = 0; CompositionString = NULL;
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/wow64win/user.c | 61 -------------------------------------------- include/ntuser.h | 3 --- 2 files changed, 64 deletions(-)
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 2b82071be49..0b2c22e560e 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1023,56 +1023,6 @@ static NTSTATUS WINAPI wow64_NtUserThunkLock( void *arg, ULONG size ) return dispatch_callback( NtUserThunkLock, arg, size ); }
-static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst0( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 0, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst1( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 1, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst2( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 2, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst3( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 3, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst4( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 4, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst5( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 5, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst6( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 6, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst7( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 7, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst8( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 8, arg, size ); -} - -static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst9( void *arg, ULONG size ) -{ - return dispatch_callback( NtUserDriverCallbackFirst + 9, arg, size ); -} - user_callback user_callbacks[] = { /* user32 callbacks */ @@ -1099,17 +1049,6 @@ user_callback user_callbacks[] = /* win16 hooks */ wow64_NtUserCallFreeIcon, wow64_NtUserThunkLock, - /* Driver-specific callbacks */ - wow64_NtUserDriverCallbackFirst0, - wow64_NtUserDriverCallbackFirst1, - wow64_NtUserDriverCallbackFirst2, - wow64_NtUserDriverCallbackFirst3, - wow64_NtUserDriverCallbackFirst4, - wow64_NtUserDriverCallbackFirst5, - wow64_NtUserDriverCallbackFirst6, - wow64_NtUserDriverCallbackFirst7, - wow64_NtUserDriverCallbackFirst8, - wow64_NtUserDriverCallbackFirst9, };
C_ASSERT( ARRAYSIZE(user_callbacks) == NtUserCallCount ); diff --git a/include/ntuser.h b/include/ntuser.h index d283fe9a39e..d161012dad2 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -51,9 +51,6 @@ enum /* win16 hooks */ NtUserCallFreeIcon, NtUserThunkLock, - /* Driver-specific callbacks */ - NtUserDriverCallbackFirst, - NtUserDriverCallbackLast = NtUserDriverCallbackFirst + 9, NtUserCallCount };
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- include/ntuser.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/ntuser.h b/include/ntuser.h index d161012dad2..80f3cc15e2a 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -24,7 +24,10 @@ #include <imm.h> #include <winternl.h>
-/* KernelCallbackTable codes, not compatible with Windows */ +/* KernelCallbackTable codes, not compatible with Windows. + All of these functions must live inside user32.dll. Overwatch 2's + KiUserCallbackDispatcher hook verifies this and prevents the callback from + running if that check fails. */ enum { /* user32 callbacks */
``` videorenderer.c:1957: Test failed: Got height 492. videorenderer.c:1963: Test failed: Got height 492. videorenderer.c:1968: Test failed: Got window bottom 492. videorenderer.c:1984: Test failed: Got height 492. videorenderer.c:1990: Test failed: Got height 492. videorenderer.c:1995: Test failed: Got window bottom 492. ```
I did 10 runs of that test on my machine and can't reproduce that failure. Might be fvwm-specific or flaky.
Superseded by !6344 and !6354.
This merge request was closed by Alexandre Julliard.