Commit c722a002 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Implement NtUserGetAtomName.

parent 77f3b54e
......@@ -165,3 +165,28 @@ NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs
return STATUS_SUCCESS;
}
/***********************************************************************
* NtUserGetAtomName (win32u.@)
*/
ULONG WINAPI NtUserGetAtomName( ATOM atom, UNICODE_STRING *name )
{
char buf[sizeof(ATOM_BASIC_INFORMATION) + MAX_ATOM_LEN * sizeof(WCHAR)];
ATOM_BASIC_INFORMATION *abi = (ATOM_BASIC_INFORMATION *)buf;
UINT size;
if (!set_ntstatus( NtQueryInformationAtom( atom, AtomBasicInformation,
buf, sizeof(buf), NULL )))
return 0;
if (name->MaximumLength < sizeof(WCHAR))
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return 0;
}
size = min( abi->NameLength, name->MaximumLength - sizeof(WCHAR) );
if (size) memcpy( name->Buffer, abi->Name, size );
name->Buffer[size / sizeof(WCHAR)] = 0;
return size / sizeof(WCHAR);
}
......@@ -28,6 +28,7 @@
#endif
#include "win32u_private.h"
#include "ntuser_private.h"
#include "wine/server.h"
#include "wine/debug.h"
......@@ -168,7 +169,7 @@ INT WINAPI NtUserGetPriorityClipboardFormat( UINT *list, INT count )
*/
INT WINAPI NtUserGetClipboardFormatName( UINT format, WCHAR *buffer, INT maxlen )
{
char buf[sizeof(ATOM_BASIC_INFORMATION) + 255 * sizeof(WCHAR)];
char buf[sizeof(ATOM_BASIC_INFORMATION) + MAX_ATOM_LEN * sizeof(WCHAR)];
ATOM_BASIC_INFORMATION *abi = (ATOM_BASIC_INFORMATION *)buf;
UINT length = 0;
......
......@@ -167,6 +167,8 @@ typedef struct tagWINDOWPROC
#define WINPROC_HANDLE (~0u >> 16)
#define BUILTIN_WINPROC(index) ((WNDPROC)(ULONG_PTR)((index) | (WINPROC_HANDLE << 16)))
#define MAX_ATOM_LEN 255
/* class.c */
WNDPROC alloc_winproc( WNDPROC func, BOOL ansi ) DECLSPEC_HIDDEN;
WINDOWPROC *get_winproc_ptr( WNDPROC handle ) DECLSPEC_HIDDEN;
......
......@@ -112,6 +112,7 @@ static void * const syscalls[] =
NtUserCreateWindowStation,
NtUserDestroyAcceleratorTable,
NtUserFindExistingCursorIcon,
NtUserGetAtomName,
NtUserGetClipboardFormatName,
NtUserGetClipboardOwner,
NtUserGetClipboardSequenceNumber,
......
......@@ -104,6 +104,67 @@ static void test_window_props(void)
DestroyWindow( hwnd );
}
static void test_class(void)
{
UNICODE_STRING name;
WCHAR buf[64];
WNDCLASSW cls;
ATOM class;
ULONG ret;
memset( &cls, 0, sizeof(cls) );
cls.style = CS_HREDRAW | CS_VREDRAW;
cls.lpfnWndProc = DefWindowProcW;
cls.hInstance = GetModuleHandleW( NULL );
cls.hbrBackground = GetStockObject( WHITE_BRUSH );
cls.lpszMenuName = 0;
cls.lpszClassName = L"test";
class = RegisterClassW( &cls );
ok( class, "RegisterClassW failed: %lu\n", GetLastError() );
memset( buf, 0xcc, sizeof(buf) );
name.Buffer = buf;
name.Length = 0xdead;
name.MaximumLength = sizeof(buf);
ret = NtUserGetAtomName( class, &name );
ok( ret == 4, "NtUserGetAtomName returned %lu\n", ret );
ok( name.Length == 0xdead, "Length = %u\n", name.Length );
ok( name.MaximumLength == sizeof(buf), "MaximumLength = %u\n", name.MaximumLength );
ok( !wcscmp( buf, L"test" ), "buf = %s\n", debugstr_w(buf) );
memset( buf, 0xcc, sizeof(buf) );
name.Buffer = buf;
name.Length = 0xdead;
name.MaximumLength = 8;
ret = NtUserGetAtomName( class, &name );
ok( ret == 3, "NtUserGetAtomName returned %lu\n", ret );
ok( name.Length == 0xdead, "Length = %u\n", name.Length );
ok( name.MaximumLength == 8, "MaximumLength = %u\n", name.MaximumLength );
ok( !wcscmp( buf, L"tes" ), "buf = %s\n", debugstr_w(buf) );
memset( buf, 0xcc, sizeof(buf) );
name.Buffer = buf;
name.MaximumLength = 1;
SetLastError( 0xdeadbeef );
ret = NtUserGetAtomName( class, &name );
ok( !ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"NtUserGetAtomName returned %lx %lu\n", ret, GetLastError() );
ret = UnregisterClassW( L"test", GetModuleHandleW(NULL) );
ok( ret, "UnregisterClassW failed: %lu\n", GetLastError() );
memset( buf, 0xcc, sizeof(buf) );
name.Buffer = buf;
name.MaximumLength = sizeof(buf);
SetLastError( 0xdeadbeef );
ret = NtUserGetAtomName( class, &name );
ok( !ret && GetLastError() == ERROR_INVALID_HANDLE,
"NtUserGetAtomName returned %lx %lu\n", ret, GetLastError() );
ok( buf[0] == 0xcccc, "buf = %s\n", debugstr_w(buf) );
}
static BOOL WINAPI count_win( HWND hwnd, LPARAM lparam )
{
ULONG *cnt = (ULONG *)lparam;
......@@ -293,6 +354,7 @@ START_TEST(win32u)
test_NtUserEnumDisplayDevices();
test_window_props();
test_class();
test_NtUserBuildHwndList();
test_cursoricon();
......
......@@ -892,7 +892,7 @@
@ stub NtUserGetAncestor
@ stub NtUserGetAppImeLevel
@ stdcall NtUserGetAsyncKeyState(long)
@ stub NtUserGetAtomName
@ stdcall -syscall NtUserGetAtomName(long ptr)
@ stub NtUserGetAutoRotationState
@ stub NtUserGetCIMSSM
@ stub NtUserGetCPD
......
......@@ -256,6 +256,7 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode,
HICON WINAPI NtUserFindExistingCursorIcon( UNICODE_STRING *module, UNICODE_STRING *res_name,
void *desc );
SHORT WINAPI NtUserGetAsyncKeyState( INT key );
ULONG WINAPI NtUserGetAtomName( ATOM atom, UNICODE_STRING *name );
INT WINAPI NtUserGetClipboardFormatName( UINT format, WCHAR *buffer, INT maxlen );
HWND WINAPI NtUserGetClipboardOwner(void);
DWORD WINAPI NtUserGetClipboardSequenceNumber(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment