Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5295cc27
Commit
5295cc27
authored
Jun 16, 2021
by
Zebediah Figura
Committed by
Alexandre Julliard
Jun 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Pass a Win32 socket address to IOCTL_AFD_WINE_CONNECT.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f0b42b2f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
51 deletions
+24
-51
socket.c
dlls/ws2_32/socket.c
+9
-45
afd.h
include/wine/afd.h
+1
-1
sock.c
server/sock.c
+14
-5
No files found.
dlls/ws2_32/socket.c
View file @
5295cc27
...
@@ -1959,8 +1959,6 @@ int WINAPI WS_closesocket(SOCKET s)
...
@@ -1959,8 +1959,6 @@ int WINAPI WS_closesocket(SOCKET s)
*/
*/
int
WINAPI
WS_connect
(
SOCKET
s
,
const
struct
WS_sockaddr
*
addr
,
int
len
)
int
WINAPI
WS_connect
(
SOCKET
s
,
const
struct
WS_sockaddr
*
addr
,
int
len
)
{
{
union
generic_unix_sockaddr
uaddr
;
unsigned
int
uaddrlen
=
ws_sockaddr_ws2u
(
addr
,
len
,
&
uaddr
);
struct
afd_connect_params
*
params
;
struct
afd_connect_params
*
params
;
IO_STATUS_BLOCK
io
;
IO_STATUS_BLOCK
io
;
HANDLE
sync_event
;
HANDLE
sync_event
;
...
@@ -1968,35 +1966,19 @@ int WINAPI WS_connect( SOCKET s, const struct WS_sockaddr *addr, int len )
...
@@ -1968,35 +1966,19 @@ int WINAPI WS_connect( SOCKET s, const struct WS_sockaddr *addr, int len )
TRACE
(
"socket %#lx, addr %s, len %d
\n
"
,
s
,
debugstr_sockaddr
(
addr
),
len
);
TRACE
(
"socket %#lx, addr %s, len %d
\n
"
,
s
,
debugstr_sockaddr
(
addr
),
len
);
if
(
!
uaddrlen
)
{
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
if
(
addr
->
sa_family
==
WS_AF_INET
)
{
struct
sockaddr_in
*
in4
=
(
struct
sockaddr_in
*
)
&
uaddr
;
if
(
!
memcmp
(
&
in4
->
sin_addr
,
magic_loopback_addr
,
sizeof
(
magic_loopback_addr
)))
{
TRACE
(
"Replacing magic address 127.12.34.56 with INADDR_LOOPBACK.
\n
"
);
in4
->
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
}
}
if
(
!
(
sync_event
=
get_sync_event
()))
return
-
1
;
if
(
!
(
sync_event
=
get_sync_event
()))
return
-
1
;
if
(
!
(
params
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
params
)
+
uaddr
len
)))
if
(
!
(
params
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
params
)
+
len
)))
{
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
-
1
;
return
-
1
;
}
}
params
->
addr_len
=
uaddr
len
;
params
->
addr_len
=
len
;
params
->
synchronous
=
TRUE
;
params
->
synchronous
=
TRUE
;
memcpy
(
params
+
1
,
&
uaddr
,
uaddrlen
);
memcpy
(
params
+
1
,
addr
,
len
);
status
=
NtDeviceIoControlFile
(
(
HANDLE
)
s
,
sync_event
,
NULL
,
NULL
,
&
io
,
IOCTL_AFD_WINE_CONNECT
,
status
=
NtDeviceIoControlFile
(
(
HANDLE
)
s
,
sync_event
,
NULL
,
NULL
,
&
io
,
IOCTL_AFD_WINE_CONNECT
,
params
,
sizeof
(
*
params
)
+
uaddrlen
,
NULL
,
0
);
params
,
sizeof
(
*
params
)
+
len
,
NULL
,
0
);
HeapFree
(
GetProcessHeap
(),
0
,
params
);
HeapFree
(
GetProcessHeap
(),
0
,
params
);
if
(
status
==
STATUS_PENDING
)
if
(
status
==
STATUS_PENDING
)
{
{
...
@@ -2029,8 +2011,6 @@ int WINAPI WSAConnect( SOCKET s, const struct WS_sockaddr* name, int namelen,
...
@@ -2029,8 +2011,6 @@ int WINAPI WSAConnect( SOCKET s, const struct WS_sockaddr* name, int namelen,
static
BOOL
WINAPI
WS2_ConnectEx
(
SOCKET
s
,
const
struct
WS_sockaddr
*
name
,
int
namelen
,
static
BOOL
WINAPI
WS2_ConnectEx
(
SOCKET
s
,
const
struct
WS_sockaddr
*
name
,
int
namelen
,
void
*
send_buffer
,
DWORD
send_len
,
DWORD
*
ret_len
,
OVERLAPPED
*
overlapped
)
void
*
send_buffer
,
DWORD
send_len
,
DWORD
*
ret_len
,
OVERLAPPED
*
overlapped
)
{
{
union
generic_unix_sockaddr
uaddr
;
unsigned
int
uaddrlen
=
ws_sockaddr_ws2u
(
name
,
namelen
,
&
uaddr
);
struct
afd_connect_params
*
params
;
struct
afd_connect_params
*
params
;
void
*
cvalue
=
NULL
;
void
*
cvalue
=
NULL
;
NTSTATUS
status
;
NTSTATUS
status
;
...
@@ -2060,35 +2040,19 @@ static BOOL WINAPI WS2_ConnectEx( SOCKET s, const struct WS_sockaddr *name, int
...
@@ -2060,35 +2040,19 @@ static BOOL WINAPI WS2_ConnectEx( SOCKET s, const struct WS_sockaddr *name, int
overlapped
->
Internal
=
STATUS_PENDING
;
overlapped
->
Internal
=
STATUS_PENDING
;
overlapped
->
InternalHigh
=
0
;
overlapped
->
InternalHigh
=
0
;
if
(
!
uaddrlen
)
if
(
!
(
params
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
params
)
+
namelen
+
send_len
)))
{
SetLastError
(
WSAEFAULT
);
return
SOCKET_ERROR
;
}
if
(
name
->
sa_family
==
WS_AF_INET
)
{
struct
sockaddr_in
*
in4
=
(
struct
sockaddr_in
*
)
&
uaddr
;
if
(
!
memcmp
(
&
in4
->
sin_addr
,
magic_loopback_addr
,
sizeof
(
magic_loopback_addr
)
))
{
TRACE
(
"Replacing magic address 127.12.34.56 with INADDR_LOOPBACK.
\n
"
);
in4
->
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
}
}
if
(
!
(
params
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
params
)
+
uaddrlen
+
send_len
)))
{
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
SOCKET_ERROR
;
return
SOCKET_ERROR
;
}
}
params
->
addr_len
=
uaddr
len
;
params
->
addr_len
=
name
len
;
params
->
synchronous
=
FALSE
;
params
->
synchronous
=
FALSE
;
memcpy
(
params
+
1
,
&
uaddr
,
uaddr
len
);
memcpy
(
params
+
1
,
name
,
name
len
);
memcpy
(
(
char
*
)(
params
+
1
)
+
uaddr
len
,
send_buffer
,
send_len
);
memcpy
(
(
char
*
)(
params
+
1
)
+
name
len
,
send_buffer
,
send_len
);
status
=
NtDeviceIoControlFile
(
SOCKET2HANDLE
(
s
),
overlapped
->
hEvent
,
NULL
,
cvalue
,
status
=
NtDeviceIoControlFile
(
SOCKET2HANDLE
(
s
),
overlapped
->
hEvent
,
NULL
,
cvalue
,
(
IO_STATUS_BLOCK
*
)
overlapped
,
IOCTL_AFD_WINE_CONNECT
,
(
IO_STATUS_BLOCK
*
)
overlapped
,
IOCTL_AFD_WINE_CONNECT
,
params
,
sizeof
(
*
params
)
+
uaddr
len
+
send_len
,
NULL
,
0
);
params
,
sizeof
(
*
params
)
+
name
len
+
send_len
,
NULL
,
0
);
HeapFree
(
GetProcessHeap
(),
0
,
params
);
HeapFree
(
GetProcessHeap
(),
0
,
params
);
if
(
ret_len
)
*
ret_len
=
overlapped
->
InternalHigh
;
if
(
ret_len
)
*
ret_len
=
overlapped
->
InternalHigh
;
SetLastError
(
NtStatusToWSAError
(
status
)
);
SetLastError
(
NtStatusToWSAError
(
status
)
);
...
...
include/wine/afd.h
View file @
5295cc27
...
@@ -173,7 +173,7 @@ struct afd_connect_params
...
@@ -173,7 +173,7 @@ struct afd_connect_params
{
{
int
addr_len
;
int
addr_len
;
int
synchronous
;
int
synchronous
;
/* VARARG(addr, struct
sockaddr
, addr_len); */
/* VARARG(addr, struct
WS(sockaddr)
, addr_len); */
/* VARARG(data, bytes); */
/* VARARG(data, bytes); */
};
};
...
...
server/sock.c
View file @
5295cc27
...
@@ -109,6 +109,8 @@
...
@@ -109,6 +109,8 @@
#define IP_UNICAST_IF 50
#define IP_UNICAST_IF 50
#endif
#endif
static
const
char
magic_loopback_addr
[]
=
{
127
,
12
,
34
,
56
};
union
win_sockaddr
union
win_sockaddr
{
{
struct
WS_sockaddr
addr
;
struct
WS_sockaddr
addr
;
...
@@ -2109,8 +2111,8 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
...
@@ -2109,8 +2111,8 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
case
IOCTL_AFD_WINE_CONNECT
:
case
IOCTL_AFD_WINE_CONNECT
:
{
{
const
struct
afd_connect_params
*
params
=
get_req_data
();
const
struct
afd_connect_params
*
params
=
get_req_data
();
const
struct
WS_sockaddr
*
addr
;
union
unix_sockaddr
unix_addr
;
union
unix_sockaddr
unix_addr
;
const
struct
sockaddr
*
addr
;
struct
connect_req
*
req
;
struct
connect_req
*
req
;
socklen_t
unix_len
;
socklen_t
unix_len
;
int
send_len
,
ret
;
int
send_len
,
ret
;
...
@@ -2122,7 +2124,7 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
...
@@ -2122,7 +2124,7 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return
0
;
return
0
;
}
}
send_len
=
get_req_data_size
()
-
sizeof
(
*
params
)
-
params
->
addr_len
;
send_len
=
get_req_data_size
()
-
sizeof
(
*
params
)
-
params
->
addr_len
;
addr
=
(
const
struct
sockaddr
*
)(
params
+
1
);
addr
=
(
const
struct
WS_
sockaddr
*
)(
params
+
1
);
if
(
sock
->
accept_recv_req
)
if
(
sock
->
accept_recv_req
)
{
{
...
@@ -2144,7 +2146,16 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
...
@@ -2144,7 +2146,16 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return
0
;
return
0
;
}
}
ret
=
connect
(
unix_fd
,
addr
,
params
->
addr_len
);
unix_len
=
sockaddr_to_unix
(
addr
,
params
->
addr_len
,
&
unix_addr
);
if
(
!
unix_len
)
{
set_error
(
STATUS_INVALID_ADDRESS
);
return
0
;
}
if
(
unix_addr
.
addr
.
sa_family
==
AF_INET
&&
!
memcmp
(
&
unix_addr
.
in
.
sin_addr
,
magic_loopback_addr
,
4
))
unix_addr
.
in
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
ret
=
connect
(
unix_fd
,
&
unix_addr
.
addr
,
unix_len
);
if
(
ret
<
0
&&
errno
!=
EINPROGRESS
)
if
(
ret
<
0
&&
errno
!=
EINPROGRESS
)
{
{
set_error
(
sock_get_ntstatus
(
errno
)
);
set_error
(
sock_get_ntstatus
(
errno
)
);
...
@@ -2427,8 +2438,6 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
...
@@ -2427,8 +2438,6 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
if
(
unix_addr
.
addr
.
sa_family
==
WS_AF_INET
)
if
(
unix_addr
.
addr
.
sa_family
==
WS_AF_INET
)
{
{
static
const
char
magic_loopback_addr
[]
=
{
127
,
12
,
34
,
56
};
if
(
!
memcmp
(
&
unix_addr
.
in
.
sin_addr
,
magic_loopback_addr
,
4
)
if
(
!
memcmp
(
&
unix_addr
.
in
.
sin_addr
,
magic_loopback_addr
,
4
)
||
bind_to_interface
(
sock
,
&
unix_addr
.
in
))
||
bind_to_interface
(
sock
,
&
unix_addr
.
in
))
bind_addr
.
in
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
bind_addr
.
in
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment