Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
083bf180
Commit
083bf180
authored
Jun 13, 2002
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authors: Peter Hunnisett <peter@transgaming.com>, Ove Kaaven <ovek@transgaming.com>
- check for sockaddr being NULL. - hackish implementation of WSADuplicateSocket.
parent
50e8768f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
8 deletions
+62
-8
socket.c
dlls/winsock/socket.c
+61
-7
ws2_32.spec
dlls/winsock/ws2_32.spec
+1
-1
No files found.
dlls/winsock/socket.c
View file @
083bf180
...
...
@@ -902,11 +902,19 @@ static const struct sockaddr* ws_sockaddr_ws2u(const struct WS_sockaddr* wsaddr,
return
NULL
;
}
/*
a
llocates a Unix sockaddr structure to receive the data */
/*
A
llocates a Unix sockaddr structure to receive the data */
inline
struct
sockaddr
*
ws_sockaddr_alloc
(
const
struct
WS_sockaddr
*
wsaddr
,
int
*
wsaddrlen
,
int
*
uaddrlen
)
{
if
(
wsaddr
==
NULL
)
return
NULL
;
{
ERR
(
"WINE shouldn't pass a NULL wsaddr! Attempting to continue
\n
"
);
/* This is not strictly the right thing to do. Hope it works however */
*
uaddrlen
=
0
;
return
NULL
;
}
if
(
*
wsaddrlen
==
0
)
*
uaddrlen
=
0
;
else
...
...
@@ -1640,12 +1648,21 @@ int WINAPI WSAConnect ( SOCKET s, const struct WS_sockaddr* name, int namelen,
*/
int
WINAPI
WS_getpeername
(
SOCKET
s
,
struct
WS_sockaddr
*
name
,
int
*
namelen
)
{
int
fd
=
_get_sock_fd
(
s
)
;
int
fd
;
int
res
;
TRACE
(
"socket: %04x, ptr %p, len %8x
\n
"
,
s
,
name
,
*
namelen
);
res
=
SOCKET_ERROR
;
/* Check if what we've received is valid. Should we use IsBadReadPtr? */
if
(
(
name
==
NULL
)
||
(
namelen
==
NULL
)
)
{
SetLastError
(
WSAEFAULT
);
return
SOCKET_ERROR
;
}
fd
=
_get_sock_fd
(
s
);
res
=
SOCKET_ERROR
;
if
(
fd
!=
-
1
)
{
struct
sockaddr
*
uaddr
;
...
...
@@ -1697,12 +1714,21 @@ INT16 WINAPI WINSOCK_getpeername16(SOCKET16 s, struct WS_sockaddr *name,
*/
int
WINAPI
WS_getsockname
(
SOCKET
s
,
struct
WS_sockaddr
*
name
,
int
*
namelen
)
{
int
fd
=
_get_sock_fd
(
s
)
;
int
fd
;
int
res
;
TRACE
(
"socket: %04x, ptr %p, len %8x
\n
"
,
s
,
name
,
*
namelen
);
res
=
SOCKET_ERROR
;
/* Check if what we've received is valid. Should we use IsBadReadPtr? */
if
(
(
name
==
NULL
)
||
(
namelen
==
NULL
)
)
{
SetLastError
(
WSAEFAULT
);
return
SOCKET_ERROR
;
}
fd
=
_get_sock_fd
(
s
);
res
=
SOCKET_ERROR
;
if
(
fd
!=
-
1
)
{
struct
sockaddr
*
uaddr
;
...
...
@@ -3337,6 +3363,13 @@ SOCKET WINAPI WSASocketA(int af, int type, int protocol,
TRACE
(
"af=%d type=%d protocol=%d protocol_info=%p group=%d flags=0x%lx
\n
"
,
af
,
type
,
protocol
,
lpProtocolInfo
,
g
,
dwFlags
);
/* hack for WSADuplicateSocket */
if
(
lpProtocolInfo
&&
lpProtocolInfo
->
dwServiceFlags4
==
0xff00ff00
)
{
ret
=
lpProtocolInfo
->
dwCatalogEntryId
;
TRACE
(
"
\t
got duplicate %04x
\n
"
,
ret
);
return
ret
;
}
/* check the socket family */
switch
(
af
)
{
...
...
@@ -4072,4 +4105,25 @@ int WINAPI WSAEnumProtocolsW(LPINT lpiProtocols, LPWSAPROTOCOL_INFOW lpProtocolB
return
0
;
}
/***********************************************************************
* WSADuplicateSocketA (WS2_32.32)
*/
int
WINAPI
WSADuplicateSocketA
(
SOCKET
s
,
DWORD
dwProcessId
,
LPWSAPROTOCOL_INFOA
lpProtocolInfo
)
{
HANDLE
hProcess
;
TRACE
(
"(%d,%lx,%p)
\n
"
,
s
,
dwProcessId
,
lpProtocolInfo
);
memset
(
lpProtocolInfo
,
0
,
sizeof
(
*
lpProtocolInfo
));
/* FIXME: WS_getsockopt(s, WS_SOL_SOCKET, SO_PROTOCOL_INFO, lpProtocolInfo, sizeof(*lpProtocolInfo)); */
/* I don't know what the real Windoze does next, this is a hack */
/* ...we could duplicate and then use ConvertToGlobalHandle on the duplicate, then let
* the target use the global duplicate, or we could copy a reference to us to the structure
* and let the target duplicate it from us, but let's do it as simple as possible */
hProcess
=
OpenProcess
(
PROCESS_DUP_HANDLE
,
FALSE
,
dwProcessId
);
DuplicateHandle
(
GetCurrentProcess
(),
s
,
hProcess
,
(
LPHANDLE
)
&
lpProtocolInfo
->
dwCatalogEntryId
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
);
CloseHandle
(
hProcess
);
lpProtocolInfo
->
dwServiceFlags4
=
0xff00ff00
;
/* magic */
return
0
;
}
dlls/winsock/ws2_32.spec
View file @
083bf180
...
...
@@ -37,7 +37,7 @@ init WS_LibMain
29 stdcall WSACloseEvent(long) WSACloseEvent
30 stdcall WSAConnect(long ptr long ptr ptr ptr ptr) WSAConnect
31 stdcall WSACreateEvent () WSACreateEvent
32 st
ub
WSADuplicateSocketA
32 st
dcall WSADuplicateSocketA(long long ptr)
WSADuplicateSocketA
33 stub WSADuplicateSocketW
34 stub WSAEnumNameSpaceProvidersA
35 stub WSAEnumNameSpaceProvidersW
...
...
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