From 9bbf3ab96b30b79f1dd0b8723157b45f21c0d17c Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 14 Jun 2021 00:41:49 -0500 Subject: [PATCH] server: Implement IOCTL_AFD_EVENT_SELECT. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ntdll/unix/socket.c | 11 +++++++++ include/wine/afd.h | 19 ++++++++++++++ server/sock.c | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index c1cd319ccf9..088f29f85ff 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1170,6 +1170,17 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc break; } + case IOCTL_AFD_EVENT_SELECT: + { + const struct afd_event_select_params *params = in_buffer; + + TRACE( "event %p, mask %#x\n", params->event, params->mask ); + if (out_size) FIXME( "unexpected output size %u\n", out_size ); + + status = STATUS_BAD_DEVICE_TYPE; + break; + } + case IOCTL_AFD_RECV: { const struct afd_recv_params *params = in_buffer; diff --git a/include/wine/afd.h b/include/wine/afd.h index c4a15d6688c..2eb3e6f12a9 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -35,6 +35,7 @@ #define IOCTL_AFD_LISTEN CTL_CODE(FILE_DEVICE_BEEP, 0x802, METHOD_NEITHER, FILE_ANY_ACCESS) #define IOCTL_AFD_RECV CTL_CODE(FILE_DEVICE_BEEP, 0x805, METHOD_NEITHER, FILE_ANY_ACCESS) #define IOCTL_AFD_POLL CTL_CODE(FILE_DEVICE_BEEP, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_EVENT_SELECT CTL_CODE(FILE_DEVICE_BEEP, 0x821, METHOD_NEITHER, FILE_ANY_ACCESS) enum afd_poll_bit { @@ -106,6 +107,24 @@ struct afd_poll_params }; #include +struct afd_event_select_params +{ + HANDLE event; + int mask; +}; + +struct afd_event_select_params_64 +{ + ULONGLONG event; + int mask; +}; + +struct afd_event_select_params_32 +{ + ULONG event; + int mask; +}; + #define IOCTL_AFD_WINE_CREATE CTL_CODE(FILE_DEVICE_NETWORK, 200, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_ACCEPT CTL_CODE(FILE_DEVICE_NETWORK, 201, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_ACCEPT_INTO CTL_CODE(FILE_DEVICE_NETWORK, 202, METHOD_BUFFERED, FILE_ANY_ACCESS) diff --git a/server/sock.c b/server/sock.c index 026188e79af..3556ee21aa3 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2011,6 +2011,59 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) } return 1; + case IOCTL_AFD_EVENT_SELECT: + { + struct event *event = NULL; + obj_handle_t event_handle; + int mask; + + if (is_machine_64bit( current->process->machine )) + { + const struct afd_event_select_params_64 *params = get_req_data(); + + if (get_req_data_size() < sizeof(params)) + { + set_error( STATUS_INVALID_PARAMETER ); + return 1; + } + + event_handle = params->event; + mask = params->mask; + } + else + { + const struct afd_event_select_params_32 *params = get_req_data(); + + if (get_req_data_size() < sizeof(params)) + { + set_error( STATUS_INVALID_PARAMETER ); + return 1; + } + + event_handle = params->event; + mask = params->mask; + } + + if ((event_handle || mask) && + !(event = get_event_obj( current->process, event_handle, EVENT_MODIFY_STATE ))) + { + set_error( STATUS_INVALID_PARAMETER ); + return 1; + } + + if (sock->event) release_object( sock->event ); + sock->event = event; + sock->mask = mask; + sock->window = 0; + sock->message = 0; + sock->wparam = 0; + sock->nonblocking = 1; + + sock_reselect( sock ); + + return 1; + } + default: set_error( STATUS_NOT_SUPPORTED ); return 0;