From 24560e70bb8a8519aff932d5e06d4e0519b6f1bc Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Fri, 9 Dec 2005 13:58:25 +0100
Subject: [PATCH] server: Make alloc_handle use attributes instead of inherit
 flag.

---
 server/atom.c       |  2 +-
 server/console.c    | 13 +++++--------
 server/debugger.c   | 14 +++++++-------
 server/directory.c  |  6 ++----
 server/event.c      |  6 ++----
 server/file.c       |  6 ++----
 server/handle.c     | 14 +++++++-------
 server/handle.h     |  4 ++--
 server/mailslot.c   |  6 ++----
 server/mapping.c    |  6 ++----
 server/mutex.c      |  6 ++----
 server/named_pipe.c |  6 ++----
 server/process.c    | 15 +++++++--------
 server/semaphore.c  |  6 ++----
 server/snapshot.c   |  2 +-
 server/sock.c       |  6 ++----
 server/symlink.c    |  6 ++----
 server/thread.c     |  6 ++----
 server/timer.c      |  6 ++----
 server/token.c      |  7 +++----
 server/winstation.c | 10 ++++------
 21 files changed, 61 insertions(+), 92 deletions(-)

diff --git a/server/atom.c b/server/atom.c
index a8d26af3515..e42a503ed7a 100644
--- a/server/atom.c
+++ b/server/atom.c
@@ -445,7 +445,7 @@ DECL_HANDLER(init_atom_table)
 
     if (table)
     {
-        reply->table = alloc_handle( current->process, table, 0, FALSE);
+        reply->table = alloc_handle( current->process, table, 0, 0 );
         release_object( table );
     }
 }
diff --git a/server/console.c b/server/console.c
index e0960793fed..56d359c2cc3 100644
--- a/server/console.c
+++ b/server/console.c
@@ -1240,10 +1240,9 @@ DECL_HANDLER(alloc_console)
     }
     if ((console = (struct console_input*)create_console_input( current )))
     {
-        if ((in = alloc_handle( renderer, console, req->access, req->attributes & OBJ_INHERIT )))
+        if ((in = alloc_handle( renderer, console, req->access, req->attributes )))
         {
-            if ((evt = alloc_handle( renderer, console->evt,
-                                     SYNCHRONIZE|GENERIC_READ|GENERIC_WRITE, FALSE )))
+            if ((evt = alloc_handle( renderer, console->evt, SYNCHRONIZE|GENERIC_READ|GENERIC_WRITE, 0 )))
             {
                 if (process != renderer)
                 {
@@ -1312,7 +1311,7 @@ DECL_HANDLER(open_console)
     /* FIXME: req->share is not used (as in screen buffer creation)  */
     if (obj)
     {
-        reply->handle = alloc_handle( current->process, obj, req->access, req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
         release_object( obj );
     }
     else if (!get_error()) set_error( STATUS_ACCESS_DENIED );
@@ -1410,8 +1409,7 @@ DECL_HANDLER(create_console_output)
     {
         /* FIXME: should store sharing and test it when opening the CONOUT$ device
          * see file.c on how this could be done */
-        reply->handle_out = alloc_handle( current->process, screen_buffer,
-                                          req->access, req->attributes & OBJ_INHERIT );
+        reply->handle_out = alloc_handle( current->process, screen_buffer, req->access, req->attributes );
         release_object( screen_buffer );
     }
     release_object( console );
@@ -1541,8 +1539,7 @@ DECL_HANDLER(get_console_wait_event)
 
     if (console)
     {
-        reply->handle = alloc_handle( current->process, console->event, 
-                                      EVENT_ALL_ACCESS, FALSE);
+        reply->handle = alloc_handle( current->process, console->event, EVENT_ALL_ACCESS, 0 );
         release_object( console );
     }
     else set_error( STATUS_INVALID_PARAMETER );
diff --git a/server/debugger.c b/server/debugger.c
index a7f88308aae..f40f494b6dc 100644
--- a/server/debugger.c
+++ b/server/debugger.c
@@ -116,7 +116,7 @@ static int fill_create_thread_event( struct debug_event *event, void *arg )
     obj_handle_t handle;
 
     /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
-    if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE ))) return 0;
+    if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, 0 ))) return 0;
     event->data.info.create_thread.handle = handle;
     event->data.info.create_thread.teb    = thread->teb;
     event->data.info.create_thread.start  = arg;
@@ -131,11 +131,11 @@ static int fill_create_process_event( struct debug_event *event, void *arg )
     obj_handle_t handle;
 
     /* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */
-    if (!(handle = alloc_handle( debugger, process, PROCESS_ALL_ACCESS, FALSE ))) return 0;
+    if (!(handle = alloc_handle( debugger, process, PROCESS_ALL_ACCESS, 0 ))) return 0;
     event->data.info.create_process.process = handle;
 
     /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
-    if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE )))
+    if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, 0 )))
     {
         close_handle( debugger, event->data.info.create_process.process, NULL );
         return 0;
@@ -145,7 +145,7 @@ static int fill_create_process_event( struct debug_event *event, void *arg )
     handle = 0;
     if (process->exe.file &&
         /* the doc says write access too, but this doesn't seem a good idea */
-        !(handle = alloc_handle( debugger, process->exe.file, GENERIC_READ, FALSE )))
+        !(handle = alloc_handle( debugger, process->exe.file, GENERIC_READ, 0 )))
     {
         close_handle( debugger, event->data.info.create_process.process, NULL );
         close_handle( debugger, event->data.info.create_process.thread, NULL );
@@ -182,7 +182,7 @@ static int fill_load_dll_event( struct debug_event *event, void *arg )
     struct process_dll *dll = arg;
     obj_handle_t handle = 0;
 
-    if (dll->file && !(handle = alloc_handle( debugger, dll->file, GENERIC_READ, FALSE )))
+    if (dll->file && !(handle = alloc_handle( debugger, dll->file, GENERIC_READ, 0 )))
         return 0;
     event->data.info.load_dll.handle     = handle;
     event->data.info.load_dll.base       = dll->base;
@@ -582,7 +582,7 @@ DECL_HANDLER(wait_debug_event)
         reply->pid  = 0;
         reply->tid  = 0;
         if (req->get_handle)
-            reply->wait = alloc_handle( current->process, debug_ctx, SYNCHRONIZE, FALSE );
+            reply->wait = alloc_handle( current->process, debug_ctx, SYNCHRONIZE, 0 );
     }
 }
 
