From c660d37ae725531ef0accce504adebd2b19a2687 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek@codeweavers.com>
Date: Thu, 21 Jul 2022 20:39:00 +0200
Subject: [PATCH] win32u: Use syscall interface for scroll bar functions.

---
 dlls/win32u/gdiobj.c         |  4 ----
 dlls/win32u/syscall.c        |  4 ++++
 dlls/win32u/win32u.spec      |  8 ++++----
 dlls/win32u/win32u_private.h |  4 ----
 dlls/win32u/wrappers.c       | 24 -----------------------
 dlls/wow64win/syscall.h      |  4 ++++
 dlls/wow64win/user.c         | 37 ++++++++++++++++++++++++++++++++++++
 7 files changed, 49 insertions(+), 36 deletions(-)

diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c
index 2bf3702ddcd..0c7693d24ed 100644
--- a/dlls/win32u/gdiobj.c
+++ b/dlls/win32u/gdiobj.c
@@ -1138,12 +1138,10 @@ static struct unix_funcs unix_funcs =
     NtGdiWidenPath,
     NtUserDrawCaptionTemp,
     NtUserDrawMenuBarTemp,
-    NtUserEnableScrollBar,
     NtUserEndPaint,
     NtUserExcludeUpdateRgn,
     NtUserFlashWindowEx,
     NtUserGetClassInfoEx,
-    NtUserGetScrollBarInfo,
     NtUserGetWindowPlacement,
     NtUserInternalGetWindowIcon,
     NtUserRegisterClassExWOW,
@@ -1155,13 +1153,11 @@ static struct unix_funcs unix_funcs =
     NtUserSetClassWord,
     NtUserSetLayeredWindowAttributes,
     NtUserSetParent,
-    NtUserSetScrollInfo,
     NtUserSetWindowLong,
     NtUserSetWindowLongPtr,
     NtUserSetWindowPlacement,
     NtUserSetWindowRgn,
     NtUserSetWindowWord,
-    NtUserShowScrollBar,
     NtUserShowWindow,
     NtUserShowWindowAsync,
     NtUserSystemParametersInfo,
diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c
index 4963657e8ba..f6b044d8c38 100644
--- a/dlls/win32u/syscall.c
+++ b/dlls/win32u/syscall.c
@@ -142,6 +142,7 @@ static void * const syscalls[] =
     NtUserDrawIconEx,
     NtUserEmptyClipboard,
     NtUserEnableMenuItem,
+    NtUserEnableScrollBar,
     NtUserEndDeferWindowPosEx,
     NtUserEndMenu,
     NtUserEnumDisplayDevices,
@@ -194,6 +195,7 @@ static void * const syscalls[] =
     NtUserGetRawInputDeviceInfo,
     NtUserGetRawInputDeviceList,
     NtUserGetRegisteredRawInputDevices,
+    NtUserGetScrollBarInfo,
     NtUserGetSystemDpiForProcess,
     NtUserGetSystemMenu,
     NtUserGetThreadDesktop,
@@ -250,6 +252,7 @@ static void * const syscalls[] =
     NtUserSetProcessDpiAwarenessContext,
     NtUserSetProcessWindowStation,
     NtUserSetProp,
+    NtUserSetScrollInfo,
     NtUserSetSysColors,
     NtUserSetSystemMenu,
     NtUserSetSystemTimer,
@@ -260,6 +263,7 @@ static void * const syscalls[] =
     NtUserSetWindowsHookEx,
     NtUserShowCaret,
     NtUserShowCursor,
+    NtUserShowScrollBar,
     NtUserThunkedMenuInfo,
     NtUserThunkedMenuItemInfo,
     NtUserToUnicodeEx,
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 9c067b0d4ac..8ddc4e0c9f7 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -866,7 +866,7 @@
 @ stub NtUserEnableMouseInputForCursorSuppression
 @ stub NtUserEnableNonClientDpiScaling
 @ stub NtUserEnableResizeLayoutSynchronization
-@ stdcall NtUserEnableScrollBar(long long long)
+@ stdcall -syscall NtUserEnableScrollBar(long long long)
 @ stub NtUserEnableSoftwareCursorForScreenCapture
 @ stub NtUserEnableTouchPad
 @ stub NtUserEnableWindowGDIScaledDpiMessage
