Commit d30b5742 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Implemented EnumWindowStations and EnumDesktops.

parent 13e47d76
......@@ -204,13 +204,27 @@ BOOL WINAPI EnumWindowStationsA( WINSTAENUMPROCA func, LPARAM lparam )
/******************************************************************************
* EnumWindowStationsA (USER32.@)
* EnumWindowStationsW (USER32.@)
*/
BOOL WINAPI EnumWindowStationsW( WINSTAENUMPROCW func, LPARAM lparam )
{
FIXME( "(%p,%lx): stub\n", func, lparam );
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
unsigned int index = 0;
WCHAR name[MAX_PATH];
BOOL ret = TRUE;
while (ret)
{
SERVER_START_REQ( enum_winstation )
{
req->index = index;
wine_server_set_reply( req, name, sizeof(name) );
ret = !wine_server_call( req );
index = reply->next;
}
SERVER_END_REQ;
if (ret) ret = func( name, lparam );
}
return ret;
}
......@@ -384,9 +398,24 @@ BOOL WINAPI EnumDesktopsA( HWINSTA winsta, DESKTOPENUMPROCA func, LPARAM lparam
*/
BOOL WINAPI EnumDesktopsW( HWINSTA winsta, DESKTOPENUMPROCW func, LPARAM lparam )
{
FIXME( "(%p,%p,%lx): stub\n", winsta, func, lparam );
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
unsigned int index = 0;
WCHAR name[MAX_PATH];
BOOL ret = TRUE;
while (ret)
{
SERVER_START_REQ( enum_desktop )
{
req->winstation = winsta;
req->index = index;
wine_server_set_reply( req, name, sizeof(name) );
ret = !wine_server_call( req );
index = reply->next;
}
SERVER_END_REQ;
if (ret) ret = func( name, lparam );
}
return ret;
}
......
......@@ -3237,6 +3237,20 @@ struct set_process_winstation_reply
struct enum_winstation_request
{
struct request_header __header;
unsigned int index;
};
struct enum_winstation_reply
{
struct reply_header __header;
unsigned int next;
/* VARARG(name,unicode_str); */
};
struct create_desktop_request
{
struct request_header __header;
......@@ -3306,6 +3320,21 @@ struct set_thread_desktop_reply
struct enum_desktop_request
{
struct request_header __header;
obj_handle_t winstation;
unsigned int index;
};
struct enum_desktop_reply
{
struct reply_header __header;
unsigned int next;
/* VARARG(name,unicode_str); */
};
struct set_user_object_info_request
{
struct request_header __header;
......@@ -4376,11 +4405,13 @@ enum request
REQ_close_winstation,
REQ_get_process_winstation,
REQ_set_process_winstation,
REQ_enum_winstation,
REQ_create_desktop,
REQ_open_desktop,
REQ_close_desktop,
REQ_get_thread_desktop,
REQ_set_thread_desktop,
REQ_enum_desktop,
REQ_set_user_object_info,
REQ_attach_thread_input,
REQ_get_thread_input,
......@@ -4611,11 +4642,13 @@ union generic_request
struct close_winstation_request close_winstation_request;
struct get_process_winstation_request get_process_winstation_request;
struct set_process_winstation_request set_process_winstation_request;
struct enum_winstation_request enum_winstation_request;
struct create_desktop_request create_desktop_request;
struct open_desktop_request open_desktop_request;
struct close_desktop_request close_desktop_request;
struct get_thread_desktop_request get_thread_desktop_request;
struct set_thread_desktop_request set_thread_desktop_request;
struct enum_desktop_request enum_desktop_request;
struct set_user_object_info_request set_user_object_info_request;
struct attach_thread_input_request attach_thread_input_request;
struct get_thread_input_request get_thread_input_request;
......@@ -4844,11 +4877,13 @@ union generic_reply
struct close_winstation_reply close_winstation_reply;
struct get_process_winstation_reply get_process_winstation_reply;
struct set_process_winstation_reply set_process_winstation_reply;
struct enum_winstation_reply enum_winstation_reply;
struct create_desktop_reply create_desktop_reply;
struct open_desktop_reply open_desktop_reply;
struct close_desktop_reply close_desktop_reply;
struct get_thread_desktop_reply get_thread_desktop_reply;
struct set_thread_desktop_reply set_thread_desktop_reply;
struct enum_desktop_reply enum_desktop_reply;
struct set_user_object_info_reply set_user_object_info_reply;
struct attach_thread_input_reply attach_thread_input_reply;
struct get_thread_input_reply get_thread_input_reply;
......@@ -4906,6 +4941,6 @@ union generic_reply
struct add_fd_completion_reply add_fd_completion_reply;
};
#define SERVER_PROTOCOL_VERSION 332
#define SERVER_PROTOCOL_VERSION 333
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -446,6 +446,27 @@ obj_handle_t find_inherited_handle( struct process *process, const struct object
return 0;
}
/* enumerate handles of a given type */
/* this is needed for window stations and desktops */
obj_handle_t enumerate_handles( struct process *process, const struct object_ops *ops,
unsigned int *index )
{
struct handle_table *table = process->handles;
unsigned int i;
struct handle_entry *entry;
if (!table) return 0;
for (i = *index, entry = &table->entries[i]; i <= table->last; i++, entry++)
{
if (!entry->ptr) continue;
if (entry->ptr->ops != ops) continue;
*index = i + 1;
return index_to_handle(i);
}
return 0;
}
/* get/set the handle reserved flags */
/* return the old flags (or -1 on error) */
static int set_handle_flags( struct process *process, obj_handle_t handle, int mask, int flags )
......
......@@ -47,6 +47,8 @@ extern obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_hand
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 obj_handle_t enumerate_handles( struct process *process, const struct object_ops *ops,
unsigned int *index );
extern struct handle_table *alloc_handle_table( struct process *process, int count );
extern struct handle_table *copy_handle_table( struct process *process, struct process *parent );
extern unsigned int get_handle_table_count( struct process *process);
......
......@@ -2359,6 +2359,15 @@ enum message_type
@END
/* Enumerate window stations */
@REQ(enum_winstation)
unsigned int index; /* current index */
@REPLY
unsigned int next; /* next index */
VARARG(name,unicode_str); /* window station name */
@END
/* Create a desktop */
@REQ(create_desktop)
unsigned int flags; /* desktop flags */
......@@ -2401,6 +2410,16 @@ enum message_type
@END
/* Enumerate desktops */
@REQ(enum_desktop)
obj_handle_t winstation; /* handle to the window station */
unsigned int index; /* current index */
@REPLY
unsigned int next; /* next index */
VARARG(name,unicode_str); /* window station name */
@END
/* Get/set information about a user object (window station or desktop) */
@REQ(set_user_object_info)
obj_handle_t handle; /* handle to the object */
......
......@@ -278,11 +278,13 @@ DECL_HANDLER(open_winstation);
DECL_HANDLER(close_winstation);
DECL_HANDLER(get_process_winstation);
DECL_HANDLER(set_process_winstation);
DECL_HANDLER(enum_winstation);
DECL_HANDLER(create_desktop);
DECL_HANDLER(open_desktop);
DECL_HANDLER(close_desktop);
DECL_HANDLER(get_thread_desktop);
DECL_HANDLER(set_thread_desktop);
DECL_HANDLER(enum_desktop);
DECL_HANDLER(set_user_object_info);
DECL_HANDLER(attach_thread_input);
DECL_HANDLER(get_thread_input);
......@@ -512,11 +514,13 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_close_winstation,
(req_handler)req_get_process_winstation,
(req_handler)req_set_process_winstation,
(req_handler)req_enum_winstation,
(req_handler)req_create_desktop,
(req_handler)req_open_desktop,
(req_handler)req_close_desktop,
(req_handler)req_get_thread_desktop,
(req_handler)req_set_thread_desktop,
(req_handler)req_enum_desktop,
(req_handler)req_set_user_object_info,
(req_handler)req_attach_thread_input,
(req_handler)req_get_thread_input,
......
......@@ -2911,6 +2911,18 @@ static void dump_set_process_winstation_request( const struct set_process_winsta
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_enum_winstation_request( const struct enum_winstation_request *req )
{
fprintf( stderr, " index=%08x", req->index );
}
static void dump_enum_winstation_reply( const struct enum_winstation_reply *req )
{
fprintf( stderr, " next=%08x,", req->next );
fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size );
}
static void dump_create_desktop_request( const struct create_desktop_request *req )
{
fprintf( stderr, " flags=%08x,", req->flags );
......@@ -2959,6 +2971,19 @@ static void dump_set_thread_desktop_request( const struct set_thread_desktop_req
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_enum_desktop_request( const struct enum_desktop_request *req )
{
fprintf( stderr, " winstation=%p,", req->winstation );
fprintf( stderr, " index=%08x", req->index );
}
static void dump_enum_desktop_reply( const struct enum_desktop_reply *req )
{
fprintf( stderr, " next=%08x,", req->next );
fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size );
}
static void dump_set_user_object_info_request( const struct set_user_object_info_request *req )
{
fprintf( stderr, " handle=%p,", req->handle );
......@@ -3876,11 +3901,13 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_close_winstation_request,
(dump_func)dump_get_process_winstation_request,
(dump_func)dump_set_process_winstation_request,
(dump_func)dump_enum_winstation_request,
(dump_func)dump_create_desktop_request,
(dump_func)dump_open_desktop_request,
(dump_func)dump_close_desktop_request,
(dump_func)dump_get_thread_desktop_request,
(dump_func)dump_set_thread_desktop_request,
(dump_func)dump_enum_desktop_request,
(dump_func)dump_set_user_object_info_request,
(dump_func)dump_attach_thread_input_request,
(dump_func)dump_get_thread_input_request,
......@@ -4107,11 +4134,13 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)0,
(dump_func)dump_get_process_winstation_reply,
(dump_func)0,
(dump_func)dump_enum_winstation_reply,
(dump_func)dump_create_desktop_reply,
(dump_func)dump_open_desktop_reply,
(dump_func)0,
(dump_func)dump_get_thread_desktop_reply,
(dump_func)0,
(dump_func)dump_enum_desktop_reply,
(dump_func)dump_set_user_object_info_reply,
(dump_func)0,
(dump_func)dump_get_thread_input_reply,
......@@ -4338,11 +4367,13 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"close_winstation",
"get_process_winstation",
"set_process_winstation",
"enum_winstation",
"create_desktop",
"open_desktop",
"close_desktop",
"get_thread_desktop",
"set_thread_desktop",
"enum_desktop",
"set_user_object_info",
"attach_thread_input",
"get_thread_input",
......
......@@ -385,6 +385,20 @@ void close_thread_desktop( struct thread *thread )
clear_error(); /* ignore errors */
}
/* set the reply data from the object name */
static void set_reply_data_obj_name( struct object *obj )
{
data_size_t len;
const WCHAR *ptr, *name = get_object_name( obj, &len );
/* if there is a backslash return the part of the name after it */
if (name && (ptr = memchrW( name, '\\', len/sizeof(WCHAR) )))
{
len -= (ptr + 1 - name) * sizeof(WCHAR);
name = ptr + 1;
}
if (name) set_reply_data( name, min( len, get_reply_max_size() ));
}
/* create a window station */
DECL_HANDLER(create_winstation)
......@@ -590,18 +604,60 @@ DECL_HANDLER(set_user_object_info)
release_object( obj );
return;
}
if (get_reply_max_size())
if (get_reply_max_size()) set_reply_data_obj_name( obj );
release_object( obj );
}
/* enumerate window stations */
DECL_HANDLER(enum_winstation)
{
unsigned int index = req->index;
obj_handle_t handle;
struct object *obj;
while ((handle = enumerate_handles( current->process, &winstation_ops, &index )))
{
data_size_t len;
const WCHAR *ptr, *name = get_object_name( obj, &len );
if (!(obj = get_handle_obj( current->process, handle, WINSTA_ENUMERATE, &winstation_ops )))
continue;
set_reply_data_obj_name( obj );
release_object( obj );
clear_error();
reply->next = index;
return;
}
set_error( STATUS_NO_MORE_ENTRIES );
}
/* if there is a backslash return the part of the name after it */
if (name && (ptr = memchrW( name, '\\', len/sizeof(WCHAR) )))
/* enumerate desktops */
DECL_HANDLER(enum_desktop)
{
struct winstation *winstation;
struct desktop *desktop;
unsigned int index = req->index;
obj_handle_t handle;
if (!(winstation = (struct winstation *)get_handle_obj( current->process, req->winstation,
WINSTA_ENUMDESKTOPS, &winstation_ops )))
return;
while ((handle = enumerate_handles( current->process, &desktop_ops, &index )))
{
len -= (ptr + 1 - name) * sizeof(WCHAR);
name = ptr + 1;
if (!(desktop = get_desktop_obj( current->process, handle, DESKTOP_ENUMERATE )))
continue;
if (desktop->winstation == winstation)
{
set_reply_data_obj_name( &desktop->obj );
release_object( desktop );
clear_error();
reply->next = index;
return;
}
if (name) set_reply_data( name, min( len, get_reply_max_size() ));
release_object( desktop );
}
release_object( obj );
release_object( winstation );
set_error( STATUS_NO_MORE_ENTRIES );
}
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