Commit ead9b062 authored by Alexandre Julliard's avatar Alexandre Julliard

Added a struct unicode_str to encapsulate object names.

parent 6c4011e7
......@@ -227,7 +227,7 @@ static struct object *create_console_input( struct thread* renderer )
console_input->history_index = 0;
console_input->history_mode = 0;
console_input->edition_mode = 0;
console_input->event = create_event( NULL, 0, 0, 1, 0 );
console_input->event = create_event( NULL, 0, 1, 0 );
if (!console_input->history || !console_input->evt)
{
......
......@@ -59,12 +59,12 @@ static const struct object_ops event_ops =
};
struct event *create_event( const WCHAR *name, size_t len, unsigned int attr,
struct event *create_event( const struct unicode_str *name, unsigned int attr,
int manual_reset, int initial_state )
{
struct event *event;
if ((event = create_named_object( sync_namespace, &event_ops, name, len, attr )))
if ((event = create_named_object( sync_namespace, &event_ops, name, attr )))
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
{
......@@ -145,10 +145,11 @@ static int event_signal( struct object *obj, unsigned int access )
DECL_HANDLER(create_event)
{
struct event *event;
struct unicode_str name;
reply->handle = 0;
if ((event = create_event( get_req_data(), get_req_data_size(), req->attributes,
req->manual_reset, req->initial_state )))
get_req_unicode_str( &name );
if ((event = create_event( &name, req->attributes, req->manual_reset, req->initial_state )))
{
reply->handle = alloc_handle( current->process, event, req->access,
req->attributes & OBJ_INHERIT );
......@@ -159,8 +160,10 @@ DECL_HANDLER(create_event)
/* open a handle to an event */
DECL_HANDLER(open_event)
{
reply->handle = open_object( sync_namespace, get_req_data(), get_req_data_size(),
&event_ops, req->access, req->attributes );
struct unicode_str name;
get_req_unicode_str( &name );
reply->handle = open_object( sync_namespace, &name, &event_ops, req->access, req->attributes );
}
/* do an event operation */
......
......@@ -521,11 +521,11 @@ obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, str
}
/* open a new handle to an existing object */
obj_handle_t open_object( const struct namespace *namespace, const WCHAR *name, size_t len,
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 )
{
obj_handle_t handle = 0;
struct object *obj = find_object( namespace, name, len, attr );
struct object *obj = find_object( namespace, name, attr );
if (obj)
{
if (ops && obj->ops != ops)
......
......@@ -28,6 +28,7 @@
struct process;
struct object_ops;
struct namespace;
struct unicode_str;
/* handle functions */
......@@ -43,7 +44,7 @@ extern int get_handle_unix_fd( struct process *process, obj_handle_t handle, uns
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 );
extern obj_handle_t open_object( const struct namespace *namespace, const WCHAR *name, size_t len,
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 );
extern struct handle_table *alloc_handle_table( struct process *process, int count );
......
......@@ -213,20 +213,20 @@ static void mailslot_queue_async( struct fd *fd, void *apc, void *user,
fd_queue_async_timeout( fd, apc, user, iosb, type, count, timeout );
}
static struct mailslot *create_mailslot( const WCHAR *name, size_t len, unsigned int attr,
static struct mailslot *create_mailslot( const struct unicode_str *name, unsigned int attr,
int max_msgsize, int read_timeout )
{
struct mailslot *mailslot;
int fds[2];
static const WCHAR slot[] = {'m','a','i','l','s','l','o','t','\\',0};
static const WCHAR slot[] = {'m','a','i','l','s','l','o','t','\\'};
if (( len <= strlenW( slot )) || strncmpiW( slot, name, strlenW( slot ) ))
if ((name->len <= sizeof(slot)) || strncmpiW( slot, name->str, sizeof(slot)/sizeof(WCHAR) ))
{
set_error( STATUS_OBJECT_NAME_INVALID );
return NULL;
}
mailslot = create_named_object( sync_namespace, &mailslot_ops, name, len, attr );
mailslot = create_named_object( sync_namespace, &mailslot_ops, name, attr );
if (!mailslot)
return NULL;
......@@ -259,11 +259,11 @@ static struct mailslot *create_mailslot( const WCHAR *name, size_t len, unsigned
return NULL;
}
static struct mailslot *open_mailslot( const WCHAR *name, size_t len, unsigned int attr )
static struct mailslot *open_mailslot( const struct unicode_str *name, unsigned int attr )
{
struct object *obj;
obj = find_object( sync_namespace, name, len, attr );
obj = find_object( sync_namespace, name, attr );
if (obj)
{
if (obj->ops == &mailslot_ops)
......@@ -350,10 +350,11 @@ static struct mailslot *get_mailslot_obj( struct process *process, obj_handle_t
DECL_HANDLER(create_mailslot)
{
struct mailslot *mailslot;
struct unicode_str name;
reply->handle = 0;
mailslot = create_mailslot( get_req_data(), get_req_data_size(), req->attributes,
req->max_msgsize, req->read_timeout );
get_req_unicode_str( &name );
mailslot = create_mailslot( &name, req->attributes, req->max_msgsize, req->read_timeout );
if (mailslot)
{
reply->handle = alloc_handle( current->process, mailslot,
......@@ -367,8 +368,10 @@ DECL_HANDLER(create_mailslot)
DECL_HANDLER(open_mailslot)
{
struct mailslot *mailslot;
struct unicode_str name;
reply->handle = 0;
get_req_unicode_str( &name );
if (!(req->sharing & FILE_SHARE_READ))
{
......@@ -376,7 +379,7 @@ DECL_HANDLER(open_mailslot)
return;
}
mailslot = open_mailslot( get_req_data(), get_req_data_size(), req->attributes );
mailslot = open_mailslot( &name, req->attributes );
if (mailslot)
{
struct mail_writer *writer;
......
......@@ -270,7 +270,7 @@ inline static int get_file_size( struct file *file, file_pos_t *size )
return 1;
}
static struct object *create_mapping( const WCHAR *name, size_t len, unsigned int attr,
static struct object *create_mapping( const struct unicode_str *name, unsigned int attr,
file_pos_t size, int protect, obj_handle_t handle )
{
struct mapping *mapping;
......@@ -278,7 +278,7 @@ static struct object *create_mapping( const WCHAR *name, size_t len, unsigned in
if (!page_mask) init_page_size();
if (!(mapping = create_named_object( sync_namespace, &mapping_ops, name, len, attr )))
if (!(mapping = create_named_object( sync_namespace, &mapping_ops, name, attr )))
return NULL;
if (get_error() == STATUS_OBJECT_NAME_COLLISION)
return &mapping->obj; /* Nothing else to do */
......@@ -374,11 +374,12 @@ int get_page_size(void)
DECL_HANDLER(create_mapping)
{
struct object *obj;
struct unicode_str name;
file_pos_t size = ((file_pos_t)req->size_high << 32) | req->size_low;
reply->handle = 0;
if ((obj = create_mapping( get_req_data(), get_req_data_size(), req->attributes,
size, req->protect, req->file_handle )))
get_req_unicode_str( &name );
if ((obj = create_mapping( &name, req->attributes, size, req->protect, req->file_handle )))
{
reply->handle = alloc_handle( current->process, obj, req->access,
req->attributes & OBJ_INHERIT );
......@@ -389,8 +390,10 @@ DECL_HANDLER(create_mapping)
/* open a handle to a mapping */
DECL_HANDLER(open_mapping)
{
reply->handle = open_object( sync_namespace, get_req_data(), get_req_data_size(),
&mapping_ops, req->access, req->attributes );
struct unicode_str name;
get_req_unicode_str( &name );
reply->handle = open_object( sync_namespace, &name, &mapping_ops, req->access, req->attributes );
}
/* get a mapping information */
......
......@@ -62,12 +62,11 @@ static const struct object_ops mutex_ops =
};
static struct mutex *create_mutex( const WCHAR *name, size_t len, unsigned int attr,
int owned )
static struct mutex *create_mutex( const struct unicode_str *name, unsigned int attr, int owned )
{
struct mutex *mutex;
if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, len, attr )))
if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, attr )))
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
{
......@@ -171,10 +170,11 @@ static void mutex_destroy( struct object *obj )
DECL_HANDLER(create_mutex)
{
struct mutex *mutex;
struct unicode_str name;
reply->handle = 0;
if ((mutex = create_mutex( get_req_data(), get_req_data_size(), req->attributes,
req->owned )))
get_req_unicode_str( &name );
if ((mutex = create_mutex( &name, req->attributes, req->owned )))
{
reply->handle = alloc_handle( current->process, mutex, req->access,
req->attributes & OBJ_INHERIT );
......@@ -185,8 +185,10 @@ DECL_HANDLER(create_mutex)
/* open a handle to a mutex */
DECL_HANDLER(open_mutex)
{
reply->handle = open_object( sync_namespace, get_req_data(), get_req_data_size(),
&mutex_ops, req->access, req->attributes );
struct unicode_str name;
get_req_unicode_str( &name );
reply->handle = open_object( sync_namespace, &name, &mutex_ops, req->access, req->attributes );
}
/* release a mutex */
......
......@@ -397,7 +397,7 @@ static int pipe_server_flush( struct fd *fd, struct event **event )
/* this kind of sux -
there's no unix way to be alerted when a pipe becomes empty */
server->event = create_event( NULL, 0, 0, 0, 0 );
server->event = create_event( NULL, 0, 0, 0 );
if (!server->event)
return 0;
gettimeofday( &tv, NULL );
......@@ -440,11 +440,11 @@ static int pipe_client_get_info( struct fd *fd )
return flags;
}
static struct named_pipe *create_named_pipe( const WCHAR *name, size_t len, unsigned int attr )
static struct named_pipe *create_named_pipe( const struct unicode_str *name, unsigned int attr )
{
struct named_pipe *pipe;
pipe = create_named_object( sync_namespace, &named_pipe_ops, name, len, attr );
pipe = create_named_object( sync_namespace, &named_pipe_ops, name, attr );
if (pipe)
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
......@@ -458,11 +458,11 @@ static struct named_pipe *create_named_pipe( const WCHAR *name, size_t len, unsi
return pipe;
}
static struct named_pipe *open_named_pipe( const WCHAR *name, size_t len, unsigned int attr )
static struct named_pipe *open_named_pipe( const struct unicode_str *name, unsigned int attr )
{
struct object *obj;
if ((obj = find_object( sync_namespace, name, len, attr )))
if ((obj = find_object( sync_namespace, name, attr )))
{
if (obj->ops == &named_pipe_ops) return (struct named_pipe *)obj;
release_object( obj );
......@@ -546,11 +546,11 @@ DECL_HANDLER(create_named_pipe)
{
struct named_pipe *pipe;
struct pipe_server *server;
struct unicode_str name;
reply->handle = 0;
pipe = create_named_pipe( get_req_data(), get_req_data_size(), req->attributes );
if (!pipe)
return;
get_req_unicode_str( &name );
if (!(pipe = create_named_pipe( &name, req->attributes ))) return;
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
{
......@@ -595,11 +595,12 @@ DECL_HANDLER(open_named_pipe)
{
struct pipe_server *server;
struct pipe_client *client;
struct unicode_str name;
struct named_pipe *pipe;
int fds[2];
if (!(pipe = open_named_pipe( get_req_data(), get_req_data_size(), req->attributes )))
return;
get_req_unicode_str( &name );
if (!(pipe = open_named_pipe( &name, req->attributes ))) return;
server = find_server2( pipe, ps_idle_server, ps_wait_open );
release_object( pipe );
......@@ -692,8 +693,10 @@ DECL_HANDLER(wait_named_pipe)
{
struct named_pipe *pipe;
struct pipe_server *server;
struct unicode_str name;
if (!(pipe = open_named_pipe( get_req_data(), get_req_data_size(), OBJ_CASE_INSENSITIVE )))
get_req_unicode_str( &name );
if (!(pipe = open_named_pipe( &name, OBJ_CASE_INSENSITIVE )))
{
set_error( STATUS_PIPE_NOT_AVAILABLE );
return;
......
......@@ -98,14 +98,14 @@ static int get_name_hash( const struct namespace *namespace, const WCHAR *name,
}
/* allocate a name for an object */
static struct object_name *alloc_name( const WCHAR *name, size_t len )
static struct object_name *alloc_name( const struct unicode_str *name )
{
struct object_name *ptr;
if ((ptr = mem_alloc( sizeof(*ptr) + len - sizeof(ptr->name) )))
if ((ptr = mem_alloc( sizeof(*ptr) + name->len - sizeof(ptr->name) )))
{
ptr->len = len;
memcpy( ptr->name, name, len );
ptr->len = name->len;
memcpy( ptr->name, name->str, name->len );
}
return ptr;
}
......@@ -157,14 +157,14 @@ void *alloc_object( const struct object_ops *ops )
}
void *create_named_object( struct namespace *namespace, const struct object_ops *ops,
const WCHAR *name, size_t len, unsigned int attributes )
const struct unicode_str *name, unsigned int attributes )
{
struct object *obj;
struct object_name *name_ptr;
if (!name || !len) return alloc_object( ops );
if (!name || !name->len) return alloc_object( ops );
if ((obj = find_object( namespace, name, len, attributes )))
if ((obj = find_object( namespace, name, attributes )))
{
if (obj->ops != ops)
{
......@@ -174,7 +174,7 @@ void *create_named_object( struct namespace *namespace, const struct object_ops
set_error( STATUS_OBJECT_NAME_COLLISION );
return obj;
}
if (!(name_ptr = alloc_name( name, len ))) return NULL;
if (!(name_ptr = alloc_name( name ))) return NULL;
if ((obj = alloc_object( ops )))
{
set_object_name( namespace, obj, name_ptr );
......@@ -225,25 +225,27 @@ void release_object( void *ptr )
}
/* find an object by its name; the refcount is incremented */
struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len,
struct object *find_object( const struct namespace *namespace, const struct unicode_str *name,
unsigned int attributes )
{
const struct list *list, *p;
if (!name || !len) return NULL;
if (!name || !name->len) return NULL;
list = &namespace->names[ get_name_hash( namespace, name, len ) ];
list = &namespace->names[ get_name_hash( namespace, name->str, name->len ) ];
LIST_FOR_EACH( p, list )
{
const struct object_name *ptr = LIST_ENTRY( p, const struct object_name, entry );
if (ptr->len != len) continue;
if (ptr->len != name->len) continue;
if (attributes & OBJ_CASE_INSENSITIVE)
{
if (!strncmpiW( ptr->name, name, len/sizeof(WCHAR) )) return grab_object( ptr->obj );
if (!strncmpiW( ptr->name, name->str, name->len/sizeof(WCHAR) ))
return grab_object( ptr->obj );
}
else
{
if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj );
if (!memcmp( ptr->name, name->str, name->len ))
return grab_object( ptr->obj );
}
}
return NULL;
......
......@@ -88,19 +88,25 @@ struct wait_queue_entry
struct thread *thread;
};
struct unicode_str
{
const WCHAR *str;
size_t len;
};
extern void *mem_alloc( size_t size ); /* malloc wrapper */
extern void *memdup( const void *data, size_t len );
extern void *alloc_object( const struct object_ops *ops );
extern const WCHAR *get_object_name( struct object *obj, size_t *len );
extern void dump_object_name( struct object *obj );
extern void *create_named_object( struct namespace *namespace, const struct object_ops *ops,
const WCHAR *name, size_t len, unsigned int attributes );
const struct unicode_str *name, unsigned int attributes );
extern struct namespace *create_namespace( unsigned int hash_size );
/* grab/release_object can take any pointer, but you better make sure */
/* that the thing pointed to starts with a struct object... */
extern struct object *grab_object( void *obj );
extern void release_object( void *obj );
extern struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len,
extern struct object *find_object( const struct namespace *namespace, const struct unicode_str *name,
unsigned int attributes );
extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );
extern int no_satisfied( struct object *obj, struct thread *thread );
......@@ -116,7 +122,7 @@ extern void dump_objects(void);
struct event;
extern struct event *create_event( const WCHAR *name, size_t len, unsigned int attr,
extern struct event *create_event( const struct unicode_str *name, unsigned int attr,
int manual_reset, int initial_state );
extern struct event *get_event_obj( struct process *process, obj_handle_t handle, unsigned int access );
extern void pulse_event( struct event *event );
......
......@@ -338,8 +338,8 @@ size_t init_process( struct thread *thread )
}
/* connect to the window station and desktop */
connect_process_winstation( process, NULL, 0 );
connect_process_desktop( process, NULL, 0 );
connect_process_winstation( process, NULL );
connect_process_desktop( process, NULL );
thread->desktop = process->desktop;
if (!info) return 0;
......@@ -993,7 +993,7 @@ DECL_HANDLER(init_process_done)
generate_startup_debug_events( process, req->entry );
set_process_startup_state( process, STARTUP_DONE );
if (req->gui) process->idle_event = create_event( NULL, 0, 0, 1, 0 );
if (req->gui) process->idle_event = create_event( NULL, 0, 1, 0 );
if (current->suspend + process->suspend > 0) stop_thread( current );
if (process->debugger) set_process_debug_flag( process, 1 );
}
......
......@@ -77,6 +77,13 @@ inline static size_t get_req_data_size(void)
return current->req.request_header.request_size;
}
/* get the request vararg as unicode string */
inline static void get_req_unicode_str( struct unicode_str *str )
{
str->str = get_req_data();
str->len = (get_req_data_size() / sizeof(WCHAR)) * sizeof(WCHAR);
}
/* get the reply maximum vararg size */
inline static size_t get_reply_max_size(void)
{
......
......@@ -59,7 +59,7 @@ static const struct object_ops semaphore_ops =
};
static struct semaphore *create_semaphore( const WCHAR *name, size_t len, unsigned int attr,
static struct semaphore *create_semaphore( const struct unicode_str *name, unsigned int attr,
unsigned int initial, unsigned int max )
{
struct semaphore *sem;
......@@ -69,7 +69,7 @@ static struct semaphore *create_semaphore( const WCHAR *name, size_t len, unsign
set_error( STATUS_INVALID_PARAMETER );
return NULL;
}
if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, len, attr )))
if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, attr )))
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
{
......@@ -145,10 +145,11 @@ static int semaphore_signal( struct object *obj, unsigned int access )
DECL_HANDLER(create_semaphore)
{
struct semaphore *sem;
struct unicode_str name;
reply->handle = 0;
if ((sem = create_semaphore( get_req_data(), get_req_data_size(), req->attributes,
req->initial, req->max )))
get_req_unicode_str( &name );
if ((sem = create_semaphore( &name, req->attributes, req->initial, req->max )))
{
reply->handle = alloc_handle( current->process, sem, req->access,
req->attributes & OBJ_INHERIT );
......@@ -159,8 +160,10 @@ DECL_HANDLER(create_semaphore)
/* open a handle to a semaphore */
DECL_HANDLER(open_semaphore)
{
reply->handle = open_object( sync_namespace, get_req_data(), get_req_data_size(),
&semaphore_ops, req->access, req->attributes );
struct unicode_str name;
get_req_unicode_str( &name );
reply->handle = open_object( sync_namespace, &name, &semaphore_ops, req->access, req->attributes );
}
/* release a semaphore */
......
......@@ -68,12 +68,12 @@ static const struct object_ops timer_ops =
/* create a timer object */
static struct timer *create_timer( const WCHAR *name, size_t len, unsigned int attr,
static struct timer *create_timer( const struct unicode_str *name, unsigned int attr,
int manual )
{
struct timer *timer;
if ((timer = create_named_object( sync_namespace, &timer_ops, name, len, attr )))
if ((timer = create_named_object( sync_namespace, &timer_ops, name, attr )))
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
{
......@@ -204,9 +204,11 @@ static void timer_destroy( struct object *obj )
DECL_HANDLER(create_timer)
{
struct timer *timer;
struct unicode_str name;
reply->handle = 0;
if ((timer = create_timer( get_req_data(), get_req_data_size(), req->attributes, req->manual )))
get_req_unicode_str( &name );
if ((timer = create_timer( &name, req->attributes, req->manual )))
{
reply->handle = alloc_handle( current->process, timer, req->access,
req->attributes & OBJ_INHERIT );
......@@ -217,8 +219,10 @@ DECL_HANDLER(create_timer)
/* open a handle to a timer */
DECL_HANDLER(open_timer)
{
reply->handle = open_object( sync_namespace, get_req_data(), get_req_data_size(),
&timer_ops, req->access, req->attributes );
struct unicode_str name;
get_req_unicode_str( &name );
reply->handle = open_object( sync_namespace, &name, &timer_ops, req->access, req->attributes );
}
/* set a waitable timer */
......
......@@ -147,8 +147,8 @@ extern void *get_class_client_ptr( struct window_class *class );
extern struct winstation *get_process_winstation( struct process *process, unsigned int access );
extern struct desktop *get_thread_desktop( struct thread *thread, unsigned int access );
extern void connect_process_winstation( struct process *process, const WCHAR *name, size_t len );
extern void connect_process_desktop( struct process *process, const WCHAR *name, size_t len );
extern void connect_process_winstation( struct process *process, const struct unicode_str *name );
extern void connect_process_desktop( struct process *process, const struct unicode_str *name );
extern void close_thread_desktop( struct thread *thread );
#endif /* __WINE_SERVER_USER_H */
......@@ -80,20 +80,20 @@ static const struct object_ops desktop_ops =
#define DESKTOP_ALL_ACCESS 0x01ff
/* create a winstation object */
static struct winstation *create_winstation( const WCHAR *name, size_t len, unsigned int flags )
static struct winstation *create_winstation( const struct unicode_str *name, unsigned int flags )
{
struct winstation *winstation;
if (!winstation_namespace && !(winstation_namespace = create_namespace( 7 )))
return NULL;
if (memchrW( name, '\\', len / sizeof(WCHAR) )) /* no backslash allowed in name */
if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) )) /* no backslash allowed in name */
{
set_error( STATUS_INVALID_PARAMETER );
return NULL;
}
if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, len,
if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name,
OBJ_CASE_INSENSITIVE )))
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
......@@ -142,14 +142,14 @@ struct winstation *get_process_winstation( struct process *process, unsigned int
}
/* build the full name of a desktop object */
static WCHAR *build_desktop_name( const WCHAR *name, size_t len,
struct winstation *winstation, size_t *res_len )
static WCHAR *build_desktop_name( const struct unicode_str *name,
struct winstation *winstation, struct unicode_str *res )
{
const WCHAR *winstation_name;
WCHAR *full_name;
size_t winstation_len;
if (memchrW( name, '\\', len / sizeof(WCHAR) ))
if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) ))
{
set_error( STATUS_INVALID_PARAMETER );
return NULL;
......@@ -158,11 +158,12 @@ static WCHAR *build_desktop_name( const WCHAR *name, size_t len,
if (!(winstation_name = get_object_name( &winstation->obj, &winstation_len )))
winstation_len = 0;
*res_len = winstation_len + len + sizeof(WCHAR);
if (!(full_name = mem_alloc( *res_len ))) return NULL;
res->len = winstation_len + name->len + sizeof(WCHAR);
if (!(full_name = mem_alloc( res->len ))) return NULL;
memcpy( full_name, winstation_name, winstation_len );
full_name[winstation_len / sizeof(WCHAR)] = '\\';
memcpy( full_name + winstation_len / sizeof(WCHAR) + 1, name, len );
memcpy( full_name + winstation_len / sizeof(WCHAR) + 1, name->str, name->len );
res->str = full_name;
return full_name;
}
......@@ -174,16 +175,16 @@ inline static struct desktop *get_desktop_obj( struct process *process, obj_hand
}
/* create a desktop object */
static struct desktop *create_desktop( const WCHAR *name, size_t len, unsigned int flags,
static struct desktop *create_desktop( const struct unicode_str *name, unsigned int flags,
struct winstation *winstation )
{
struct desktop *desktop;
struct unicode_str full_str;
WCHAR *full_name;
size_t full_len;
if (!(full_name = build_desktop_name( name, len, winstation, &full_len ))) return NULL;
if (!(full_name = build_desktop_name( name, winstation, &full_str ))) return NULL;
if ((desktop = create_named_object( winstation_namespace, &desktop_ops, full_name, full_len,
if ((desktop = create_named_object( winstation_namespace, &desktop_ops, &full_str,
OBJ_CASE_INSENSITIVE )))
{
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
......@@ -238,7 +239,7 @@ struct desktop *get_thread_desktop( struct thread *thread, unsigned int access )
}
/* connect a process to its window station */
void connect_process_winstation( struct process *process, const WCHAR *name, size_t len )
void connect_process_winstation( struct process *process, const struct unicode_str *name )
{
struct winstation *winstation;
......@@ -249,14 +250,15 @@ void connect_process_winstation( struct process *process, const WCHAR *name, siz
if (name)
{
winstation = create_winstation( name, len, 0 );
winstation = create_winstation( name, 0 );
}
else
{
if (!interactive_winstation)
{
static const WCHAR winsta0W[] = {'W','i','n','S','t','a','0'};
interactive_winstation = create_winstation( winsta0W, sizeof(winsta0W), 0 );
static const struct unicode_str winsta0 = { winsta0W, sizeof(winsta0W) };
interactive_winstation = create_winstation( &winsta0, 0 );
winstation = interactive_winstation;
}
else winstation = (struct winstation *)grab_object( interactive_winstation );
......@@ -270,7 +272,7 @@ void connect_process_winstation( struct process *process, const WCHAR *name, siz
}
/* connect a process to its main desktop */
void connect_process_desktop( struct process *process, const WCHAR *name, size_t len )
void connect_process_desktop( struct process *process, const struct unicode_str *name )
{
struct desktop *desktop;
struct winstation *winstation;
......@@ -280,13 +282,10 @@ void connect_process_desktop( struct process *process, const WCHAR *name, size_t
if ((winstation = get_process_winstation( process, WINSTA_CREATEDESKTOP )))
{
static const WCHAR defaultW[] = {'D','e','f','a','u','l','t'};
static const struct unicode_str default_str = { defaultW, sizeof(defaultW) };
if (!name)
{
name = defaultW;
len = sizeof(defaultW);
}
if ((desktop = create_desktop( name, len, 0, winstation )))
if (!name) name = &default_str;
if ((desktop = create_desktop( name, 0, winstation )))
{
process->desktop = alloc_handle( process, desktop, DESKTOP_ALL_ACCESS, FALSE );
release_object( desktop );
......@@ -311,9 +310,11 @@ void close_thread_desktop( struct thread *thread )
DECL_HANDLER(create_winstation)
{
struct winstation *winstation;
struct unicode_str name;
reply->handle = 0;
if ((winstation = create_winstation( get_req_data(), get_req_data_size(), req->flags )))
get_req_unicode_str( &name );
if ((winstation = create_winstation( &name, req->flags )))
{
reply->handle = alloc_handle( current->process, winstation, req->access, req->inherit );
release_object( winstation );
......@@ -323,9 +324,11 @@ DECL_HANDLER(create_winstation)
/* open a handle to a window station */
DECL_HANDLER(open_winstation)
{
struct unicode_str name;
get_req_unicode_str( &name );
if (winstation_namespace)
reply->handle = open_object( winstation_namespace, get_req_data(), get_req_data_size(),
&winstation_ops, req->access,
reply->handle = open_object( winstation_namespace, &name, &winstation_ops, req->access,
OBJ_CASE_INSENSITIVE | (req->inherit ? OBJ_INHERIT:0) );
else
set_error( STATUS_OBJECT_NAME_NOT_FOUND );
......@@ -372,12 +375,13 @@ DECL_HANDLER(create_desktop)
{
struct desktop *desktop;
struct winstation *winstation;
struct unicode_str name;
reply->handle = 0;
get_req_unicode_str( &name );
if ((winstation = get_process_winstation( current->process, WINSTA_CREATEDESKTOP )))
{
if ((desktop = create_desktop( get_req_data(), get_req_data_size(),
req->flags, winstation )))
if ((desktop = create_desktop( &name, req->flags, winstation )))
{
reply->handle = alloc_handle( current->process, desktop, req->access, req->inherit );
release_object( desktop );
......@@ -390,17 +394,17 @@ DECL_HANDLER(create_desktop)
DECL_HANDLER(open_desktop)
{
struct winstation *winstation;
struct unicode_str name;
get_req_unicode_str( &name );
if ((winstation = get_process_winstation( current->process, 0 /* FIXME: access rights? */ )))
{
size_t full_len;
struct unicode_str full_str;
WCHAR *full_name;
if ((full_name = build_desktop_name( get_req_data(), get_req_data_size(),
winstation, &full_len )))
if ((full_name = build_desktop_name( &name, winstation, &full_str )))
{
reply->handle = open_object( winstation_namespace, full_name, full_len,
&desktop_ops, req->access,
reply->handle = open_object( winstation_namespace, &full_str, &desktop_ops, req->access,
OBJ_CASE_INSENSITIVE | (req->inherit ? OBJ_INHERIT:0) );
free( full_name );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment