ReactOS  0.4.14-dev-384-g5b37caa
dupsock.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for dupsock.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

INT WSAAPI WSADuplicateSocketA (IN SOCKET s, IN DWORD dwProcessId, OUT LPWSAPROTOCOL_INFOA lpProtocolInfo)
 
INT WSAAPI WSADuplicateSocketW (IN SOCKET s, IN DWORD dwProcessId, OUT LPWSAPROTOCOL_INFOW lpProtocolInfo)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file dupsock.c.

Function Documentation

◆ WSADuplicateSocketA()

INT WSAAPI WSADuplicateSocketA ( IN SOCKET  s,
IN DWORD  dwProcessId,
OUT LPWSAPROTOCOL_INFOA  lpProtocolInfo 
)

Definition at line 23 of file dupsock.c.

26 {
27  WSAPROTOCOL_INFOW ProtocolInfoW;
28  INT ErrorCode;
29  DPRINT("WSADuplicateSocketA: %lx, %lx, %p\n", s, dwProcessId, lpProtocolInfo);
30 
31  /* Call the Unicode Function */
32  ErrorCode = WSADuplicateSocketW(s, dwProcessId, &ProtocolInfoW);
33 
34  /* Check for success */
35  if (ErrorCode == ERROR_SUCCESS)
36  {
37  /* Convert Protocol Info to Ansi */
38  if (lpProtocolInfo)
39  {
40  /* Convert the information to ANSI */
41  ErrorCode = MapUnicodeProtocolInfoToAnsi(&ProtocolInfoW,
42  lpProtocolInfo);
43  }
44  else
45  {
46  /* Fail */
48  }
49 
50  /* Check if the conversion failed */
51  if (ErrorCode != ERROR_SUCCESS)
52  {
53  /* Set the last error and normalize the error */
56  }
57  }
58 
59  /* Return */
60  return ErrorCode;
61 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define WSAEFAULT
Definition: winerror.h:1945
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT
Definition: typedefs.h:56
void DPRINT(...)
Definition: polytest.cpp:61
#define SetLastError(x)
Definition: compat.h:417
INT WSAAPI WSADuplicateSocketW(IN SOCKET s, IN DWORD dwProcessId, OUT LPWSAPROTOCOL_INFOW lpProtocolInfo)
Definition: dupsock.c:68
GLdouble s
Definition: gl.h:2039
INT WSAAPI MapUnicodeProtocolInfoToAnsi(IN LPWSAPROTOCOL_INFOW UnicodeInfo, OUT LPWSAPROTOCOL_INFOA AnsiInfo)
Definition: wsautil.c:224

Referenced by test_completion_port(), test_WithWSAStartup(), and test_WSADuplicateSocket().

◆ WSADuplicateSocketW()

INT WSAAPI WSADuplicateSocketW ( IN SOCKET  s,
IN DWORD  dwProcessId,
OUT LPWSAPROTOCOL_INFOW  lpProtocolInfo 
)

Definition at line 68 of file dupsock.c.

71 {
72  PWSSOCKET Socket;
73  INT Status;
74  INT ErrorCode;
75  DPRINT("WSADuplicateSocketW: %lx, %lx, %p\n", s, dwProcessId, lpProtocolInfo);
76 
77  /* Check for WSAStartup */
79  {
80  /* Get the Socket Context */
81  if ((Socket = WsSockGetSocket(s)))
82  {
83  /* Make the call */
85  dwProcessId,
86  lpProtocolInfo,
87  &ErrorCode);
88  /* Deference the Socket Context */
89  WsSockDereference(Socket);
90 
91  /* Return Provider Value */
92  if (Status == ERROR_SUCCESS) return Status;
93 
94  /* If everything seemed fine, then the WSP call failed itself */
96  }
97  else
98  {
99  /* No Socket Context Found */
101  }
102  }
103 
104  /* Return with an Error */
106  return SOCKET_ERROR;
107 }
#define WSAENOTSOCK
Definition: winerror.h:1951
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140
LPWSPDUPLICATESOCKET lpWSPDuplicateSocket
Definition: ws2spi.h:469
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
void DPRINT(...)
Definition: polytest.cpp:61
PTPROVIDER Provider
Definition: ws2_32p.h:199
#define SetLastError(x)
Definition: compat.h:417
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
FORCEINLINE DWORD WsQuickProlog(VOID)
Definition: ws2_32p.h:892

Referenced by Test_CloseDuplicatedSocket(), Test_CloseWhileSelectDuplicatedSocket(), and WSADuplicateSocketA().