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
41 #include "wine/unicode.h"
44 static struct list winstation_list
= LIST_INIT(winstation_list
);
46 static void winstation_dump( struct object
*obj
, int verbose
);
47 static struct object_type
*winstation_get_type( struct object
*obj
);
48 static int winstation_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
);
49 static struct object
*winstation_lookup_name( struct object
*obj
, struct unicode_str
*name
,
51 static void winstation_destroy( struct object
*obj
);
52 static unsigned int winstation_map_access( struct object
*obj
, unsigned int access
);
53 static void desktop_dump( struct object
*obj
, int verbose
);
54 static struct object_type
*desktop_get_type( struct object
*obj
);
55 static int desktop_link_name( struct object
*obj
, struct object_name
*name
, struct object
*parent
);
56 static int desktop_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
);
57 static void desktop_destroy( struct object
*obj
);
58 static unsigned int desktop_map_access( struct object
*obj
, unsigned int access
);
60 static const struct object_ops winstation_ops
=
62 sizeof(struct winstation
), /* size */
63 winstation_dump
, /* dump */
64 winstation_get_type
, /* get_type */
65 no_add_queue
, /* add_queue */
66 NULL
, /* remove_queue */
69 no_signal
, /* signal */
70 no_get_fd
, /* get_fd */
71 winstation_map_access
, /* map_access */
72 default_get_sd
, /* get_sd */
73 default_set_sd
, /* set_sd */
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 no_lookup_name
, /* lookup_name */
99 desktop_link_name
, /* link_name */
100 default_unlink_name
, /* unlink_name */
101 no_open_file
, /* open_file */
102 no_kernel_obj_list
, /* get_kernel_obj_list */
103 desktop_close_handle
, /* close_handle */
104 desktop_destroy
/* destroy */
107 #define DESKTOP_ALL_ACCESS 0x01ff
109 /* create a winstation object */
110 static struct winstation
*create_winstation( struct object
*root
, const struct unicode_str
*name
,
111 unsigned int attr
, unsigned int flags
)
113 struct winstation
*winstation
;
115 if ((winstation
= create_named_object( root
, &winstation_ops
, name
, attr
, NULL
)))
117 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
119 /* initialize it if it didn't already exist */
120 winstation
->flags
= flags
;
121 winstation
->clipboard
= NULL
;
122 winstation
->atom_table
= NULL
;
123 list_add_tail( &winstation_list
, &winstation
->entry
);
124 list_init( &winstation
->desktops
);
125 if (!(winstation
->desktop_names
= create_namespace( 7 )))
127 release_object( winstation
);
136 static void winstation_dump( struct object
*obj
, int verbose
)
138 struct winstation
*winstation
= (struct winstation
*)obj
;
140 fprintf( stderr
, "Winstation flags=%x clipboard=%p atoms=%p\n",
141 winstation
->flags
, winstation
->clipboard
, winstation
->atom_table
);
144 static struct object_type
*winstation_get_type( struct object
*obj
)
146 static const WCHAR name
[] = {'W','i','n','d','o','w','S','t','a','t','i','o','n'};
147 static const struct unicode_str str
= { name
, sizeof(name
) };
148 return get_object_type( &str
);
151 static int winstation_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
)
153 return (process
->winstation
!= handle
);
156 static struct object
*winstation_lookup_name( struct object
*obj
, struct unicode_str
*name
,
159 struct winstation
*winstation
= (struct winstation
*)obj
;
160 struct object
*found
;
162 assert( obj
->ops
== &winstation_ops
);
164 if (!name
) return NULL
; /* open the winstation itself */
166 if (memchrW( name
->str
, '\\', name
->len
/ sizeof(WCHAR
) )) /* no backslash allowed in name */
168 set_error( STATUS_OBJECT_PATH_SYNTAX_BAD
);
172 if ((found
= find_object( winstation
->desktop_names
, name
, attr
)))
178 static void winstation_destroy( struct object
*obj
)
180 struct winstation
*winstation
= (struct winstation
*)obj
;
182 list_remove( &winstation
->entry
);
183 if (winstation
->clipboard
) release_object( winstation
->clipboard
);
184 if (winstation
->atom_table
) release_object( winstation
->atom_table
);
185 free( winstation
->desktop_names
);
188 static unsigned int winstation_map_access( struct object
*obj
, unsigned int access
)
190 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| WINSTA_ENUMDESKTOPS
| WINSTA_READATTRIBUTES
|
191 WINSTA_ENUMERATE
| WINSTA_READSCREEN
;
192 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| WINSTA_ACCESSCLIPBOARD
| WINSTA_CREATEDESKTOP
|
193 WINSTA_WRITEATTRIBUTES
;
194 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| WINSTA_ACCESSGLOBALATOMS
| WINSTA_EXITWINDOWS
;
195 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_REQUIRED
| WINSTA_ALL_ACCESS
;
196 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
199 /* retrieve the process window station, checking the handle access rights */
200 struct winstation
*get_process_winstation( struct process
*process
, unsigned int access
)
202 return (struct winstation
*)get_handle_obj( process
, process
->winstation
,
203 access
, &winstation_ops
);
206 /* retrieve a pointer to a desktop object */
207 struct desktop
*get_desktop_obj( struct process
*process
, obj_handle_t handle
, unsigned int access
)
209 return (struct desktop
*)get_handle_obj( process
, handle
, access
, &desktop_ops
);
212 /* create a desktop object */
213 static struct desktop
*create_desktop( const struct unicode_str
*name
, unsigned int attr
,
214 unsigned int flags
, struct winstation
*winstation
)
216 struct desktop
*desktop
;
218 if ((desktop
= create_named_object( &winstation
->obj
, &desktop_ops
, name
, attr
, NULL
)))
220 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
222 /* initialize it if it didn't already exist */
223 desktop
->flags
= flags
;
224 desktop
->winstation
= (struct winstation
*)grab_object( winstation
);
225 desktop
->top_window
= NULL
;
226 desktop
->msg_window
= NULL
;
227 desktop
->global_hooks
= NULL
;
228 desktop
->close_timeout
= NULL
;
229 desktop
->foreground_input
= NULL
;
231 memset( &desktop
->cursor
, 0, sizeof(desktop
->cursor
) );
232 memset( desktop
->keystate
, 0, sizeof(desktop
->keystate
) );
233 list_add_tail( &winstation
->desktops
, &desktop
->entry
);
234 list_init( &desktop
->hotkeys
);
241 static void desktop_dump( struct object
*obj
, int verbose
)
243 struct desktop
*desktop
= (struct desktop
*)obj
;
245 fprintf( stderr
, "Desktop flags=%x winstation=%p top_win=%p hooks=%p\n",
246 desktop
->flags
, desktop
->winstation
, desktop
->top_window
, desktop
->global_hooks
);
249 static struct object_type
*desktop_get_type( struct object
*obj
)
251 static const WCHAR name
[] = {'D','e','s','k','t','o','p'};
252 static const struct unicode_str str
= { name
, sizeof(name
) };
253 return get_object_type( &str
);
256 static int desktop_link_name( struct object
*obj
, struct object_name
*name
, struct object
*parent
)
258 struct winstation
*winstation
= (struct winstation
*)parent
;
260 if (parent
->ops
!= &winstation_ops
)
262 set_error( STATUS_OBJECT_TYPE_MISMATCH
);
265 if (memchrW( name
->name
, '\\', name
->len
/ sizeof(WCHAR
) )) /* no backslash allowed in name */
267 set_error( STATUS_OBJECT_PATH_SYNTAX_BAD
);
270 namespace_add( winstation
->desktop_names
, name
);
274 static int desktop_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
)
276 struct thread
*thread
;
278 /* check if the handle is currently used by the process or one of its threads */
279 if (process
->desktop
== handle
) return 0;
280 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
281 if (thread
->desktop
== handle
) return 0;
285 static void desktop_destroy( struct object
*obj
)
287 struct desktop
*desktop
= (struct desktop
*)obj
;
289 free_hotkeys( desktop
, 0 );
290 if (desktop
->top_window
) destroy_window( desktop
->top_window
);
291 if (desktop
->msg_window
) destroy_window( desktop
->msg_window
);
292 if (desktop
->global_hooks
) release_object( desktop
->global_hooks
);
293 if (desktop
->close_timeout
) remove_timeout_user( desktop
->close_timeout
);
294 list_remove( &desktop
->entry
);
295 release_object( desktop
->winstation
);
298 static unsigned int desktop_map_access( struct object
*obj
, unsigned int access
)
300 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| DESKTOP_READOBJECTS
| DESKTOP_ENUMERATE
;
301 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| DESKTOP_CREATEMENU
| DESKTOP_CREATEWINDOW
|
302 DESKTOP_HOOKCONTROL
| DESKTOP_JOURNALRECORD
| DESKTOP_JOURNALPLAYBACK
|
303 DESKTOP_WRITEOBJECTS
;
304 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| DESKTOP_SWITCHDESKTOP
;
305 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_REQUIRED
| DESKTOP_ALL_ACCESS
;
306 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
309 /* retrieve the thread desktop, checking the handle access rights */
310 struct desktop
*get_thread_desktop( struct thread
*thread
, unsigned int access
)
312 return get_desktop_obj( thread
->process
, thread
->desktop
, access
);
315 static void close_desktop_timeout( void *private )
317 struct desktop
*desktop
= private;
319 desktop
->close_timeout
= NULL
;
320 unlink_named_object( &desktop
->obj
); /* make sure no other process can open it */
321 post_desktop_message( desktop
, WM_CLOSE
, 0, 0 ); /* and signal the owner to quit */
324 /* add a user of the desktop and cancel the close timeout */
325 static void add_desktop_user( struct desktop
*desktop
)
328 if (desktop
->close_timeout
)
330 remove_timeout_user( desktop
->close_timeout
);
331 desktop
->close_timeout
= NULL
;
335 /* remove a user of the desktop and start the close timeout if necessary */
336 static void remove_desktop_user( struct desktop
*desktop
)
338 assert( desktop
->users
> 0 );
341 /* if we have one remaining user, it has to be the manager of the desktop window */
342 if (desktop
->users
== 1 && get_top_window_owner( desktop
))
344 assert( !desktop
->close_timeout
);
345 desktop
->close_timeout
= add_timeout_user( -TICKS_PER_SEC
, close_desktop_timeout
, desktop
);
349 /* set the process default desktop handle */
350 void set_process_default_desktop( struct process
*process
, struct desktop
*desktop
,
351 obj_handle_t handle
)
353 struct thread
*thread
;
354 struct desktop
*old_desktop
;
356 if (process
->desktop
== handle
) return; /* nothing to do */
358 if (!(old_desktop
= get_desktop_obj( process
, process
->desktop
, 0 ))) clear_error();
359 process
->desktop
= handle
;
361 /* set desktop for threads that don't have one yet */
362 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
363 if (!thread
->desktop
) thread
->desktop
= handle
;
365 if (!process
->is_system
&& desktop
!= old_desktop
)
367 add_desktop_user( desktop
);
368 if (old_desktop
) remove_desktop_user( old_desktop
);
371 if (old_desktop
) release_object( old_desktop
);
374 /* connect a process to its window station */
375 void connect_process_winstation( struct process
*process
, struct thread
*parent_thread
,
376 struct process
*parent_process
)
378 struct winstation
*winstation
= NULL
;
379 struct desktop
*desktop
= NULL
;
382 /* check for an inherited winstation handle (don't ask...) */
383 if ((handle
= find_inherited_handle( process
, &winstation_ops
)))
385 winstation
= (struct winstation
*)get_handle_obj( process
, handle
, 0, &winstation_ops
);
387 else if (parent_process
->winstation
)
389 handle
= duplicate_handle( parent_process
, parent_process
->winstation
,
390 process
, 0, 0, DUP_HANDLE_SAME_ACCESS
);
391 winstation
= (struct winstation
*)get_handle_obj( process
, handle
, 0, &winstation_ops
);
393 if (!winstation
) goto done
;
394 process
->winstation
= handle
;
396 if ((handle
= find_inherited_handle( process
, &desktop_ops
)))
398 desktop
= get_desktop_obj( process
, handle
, 0 );
399 if (!desktop
|| desktop
->winstation
!= winstation
) goto done
;
403 if (parent_thread
&& parent_thread
->desktop
)
404 handle
= parent_thread
->desktop
;
405 else if (parent_process
->desktop
)
406 handle
= parent_process
->desktop
;
410 desktop
= get_desktop_obj( parent_process
, handle
, 0 );
412 if (!desktop
|| desktop
->winstation
!= winstation
) goto done
;
414 handle
= duplicate_handle( parent_process
, handle
, process
, 0, 0, DUP_HANDLE_SAME_ACCESS
);
416 if (handle
) set_process_default_desktop( process
, desktop
, handle
);
419 if (desktop
) release_object( desktop
);
420 if (winstation
) release_object( winstation
);
424 /* close the desktop of a given process */
425 void close_process_desktop( struct process
*process
)
427 struct desktop
*desktop
;
429 if (process
->desktop
&& (desktop
= get_desktop_obj( process
, process
->desktop
, 0 )))
431 remove_desktop_user( desktop
);
432 release_object( desktop
);
434 clear_error(); /* ignore errors */
437 /* close the desktop of a given thread */
438 void close_thread_desktop( struct thread
*thread
)
440 obj_handle_t handle
= thread
->desktop
;
443 if (handle
) close_handle( thread
->process
, handle
);
446 /* create a window station */
447 DECL_HANDLER(create_winstation
)
449 struct winstation
*winstation
;
450 struct unicode_str name
= get_req_unicode_str();
451 struct object
*root
= NULL
;
454 if (req
->rootdir
&& !(root
= get_directory_obj( current
->process
, req
->rootdir
))) return;
456 if ((winstation
= create_winstation( root
, &name
, req
->attributes
, req
->flags
)))
458 reply
->handle
= alloc_handle( current
->process
, winstation
, req
->access
, req
->attributes
);
459 release_object( winstation
);
461 if (root
) release_object( root
);
464 /* open a handle to a window station */
465 DECL_HANDLER(open_winstation
)
467 struct unicode_str name
= get_req_unicode_str();
469 reply
->handle
= open_object( current
->process
, req
->rootdir
, req
->access
,
470 &winstation_ops
, &name
, req
->attributes
);
474 /* close a window station */
475 DECL_HANDLER(close_winstation
)
477 struct winstation
*winstation
;
479 if ((winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->handle
,
480 0, &winstation_ops
)))
482 if (close_handle( current
->process
, req
->handle
)) set_error( STATUS_ACCESS_DENIED
);
483 release_object( winstation
);
488 /* get the process current window station */
489 DECL_HANDLER(get_process_winstation
)
491 reply
->handle
= current
->process
->winstation
;
495 /* set the process current window station */
496 DECL_HANDLER(set_process_winstation
)
498 struct winstation
*winstation
;
500 if ((winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->handle
,
501 0, &winstation_ops
)))
503 /* FIXME: should we close the old one? */
504 current
->process
->winstation
= req
->handle
;
505 release_object( winstation
);
509 /* create a desktop */
510 DECL_HANDLER(create_desktop
)
512 struct desktop
*desktop
;
513 struct winstation
*winstation
;
514 struct unicode_str name
= get_req_unicode_str();
517 if ((winstation
= get_process_winstation( current
->process
, WINSTA_CREATEDESKTOP
)))
519 if ((desktop
= create_desktop( &name
, req
->attributes
, req
->flags
, winstation
)))
521 reply
->handle
= alloc_handle( current
->process
, desktop
, req
->access
, req
->attributes
);
522 release_object( desktop
);
524 release_object( winstation
);
528 /* open a handle to a desktop */
529 DECL_HANDLER(open_desktop
)
531 struct winstation
*winstation
;
533 struct unicode_str name
= get_req_unicode_str();
535 /* FIXME: check access rights */
537 winstation
= get_process_winstation( current
->process
, 0 );
539 winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->winsta
, 0, &winstation_ops
);
541 if (!winstation
) return;
543 if ((obj
= open_named_object( &winstation
->obj
, &desktop_ops
, &name
, req
->attributes
)))
545 reply
->handle
= alloc_handle( current
->process
, obj
, req
->access
, req
->attributes
);
546 release_object( obj
);
549 release_object( winstation
);
552 /* open a handle to current input desktop */
553 DECL_HANDLER(open_input_desktop
)
555 /* FIXME: check access rights */
556 struct winstation
*winstation
= get_process_winstation( current
->process
, 0 );
557 struct desktop
*desktop
;
559 if (!winstation
) return;
561 if (!(winstation
->flags
& WSF_VISIBLE
))
563 set_error( STATUS_ILLEGAL_FUNCTION
);
564 release_object( winstation
);
568 if ((desktop
= get_desktop_obj( current
->process
, current
->process
->desktop
, 0 )))
570 reply
->handle
= alloc_handle( current
->process
, desktop
, req
->access
, req
->attributes
);
571 release_object( desktop
);
573 release_object( winstation
);
576 /* close a desktop */
577 DECL_HANDLER(close_desktop
)
579 struct desktop
*desktop
;
581 /* make sure it is a desktop handle */
582 if ((desktop
= (struct desktop
*)get_handle_obj( current
->process
, req
->handle
,
585 if (close_handle( current
->process
, req
->handle
)) set_error( STATUS_DEVICE_BUSY
);
586 release_object( desktop
);
591 /* get the thread current desktop */
592 DECL_HANDLER(get_thread_desktop
)
594 struct thread
*thread
;
596 if (!(thread
= get_thread_from_id( req
->tid
))) return;
597 reply
->handle
= thread
->desktop
;
598 release_object( thread
);
602 /* set the thread current desktop */
603 DECL_HANDLER(set_thread_desktop
)
605 struct desktop
*old_desktop
, *new_desktop
;
606 struct winstation
*winstation
;
608 if (!(winstation
= get_process_winstation( current
->process
, 0 /* FIXME: access rights? */ )))
611 if (!(new_desktop
= get_desktop_obj( current
->process
, req
->handle
, 0 )))
613 release_object( winstation
);
616 if (new_desktop
->winstation
!= winstation
)
618 set_error( STATUS_ACCESS_DENIED
);
619 release_object( new_desktop
);
620 release_object( winstation
);
624 /* check if we are changing to a new desktop */
626 if (!(old_desktop
= get_desktop_obj( current
->process
, current
->desktop
, 0)))
627 clear_error(); /* ignore error */
629 /* when changing desktop, we can't have any users on the current one */
630 if (old_desktop
!= new_desktop
&& current
->desktop_users
> 0)
631 set_error( STATUS_DEVICE_BUSY
);
633 current
->desktop
= req
->handle
; /* FIXME: should we close the old one? */
635 if (!current
->process
->desktop
)
636 set_process_default_desktop( current
->process
, new_desktop
, req
->handle
);
638 if (old_desktop
!= new_desktop
&& current
->queue
) detach_thread_input( current
);
640 if (old_desktop
) release_object( old_desktop
);
641 release_object( new_desktop
);
642 release_object( winstation
);
646 /* get/set information about a user object (window station or desktop) */
647 DECL_HANDLER(set_user_object_info
)
652 if (!(obj
= get_handle_obj( current
->process
, req
->handle
, 0, NULL
))) return;
654 if (obj
->ops
== &desktop_ops
)
656 struct desktop
*desktop
= (struct desktop
*)obj
;
657 reply
->is_desktop
= 1;
658 reply
->old_obj_flags
= desktop
->flags
;
659 if (req
->flags
& SET_USER_OBJECT_SET_FLAGS
) desktop
->flags
= req
->obj_flags
;
661 else if (obj
->ops
== &winstation_ops
)
663 struct winstation
*winstation
= (struct winstation
*)obj
;
664 reply
->is_desktop
= 0;
665 reply
->old_obj_flags
= winstation
->flags
;
666 if (req
->flags
& SET_USER_OBJECT_SET_FLAGS
) winstation
->flags
= req
->obj_flags
;
670 set_error( STATUS_OBJECT_TYPE_MISMATCH
);
671 release_object( obj
);
674 if (obj
->ops
== &desktop_ops
&& get_reply_max_size() && (req
->flags
& SET_USER_OBJECT_GET_FULL_NAME
))
676 struct desktop
*desktop
= (struct desktop
*)obj
;
677 data_size_t winstation_len
, desktop_len
;
678 const WCHAR
*winstation_name
= get_object_name( &desktop
->winstation
->obj
, &winstation_len
);
679 const WCHAR
*desktop_name
= get_object_name( obj
, &desktop_len
);
682 if (!winstation_name
) winstation_len
= 0;
683 if (!desktop_name
) desktop_len
= 0;
684 len
= winstation_len
+ desktop_len
+ sizeof(WCHAR
);
685 if ((full_name
= mem_alloc( len
)))
687 memcpy( full_name
, winstation_name
, winstation_len
);
688 full_name
[winstation_len
/ sizeof(WCHAR
)] = '\\';
689 memcpy( full_name
+ winstation_len
/ sizeof(WCHAR
) + 1, desktop_name
, desktop_len
);
690 set_reply_data_ptr( full_name
, min( len
, get_reply_max_size() ));
695 const WCHAR
*name
= get_object_name( obj
, &len
);
696 if (name
) set_reply_data( name
, min( len
, get_reply_max_size() ));
698 release_object( obj
);
702 /* enumerate window stations */
703 DECL_HANDLER(enum_winstation
)
705 unsigned int index
= 0;
706 struct winstation
*winsta
;
710 LIST_FOR_EACH_ENTRY( winsta
, &winstation_list
, struct winstation
, entry
)
712 unsigned int access
= WINSTA_ENUMERATE
;
713 if (req
->index
> index
++) continue;
714 if (!check_object_access( &winsta
->obj
, &access
)) continue;
717 if ((name
= get_object_name( &winsta
->obj
, &len
)))
718 set_reply_data( name
, min( len
, get_reply_max_size() ));
721 set_error( STATUS_NO_MORE_ENTRIES
);
725 /* enumerate desktops */
726 DECL_HANDLER(enum_desktop
)
728 struct winstation
*winstation
;
729 struct desktop
*desktop
;
730 unsigned int index
= 0;
734 if (!(winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->winstation
,
735 WINSTA_ENUMDESKTOPS
, &winstation_ops
)))
738 LIST_FOR_EACH_ENTRY( desktop
, &winstation
->desktops
, struct desktop
, entry
)
740 unsigned int access
= DESKTOP_ENUMERATE
;
741 if (req
->index
> index
++) continue;
742 if (!desktop
->obj
.name
) continue;
743 if (!check_object_access( &desktop
->obj
, &access
)) continue;
744 if ((name
= get_object_name( &desktop
->obj
, &len
)))
745 set_reply_data( name
, min( len
, get_reply_max_size() ));
746 release_object( winstation
);
752 release_object( winstation
);
753 set_error( STATUS_NO_MORE_ENTRIES
);