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.
-- v18: 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.
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 | 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 15e4796bab2..d2b51c7629c 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 256add62aab..aad4d1c0d3f 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 5331b3d7400..53a48ecfe67 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 | 44 +++++++++++++++++++------------- dlls/winevulkan/vulkan.c | 25 +++++++++++++----- dlls/winevulkan/vulkan_loader.h | 17 ++++++++++++ dlls/winevulkan/vulkan_private.h | 1 + dlls/wow64win/user.c | 15 ----------- include/ntuser.h | 3 --- 6 files changed, 62 insertions(+), 43 deletions(-)
diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index a86a35b0d40..ca91212b348 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -233,13 +233,38 @@ 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) { + struct vk_callback_funcs callback_funcs = + { + (ULONG_PTR)call_vulkan_debug_report_callback, + (ULONG_PTR)call_vulkan_debug_utils_callback, + }; + struct init_vulkan_params params; + if (NtQueryVirtualMemory(GetCurrentProcess(), hinstance, MemoryWineUnixFuncs, &unix_handle, sizeof(unix_handle), NULL)) return FALSE;
- return !vk_unix_call(unix_init, &p_vk_direct_unix_call); + params.callback_funcs = &callback_funcs; + if (vk_unix_call(unix_init, ¶ms)) return FALSE; + p_vk_direct_unix_call = params.vk_direct_unix_call; + return TRUE; }
static BOOL wine_vk_init_once(void) @@ -609,21 +634,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) @@ -631,10 +643,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 bd02edde4b6..0c87659a5c6 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.cbparams, 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.cbparams, sizeof(params), &ret_ptr, &ret_len ); }
static void wine_vk_physical_device_free(struct wine_phys_dev *phys_dev) @@ -410,10 +410,14 @@ static void wine_vk_device_free(struct wine_device *device) free(device); }
+struct vk_callback_funcs callback_funcs; + #ifdef _WIN64
NTSTATUS init_vulkan(void *args) { + struct init_vulkan_params *params = args; + vk_funcs = __wine_get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION); if (!vk_funcs) { @@ -421,8 +425,8 @@ NTSTATUS init_vulkan(void *args) return STATUS_UNSUCCESSFUL; }
- - *(void **)args = vk_direct_unix_call; + callback_funcs = *params->callback_funcs; + params->vk_direct_unix_call = vk_direct_unix_call; return STATUS_SUCCESS; }
@@ -430,6 +434,12 @@ NTSTATUS init_vulkan(void *args)
NTSTATUS init_vulkan32(void *args) { + struct + { + UINT32 callback_funcs; + UINT32 vk_direct_unix_call; + } *params = args; + vk_funcs = __wine_get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION); if (!vk_funcs) { @@ -437,8 +447,9 @@ NTSTATUS init_vulkan32(void *args) return STATUS_UNSUCCESSFUL; }
+ callback_funcs = *(struct vk_callback_funcs*)(ULONG_PTR)params->callback_funcs; #ifndef _WIN64 - *(void **)args = vk_direct_unix_call; + params->vk_direct_unix_call = (UINT32)(ULONG_PTR)vk_direct_unix_call; #endif return STATUS_SUCCESS; } diff --git a/dlls/winevulkan/vulkan_loader.h b/dlls/winevulkan/vulkan_loader.h index 8e22fc1ee45..21a871dd9d3 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,24 @@ 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; +}; + +struct init_vulkan_params +{ + const struct vk_callback_funcs *callback_funcs; + NTSTATUS (WINAPI *vk_direct_unix_call)(unixlib_handle_t handle, unsigned int code, void *args); +}; + /* debug callbacks params */
struct wine_vk_debug_utils_params { + struct user32_callback_params cbparams; + PFN_vkDebugUtilsMessengerCallbackEXT user_callback; void *user_data;
@@ -121,6 +136,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 a895b848156..94ca3ab6943 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -228,6 +228,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 init_vulkan32(void *args) DECLSPEC_HIDDEN;
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index aad4d1c0d3f..357ddbc6a55 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 53a48ecfe67..b960eb0dd19 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 5654ddfa824..084c722a4e9 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -999,10 +999,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{$_}; @@ -1021,6 +1029,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) @@ -1043,6 +1052,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"; @@ -1145,6 +1155,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) @@ -1191,6 +1202,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 f07b0c2f775..7511a9e0d51 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; @@ -24155,6 +24156,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 b0874af546e..d6f7f40d906 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 */ @@ -811,6 +813,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, @@ -825,8 +828,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 WINAPI wrap_glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) @@ -865,6 +867,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 e7f21383f86..d874301bede 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 { HGLRC hglrcSrc; @@ -22293,6 +22301,7 @@ struct wglSwapIntervalEXT_params
enum unix_funcs { + unix_wglInit, unix_thread_attach, unix_process_detach, unix_wglCopyContext, @@ -25340,6 +25349,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 27efa6df745..000b86fcace 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1239,8 +1239,10 @@ GLboolean WINAPI glUnmapNamedBufferEXT( GLuint buffer ) return glUnmapNamedBuffer( 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; @@ -1251,12 +1253,14 @@ 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 = NtQueryVirtualMemory( GetCurrentProcess(), hinst, MemoryWineUnixFuncs, &unixlib_handle, sizeof(unixlib_handle), NULL ))) { @@ -1264,9 +1268,8 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) 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, NULL ))) { diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 357ddbc6a55..000e852b660 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 b960eb0dd19..81b5d763b5c 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 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 ca3583b574f..3b036e0f44a 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 acf6b9abbbe..aa3c96802dd 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 dd12321fa7f..10e6b1281ba 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..0d7dc15a197 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 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..c7ef0858cb5 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 6ebc36cbead..f7152b8c553 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 86edf66b820..8e8daf38398 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1486,8 +1486,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 ); } @@ -1536,14 +1537,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 ); } }
@@ -1565,7 +1566,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; @@ -1586,11 +1586,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 ); @@ -1605,8 +1607,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 47a29c8eb98..73267edd479 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -661,8 +661,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 0599159646f..edcdd991d24 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 d736dd80345..ab1b99edfaf 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -97,16 +97,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 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 8e8daf38398..906e50b3924 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 = (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) ); } }
@@ -737,7 +738,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); @@ -1456,7 +1457,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; @@ -1480,7 +1481,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; @@ -1489,8 +1490,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 ); }
/********************************************************************** @@ -1756,7 +1758,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 ); }
@@ -1807,11 +1810,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 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 73267edd479..151c288cd6b 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -424,6 +424,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; @@ -852,8 +853,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 561f25783b6..9613af52f81 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 = { { (ULONG_PTR)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 ab1b99edfaf..cb8840af71b 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) @@ -68,13 +74,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"); @@ -85,14 +93,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 ) @@ -103,9 +111,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 ); }
@@ -142,8 +151,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 000e852b660..b565c806824 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 81b5d763b5c..26ccb39e9cf 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 26ccb39e9cf..2357fbe22dd 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 */
"ERROR: Job failed: execution took longer than 1h0m0s seconds" lmao ok