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 winstation_close_handle
, /* close_handle */
79 winstation_destroy
/* destroy */
83 static const struct object_ops desktop_ops
=
85 sizeof(struct desktop
), /* size */
86 desktop_dump
, /* dump */
87 desktop_get_type
, /* get_type */
88 no_add_queue
, /* add_queue */
89 NULL
, /* remove_queue */
92 no_signal
, /* signal */
93 no_get_fd
, /* get_fd */
94 desktop_map_access
, /* map_access */
95 default_get_sd
, /* get_sd */
96 default_set_sd
, /* set_sd */
97 no_lookup_name
, /* lookup_name */
98 desktop_link_name
, /* link_name */
99 default_unlink_name
, /* unlink_name */
100 no_open_file
, /* open_file */
101 desktop_close_handle
, /* close_handle */
102 desktop_destroy
/* destroy */
105 #define DESKTOP_ALL_ACCESS 0x01ff
107 /* create a winstation object */
108 static struct winstation
*create_winstation( struct object
*root
, const struct unicode_str
*name
,
109 unsigned int attr
, unsigned int flags
)
111 struct winstation
*winstation
;
113 if ((winstation
= create_named_object( root
, &winstation_ops
, name
, attr
, NULL
)))
115 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
117 /* initialize it if it didn't already exist */
118 winstation
->flags
= flags
;
119 winstation
->clipboard
= NULL
;
120 winstation
->atom_table
= NULL
;
121 list_add_tail( &winstation_list
, &winstation
->entry
);
122 list_init( &winstation
->desktops
);
123 if (!(winstation
->desktop_names
= create_namespace( 7 )))
125 release_object( winstation
);
134 static void winstation_dump( struct object
*obj
, int verbose
)
136 struct winstation
*winstation
= (struct winstation
*)obj
;
138 fprintf( stderr
, "Winstation flags=%x clipboard=%p atoms=%p\n",
139 winstation
->flags
, winstation
->clipboard
, winstation
->atom_table
);
142 static struct object_type
*winstation_get_type( struct object
*obj
)
144 static const WCHAR name
[] = {'W','i','n','d','o','w','S','t','a','t','i','o','n'};
145 static const struct unicode_str str
= { name
, sizeof(name
) };
146 return get_object_type( &str
);
149 static int winstation_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
)
151 return (process
->winstation
!= handle
);
154 static struct object
*winstation_lookup_name( struct object
*obj
, struct unicode_str
*name
,
157 struct winstation
*winstation
= (struct winstation
*)obj
;
158 struct object
*found
;
160 assert( obj
->ops
== &winstation_ops
);
162 if (!name
) return NULL
; /* open the winstation itself */
164 if (memchrW( name
->str
, '\\', name
->len
/ sizeof(WCHAR
) )) /* no backslash allowed in name */
166 set_error( STATUS_OBJECT_PATH_SYNTAX_BAD
);
170 if ((found
= find_object( winstation
->desktop_names
, name
, attr
)))
176 static void winstation_destroy( struct object
*obj
)
178 struct winstation
*winstation
= (struct winstation
*)obj
;
180 list_remove( &winstation
->entry
);
181 if (winstation
->clipboard
) release_object( winstation
->clipboard
);
182 if (winstation
->atom_table
) release_object( winstation
->atom_table
);
183 free( winstation
->desktop_names
);
186 static unsigned int winstation_map_access( struct object
*obj
, unsigned int access
)
188 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| WINSTA_ENUMDESKTOPS
| WINSTA_READATTRIBUTES
|
189 WINSTA_ENUMERATE
| WINSTA_READSCREEN
;
190 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| WINSTA_ACCESSCLIPBOARD
| WINSTA_CREATEDESKTOP
|
191 WINSTA_WRITEATTRIBUTES
;
192 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| WINSTA_ACCESSGLOBALATOMS
| WINSTA_EXITWINDOWS
;
193 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_REQUIRED
| WINSTA_ALL_ACCESS
;
194 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
197 /* retrieve the process window station, checking the handle access rights */
198 struct winstation
*get_process_winstation( struct process
*process
, unsigned int access
)
200 return (struct winstation
*)get_handle_obj( process
, process
->winstation
,
201 access
, &winstation_ops
);
204 /* retrieve a pointer to a desktop object */
205 struct desktop
*get_desktop_obj( struct process
*process
, obj_handle_t handle
, unsigned int access
)
207 return (struct desktop
*)get_handle_obj( process
, handle
, access
, &desktop_ops
);
210 /* create a desktop object */
211 static struct desktop
*create_desktop( const struct unicode_str
*name
, unsigned int attr
,
212 unsigned int flags
, struct winstation
*winstation
)
214 struct desktop
*desktop
;
216 if ((desktop
= create_named_object( &winstation
->obj
, &desktop_ops
, name
, attr
, NULL
)))
218 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
220 /* initialize it if it didn't already exist */
221 desktop
->flags
= flags
;
222 desktop
->winstation
= (struct winstation
*)grab_object( winstation
);
223 desktop
->top_window
= NULL
;
224 desktop
->msg_window
= NULL
;
225 desktop
->global_hooks
= NULL
;
226 desktop
->close_timeout
= NULL
;
227 desktop
->foreground_input
= NULL
;
229 memset( &desktop
->cursor
, 0, sizeof(desktop
->cursor
) );
230 memset( desktop
->keystate
, 0, sizeof(desktop
->keystate
) );
231 list_add_tail( &winstation
->desktops
, &desktop
->entry
);
232 list_init( &desktop
->hotkeys
);
239 static void desktop_dump( struct object
*obj
, int verbose
)
241 struct desktop
*desktop
= (struct desktop
*)obj
;
243 fprintf( stderr
, "Desktop flags=%x winstation=%p top_win=%p hooks=%p\n",
244 desktop
->flags
, desktop
->winstation
, desktop
->top_window
, desktop
->global_hooks
);
247 static struct object_type
*desktop_get_type( struct object
*obj
)
249 static const WCHAR name
[] = {'D','e','s','k','t','o','p'};
250 static const struct unicode_str str
= { name
, sizeof(name
) };
251 return get_object_type( &str
);
254 static int desktop_link_name( struct object
*obj
, struct object_name
*name
, struct object
*parent
)
256 struct winstation
*winstation
= (struct winstation
*)parent
;
258 if (parent
->ops
!= &winstation_ops
)
260 set_error( STATUS_OBJECT_TYPE_MISMATCH
);
263 if (memchrW( name
->name
, '\\', name
->len
/ sizeof(WCHAR
) )) /* no backslash allowed in name */
265 set_error( STATUS_OBJECT_PATH_SYNTAX_BAD
);
268 namespace_add( winstation
->desktop_names
, name
);
272 static int desktop_close_handle( struct object
*obj
, struct process
*process
, obj_handle_t handle
)
274 struct thread
*thread
;
276 /* check if the handle is currently used by the process or one of its threads */
277 if (process
->desktop
== handle
) return 0;
278 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
279 if (thread
->desktop
== handle
) return 0;
283 static void desktop_destroy( struct object
*obj
)
285 struct desktop
*desktop
= (struct desktop
*)obj
;
287 free_hotkeys( desktop
, 0 );
288 if (desktop
->top_window
) destroy_window( desktop
->top_window
);
289 if (desktop
->msg_window
) destroy_window( desktop
->msg_window
);
290 if (desktop
->global_hooks
) release_object( desktop
->global_hooks
);
291 if (desktop
->close_timeout
) remove_timeout_user( desktop
->close_timeout
);
292 list_remove( &desktop
->entry
);
293 release_object( desktop
->winstation
);
296 static unsigned int desktop_map_access( struct object
*obj
, unsigned int access
)
298 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| DESKTOP_READOBJECTS
| DESKTOP_ENUMERATE
;
299 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| DESKTOP_CREATEMENU
| DESKTOP_CREATEWINDOW
|
300 DESKTOP_HOOKCONTROL
| DESKTOP_JOURNALRECORD
| DESKTOP_JOURNALPLAYBACK
|
301 DESKTOP_WRITEOBJECTS
;
302 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| DESKTOP_SWITCHDESKTOP
;
303 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_REQUIRED
| DESKTOP_ALL_ACCESS
;
304 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
307 /* retrieve the thread desktop, checking the handle access rights */
308 struct desktop
*get_thread_desktop( struct thread
*thread
, unsigned int access
)
310 return get_desktop_obj( thread
->process
, thread
->desktop
, access
);
313 static void close_desktop_timeout( void *private )
315 struct desktop
*desktop
= private;
317 desktop
->close_timeout
= NULL
;
318 unlink_named_object( &desktop
->obj
); /* make sure no other process can open it */
319 post_desktop_message( desktop
, WM_CLOSE
, 0, 0 ); /* and signal the owner to quit */
322 /* add a user of the desktop and cancel the close timeout */
323 static void add_desktop_user( struct desktop
*desktop
)
326 if (desktop
->close_timeout
)
328 remove_timeout_user( desktop
->close_timeout
);
329 desktop
->close_timeout
= NULL
;
333 /* remove a user of the desktop and start the close timeout if necessary */
334 static void remove_desktop_user( struct desktop
*desktop
)
336 assert( desktop
->users
> 0 );
339 /* if we have one remaining user, it has to be the manager of the desktop window */
340 if (desktop
->users
== 1 && get_top_window_owner( desktop
))
342 assert( !desktop
->close_timeout
);
343 desktop
->close_timeout
= add_timeout_user( -TICKS_PER_SEC
, close_desktop_timeout
, desktop
);
347 /* set the process default desktop handle */
348 void set_process_default_desktop( struct process
*process
, struct desktop
*desktop
,
349 obj_handle_t handle
)
351 struct thread
*thread
;
352 struct desktop
*old_desktop
;
354 if (process
->desktop
== handle
) return; /* nothing to do */
356 if (!(old_desktop
= get_desktop_obj( process
, process
->desktop
, 0 ))) clear_error();
357 process
->desktop
= handle
;
359 /* set desktop for threads that don't have one yet */
360 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
361 if (!thread
->desktop
) thread
->desktop
= handle
;
363 if (!process
->is_system
&& desktop
!= old_desktop
)
365 add_desktop_user( desktop
);
366 if (old_desktop
) remove_desktop_user( old_desktop
);
369 if (old_desktop
) release_object( old_desktop
);
372 /* connect a process to its window station */
373 void connect_process_winstation( struct process
*process
, struct thread
*parent
)
375 struct winstation
*winstation
= NULL
;
376 struct desktop
*desktop
= NULL
;
379 /* check for an inherited winstation handle (don't ask...) */
380 if ((handle
= find_inherited_handle( process
, &winstation_ops
)))
382 winstation
= (struct winstation
*)get_handle_obj( process
, handle
, 0, &winstation_ops
);
384 else if (parent
&& parent
->process
->winstation
)
386 handle
= duplicate_handle( parent
->process
, parent
->process
->winstation
,
387 process
, 0, 0, DUP_HANDLE_SAME_ACCESS
);
388 winstation
= (struct winstation
*)get_handle_obj( process
, handle
, 0, &winstation_ops
);
390 if (!winstation
) goto done
;
391 process
->winstation
= handle
;
393 if ((handle
= find_inherited_handle( process
, &desktop_ops
)))
395 desktop
= get_desktop_obj( process
, handle
, 0 );
396 if (!desktop
|| desktop
->winstation
!= winstation
) goto done
;
398 else if (parent
&& parent
->desktop
)
400 desktop
= get_desktop_obj( parent
->process
, parent
->desktop
, 0 );
401 if (!desktop
|| desktop
->winstation
!= winstation
) goto done
;
402 handle
= duplicate_handle( parent
->process
, parent
->desktop
,
403 process
, 0, 0, DUP_HANDLE_SAME_ACCESS
);
406 if (handle
) set_process_default_desktop( process
, desktop
, handle
);
409 if (desktop
) release_object( desktop
);
410 if (winstation
) release_object( winstation
);
414 /* close the desktop of a given process */
415 void close_process_desktop( struct process
*process
)
417 struct desktop
*desktop
;
419 if (process
->desktop
&& (desktop
= get_desktop_obj( process
, process
->desktop
, 0 )))
421 remove_desktop_user( desktop
);
422 release_object( desktop
);
424 clear_error(); /* ignore errors */
427 /* close the desktop of a given thread */
428 void close_thread_desktop( struct thread
*thread
)
430 obj_handle_t handle
= thread
->desktop
;
433 if (handle
) close_handle( thread
->process
, handle
);
436 /* create a window station */
437 DECL_HANDLER(create_winstation
)
439 struct winstation
*winstation
;
440 struct unicode_str name
= get_req_unicode_str();
441 struct object
*root
= NULL
;
444 if (req
->rootdir
&& !(root
= get_directory_obj( current
->process
, req
->rootdir
))) return;
446 if ((winstation
= create_winstation( root
, &name
, req
->attributes
, req
->flags
)))
448 reply
->handle
= alloc_handle( current
->process
, winstation
, req
->access
, req
->attributes
);
449 release_object( winstation
);
451 if (root
) release_object( root
);
454 /* open a handle to a window station */
455 DECL_HANDLER(open_winstation
)
457 struct unicode_str name
= get_req_unicode_str();
459 reply
->handle
= open_object( current
->process
, req
->rootdir
, req
->access
,
460 &winstation_ops
, &name
, req
->attributes
);
464 /* close a window station */
465 DECL_HANDLER(close_winstation
)
467 struct winstation
*winstation
;
469 if ((winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->handle
,
470 0, &winstation_ops
)))
472 if (close_handle( current
->process
, req
->handle
)) set_error( STATUS_ACCESS_DENIED
);
473 release_object( winstation
);
478 /* get the process current window station */
479 DECL_HANDLER(get_process_winstation
)
481 reply
->handle
= current
->process
->winstation
;
485 /* set the process current window station */
486 DECL_HANDLER(set_process_winstation
)
488 struct winstation
*winstation
;
490 if ((winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->handle
,
491 0, &winstation_ops
)))
493 /* FIXME: should we close the old one? */
494 current
->process
->winstation
= req
->handle
;
495 release_object( winstation
);
499 /* create a desktop */
500 DECL_HANDLER(create_desktop
)
502 struct desktop
*desktop
;
503 struct winstation
*winstation
;
504 struct unicode_str name
= get_req_unicode_str();
507 if ((winstation
= get_process_winstation( current
->process
, WINSTA_CREATEDESKTOP
)))
509 if ((desktop
= create_desktop( &name
, req
->attributes
, req
->flags
, winstation
)))
511 reply
->handle
= alloc_handle( current
->process
, desktop
, req
->access
, req
->attributes
);
512 release_object( desktop
);
514 release_object( winstation
);
518 /* open a handle to a desktop */
519 DECL_HANDLER(open_desktop
)
521 struct winstation
*winstation
;
523 struct unicode_str name
= get_req_unicode_str();
525 /* FIXME: check access rights */
527 winstation
= get_process_winstation( current
->process
, 0 );
529 winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->winsta
, 0, &winstation_ops
);
531 if (!winstation
) return;
533 if ((obj
= open_named_object( &winstation
->obj
, &desktop_ops
, &name
, req
->attributes
)))
535 reply
->handle
= alloc_handle( current
->process
, obj
, req
->access
, req
->attributes
);
536 release_object( obj
);
539 release_object( winstation
);
542 /* open a handle to current input desktop */
543 DECL_HANDLER(open_input_desktop
)
545 /* FIXME: check access rights */
546 struct winstation
*winstation
= get_process_winstation( current
->process
, 0 );
547 struct desktop
*desktop
;
549 if (!winstation
) return;
551 if (!(winstation
->flags
& WSF_VISIBLE
))
553 set_error( STATUS_ILLEGAL_FUNCTION
);
554 release_object( winstation
);
558 if ((desktop
= get_desktop_obj( current
->process
, current
->process
->desktop
, 0 )))
560 reply
->handle
= alloc_handle( current
->process
, desktop
, req
->access
, req
->attributes
);
561 release_object( desktop
);
563 release_object( winstation
);
566 /* close a desktop */
567 DECL_HANDLER(close_desktop
)
569 struct desktop
*desktop
;
571 /* make sure it is a desktop handle */
572 if ((desktop
= (struct desktop
*)get_handle_obj( current
->process
, req
->handle
,
575 if (close_handle( current
->process
, req
->handle
)) set_error( STATUS_DEVICE_BUSY
);
576 release_object( desktop
);
581 /* get the thread current desktop */
582 DECL_HANDLER(get_thread_desktop
)
584 struct thread
*thread
;
586 if (!(thread
= get_thread_from_id( req
->tid
))) return;
587 reply
->handle
= thread
->desktop
;
588 release_object( thread
);
592 /* set the thread current desktop */
593 DECL_HANDLER(set_thread_desktop
)
595 struct desktop
*old_desktop
, *new_desktop
;
596 struct winstation
*winstation
;
598 if (!(winstation
= get_process_winstation( current
->process
, 0 /* FIXME: access rights? */ )))
601 if (!(new_desktop
= get_desktop_obj( current
->process
, req
->handle
, 0 )))
603 release_object( winstation
);
606 if (new_desktop
->winstation
!= winstation
)
608 set_error( STATUS_ACCESS_DENIED
);
609 release_object( new_desktop
);
610 release_object( winstation
);
614 /* check if we are changing to a new desktop */
616 if (!(old_desktop
= get_desktop_obj( current
->process
, current
->desktop
, 0)))
617 clear_error(); /* ignore error */
619 /* when changing desktop, we can't have any users on the current one */
620 if (old_desktop
!= new_desktop
&& current
->desktop_users
> 0)
621 set_error( STATUS_DEVICE_BUSY
);
623 current
->desktop
= req
->handle
; /* FIXME: should we close the old one? */
625 if (!current
->process
->desktop
)
626 set_process_default_desktop( current
->process
, new_desktop
, req
->handle
);
628 if (old_desktop
!= new_desktop
&& current
->queue
) detach_thread_input( current
);
630 if (old_desktop
) release_object( old_desktop
);
631 release_object( new_desktop
);
632 release_object( winstation
);
636 /* get/set information about a user object (window station or desktop) */
637 DECL_HANDLER(set_user_object_info
)
642 if (!(obj
= get_handle_obj( current
->process
, req
->handle
, 0, NULL
))) return;
644 if (obj
->ops
== &desktop_ops
)
646 struct desktop
*desktop
= (struct desktop
*)obj
;
647 reply
->is_desktop
= 1;
648 reply
->old_obj_flags
= desktop
->flags
;
649 if (req
->flags
& SET_USER_OBJECT_SET_FLAGS
) desktop
->flags
= req
->obj_flags
;
651 else if (obj
->ops
== &winstation_ops
)
653 struct winstation
*winstation
= (struct winstation
*)obj
;
654 reply
->is_desktop
= 0;
655 reply
->old_obj_flags
= winstation
->flags
;
656 if (req
->flags
& SET_USER_OBJECT_SET_FLAGS
) winstation
->flags
= req
->obj_flags
;
660 set_error( STATUS_OBJECT_TYPE_MISMATCH
);
661 release_object( obj
);
664 if (obj
->ops
== &desktop_ops
&& get_reply_max_size() && (req
->flags
& SET_USER_OBJECT_GET_FULL_NAME
))
666 struct desktop
*desktop
= (struct desktop
*)obj
;
667 data_size_t winstation_len
, desktop_len
;
668 const WCHAR
*winstation_name
= get_object_name( &desktop
->winstation
->obj
, &winstation_len
);
669 const WCHAR
*desktop_name
= get_object_name( obj
, &desktop_len
);
672 if (!winstation_name
) winstation_len
= 0;
673 if (!desktop_name
) desktop_len
= 0;
674 len
= winstation_len
+ desktop_len
+ sizeof(WCHAR
);
675 if ((full_name
= mem_alloc( len
)))
677 memcpy( full_name
, winstation_name
, winstation_len
);
678 full_name
[winstation_len
/ sizeof(WCHAR
)] = '\\';
679 memcpy( full_name
+ winstation_len
/ sizeof(WCHAR
) + 1, desktop_name
, desktop_len
);
680 set_reply_data_ptr( full_name
, min( len
, get_reply_max_size() ));
685 const WCHAR
*name
= get_object_name( obj
, &len
);
686 if (name
) set_reply_data( name
, min( len
, get_reply_max_size() ));
688 release_object( obj
);
692 /* enumerate window stations */
693 DECL_HANDLER(enum_winstation
)
695 unsigned int index
= 0;
696 struct winstation
*winsta
;
700 LIST_FOR_EACH_ENTRY( winsta
, &winstation_list
, struct winstation
, entry
)
702 unsigned int access
= WINSTA_ENUMERATE
;
703 if (req
->index
> index
++) continue;
704 if (!check_object_access( &winsta
->obj
, &access
)) continue;
707 if ((name
= get_object_name( &winsta
->obj
, &len
)))
708 set_reply_data( name
, min( len
, get_reply_max_size() ));
711 set_error( STATUS_NO_MORE_ENTRIES
);
715 /* enumerate desktops */
716 DECL_HANDLER(enum_desktop
)
718 struct winstation
*winstation
;
719 struct desktop
*desktop
;
720 unsigned int index
= 0;
724 if (!(winstation
= (struct winstation
*)get_handle_obj( current
->process
, req
->winstation
,
725 WINSTA_ENUMDESKTOPS
, &winstation_ops
)))
728 LIST_FOR_EACH_ENTRY( desktop
, &winstation
->desktops
, struct desktop
, entry
)
730 unsigned int access
= DESKTOP_ENUMERATE
;
731 if (req
->index
> index
++) continue;
732 if (!desktop
->obj
.name
) continue;
733 if (!check_object_access( &desktop
->obj
, &access
)) continue;
734 if ((name
= get_object_name( &desktop
->obj
, &len
)))
735 set_reply_data( name
, min( len
, get_reply_max_size() ));
736 release_object( winstation
);
742 release_object( winstation
);
743 set_error( STATUS_NO_MORE_ENTRIES
);