ReactOS  0.4.15-dev-494-g1d8c567
extensions.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS WinSock DLL
4  * FILE: stubs.c
5  * PURPOSE: WSAIoctl wrappers for Microsoft extensions to Winsock
6  * PROGRAMMERS: KJK::Hyperion <hackbunny@reactos.com>
7  * REVISIONS:
8  */
9 
10 #include "precomp.h"
11 
12 #include <winsock2.h>
13 #include <mswsock.h>
14 
15 LPFN_TRANSMITFILE pfnTransmitFile = NULL;
16 LPFN_GETACCEPTEXSOCKADDRS pfnGetAcceptExSockaddrs = NULL;
17 LPFN_ACCEPTEX pfnAcceptEx = NULL;
18 /*
19  * @implemented
20  */
21 BOOL
22 WINAPI
24  HANDLE File,
25  DWORD NumberOfBytesToWrite,
26  DWORD NumberOfBytesPerSend,
27  LPOVERLAPPED Overlapped,
28  LPTRANSMIT_FILE_BUFFERS TransmitBuffers,
29  DWORD Flags)
30 {
31  GUID TransmitFileGUID = WSAID_TRANSMITFILE;
32  DWORD cbBytesReturned;
33 
34  if (WSAIoctl(Socket,
36  &TransmitFileGUID,
37  sizeof(TransmitFileGUID),
39  sizeof(pfnTransmitFile),
40  &cbBytesReturned,
41  NULL,
42  NULL) == SOCKET_ERROR)
43  {
44  return FALSE;
45  }
46 
47  return pfnTransmitFile(Socket,
48  File,
49  NumberOfBytesToWrite,
50  NumberOfBytesPerSend,
51  Overlapped,
52  TransmitBuffers,
53  Flags);
54 }
55 
56 /*
57 * @implemented
58 */
59 BOOL
60 WINAPI
61 AcceptEx(SOCKET ListenSocket,
64  DWORD ReceiveDataLength,
65  DWORD LocalAddressLength,
66  DWORD RemoteAddressLength,
67  LPDWORD BytesReceived,
68  LPOVERLAPPED Overlapped)
69 {
70  GUID AcceptExGUID = WSAID_ACCEPTEX;
71  GUID GetAcceptExSockaddrsGUID = WSAID_GETACCEPTEXSOCKADDRS;
72  DWORD cbBytesReturned;
73 
74  if (WSAIoctl(ListenSocket,
76  &AcceptExGUID,
77  sizeof(AcceptExGUID),
78  &pfnAcceptEx,
79  sizeof(pfnAcceptEx),
80  &cbBytesReturned,
81  NULL,
82  NULL) == SOCKET_ERROR)
83  {
84  return FALSE;
85  }
86 
87  if (WSAIoctl(ListenSocket,
89  &GetAcceptExSockaddrsGUID,
90  sizeof(GetAcceptExSockaddrsGUID),
93  &cbBytesReturned,
94  NULL,
95  NULL) == SOCKET_ERROR)
96  {
97  pfnAcceptEx = NULL;
98  return FALSE;
99  }
100 
101  return pfnAcceptEx(ListenSocket,
102  AcceptSocket,
103  OutputBuffer,
104  ReceiveDataLength,
105  LocalAddressLength,
106  RemoteAddressLength,
107  BytesReceived,
108  Overlapped);
109 }
110 
111 
112 /*
113 * @implemented
114 */
115 VOID
116 WINAPI
118  DWORD ReceiveDataLength,
119  DWORD LocalAddressLength,
120  DWORD RemoteAddressLength,
125 {
127  {
129  ReceiveDataLength,
130  LocalAddressLength,
131  RemoteAddressLength,
136  }
137 }
138 /* EOF */
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_result_bytebuffer_ LocalSockaddrLength struct sockaddr ** LocalSockaddr
Definition: mswsock.h:114
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_result_bytebuffer_ LocalSockaddrLength struct sockaddr _Out_ LPINT LocalSockaddrLength
Definition: mswsock.h:114
VOID WINAPI GetAcceptExSockaddrs(PVOID OutputBuffer, DWORD ReceiveDataLength, DWORD LocalAddressLength, DWORD RemoteAddressLength, LPSOCKADDR *LocalSockaddr, LPINT LocalSockaddrLength, LPSOCKADDR *RemoteSockaddr, LPINT RemoteSockaddrLength)
Definition: extensions.c:117
BOOL WINAPI AcceptEx(SOCKET ListenSocket, SOCKET AcceptSocket, PVOID OutputBuffer, DWORD ReceiveDataLength, DWORD LocalAddressLength, DWORD RemoteAddressLength, LPDWORD BytesReceived, LPOVERLAPPED Overlapped)
Definition: extensions.c:61
#define SIO_GET_EXTENSION_FUNCTION_POINTER
Definition: ws2def.h:167
INT WSAAPI WSAIoctl(IN SOCKET s, IN DWORD dwIoControlCode, IN LPVOID lpvInBuffer, IN DWORD cbInBuffer, OUT LPVOID lpvOutBuffer, IN DWORD cbOutBuffer, OUT LPDWORD lpcbBytesReturned, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: ioctl.c:46
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_result_bytebuffer_ LocalSockaddrLength struct sockaddr _Out_ LPINT _Outptr_result_bytebuffer_ RemoteSockaddrLength struct sockaddr ** RemoteSockaddr
Definition: mswsock.h:116
#define WSAID_GETACCEPTEXSOCKADDRS
Definition: mswsock.h:77
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WSAID_TRANSMITFILE
Definition: mswsock.h:71
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
LPFN_ACCEPTEX pfnAcceptEx
Definition: extensions.c:17
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
LPFN_TRANSMITFILE pfnTransmitFile
Definition: extensions.c:15
LPFN_GETACCEPTEXSOCKADDRS pfnGetAcceptExSockaddrs
Definition: extensions.c:16
#define WSAID_ACCEPTEX
Definition: mswsock.h:74
BOOL WINAPI TransmitFile(SOCKET Socket, HANDLE File, DWORD NumberOfBytesToWrite, DWORD NumberOfBytesPerSend, LPOVERLAPPED Overlapped, LPTRANSMIT_FILE_BUFFERS TransmitBuffers, DWORD Flags)
Definition: extensions.c:23
uint32_t * LPDWORD
Definition: typedefs.h:58
UINT_PTR SOCKET
Definition: winsock.h:47
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_result_bytebuffer_ LocalSockaddrLength struct sockaddr _Out_ LPINT _Outptr_result_bytebuffer_ RemoteSockaddrLength struct sockaddr _Out_ LPINT RemoteSockaddrLength
Definition: mswsock.h:116
Definition: File.h:15
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _In_opt_ PWSK_SOCKET AcceptSocket
Definition: wsk.h:170
int * LPINT
Definition: windef.h:178