ddraw: COM cleanup for the IDirect3DExecuteBuffer iface.
[wine] / server / winstation.c
1 /*
2  * Server-side window stations and desktops handling
3  *
4  * Copyright (C) 2002, 2005 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <stdio.h>
25 #include <stdarg.h>
26
27 #include "ntstatus.h"
28 #define WIN32_NO_STATUS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "winternl.h"
33
34 #include "object.h"
35 #include "handle.h"
36 #include "request.h"
37 #include "process.h"
38 #include "user.h"
39 #include "file.h"
40 #include "security.h"
41 #include "wine/unicode.h"
42
43
44 static struct list winstation_list = LIST_INIT(winstation_list);
45 static struct namespace *winstation_namespace;
46
47 static void winstation_dump( struct object *obj, int verbose );
48 static struct object_type *winstation_get_type( struct object *obj );
49 static int winstation_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
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_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
55 static void desktop_destroy( struct object *obj );
56 static unsigned int desktop_map_access( struct object *obj, unsigned int access );
57
58 static const struct object_ops winstation_ops =
59 {
60     sizeof(struct winstation),    /* size */
61     winstation_dump,              /* dump */
62     winstation_get_type,          /* get_type */
63     no_add_queue,                 /* add_queue */
64     NULL,                         /* remove_queue */
65     NULL,                         /* signaled */
66     NULL,                         /* satisfied */
67     no_signal,                    /* signal */
68     no_get_fd,                    /* get_fd */
69     winstation_map_access,        /* map_access */
70     default_get_sd,               /* get_sd */
71     default_set_sd,               /* set_sd */
72     no_lookup_name,               /* lookup_name */
73     no_open_file,                 /* open_file */
74     winstation_close_handle,      /* close_handle */
75     winstation_destroy            /* destroy */
76 };
77
78
79 static const struct object_ops desktop_ops =
80 {
81     sizeof(struct desktop),       /* size */
82     desktop_dump,                 /* dump */
83     desktop_get_type,             /* get_type */
84     no_add_queue,                 /* add_queue */
85     NULL,                         /* remove_queue */
86     NULL,                         /* signaled */
87     NULL,                         /* satisfied */
88     no_signal,                    /* signal */
89     no_get_fd,                    /* get_fd */
90     desktop_map_access,           /* map_access */
91     default_get_sd,               /* get_sd */
92     default_set_sd,               /* set_sd */
93     no_lookup_name,               /* lookup_name */
94     no_open_file,                 /* open_file */
95     desktop_close_handle,         /* close_handle */
96     desktop_destroy               /* destroy */
97 };
98
99 #define DESKTOP_ALL_ACCESS 0x01ff
100
101 /* create a winstation object */
102 static struct winstation *create_winstation( const struct unicode_str *name, unsigned int attr,
103                                              unsigned int flags )
104 {
105     struct winstation *winstation;
106
107     if (!winstation_namespace && !(winstation_namespace = create_namespace( 7 )))
108         return NULL;
109
110     if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) ))  /* no backslash allowed in name */
111     {
112         set_error( STATUS_INVALID_PARAMETER );
113         return NULL;
114     }
115
116     if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, attr )))
117     {
118         if (get_error() != STATUS_OBJECT_NAME_EXISTS)
119         {
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         }
127     }
128     return winstation;
129 }
130
131 static void winstation_dump( struct object *obj, int verbose )
132 {
133     struct winstation *winstation = (struct winstation *)obj;
134
135     fprintf( stderr, "Winstation flags=%x clipboard=%p atoms=%p ",
136              winstation->flags, winstation->clipboard, winstation->atom_table );
137     dump_object_name( &winstation->obj );
138     fputc( '\n', stderr );
139 }
140
141 static struct object_type *winstation_get_type( struct object *obj )
142 {
143     static const WCHAR name[] = {'W','i','n','d','o','w','S','t','a','t','i','o','n'};
144     static const struct unicode_str str = { name, sizeof(name) };
145     return get_object_type( &str );
146 }
147
148 static int winstation_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
149 {
150     return (process->winstation != handle);
151 }
152
153 static void winstation_destroy( struct object *obj )
154 {
155     struct winstation *winstation = (struct winstation *)obj;
156
157     list_remove( &winstation->entry );
158     if (winstation->clipboard) release_object( winstation->clipboard );
159     if (winstation->atom_table) release_object( winstation->atom_table );
160 }
161
162 static unsigned int winstation_map_access( struct object *obj, unsigned int access )
163 {
164     if (access & GENERIC_READ)    access |= STANDARD_RIGHTS_READ | WINSTA_ENUMDESKTOPS | WINSTA_READATTRIBUTES |
165                                             WINSTA_ENUMERATE | WINSTA_READSCREEN;
166     if (access & GENERIC_WRITE)   access |= STANDARD_RIGHTS_WRITE | WINSTA_ACCESSCLIPBOARD | WINSTA_CREATEDESKTOP |
167                                             WINSTA_WRITEATTRIBUTES;
168     if (access & GENERIC_EXECUTE) access |= STANDARD_RIGHTS_EXECUTE | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS;
169     if (access & GENERIC_ALL)     access |= STANDARD_RIGHTS_REQUIRED | WINSTA_ALL_ACCESS;
170     return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
171 }
172
173 /* retrieve the process window station, checking the handle access rights */
174 struct winstation *get_process_winstation( struct process *process, unsigned int access )
175 {
176     return (struct winstation *)get_handle_obj( process, process->winstation,
177                                                 access, &winstation_ops );
178 }
179
180 /* build the full name of a desktop object */
181 static WCHAR *build_desktop_name( const struct unicode_str *name,
182                                   struct winstation *winstation, struct unicode_str *res )
183 {
184     const WCHAR *winstation_name;
185     WCHAR *full_name;
186     data_size_t winstation_len;
187
188     if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) ))
189     {
190         set_error( STATUS_INVALID_PARAMETER );
191         return NULL;
192     }
193
194     if (!(winstation_name = get_object_name( &winstation->obj, &winstation_len )))
195         winstation_len = 0;
196
197     res->len = winstation_len + name->len + sizeof(WCHAR);
198     if (!(full_name = mem_alloc( res->len ))) return NULL;
199     memcpy( full_name, winstation_name, winstation_len );
200     full_name[winstation_len / sizeof(WCHAR)] = '\\';
201     memcpy( full_name + winstation_len / sizeof(WCHAR) + 1, name->str, name->len );
202     res->str = full_name;
203     return full_name;
204 }
205
206 /* retrieve a pointer to a desktop object */
207 struct desktop *get_desktop_obj( struct process *process, obj_handle_t handle, unsigned int access )
208 {
209     return (struct desktop *)get_handle_obj( process, handle, access, &desktop_ops );
210 }
211
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 )
215 {
216     struct desktop *desktop;
217     struct unicode_str full_str;
218     WCHAR *full_name;
219
220     if (!(full_name = build_desktop_name( name, winstation, &full_str ))) return NULL;
221
222     if ((desktop = create_named_object( winstation_namespace, &desktop_ops, &full_str, attr )))
223     {
224         if (get_error() != STATUS_OBJECT_NAME_EXISTS)
225         {
226             /* initialize it if it didn't already exist */
227             desktop->flags = flags;
228             desktop->winstation = (struct winstation *)grab_object( winstation );
229             desktop->top_window = NULL;
230             desktop->msg_window = NULL;
231             desktop->global_hooks = NULL;
232             desktop->close_timeout = NULL;
233             desktop->foreground_input = NULL;
234             desktop->users = 0;
235             memset( &desktop->cursor, 0, sizeof(desktop->cursor) );
236             memset( desktop->keystate, 0, sizeof(desktop->keystate) );
237             list_add_tail( &winstation->desktops, &desktop->entry );
238             list_init( &desktop->hotkeys );
239         }
240     }
241     free( full_name );
242     return desktop;
243 }
244
245 static void desktop_dump( struct object *obj, int verbose )
246 {
247     struct desktop *desktop = (struct desktop *)obj;
248
249     fprintf( stderr, "Desktop flags=%x winstation=%p top_win=%p hooks=%p ",
250              desktop->flags, desktop->winstation, desktop->top_window, desktop->global_hooks );
251     dump_object_name( &desktop->obj );
252     fputc( '\n', stderr );
253 }
254
255 static struct object_type *desktop_get_type( struct object *obj )
256 {
257     static const WCHAR name[] = {'D','e','s','k','t','o','p'};
258     static const struct unicode_str str = { name, sizeof(name) };
259     return get_object_type( &str );
260 }
261
262 static int desktop_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
263 {
264     struct thread *thread;
265
266     /* check if the handle is currently used by the process or one of its threads */
267     if (process->desktop == handle) return 0;
268     LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
269         if (thread->desktop == handle) return 0;
270     return 1;
271 }
272
273 static void desktop_destroy( struct object *obj )
274 {
275     struct desktop *desktop = (struct desktop *)obj;
276
277     free_hotkeys( desktop, 0 );
278     if (desktop->top_window) destroy_window( desktop->top_window );
279     if (desktop->msg_window) destroy_window( desktop->msg_window );
280     if (desktop->global_hooks) release_object( desktop->global_hooks );
281     if (desktop->close_timeout) remove_timeout_user( desktop->close_timeout );
282     list_remove( &desktop->entry );
283     release_object( desktop->winstation );
284 }
285
286 static unsigned int desktop_map_access( struct object *obj, unsigned int access )
287 {
288     if (access & GENERIC_READ)    access |= STANDARD_RIGHTS_READ | DESKTOP_READOBJECTS | DESKTOP_ENUMERATE;
289     if (access & GENERIC_WRITE)   access |= STANDARD_RIGHTS_WRITE | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
290                                             DESKTOP_HOOKCONTROL | DESKTOP_JOURNALRECORD | DESKTOP_JOURNALPLAYBACK |
291                                             DESKTOP_WRITEOBJECTS;
292     if (access & GENERIC_EXECUTE) access |= STANDARD_RIGHTS_EXECUTE | DESKTOP_SWITCHDESKTOP;
293     if (access & GENERIC_ALL)     access |= STANDARD_RIGHTS_REQUIRED | DESKTOP_ALL_ACCESS;
294     return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
295 }
296
297 /* retrieve the thread desktop, checking the handle access rights */
298 struct desktop *get_thread_desktop( struct thread *thread, unsigned int access )
299 {
300     return get_desktop_obj( thread->process, thread->desktop, access );
301 }
302
303 /* set the process default desktop handle */
304 void set_process_default_desktop( struct process *process, struct desktop *desktop,
305                                   obj_handle_t handle )
306 {
307     struct thread *thread;
308     struct desktop *old_desktop;
309
310     if (process->desktop == handle) return;  /* nothing to do */
311
312     if (!(old_desktop = get_desktop_obj( process, process->desktop, 0 ))) clear_error();
313     process->desktop = handle;
314
315     /* set desktop for threads that don't have one yet */
316     LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
317         if (!thread->desktop) thread->desktop = handle;
318
319     if (!process->is_system)
320     {
321         desktop->users++;
322         if (desktop->close_timeout)
323         {
324             remove_timeout_user( desktop->close_timeout );
325             desktop->close_timeout = NULL;
326         }
327         if (old_desktop) old_desktop->users--;
328     }
329
330     if (old_desktop) release_object( old_desktop );
331 }
332
333 /* connect a process to its window station */
334 void connect_process_winstation( struct process *process, struct thread *parent )
335 {
336     struct winstation *winstation = NULL;
337     struct desktop *desktop = NULL;
338     obj_handle_t handle;
339
340     /* check for an inherited winstation handle (don't ask...) */
341     if ((handle = find_inherited_handle( process, &winstation_ops )))
342     {
343         winstation = (struct winstation *)get_handle_obj( process, handle, 0, &winstation_ops );
344     }
345     else if (parent && parent->process->winstation)
346     {
347         handle = duplicate_handle( parent->process, parent->process->winstation,
348                                    process, 0, 0, DUP_HANDLE_SAME_ACCESS );
349         winstation = (struct winstation *)get_handle_obj( process, handle, 0, &winstation_ops );
350     }
351     if (!winstation) goto done;
352     process->winstation = handle;
353
354     if ((handle = find_inherited_handle( process, &desktop_ops )))
355     {
356         desktop = get_desktop_obj( process, handle, 0 );
357         if (!desktop || desktop->winstation != winstation) goto done;
358     }
359     else if (parent && parent->desktop)
360     {
361         desktop = get_desktop_obj( parent->process, parent->desktop, 0 );
362         if (!desktop || desktop->winstation != winstation) goto done;
363         handle = duplicate_handle( parent->process, parent->desktop,
364                                    process, 0, 0, DUP_HANDLE_SAME_ACCESS );
365     }
366
367     if (handle) set_process_default_desktop( process, desktop, handle );
368
369 done:
370     if (desktop) release_object( desktop );
371     if (winstation) release_object( winstation );
372     clear_error();
373 }
374
375 static void close_desktop_timeout( void *private )
376 {
377     struct desktop *desktop = private;
378
379     desktop->close_timeout = NULL;
380     unlink_named_object( &desktop->obj );  /* make sure no other process can open it */
381     post_desktop_message( desktop, WM_CLOSE, 0, 0 );  /* and signal the owner to quit */
382 }
383
384 /* close the desktop of a given process */
385 void close_process_desktop( struct process *process )
386 {
387     struct desktop *desktop;
388
389     if (process->desktop && (desktop = get_desktop_obj( process, process->desktop, 0 )))
390     {
391         assert( desktop->users > 0 );
392         desktop->users--;
393         /* if we have one remaining user, it has to be the manager of the desktop window */
394         if (desktop->users == 1 && get_top_window_owner( desktop ))
395         {
396             assert( !desktop->close_timeout );
397             desktop->close_timeout = add_timeout_user( -TICKS_PER_SEC, close_desktop_timeout, desktop );
398         }
399         release_object( desktop );
400     }
401     clear_error();  /* ignore errors */
402 }
403
404 /* close the desktop of a given thread */
405 void close_thread_desktop( struct thread *thread )
406 {
407     obj_handle_t handle = thread->desktop;
408
409     thread->desktop = 0;
410     if (handle) close_handle( thread->process, handle );
411 }
412
413 /* set the reply data from the object name */
414 static void set_reply_data_obj_name( struct object *obj )
415 {
416     data_size_t len;
417     const WCHAR *ptr, *name = get_object_name( obj, &len );
418
419     /* if there is a backslash return the part of the name after it */
420     if (name && (ptr = memchrW( name, '\\', len/sizeof(WCHAR) )))
421     {
422         len -= (ptr + 1 - name) * sizeof(WCHAR);
423         name = ptr + 1;
424     }
425     if (name) set_reply_data( name, min( len, get_reply_max_size() ));
426 }
427
428 /* create a window station */
429 DECL_HANDLER(create_winstation)
430 {
431     struct winstation *winstation;
432     struct unicode_str name;
433
434     reply->handle = 0;
435     get_req_unicode_str( &name );
436     if ((winstation = create_winstation( &name, req->attributes, req->flags )))
437     {
438         reply->handle = alloc_handle( current->process, winstation, req->access, req->attributes );
439         release_object( winstation );
440     }
441 }
442
443 /* open a handle to a window station */
444 DECL_HANDLER(open_winstation)
445 {
446     struct unicode_str name;
447
448     get_req_unicode_str( &name );
449     if (winstation_namespace)
450         reply->handle = open_object( winstation_namespace, &name, &winstation_ops, req->access,
451                                      req->attributes );
452     else
453         set_error( STATUS_OBJECT_NAME_NOT_FOUND );
454 }
455
456
457 /* close a window station */
458 DECL_HANDLER(close_winstation)
459 {
460     struct winstation *winstation;
461
462     if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
463                                                            0, &winstation_ops )))
464     {
465         if (close_handle( current->process, req->handle )) set_error( STATUS_ACCESS_DENIED );
466         release_object( winstation );
467     }
468 }
469
470
471 /* get the process current window station */
472 DECL_HANDLER(get_process_winstation)
473 {
474     reply->handle = current->process->winstation;
475 }
476
477
478 /* set the process current window station */
479 DECL_HANDLER(set_process_winstation)
480 {
481     struct winstation *winstation;
482
483     if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
484                                                            0, &winstation_ops )))
485     {
486         /* FIXME: should we close the old one? */
487         current->process->winstation = req->handle;
488         release_object( winstation );
489     }
490 }
491
492 /* create a desktop */
493 DECL_HANDLER(create_desktop)
494 {
495     struct desktop *desktop;
496     struct winstation *winstation;
497     struct unicode_str name;
498
499     reply->handle = 0;
500     get_req_unicode_str( &name );
501     if ((winstation = get_process_winstation( current->process, WINSTA_CREATEDESKTOP )))
502     {
503         if ((desktop = create_desktop( &name, req->attributes, req->flags, winstation )))
504         {
505             reply->handle = alloc_handle( current->process, desktop, req->access, req->attributes );
506             release_object( desktop );
507         }
508         release_object( winstation );
509     }
510 }
511
512 /* open a handle to a desktop */
513 DECL_HANDLER(open_desktop)
514 {
515     struct winstation *winstation;
516     struct unicode_str name;
517
518     get_req_unicode_str( &name );
519
520     /* FIXME: check access rights */
521     if (!req->winsta)
522         winstation = get_process_winstation( current->process, 0 );
523     else
524         winstation = (struct winstation *)get_handle_obj( current->process, req->winsta, 0, &winstation_ops );
525
526     if (winstation)
527     {
528         struct unicode_str full_str;
529         WCHAR *full_name;
530
531         if ((full_name = build_desktop_name( &name, winstation, &full_str )))
532         {
533             reply->handle = open_object( winstation_namespace, &full_str, &desktop_ops, req->access,
534                                          req->attributes );
535             free( full_name );
536         }
537         release_object( winstation );
538     }
539 }
540
541
542 /* close a desktop */
543 DECL_HANDLER(close_desktop)
544 {
545     struct desktop *desktop;
546
547     /* make sure it is a desktop handle */
548     if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle,
549                                                      0, &desktop_ops )))
550     {
551         if (close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
552         release_object( desktop );
553     }
554 }
555
556
557 /* get the thread current desktop */
558 DECL_HANDLER(get_thread_desktop)
559 {
560     struct thread *thread;
561
562     if (!(thread = get_thread_from_id( req->tid ))) return;
563     reply->handle = thread->desktop;
564     release_object( thread );
565 }
566
567
568 /* set the thread current desktop */
569 DECL_HANDLER(set_thread_desktop)
570 {
571     struct desktop *old_desktop, *new_desktop;
572     struct winstation *winstation;
573
574     if (!(winstation = get_process_winstation( current->process, 0 /* FIXME: access rights? */ )))
575         return;
576
577     if (!(new_desktop = get_desktop_obj( current->process, req->handle, 0 )))
578     {
579         release_object( winstation );
580         return;
581     }
582     if (new_desktop->winstation != winstation)
583     {
584         set_error( STATUS_ACCESS_DENIED );
585         release_object( new_desktop );
586         release_object( winstation );
587         return;
588     }
589
590     /* check if we are changing to a new desktop */
591
592     if (!(old_desktop = get_desktop_obj( current->process, current->desktop, 0)))
593         clear_error();  /* ignore error */
594
595     /* when changing desktop, we can't have any users on the current one */
596     if (old_desktop != new_desktop && current->desktop_users > 0)
597         set_error( STATUS_DEVICE_BUSY );
598     else
599         current->desktop = req->handle;  /* FIXME: should we close the old one? */
600
601     if (!current->process->desktop)
602         set_process_default_desktop( current->process, new_desktop, req->handle );
603
604     if (old_desktop != new_desktop && current->queue) detach_thread_input( current );
605
606     if (old_desktop) release_object( old_desktop );
607     release_object( new_desktop );
608     release_object( winstation );
609 }
610
611
612 /* get/set information about a user object (window station or desktop) */
613 DECL_HANDLER(set_user_object_info)
614 {
615     struct object *obj;
616
617     if (!(obj = get_handle_obj( current->process, req->handle, 0, NULL ))) return;
618
619     if (obj->ops == &desktop_ops)
620     {
621         struct desktop *desktop = (struct desktop *)obj;
622         reply->is_desktop = 1;
623         reply->old_obj_flags = desktop->flags;
624         if (req->flags & SET_USER_OBJECT_FLAGS) desktop->flags = req->obj_flags;
625     }
626     else if (obj->ops == &winstation_ops)
627     {
628         struct winstation *winstation = (struct winstation *)obj;
629         reply->is_desktop = 0;
630         reply->old_obj_flags = winstation->flags;
631         if (req->flags & SET_USER_OBJECT_FLAGS) winstation->flags = req->obj_flags;
632     }
633     else
634     {
635         set_error( STATUS_OBJECT_TYPE_MISMATCH );
636         release_object( obj );
637         return;
638     }
639     if (get_reply_max_size()) set_reply_data_obj_name( obj );
640     release_object( obj );
641 }
642
643
644 /* enumerate window stations */
645 DECL_HANDLER(enum_winstation)
646 {
647     unsigned int index = 0;
648     struct winstation *winsta;
649
650     LIST_FOR_EACH_ENTRY( winsta, &winstation_list, struct winstation, entry )
651     {
652         unsigned int access = WINSTA_ENUMERATE;
653         if (req->index > index++) continue;
654         if (!check_object_access( &winsta->obj, &access )) continue;
655         set_reply_data_obj_name( &winsta->obj );
656         clear_error();
657         reply->next = index;
658         return;
659     }
660     set_error( STATUS_NO_MORE_ENTRIES );
661 }
662
663
664 /* enumerate desktops */
665 DECL_HANDLER(enum_desktop)
666 {
667     struct winstation *winstation;
668     struct desktop *desktop;
669     unsigned int index = 0;
670
671     if (!(winstation = (struct winstation *)get_handle_obj( current->process, req->winstation,
672                                                             WINSTA_ENUMDESKTOPS, &winstation_ops )))
673         return;
674
675     LIST_FOR_EACH_ENTRY( desktop, &winstation->desktops, struct desktop, entry )
676     {
677         unsigned int access = DESKTOP_ENUMERATE;
678         if (req->index > index++) continue;
679         if (!desktop->obj.name) continue;
680         if (!check_object_access( &desktop->obj, &access )) continue;
681         set_reply_data_obj_name( &desktop->obj );
682         release_object( winstation );
683         clear_error();
684         reply->next = index;
685         return;
686     }
687
688     release_object( winstation );
689     set_error( STATUS_NO_MORE_ENTRIES );
690 }