[PATCH v2 12/12] win32u: Use user mode callback for registering builtin classes.

Huw Davies huw at codeweavers.com
Tue Apr 26 10:06:11 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/user32/class.c          | 15 ++-------------
 dlls/user32/controls.h       |  1 -
 dlls/user32/user_main.c      |  2 +-
 dlls/user32/user_private.h   |  1 +
 dlls/win32u/class.c          | 16 ++++++++++++++++
 dlls/win32u/ntuser_private.h |  2 +-
 dlls/win32u/window.c         |  2 +-
 dlls/win32u/winstation.c     |  2 +-
 include/ntuser.h             |  1 +
 9 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index aaa8f75bebe..620477f1b14 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -40,8 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(class);
 
 #define MAX_ATOM_LEN 255 /* from dlls/kernel32/atom.c */
 
-static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
-
 static inline const char *debugstr_us( const UNICODE_STRING *us )
 {
     if (!us) return "<null>";
@@ -307,9 +305,9 @@ static void load_uxtheme(void)
 }
 
 /***********************************************************************
- *           register_builtins
+ *           User32RegisterBuiltinClasses
  */
-static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context )
+BOOL WINAPI User32RegisterBuiltinClasses( const struct win_hook_params *params, ULONG size )
 {
     register_builtin( &BUTTON_builtin_class );
     register_builtin( &COMBO_builtin_class );
@@ -330,15 +328,6 @@ static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **conte
 }
 
 
-/***********************************************************************
- *           register_builtin_classes
- */
-void register_builtin_classes(void)
-{
-    InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL );
-}
-
-
 /***********************************************************************
  *           register_desktop_class
  */
diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h
index a410bf27460..5dcdd9bb935 100644
--- a/dlls/user32/controls.h
+++ b/dlls/user32/controls.h
@@ -104,7 +104,6 @@ extern LRESULT StaticWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDE
 struct tagCLASS;  /* opaque structure */
 struct tagWND;
 extern ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN;
-extern void register_builtin_classes(void) DECLSPEC_HIDDEN;
 extern void register_desktop_class(void) DECLSPEC_HIDDEN;
 
 /* defwnd proc */
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 1258181c88a..1400597eb5d 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -172,7 +172,6 @@ static const struct user_callbacks user_funcs =
     post_dde_message,
     process_rawinput_message,
     rawinput_device_get_usages,
-    register_builtin_classes,
     SCROLL_SetStandardScrollPainted,
     unpack_dde_message,
     register_imm,
@@ -207,6 +206,7 @@ static const void *kernel_callback_table[NtUserCallCount] =
     User32CallWindowsHook,
     User32FreeCachedClipboardData,
     User32LoadDriver,
+    User32RegisterBuiltinClasses,
     User32RenderSsynthesizedFormat,
 };
 
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index f28fc66bbf2..aa3e1565bfa 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -124,6 +124,7 @@ BOOL WINAPI User32CallSendAsyncCallback( const struct send_async_params *params,
 BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params, ULONG size );
 BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size );
 BOOL WINAPI User32CallWindowsHook( const struct win_hook_params *params, ULONG size );
+BOOL WINAPI User32RegisterBuiltinClasses( const struct win_hook_params *params, ULONG size );
 
 /* message spy definitions */
 
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c
index ba60794ccd7..c52fcad6025 100644
--- a/dlls/win32u/class.c
+++ b/dlls/win32u/class.c
@@ -972,3 +972,19 @@ WORD get_class_word( HWND hwnd, INT offset )
     release_class_ptr( class );
     return retvalue;
 }
+
+static void register_builtins(void)
+{
+    void *ret_ptr;
+    ULONG ret_len;
+    KeUserModeCallback( NtUserRegisterBuiltinClasses, NULL, 0, &ret_ptr, &ret_len );
+}
+
+/***********************************************************************
+ *           register_builtin_classes
+ */
+void register_builtin_classes(void)
+{
+    static pthread_once_t init_once = PTHREAD_ONCE_INIT;
+    pthread_once( &init_once, register_builtins );
+}
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index 632cb16d23a..fe9d7e18bc9 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -46,7 +46,6 @@ struct user_callbacks
                                     DWORD type );
     BOOL (CDECL *process_rawinput_message)( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data );
     BOOL (CDECL *rawinput_device_get_usages)(HANDLE handle, USHORT *usage_page, USHORT *usage);
-    void (CDECL *register_builtin_classes)(void);
     void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible );
     BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
                                       void **buffer, size_t size );
@@ -303,6 +302,7 @@ WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN;
 void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN;
 struct dce *get_class_dce( struct tagCLASS *class ) DECLSPEC_HIDDEN;
 struct dce *set_class_dce( struct tagCLASS *class, struct dce *dce ) DECLSPEC_HIDDEN;
+extern void register_builtin_classes(void) DECLSPEC_HIDDEN;
 
 /* cursoricon.c */
 HICON alloc_cursoricon_handle( BOOL is_icon ) DECLSPEC_HIDDEN;
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c
index e206881e596..edafc522d14 100644
--- a/dlls/win32u/window.c
+++ b/dlls/win32u/window.c
@@ -4732,7 +4732,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name,
             else assert( full_parent == thread_info->top_window );
             if (full_parent && !user_driver->pCreateDesktopWindow( thread_info->top_window ))
                 ERR( "failed to create desktop window\n" );
-            if (user_callbacks) user_callbacks->register_builtin_classes();
+            register_builtin_classes();
         }
         else  /* HWND_MESSAGE parent */
         {
diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c
index 4cd223750c2..0f6fb66a2b2 100644
--- a/dlls/win32u/winstation.c
+++ b/dlls/win32u/winstation.c
@@ -499,7 +499,7 @@ HWND get_desktop_window(void)
     if (!thread_info->top_window || !user_driver->pCreateDesktopWindow( thread_info->top_window ))
         ERR_(win)( "failed to create desktop window\n" );
 
-    if (user_callbacks) user_callbacks->register_builtin_classes();
+    register_builtin_classes();
     return thread_info->top_window;
 }
 
diff --git a/include/ntuser.h b/include/ntuser.h
index cad90b91882..58486fcfcb0 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -34,6 +34,7 @@ enum
     NtUserCallWindowsHook,
     NtUserFreeCachedClipboardData,
     NtUserLoadDriver,
+    NtUserRegisterBuiltinClasses,
     NtUserRenderSynthesizedFormat,
     /* win16 hooks */
     NtUserCallFreeIcon,
-- 
2.25.1




More information about the wine-devel mailing list