dbghelp: In dwarf parsing, correctly handle the DW_OP_regx option.
[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->users = 0;
234             list_add_tail( &winstation->desktops, &desktop->entry );
235         }
236     }
237     free( full_name );
238     return desktop;
239 }
240
241 static void desktop_dump( struct object *obj, int verbose )
242 {
243     struct desktop *desktop = (struct desktop *)obj;
244
245     fprintf( stderr, "Desktop flags=%x winstation=%p top_win=%p hooks=%p ",
246              desktop->flags, desktop->winstation, desktop->top_window, desktop->global_hooks );
247     dump_object_name( &desktop->obj );
248     fputc( '\n', stderr );
249 }
250
251 static struct object_type *desktop_get_type( struct object *obj )
252 {
253     static const WCHAR name[] = {'D','e','s','k','t','o','p'};
254     static const struct unicode_str str = { name, sizeof(name) };
255     return get_object_type( &str );
256 }
257
258 static int desktop_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
259 {
260     struct thread *thread;
261
262     /* check if the handle is currently used by the process or one of its threads */
263     if (process->desktop == handle) return 0;
264     LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
265         if (thread->desktop == handle) return 0;
266     return 1;
267 }
268
269 static void desktop_destroy( struct object *obj )
270 {
271     struct desktop *desktop = (struct desktop *)obj;
272
273     if (desktop->top_window) destroy_window( desktop->top_window );
274     if (desktop->msg_window) destroy_window( desktop->msg_window );
275     if (desktop->global_hooks) release_object( desktop->global_hooks );
276     if (desktop->close_timeout) remove_timeout_user( desktop->close_timeout );
277     list_remove( &desktop->entry );
278     release_object( desktop->winstation );
279 }
280
281 static unsigned int desktop_map_access( struct object *obj, unsigned int access )
282 {
283     if (access & GENERIC_READ)    access |= STANDARD_RIGHTS_READ | DESKTOP_READOBJECTS | DESKTOP_ENUMERATE;
284     if (access & GENERIC_WRITE)   access |= STANDARD_RIGHTS_WRITE | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
285                                             DESKTOP_HOOKCONTROL | DESKTOP_JOURNALRECORD | DESKTOP_JOURNALPLAYBACK |
286                                             DESKTOP_WRITEOBJECTS;
287     if (access & GENERIC_EXECUTE) access |= STANDARD_RIGHTS_EXECUTE | DESKTOP_SWITCHDESKTOP;
288     if (access & GENERIC_ALL)     access |= STANDARD_RIGHTS_REQUIRED | DESKTOP_ALL_ACCESS;
289     return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
290 }
291
292 /* retrieve the thread desktop, checking the handle access rights */
293 struct desktop *get_thread_desktop( struct thread *thread, unsigned int access )
294 {
295     return get_desktop_obj( thread->process, thread->desktop, access );
296 }
297
298 /* set the process default desktop handle */
299 void set_process_default_desktop( struct process *process, struct desktop *desktop,
300                                   obj_handle_t handle )
301 {
302     struct thread *thread;
303     struct desktop *old_desktop;
304
305     if (process->desktop == handle) return;  /* nothing to do */
306
307     if (!(old_desktop = get_desktop_obj( process, process->desktop, 0 ))) clear_error();
308     process->desktop = handle;
309
310     /* set desktop for threads that don't have one yet */
311     LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
312         if (!thread->desktop) thread->desktop = handle;
313
314     if (!process->is_system)
315     {
316         desktop->users++;
317         if (desktop->close_timeout)
318         {
319             remove_timeout_user( desktop->close_timeout );
320             desktop->close_timeout = NULL;
321         }
322         if (old_desktop) old_desktop->users--;
323     }
324
325     if (old_desktop) release_object( old_desktop );
326 }
327
328 /* connect a process to its window station */
329 void connect_process_winstation( struct process *process, struct thread *parent )
330 {
331     struct winstation *winstation = NULL;
332     struct desktop *desktop = NULL;
333     obj_handle_t handle;
334
335     /* check for an inherited winstation handle (don't ask...) */
336     if ((handle = find_inherited_handle( process, &winstation_ops )))
337     {
338         winstation = (struct winstation *)get_handle_obj( process, handle, 0, &winstation_ops );
339     }
340     else if (parent && parent->process->winstation)
341     {
342         handle = duplicate_handle( parent->process, parent->process->winstation,
343                                    process, 0, 0, DUP_HANDLE_SAME_ACCESS );
344         winstation = (struct winstation *)get_handle_obj( process, handle, 0, &winstation_ops );
345     }
346     if (!winstation) goto done;
347     process->winstation = handle;
348
349     if ((handle = find_inherited_handle( process, &desktop_ops )))
350     {
351         desktop = get_desktop_obj( process, handle, 0 );
352         if (!desktop || desktop->winstation != winstation) goto done;
353     }
354     else if (parent && parent->desktop)
355     {
356         desktop = get_desktop_obj( parent->process, parent->desktop, 0 );
357         if (!desktop || desktop->winstation != winstation) goto done;
358         handle = duplicate_handle( parent->process, parent->desktop,
359                                    process, 0, 0, DUP_HANDLE_SAME_ACCESS );
360     }
361
362     if (handle) set_process_default_desktop( process, desktop, handle );
363
364 done:
365     if (desktop) release_object( desktop );
366     if (winstation) release_object( winstation );
367     clear_error();
368 }
369
370 static void close_desktop_timeout( void *private )
371 {
372     struct desktop *desktop = private;
373
374     desktop->close_timeout = NULL;
375     unlink_named_object( &desktop->obj );  /* make sure no other process can open it */
376     close_desktop_window( desktop );  /* and signal the owner to quit */
377 }
378
379 /* close the desktop of a given process */
380 void close_process_desktop( struct process *process )
381 {
382     struct desktop *desktop;
383
384     if (process->desktop && (desktop = get_desktop_obj( process, process->desktop, 0 )))
385     {
386         assert( desktop->users > 0 );
387         desktop->users--;
388         /* if we have one remaining user, it has to be the manager of the desktop window */
389         if (desktop->users == 1 && get_top_window_owner( desktop ))
390         {
391             assert( !desktop->close_timeout );
392             desktop->close_timeout = add_timeout_user( -TICKS_PER_SEC, close_desktop_timeout, desktop );
393         }
394         release_object( desktop );
395     }
396     clear_error();  /* ignore errors */
397 }
398
399 /* close the desktop of a given thread */
400 void close_thread_desktop( struct thread *thread )
401 {
402     obj_handle_t handle = thread->desktop;
403
404     thread->desktop = 0;
405     if (handle) close_handle( thread->process, handle );
406 }
407
408 /* set the reply data from the object name */
409 static void set_reply_data_obj_name( struct object *obj )
410 {
411     data_size_t len;
412     const WCHAR *ptr, *name = get_object_name( obj, &len );
413
414     /* if there is a backslash return the part of the name after it */
415     if (name && (ptr = memchrW( name, '\\', len/sizeof(WCHAR) )))
416     {
417         len -= (ptr + 1 - name) * sizeof(WCHAR);
418         name = ptr + 1;
419     }
420     if (name) set_reply_data( name, min( len, get_reply_max_size() ));
421 }
422
423 /* create a window station */
424 DECL_HANDLER(create_winstation)
425 {
426     struct winstation *winstation;
427     struct unicode_str name;
428
429     reply->handle = 0;
430     get_req_unicode_str( &name );
431     if ((winstation = create_winstation( &name, req->attributes, req->flags )))
432     {
433         reply->handle = alloc_handle( current->process, winstation, req->access, req->attributes );
434         release_object( winstation );
435     }
436 }
437
438 /* open a handle to a window station */
439 DECL_HANDLER(open_winstation)
440 {
441     struct unicode_str name;
442
443     get_req_unicode_str( &name );
444     if (winstation_namespace)
445         reply->handle = open_object( winstation_namespace, &name, &winstation_ops, req->access,
446                                      req->attributes );
447     else
448         set_error( STATUS_OBJECT_NAME_NOT_FOUND );
449 }
450
451
452 /* close a window station */
453 DECL_HANDLER(close_winstation)
454 {
455     struct winstation *winstation;
456
457     if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
458                                                            0, &winstation_ops )))
459     {
460         if (close_handle( current->process, req->handle )) set_error( STATUS_ACCESS_DENIED );
461         release_object( winstation );
462     }
463 }
464
465
466 /* get the process current window station */
467 DECL_HANDLER(get_process_winstation)
468 {
469     reply->handle = current->process->winstation;
470 }
471
472
473 /* set the process current window station */
474 DECL_HANDLER(set_process_winstation)
475 {
476     struct winstation *winstation;
477
478     if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
479                                                            0, &winstation_ops )))
480     {
481         /* FIXME: should we close the old one? */
482         current->process->winstation = req->handle;
483         release_object( winstation );
484     }
485 }
486
487 /* create a desktop */
488 DECL_HANDLER(create_desktop)
489 {
490     struct desktop *desktop;
491     struct winstation *winstation;
492     struct unicode_str name;
493
494     reply->handle = 0;
495     get_req_unicode_str( &name );
496     if ((winstation = get_process_winstation( current->process, WINSTA_CREATEDESKTOP )))
497     {
498         if ((desktop = create_desktop( &name, req->attributes, req->flags, winstation )))
499         {
500             reply->handle = alloc_handle( current->process, desktop, req->access, req->attributes );
501             release_object( desktop );
502         }
503         release_object( winstation );
504     }
505 }
506
507 /* open a handle to a desktop */
508 DECL_HANDLER(open_desktop)
509 {
510     struct winstation *winstation;
511     struct unicode_str name;
512
513     get_req_unicode_str( &name );
514
515     /* FIXME: check access rights */
516     if (!req->winsta)
517         winstation = get_process_winstation( current->process, 0 );
518     else
519         winstation = (struct winstation *)get_handle_obj( current->process, req->winsta, 0, &winstation_ops );
520
521     if (winstation)
522     {
523         struct unicode_str full_str;
524         WCHAR *full_name;
525
526         if ((full_name = build_desktop_name( &name, winstation, &full_str )))
527         {
528             reply->handle = open_object( winstation_namespace, &full_str, &desktop_ops, req->access,
529                                          req->attributes );
530             free( full_name );
531         }
532         release_object( winstation );
533     }
534 }
535
536
537 /* close a desktop */
538 DECL_HANDLER(close_desktop)
539 {
540     struct desktop *desktop;
541
542     /* make sure it is a desktop handle */
543     if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle,
544                                                      0, &desktop_ops )))
545     {
546         if (close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
547         release_object( desktop );
548     }
549 }
550
551
552 /* get the thread current desktop */
553 DECL_HANDLER(get_thread_desktop)
554 {
555     struct thread *thread;
556
557     if (!(thread = get_thread_from_id( req->tid ))) return;
558     reply->handle = thread->desktop;
559     release_object( thread );
560 }
561
562
563 /* set the thread current desktop */
564 DECL_HANDLER(set_thread_desktop)
565 {
566     struct desktop *old_desktop, *new_desktop;
567     struct winstation *winstation;
568
569     if (!(winstation = get_process_winstation( current->process, 0 /* FIXME: access rights? */ )))
570         return;
571
572     if (!(new_desktop = get_desktop_obj( current->process, req->handle, 0 )))
573     {
574         release_object( winstation );
575         return;
576     }
577     if (new_desktop->winstation != winstation)
578     {
579         set_error( STATUS_ACCESS_DENIED );
580         release_object( new_desktop );
581         release_object( winstation );
582         return;
583     }
584
585     /* check if we are changing to a new desktop */
586
587     if (!(old_desktop = get_desktop_obj( current->process, current->desktop, 0)))
588         clear_error();  /* ignore error */
589
590     /* when changing desktop, we can't have any users on the current one */
591     if (old_desktop != new_desktop && current->desktop_users > 0)
592         set_error( STATUS_DEVICE_BUSY );
593     else
594         current->desktop = req->handle;  /* FIXME: should we close the old one? */
595
596     if (!current->process->desktop)
597         set_process_default_desktop( current->process, new_desktop, req->handle );
598
599     if (old_desktop != new_desktop && current->queue) detach_thread_input( current );
600
601     if (old_desktop) release_object( old_desktop );
602     release_object( new_desktop );
603     release_object( winstation );
604 }
605
606
607 /* get/set information about a user object (window station or desktop) */
608 DECL_HANDLER(set_user_object_info)
609 {
610     struct object *obj;
611
612     if (!(obj = get_handle_obj( current->process, req->handle, 0, NULL ))) return;
613
614     if (obj->ops == &desktop_ops)
615     {
616         struct desktop *desktop = (struct desktop *)obj;
617         reply->is_desktop = 1;
618         reply->old_obj_flags = desktop->flags;
619         if (req->flags & SET_USER_OBJECT_FLAGS) desktop->flags = req->obj_flags;
620     }
621     else if (obj->ops == &winstation_ops)
622     {
623         struct winstation *winstation = (struct winstation *)obj;
624         reply->is_desktop = 0;
625         reply->old_obj_flags = winstation->flags;
626         if (req->flags & SET_USER_OBJECT_FLAGS) winstation->flags = req->obj_flags;
627     }
628     else
629     {
630         set_error( STATUS_OBJECT_TYPE_MISMATCH );
631         release_object( obj );
632         return;
633     }
634     if (get_reply_max_size()) set_reply_data_obj_name( obj );
635     release_object( obj );
636 }
637
638
639 /* enumerate window stations */
640 DECL_HANDLER(enum_winstation)
641 {
642     unsigned int index = 0;
643     struct winstation *winsta;
644
645     LIST_FOR_EACH_ENTRY( winsta, &winstation_list, struct winstation, entry )
646     {
647         unsigned int access = WINSTA_ENUMERATE;
648         if (req->index > index++) continue;
649         if (!check_object_access( &winsta->obj, &access )) continue;
650         set_reply_data_obj_name( &winsta->obj );
651         clear_error();
652         reply->next = index;
653         return;
654     }
655     set_error( STATUS_NO_MORE_ENTRIES );
656 }
657
658
659 /* enumerate desktops */
660 DECL_HANDLER(enum_desktop)
661 {
662     struct winstation *winstation;
663     struct desktop *desktop;
664     unsigned int index = 0;
665
666     if (!(winstation = (struct winstation *)get_handle_obj( current->process, req->winstation,
667                                                             WINSTA_ENUMDESKTOPS, &winstation_ops )))
668         return;
669
670     LIST_FOR_EACH_ENTRY( desktop, &winstation->desktops, struct desktop, entry )
671     {
672         unsigned int access = DESKTOP_ENUMERATE;
673         if (req->index > index++) continue;
674         if (!desktop->obj.name) continue;
675         if (!check_object_access( &desktop->obj, &access )) continue;
676         set_reply_data_obj_name( &desktop->obj );
677         release_object( winstation );
678         clear_error();
679         reply->next = index;
680         return;
681     }
682
683     release_object( winstation );
684     set_error( STATUS_NO_MORE_ENTRIES );
685 }