Module: wine Branch: master Commit: 70f8330d0e726bddc562dbdd2d4ffc78de5535b1 URL: https://source.winehq.org/git/wine.git/?a=commit;h=70f8330d0e726bddc562dbdd2...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Nov 12 12:53:28 2021 +0100
win32u: Move NtUserGetClipboardFormatName implementation from user32.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/clipboard.c | 12 +----------- dlls/user32/user32.spec | 2 +- dlls/win32u/clipboard.c | 25 +++++++++++++++++++++++++ dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 6 ++++++ dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 9 +++++++++ include/ntuser.h | 1 + 9 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c index b9bcc184ca1..2e0c6b92d39 100644 --- a/dlls/user32/clipboard.c +++ b/dlls/user32/clipboard.c @@ -82,7 +82,7 @@ static const char *debugstr_format( UINT id ) { WCHAR buffer[256]; DWORD le = GetLastError(); - BOOL r = GetClipboardFormatNameW( id, buffer, 256 ); + BOOL r = NtUserGetClipboardFormatName( id, buffer, 256 ); SetLastError(le);
if (r) @@ -658,16 +658,6 @@ UINT WINAPI RegisterClipboardFormatA( LPCSTR name ) }
-/************************************************************************** - * GetClipboardFormatNameW (USER32.@) - */ -INT WINAPI GetClipboardFormatNameW( UINT format, LPWSTR buffer, INT maxlen ) -{ - if (format < MAXINTATOM || format > 0xffff) return 0; - return GlobalGetAtomNameW( format, buffer, maxlen ); -} - - /************************************************************************** * GetClipboardFormatNameA (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 87f4dc468bf..319dda49eb5 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -276,7 +276,7 @@ @ stdcall GetClipCursor(ptr) @ stdcall GetClipboardData(long) @ stdcall GetClipboardFormatNameA(long ptr long) -@ stdcall GetClipboardFormatNameW(long ptr long) +@ stdcall GetClipboardFormatNameW(long ptr long) NtUserGetClipboardFormatName @ stdcall GetClipboardOwner() @ stdcall GetClipboardSequenceNumber () @ stdcall GetClipboardViewer() diff --git a/dlls/win32u/clipboard.c b/dlls/win32u/clipboard.c index 8d0e09fdb55..c2fd07ac5b9 100644 --- a/dlls/win32u/clipboard.c +++ b/dlls/win32u/clipboard.c @@ -53,3 +53,28 @@ INT WINAPI NtUserCountClipboardFormats(void) TRACE( "returning %d\n", count ); return count; } + +/************************************************************************** + * NtUserGetClipboardFormatName (win32u.@) + */ +INT WINAPI NtUserGetClipboardFormatName( UINT format, WCHAR *buffer, INT maxlen ) +{ + char buf[sizeof(ATOM_BASIC_INFORMATION) + 255 * sizeof(WCHAR)]; + ATOM_BASIC_INFORMATION *abi = (ATOM_BASIC_INFORMATION *)buf; + UINT length = 0; + + if (format < MAXINTATOM || format > 0xffff) return 0; + if (maxlen <= 0) + { + SetLastError( ERROR_MORE_DATA ); + return 0; + } + if (!set_ntstatus( NtQueryInformationAtom( format, AtomBasicInformation, + buf, sizeof(buf), NULL ))) + return 0; + + length = min( abi->NameLength / sizeof(WCHAR), maxlen - 1 ); + if (length) memcpy( buffer, abi->Name, length * sizeof(WCHAR) ); + buffer[length] = 0; + return length; +} diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index 762729f815e..a84633b2215 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -105,6 +105,7 @@ static void * const syscalls[] = NtUserCloseWindowStation, NtUserCreateDesktopEx, NtUserCreateWindowStation, + NtUserGetClipboardFormatName, NtUserGetLayeredWindowAttributes, NtUserGetObjectInformation, NtUserGetProcessWindowStation, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index daea9cfe21a..d1774804293 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -903,7 +903,7 @@ @ stub NtUserGetClipCursor @ stub NtUserGetClipboardAccessToken @ stub NtUserGetClipboardData -@ stub NtUserGetClipboardFormatName +@ stdcall -syscall NtUserGetClipboardFormatName(long ptr long) @ stub NtUserGetClipboardOwner @ stub NtUserGetClipboardSequenceNumber @ stub NtUserGetClipboardViewer diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index a78c7bb906b..7526f4414dd 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -232,6 +232,12 @@ extern ULONG query_reg_ascii_value( HKEY hkey, const char *name,
extern const struct user_driver_funcs *user_driver DECLSPEC_HIDDEN;
+static inline BOOL set_ntstatus( NTSTATUS status ) +{ + if (status) SetLastError( RtlNtStatusToDosError( status )); + return !status; +} + static inline WCHAR *win32u_wcsrchr( const WCHAR *str, WCHAR ch ) { WCHAR *ret = NULL; diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index 8430d0b1527..b78b4697e6c 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -92,6 +92,7 @@ SYSCALL_ENTRY( NtUserCloseWindowStation ) \ SYSCALL_ENTRY( NtUserCreateDesktopEx ) \ SYSCALL_ENTRY( NtUserCreateWindowStation ) \ + SYSCALL_ENTRY( NtUserGetClipboardFormatName ) \ SYSCALL_ENTRY( NtUserGetLayeredWindowAttributes ) \ SYSCALL_ENTRY( NtUserGetObjectInformation ) \ SYSCALL_ENTRY( NtUserGetProcessWindowStation ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 2686d75a094..f12516843fb 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -190,3 +190,12 @@ NTSTATUS WINAPI wow64_NtUserGetLayeredWindowAttributes( UINT *args )
return NtUserGetLayeredWindowAttributes( hwnd, key, alpha, flags ); } + +NTSTATUS WINAPI wow64_NtUserGetClipboardFormatName( UINT *args ) +{ + UINT format = get_ulong( &args ); + WCHAR *buffer = get_ptr( &args ); + INT maxlen = get_ulong( &args ); + + return NtUserGetClipboardFormatName( format, buffer, maxlen ); +} diff --git a/include/ntuser.h b/include/ntuser.h index de493b7a6d7..a68c8458213 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -31,6 +31,7 @@ HDESK WINAPI NtUserCreateDesktopEx( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *d ULONG heap_size ); HWINSTA WINAPI NtUserCreateWindowStation( OBJECT_ATTRIBUTES *attr, ACCESS_MASK mask, ULONG arg3, ULONG arg4, ULONG arg5, ULONG arg6, ULONG arg7 ); +INT WINAPI NtUserGetClipboardFormatName( UINT format, WCHAR *buffer, INT maxlen ); BOOL WINAPI NtUserGetLayeredWindowAttributes( HWND hwnd, COLORREF *key, BYTE *alpha, DWORD *flags ); BOOL WINAPI NtUserGetObjectInformation( HANDLE handle, INT index, void *info, DWORD len, DWORD *needed );