server: Make alloc_handle use attributes instead of inherit flag.

This commit is contained in:
Alexandre Julliard 2005-12-09 13:58:25 +01:00
parent d02c4a1b82
commit 24560e70bb
21 changed files with 61 additions and 92 deletions

View File

@ -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 );
}
}

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -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 );
}
}

View File

@ -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 */

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -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

View File

@ -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 );
}
}

View File

@ -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 );
}

View File

@ -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 );
}
}

View File

@ -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 );

View File

@ -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 );
}

View File

@ -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 );
}
}

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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 );