2005-06-08 20:44:50 +02:00
|
|
|
/*
|
|
|
|
* Window stations and desktops
|
|
|
|
*
|
|
|
|
* Copyright 2002 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-08 20:44:50 +02:00
|
|
|
*/
|
|
|
|
|
2008-03-05 22:41:41 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
|
2005-06-08 20:44:50 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2016-01-20 14:02:03 +01:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "ddk/wdm.h"
|
2005-06-08 20:44:50 +02:00
|
|
|
#include "wine/server.h"
|
|
|
|
#include "wine/debug.h"
|
2005-07-08 13:37:40 +02:00
|
|
|
#include "user_private.h"
|
2005-06-08 20:44:50 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winstation);
|
|
|
|
|
|
|
|
|
|
|
|
/* callback for enumeration functions */
|
|
|
|
struct enum_proc_lparam
|
|
|
|
{
|
|
|
|
NAMEENUMPROCA func;
|
|
|
|
LPARAM lparam;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL CALLBACK enum_names_WtoA( LPWSTR name, LPARAM lparam )
|
|
|
|
{
|
|
|
|
struct enum_proc_lparam *data = (struct enum_proc_lparam *)lparam;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!WideCharToMultiByte( CP_ACP, 0, name, -1, buffer, sizeof(buffer), NULL, NULL ))
|
|
|
|
return FALSE;
|
|
|
|
return data->func( buffer, data->lparam );
|
|
|
|
}
|
|
|
|
|
2016-01-20 14:02:03 +01:00
|
|
|
/* return a handle to the directory where window station objects are created */
|
|
|
|
static HANDLE get_winstations_dir_handle(void)
|
|
|
|
{
|
|
|
|
static HANDLE handle = NULL;
|
2016-07-18 08:38:42 +02:00
|
|
|
WCHAR buffer[64];
|
2016-01-20 14:02:03 +01:00
|
|
|
UNICODE_STRING str;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
{
|
|
|
|
HANDLE dir;
|
|
|
|
|
2020-09-21 16:31:11 +02:00
|
|
|
swprintf( buffer, ARRAY_SIZE(buffer), L"\\Sessions\\%u\\Windows\\WindowStations", NtCurrentTeb()->Peb->SessionId );
|
2016-07-18 08:38:42 +02:00
|
|
|
RtlInitUnicodeString( &str, buffer );
|
2016-01-20 14:02:03 +01:00
|
|
|
InitializeObjectAttributes( &attr, &str, 0, 0, NULL );
|
|
|
|
NtOpenDirectoryObject( &dir, DIRECTORY_CREATE_OBJECT | DIRECTORY_TRAVERSE, &attr );
|
|
|
|
if (InterlockedCompareExchangePointer( &handle, dir, 0 ) != 0) /* someone beat us here */
|
|
|
|
CloseHandle( dir );
|
|
|
|
}
|
|
|
|
return handle;
|
|
|
|
}
|
2005-06-08 20:44:50 +02:00
|
|
|
|
2020-09-21 13:53:21 +02:00
|
|
|
static WCHAR default_name[29];
|
|
|
|
|
2020-06-23 13:56:39 +02:00
|
|
|
static BOOL WINAPI winstation_default_name_once( INIT_ONCE *once, void *param, void **context )
|
|
|
|
{
|
|
|
|
TOKEN_STATISTICS stats;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ret = GetTokenInformation( GetCurrentProcessToken(), TokenStatistics, &stats, sizeof(stats), NULL );
|
|
|
|
if (ret)
|
2020-09-21 16:31:11 +02:00
|
|
|
swprintf( default_name, ARRAY_SIZE(default_name), L"Service-0x%x-%x$",
|
2020-09-21 13:53:21 +02:00
|
|
|
stats.AuthenticationId.HighPart, stats.AuthenticationId.LowPart );
|
2020-06-23 13:56:39 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR *get_winstation_default_name( void )
|
|
|
|
{
|
|
|
|
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-09-21 13:53:21 +02:00
|
|
|
ret = InitOnceExecuteOnce( &once, winstation_default_name_once, NULL, NULL );
|
|
|
|
return ret ? default_name : NULL;
|
2020-06-23 13:56:39 +02:00
|
|
|
}
|
|
|
|
|
2005-06-08 20:44:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CreateWindowStationA (USER32.@)
|
|
|
|
*/
|
2019-04-08 07:37:30 +02:00
|
|
|
HWINSTA WINAPI CreateWindowStationA( LPCSTR name, DWORD flags, ACCESS_MASK access,
|
2005-06-08 20:44:50 +02:00
|
|
|
LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
2019-04-08 07:37:30 +02:00
|
|
|
if (!name) return CreateWindowStationW( NULL, flags, access, sa );
|
2005-06-08 20:44:50 +02:00
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2019-04-08 07:37:30 +02:00
|
|
|
return CreateWindowStationW( buffer, flags, access, sa );
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateWindowStationW (USER32.@)
|
|
|
|
*/
|
2019-04-08 07:37:30 +02:00
|
|
|
HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD flags, ACCESS_MASK access,
|
2005-06-08 20:44:50 +02:00
|
|
|
LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
2020-09-21 13:53:21 +02:00
|
|
|
DWORD len = name ? lstrlenW(name) : 0;
|
2005-06-08 20:44:50 +02:00
|
|
|
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-23 13:56:39 +02:00
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
name = get_winstation_default_name();
|
2020-09-21 13:53:21 +02:00
|
|
|
len = lstrlenW( name );
|
2020-06-23 13:56:39 +02:00
|
|
|
}
|
2005-06-08 20:44:50 +02:00
|
|
|
SERVER_START_REQ( create_winstation )
|
|
|
|
{
|
2005-11-21 13:05:38 +01:00
|
|
|
req->flags = 0;
|
|
|
|
req->access = access;
|
2019-04-08 07:37:30 +02:00
|
|
|
req->attributes = OBJ_CASE_INSENSITIVE |
|
|
|
|
((flags & CWF_CREATE_ONLY) ? 0 : OBJ_OPENIF) |
|
2005-11-21 13:05:38 +01:00
|
|
|
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
|
2016-01-20 14:02:03 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( get_winstations_dir_handle() );
|
2005-06-08 20:44:50 +02:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2016-02-01 09:53:10 +01:00
|
|
|
wine_server_call_err( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
ret = wine_server_ptr_handle( reply->handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenWindowStationA (USER32.@)
|
|
|
|
*/
|
|
|
|
HWINSTA WINAPI OpenWindowStationA( LPCSTR name, BOOL inherit, ACCESS_MASK access )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenWindowStationW( NULL, inherit, access );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OpenWindowStationW( buffer, inherit, access );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenWindowStationW (USER32.@)
|
|
|
|
*/
|
|
|
|
HWINSTA WINAPI OpenWindowStationW( LPCWSTR name, BOOL inherit, ACCESS_MASK access )
|
|
|
|
{
|
|
|
|
HANDLE ret = 0;
|
2020-09-21 13:53:21 +02:00
|
|
|
DWORD len = name ? lstrlenW(name) : 0;
|
2005-06-08 20:44:50 +02:00
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-23 13:56:39 +02:00
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
name = get_winstation_default_name();
|
2020-09-21 13:53:21 +02:00
|
|
|
len = lstrlenW( name );
|
2020-06-23 13:56:39 +02:00
|
|
|
}
|
2005-06-08 20:44:50 +02:00
|
|
|
SERVER_START_REQ( open_winstation )
|
|
|
|
{
|
2005-11-21 13:05:38 +01:00
|
|
|
req->access = access;
|
|
|
|
req->attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0);
|
2016-01-20 14:02:03 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( get_winstations_dir_handle() );
|
2005-06-08 20:44:50 +02:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumWindowStationsA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumWindowStationsA( WINSTAENUMPROCA func, LPARAM lparam )
|
|
|
|
{
|
|
|
|
struct enum_proc_lparam data;
|
|
|
|
data.func = func;
|
|
|
|
data.lparam = lparam;
|
|
|
|
return EnumWindowStationsW( enum_names_WtoA, (LPARAM)&data );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2007-12-05 16:45:32 +01:00
|
|
|
* EnumWindowStationsW (USER32.@)
|
2005-06-08 20:44:50 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumWindowStationsW( WINSTAENUMPROCW func, LPARAM lparam )
|
|
|
|
{
|
2007-12-05 16:45:32 +01:00
|
|
|
unsigned int index = 0;
|
|
|
|
WCHAR name[MAX_PATH];
|
|
|
|
BOOL ret = TRUE;
|
2008-03-05 22:41:41 +01:00
|
|
|
NTSTATUS status;
|
2007-12-05 16:45:32 +01:00
|
|
|
|
|
|
|
while (ret)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( enum_winstation )
|
|
|
|
{
|
|
|
|
req->index = index;
|
2008-03-05 22:41:41 +01:00
|
|
|
wine_server_set_reply( req, name, sizeof(name) - sizeof(WCHAR) );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
name[wine_server_reply_size(reply)/sizeof(WCHAR)] = 0;
|
2007-12-05 16:45:32 +01:00
|
|
|
index = reply->next;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2008-03-05 22:41:41 +01:00
|
|
|
if (status == STATUS_NO_MORE_ENTRIES)
|
|
|
|
break;
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError( status ) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ret = func( name, lparam );
|
2007-12-05 16:45:32 +01:00
|
|
|
}
|
|
|
|
return ret;
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateDesktopA (USER32.@)
|
|
|
|
*/
|
|
|
|
HDESK WINAPI CreateDesktopA( LPCSTR name, LPCSTR device, LPDEVMODEA devmode,
|
|
|
|
DWORD flags, ACCESS_MASK access, LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (device || devmode)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!name) return CreateDesktopW( NULL, NULL, NULL, flags, access, sa );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return CreateDesktopW( buffer, NULL, NULL, flags, access, sa );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateDesktopW (USER32.@)
|
|
|
|
*/
|
|
|
|
HDESK WINAPI CreateDesktopW( LPCWSTR name, LPCWSTR device, LPDEVMODEW devmode,
|
|
|
|
DWORD flags, ACCESS_MASK access, LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
2020-09-21 13:53:21 +02:00
|
|
|
DWORD len = name ? lstrlenW(name) : 0;
|
2005-06-08 20:44:50 +02:00
|
|
|
|
|
|
|
if (device || devmode)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
SERVER_START_REQ( create_desktop )
|
|
|
|
{
|
2005-11-21 13:05:38 +01:00
|
|
|
req->flags = flags;
|
|
|
|
req->access = access;
|
|
|
|
req->attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
|
|
|
|
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
|
2005-06-08 20:44:50 +02:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2016-02-01 09:53:10 +01:00
|
|
|
wine_server_call_err( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
ret = wine_server_ptr_handle( reply->handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenDesktopA (USER32.@)
|
|
|
|
*/
|
|
|
|
HDESK WINAPI OpenDesktopA( LPCSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenDesktopW( NULL, flags, inherit, access );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OpenDesktopW( buffer, flags, inherit, access );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-01 21:15:55 +02:00
|
|
|
HDESK open_winstation_desktop( HWINSTA hwinsta, LPCWSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access )
|
2005-06-08 20:44:50 +02:00
|
|
|
{
|
|
|
|
HANDLE ret = 0;
|
2020-09-21 13:53:21 +02:00
|
|
|
DWORD len = name ? lstrlenW(name) : 0;
|
2005-06-08 20:44:50 +02:00
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
SERVER_START_REQ( open_desktop )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->winsta = wine_server_obj_handle( hwinsta );
|
2005-11-21 13:05:38 +01:00
|
|
|
req->flags = flags;
|
|
|
|
req->access = access;
|
|
|
|
req->attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0);
|
2005-06-08 20:44:50 +02:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2016-02-01 09:53:10 +01:00
|
|
|
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-01 21:15:55 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* OpenDesktopW (USER32.@)
|
|
|
|
*/
|
|
|
|
HDESK WINAPI OpenDesktopW( LPCWSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access )
|
|
|
|
{
|
|
|
|
return open_winstation_desktop( NULL, name, flags, inherit, access );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-08 20:44:50 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* SetThreadDesktop (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetThreadDesktop( HDESK handle )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_thread_desktop )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2008-06-25 14:26:06 +02:00
|
|
|
if (ret) /* reset the desktop windows */
|
|
|
|
{
|
|
|
|
struct user_thread_info *thread_info = get_user_thread_info();
|
2015-04-07 02:33:28 +02:00
|
|
|
struct user_key_state_info *key_state_info = thread_info->key_state;
|
2008-06-25 14:26:06 +02:00
|
|
|
thread_info->top_window = 0;
|
|
|
|
thread_info->msg_window = 0;
|
2015-04-07 02:33:28 +02:00
|
|
|
if (key_state_info) key_state_info->time = 0;
|
2008-06-25 14:26:06 +02:00
|
|
|
}
|
2005-06-08 20:44:50 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumDesktopsA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumDesktopsA( HWINSTA winsta, DESKTOPENUMPROCA func, LPARAM lparam )
|
|
|
|
{
|
|
|
|
struct enum_proc_lparam data;
|
|
|
|
data.func = func;
|
|
|
|
data.lparam = lparam;
|
|
|
|
return EnumDesktopsW( winsta, enum_names_WtoA, (LPARAM)&data );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumDesktopsW (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumDesktopsW( HWINSTA winsta, DESKTOPENUMPROCW func, LPARAM lparam )
|
|
|
|
{
|
2007-12-05 16:45:32 +01:00
|
|
|
unsigned int index = 0;
|
|
|
|
WCHAR name[MAX_PATH];
|
|
|
|
BOOL ret = TRUE;
|
2008-03-05 22:41:41 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
if (!winsta)
|
2021-10-13 14:52:53 +02:00
|
|
|
winsta = NtUserGetProcessWindowStation();
|
2007-12-05 16:45:32 +01:00
|
|
|
|
|
|
|
while (ret)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( enum_desktop )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->winstation = wine_server_obj_handle( winsta );
|
2007-12-05 16:45:32 +01:00
|
|
|
req->index = index;
|
2008-03-05 22:41:41 +01:00
|
|
|
wine_server_set_reply( req, name, sizeof(name) - sizeof(WCHAR) );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
name[wine_server_reply_size(reply)/sizeof(WCHAR)] = 0;
|
2007-12-05 16:45:32 +01:00
|
|
|
index = reply->next;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2008-03-05 22:41:41 +01:00
|
|
|
if (status == STATUS_NO_MORE_ENTRIES)
|
|
|
|
break;
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError( status ) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ret = func(name, lparam);
|
2007-12-05 16:45:32 +01:00
|
|
|
}
|
|
|
|
return ret;
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenInputDesktop (USER32.@)
|
|
|
|
*/
|
|
|
|
HDESK WINAPI OpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK access )
|
|
|
|
{
|
2013-11-08 10:10:24 +01:00
|
|
|
HANDLE ret = 0;
|
|
|
|
|
|
|
|
TRACE( "(%x,%i,%x)\n", flags, inherit, access );
|
|
|
|
|
|
|
|
if (flags)
|
|
|
|
FIXME( "partial stub flags %08x\n", flags );
|
|
|
|
|
|
|
|
SERVER_START_REQ( open_input_desktop )
|
|
|
|
{
|
|
|
|
req->flags = flags;
|
|
|
|
req->access = access;
|
|
|
|
req->attributes = inherit ? OBJ_INHERIT : 0;
|
|
|
|
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return ret;
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetUserObjectInformationA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetUserObjectInformationA( HANDLE handle, INT index, LPVOID info, DWORD len, LPDWORD needed )
|
|
|
|
{
|
|
|
|
/* check for information types returning strings */
|
|
|
|
if (index == UOI_TYPE || index == UOI_NAME)
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
2012-05-14 16:25:03 +02:00
|
|
|
DWORD lenA, lenW;
|
2005-06-08 20:44:50 +02:00
|
|
|
|
2012-05-14 16:25:03 +02:00
|
|
|
if (!GetUserObjectInformationW( handle, index, buffer, sizeof(buffer), &lenW )) return FALSE;
|
2005-06-08 20:44:50 +02:00
|
|
|
lenA = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
|
|
|
|
if (needed) *needed = lenA;
|
|
|
|
if (lenA > len)
|
|
|
|
{
|
2012-05-14 16:25:03 +02:00
|
|
|
/* If the buffer length supplied by the caller is insufficient, Windows returns a
|
|
|
|
'needed' length based upon the Unicode byte length, so we should do similarly. */
|
|
|
|
if (needed) *needed = lenW;
|
|
|
|
|
2012-05-14 16:23:29 +02:00
|
|
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
2005-06-08 20:44:50 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
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 )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
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 )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
req->flags = 0;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
if (ret)
|
|
|
|
{
|
2020-09-21 16:31:11 +02:00
|
|
|
size_t size = reply->is_desktop ? sizeof(L"Desktop") : sizeof(L"WindowStation");
|
2005-06-08 20:44:50 +02:00
|
|
|
if (needed) *needed = size;
|
|
|
|
if (len < size)
|
|
|
|
{
|
2012-05-14 16:23:29 +02:00
|
|
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
2005-06-08 20:44:50 +02:00
|
|
|
ret = FALSE;
|
|
|
|
}
|
2020-09-21 16:31:11 +02:00
|
|
|
else memcpy( info, reply->is_desktop ? L"Desktop" : L"WindowStation", size );
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
case UOI_NAME:
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
SERVER_START_REQ( set_user_object_info )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2005-06-08 20:44:50 +02:00
|
|
|
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)
|
|
|
|
{
|
2012-05-14 16:23:29 +02:00
|
|
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
2005-06-08 20:44:50 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetUserObjectInformationA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetUserObjectInformationA( HANDLE handle, INT index, LPVOID info, DWORD len )
|
|
|
|
{
|
|
|
|
return SetUserObjectInformationW( handle, index, info, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetUserObjectInformationW (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetUserObjectInformationW( HANDLE handle, INT index, LPVOID info, DWORD len )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
const USEROBJECTFLAGS *obj_flags = info;
|
|
|
|
|
|
|
|
if (index != UOI_FLAGS || !info || len < sizeof(*obj_flags))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* FIXME: inherit flag */
|
|
|
|
SERVER_START_REQ( set_user_object_info )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2015-12-04 01:19:58 +01:00
|
|
|
req->flags = SET_USER_OBJECT_SET_FLAGS;
|
2005-06-08 20:44:50 +02:00
|
|
|
req->obj_flags = obj_flags->dwFlags;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetUserObjectSecurity (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetUserObjectSecurity( HANDLE handle, PSECURITY_INFORMATION info,
|
|
|
|
PSECURITY_DESCRIPTOR sid, DWORD len, LPDWORD needed )
|
|
|
|
{
|
2006-09-30 00:25:15 +02:00
|
|
|
FIXME( "(%p %p %p len=%d %p),stub!\n", handle, info, sid, len, needed );
|
2009-01-03 16:35:18 +01:00
|
|
|
if (needed)
|
|
|
|
*needed = sizeof(SECURITY_DESCRIPTOR);
|
|
|
|
if (len < sizeof(SECURITY_DESCRIPTOR))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return InitializeSecurityDescriptor(sid, SECURITY_DESCRIPTOR_REVISION);
|
2005-06-08 20:44:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetUserObjectSecurity (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetUserObjectSecurity( HANDLE handle, PSECURITY_INFORMATION info,
|
|
|
|
PSECURITY_DESCRIPTOR sid )
|
|
|
|
{
|
|
|
|
FIXME( "(%p,%p,%p),stub!\n", handle, info, sid );
|
|
|
|
return TRUE;
|
|
|
|
}
|