2005-06-08 11:44:50 -07:00
|
|
|
/*
|
|
|
|
* Server-side window stations and desktops handling
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002, 2005 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 05:49:52 -07:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-08 11:44:50 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2021-10-11 02:43:27 -07:00
|
|
|
#include <sys/types.h>
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2005-11-28 09:32:54 -07:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2005-06-08 11:44:50 -07:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2005-10-27 11:30:37 -07:00
|
|
|
#include "winternl.h"
|
2023-06-14 10:25:40 -07:00
|
|
|
#include "ntuser.h"
|
2005-06-08 11:44:50 -07:00
|
|
|
|
|
|
|
#include "object.h"
|
|
|
|
#include "handle.h"
|
|
|
|
#include "request.h"
|
|
|
|
#include "process.h"
|
2005-06-09 02:43:54 -07:00
|
|
|
#include "user.h"
|
2006-03-06 13:02:24 -07:00
|
|
|
#include "file.h"
|
2008-04-15 14:32:43 -07:00
|
|
|
#include "security.h"
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2021-02-05 04:08:42 -07:00
|
|
|
#define DESKTOP_ALL_ACCESS 0x01ff
|
2005-06-08 11:44:50 -07:00
|
|
|
|
|
|
|
static struct list winstation_list = LIST_INIT(winstation_list);
|
|
|
|
|
|
|
|
static void winstation_dump( struct object *obj, int verbose );
|
2005-06-09 08:39:52 -07:00
|
|
|
static int winstation_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
|
2016-02-07 22:02:45 -07:00
|
|
|
static struct object *winstation_lookup_name( struct object *obj, struct unicode_str *name,
|
2020-11-25 11:42:42 -07:00
|
|
|
unsigned int attr, struct object *root );
|
2005-06-08 11:44:50 -07:00
|
|
|
static void winstation_destroy( struct object *obj );
|
|
|
|
static void desktop_dump( struct object *obj, int verbose );
|
2016-02-04 05:08:02 -07:00
|
|
|
static int desktop_link_name( struct object *obj, struct object_name *name, struct object *parent );
|
2005-06-09 08:39:52 -07:00
|
|
|
static int desktop_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
|
2005-06-08 11:44:50 -07:00
|
|
|
static void desktop_destroy( struct object *obj );
|
|
|
|
|
2021-02-04 05:44:18 -07:00
|
|
|
static const WCHAR winstation_name[] = {'W','i','n','d','o','w','S','t','a','t','i','o','n'};
|
|
|
|
|
|
|
|
struct type_descr winstation_type =
|
|
|
|
{
|
|
|
|
{ winstation_name, sizeof(winstation_name) }, /* name */
|
2021-02-05 04:08:42 -07:00
|
|
|
STANDARD_RIGHTS_REQUIRED | WINSTA_ALL_ACCESS, /* valid_access */
|
|
|
|
{ /* mapping */
|
|
|
|
STANDARD_RIGHTS_READ | WINSTA_READSCREEN | WINSTA_ENUMERATE | WINSTA_READATTRIBUTES | WINSTA_ENUMDESKTOPS,
|
|
|
|
STANDARD_RIGHTS_WRITE | WINSTA_WRITEATTRIBUTES | WINSTA_CREATEDESKTOP | WINSTA_ACCESSCLIPBOARD,
|
|
|
|
STANDARD_RIGHTS_EXECUTE | WINSTA_EXITWINDOWS | WINSTA_ACCESSGLOBALATOMS,
|
|
|
|
STANDARD_RIGHTS_REQUIRED | WINSTA_ALL_ACCESS
|
|
|
|
},
|
2021-02-04 05:44:18 -07:00
|
|
|
};
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
static const struct object_ops winstation_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct winstation), /* size */
|
2021-02-04 05:44:18 -07:00
|
|
|
&winstation_type, /* type */
|
2005-06-08 11:44:50 -07:00
|
|
|
winstation_dump, /* dump */
|
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
|
|
|
NULL, /* satisfied */
|
|
|
|
no_signal, /* signal */
|
|
|
|
no_get_fd, /* get_fd */
|
2021-02-05 04:10:44 -07:00
|
|
|
default_map_access, /* map_access */
|
2007-10-03 05:10:37 -07:00
|
|
|
default_get_sd, /* get_sd */
|
|
|
|
default_set_sd, /* set_sd */
|
2020-09-22 07:52:31 -07:00
|
|
|
default_get_full_name, /* get_full_name */
|
2016-02-07 22:02:45 -07:00
|
|
|
winstation_lookup_name, /* lookup_name */
|
2016-02-04 05:08:02 -07:00
|
|
|
directory_link_name, /* link_name */
|
|
|
|
default_unlink_name, /* unlink_name */
|
2007-03-22 03:44:29 -07:00
|
|
|
no_open_file, /* open_file */
|
2019-03-25 06:37:09 -07:00
|
|
|
no_kernel_obj_list, /* get_kernel_obj_list */
|
2005-06-09 08:39:52 -07:00
|
|
|
winstation_close_handle, /* close_handle */
|
2005-06-08 11:44:50 -07:00
|
|
|
winstation_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-02-04 05:44:18 -07:00
|
|
|
static const WCHAR desktop_name[] = {'D','e','s','k','t','o','p'};
|
|
|
|
|
|
|
|
struct type_descr desktop_type =
|
|
|
|
{
|
|
|
|
{ desktop_name, sizeof(desktop_name) }, /* name */
|
2021-02-05 04:08:42 -07:00
|
|
|
STANDARD_RIGHTS_REQUIRED | DESKTOP_ALL_ACCESS, /* valid_access */
|
|
|
|
{ /* mapping */
|
|
|
|
STANDARD_RIGHTS_READ | DESKTOP_ENUMERATE | DESKTOP_READOBJECTS,
|
|
|
|
STANDARD_RIGHTS_WRITE | DESKTOP_WRITEOBJECTS | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD
|
|
|
|
| DESKTOP_HOOKCONTROL | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW,
|
|
|
|
STANDARD_RIGHTS_EXECUTE | DESKTOP_SWITCHDESKTOP,
|
|
|
|
STANDARD_RIGHTS_REQUIRED | DESKTOP_ALL_ACCESS
|
|
|
|
},
|
2021-02-04 05:44:18 -07:00
|
|
|
};
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
static const struct object_ops desktop_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct desktop), /* size */
|
2021-02-04 05:44:18 -07:00
|
|
|
&desktop_type, /* type */
|
2005-06-08 11:44:50 -07:00
|
|
|
desktop_dump, /* dump */
|
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
|
|
|
NULL, /* satisfied */
|
|
|
|
no_signal, /* signal */
|
|
|
|
no_get_fd, /* get_fd */
|
2021-02-05 04:10:44 -07:00
|
|
|
default_map_access, /* map_access */
|
2007-10-03 05:10:37 -07:00
|
|
|
default_get_sd, /* get_sd */
|
|
|
|
default_set_sd, /* set_sd */
|
2020-09-22 07:52:31 -07:00
|
|
|
default_get_full_name, /* get_full_name */
|
2005-11-22 07:55:42 -07:00
|
|
|
no_lookup_name, /* lookup_name */
|
2016-02-04 05:08:02 -07:00
|
|
|
desktop_link_name, /* link_name */
|
|
|
|
default_unlink_name, /* unlink_name */
|
2007-03-22 03:44:29 -07:00
|
|
|
no_open_file, /* open_file */
|
2019-03-25 06:37:09 -07:00
|
|
|
no_kernel_obj_list, /* get_kernel_obj_list */
|
2005-06-09 08:39:52 -07:00
|
|
|
desktop_close_handle, /* close_handle */
|
2005-06-08 11:44:50 -07:00
|
|
|
desktop_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* create a winstation object */
|
2016-02-12 05:00:41 -07:00
|
|
|
static struct winstation *create_winstation( struct object *root, const struct unicode_str *name,
|
2016-01-20 06:02:03 -07:00
|
|
|
unsigned int attr, unsigned int flags )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
|
|
|
|
2016-02-12 06:57:33 -07:00
|
|
|
if ((winstation = create_named_object( root, &winstation_ops, name, attr, NULL )))
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2005-11-21 09:27:03 -07:00
|
|
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
|
|
|
/* initialize it if it didn't already exist */
|
|
|
|
winstation->flags = flags;
|
2024-01-27 13:03:41 -07:00
|
|
|
winstation->input_desktop = NULL;
|
2005-06-29 13:13:36 -07:00
|
|
|
winstation->clipboard = NULL;
|
2005-07-07 04:29:23 -07:00
|
|
|
winstation->atom_table = NULL;
|
2024-09-25 02:07:40 -07:00
|
|
|
winstation->monitors = NULL;
|
|
|
|
winstation->monitor_count = 0;
|
2005-06-08 11:44:50 -07:00
|
|
|
list_add_tail( &winstation_list, &winstation->entry );
|
|
|
|
list_init( &winstation->desktops );
|
2016-01-20 06:27:44 -07:00
|
|
|
if (!(winstation->desktop_names = create_namespace( 7 )))
|
|
|
|
{
|
|
|
|
release_object( winstation );
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
2016-02-02 05:46:46 -07:00
|
|
|
else clear_error();
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
return winstation;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void winstation_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
struct winstation *winstation = (struct winstation *)obj;
|
|
|
|
|
2016-01-21 05:08:56 -07:00
|
|
|
fprintf( stderr, "Winstation flags=%x clipboard=%p atoms=%p\n",
|
2005-07-11 06:30:23 -07:00
|
|
|
winstation->flags, winstation->clipboard, winstation->atom_table );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2005-06-09 08:39:52 -07:00
|
|
|
static int winstation_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
|
|
|
|
{
|
|
|
|
return (process->winstation != handle);
|
|
|
|
}
|
|
|
|
|
2016-02-07 22:02:45 -07:00
|
|
|
static struct object *winstation_lookup_name( struct object *obj, struct unicode_str *name,
|
2020-11-25 11:42:42 -07:00
|
|
|
unsigned int attr, struct object *root )
|
2016-02-07 22:02:45 -07:00
|
|
|
{
|
|
|
|
struct winstation *winstation = (struct winstation *)obj;
|
|
|
|
struct object *found;
|
|
|
|
|
|
|
|
assert( obj->ops == &winstation_ops );
|
|
|
|
|
2016-02-09 04:16:27 -07:00
|
|
|
if (!name) return NULL; /* open the winstation itself */
|
|
|
|
|
2020-03-24 04:47:31 -07:00
|
|
|
if (get_path_element( name->str, name->len ) < name->len) /* no backslash allowed in name */
|
2016-02-07 22:02:45 -07:00
|
|
|
{
|
|
|
|
set_error( STATUS_OBJECT_PATH_SYNTAX_BAD );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((found = find_object( winstation->desktop_names, name, attr )))
|
|
|
|
name->len = 0;
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
static void winstation_destroy( struct object *obj )
|
|
|
|
{
|
|
|
|
struct winstation *winstation = (struct winstation *)obj;
|
|
|
|
|
|
|
|
list_remove( &winstation->entry );
|
2005-06-29 13:13:36 -07:00
|
|
|
if (winstation->clipboard) release_object( winstation->clipboard );
|
2005-07-07 04:29:23 -07:00
|
|
|
if (winstation->atom_table) release_object( winstation->atom_table );
|
2016-01-20 06:27:44 -07:00
|
|
|
free( winstation->desktop_names );
|
2024-09-25 02:07:40 -07:00
|
|
|
free( winstation->monitors );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* retrieve the process window station, checking the handle access rights */
|
2005-06-29 13:13:36 -07:00
|
|
|
struct winstation *get_process_winstation( struct process *process, unsigned int access )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
|
|
|
return (struct winstation *)get_handle_obj( process, process->winstation,
|
|
|
|
access, &winstation_ops );
|
|
|
|
}
|
|
|
|
|
2024-02-25 01:33:06 -07:00
|
|
|
/* retrieve the visible winstation */
|
|
|
|
struct winstation *get_visible_winstation(void)
|
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
|
|
|
LIST_FOR_EACH_ENTRY( winstation, &winstation_list, struct winstation, entry )
|
|
|
|
if (winstation->flags & WSF_VISIBLE) return winstation;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-01-27 13:03:41 -07:00
|
|
|
/* retrieve the winstation current input desktop */
|
2024-02-25 01:33:06 -07:00
|
|
|
struct desktop *get_input_desktop( struct winstation *winstation )
|
2024-01-27 13:03:41 -07:00
|
|
|
{
|
|
|
|
struct desktop *desktop;
|
|
|
|
if (!(desktop = winstation->input_desktop)) return NULL;
|
|
|
|
return (struct desktop *)grab_object( desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* changes the winstation current input desktop and update its input time */
|
2024-02-25 01:33:06 -07:00
|
|
|
int set_input_desktop( struct winstation *winstation, struct desktop *new_desktop )
|
2024-01-27 13:03:41 -07:00
|
|
|
{
|
2024-02-25 01:53:09 -07:00
|
|
|
struct desktop *old_desktop = winstation->input_desktop;
|
|
|
|
struct thread *thread;
|
|
|
|
|
2024-01-27 13:03:41 -07:00
|
|
|
if (!(winstation->flags & WSF_VISIBLE)) return 0;
|
|
|
|
if (new_desktop) new_desktop->input_time = current_time;
|
2024-02-25 01:53:09 -07:00
|
|
|
if (old_desktop == new_desktop) return 1;
|
|
|
|
|
|
|
|
if (old_desktop)
|
|
|
|
{
|
|
|
|
/* disconnect every process of the old input desktop from rawinput */
|
|
|
|
LIST_FOR_EACH_ENTRY( thread, &old_desktop->threads, struct thread, desktop_entry )
|
|
|
|
set_rawinput_process( thread->process, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((winstation->input_desktop = new_desktop))
|
|
|
|
{
|
|
|
|
/* connect every process of the new input desktop to rawinput */
|
|
|
|
LIST_FOR_EACH_ENTRY( thread, &new_desktop->threads, struct thread, desktop_entry )
|
|
|
|
set_rawinput_process( thread->process, 1 );
|
|
|
|
}
|
|
|
|
|
2024-01-27 13:03:41 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-06-28 12:37:52 -07:00
|
|
|
/* retrieve a pointer to a desktop object */
|
2008-03-18 07:17:40 -07:00
|
|
|
struct desktop *get_desktop_obj( struct process *process, obj_handle_t handle, unsigned int access )
|
2005-06-28 12:37:52 -07:00
|
|
|
{
|
|
|
|
return (struct desktop *)get_handle_obj( process, handle, access, &desktop_ops );
|
|
|
|
}
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
/* create a desktop object */
|
2005-11-21 05:05:38 -07:00
|
|
|
static struct desktop *create_desktop( const struct unicode_str *name, unsigned int attr,
|
|
|
|
unsigned int flags, struct winstation *winstation )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2024-01-07 07:25:24 -07:00
|
|
|
struct desktop *desktop, *current_desktop;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2016-02-12 06:57:33 -07:00
|
|
|
if ((desktop = create_named_object( &winstation->obj, &desktop_ops, name, attr, NULL )))
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2005-11-21 09:27:03 -07:00
|
|
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
|
|
|
/* initialize it if it didn't already exist */
|
2024-01-07 07:25:24 -07:00
|
|
|
|
|
|
|
/* inherit DF_WINE_*_DESKTOP flags if none of them are specified */
|
|
|
|
if (!(flags & (DF_WINE_ROOT_DESKTOP | DF_WINE_VIRTUAL_DESKTOP))
|
|
|
|
&& (current_desktop = get_thread_desktop( current, 0 )))
|
|
|
|
{
|
2024-06-21 13:27:44 -07:00
|
|
|
flags |= current_desktop->shared->flags & (DF_WINE_VIRTUAL_DESKTOP | DF_WINE_ROOT_DESKTOP);
|
2024-01-07 07:25:24 -07:00
|
|
|
release_object( current_desktop );
|
|
|
|
}
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
desktop->winstation = (struct winstation *)grab_object( winstation );
|
2005-07-11 06:30:23 -07:00
|
|
|
desktop->top_window = NULL;
|
2008-06-25 05:43:39 -07:00
|
|
|
desktop->msg_window = NULL;
|
2024-09-26 11:55:51 -07:00
|
|
|
desktop->shell_window = NULL;
|
|
|
|
desktop->shell_listview = NULL;
|
|
|
|
desktop->progman_window = NULL;
|
|
|
|
desktop->taskman_window = NULL;
|
2005-07-11 11:05:50 -07:00
|
|
|
desktop->global_hooks = NULL;
|
2006-03-06 13:02:24 -07:00
|
|
|
desktop->close_timeout = NULL;
|
2011-02-24 08:45:04 -07:00
|
|
|
desktop->foreground_input = NULL;
|
2006-03-06 13:02:24 -07:00
|
|
|
desktop->users = 0;
|
2024-01-27 14:00:12 -07:00
|
|
|
list_init( &desktop->threads );
|
2024-02-19 14:27:55 -07:00
|
|
|
desktop->clip_flags = 0;
|
|
|
|
desktop->cursor_win = 0;
|
2024-06-20 14:59:52 -07:00
|
|
|
desktop->alt_pressed = 0;
|
2024-05-27 02:48:52 -07:00
|
|
|
memset( &desktop->key_repeat, 0, sizeof(desktop->key_repeat) );
|
2005-06-08 11:44:50 -07:00
|
|
|
list_add_tail( &winstation->desktops, &desktop->entry );
|
2011-05-26 13:52:17 -07:00
|
|
|
list_init( &desktop->hotkeys );
|
2021-10-04 11:57:55 -07:00
|
|
|
list_init( &desktop->pointers );
|
2024-05-07 00:52:18 -07:00
|
|
|
|
|
|
|
if (!(desktop->shared = alloc_shared_object()))
|
|
|
|
{
|
|
|
|
release_object( desktop );
|
|
|
|
return NULL;
|
|
|
|
}
|
2024-04-28 02:05:31 -07:00
|
|
|
|
|
|
|
SHARED_WRITE_BEGIN( desktop->shared, desktop_shm_t )
|
|
|
|
{
|
2024-06-21 13:27:44 -07:00
|
|
|
shared->flags = flags;
|
2024-04-28 02:05:31 -07:00
|
|
|
shared->cursor.x = 0;
|
|
|
|
shared->cursor.y = 0;
|
2024-02-19 14:17:27 -07:00
|
|
|
shared->cursor.last_change = 0;
|
2024-02-19 14:25:01 -07:00
|
|
|
shared->cursor.clip.left = 0;
|
|
|
|
shared->cursor.clip.top = 0;
|
|
|
|
shared->cursor.clip.right = 0;
|
|
|
|
shared->cursor.clip.bottom = 0;
|
2024-06-20 15:11:11 -07:00
|
|
|
memset( (void *)shared->keystate, 0, sizeof(shared->keystate) );
|
2024-04-28 02:05:31 -07:00
|
|
|
}
|
|
|
|
SHARED_WRITE_END;
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
2023-06-14 10:25:40 -07:00
|
|
|
else
|
|
|
|
{
|
2024-06-21 13:27:44 -07:00
|
|
|
SHARED_WRITE_BEGIN( desktop->shared, desktop_shm_t )
|
|
|
|
{
|
|
|
|
shared->flags |= flags & (DF_WINE_VIRTUAL_DESKTOP | DF_WINE_ROOT_DESKTOP);
|
|
|
|
}
|
|
|
|
SHARED_WRITE_END;
|
|
|
|
|
2023-06-14 10:25:40 -07:00
|
|
|
clear_error();
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
return desktop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
struct desktop *desktop = (struct desktop *)obj;
|
|
|
|
|
2016-01-21 05:08:56 -07:00
|
|
|
fprintf( stderr, "Desktop flags=%x winstation=%p top_win=%p hooks=%p\n",
|
2024-06-21 13:27:44 -07:00
|
|
|
desktop->shared->flags, desktop->winstation, desktop->top_window, desktop->global_hooks );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2016-02-04 05:08:02 -07:00
|
|
|
static int desktop_link_name( struct object *obj, struct object_name *name, struct object *parent )
|
|
|
|
{
|
|
|
|
struct winstation *winstation = (struct winstation *)parent;
|
|
|
|
|
|
|
|
if (parent->ops != &winstation_ops)
|
|
|
|
{
|
|
|
|
set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-24 04:47:31 -07:00
|
|
|
if (get_path_element( name->name, name->len ) < name->len) /* no backslash allowed in name */
|
2016-02-04 05:08:02 -07:00
|
|
|
{
|
|
|
|
set_error( STATUS_OBJECT_PATH_SYNTAX_BAD );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
namespace_add( winstation->desktop_names, name );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-06-09 08:39:52 -07:00
|
|
|
static int desktop_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2005-06-09 08:39:52 -07:00
|
|
|
struct thread *thread;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2005-06-09 08:39:52 -07:00
|
|
|
/* check if the handle is currently used by the process or one of its threads */
|
|
|
|
if (process->desktop == handle) return 0;
|
|
|
|
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
|
|
|
|
if (thread->desktop == handle) return 0;
|
|
|
|
return 1;
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2005-06-09 08:39:52 -07:00
|
|
|
static void desktop_destroy( struct object *obj )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2005-06-09 08:39:52 -07:00
|
|
|
struct desktop *desktop = (struct desktop *)obj;
|
2024-01-27 13:03:41 -07:00
|
|
|
struct winstation *winstation = desktop->winstation;
|
|
|
|
|
2024-03-08 09:02:53 -07:00
|
|
|
list_remove( &desktop->entry );
|
|
|
|
|
2024-01-27 13:03:41 -07:00
|
|
|
if (desktop == winstation->input_desktop)
|
|
|
|
{
|
|
|
|
struct desktop *other, *found = NULL;
|
|
|
|
LIST_FOR_EACH_ENTRY(other, &winstation->desktops, struct desktop, entry)
|
|
|
|
if (!found || other->input_time > found->input_time) found = other;
|
|
|
|
set_input_desktop( winstation, found );
|
|
|
|
}
|
2005-06-09 05:07:12 -07:00
|
|
|
|
2011-05-26 13:52:17 -07:00
|
|
|
free_hotkeys( desktop, 0 );
|
2021-10-04 11:57:55 -07:00
|
|
|
free_pointers( desktop );
|
2022-02-08 05:12:43 -07:00
|
|
|
if (desktop->top_window) free_window_handle( desktop->top_window );
|
|
|
|
if (desktop->msg_window) free_window_handle( desktop->msg_window );
|
2005-07-11 11:05:50 -07:00
|
|
|
if (desktop->global_hooks) release_object( desktop->global_hooks );
|
2006-03-06 13:02:24 -07:00
|
|
|
if (desktop->close_timeout) remove_timeout_user( desktop->close_timeout );
|
2024-05-27 02:48:52 -07:00
|
|
|
if (desktop->key_repeat.timeout) remove_timeout_user( desktop->key_repeat.timeout );
|
2005-06-09 08:39:52 -07:00
|
|
|
release_object( desktop->winstation );
|
2024-05-07 00:52:18 -07:00
|
|
|
if (desktop->shared) free_shared_object( desktop->shared );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2005-07-11 03:55:53 -07:00
|
|
|
/* retrieve the thread desktop, checking the handle access rights */
|
|
|
|
struct desktop *get_thread_desktop( struct thread *thread, unsigned int access )
|
|
|
|
{
|
|
|
|
return get_desktop_obj( thread->process, thread->desktop, access );
|
|
|
|
}
|
|
|
|
|
2013-04-30 04:55:54 -07:00
|
|
|
static void close_desktop_timeout( void *private )
|
|
|
|
{
|
|
|
|
struct desktop *desktop = private;
|
|
|
|
|
|
|
|
desktop->close_timeout = NULL;
|
|
|
|
unlink_named_object( &desktop->obj ); /* make sure no other process can open it */
|
|
|
|
post_desktop_message( desktop, WM_CLOSE, 0, 0 ); /* and signal the owner to quit */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add a user of the desktop and cancel the close timeout */
|
2024-01-27 14:00:12 -07:00
|
|
|
static void add_desktop_thread( struct desktop *desktop, struct thread *thread )
|
2013-04-30 04:55:54 -07:00
|
|
|
{
|
2024-01-27 14:00:12 -07:00
|
|
|
list_add_tail( &desktop->threads, &thread->desktop_entry );
|
2024-06-24 14:35:06 -07:00
|
|
|
add_desktop_hook_count( desktop, thread, 1 );
|
2024-01-27 14:00:12 -07:00
|
|
|
|
|
|
|
if (!thread->process->is_system)
|
2013-04-30 04:55:54 -07:00
|
|
|
{
|
2024-01-27 14:00:12 -07:00
|
|
|
desktop->users++;
|
|
|
|
if (desktop->close_timeout)
|
|
|
|
{
|
|
|
|
remove_timeout_user( desktop->close_timeout );
|
|
|
|
desktop->close_timeout = NULL;
|
|
|
|
}
|
2013-04-30 04:55:54 -07:00
|
|
|
}
|
2024-02-25 01:53:09 -07:00
|
|
|
|
|
|
|
/* if thread process is now connected to the input desktop, let it receive rawinput */
|
|
|
|
if (desktop == desktop->winstation->input_desktop) set_rawinput_process( thread->process, 1 );
|
2013-04-30 04:55:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove a user of the desktop and start the close timeout if necessary */
|
2024-03-21 10:49:56 -07:00
|
|
|
static void remove_desktop_user( struct desktop *desktop, struct thread *thread )
|
2013-04-30 04:55:54 -07:00
|
|
|
{
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
struct process *process;
|
2013-04-30 04:55:54 -07:00
|
|
|
|
2024-03-21 10:49:56 -07:00
|
|
|
assert( desktop->users > 0 );
|
|
|
|
desktop->users--;
|
2024-01-27 14:00:12 -07:00
|
|
|
|
2024-03-21 10:49:56 -07:00
|
|
|
/* if we have one remaining user, it has to be the manager of the desktop window */
|
|
|
|
if ((process = get_top_window_owner( desktop )) && desktop->users == process->running_threads && !desktop->close_timeout)
|
|
|
|
desktop->close_timeout = add_timeout_user( -TICKS_PER_SEC, close_desktop_timeout, desktop );
|
|
|
|
}
|
2024-01-27 14:00:12 -07:00
|
|
|
|
2024-03-21 10:49:56 -07:00
|
|
|
/* remove a thread from the list of threads attached to a desktop */
|
|
|
|
static void remove_desktop_thread( struct desktop *desktop, struct thread *thread )
|
|
|
|
{
|
2024-06-24 14:35:06 -07:00
|
|
|
add_desktop_hook_count( desktop, thread, -1 );
|
2024-03-21 10:49:56 -07:00
|
|
|
list_remove( &thread->desktop_entry );
|
|
|
|
|
|
|
|
if (!thread->process->is_system) remove_desktop_user( desktop, thread );
|
2024-02-25 01:53:09 -07:00
|
|
|
|
|
|
|
if (desktop == desktop->winstation->input_desktop)
|
|
|
|
{
|
|
|
|
/* thread process might still be connected the input desktop through another thread, update the full list */
|
|
|
|
LIST_FOR_EACH_ENTRY( thread, &desktop->threads, struct thread, desktop_entry )
|
|
|
|
set_rawinput_process( thread->process, 1 );
|
|
|
|
}
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set the thread default desktop handle */
|
|
|
|
void set_thread_default_desktop( struct thread *thread, struct desktop *desktop, obj_handle_t handle )
|
|
|
|
{
|
|
|
|
if (thread->desktop) return; /* nothing to do */
|
|
|
|
|
|
|
|
thread->desktop = handle;
|
2024-01-27 14:00:12 -07:00
|
|
|
add_desktop_thread( desktop, thread );
|
2013-04-30 04:55:54 -07:00
|
|
|
}
|
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
/* set the process default desktop handle */
|
|
|
|
void set_process_default_desktop( struct process *process, struct desktop *desktop,
|
|
|
|
obj_handle_t handle )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2006-03-27 03:57:17 -07:00
|
|
|
struct thread *thread;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
if (process->desktop == handle) return; /* nothing to do */
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
process->desktop = handle;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
/* set desktop for threads that don't have one yet */
|
|
|
|
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
set_thread_default_desktop( thread, desktop, handle );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
/* connect a process to its window station */
|
2024-02-21 12:11:55 -07:00
|
|
|
void connect_process_winstation( struct process *process, struct unicode_str *desktop_path,
|
|
|
|
struct thread *parent_thread, struct process *parent_process )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2024-02-21 12:11:55 -07:00
|
|
|
struct unicode_str desktop_name = *desktop_path, winstation_name = {0};
|
|
|
|
const int attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF;
|
2006-03-27 03:57:17 -07:00
|
|
|
struct winstation *winstation = NULL;
|
|
|
|
struct desktop *desktop = NULL;
|
2024-02-21 12:11:55 -07:00
|
|
|
const WCHAR *wch, *end;
|
2006-03-27 03:57:17 -07:00
|
|
|
obj_handle_t handle;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2024-02-21 12:11:55 -07:00
|
|
|
for (wch = desktop_name.str, end = wch + desktop_name.len / sizeof(WCHAR); wch != end; wch++)
|
|
|
|
{
|
|
|
|
if (*wch == '\\')
|
|
|
|
{
|
|
|
|
winstation_name.str = desktop_name.str;
|
|
|
|
winstation_name.len = (wch - winstation_name.str) * sizeof(WCHAR);
|
|
|
|
desktop_name.str = wch + 1;
|
|
|
|
desktop_name.len = (end - desktop_name.str) * sizeof(WCHAR);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
/* check for an inherited winstation handle (don't ask...) */
|
|
|
|
if ((handle = find_inherited_handle( process, &winstation_ops )))
|
|
|
|
{
|
|
|
|
winstation = (struct winstation *)get_handle_obj( process, handle, 0, &winstation_ops );
|
|
|
|
}
|
2024-02-21 12:11:55 -07:00
|
|
|
else if (winstation_name.len && (winstation = open_named_object( NULL, &winstation_ops, &winstation_name, attributes )))
|
|
|
|
{
|
|
|
|
handle = alloc_handle( process, winstation, STANDARD_RIGHTS_REQUIRED | WINSTA_ALL_ACCESS, 0 );
|
|
|
|
}
|
2019-12-12 04:18:31 -07:00
|
|
|
else if (parent_process->winstation)
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2019-12-12 04:18:31 -07:00
|
|
|
handle = duplicate_handle( parent_process, parent_process->winstation,
|
2021-02-16 03:27:18 -07:00
|
|
|
process, 0, 0, DUPLICATE_SAME_ACCESS );
|
2006-03-27 03:57:17 -07:00
|
|
|
winstation = (struct winstation *)get_handle_obj( process, handle, 0, &winstation_ops );
|
|
|
|
}
|
|
|
|
if (!winstation) goto done;
|
|
|
|
process->winstation = handle;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
if ((handle = find_inherited_handle( process, &desktop_ops )))
|
|
|
|
{
|
|
|
|
desktop = get_desktop_obj( process, handle, 0 );
|
|
|
|
if (!desktop || desktop->winstation != winstation) goto done;
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
2024-02-21 12:11:55 -07:00
|
|
|
else if (desktop_name.len && (desktop = open_named_object( &winstation->obj, &desktop_ops, &desktop_name, attributes )))
|
|
|
|
{
|
|
|
|
handle = alloc_handle( process, desktop, STANDARD_RIGHTS_REQUIRED | DESKTOP_ALL_ACCESS, 0 );
|
|
|
|
}
|
2019-12-12 04:18:31 -07:00
|
|
|
else
|
2006-03-27 03:57:17 -07:00
|
|
|
{
|
2019-12-12 04:18:31 -07:00
|
|
|
if (parent_thread && parent_thread->desktop)
|
|
|
|
handle = parent_thread->desktop;
|
|
|
|
else if (parent_process->desktop)
|
|
|
|
handle = parent_process->desktop;
|
|
|
|
else
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
desktop = get_desktop_obj( parent_process, handle, 0 );
|
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
if (!desktop || desktop->winstation != winstation) goto done;
|
|
|
|
|
2021-02-16 03:27:18 -07:00
|
|
|
handle = duplicate_handle( parent_process, handle, process, 0, 0, DUPLICATE_SAME_ACCESS );
|
2019-12-12 04:18:31 -07:00
|
|
|
}
|
2006-03-27 03:57:17 -07:00
|
|
|
if (handle) set_process_default_desktop( process, desktop, handle );
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (desktop) release_object( desktop );
|
|
|
|
if (winstation) release_object( winstation );
|
|
|
|
clear_error();
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2006-03-06 13:02:24 -07:00
|
|
|
/* close the desktop of a given process */
|
|
|
|
void close_process_desktop( struct process *process )
|
|
|
|
{
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
obj_handle_t handle;
|
2006-03-06 13:02:24 -07:00
|
|
|
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
if (!(handle = process->desktop)) return;
|
|
|
|
|
|
|
|
process->desktop = 0;
|
|
|
|
close_handle( process, handle );
|
2006-03-06 13:02:24 -07:00
|
|
|
}
|
|
|
|
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
/* release (and eventually close) the desktop of a given thread */
|
|
|
|
void release_thread_desktop( struct thread *thread, int close )
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
struct desktop *desktop;
|
|
|
|
obj_handle_t handle;
|
|
|
|
|
|
|
|
if (!(handle = thread->desktop)) return;
|
|
|
|
|
2024-01-27 14:00:12 -07:00
|
|
|
if (!(desktop = get_desktop_obj( thread->process, handle, 0 ))) clear_error(); /* ignore errors */
|
|
|
|
else
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
{
|
2024-03-21 10:49:56 -07:00
|
|
|
if (close) remove_desktop_thread( desktop, thread );
|
|
|
|
else remove_desktop_user( desktop, thread );
|
2024-01-27 14:00:12 -07:00
|
|
|
release_object( desktop );
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
if (close)
|
|
|
|
{
|
|
|
|
thread->desktop = 0;
|
|
|
|
close_handle( thread->process, handle );
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create a window station */
|
|
|
|
DECL_HANDLER(create_winstation)
|
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
2016-01-29 00:36:45 -07:00
|
|
|
struct unicode_str name = get_req_unicode_str();
|
2016-02-12 05:00:41 -07:00
|
|
|
struct object *root = NULL;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
|
|
|
reply->handle = 0;
|
2016-02-12 05:00:41 -07:00
|
|
|
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir ))) return;
|
2016-01-20 06:02:03 -07:00
|
|
|
|
|
|
|
if ((winstation = create_winstation( root, &name, req->attributes, req->flags )))
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2005-12-09 05:58:25 -07:00
|
|
|
reply->handle = alloc_handle( current->process, winstation, req->access, req->attributes );
|
2005-06-08 11:44:50 -07:00
|
|
|
release_object( winstation );
|
|
|
|
}
|
2016-01-20 06:02:03 -07:00
|
|
|
if (root) release_object( root );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* open a handle to a window station */
|
|
|
|
DECL_HANDLER(open_winstation)
|
|
|
|
{
|
2016-01-29 00:36:45 -07:00
|
|
|
struct unicode_str name = get_req_unicode_str();
|
2005-11-18 09:31:18 -07:00
|
|
|
|
2016-01-29 00:23:29 -07:00
|
|
|
reply->handle = open_object( current->process, req->rootdir, req->access,
|
|
|
|
&winstation_ops, &name, req->attributes );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* close a window station */
|
|
|
|
DECL_HANDLER(close_winstation)
|
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
|
|
|
|
|
|
|
if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
|
|
|
|
0, &winstation_ops )))
|
|
|
|
{
|
2009-12-01 05:59:41 -07:00
|
|
|
if (close_handle( current->process, req->handle )) set_error( STATUS_ACCESS_DENIED );
|
2005-06-08 11:44:50 -07:00
|
|
|
release_object( winstation );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-09-25 02:07:40 -07:00
|
|
|
/* set the process current window station monitors */
|
|
|
|
DECL_HANDLER(set_winstation_monitors)
|
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
|
|
|
unsigned int size;
|
|
|
|
|
|
|
|
if (!(winstation = (struct winstation *)get_handle_obj( current->process, current->process->winstation,
|
|
|
|
0, &winstation_ops )))
|
|
|
|
return;
|
|
|
|
|
|
|
|
free( winstation->monitors );
|
|
|
|
winstation->monitors = NULL;
|
|
|
|
winstation->monitor_count = 0;
|
|
|
|
|
|
|
|
if ((size = get_req_data_size()) && (winstation->monitors = memdup( get_req_data(), size )))
|
|
|
|
winstation->monitor_count = size / sizeof(*winstation->monitors);
|
|
|
|
|
|
|
|
release_object( winstation );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
/* get the process current window station */
|
|
|
|
DECL_HANDLER(get_process_winstation)
|
|
|
|
{
|
|
|
|
reply->handle = current->process->winstation;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set the process current window station */
|
|
|
|
DECL_HANDLER(set_process_winstation)
|
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
|
|
|
|
|
|
|
if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
|
|
|
|
0, &winstation_ops )))
|
|
|
|
{
|
|
|
|
/* FIXME: should we close the old one? */
|
|
|
|
current->process->winstation = req->handle;
|
|
|
|
release_object( winstation );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a desktop */
|
|
|
|
DECL_HANDLER(create_desktop)
|
|
|
|
{
|
|
|
|
struct desktop *desktop;
|
|
|
|
struct winstation *winstation;
|
2016-01-29 00:36:45 -07:00
|
|
|
struct unicode_str name = get_req_unicode_str();
|
2005-06-08 11:44:50 -07:00
|
|
|
|
|
|
|
reply->handle = 0;
|
2020-06-24 03:37:22 -07:00
|
|
|
if (!name.len)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_HANDLE );
|
|
|
|
return;
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
if ((winstation = get_process_winstation( current->process, WINSTA_CREATEDESKTOP )))
|
|
|
|
{
|
2005-11-21 05:05:38 -07:00
|
|
|
if ((desktop = create_desktop( &name, req->attributes, req->flags, winstation )))
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2024-01-27 13:03:41 -07:00
|
|
|
if (!winstation->input_desktop) set_input_desktop( winstation, desktop );
|
2005-12-09 05:58:25 -07:00
|
|
|
reply->handle = alloc_handle( current->process, desktop, req->access, req->attributes );
|
2005-06-08 11:44:50 -07:00
|
|
|
release_object( desktop );
|
|
|
|
}
|
|
|
|
release_object( winstation );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* open a handle to a desktop */
|
|
|
|
DECL_HANDLER(open_desktop)
|
|
|
|
{
|
|
|
|
struct winstation *winstation;
|
2016-01-29 00:23:29 -07:00
|
|
|
struct object *obj;
|
2016-01-29 00:36:45 -07:00
|
|
|
struct unicode_str name = get_req_unicode_str();
|
2008-04-01 12:15:55 -07:00
|
|
|
|
|
|
|
/* FIXME: check access rights */
|
|
|
|
if (!req->winsta)
|
|
|
|
winstation = get_process_winstation( current->process, 0 );
|
|
|
|
else
|
|
|
|
winstation = (struct winstation *)get_handle_obj( current->process, req->winsta, 0, &winstation_ops );
|
|
|
|
|
2016-01-29 00:23:29 -07:00
|
|
|
if (!winstation) return;
|
|
|
|
|
2016-02-08 00:53:31 -07:00
|
|
|
if ((obj = open_named_object( &winstation->obj, &desktop_ops, &name, req->attributes )))
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2016-01-29 00:23:29 -07:00
|
|
|
reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
|
|
|
|
release_object( obj );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
2016-01-29 00:23:29 -07:00
|
|
|
|
|
|
|
release_object( winstation );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
2013-11-08 02:10:24 -07:00
|
|
|
/* open a handle to current input desktop */
|
|
|
|
DECL_HANDLER(open_input_desktop)
|
|
|
|
{
|
|
|
|
/* FIXME: check access rights */
|
|
|
|
struct winstation *winstation = get_process_winstation( current->process, 0 );
|
|
|
|
struct desktop *desktop;
|
|
|
|
|
|
|
|
if (!winstation) return;
|
|
|
|
|
|
|
|
if (!(winstation->flags & WSF_VISIBLE))
|
|
|
|
{
|
|
|
|
set_error( STATUS_ILLEGAL_FUNCTION );
|
2013-11-09 02:17:11 -07:00
|
|
|
release_object( winstation );
|
2013-11-08 02:10:24 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-27 13:03:41 -07:00
|
|
|
if ((desktop = get_input_desktop( winstation )))
|
2013-11-08 02:10:24 -07:00
|
|
|
{
|
|
|
|
reply->handle = alloc_handle( current->process, desktop, req->access, req->attributes );
|
|
|
|
release_object( desktop );
|
|
|
|
}
|
|
|
|
release_object( winstation );
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2024-01-27 13:03:41 -07:00
|
|
|
/* changes the current input desktop */
|
|
|
|
DECL_HANDLER(set_input_desktop)
|
|
|
|
{
|
|
|
|
/* FIXME: check access rights */
|
|
|
|
struct winstation *winstation;
|
|
|
|
struct desktop *desktop;
|
|
|
|
|
|
|
|
if (!(winstation = get_process_winstation( current->process, 0 ))) return;
|
|
|
|
|
|
|
|
if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle, 0, &desktop_ops )))
|
|
|
|
{
|
|
|
|
if (!set_input_desktop( winstation, desktop )) set_error( STATUS_ILLEGAL_FUNCTION );
|
|
|
|
release_object( desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
release_object( winstation );
|
|
|
|
}
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
/* close a desktop */
|
|
|
|
DECL_HANDLER(close_desktop)
|
|
|
|
{
|
|
|
|
struct desktop *desktop;
|
|
|
|
|
|
|
|
/* make sure it is a desktop handle */
|
|
|
|
if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle,
|
|
|
|
0, &desktop_ops )))
|
|
|
|
{
|
2009-12-01 05:59:41 -07:00
|
|
|
if (close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
|
2005-06-08 11:44:50 -07:00
|
|
|
release_object( desktop );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* get the thread current desktop */
|
|
|
|
DECL_HANDLER(get_thread_desktop)
|
|
|
|
{
|
2024-03-16 12:41:13 -07:00
|
|
|
struct desktop *desktop;
|
2005-06-08 11:44:50 -07:00
|
|
|
struct thread *thread;
|
|
|
|
|
|
|
|
if (!(thread = get_thread_from_id( req->tid ))) return;
|
|
|
|
reply->handle = thread->desktop;
|
2024-03-16 12:41:13 -07:00
|
|
|
|
|
|
|
if (!(desktop = get_thread_desktop( thread, 0 ))) clear_error();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (desktop->shared) reply->locator = get_shared_object_locator( desktop->shared );
|
|
|
|
release_object( desktop );
|
|
|
|
}
|
|
|
|
|
2005-06-08 11:44:50 -07:00
|
|
|
release_object( thread );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set the thread current desktop */
|
|
|
|
DECL_HANDLER(set_thread_desktop)
|
|
|
|
{
|
2005-06-28 12:37:52 -07:00
|
|
|
struct desktop *old_desktop, *new_desktop;
|
|
|
|
struct winstation *winstation;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
2005-06-28 12:37:52 -07:00
|
|
|
if (!(winstation = get_process_winstation( current->process, 0 /* FIXME: access rights? */ )))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(new_desktop = get_desktop_obj( current->process, req->handle, 0 )))
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2005-06-28 12:37:52 -07:00
|
|
|
release_object( winstation );
|
|
|
|
return;
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
2005-06-28 12:37:52 -07:00
|
|
|
if (new_desktop->winstation != winstation)
|
|
|
|
{
|
|
|
|
set_error( STATUS_ACCESS_DENIED );
|
|
|
|
release_object( new_desktop );
|
|
|
|
release_object( winstation );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if we are changing to a new desktop */
|
|
|
|
|
|
|
|
if (!(old_desktop = get_desktop_obj( current->process, current->desktop, 0)))
|
|
|
|
clear_error(); /* ignore error */
|
|
|
|
|
|
|
|
/* when changing desktop, we can't have any users on the current one */
|
|
|
|
if (old_desktop != new_desktop && current->desktop_users > 0)
|
|
|
|
set_error( STATUS_DEVICE_BUSY );
|
|
|
|
else
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
{
|
2005-06-28 12:37:52 -07:00
|
|
|
current->desktop = req->handle; /* FIXME: should we close the old one? */
|
2024-01-27 14:00:12 -07:00
|
|
|
if (old_desktop != new_desktop)
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
{
|
2024-01-27 14:00:12 -07:00
|
|
|
if (old_desktop) remove_desktop_thread( old_desktop, current );
|
|
|
|
add_desktop_thread( new_desktop, current );
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
}
|
2024-03-16 12:41:13 -07:00
|
|
|
reply->locator = get_shared_object_locator( new_desktop->shared );
|
server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.
This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.
Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.
Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.
Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 01:38:15 -07:00
|
|
|
}
|
2005-06-28 12:37:52 -07:00
|
|
|
|
2006-03-27 03:57:17 -07:00
|
|
|
if (!current->process->desktop)
|
|
|
|
set_process_default_desktop( current->process, new_desktop, req->handle );
|
|
|
|
|
2006-03-06 07:10:59 -07:00
|
|
|
if (old_desktop != new_desktop && current->queue) detach_thread_input( current );
|
2005-07-11 06:30:23 -07:00
|
|
|
|
2005-06-28 12:37:52 -07:00
|
|
|
if (old_desktop) release_object( old_desktop );
|
|
|
|
release_object( new_desktop );
|
|
|
|
release_object( winstation );
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* get/set information about a user object (window station or desktop) */
|
|
|
|
DECL_HANDLER(set_user_object_info)
|
|
|
|
{
|
|
|
|
struct object *obj;
|
2016-01-20 06:27:44 -07:00
|
|
|
data_size_t len;
|
2005-06-08 11:44:50 -07:00
|
|
|
|
|
|
|
if (!(obj = get_handle_obj( current->process, req->handle, 0, NULL ))) return;
|
|
|
|
|
|
|
|
if (obj->ops == &desktop_ops)
|
|
|
|
{
|
|
|
|
struct desktop *desktop = (struct desktop *)obj;
|
|
|
|
reply->is_desktop = 1;
|
2024-06-21 13:27:44 -07:00
|
|
|
reply->old_obj_flags = desktop->shared->flags;
|
|
|
|
if (req->flags & SET_USER_OBJECT_SET_FLAGS)
|
|
|
|
{
|
|
|
|
SHARED_WRITE_BEGIN( desktop->shared, desktop_shm_t )
|
|
|
|
{
|
|
|
|
shared->flags = req->obj_flags;
|
|
|
|
}
|
|
|
|
SHARED_WRITE_END;
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
else if (obj->ops == &winstation_ops)
|
|
|
|
{
|
|
|
|
struct winstation *winstation = (struct winstation *)obj;
|
|
|
|
reply->is_desktop = 0;
|
|
|
|
reply->old_obj_flags = winstation->flags;
|
2015-12-03 17:19:58 -07:00
|
|
|
if (req->flags & SET_USER_OBJECT_SET_FLAGS) winstation->flags = req->obj_flags;
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
|
|
|
release_object( obj );
|
|
|
|
return;
|
|
|
|
}
|
2016-01-20 06:27:44 -07:00
|
|
|
if (obj->ops == &desktop_ops && get_reply_max_size() && (req->flags & SET_USER_OBJECT_GET_FULL_NAME))
|
|
|
|
{
|
|
|
|
struct desktop *desktop = (struct desktop *)obj;
|
|
|
|
data_size_t winstation_len, desktop_len;
|
|
|
|
const WCHAR *winstation_name = get_object_name( &desktop->winstation->obj, &winstation_len );
|
|
|
|
const WCHAR *desktop_name = get_object_name( obj, &desktop_len );
|
|
|
|
WCHAR *full_name;
|
|
|
|
|
|
|
|
if (!winstation_name) winstation_len = 0;
|
|
|
|
if (!desktop_name) desktop_len = 0;
|
|
|
|
len = winstation_len + desktop_len + sizeof(WCHAR);
|
|
|
|
if ((full_name = mem_alloc( len )))
|
|
|
|
{
|
2024-09-11 08:10:46 -07:00
|
|
|
WCHAR *ptr = mem_append( full_name, winstation_name, winstation_len );
|
|
|
|
*ptr++ = '\\';
|
|
|
|
mem_append( ptr, desktop_name, desktop_len );
|
2016-01-20 06:27:44 -07:00
|
|
|
set_reply_data_ptr( full_name, min( len, get_reply_max_size() ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const WCHAR *name = get_object_name( obj, &len );
|
|
|
|
if (name) set_reply_data( name, min( len, get_reply_max_size() ));
|
|
|
|
}
|
2007-12-05 08:45:32 -07:00
|
|
|
release_object( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-11-18 13:08:10 -07:00
|
|
|
/* enumerate window stations and desktops */
|
2007-12-05 08:45:32 -07:00
|
|
|
DECL_HANDLER(enum_winstation)
|
|
|
|
{
|
2024-11-18 13:08:10 -07:00
|
|
|
data_size_t size = get_reply_max_size() / sizeof(WCHAR) * sizeof(WCHAR);
|
|
|
|
struct object_name *name;
|
|
|
|
struct winstation *winstation;
|
|
|
|
WCHAR *data = NULL, *ptr;
|
2007-12-05 08:45:32 -07:00
|
|
|
|
2024-11-18 13:08:10 -07:00
|
|
|
if (size && !(data = mem_alloc( size ))) return;
|
|
|
|
ptr = data;
|
2007-12-05 08:45:32 -07:00
|
|
|
|
2024-11-18 13:08:10 -07:00
|
|
|
if (req->handle)
|
|
|
|
{
|
|
|
|
struct desktop *desktop;
|
2007-12-05 08:45:32 -07:00
|
|
|
|
2024-11-18 13:08:10 -07:00
|
|
|
if (!(winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
|
|
|
|
WINSTA_ENUMDESKTOPS, &winstation_ops )))
|
|
|
|
{
|
|
|
|
free( data );
|
|
|
|
return;
|
|
|
|
}
|
2007-12-05 08:45:32 -07:00
|
|
|
|
2024-11-18 13:08:10 -07:00
|
|
|
LIST_FOR_EACH_ENTRY( desktop, &winstation->desktops, struct desktop, entry )
|
|
|
|
{
|
|
|
|
unsigned int access = DESKTOP_ENUMERATE;
|
|
|
|
if (!(name = desktop->obj.name)) continue;
|
|
|
|
if (!check_object_access( NULL, &desktop->obj, &access )) continue;
|
|
|
|
reply->count++;
|
|
|
|
reply->total += name->len + sizeof(WCHAR);
|
|
|
|
if (reply->total <= size)
|
|
|
|
{
|
|
|
|
ptr = mem_append( ptr, name->name, name->len );
|
|
|
|
*ptr++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
release_object( winstation );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LIST_FOR_EACH_ENTRY( winstation, &winstation_list, struct winstation, entry )
|
|
|
|
{
|
|
|
|
unsigned int access = WINSTA_ENUMERATE;
|
|
|
|
if (!(name = winstation->obj.name)) continue;
|
|
|
|
if (!check_object_access( NULL, &winstation->obj, &access )) continue;
|
|
|
|
reply->count++;
|
|
|
|
reply->total += name->len + sizeof(WCHAR);
|
|
|
|
if (reply->total <= size)
|
|
|
|
{
|
|
|
|
ptr = mem_append( ptr, name->name, name->len );
|
|
|
|
*ptr++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-05 08:45:32 -07:00
|
|
|
|
2024-11-18 13:08:10 -07:00
|
|
|
if (reply->total <= size)
|
2005-06-08 11:44:50 -07:00
|
|
|
{
|
2024-11-18 13:08:10 -07:00
|
|
|
set_reply_data_ptr( data, reply->total );
|
2008-04-15 16:38:58 -07:00
|
|
|
clear_error();
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|
2024-11-18 13:08:10 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
set_reply_data_ptr( data, (ptr - data) * sizeof(WCHAR) );
|
|
|
|
set_error( STATUS_BUFFER_TOO_SMALL );
|
|
|
|
}
|
2005-06-08 11:44:50 -07:00
|
|
|
}
|