Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/unix/socket.c | 32 ++++++++++++++++++++------------ dlls/ws2_32/socket.c | 12 ++++++++++-- include/wine/afd.h | 10 +++++++--- 3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 676864744a3..20368ad6415 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -91,6 +91,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(winsock);
+#define u64_to_user_ptr(u) ((void *)(uintptr_t)(u)) + union unix_sockaddr { struct sockaddr addr; @@ -141,7 +143,10 @@ struct async_transmit_ioctl unsigned int tail_cursor; /* amount of tail data already sent */ unsigned int file_len; /* total file length to send */ DWORD flags; - TRANSMIT_FILE_BUFFERS buffers; + const char *head; + const char *tail; + unsigned int head_len; + unsigned int tail_len; LARGE_INTEGER offset; };
@@ -1088,11 +1093,11 @@ static NTSTATUS try_transmit( int sock_fd, int file_fd, struct async_transmit_io { ssize_t ret;
- while (async->head_cursor < async->buffers.HeadLength) + while (async->head_cursor < async->head_len) { - TRACE( "sending %u bytes of header data\n", async->buffers.HeadLength - async->head_cursor ); - ret = do_send( sock_fd, (char *)async->buffers.Head + async->head_cursor, - async->buffers.HeadLength - async->head_cursor, 0 ); + TRACE( "sending %u bytes of header data\n", async->head_len - async->head_cursor ); + ret = do_send( sock_fd, async->head + async->head_cursor, + async->head_len - async->head_cursor, 0 ); if (ret < 0) return sock_errno_to_status( errno ); TRACE( "send returned %zd\n", ret ); async->head_cursor += ret; @@ -1137,11 +1142,11 @@ static NTSTATUS try_transmit( int sock_fd, int file_fd, struct async_transmit_io return STATUS_DEVICE_NOT_READY; /* still more data to send */ }
- while (async->tail_cursor < async->buffers.TailLength) + while (async->tail_cursor < async->tail_len) { - TRACE( "sending %u bytes of tail data\n", async->buffers.TailLength - async->tail_cursor ); - ret = do_send( sock_fd, (char *)async->buffers.Tail + async->tail_cursor, - async->buffers.TailLength - async->tail_cursor, 0 ); + TRACE( "sending %u bytes of tail data\n", async->tail_len - async->tail_cursor ); + ret = do_send( sock_fd, async->tail + async->tail_cursor, + async->tail_len - async->tail_cursor, 0 ); if (ret < 0) return sock_errno_to_status( errno ); TRACE( "send returned %zd\n", ret ); async->tail_cursor += ret; @@ -1200,7 +1205,7 @@ static NTSTATUS sock_transmit( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc,
if (params->file) { - if ((status = server_get_unix_fd( params->file, 0, &file_fd, &file_needs_close, &file_type, NULL ))) + if ((status = server_get_unix_fd( ULongToHandle( params->file ), 0, &file_fd, &file_needs_close, &file_type, NULL ))) return status; if (file_needs_close) close( file_fd );
@@ -1214,7 +1219,7 @@ static NTSTATUS sock_transmit( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, if (!(async = (struct async_transmit_ioctl *)alloc_fileio( sizeof(*async), async_transmit_proc, handle ))) return STATUS_NO_MEMORY;
- async->file = params->file; + async->file = ULongToHandle( params->file ); async->buffer_size = params->buffer_size ? params->buffer_size : 65536; if (!(async->buffer = malloc( async->buffer_size ))) { @@ -1228,7 +1233,10 @@ static NTSTATUS sock_transmit( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, async->tail_cursor = 0; async->file_len = params->file_len; async->flags = params->flags; - async->buffers = params->buffers; + async->head = u64_to_user_ptr(params->head_ptr); + async->head_len = params->head_len; + async->tail = u64_to_user_ptr(params->tail_ptr); + async->tail_len = params->tail_len; async->offset = params->offset;
SERVER_START_REQ( send_socket ) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index fb8ae1b2cce..3a5b77e32e6 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -35,6 +35,8 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
#define TIMEOUT_INFINITE _I64_MAX
+#define u64_from_user_ptr(ptr) ((ULONGLONG)(uintptr_t)(ptr)) + static const WSAPROTOCOL_INFOW supported_protocols[] = { { @@ -842,10 +844,16 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE file, DWORD file_len, DWOR params.offset.QuadPart = FILE_USE_FILE_POINTER_POSITION; }
- params.file = file; + params.file = HandleToULong( file ); params.file_len = file_len; params.buffer_size = buffer_size; - if (buffers) params.buffers = *buffers; + if (buffers) + { + params.head_ptr = u64_from_user_ptr(buffers->Head); + params.head_len = buffers->HeadLength; + params.tail_ptr = u64_from_user_ptr(buffers->Tail); + params.tail_len = buffers->TailLength; + } params.flags = flags;
status = NtDeviceIoControlFile( (HANDLE)s, event, NULL, cvalue, piosb, diff --git a/include/wine/afd.h b/include/wine/afd.h index ee67e255dd0..97128c67ca6 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -310,13 +310,17 @@ C_ASSERT( sizeof(struct afd_sendmsg_params) == 32 );
struct afd_transmit_params { - HANDLE file; + LARGE_INTEGER offset; + ULONGLONG head_ptr; + ULONGLONG tail_ptr; + DWORD head_len; + DWORD tail_len; + ULONG file; DWORD file_len; DWORD buffer_size; - LARGE_INTEGER offset; - TRANSMIT_FILE_BUFFERS buffers; DWORD flags; }; +C_ASSERT( sizeof(struct afd_transmit_params) == 48 );
struct afd_message_select_params {