@@ -991,7 +991,7 @@
 @ stdcall -syscall NtUserGetRegisteredRawInputDevices(ptr ptr long)
 @ stub NtUserGetRequiredCursorSizes
 @ stub NtUserGetResizeDCompositionSynchronizationObject
-@ stdcall NtUserGetScrollBarInfo(long long ptr)
+@ stdcall -syscall NtUserGetScrollBarInfo(long long ptr)
 @ stub NtUserGetSharedWindowData
 @ stdcall -syscall NtUserGetSystemDpiForProcess(long)
 @ stdcall -syscall NtUserGetSystemMenu(long long)
@@ -1223,7 +1223,7 @@
 @ stub NtUserSetProcessUIAccessZorder
 @ stdcall -syscall NtUserSetProcessWindowStation(long)
 @ stdcall -syscall NtUserSetProp(long wstr ptr)
-@ stdcall NtUserSetScrollInfo(long long ptr long)
+@ stdcall -syscall NtUserSetScrollInfo(long long ptr long)
 @ stub NtUserSetSensorPresence
 @ stub NtUserSetSharedWindowData
 @ stub NtUserSetShellWindowEx
@@ -1259,7 +1259,7 @@
 @ stdcall -syscall NtUserSetWindowsHookEx(ptr ptr long long ptr long)
 @ stdcall -syscall NtUserShowCaret(long)
 @ stdcall -syscall NtUserShowCursor(long)
-@ stdcall NtUserShowScrollBar(long long long)
+@ stdcall -syscall NtUserShowScrollBar(long long long)
 @ stub NtUserShowSystemCursor
 @ stdcall NtUserShowWindow(long long)
 @ stdcall NtUserShowWindowAsync(long long)
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index a7128648e51..aec24b73f53 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -189,13 +189,11 @@ struct unix_funcs
     BOOL     (WINAPI *pNtUserDrawCaptionTemp)( HWND hwnd, HDC hdc, const RECT *rect, HFONT font,
                                                HICON icon, const WCHAR *str, UINT flags );
     DWORD    (WINAPI *pNtUserDrawMenuBarTemp)( HWND hwnd, HDC hdc, RECT *rect, HMENU handle, HFONT font );
-    BOOL     (WINAPI *pNtUserEnableScrollBar)( HWND hwnd, UINT bar, UINT flags );
     BOOL     (WINAPI *pNtUserEndPaint)( HWND hwnd, const PAINTSTRUCT *ps );
     INT      (WINAPI *pNtUserExcludeUpdateRgn)( HDC hdc, HWND hwnd );
     BOOL     (WINAPI *pNtUserFlashWindowEx)( FLASHWINFO *info );
     ATOM     (WINAPI *pNtUserGetClassInfoEx)( HINSTANCE instance, UNICODE_STRING *name, WNDCLASSEXW *wc,
                                               struct client_menu_name *menu_name, BOOL ansi );
