Module: wine
Branch: master
Commit: 29334489795f0f3fbca52b65b7c5a002983a997b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=29334489795f0f3fbca52b65…
Author: Zebediah Figura <z.figura12(a)gmail.com>
Date: Sat Sep 19 17:13:36 2020 -0500
server: Introduce IOCTL_AFD_CREATE.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
include/wine/afd.h | 34 ++++++++++++++++++++++++++++++++++
server/sock.c | 19 ++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/include/wine/afd.h b/include/wine/afd.h
new file mode 100644
index 0000000000..41caaa7b4f
--- /dev/null
+++ b/include/wine/afd.h
@@ -0,0 +1,34 @@
+/*
+ * Socket driver ioctls
+ *
+ * Copyright 2020 Zebediah Figura for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_WINE_AFD_H
+#define __WINE_WINE_AFD_H
+
+#include <winioctl.h>
+
+#define IOCTL_AFD_CREATE CTL_CODE(FILE_DEVICE_NETWORK, 200, METHOD_BUFFERED, FILE_WRITE_ACCESS)
+
+struct afd_create_params
+{
+ int family, type, protocol;
+ unsigned int flags;
+};
+
+#endif
diff --git a/server/sock.c b/server/sock.c
index fd26c6c845..7148702165 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -58,6 +58,7 @@
#include "winerror.h"
#define USE_WS_PREFIX
#include "winsock2.h"
+#include "wine/afd.h"
#include "process.h"
#include "file.h"
@@ -133,6 +134,7 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
static void sock_queue_async( struct fd *fd, struct async *async, int type, int count );
static void sock_reselect_async( struct fd *fd, struct async_queue *queue );
+static int init_socket( struct sock *sock, int family, int type, int protocol, unsigned int flags );
static int sock_get_ntstatus( int err );
static unsigned int sock_get_error( int err );
@@ -542,10 +544,23 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
assert( sock->obj.ops == &sock_ops );
- if (get_unix_fd( fd ) == -1) return 0;
+ if (get_unix_fd( fd ) == -1 && code != IOCTL_AFD_CREATE) return 0;
switch(code)
{
+ case IOCTL_AFD_CREATE:
+ {
+ const struct afd_create_params *params = get_req_data();
+
+ if (get_req_data_size() != sizeof(*params))
+ {
+ set_error( STATUS_INVALID_PARAMETER );
+ return 0;
+ }
+ init_socket( sock, params->family, params->type, params->protocol, params->flags );
+ return 0;
+ }
+
case WS_SIO_ADDRESS_LIST_CHANGE:
if ((sock->state & FD_WINE_NONBLOCKING) && async_is_blocking( async ))
{
@@ -680,6 +695,8 @@ static int init_socket( struct sock *sock, int family, int type, int protocol, u
sock->type = type;
sock->family = family;
+ if (sock->fd) release_object( sock->fd );
+
if (!(sock->fd = create_anonymous_fd( &sock_fd_ops, sockfd, &sock->obj,
(flags & WSA_FLAG_OVERLAPPED) ? 0 : FILE_SYNCHRONOUS_IO_NONALERT )))
{