@@ -651,7 +651,7 @@ DECL_HANDLER(queue_exception_event)
         data.first  = req->first;
         if ((event = alloc_debug_event( current, EXCEPTION_DEBUG_EVENT, &data, context )))
         {
-            if ((reply->handle = alloc_handle( current->process, event, SYNCHRONIZE, FALSE )))
+            if ((reply->handle = alloc_handle( current->process, event, SYNCHRONIZE, 0 )))
             {
                 link_event( event );
                 suspend_process( current->process );
diff --git a/server/directory.c b/server/directory.c
index 21dec3ab312..6f1483387d4 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -368,8 +368,7 @@ DECL_HANDLER(create_directory)
 
     if ((dir = create_directory( root, &name, req->attributes, HASH_SIZE )))
     {
-        reply->handle = alloc_handle( current->process, dir, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, dir, req->access, req->attributes );
         release_object( dir );
     }
 
@@ -388,8 +387,7 @@ DECL_HANDLER(open_directory)
 
     if ((dir = open_object_dir( root, &name, req->attributes, &directory_ops )))
     {
-        reply->handle = alloc_handle( current->process, &dir->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &dir->obj, req->access, req->attributes );
         release_object( dir );
     }
 
diff --git a/server/event.c b/server/event.c
index 7464e189755..adbbb11748f 100644
--- a/server/event.c
+++ b/server/event.c
@@ -159,8 +159,7 @@ DECL_HANDLER(create_event)
 
     if ((event = create_event( root, &name, req->attributes, req->manual_reset, req->initial_state )))
     {
-        reply->handle = alloc_handle( current->process, event, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, event, req->access, req->attributes );
         release_object( event );
     }
 
@@ -180,8 +179,7 @@ DECL_HANDLER(open_event)
 
     if ((event = open_object_dir( root, &name, req->attributes, &event_ops )))
     {
-        reply->handle = alloc_handle( current->process, &event->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &event->obj, req->access, req->attributes );
         release_object( event );
     }
 
diff --git a/server/file.c b/server/file.c
index 1b34c7aa022..b24751ac0c0 100644
--- a/server/file.c
+++ b/server/file.c
@@ -356,8 +356,7 @@ DECL_HANDLER(create_file)
     if ((file = create_file( get_req_data(), get_req_data_size(), req->access,
                              req->sharing, req->create, req->options, req->attrs )))
     {
-        reply->handle = alloc_handle( current->process, file, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, file, req->access, req->attributes );
         release_object( file );
     }
 }
@@ -376,8 +375,7 @@ DECL_HANDLER(alloc_file_handle)
     }
     if ((file = create_file_for_fd( fd, req->access, FILE_SHARE_READ | FILE_SHARE_WRITE )))
     {
-        reply->handle = alloc_handle( current->process, file, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, file, req->access, req->attributes );
         release_object( file );
     }
 }
diff --git a/server/handle.c b/server/handle.c
index 9ba56b6c2bb..930519180ab 100644
--- a/server/handle.c
+++ b/server/handle.c
@@ -223,10 +223,10 @@ static obj_handle_t alloc_entry( struct handle_table *table, void *obj, unsigned
 
 /* allocate a handle for an object, incrementing its refcount */
 /* return the handle, or 0 on error */
-obj_handle_t alloc_handle( struct process *process, void *obj, unsigned int access, int inherit )
+obj_handle_t alloc_handle( struct process *process, void *obj, unsigned int access, unsigned int attr )
 {
     access &= ~RESERVED_ALL;
-    if (inherit) access |= RESERVED_INHERIT;
+    if (attr & OBJ_INHERIT) access |= RESERVED_INHERIT;
     if (!process->handles)
     {
         set_error( STATUS_NO_MEMORY );
@@ -497,7 +497,7 @@ static int set_handle_flags( struct process *process, obj_handle_t handle, int m
 
 /* duplicate a handle */
 obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, struct process *dst,
-                           unsigned int access, int inherit, int options )
+                               unsigned int access, unsigned int attr, unsigned int options )
 {
     obj_handle_t res;
     struct object *obj = get_handle_obj( src, src_handle, 0, NULL );
@@ -518,7 +518,7 @@ obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, str
     if (options & DUP_HANDLE_MAKE_GLOBAL)
         res = alloc_global_handle( obj, access );
     else
-        res = alloc_handle( dst, obj, access, inherit );
+        res = alloc_handle( dst, obj, access, attr );
     release_object( obj );
     return res;
 }
@@ -534,7 +534,7 @@ obj_handle_t open_object( const struct namespace *namespace, const struct unicod
         if (ops && obj->ops != ops)
             set_error( STATUS_OBJECT_TYPE_MISMATCH );
         else
-            handle = alloc_handle( current->process, obj, access, attr & OBJ_INHERIT );
+            handle = alloc_handle( current->process, obj, access, attr );
         release_object( obj );
     }
     else
@@ -573,12 +573,12 @@ DECL_HANDLER(dup_handle)
         if (req->options & DUP_HANDLE_MAKE_GLOBAL)
         {
             reply->handle = duplicate_handle( src, req->src_handle, NULL,
-                                              req->access, req->attributes & OBJ_INHERIT, req->options );
+                                              req->access, req->attributes, req->options );
         }
         else if ((dst = get_process_from_handle( req->dst_process, PROCESS_DUP_HANDLE )))
         {
             reply->handle = duplicate_handle( src, req->src_handle, dst,
-                                              req->access, req->attributes & OBJ_INHERIT, req->options );
+                                              req->access, req->attributes, req->options );
             release_object( dst );
         }
         /* close the handle no matter what happened */
diff --git a/server/handle.h b/server/handle.h
index 74dd7ddd86a..ad712523c79 100644
--- a/server/handle.h
+++ b/server/handle.h
@@ -35,7 +35,7 @@ struct unicode_str;
 /* alloc_handle takes a void *obj for convenience, but you better make sure */
 /* that the thing pointed to starts with a struct object... */
 extern obj_handle_t alloc_handle( struct process *process, void *obj,
-                              unsigned int access, int inherit );
+                                  unsigned int access, unsigned int attr );
 extern int close_handle( struct process *process, obj_handle_t handle, int *fd );
 extern struct object *get_handle_obj( struct process *process, obj_handle_t handle,
                                       unsigned int access, const struct object_ops *ops );
@@ -43,7 +43,7 @@ extern unsigned int get_handle_access( struct process *process, obj_handle_t han
 extern int get_handle_unix_fd( struct process *process, obj_handle_t handle, unsigned int access );
 extern int set_handle_unix_fd( struct process *process, obj_handle_t handle, int fd );
 extern obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, struct process *dst,
-                                  unsigned int access, int inherit, int options );
+                                      unsigned int access, unsigned int attr, unsigned int options );
 extern obj_handle_t open_object( const struct namespace *namespace, const struct unicode_str *name,
                                  const struct object_ops *ops, unsigned int access, unsigned int attr );
 extern obj_handle_t find_inherited_handle( struct process *process, const struct object_ops *ops );
diff --git a/server/mailslot.c b/server/mailslot.c
index c88289600b2..f4accf22eb8 100644
--- a/server/mailslot.c
+++ b/server/mailslot.c
@@ -429,8 +429,7 @@ DECL_HANDLER(create_mailslot)
     if ((mailslot = create_mailslot( root, &name, req->attributes, req->max_msgsize,
                                      req->read_timeout )))
     {
-        reply->handle = alloc_handle( current->process, mailslot,
-                                      req->access, req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, mailslot, req->access, req->attributes );
         release_object( mailslot );
     }
 
@@ -466,8 +465,7 @@ DECL_HANDLER(open_mailslot)
         writer = create_mail_writer( mailslot, req->access, req->sharing );
         if (writer)
         {
-            reply->handle = alloc_handle( current->process, writer,
-                                          req->access, req->attributes & OBJ_INHERIT );
+            reply->handle = alloc_handle( current->process, writer, req->access, req->attributes );
             release_object( writer );
         }
         release_object( mailslot );
diff --git a/server/mapping.c b/server/mapping.c
index cc81e376d62..c9813f222f4 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -389,8 +389,7 @@ DECL_HANDLER(create_mapping)
 
     if ((obj = create_mapping( root, &name, req->attributes, size, req->protect, req->file_handle )))
     {
-        reply->handle = alloc_handle( current->process, obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
         release_object( obj );
     }
 
@@ -410,8 +409,7 @@ DECL_HANDLER(open_mapping)
 
     if ((mapping = open_object_dir( root, &name, req->attributes, &mapping_ops )))
     {
-        reply->handle = alloc_handle( current->process, &mapping->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &mapping->obj, req->access, req->attributes );
         release_object( mapping );
     }
 
diff --git a/server/mutex.c b/server/mutex.c
index 18c194e0dd4..f6022002424 100644
--- a/server/mutex.c
+++ b/server/mutex.c
@@ -185,8 +185,7 @@ DECL_HANDLER(create_mutex)
 
     if ((mutex = create_mutex( root, &name, req->attributes, req->owned )))
     {
-        reply->handle = alloc_handle( current->process, mutex, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, mutex, req->access, req->attributes );
         release_object( mutex );
     }
 
@@ -206,8 +205,7 @@ DECL_HANDLER(open_mutex)
 
     if ((mutex = open_object_dir( root, &name, req->attributes, &mutex_ops )))
     {
-        reply->handle = alloc_handle( current->process, &mutex->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &mutex->obj, req->access, req->attributes );
         release_object( mutex );
     }
 
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 2917d7b69e2..bda6bd9d671 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -679,8 +679,7 @@ DECL_HANDLER(create_named_pipe)
     server = create_pipe_server( pipe, req->options );
     if (server)
     {
-        reply->handle = alloc_handle( current->process, server,
-                                      req->access, req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, server, req->access, req->attributes );
         server->pipe->instances++;
         release_object( server );
     }
@@ -745,8 +744,7 @@ DECL_HANDLER(open_named_pipe)
                 server->state = ps_connected_server;
                 server->client = client;
                 client->server = server;
-                reply->handle = alloc_handle( current->process, client,
-                                              req->access, req->attributes & OBJ_INHERIT );
+                reply->handle = alloc_handle( current->process, client, req->access, req->attributes );
             }
         }
         else
diff --git a/server/process.c b/server/process.c
index 401c1ec9bd3..3f7daf37d53 100644
--- a/server/process.c
+++ b/server/process.c
@@ -892,7 +892,7 @@ DECL_HANDLER(new_process)
         goto done;
 
     if (!(info->data = memdup( get_req_data(), info->data_size ))) goto done;
-    reply->info = alloc_handle( current->process, info, SYNCHRONIZE, FALSE );
+    reply->info = alloc_handle( current->process, info, SYNCHRONIZE, 0 );
 
  done:
     release_object( info );
@@ -909,9 +909,9 @@ DECL_HANDLER(get_new_process_info)
         reply->pid = get_process_id( info->process );
         reply->tid = get_thread_id( info->thread );
         reply->phandle = alloc_handle( current->process, info->process,
-                                       req->process_access, req->process_attr & OBJ_INHERIT );
+                                       req->process_access, req->process_attr );
         reply->thandle = alloc_handle( current->process, info->thread,
-                                       req->thread_access, req->thread_attr & OBJ_INHERIT );
+                                       req->thread_access, req->thread_attr );
         reply->success = is_process_init_done( info->process );
         release_object( info );
     }
@@ -943,11 +943,11 @@ DECL_HANDLER(get_startup_info)
     {
         struct process *parent_process = info->owner->process;
         reply->hstdin  = duplicate_handle( parent_process, info->hstdin, process,
-                                           0, TRUE, DUPLICATE_SAME_ACCESS );
+                                           0, OBJ_INHERIT, DUPLICATE_SAME_ACCESS );
         reply->hstdout = duplicate_handle( parent_process, info->hstdout, process,
-                                           0, TRUE, DUPLICATE_SAME_ACCESS );
+                                           0, OBJ_INHERIT, DUPLICATE_SAME_ACCESS );
         reply->hstderr = duplicate_handle( parent_process, info->hstderr, process,
-                                           0, TRUE, DUPLICATE_SAME_ACCESS );
+                                           0, OBJ_INHERIT, DUPLICATE_SAME_ACCESS );
         /* some handles above may have been invalid; this is not an error */
         if (get_error() == STATUS_INVALID_HANDLE ||
             get_error() == STATUS_OBJECT_TYPE_MISMATCH) clear_error();
@@ -1009,8 +1009,7 @@ DECL_HANDLER(open_process)
     reply->handle = 0;
     if (process)
     {
-        reply->handle = alloc_handle( current->process, process, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, process, req->access, req->attributes );
         release_object( process );
     }
 }