-    BOOL     (WINAPI *pNtUserGetScrollBarInfo)( HWND hwnd, LONG id, SCROLLBARINFO *info );
     BOOL     (WINAPI *pNtUserGetWindowPlacement)( HWND hwnd, WINDOWPLACEMENT *placement );
     HICON    (WINAPI *pNtUserInternalGetWindowIcon)( HWND hwnd, UINT type );
     ATOM     (WINAPI *pNtUserRegisterClassExWOW)( const WNDCLASSEXW *wc, UNICODE_STRING *name,
@@ -211,13 +209,11 @@ struct unix_funcs
     WORD     (WINAPI *pNtUserSetClassWord)( HWND hwnd, INT offset, WORD newval );
     BOOL     (WINAPI *pNtUserSetLayeredWindowAttributes)( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags );
     HWND     (WINAPI *pNtUserSetParent)( HWND hwnd, HWND parent );
-    INT      (WINAPI *pNtUserSetScrollInfo)( HWND hwnd, INT bar, const SCROLLINFO *info, BOOL redraw );
     LONG     (WINAPI *pNtUserSetWindowLong)( HWND hwnd, INT offset, LONG newval, BOOL ansi );
     LONG_PTR (WINAPI *pNtUserSetWindowLongPtr)( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi );
     BOOL     (WINAPI *pNtUserSetWindowPlacement)( HWND hwnd, const WINDOWPLACEMENT *wpl );
     int      (WINAPI *pNtUserSetWindowRgn)( HWND hwnd, HRGN hrgn, BOOL redraw );
     WORD     (WINAPI *pNtUserSetWindowWord)( HWND hwnd, INT offset, WORD newval );
-    BOOL     (WINAPI *pNtUserShowScrollBar)( HWND hwnd, INT bar, BOOL show );
     BOOL     (WINAPI *pNtUserShowWindow)( HWND hwnd, INT cmd );
     BOOL     (WINAPI *pNtUserShowWindowAsync)( HWND hwnd, INT cmd );
     BOOL     (WINAPI *pNtUserSystemParametersInfo)( UINT action, UINT val, PVOID ptr, UINT winini );
diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c
index b07c40a01ee..b2b143cc136 100644
--- a/dlls/win32u/wrappers.c
+++ b/dlls/win32u/wrappers.c
@@ -738,12 +738,6 @@ DWORD WINAPI NtUserDrawMenuBarTemp( HWND hwnd, HDC hdc, RECT *rect, HMENU handle
     return unix_funcs->pNtUserDrawMenuBarTemp( hwnd, hdc, rect, handle, font );
 }
 
-BOOL WINAPI NtUserEnableScrollBar( HWND hwnd, UINT bar, UINT flags )
-{
-    if (!unix_funcs) return FALSE;
-    return unix_funcs->pNtUserEnableScrollBar( hwnd, bar, flags );
-}
-
 INT WINAPI NtUserExcludeUpdateRgn( HDC hdc, HWND hwnd )
 {
     if (!unix_funcs) return ERROR;
@@ -763,12 +757,6 @@ ATOM WINAPI NtUserGetClassInfoEx( HINSTANCE instance, UNICODE_STRING *name, WNDC
     return unix_funcs->pNtUserGetClassInfoEx( instance, name, wc, menu_name, ansi );
 }
 
-BOOL WINAPI NtUserGetScrollBarInfo( HWND hwnd, LONG id, SCROLLBARINFO *info )
-{
-    if (!unix_funcs) return FALSE;
-    return unix_funcs->pNtUserGetScrollBarInfo( hwnd, id, info );
-}
-
 BOOL WINAPI NtUserGetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *placement )
 {
     if (!unix_funcs) return FALSE;
@@ -838,12 +826,6 @@ HWND WINAPI NtUserSetParent( HWND hwnd, HWND parent )
     return unix_funcs->pNtUserSetParent( hwnd, parent );
 }
 
-INT WINAPI NtUserSetScrollInfo( HWND hwnd, INT bar, const SCROLLINFO *info, BOOL redraw )
-{
-    if (!unix_funcs) return 0;
-    return unix_funcs->pNtUserSetScrollInfo( hwnd, bar, info, redraw );
-}
-
 LONG WINAPI NtUserSetWindowLong( HWND hwnd, INT offset, LONG newval, BOOL ansi )
 {
     if (!unix_funcs) return 0;
@@ -874,12 +856,6 @@ WORD WINAPI NtUserSetWindowWord( HWND hwnd, INT offset, WORD newval )
     return unix_funcs->pNtUserSetWindowWord( hwnd, offset, newval );
 }
 
-BOOL WINAPI NtUserShowScrollBar( HWND hwnd, INT bar, BOOL show )
-{
-    if (!unix_funcs) return FALSE;
-    return unix_funcs->pNtUserShowScrollBar( hwnd, bar, show );
-}
-
 BOOL WINAPI NtUserShowWindowAsync( HWND hwnd, INT cmd )
 {
     if (!unix_funcs) return FALSE;
diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h
index cd1823edc76..3a2cdf3f8ec 100644
--- a/dlls/wow64win/syscall.h
+++ b/dlls/wow64win/syscall.h
@@ -129,6 +129,7 @@
     SYSCALL_ENTRY( NtUserDrawIconEx ) \
     SYSCALL_ENTRY( NtUserEmptyClipboard ) \
     SYSCALL_ENTRY( NtUserEnableMenuItem ) \
+    SYSCALL_ENTRY( NtUserEnableScrollBar ) \
     SYSCALL_ENTRY( NtUserEndDeferWindowPosEx ) \
     SYSCALL_ENTRY( NtUserEndMenu ) \
     SYSCALL_ENTRY( NtUserEnumDisplayDevices ) \
@@ -181,6 +182,7 @@
     SYSCALL_ENTRY( NtUserGetRawInputDeviceInfo ) \
     SYSCALL_ENTRY( NtUserGetRawInputDeviceList ) \
     SYSCALL_ENTRY( NtUserGetRegisteredRawInputDevices ) \
+    SYSCALL_ENTRY( NtUserGetScrollBarInfo ) \
     SYSCALL_ENTRY( NtUserGetSystemDpiForProcess ) \
     SYSCALL_ENTRY( NtUserGetSystemMenu ) \
     SYSCALL_ENTRY( NtUserGetThreadDesktop ) \
@@ -237,6 +239,7 @@
     SYSCALL_ENTRY( NtUserSetProcessDpiAwarenessContext ) \
     SYSCALL_ENTRY( NtUserSetProcessWindowStation ) \
     SYSCALL_ENTRY( NtUserSetProp ) \
+    SYSCALL_ENTRY( NtUserSetScrollInfo ) \
     SYSCALL_ENTRY( NtUserSetSysColors ) \
     SYSCALL_ENTRY( NtUserSetSystemMenu ) \
     SYSCALL_ENTRY( NtUserSetSystemTimer ) \
@@ -247,6 +250,7 @@
     SYSCALL_ENTRY( NtUserSetWindowsHookEx ) \
     SYSCALL_ENTRY( NtUserShowCaret ) \
     SYSCALL_ENTRY( NtUserShowCursor ) \
+    SYSCALL_ENTRY( NtUserShowScrollBar ) \
     SYSCALL_ENTRY( NtUserThunkedMenuInfo ) \
     SYSCALL_ENTRY( NtUserThunkedMenuItemInfo ) \
     SYSCALL_ENTRY( NtUserToUnicodeEx ) \
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c
index 057ca772905..a6acccf5089 100644
--- a/dlls/wow64win/user.c
+++ b/dlls/wow64win/user.c
@@ -574,6 +574,15 @@ NTSTATUS WINAPI wow64_NtUserEnableMenuItem( UINT *args )
     return NtUserEnableMenuItem( handle, id, flags );
 }
 
+NTSTATUS WINAPI wow64_NtUserEnableScrollBar( UINT *args )
+{
+    HWND hwnd = get_handle( &args );
+    UINT bar = get_ulong( &args );
+    UINT flags = get_ulong( &args );
+
+    return NtUserEnableScrollBar( hwnd, bar, flags );
+}
+
 NTSTATUS WINAPI wow64_NtUserEndDeferWindowPosEx( UINT *args )
 {
     HDWP hdwp = get_handle( &args );
@@ -1282,6 +1291,15 @@ NTSTATUS WINAPI wow64_NtUserGetRegisteredRawInputDevices( UINT *args )
     }
 }
 
