server: Add console process list ioctl.

Signed-off-by: Roman Pišl <rpisl@seznam.cz>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Roman Pišl 2022-02-12 12:56:03 +01:00 committed by Alexandre Julliard
parent ac4dd0773f
commit 6559134702
2 changed files with 49 additions and 0 deletions

View File

@ -43,6 +43,7 @@
#define IOCTL_CONDRV_BEEP CTL_CODE(FILE_DEVICE_CONSOLE, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_CONDRV_FLUSH CTL_CODE(FILE_DEVICE_CONSOLE, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_CONDRV_GET_WINDOW CTL_CODE(FILE_DEVICE_CONSOLE, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_CONDRV_GET_PROCESS_LIST CTL_CODE(FILE_DEVICE_CONSOLE, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* console output ioctls */
#define IOCTL_CONDRV_WRITE_CONSOLE CTL_CODE(FILE_DEVICE_CONSOLE, 30, METHOD_BUFFERED, FILE_WRITE_ACCESS)

View File

@ -707,6 +707,27 @@ static void propagate_console_signal( struct console *console,
enum_processes(propagate_console_signal_cb, &csi);
}
struct console_process_list
{
unsigned int size;
unsigned int count;
process_id_t *processes;
struct console *console;
};
static int console_process_list_cb(struct process *process, void *user)
{
struct console_process_list *cpl = user;
if (process->console == cpl->console)
{
if (cpl->count < cpl->size) cpl->processes[cpl->count] = process->id;
cpl->count++;
}
return 0;
}
/* dumb dump */
static void console_dump( struct object *obj, int verbose )
{
@ -963,6 +984,33 @@ static void console_ioctl( struct fd *fd, ioctl_code_t code, struct async *async
return;
}
case IOCTL_CONDRV_GET_PROCESS_LIST:
{
struct console_process_list cpl;
if (get_reply_max_size() < sizeof(unsigned int))
{
set_error( STATUS_INVALID_PARAMETER );
return;
}
cpl.count = 0;
cpl.size = 0;
cpl.console = console;
enum_processes( console_process_list_cb, &cpl );
if (cpl.count * sizeof(process_id_t) > get_reply_max_size())
{
set_reply_data( &cpl.count, sizeof(cpl.count) );
set_error( STATUS_BUFFER_TOO_SMALL );
return;
}
cpl.size = cpl.count;
cpl.count = 0;
if ((cpl.processes = set_reply_data_size( cpl.size * sizeof(process_id_t) )))
enum_processes( console_process_list_cb, &cpl );
return;
}
default:
if (!console->server || code >> 16 != FILE_DEVICE_CONSOLE)
{