diff --git a/server/semaphore.c b/server/semaphore.c
index 2dd6beb9e7b..d64bfbee96c 100644
--- a/server/semaphore.c
+++ b/server/semaphore.c
@@ -159,8 +159,7 @@ DECL_HANDLER(create_semaphore)
 
     if ((sem = create_semaphore( root, &name, req->attributes, req->initial, req->max )))
     {
-        reply->handle = alloc_handle( current->process, sem, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, sem, req->access, req->attributes );
         release_object( sem );
     }
 
@@ -180,8 +179,7 @@ DECL_HANDLER(open_semaphore)
 
     if ((sem = open_object_dir( root, &name, req->attributes, &semaphore_ops )))
     {
-        reply->handle = alloc_handle( current->process, &sem->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &sem->obj, req->access, req->attributes );
         release_object( sem );
     }
 
diff --git a/server/snapshot.c b/server/snapshot.c
index 4159962bb1a..1d2ec97f3fa 100644
--- a/server/snapshot.c
+++ b/server/snapshot.c
@@ -236,7 +236,7 @@ DECL_HANDLER(create_snapshot)
     reply->handle = 0;
     if ((snapshot = create_snapshot( req->pid, req->flags )))
     {
-        reply->handle = alloc_handle( current->process, snapshot, 0, req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, snapshot, 0, req->attributes );
         release_object( snapshot );
     }
 }
diff --git a/server/sock.c b/server/sock.c
index 6e2acbb1701..2cbd100ca2b 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -773,8 +773,7 @@ DECL_HANDLER(create_socket)
     reply->handle = 0;
     if ((obj = create_socket( req->family, req->type, req->protocol, req->flags )) != NULL)
     {
-        reply->handle = alloc_handle( current->process, obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
         release_object( obj );
     }
 }
@@ -787,8 +786,7 @@ DECL_HANDLER(accept_socket)
     reply->handle = 0;
     if ((sock = accept_socket( req->lhandle )) != NULL)
     {
-        reply->handle = alloc_handle( current->process, &sock->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &sock->obj, req->access, req->attributes );
         sock->wparam = reply->handle;  /* wparam for message is the socket handle */
         sock_reselect( sock );
         release_object( &sock->obj );
diff --git a/server/symlink.c b/server/symlink.c
index cf805a71c27..083da71853b 100644
--- a/server/symlink.c
+++ b/server/symlink.c
@@ -155,8 +155,7 @@ DECL_HANDLER(create_symlink)
 
     if ((symlink = create_symlink( root, &name, req->attributes, &target )))
     {
-        reply->handle = alloc_handle( current->process, symlink, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, symlink, req->access, req->attributes );
         release_object( symlink );
     }
 
@@ -176,8 +175,7 @@ DECL_HANDLER(open_symlink)
 
     if ((symlink = open_object_dir( root, &name, req->attributes | OBJ_OPENLINK, &symlink_ops )))
     {
-        reply->handle = alloc_handle( current->process, &symlink->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &symlink->obj, req->access, req->attributes );
         release_object( symlink );
     }
 
diff --git a/server/thread.c b/server/thread.c
index 51ef5ec9e06..705dc7bdc9a 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -828,8 +828,7 @@ DECL_HANDLER(new_thread)
     {
         if (req->suspend) thread->suspend++;
         reply->tid = get_thread_id( thread );
-        if ((reply->handle = alloc_handle( current->process, thread,
-                                           req->access, req->attributes & OBJ_INHERIT )))
+        if ((reply->handle = alloc_handle( current->process, thread, req->access, req->attributes )))
         {
             /* thread object will be released when the thread gets killed */
             return;
@@ -931,8 +930,7 @@ DECL_HANDLER(open_thread)
     reply->handle = 0;
     if (thread)
     {
-        reply->handle = alloc_handle( current->process, thread, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, thread, req->access, req->attributes );
         release_object( thread );
     }
 }
diff --git a/server/timer.c b/server/timer.c
index 436ed7cd3af..395bbda14f8 100644
--- a/server/timer.c
+++ b/server/timer.c
@@ -218,8 +218,7 @@ DECL_HANDLER(create_timer)
 
     if ((timer = create_timer( root, &name, req->attributes, req->manual )))
     {
-        reply->handle = alloc_handle( current->process, timer, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, timer, req->access, req->attributes );
         release_object( timer );
     }
 
@@ -239,8 +238,7 @@ DECL_HANDLER(open_timer)
 
     if ((timer = open_object_dir( root, &name, req->attributes, &timer_ops )))
     {
-        reply->handle = alloc_handle( current->process, &timer->obj, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, &timer->obj, req->access, req->attributes );
         release_object( timer );
     }
 
diff --git a/server/token.c b/server/token.c
index d10b9a19e08..3af72366618 100644
--- a/server/token.c
+++ b/server/token.c
@@ -884,7 +884,7 @@ DECL_HANDLER(open_token)
         {
             if (thread->token)
                 reply->token = alloc_handle( current->process, thread->token, req->access,
-                                             req->attributes & OBJ_INHERIT );
+                                             req->attributes );
             else
                 set_error(STATUS_NO_TOKEN);
             release_object( thread );
@@ -897,7 +897,7 @@ DECL_HANDLER(open_token)
         {
             if (process->token)
                 reply->token = alloc_handle( current->process, process->token, req->access,
-                                             req->attributes & OBJ_INHERIT );
+                                             req->attributes );
             else
                 set_error(STATUS_NO_TOKEN);
             release_object( process );
@@ -1017,8 +1017,7 @@ DECL_HANDLER(duplicate_token)
 
             access = req->access;
             if (access & MAXIMUM_ALLOWED) access = TOKEN_ALL_ACCESS; /* FIXME: needs general solution */
-            reply->new_handle = alloc_handle( current->process, token, access,
-                                              req->attributes & OBJ_INHERIT);
+            reply->new_handle = alloc_handle( current->process, token, access, req->attributes);
             release_object( token );
         }
         release_object( src_token );
diff --git a/server/winstation.c b/server/winstation.c
index 0f7b85d753b..efacdf31afa 100644
--- a/server/winstation.c
+++ b/server/winstation.c
@@ -268,7 +268,7 @@ void connect_process_winstation( struct process *process, const struct unicode_s
     }
     if (winstation)
     {
-        process->winstation = alloc_handle( process, winstation, WINSTA_ALL_ACCESS, FALSE );
+        process->winstation = alloc_handle( process, winstation, WINSTA_ALL_ACCESS, 0 );
         release_object( winstation );
     }
     clear_error();  /* ignore errors */
@@ -290,7 +290,7 @@ void connect_process_desktop( struct process *process, const struct unicode_str
         if (!name) name = &default_str;
         if ((desktop = create_desktop( name, OBJ_CASE_INSENSITIVE | OBJ_OPENIF, 0, winstation )))
         {
-            process->desktop = alloc_handle( process, desktop, DESKTOP_ALL_ACCESS, FALSE );
+            process->desktop = alloc_handle( process, desktop, DESKTOP_ALL_ACCESS, 0 );
             release_object( desktop );
         }
         release_object( winstation );
@@ -319,8 +319,7 @@ DECL_HANDLER(create_winstation)
     get_req_unicode_str( &name );
     if ((winstation = create_winstation( &name, req->attributes, req->flags )))
     {
-        reply->handle = alloc_handle( current->process, winstation, req->access,
-                                      req->attributes & OBJ_INHERIT );
+        reply->handle = alloc_handle( current->process, winstation, req->access, req->attributes );
         release_object( winstation );
     }
 }
@@ -387,8 +386,7 @@ DECL_HANDLER(create_desktop)
     {
         if ((desktop = create_desktop( &name, req->attributes, req->flags, winstation )))
         {
-            reply->handle = alloc_handle( current->process, desktop, req->access,
-                                          req->attributes & OBJ_INHERIT );
+            reply->handle = alloc_handle( current->process, desktop, req->access, req->attributes );
             release_object( desktop );
         }
         release_object( winstation );
-- 
GitLab