+NTSTATUS WINAPI wow64_NtUserGetScrollBarInfo( UINT *args )
+{
+    HWND hwnd = get_handle( &args );
+    LONG id = get_ulong( &args );
+    SCROLLBARINFO *info = get_ptr( &args );
+
+    return NtUserGetScrollBarInfo( hwnd, id, info );
+}
+
 NTSTATUS WINAPI wow64_NtUserGetSystemDpiForProcess( UINT *args )
 {
     HANDLE process = get_handle( &args );
@@ -1868,6 +1886,16 @@ NTSTATUS WINAPI wow64_NtUserSetProp( UINT *args )
     return NtUserSetProp( hwnd, str, handle );
 }
 
+NTSTATUS WINAPI wow64_NtUserSetScrollInfo( UINT *args )
+{
+    HWND hwnd = get_handle( &args );
+    INT bar = get_ulong( &args );
+    const SCROLLINFO *info = get_ptr( &args );
+    BOOL redraw = get_ulong( &args );
+
+    return NtUserSetScrollInfo( hwnd, bar, info, redraw );
+}
+
 NTSTATUS WINAPI wow64_NtUserSetSysColors( UINT *args )
 {
     INT count = get_ulong( &args );
@@ -1974,6 +2002,15 @@ NTSTATUS WINAPI wow64_NtUserShowCursor( UINT *args )
     return NtUserShowCursor( show );
 }
 
+NTSTATUS WINAPI wow64_NtUserShowScrollBar( UINT *args )
+{
+    HWND hwnd = get_handle( &args );
+    INT bar = get_ulong( &args );
+    BOOL show = get_ulong( &args );
+
+    return NtUserShowScrollBar( hwnd, bar, show );
+}
+
 NTSTATUS WINAPI wow64_NtUserThunkedMenuInfo( UINT *args )
 {
     HMENU menu = get_handle( &args );
-- 
GitLab