win32u: Move NtUserGetObjectInformation implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-10-13 14:55:30 +02:00 committed by Alexandre Julliard
parent af7ed8a538
commit b55abd072e
8 changed files with 113 additions and 96 deletions

View File

@ -4121,7 +4121,7 @@ BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC pro
/* Report physical monitor information only if window station has visible display surfaces */
winstation = NtUserGetProcessWindowStation();
if (GetUserObjectInformationW( winstation, UOI_FLAGS, &flags, sizeof(flags), NULL ))
if (NtUserGetObjectInformation( winstation, UOI_FLAGS, &flags, sizeof(flags), NULL ))
is_winstation_visible = flags.dwFlags & WSF_VISIBLE;
if (is_winstation_visible && update_monitor_cache())

View File

@ -396,7 +396,7 @@
@ stdcall GetUpdateRgn(long long long)
@ stdcall GetUpdatedClipboardFormats(ptr long ptr)
@ stdcall GetUserObjectInformationA (long long ptr long ptr)
@ stdcall GetUserObjectInformationW (long long ptr long ptr)
@ stdcall GetUserObjectInformationW (long long ptr long ptr) NtUserGetObjectInformation
@ stdcall GetUserObjectSecurity (long ptr ptr long ptr)
# @ stub GetWinStationInfo
@ stdcall GetWindow(long long)

View File

@ -437,7 +437,7 @@ BOOL WINAPI GetUserObjectInformationA( HANDLE handle, INT index, LPVOID info, DW
WCHAR buffer[MAX_PATH];
DWORD lenA, lenW;
if (!GetUserObjectInformationW( handle, index, buffer, sizeof(buffer), &lenW )) return FALSE;
if (!NtUserGetObjectInformation( handle, index, buffer, sizeof(buffer), &lenW )) return FALSE;
lenA = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
if (needed) *needed = lenA;
if (lenA > len)
@ -452,98 +452,7 @@ BOOL WINAPI GetUserObjectInformationA( HANDLE handle, INT index, LPVOID info, DW
if (info) WideCharToMultiByte( CP_ACP, 0, buffer, -1, info, len, NULL, NULL );
return TRUE;
}
return GetUserObjectInformationW( handle, index, info, len, needed );
}
/***********************************************************************
* GetUserObjectInformationW (USER32.@)
*/
BOOL WINAPI GetUserObjectInformationW( HANDLE handle, INT index, LPVOID info, DWORD len, LPDWORD needed )
{
BOOL ret;
switch(index)
{
case UOI_FLAGS:
{
USEROBJECTFLAGS *obj_flags = info;
if (needed) *needed = sizeof(*obj_flags);
if (len < sizeof(*obj_flags))
{
SetLastError( ERROR_BUFFER_OVERFLOW );
return FALSE;
}
SERVER_START_REQ( set_user_object_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
ret = !wine_server_call_err( req );
if (ret)
{
/* FIXME: inherit flag */
obj_flags->dwFlags = reply->old_obj_flags;
}
}
SERVER_END_REQ;
}
return ret;
case UOI_TYPE:
SERVER_START_REQ( set_user_object_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
ret = !wine_server_call_err( req );
if (ret)
{
size_t size = reply->is_desktop ? sizeof(L"Desktop") : sizeof(L"WindowStation");
if (needed) *needed = size;
if (len < size)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
ret = FALSE;
}
else memcpy( info, reply->is_desktop ? L"Desktop" : L"WindowStation", size );
}
}
SERVER_END_REQ;
return ret;
case UOI_NAME:
{
WCHAR buffer[MAX_PATH];
SERVER_START_REQ( set_user_object_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
wine_server_set_reply( req, buffer, sizeof(buffer) - sizeof(WCHAR) );
ret = !wine_server_call_err( req );
if (ret)
{
size_t size = wine_server_reply_size( reply );
buffer[size / sizeof(WCHAR)] = 0;
size += sizeof(WCHAR);
if (needed) *needed = size;
if (len < size)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
ret = FALSE;
}
else memcpy( info, buffer, size );
}
}
SERVER_END_REQ;
}
return ret;
case UOI_USER_SID:
FIXME( "not supported index %d\n", index );
/* fall through */
default:
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
return NtUserGetObjectInformation( handle, index, info, len, needed );
}

