2 * Server-side window stations and desktops handling
4 * Copyright (C) 2002, 2005 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
28 #define WIN32_NO_STATUS
43 static struct list winstation_list
= LIST_INIT(winstation_list
);
45 static void winstation_dump( struct object
*obj
, int verbose
);
46 static struct object_type
*winstation_get_type( struct object
*obj
);
47 static int winstation_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
);
48 static struct object
*winstation_lookup_name( struct object
*obj
, struct unicode_str
*name
,
49 unsigned int attr
, struct object
*root
);
50 static void winstation_destroy( struct object
*obj
);
51 static unsigned int winstation_map_access( struct object
*obj
, unsigned int access
);
52 static void desktop_dump( struct object
*obj
, int verbose
);
53 static struct object_type
*desktop_get_type( struct object
*obj
);
54 static int desktop_link_name( struct object
*obj
, struct object_name
*name
, struct object
*parent
);
55 static int desktop_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
);
56 static void desktop_destroy( struct object
*obj
);
57 static unsigned int desktop_map_access( struct object
*obj
, unsigned int access
);
59 static const struct object_ops winstation_ops
=
61 sizeof(struct winstation
), /* size */
62 winstation_dump
, /* dump */
63 winstation_get_type
, /* get_type */
64 no_add_queue
, /* add_queue */
65 NULL
, /* remove_queue */
68 no_signal
, /* signal */
69 no_get_fd
, /* get_fd */
70 winstation_map_access
, /* map_access */
71 default_get_sd
, /* get_sd */
72 default_set_sd
, /* set_sd */
73 default_get_full_name
, /* get_full_name */
74 winstation_lookup_name
, /* lookup_name */
75 directory_link_name
, /* link_name */
76 default_unlink_name
, /* unlink_name */
77 no_open_file
, /* open_file */
78 no_kernel_obj_list
, /* get_kernel_obj_list */
79 winstation_close_handle
, /* close_handle */
80 winstation_destroy
/* destroy */
84 static const struct object_ops desktop_ops
=
86 sizeof(struct desktop
), /* size */
87 desktop_dump
, /* dump */
88 desktop_get_type
, /* get_type */
89 no_add_queue
, /* add_queue */
90 NULL
, /* remove_queue */
93 no_signal
, /* signal */
94 no_get_fd
, /* get_fd */
95 desktop_map_access
, /* map_access */
96 default_get_sd
, /* get_sd */
97 default_set_sd
, /* set_sd */
98 default_get_full_name
, /* get_full_name */
99 no_lookup_name
, /* lookup_name */
100 desktop_link_name
, /* link_name */
101 default_unlink_name
, /* unlink_name */
102 no_open_file
, /* open_file */
103 no_kernel_obj_list
, /* get_kernel_obj_list */
104 desktop_close_handle
, /* close_handle */
105 desktop_destroy
/* destroy */
108 #define DESKTOP_ALL_ACCESS 0x01ff
110 /* create a winstation object */
111 static struct winstation
*create_winstation( struct object
*root
, const struct unicode_str
*name
,
112 unsigned int attr
, unsigned int flags
)
114 struct winstation
*winstation
;
116 if ((winstation
= create_named_object( root
, &winstation_ops
, name
, attr
, NULL
)))
118 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
120 /* initialize it if it didn't already exist */
121 winstation
->flags
= flags
;
122 winstation
->clipboard
= NULL
;
123 winstation
->atom_table
= NULL
;
124 list_add_tail( &winstation_list
, &winstation
->entry
);
125 list_init( &winstation
->desktops
);
126 if (!(winstation
->desktop_names
= create_namespace( 7 )))
128 release_object( winstation
);
137 static void winstation_dump( struct object
*obj
, int verbose
)
139 struct winstation
*winstation
= (struct winstation
*)obj
;
141 fprintf( stderr
, "Winstation flags=%x clipboard=%p atoms=%p\n",
142 winstation
->flags
, winstation
->clipboard
, winstation
->atom_table
);
145 static struct object_type
*winstation_get_type( struct object
*obj
)
147 static const WCHAR name
[] = {'W','i','n','d','o','w','S','t','a','t','i','o','n'};
148 static const struct unicode_str str
= { name
, sizeof(name
) };
149 return get_object_type( &str
);
152 static int winstation_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
)
154 return (process
->winstation
!= handle
);
157 static struct object
*winstation_lookup_name( struct object
*obj
, struct unicode_str
*name
,
158 unsigned int attr
, struct object
*root
)
160 struct winstation
*winstation
= (struct winstation
*)obj
;
161 struct object
*found
;
163 assert( obj
->ops
== &winstation_ops
);
165 if (!name
) return NULL
; /* open the winstation itself */
167 if (get_path_element( name
->str
, name
->len
) < name
->len
) /* no backslash allowed in name */
169 set_error( STATUS_OBJECT_PATH_SYNTAX_BAD
);
173 if ((found
= find_object( winstation
->desktop_names
, name
, attr
)))
179 static void winstation_destroy( struct object
*obj
)
181 struct winstation
*winstation
= (struct winstation
*)obj
;
183 list_remove( &winstation
->entry
);
184 if (winstation
->clipboard
) release_object( winstation
->clipboard
);
185 if (winstation
->atom_table
) release_object( winstation
->atom_table
);
186 free( winstation
->desktop_names
);
189 static unsigned int winstation_map_access( struct object
*obj
, unsigned int access
)
191 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| WINSTA_ENUMDESKTOPS
| WINSTA_READATTRIBUTES
|
192 WINSTA_ENUMERATE
| WINSTA_READSCREEN
;
193 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| WINSTA_ACCESSCLIPBOARD
| WINSTA_CREATEDESKTOP
|
194 WINSTA_WRITEATTRIBUTES
;
195 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| WINSTA_ACCESSGLOBALATOMS
| WINSTA_EXITWINDOWS
;
196 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_REQUIRED
| WINSTA_ALL_ACCESS
;
197 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
200 /* retrieve the process window station, checking the handle access rights */
201 struct winstation
*get_process_winstation( struct process
*process
, unsigned int access
)
203 return (struct winstation
*)get_handle_obj( process
, process
->winstation
,
204 access
, &winstation_ops
);
207 /* retrieve a pointer to a desktop object */
208 struct desktop
*get_desktop_obj( struct process
*process
, obj_handle_t handle
, unsigned int access
)
210 return (struct desktop
*)get_handle_obj( process
, handle
, access
, &desktop_ops
);
213 /* create a desktop object */
214 static struct desktop
*create_desktop( const struct unicode_str
*name
, unsigned int attr
,
215 unsigned int flags
, struct winstation
*winstation
)
217 struct desktop
*desktop
;
219 if ((desktop
= create_named_object( &winstation
->obj
, &desktop_ops
, name
, attr
, NULL
)))
221 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
223 /* initialize it if it didn't already exist */
224 desktop
->flags
= flags
;
225 desktop
->winstation
= (struct winstation
*)grab_object( winstation
);
226 desktop
->top_window
= NULL
;
227 desktop
->msg_window
= NULL
;
228 desktop
->global_hooks
= NULL
;
229 desktop
->close_timeout
= NULL
;
230 desktop
->foreground_input
= NULL
;
232 memset( &desktop
->cursor
, 0, sizeof(desktop
->cursor
) );
233 memset( desktop
->keystate
, 0, sizeof(desktop
->keystate
) );
234 list_add_tail( &winstation
->desktops
, &desktop
->entry
);
235 list_init( &desktop
->hotkeys
);
242 static void desktop_dump( struct object
*obj
, int verbose
)
244 struct desktop
*desktop
= (struct desktop
*)obj
;
246 fprintf( stderr
, "Desktop flags=%x winstation=%p top_win=%p hooks=%p\n",
247 desktop
->flags
, desktop
->winstation
, desktop
->top_window
, desktop
->global_hooks
);
250 static struct object_type
*desktop_get_type( struct object
*obj
)
252 static const WCHAR name
[] = {'D','e','s','k','t','o','p'};
253 static const struct unicode_str str
= { name
, sizeof(name
) };
254 return get_object_type( &str
);
257 static int desktop_link_name( struct object
*obj
, struct object_name
*name
, struct object
*parent
)
259 struct winstation
*winstation
= (struct winstation
*)parent
;
261 if (parent
->ops
!= &winstation_ops
)
263 set_error( STATUS_OBJECT_TYPE_MISMATCH
);
266 if (get_path_element( name
->name
, name
->len
) < name
->len
) /* no backslash allowed in name */
268 set_error( STATUS_OBJECT_PATH_SYNTAX_BAD
);
271 namespace_add( winstation
->desktop_names
, name
);
275 static int desktop_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
)
277 struct thread
*thread
;
279 /* check if the handle is currently used by the process or one of its threads */
280 if (process
->desktop
== handle
) return 0;
281 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
282 if (thread
->desktop
== handle
) return 0;
286 static void desktop_destroy( struct object
*obj
)
288 struct desktop
*desktop
= (struct desktop
*)obj
;
290 free_hotkeys( desktop
, 0 );
291 if (desktop
->top_window
) destroy_window( desktop
->top_window
);
292 if (desktop
->msg_window
) destroy_window( desktop
->msg_window
);
293 if (desktop
->global_hooks
) release_object( desktop
->global_hooks
);
294 if (desktop
->close_timeout
) remove_timeout_user( desktop
->close_timeout
);
295 list_remove( &desktop
->entry
);
296 release_object( desktop
->winstation
);
299 static unsigned int desktop_map_access( struct object
*obj
, unsigned int access
)
301 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| DESKTOP_READOBJECTS
| DESKTOP_ENUMERATE
;
302 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| DESKTOP_CREATEMENU
| DESKTOP_CREATEWINDOW
|
303 DESKTOP_HOOKCONTROL
| DESKTOP_JOURNALRECORD
| DESKTOP_JOURNALPLAYBACK
|
304 DESKTOP_WRITEOBJECTS
;
305 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| DESKTOP_SWITCHDESKTOP
;
306 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_REQUIRED
| DESKTOP_ALL_ACCESS
;
307 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
310 /* retrieve the thread desktop, checking the handle access rights */
311 struct desktop
*get_thread_desktop( struct thread
*thread
, unsigned int access
)
313 return get_desktop_obj( thread
->process
, thread
->desktop
, access
);
316 static void close_desktop_timeout( void *private )
318 struct desktop
*desktop
= private;
320 desktop
->close_timeout
= NULL
;
321 unlink_named_object( &desktop
->obj
); /* make sure no other process can open it */
322 post_desktop_message( desktop
, WM_CLOSE
, 0, 0 ); /* and signal the owner to quit */
325 /* add a user of the desktop and cancel the close timeout */
326 static void add_desktop_user( struct desktop
*desktop
)
329 if (desktop
->close_timeout
)
331 remove_timeout_user( desktop
->close_timeout
);
332 desktop
->close_timeout
= NULL
;
336 /* remove a user of the desktop and start the close timeout if necessary */
337 static void remove_desktop_user( struct desktop
*desktop
)
339 assert( desktop
->users
> 0 );
342 /* if we have one remaining user, it has to be the manager of the desktop window */
343 if (desktop
->users
== 1 && get_top_window_owner( desktop
))
345 assert( !desktop
->close_timeout
);
346 desktop
->close_timeout
= add_timeout_user( -TICKS_PER_SEC
, close_desktop_timeout
, desktop
);
350 /* set the process default desktop handle */
351 void set_process_default_desktop( struct process
*process
, struct desktop
*desktop
,
352 obj_handle_t handle
)
354 struct thread
*thread
;
355 struct desktop
*old_desktop
;
357 if (process
->desktop
== handle
) return; /* nothing to do */
359 if (!(old_desktop
= get_desktop_obj( process
, process
->desktop
, 0 ))) clear_error();
360 process
->desktop
= handle
;
362 /* set desktop for threads that don't have one yet */
363 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
364 if (!thread
->desktop
) thread
->desktop
= handle
;
366 if (!process
->is_system
&& desktop
!= old_desktop
)
368 add_desktop_user( desktop
);
369 if (old_desktop
) remove_desktop_user( old_desktop
);
372 if (old_desktop
) release_object( old_desktop
);
375 /* connect a process to its window station */
376 void connect_process_winstation( struct process
*process
, struct thread
*parent_thread
,
377 struct process
*parent_process
)
379 struct winstation
*winstation
= NULL
;
380 struct desktop
*desktop
= NULL
;
383 /* check for an inherited winstation handle (don't ask...) */
384 if ((handle
= find_inherited_handle( process
, &winstation_ops
)))
386 winstation
= (struct winstation
*)get_handle_obj( process
, handle
, 0, &winstation_ops
);
388 else if (parent_process
->winstation
)
390 handle
= duplicate_handle( parent_process
, parent_process
->winstation
,
391 process
, 0, 0, DUP_HANDLE_SAME_ACCESS
);
392 winstation
= (struct winstation
*)get_handle_obj( process
, handle
, 0, &winstation_ops
);
394 if (!winstation
) goto done
;
395 process
->winstation
= handle
;
397 if ((handle
= find_inherited_handle( process
, &desktop_ops
)))
399 desktop
= get_desktop_obj( process
, handle
, 0 );
400 if (!desktop
|| desktop
->winstation
!= winstation
) goto done
;
404 if (parent_thread
&& parent_thread
->desktop
)
405 handle
= parent_thread
->desktop
;
406 else if (parent_process
->desktop
)
407 handle
= parent_process
->desktop
;
411 desktop
= get_desktop_obj( parent_process
, handle
, 0 );
413 if (!desktop
|| desktop
->winstation
!= winstation
) goto done
;
415 handle
= duplicate_handle( parent_process
, handle
, process
, 0, 0, DUP_HANDLE_SAME_ACCESS
);
417 if (handle
) set_process_default_desktop( process
, desktop
, handle
);
420 if (desktop
) release_object( desktop
);
421 if (winstation
) release_object( winstation
);
425 /* close the desktop of a given process */
426 void close_process_desktop( struct process
*process
)
428 struct desktop
*desktop
;
430 if (process
->desktop
&& (desktop
= get_desktop_obj( process
, process
->desktop
, 0 )))
432 remove_desktop_user( desktop
);
433 release_object( desktop
);
435 clear_error(); /* ignore errors */
438 /* close the desktop of a given thread */
439 void close_thread_desktop( struct thread
*thread
)
441 obj_handle_t handle
= thread
->desktop
;
444 if (handle
) close_handle( thread
->process
, handle
);
447 /* create a window station */
448 DECL_HANDLER(create_winstation
)
450 struct winstation
*winstation
;
451 struct unicode_str name
= get_req_unicode_str();
452 struct object
*root
= NULL
;
455 if (req
->rootdir
&& !(root
= get_directory_obj( current
->process
, req
->rootdir
))) return;
457 if ((winstation
= create_winstation( root
, &name
, req
->attributes
, req
->flags
)))
459 reply
->handle
= alloc_handle( current
->process
, winstation
, req
->access
, req
->attributes
);
460 release_object( winstation
);
462 if (root
) release_object( root
);
465 /* open a handle to a window station */
466 DECL_HANDLER(open_winstation
)
468 struct unicode_str name
= get_req_unicode_str();
470 reply
->handle
= open_object( current
->process
, req
->rootdir
, req
->access
,
471 &winstation_ops
, &name
, req
->attributes
);
475 /* close a window station */
476 DECL_HANDLER(close_winstation
)
478 struct winstation
*winstation
;
480 if ((winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->handle
,
481 0, &winstation_ops
)))
483 if (close_handle( current
->process
, req
->handle
)) set_error( STATUS_ACCESS_DENIED
);
484 release_object( winstation
);
489 /* get the process current window station */
490 DECL_HANDLER(get_process_winstation
)
492 reply
->handle
= current
->process
->winstation
;
496 /* set the process current window station */
497 DECL_HANDLER(set_process_winstation
)
499 struct winstation
*winstation
;
501 if ((winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->handle
,
502 0, &winstation_ops
)))
504 /* FIXME: should we close the old one? */
505 current
->process
->winstation
= req
->handle
;
506 release_object( winstation
);
510 /* create a desktop */
511 DECL_HANDLER(create_desktop
)
513 struct desktop
*desktop
;
514 struct winstation
*winstation
;
515 struct unicode_str name
= get_req_unicode_str();
520 set_error( STATUS_INVALID_HANDLE
);
523 if ((winstation
= get_process_winstation( current
->process
, WINSTA_CREATEDESKTOP
)))
525 if ((desktop
= create_desktop( &name
, req
->attributes
, req
->flags
, winstation
)))
527 reply
->handle
= alloc_handle( current
->process
, desktop
, req
->access
, req
->attributes
);
528 release_object( desktop
);
530 release_object( winstation
);
534 /* open a handle to a desktop */
535 DECL_HANDLER(open_desktop
)
537 struct winstation
*winstation
;
539 struct unicode_str name
= get_req_unicode_str();
541 /* FIXME: check access rights */
543 winstation
= get_process_winstation( current
->process
, 0 );
545 winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->winsta
, 0, &winstation_ops
);
547 if (!winstation
) return;
549 if ((obj
= open_named_object( &winstation
->obj
, &desktop_ops
, &name
, req
->attributes
)))
551 reply
->handle
= alloc_handle( current
->process
, obj
, req
->access
, req
->attributes
);
552 release_object( obj
);
555 release_object( winstation
);
558 /* open a handle to current input desktop */
559 DECL_HANDLER(open_input_desktop
)
561 /* FIXME: check access rights */
562 struct winstation
*winstation
= get_process_winstation( current
->process
, 0 );
563 struct desktop
*desktop
;
565 if (!winstation
) return;
567 if (!(winstation
->flags
& WSF_VISIBLE
))
569 set_error( STATUS_ILLEGAL_FUNCTION
);
570 release_object( winstation
);
574 if ((desktop
= get_desktop_obj( current
->process
, current
->process
->desktop
, 0 )))
576 reply
->handle
= alloc_handle( current
->process
, desktop
, req
->access
, req
->attributes
);
577 release_object( desktop
);
579 release_object( winstation
);
582 /* close a desktop */
583 DECL_HANDLER(close_desktop
)
585 struct desktop
*desktop
;
587 /* make sure it is a desktop handle */
588 if ((desktop
= (struct desktop
*)get_handle_obj( current
->process
, req
->handle
,
591 if (close_handle( current
->process
, req
->handle
)) set_error( STATUS_DEVICE_BUSY
);
592 release_object( desktop
);
597 /* get the thread current desktop */
598 DECL_HANDLER(get_thread_desktop
)
600 struct thread
*thread
;
602 if (!(thread
= get_thread_from_id( req
->tid
))) return;
603 reply
->handle
= thread
->desktop
;
604 release_object( thread
);
608 /* set the thread current desktop */
609 DECL_HANDLER(set_thread_desktop
)
611 struct desktop
*old_desktop
, *new_desktop
;
612 struct winstation
*winstation
;
614 if (!(winstation
= get_process_winstation( current
->process
, 0 /* FIXME: access rights? */ )))
617 if (!(new_desktop
= get_desktop_obj( current
->process
, req
->handle
, 0 )))
619 release_object( winstation
);
622 if (new_desktop
->winstation
!= winstation
)
624 set_error( STATUS_ACCESS_DENIED
);
625 release_object( new_desktop
);
626 release_object( winstation
);
630 /* check if we are changing to a new desktop */
632 if (!(old_desktop
= get_desktop_obj( current
->process
, current
->desktop
, 0)))
633 clear_error(); /* ignore error */
635 /* when changing desktop, we can't have any users on the current one */
636 if (old_desktop
!= new_desktop
&& current
->desktop_users
> 0)
637 set_error( STATUS_DEVICE_BUSY
);
639 current
->desktop
= req
->handle
; /* FIXME: should we close the old one? */
641 if (!current
->process
->desktop
)
642 set_process_default_desktop( current
->process
, new_desktop
, req
->handle
);
644 if (old_desktop
!= new_desktop
&& current
->queue
) detach_thread_input( current
);
646 if (old_desktop
) release_object( old_desktop
);
647 release_object( new_desktop
);
648 release_object( winstation
);
652 /* get/set information about a user object (window station or desktop) */
653 DECL_HANDLER(set_user_object_info
)
658 if (!(obj
= get_handle_obj( current
->process
, req
->handle
, 0, NULL
))) return;
660 if (obj
->ops
== &desktop_ops
)
662 struct desktop
*desktop
= (struct desktop
*)obj
;
663 reply
->is_desktop
= 1;
664 reply
->old_obj_flags
= desktop
->flags
;
665 if (req
->flags
& SET_USER_OBJECT_SET_FLAGS
) desktop
->flags
= req
->obj_flags
;
667 else if (obj
->ops
== &winstation_ops
)
669 struct winstation
*winstation
= (struct winstation
*)obj
;
670 reply
->is_desktop
= 0;
671 reply
->old_obj_flags
= winstation
->flags
;
672 if (req
->flags
& SET_USER_OBJECT_SET_FLAGS
) winstation
->flags
= req
->obj_flags
;
676 set_error( STATUS_OBJECT_TYPE_MISMATCH
);
677 release_object( obj
);
680 if (obj
->ops
== &desktop_ops
&& get_reply_max_size() && (req
->flags
& SET_USER_OBJECT_GET_FULL_NAME
))
682 struct desktop
*desktop
= (struct desktop
*)obj
;
683 data_size_t winstation_len
, desktop_len
;
684 const WCHAR
*winstation_name
= get_object_name( &desktop
->winstation
->obj
, &winstation_len
);
685 const WCHAR
*desktop_name
= get_object_name( obj
, &desktop_len
);
688 if (!winstation_name
) winstation_len
= 0;
689 if (!desktop_name
) desktop_len
= 0;
690 len
= winstation_len
+ desktop_len
+ sizeof(WCHAR
);
691 if ((full_name
= mem_alloc( len
)))
693 memcpy( full_name
, winstation_name
, winstation_len
);
694 full_name
[winstation_len
/ sizeof(WCHAR
)] = '\\';
695 memcpy( full_name
+ winstation_len
/ sizeof(WCHAR
) + 1, desktop_name
, desktop_len
);
696 set_reply_data_ptr( full_name
, min( len
, get_reply_max_size() ));
701 const WCHAR
*name
= get_object_name( obj
, &len
);
702 if (name
) set_reply_data( name
, min( len
, get_reply_max_size() ));
704 release_object( obj
);
708 /* enumerate window stations */
709 DECL_HANDLER(enum_winstation
)
711 unsigned int index
= 0;
712 struct winstation
*winsta
;
716 LIST_FOR_EACH_ENTRY( winsta
, &winstation_list
, struct winstation
, entry
)
718 unsigned int access
= WINSTA_ENUMERATE
;
719 if (req
->index
> index
++) continue;
720 if (!check_object_access( NULL
, &winsta
->obj
, &access
)) continue;
723 if ((name
= get_object_name( &winsta
->obj
, &len
)))
724 set_reply_data( name
, min( len
, get_reply_max_size() ));
727 set_error( STATUS_NO_MORE_ENTRIES
);
731 /* enumerate desktops */
732 DECL_HANDLER(enum_desktop
)
734 struct winstation
*winstation
;
735 struct desktop
*desktop
;
736 unsigned int index
= 0;
740 if (!(winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->winstation
,
741 WINSTA_ENUMDESKTOPS
, &winstation_ops
)))
744 LIST_FOR_EACH_ENTRY( desktop
, &winstation
->desktops
, struct desktop
, entry
)
746 unsigned int access
= DESKTOP_ENUMERATE
;
747 if (req
->index
> index
++) continue;
748 if (!desktop
->obj
.name
) continue;
749 if (!check_object_access( NULL
, &desktop
->obj
, &access
)) continue;
750 if ((name
= get_object_name( &desktop
->obj
, &len
)))
751 set_reply_data( name
, min( len
, get_reply_max_size() ));
752 release_object( winstation
);
758 release_object( winstation
);
759 set_error( STATUS_NO_MORE_ENTRIES
);