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.
-- v10: 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: Do not store debug message callback in kernel callback table. 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 9af217bf5f1..d4ea1b44742 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 0ddbd710b6b..15e4796bab2 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 6cd41b51435..37b3dcab969 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 | 28 ++++++++++++++++++++++++++++ include/ntuser.h | 8 ++++++++ 3 files changed, 44 insertions(+)
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index 15e4796bab2..a6943bc9dc9 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" @@ -210,6 +212,11 @@ static DWORD WINAPI User32ThunkLock( DWORD *param, ULONG size ) return wow_handlers.thunk_lock( param ? *param : 0, size == sizeof(DWORD) ); }
+static NTSTATUS WINAPI User32DispatchCallback( const struct user32_callback_params *params, ULONG size ) +{ + return params->func( (void*)params, size ); +} + static const void *kernel_callback_table[NtUserCallCount] = { User32CallEnumDisplayMonitor, @@ -233,6 +240,7 @@ static const void *kernel_callback_table[NtUserCallCount] = User32UnpackDDEMessage, User32CallFreeIcon, User32ThunkLock, + User32DispatchCallback, };
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 256add62aab..48f34f01a40 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -328,6 +328,11 @@ struct unpack_dde_message_params32 char data[1]; };
+struct user32_callback_params32 +{ + ULONG func; +}; + static MSG *msg_32to64( MSG *msg, const MSG32 *msg32 ) { if (!msg32) return NULL; @@ -1008,6 +1013,28 @@ static NTSTATUS WINAPI wow64_NtUserUnpackDDEMessage( void *arg, ULONG size ) return TRUE; }
+static NTSTATUS WINAPI wow64_NtUserDispatchCallback( void *arg, ULONG size ) +{ + struct user32_callback_params *params = arg; + struct user32_callback_params32 *params32; + NTSTATUS status; + void *ret_ptr; + ULONG ret_len; + + size -= sizeof(*params); + if (!(params32 = Wow64AllocateTemp( sizeof(*params32) + size ))) + return 0; + + params32->func = (ULONG)(ULONG_PTR)params->func; + if (size) memcpy( params32 + 1, params + 1, size ); + + status = Wow64KiUserCallbackDispatcher( NtUserDispatchCallback, params32, size + sizeof(*params32), + &ret_ptr, &ret_len ); + params->func = (void*)(ULONG_PTR)params32->func; + if (size) memcpy( params + 1, params32 + 1, size ); + return NtCallbackReturn( ret_ptr, ret_len, status ); +} + static NTSTATUS WINAPI wow64_NtUserCallFreeIcon( void *arg, ULONG size ) { return dispatch_callback( NtUserCallFreeIcon, arg, size ); @@ -1108,6 +1135,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 5331b3d7400..081056d6384 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 +{ + user32_callback_func 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 | 27 ++++++++++++++++++--------- dlls/winevulkan/loader_thunks.h | 1 + dlls/winevulkan/make_vulkan | 3 +++ dlls/winevulkan/vulkan.c | 16 ++++++++++++---- dlls/winevulkan/vulkan_loader.h | 11 +++++++++++ dlls/winevulkan/vulkan_private.h | 2 ++ dlls/winevulkan/vulkan_thunks.c | 2 ++ dlls/wow64win/user.c | 15 --------------- include/ntuser.h | 3 --- 9 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index 20bd9d38c27..d140a35422f 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -89,6 +89,11 @@ static void *wine_vk_get_global_proc_addr(const char *name) return NULL; }
+static BOOL set_callback_functions(const struct vk_callback_funcs *funcs) +{ + return !vk_unix_call(unix_set_callback_functions, (void*)funcs); +} + static BOOL is_available_instance_function(VkInstance instance, const char *name) { struct is_available_instance_function_params params = { .instance = instance, .name = name }; @@ -611,21 +616,29 @@ 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 ) +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 BOOL WINAPI call_vulkan_debug_utils_callback( struct wine_vk_debug_utils_params *params, ULONG size ) +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); }
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved) +static const struct vk_callback_funcs callback_funcs = { - void **kernel_callback_table; + call_vulkan_debug_report_callback, + call_vulkan_debug_utils_callback, +};
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved) +{ TRACE("%p, %lu, %p\n", hinst, reason, reserved);
switch (reason) @@ -633,11 +646,7 @@ 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 set_callback_functions(&callback_funcs); } return TRUE; } diff --git a/dlls/winevulkan/loader_thunks.h b/dlls/winevulkan/loader_thunks.h index e79209cfb97..ae3db88febb 100644 --- a/dlls/winevulkan/loader_thunks.h +++ b/dlls/winevulkan/loader_thunks.h @@ -15,6 +15,7 @@ enum unix_call { unix_init, + unix_set_callback_functions, unix_is_available_instance_function, unix_is_available_device_function, unix_vkAcquireNextImage2KHR, diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index c7f422c3c64..cfde41db087 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -2442,6 +2442,7 @@ class VkGenerator(object): f.write("const unixlib_entry_t __wine_unix_call_funcs[] =\n") f.write("{\n") f.write(" init_vulkan,\n") + f.write(" vk_set_callback_functions,\n") f.write(" vk_is_available_instance_function,\n") f.write(" vk_is_available_device_function,\n") for vk_func in self.registry.funcs.values(): @@ -2459,6 +2460,7 @@ class VkGenerator(object): f.write("const unixlib_entry_t __wine_unix_call_funcs[] =\n") f.write("{\n") f.write(" init_vulkan,\n") + f.write(" vk_set_callback_functions,\n") f.write(" vk_is_available_instance_function,\n") f.write(" vk_is_available_device_function,\n") for vk_func in self.registry.funcs.values(): @@ -2655,6 +2657,7 @@ class VkGenerator(object): f.write("enum unix_call\n") f.write("{\n") f.write(" unix_init,\n") + f.write(" unix_set_callback_functions,\n") f.write(" unix_is_available_instance_function,\n") f.write(" unix_is_available_device_function,\n") for vk_func in self.registry.funcs.values(): diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 4868ac8858b..3c01f1cf8ac 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -119,6 +119,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; @@ -153,8 +154,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, sizeof(params), &ret_ptr, &ret_len );
free(object_name_infos);
@@ -181,6 +181,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; @@ -194,8 +195,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, sizeof(params), &ret_ptr, &ret_len ); }
static void wine_vk_physical_device_free(struct wine_phys_dev *phys_dev) @@ -1702,6 +1702,14 @@ VkResult wine_vkCreateRayTracingPipelinesNV(VkDevice handle, VkPipelineCache pip return res; }
+struct vk_callback_funcs callback_funcs; + +NTSTATUS vk_set_callback_functions(void *arg) +{ + callback_funcs = *(struct vk_callback_funcs*)arg; + return STATUS_SUCCESS; +} + NTSTATUS vk_is_available_instance_function(void *arg) { struct is_available_instance_function_params *params = arg; diff --git a/dlls/winevulkan/vulkan_loader.h b/dlls/winevulkan/vulkan_loader.h index 8e22fc1ee45..41fd921faff 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" @@ -109,8 +110,16 @@ void *wine_vk_get_instance_proc_addr(const char *name) DECLSPEC_HIDDEN;
/* debug callbacks params */
+struct vk_callback_funcs +{ + user32_callback_func call_vulkan_debug_report_callback; + user32_callback_func call_vulkan_debug_utils_callback; +}; + 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 adc067462ce..b345842f702 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -235,6 +235,8 @@ NTSTATUS init_vulkan(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI vk_direct_unix_call(unixlib_handle_t handle, unsigned int code, void *arg) DECLSPEC_HIDDEN;
+extern struct vk_callback_funcs callback_funcs; +NTSTATUS vk_set_callback_functions(void *arg) DECLSPEC_HIDDEN; NTSTATUS vk_is_available_instance_function(void *arg) DECLSPEC_HIDDEN; NTSTATUS vk_is_available_device_function(void *arg) DECLSPEC_HIDDEN;
diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index c01801f80e7..2d719be288d 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -21232,6 +21232,7 @@ BOOL wine_vk_is_type_wrapped(VkObjectType type) const unixlib_entry_t __wine_unix_call_funcs[] = { init_vulkan, + vk_set_callback_functions, vk_is_available_instance_function, vk_is_available_device_function, thunk64_vkAcquireNextImage2KHR, @@ -21757,6 +21758,7 @@ C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_count); const unixlib_entry_t __wine_unix_call_funcs[] = { init_vulkan, + vk_set_callback_functions, vk_is_available_instance_function, vk_is_available_device_function, thunk32_vkAcquireNextImage2KHR, diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 48f34f01a40..ddb3966a0b0 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1045,18 +1045,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" ); @@ -1139,9 +1127,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 081056d6384..1065b5e3e92 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 | 15 ++++++++++----- dlls/opengl32/unixlib.h | 9 +++++++++ dlls/opengl32/wgl.c | 10 +++++----- dlls/wow64win/user.c | 8 -------- include/ntuser.h | 2 -- include/wine/wgl_driver.h | 2 +- 8 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 78368ec6c2f..a77661684b9 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -796,10 +796,19 @@ 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)( struct wine_gl_debug_message_params *params,"; +print OUT " ULONG size );\n"; +print OUT "};\n\n"; + foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; @@ -818,6 +827,7 @@ foreach (sort keys %ext_functions)
print OUT "enum unix_funcs\n"; print OUT "{\n"; +print OUT " unix_wglInit,\n"; foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; @@ -936,6 +946,7 @@ print OUT "#include "wingdi.h"\n\n"; print OUT "#include "unixlib.h"\n\n"; print OUT "#include "opengl_ext.h"\n\n";
+print OUT "extern NTSTATUS wgl_wglInit( void *args ) DECLSPEC_HIDDEN;\n"; foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; @@ -970,6 +981,7 @@ foreach (sort keys %ext_functions)
print OUT "const unixlib_function_t __wine_unix_call_funcs[] =\n"; print OUT "{\n"; +print OUT " &wgl_wglInit,\n"; foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 86af754b278..be0caeed7eb 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13,6 +13,7 @@
#include "opengl_ext.h"
+extern NTSTATUS wgl_wglInit( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wgl_wglCopyContext( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wgl_wglCreateContext( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wgl_wglDeleteContext( void *args ) DECLSPEC_HIDDEN; @@ -24172,6 +24173,7 @@ static NTSTATUS ext_wglSwapIntervalEXT( void *args )
const unixlib_function_t __wine_unix_call_funcs[] = { + &wgl_wglInit, &wgl_wglCopyContext, &wgl_wglCreateContext, &wgl_wglDeleteContext, diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 4771205a47e..c56ddf43093 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -35,6 +35,8 @@
#include "wine/debug.h"
+static BOOL (*WINAPI call_opengl_debug_message_callback)( struct wine_gl_debug_message_params *params, ULONG size ); + struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; static struct wgl_handle *next_free; static unsigned int handle_count; @@ -408,16 +410,12 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL .length = length, .message = message, }; - BOOL (WINAPI *callback)( struct wine_gl_debug_message_params *params, ULONG size ); - void **kernel_callback_table;
struct wgl_handle *ptr = (struct wgl_handle *)userParam; if (!(params.user_callback = ptr->u.context->debug_callback)) return; params.user_data = ptr->u.context->debug_user;
- kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - callback = kernel_callback_table[NtUserCallOpenGLDebugMessageCallback]; - callback( ¶ms, sizeof(params) ); + call_opengl_debug_message_callback( ¶ms, sizeof(params) ); }
static void WINAPI wrap_glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) @@ -456,6 +454,13 @@ static void WINAPI wrap_glDebugMessageCallbackARB( GLDEBUGPROCARB callback, cons 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 68e66b47a3a..46de5c4a277 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)( struct wine_gl_debug_message_params *params, ULONG size ); +}; + struct wglCopyContext_params { HGLRC hglrcSrc; @@ -22293,6 +22301,7 @@ struct wglSwapIntervalEXT_params
enum unix_funcs { + unix_wglInit, unix_wglCopyContext, unix_wglCreateContext, unix_wglDeleteContext, diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index d5b0a78b916..89d9b1b85ef 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1228,16 +1228,16 @@ 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; - switch(reason) { case DLL_PROCESS_ATTACH: + { + struct wglInit_params args = { (void*)call_opengl_debug_message_callback, }; + NtCurrentTeb()->glTable = &null_opengl_funcs;
- kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_opengl_debug_message_callback; - break; + return !UNIX_CALL( wglInit, &args ); + } case DLL_THREAD_ATTACH: NtCurrentTeb()->glTable = &null_opengl_funcs; break; diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index ddb3966a0b0..6276e8d8e1d 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1045,12 +1045,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 ); @@ -1127,8 +1121,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 1065b5e3e92..343d22bd9bd 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 36b1f384ddf..24ade7399c7 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 21 +#define WINE_WGL_DRIVER_VERSION 22
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 22652f11d27..f767ceb4187 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -120,6 +120,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 b7292b5faf1..bd0d5cf5925 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 = { 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 b10491a22d8..1e3c0d20631 100644 --- a/dlls/wineandroid.drv/dllmain.c +++ b/dlls/wineandroid.drv/dllmain.c @@ -119,7 +119,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;
@@ -129,12 +128,8 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) 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 4308725dcee..0d0f36fd1cf 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 { @@ -586,6 +587,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 98da6528fd5..4cdc6f7a407 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 083c539dd26..cea432b3a71 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -367,8 +367,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, @@ -379,13 +378,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[] = { @@ -413,12 +409,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 6ca46f55dff..67e272f99c5 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 = 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 = 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 = 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 = 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 = 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..8b9f988bd16 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 = 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 f6f9e5b6c67..dfd4ab9fd88 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; @@ -280,8 +281,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 2350ec61b21..d3054dea95a 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -49,6 +49,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; @@ -444,6 +446,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); @@ -610,11 +614,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 5fe19a94fee..a0f93492b25 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -80,9 +80,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 */ @@ -98,19 +111,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 { @@ -130,18 +130,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; @@ -152,6 +155,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; @@ -162,6 +166,7 @@ struct dnd_query_drop_params /* macdrv_dnd_query_exited params */ struct dnd_query_exited_params { + struct user32_callback_params cbparams; UINT32 hwnd; };
@@ -176,6 +181,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; @@ -186,6 +192,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; @@ -197,5 +204,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 37696f02d25..afc62ebf26b 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 = 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 4570e849d3d..b3f9296bdaa 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 4a1a8dc0443..7d70df78134 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1484,8 +1484,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 ); } @@ -1534,14 +1535,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 ); } }
@@ -1563,7 +1564,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; @@ -1584,11 +1584,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 ); @@ -1603,8 +1605,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 e8b243d67a1..c0f61b79fb9 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -128,6 +128,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 a424eb112e8..ab002e66366 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -651,8 +651,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 21a4bb7f6fb..991e48189fa 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 5f8bdd8c68b..e28d659a832 100644 --- a/dlls/winex11.drv/ime.c +++ b/dlls/winex11.drv/ime.c @@ -1010,9 +1010,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; @@ -1020,6 +1021,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 c0f61b79fb9..1ca67cfb3e7 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -137,3 +137,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 00c15bb3bcf..988c987df24 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -98,16 +98,16 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset,
void X11DRV_XIMLookupChars( const char *str, DWORD 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 XIMPreEditStateNotifyCallback(XIC xic, XPointer p, XPointer data)
From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winex11.drv/dllmain.c | 14 +++----------- 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(+), 51 deletions(-)
diff --git a/dlls/winex11.drv/dllmain.c b/dlls/winex11.drv/dllmain.c index 8ed0e40d1ac..18710b5b403 100644 --- a/dlls/winex11.drv/dllmain.c +++ b/dlls/winex11.drv/dllmain.c @@ -46,8 +46,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, @@ -58,16 +57,13 @@ 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; @@ -78,11 +74,7 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) &x11drv_handle, sizeof(x11drv_handle), NULL )) 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 !X11DRV_CALL( init, ¶ms ); }
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 7d70df78134..c925157391c 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -520,7 +520,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. */
@@ -626,8 +626,9 @@ static void handle_manager_message( HWND hwnd, XClientMessageEvent *event )
TRACE( "new owner %lx\n", event->data.l[2] );
+ params.cbparams.func = 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) ); } }
@@ -736,7 +737,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); @@ -1454,7 +1455,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; @@ -1478,7 +1479,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; @@ -1487,8 +1488,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 = 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 ); }
/********************************************************************** @@ -1754,7 +1756,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 = client_funcs.dnd_enter_event; + x11drv_client_func( &data->cbparams, size ); free( data ); }
@@ -1805,11 +1808,12 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event ) XClientMessageEvent e; DWORD effect;
+ params.cbparams.func = 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, params.point.x, params.point.y ); diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 1ca67cfb3e7..1dea87c0b78 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -46,11 +46,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 @@ -77,21 +90,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 { @@ -108,6 +106,7 @@ enum client_callback /* x11drv_callback params */ struct client_callback_params { + struct user32_callback_params cbparams; UINT id; UINT arg; }; @@ -115,6 +114,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]; @@ -123,6 +123,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; @@ -130,15 +131,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 ab002e66366..cdc461f7325 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -414,6 +414,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; @@ -842,8 +843,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 77e72752017..f4fefc1120c 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -62,6 +62,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; @@ -670,6 +672,8 @@ static NTSTATUS x11drv_init( void *arg ) dlopen( SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL ); #endif
+ client_funcs = *params->client_funcs; + setup_options();
/* Open display */ @@ -1310,18 +1314,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 = { { client_funcs.callback }, .id = func, .arg = arg }; + return x11drv_client_func( ¶ms.cbparams, sizeof(params) ); }
@@ -1353,11 +1357,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 988c987df24..451b2924dcf 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) @@ -69,13 +75,15 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset, unsigned int byte_offset = dwOffset * 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", dwOffset, selLength, lpComp, dwCompLen );
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"); @@ -86,14 +94,14 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset, dwCompStringSize += byte_expansion; }
- ptr_new = CompositionString + byte_offset; - memmove(ptr_new + byte_length, ptr_new + byte_selection, + CompositionString->cbparams.func = 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, DWORD count ) @@ -104,9 +112,10 @@ void X11DRV_XIMLookupChars( const char *str, DWORD count ) TRACE("%p %u\n", str, count);
if (!(params = malloc( FIELD_OFFSET( struct ime_set_result_params, data[count] ) ))) return; + params->cbparams.func = 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 ); }
@@ -143,8 +152,7 @@ static void XIMPreEditDoneCallback(XIC ic, XPointer client_data, XPointer call_d { TRACE("PreeditDoneCallback %p\n",ic); 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 6276e8d8e1d..2905522e71f 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1045,56 +1045,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 */ @@ -1121,17 +1071,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 343d22bd9bd..39ffad66986 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 };
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 tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125888
Your paranoid android.
=== debian11 (32 bit report) ===
vulkan-1=load error 3221225794
=== debian11 (build log) ===
06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 06e0:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 03cc:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 0650:err:winediag:D3D12CreateDevice Failed to load Vulkan library. 0650:err:winediag:D3D12CreateDevice Failed to load Vulkan library.