View File

@ -96,6 +96,7 @@ static void * const syscalls[] =
NtGdiTransformPoints,
NtUserCloseDesktop,
NtUserCloseWindowStation,
NtUserGetObjectInformation,
NtUserGetProcessWindowStation,
NtUserGetThreadDesktop,
NtUserOpenInputDesktop,

View File

@ -957,7 +957,7 @@
@ stub NtUserGetMenuItemRect
@ stub NtUserGetMessage
@ stub NtUserGetMouseMovePointsEx
@ stub NtUserGetObjectInformation
@ stdcall -syscall NtUserGetObjectInformation(long long long long ptr)
@ stub NtUserGetOemBitmapSize
@ stub NtUserGetOpenClipboardWindow
@ stub NtUserGetOwnerTransformedMonitorRect

View File

@ -152,3 +152,97 @@ HDESK WINAPI NtUserOpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK acce
return ret;
}
/***********************************************************************
* NtUserGetObjectInformation (win32u.@)
*/
BOOL WINAPI NtUserGetObjectInformation( HANDLE handle, INT index, void *info,
DWORD len, DWORD *needed )
{
BOOL ret;
static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
static const WCHAR window_stationW[] = {'W','i','n','d','o','w','S','t','a','t','i','o','n',0};
switch(index)
{
case UOI_FLAGS:
{
USEROBJECTFLAGS *obj_flags = info;
if (needed) *needed = sizeof(*obj_flags);
if (len < sizeof(*obj_flags))
{
SetLastError( ERROR_BUFFER_OVERFLOW );
return FALSE;
}
SERVER_START_REQ( set_user_object_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
ret = !wine_server_call_err( req );
if (ret)
{
/* FIXME: inherit flag */
obj_flags->dwFlags = reply->old_obj_flags;
}
}
SERVER_END_REQ;
}
return ret;
case UOI_TYPE:
SERVER_START_REQ( set_user_object_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
ret = !wine_server_call_err( req );
if (ret)
{
size_t size = reply->is_desktop ? sizeof(desktopW) : sizeof(window_stationW);
if (needed) *needed = size;
if (len < size)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
ret = FALSE;
}
else memcpy( info, reply->is_desktop ? desktopW : window_stationW, size );
}
}
SERVER_END_REQ;
return ret;
case UOI_NAME:
{
WCHAR buffer[MAX_PATH];
SERVER_START_REQ( set_user_object_info )
{
req->handle = wine_server_obj_handle( handle );
req->flags = 0;
wine_server_set_reply( req, buffer, sizeof(buffer) - sizeof(WCHAR) );
ret = !wine_server_call_err( req );
if (ret)
{
size_t size = wine_server_reply_size( reply );
buffer[size / sizeof(WCHAR)] = 0;
size += sizeof(WCHAR);
if (needed) *needed = size;
if (len < size)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
ret = FALSE;
}
else memcpy( info, buffer, size );
}
}
SERVER_END_REQ;
}
return ret;
case UOI_USER_SID:
FIXME( "not supported index %d\n", index );
/* fall through */
default:
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
}

View File

@ -75,3 +75,14 @@ NTSTATUS WINAPI wow64_NtUserOpenInputDesktop( UINT *args )
return HandleToUlong( NtUserOpenInputDesktop( flags, inherit, access ));
}
NTSTATUS WINAPI wow64_NtUserGetObjectInformation( UINT *args )
{
HANDLE handle = get_handle( &args );
INT index = get_ulong( &args );
void *info = get_ptr( &args );
DWORD len = get_ulong( &args );
DWORD *needed = get_ptr( &args );
return NtUserGetObjectInformation( handle, index, info, len, needed );
}

View File

@ -24,6 +24,8 @@
BOOL WINAPI NtUserCloseDesktop( HDESK handle );
BOOL WINAPI NtUserCloseWindowStation( HWINSTA handle );
BOOL WINAPI NtUserGetObjectInformation( HANDLE handle, INT index, void *info,
DWORD len, DWORD *needed );
HWINSTA WINAPI NtUserGetProcessWindowStation(void);
HDESK WINAPI NtUserGetThreadDesktop( DWORD thread );
HDESK WINAPI NtUserOpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK access );