ReactOS 0.4.16-dev-297-gc569aee
msafdlib.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SOCK_SHARED_INFO
 
struct  _HELPER_DATA
 
struct  _ASYNC_DATA
 
struct  _SOCKET_INFORMATION
 
struct  _SOCKET_CONTEXT
 
struct  _SOCK_RW_LOCK
 
struct  _WINSOCK_TEB_DATA
 
struct  _SOCK_ICF_DATA
 

Macros

#define NO_BLOCKING_HOOK   0
 
#define MAYBE_BLOCKING_HOOK   1
 
#define ALWAYS_BLOCKING_HOOK   2
 
#define NO_TIMEOUT   0
 
#define SEND_TIMEOUT   1
 
#define RECV_TIMEOUT   2
 
#define MAX_TDI_ADDRESS_LENGTH   32
 
#define WSA_FLAG_MULTIPOINT_ALL
 
#define MSAFD_IS_DGRAM_SOCK(s)    (s->SharedData.ServiceFlags1 & XP1_CONNECTIONLESS)
 

Typedefs

typedef enum _SOCKET_STATE SOCKET_STATE
 
typedef enum _SOCKET_STATEPSOCKET_STATE
 
typedef struct _SOCK_SHARED_INFO SOCK_SHARED_INFO
 
typedef struct _SOCK_SHARED_INFOPSOCK_SHARED_INFO
 
typedef struct _HELPER_DATA HELPER_DATA
 
typedef struct _HELPER_DATAPHELPER_DATA
 
typedef struct _ASYNC_DATA ASYNC_DATA
 
typedef struct _ASYNC_DATAPASYNC_DATA
 
typedef struct _SOCKET_INFORMATION SOCKET_INFORMATION
 
typedef struct _SOCKET_INFORMATIONPSOCKET_INFORMATION
 
typedef struct _SOCKET_CONTEXT SOCKET_CONTEXT
 
typedef struct _SOCKET_CONTEXTPSOCKET_CONTEXT
 
typedef struct _SOCK_RW_LOCK SOCK_RW_LOCK
 
typedef struct _SOCK_RW_LOCKPSOCK_RW_LOCK
 
typedef struct _WINSOCK_TEB_DATA WINSOCK_TEB_DATA
 
typedef struct _WINSOCK_TEB_DATAPWINSOCK_TEB_DATA
 
typedef INT(WINAPIPICF_CONNECT) (PVOID IcfData)
 
typedef struct _SOCK_ICF_DATA SOCK_ICF_DATA
 
typedef struct _SOCK_ICF_DATAPSOCK_ICF_DATA
 
typedef PVOID(NTAPIPRTL_HEAP_ALLOCATE) (IN HANDLE Heap, IN ULONG Flags, IN ULONG Size)
 
typedef VOID(WSPAPIPASYNC_COMPLETION_ROUTINE) (PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
 

Enumerations

enum  _SOCKET_STATE {
  SocketOpen , SocketBound , SocketBoundUdp , SocketConnected ,
  SocketClosed , SocketStateCreated , SocketStateBound , SocketStateListening ,
  SocketStateConnected , SocketUndefined = -1 , SocketOpen , SocketBound ,
  SocketBoundUdp , SocketConnected , SocketClosed
}
 

Functions

BOOL WSPAPI MSWSOCK_Initialize (VOID)
 
BOOL WSPAPI MSAFD_SockThreadInitialize (VOID)
 
INT WSPAPI SockCreateAsyncQueuePort (VOID)
 
PVOID WSPAPI SockInitializeHeap (IN HANDLE Heap, IN ULONG Flags, IN ULONG Size)
 
NTSTATUS WSPAPI SockInitializeRwLockAndSpinCount (IN PSOCK_RW_LOCK Lock, IN ULONG SpinCount)
 
VOID WSPAPI SockAcquireRwLockExclusive (IN PSOCK_RW_LOCK Lock)
 
VOID WSPAPI SockAcquireRwLockShared (IN PSOCK_RW_LOCK Lock)
 
VOID WSPAPI SockReleaseRwLockExclusive (IN PSOCK_RW_LOCK Lock)
 
VOID WSPAPI SockReleaseRwLockShared (IN PSOCK_RW_LOCK Lock)
 
NTSTATUS WSPAPI SockDeleteRwLock (IN PSOCK_RW_LOCK Lock)
 
INT WSPAPI SockGetConnectData (IN PSOCKET_INFORMATION Socket, IN ULONG Ioctl, IN PVOID Buffer, IN ULONG BufferLength, OUT PULONG BufferReturned)
 
INT WSPAPI SockIsAddressConsistentWithConstrainedGroup (IN PSOCKET_INFORMATION Socket, IN GROUP Group, IN PSOCKADDR SocketAddress, IN INT SocketAddressLength)
 
BOOL WSPAPI SockWaitForSingleObject (IN HANDLE Handle, IN SOCKET SocketHandle, IN DWORD BlockingFlags, IN DWORD TimeoutFlags)
 
BOOLEAN WSPAPI SockIsSocketConnected (IN PSOCKET_INFORMATION Socket)
 
INT WSPAPI SockNotifyHelperDll (IN PSOCKET_INFORMATION Socket, IN DWORD Event)
 
INT WSPAPI SockUpdateWindowSizes (IN PSOCKET_INFORMATION Socket, IN BOOLEAN Force)
 
INT WSPAPI SockBuildTdiAddress (OUT PTRANSPORT_ADDRESS TdiAddress, IN PSOCKADDR Sockaddr, IN INT SockaddrLength)
 
INT WSPAPI SockBuildSockaddr (OUT PSOCKADDR Sockaddr, OUT PINT SockaddrLength, IN PTRANSPORT_ADDRESS TdiAddress)
 
INT WSPAPI SockGetTdiHandles (IN PSOCKET_INFORMATION Socket)
 
VOID WSPAPI SockIoCompletion (IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, DWORD Reserved)
 
VOID WSPAPI SockCancelIo (IN SOCKET Handle)
 
INT WSPAPI SockGetInformation (IN PSOCKET_INFORMATION Socket, IN ULONG AfdInformationClass, IN PVOID ExtraData OPTIONAL, IN ULONG ExtraDataSize, IN OUT PBOOLEAN Boolean OPTIONAL, IN OUT PULONG Ulong OPTIONAL, IN OUT PLARGE_INTEGER LargeInteger OPTIONAL)
 
INT WSPAPI SockSetInformation (IN PSOCKET_INFORMATION Socket, IN ULONG AfdInformationClass, IN PBOOLEAN Boolean OPTIONAL, IN PULONG Ulong OPTIONAL, IN PLARGE_INTEGER LargeInteger OPTIONAL)
 
INT WSPAPI SockSetHandleContext (IN PSOCKET_INFORMATION Socket)
 
VOID WSPAPI SockDereferenceSocket (IN PSOCKET_INFORMATION Socket)
 
VOID WSPAPI SockFreeHelperDll (IN PHELPER_DATA Helper)
 
PSOCKET_INFORMATION WSPAPI SockFindAndReferenceSocket (IN SOCKET Handle, IN BOOLEAN Import)
 
INT WSPAPI SockEnterApiSlow (OUT PWINSOCK_TEB_DATA *ThreadData)
 
VOID WSPAPI SockSanInitialize (VOID)
 
VOID WSPAPI SockSanGetTcpipCatalogId (VOID)
 
VOID WSPAPI CloseIcfConnection (IN PSOCK_ICF_DATA IcfData)
 
VOID WSPAPI InitializeIcfConnection (IN PSOCK_ICF_DATA IcfData)
 
VOID WSPAPI NewIcfConnection (IN PSOCK_ICF_DATA IcfData)
 
INT WSPAPI NtStatusToSocketError (IN NTSTATUS Status)
 
INT WSPAPI SockSocket (INT AddressFamily, INT SocketType, INT Protocol, LPGUID ProviderId, GROUP g, DWORD dwFlags, DWORD ProviderFlags, DWORD ServiceFlags, DWORD CatalogEntryId, PSOCKET_INFORMATION *NewSocket)
 
INT WSPAPI SockCloseSocket (IN PSOCKET_INFORMATION Socket)
 
FORCEINLINE INT WSPAPI SockEnterApiFast (OUT PWINSOCK_TEB_DATA *ThreadData)
 
FORCEINLINE VOID WSPAPI SockDereferenceHelperDll (IN PHELPER_DATA Helper)
 
INT WSPAPI SockLoadHelperDll (PWSTR TransportName, PWINSOCK_MAPPING Mapping, PHELPER_DATA *HelperDllData)
 
INT WSPAPI SockLoadTransportMapping (PWSTR TransportName, PWINSOCK_MAPPING *Mapping)
 
INT WSPAPI SockLoadTransportList (PWSTR *TransportList)
 
BOOL WSPAPI SockIsTripleInMapping (IN PWINSOCK_MAPPING Mapping, IN INT AddressFamily, OUT PBOOLEAN AfMatch, IN INT SocketType, OUT PBOOLEAN SockMatch, IN INT Protocol, OUT PBOOLEAN ProtoMatch)
 
INT WSPAPI SockAsyncSelectHelper (IN PSOCKET_INFORMATION Socket, IN HWND hWnd, IN UINT wMsg, IN LONG Events)
 
INT WSPAPI SockEventSelectHelper (IN PSOCKET_INFORMATION Socket, IN WSAEVENT EventObject, IN LONG Events)
 
BOOLEAN WSPAPI SockCheckAndReferenceAsyncThread (VOID)
 
BOOLEAN WSPAPI SockCheckAndInitAsyncSelectHelper (VOID)
 
INT WSPAPI SockGetTdiName (PINT AddressFamily, PINT SocketType, PINT Protocol, LPGUID ProviderId, GROUP Group, DWORD Flags, PUNICODE_STRING TransportName, PVOID *HelperDllContext, PHELPER_DATA *HelperDllData, PDWORD Events)
 
INT WSPAPI SockAsyncThread (PVOID ThreadParam)
 
VOID WSPAPI SockProcessAsyncSelect (PSOCKET_INFORMATION Socket, PASYNC_DATA AsyncData)
 
VOID WSPAPI SockHandleAsyncIndication (IN PASYNC_COMPLETION_ROUTINE Callback, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatusBlock)
 
INT WSPAPI SockReenableAsyncSelectEvent (IN PSOCKET_INFORMATION Socket, IN ULONG Event)
 
VOID WSPAPI SockProcessQueuedAsyncSelect (PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
 
VOID WSPAPI SockAsyncSelectCompletion (PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
 
SOCKET WSPAPI WSPAccept (IN SOCKET s, OUT LPSOCKADDR addr, IN OUT LPINT addrlen, IN LPCONDITIONPROC lpfnCondition, IN DWORD dwCallbackData, OUT LPINT lpErrno)
 
INT WSPAPI WSPAddressToString (IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPWSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength, OUT LPINT lpErrno)
 
INT WSPAPI WSPAsyncSelect (IN SOCKET s, IN HWND hWnd, IN UINT wMsg, IN LONG lEvent, OUT LPINT lpErrno)
 
INT WSPAPI WSPBind (IN SOCKET s, IN CONST SOCKADDR *name, IN INT namelen, OUT LPINT lpErrno)
 
INT WSPAPI WSPCancelBlockingCall (OUT LPINT lpErrno)
 
INT WSPAPI WSPCleanup (OUT LPINT lpErrno)
 
INT WSPAPI WSPCloseSocket (IN SOCKET s, OUT LPINT lpErrno)
 
INT WSPAPI WSPConnect (IN SOCKET s, IN CONST SOCKADDR *name, IN INT namelen, IN LPWSABUF lpCallerData, OUT LPWSABUF lpCalleeData, IN LPQOS lpSQOS, IN LPQOS lpGQOS, OUT LPINT lpErrno)
 
INT WSPAPI WSPDuplicateSocket (IN SOCKET s, IN DWORD dwProcessId, OUT LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPINT lpErrno)
 
INT WSPAPI WSPEnumNetworkEvents (IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents, OUT LPINT lpErrno)
 
INT WSPAPI WSPEventSelect (IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents, OUT LPINT lpErrno)
 
BOOL WSPAPI WSPGetOverlappedResult (IN SOCKET s, IN LPWSAOVERLAPPED lpOverlapped, OUT LPDWORD lpcbTransfer, IN BOOL fWait, OUT LPDWORD lpdwFlags, OUT LPINT lpErrno)
 
INT WSPAPI WSPGetPeerName (IN SOCKET s, OUT LPSOCKADDR name, IN OUT LPINT namelen, OUT LPINT lpErrno)
 
BOOL WSPAPI WSPGetQOSByName (IN SOCKET s, IN OUT LPWSABUF lpQOSName, OUT LPQOS lpQOS, OUT LPINT lpErrno)
 
INT WSPAPI WSPGetSockName (IN SOCKET s, OUT LPSOCKADDR name, IN OUT LPINT namelen, OUT LPINT lpErrno)
 
INT WSPAPI WSPGetSockOpt (IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT LPINT optlen, OUT LPINT lpErrno)
 
INT WSPAPI WSPIoctl (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, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
 
SOCKET WSPAPI WSPJoinLeaf (IN SOCKET s, IN CONST SOCKADDR *name, IN INT namelen, IN LPWSABUF lpCallerData, OUT LPWSABUF lpCalleeData, IN LPQOS lpSQOS, IN LPQOS lpGQOS, IN DWORD dwFlags, OUT LPINT lpErrno)
 
INT WSPAPI WSPListen (IN SOCKET s, IN INT backlog, OUT LPINT lpErrno)
 
INT WSPAPI WSPRecv (IN SOCKET s, IN OUT LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesRecvd, IN OUT LPDWORD lpFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
 
INT WSPAPI WSPRecvDisconnect (IN SOCKET s, OUT LPWSABUF lpInboundDisconnectData, OUT LPINT lpErrno)
 
INT WSPAPI WSPRecvFrom (IN SOCKET s, IN OUT LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesRecvd, IN OUT LPDWORD lpFlags, OUT LPSOCKADDR lpFrom, IN OUT LPINT lpFromlen, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
 
INT WSPAPI WSPSelect (IN INT nfds, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST LPTIMEVAL timeout, OUT LPINT lpErrno)
 
INT WSPAPI WSPSend (IN SOCKET s, IN LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesSent, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
 
INT WSPAPI WSPSendDisconnect (IN SOCKET s, IN LPWSABUF lpOutboundDisconnectData, OUT LPINT lpErrno)
 
INT WSPAPI WSPSendTo (IN SOCKET s, IN LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesSent, IN DWORD dwFlags, IN CONST SOCKADDR *lpTo, IN INT iTolen, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
 
INT WSPAPI WSPSetSockOpt (IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen, OUT LPINT lpErrno)
 
INT WSPAPI WSPShutdown (IN SOCKET s, IN INT how, OUT LPINT lpErrno)
 
SOCKET WSPAPI WSPSocket (IN INT af, IN INT type, IN INT protocol, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, IN GROUP g, IN DWORD dwFlags, OUT LPINT lpErrno)
 
INT WSPAPI WSPStringToAddress (IN LPWSTR AddressString, IN INT AddressFamily, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPSOCKADDR lpAddress, IN OUT LPINT lpAddressLength, OUT LPINT lpErrno)
 

Variables

HANDLE SockPrivateHeap
 
PRTL_HEAP_ALLOCATE SockAllocateHeapRoutine
 
SOCK_RW_LOCK SocketGlobalLock
 
PWAH_HANDLE_TABLE SockContextTable
 
LPWSPUPCALLTABLE SockUpcallTable
 
BOOL SockProcessTerminating
 
LONG SockWspStartupCount
 
DWORD SockSendBufferWindow
 
DWORD SockReceiveBufferWindow
 
HANDLE SockAsyncQueuePort
 
BOOLEAN SockAsyncSelectCalled
 
LONG SockProcessPendingAPCCount
 
HINSTANCE SockModuleHandle
 
LONG gWSM_NSPStartupRef
 
LONG gWSM_NSPCallRef
 
LIST_ENTRY SockHelperDllListHead
 
CRITICAL_SECTION MSWSOCK_SocketLock
 
HINSTANCE NlsMsgSourcemModuleHandle
 
PVOID SockBufferKeyTable
 
ULONG SockBufferKeyTableSize
 
LONG SockAsyncThreadReferenceCount
 
BOOLEAN g_fRnrLockInit
 
CRITICAL_SECTION g_RnrLock
 
HANDLE SockSanCleanUpCompleteEvent
 
BOOLEAN SockSanEnabled
 
WSAPROTOCOL_INFOW SockTcpProviderInfo
 

Macro Definition Documentation

◆ ALWAYS_BLOCKING_HOOK

#define ALWAYS_BLOCKING_HOOK   2

Definition at line 10 of file msafdlib.h.

◆ MAX_TDI_ADDRESS_LENGTH

#define MAX_TDI_ADDRESS_LENGTH   32

Definition at line 16 of file msafdlib.h.

◆ MAYBE_BLOCKING_HOOK

#define MAYBE_BLOCKING_HOOK   1

Definition at line 9 of file msafdlib.h.

◆ MSAFD_IS_DGRAM_SOCK

#define MSAFD_IS_DGRAM_SOCK (   s)     (s->SharedData.ServiceFlags1 & XP1_CONNECTIONLESS)

Definition at line 430 of file msafdlib.h.

◆ NO_BLOCKING_HOOK

#define NO_BLOCKING_HOOK   0

Definition at line 8 of file msafdlib.h.

◆ NO_TIMEOUT

#define NO_TIMEOUT   0

Definition at line 12 of file msafdlib.h.

◆ RECV_TIMEOUT

#define RECV_TIMEOUT   2

Definition at line 14 of file msafdlib.h.

◆ SEND_TIMEOUT

#define SEND_TIMEOUT   1

Definition at line 13 of file msafdlib.h.

◆ WSA_FLAG_MULTIPOINT_ALL

#define WSA_FLAG_MULTIPOINT_ALL
Value:
#define WSA_FLAG_MULTIPOINT_D_LEAF
Definition: winsock2.h:470
#define WSA_FLAG_MULTIPOINT_C_ROOT
Definition: winsock2.h:467
#define WSA_FLAG_MULTIPOINT_D_ROOT
Definition: winsock2.h:469
#define WSA_FLAG_MULTIPOINT_C_LEAF
Definition: winsock2.h:468

Definition at line 18 of file msafdlib.h.

Typedef Documentation

◆ ASYNC_DATA

◆ HELPER_DATA

◆ PASYNC_COMPLETION_ROUTINE

typedef VOID(WSPAPI * PASYNC_COMPLETION_ROUTINE) (PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)

Definition at line 438 of file msafdlib.h.

◆ PASYNC_DATA

◆ PHELPER_DATA

◆ PICF_CONNECT

typedef INT(WINAPI * PICF_CONNECT) (PVOID IcfData)

Definition at line 169 of file msafdlib.h.

◆ PRTL_HEAP_ALLOCATE

typedef PVOID(NTAPI * PRTL_HEAP_ALLOCATE) (IN HANDLE Heap, IN ULONG Flags, IN ULONG Size)

Definition at line 181 of file msafdlib.h.

◆ PSOCK_ICF_DATA

◆ PSOCK_RW_LOCK

◆ PSOCK_SHARED_INFO

◆ PSOCKET_CONTEXT

◆ PSOCKET_INFORMATION

◆ PSOCKET_STATE

◆ PWINSOCK_TEB_DATA

◆ SOCK_ICF_DATA

◆ SOCK_RW_LOCK

◆ SOCK_SHARED_INFO

◆ SOCKET_CONTEXT

◆ SOCKET_INFORMATION

◆ SOCKET_STATE

◆ WINSOCK_TEB_DATA

Enumeration Type Documentation

◆ _SOCKET_STATE

Enumerator
SocketOpen 
SocketBound 
SocketBoundUdp 
SocketConnected 
SocketClosed 
SocketStateCreated 
SocketStateBound 
SocketStateListening 
SocketStateConnected 
SocketUndefined 
SocketOpen 
SocketBound 
SocketBoundUdp 
SocketConnected 
SocketClosed 

Definition at line 25 of file msafdlib.h.

26{
27 SocketUndefined = -1,
enum _SOCKET_STATE SOCKET_STATE
enum _SOCKET_STATE * PSOCKET_STATE
@ SocketBound
Definition: msafdlib.h:29
@ SocketConnected
Definition: msafdlib.h:31
@ SocketUndefined
Definition: msafdlib.h:27
@ SocketClosed
Definition: msafdlib.h:32
@ SocketBoundUdp
Definition: msafdlib.h:30
@ SocketOpen
Definition: msafdlib.h:28

Function Documentation

◆ CloseIcfConnection()

VOID WSPAPI CloseIcfConnection ( IN PSOCK_ICF_DATA  IcfData)

◆ InitializeIcfConnection()

VOID WSPAPI InitializeIcfConnection ( IN PSOCK_ICF_DATA  IcfData)

◆ MSAFD_SockThreadInitialize()

BOOL WSPAPI MSAFD_SockThreadInitialize ( VOID  )

◆ MSWSOCK_Initialize()

BOOL WSPAPI MSWSOCK_Initialize ( VOID  )

◆ NewIcfConnection()

VOID WSPAPI NewIcfConnection ( IN PSOCK_ICF_DATA  IcfData)

◆ NtStatusToSocketError()

INT WSPAPI NtStatusToSocketError ( IN NTSTATUS  Status)

◆ SockAcquireRwLockExclusive()

VOID WSPAPI SockAcquireRwLockExclusive ( IN PSOCK_RW_LOCK  Lock)

◆ SockAcquireRwLockShared()

VOID WSPAPI SockAcquireRwLockShared ( IN PSOCK_RW_LOCK  Lock)

◆ SockAsyncSelectCompletion()

VOID WSPAPI SockAsyncSelectCompletion ( PVOID  Context,
PIO_STATUS_BLOCK  IoStatusBlock 
)

◆ SockAsyncSelectHelper()

INT WSPAPI SockAsyncSelectHelper ( IN PSOCKET_INFORMATION  Socket,
IN HWND  hWnd,
IN UINT  wMsg,
IN LONG  Events 
)

◆ SockAsyncThread()

INT WSPAPI SockAsyncThread ( PVOID  ThreadParam)

Definition at line 3654 of file dllmain.c.

3655{
3656 PVOID AsyncContext;
3657 PASYNC_COMPLETION_ROUTINE AsyncCompletionRoutine;
3658 IO_STATUS_BLOCK IOSB;
3660
3661 /* Make the Thread Higher Priority */
3663
3664 /* Do a KQUEUE/WorkItem Style Loop, thanks to IoCompletion Ports */
3665 do
3666 {
3668 (PVOID*)&AsyncCompletionRoutine,
3669 &AsyncContext,
3670 &IOSB,
3671 NULL);
3672 /* Call the Async Function */
3673 if (NT_SUCCESS(Status))
3674 {
3675 (*AsyncCompletionRoutine)(AsyncContext, &IOSB);
3676 }
3677 else
3678 {
3679 /* It Failed, sleep for a second */
3680 Sleep(1000);
3681 }
3682 } while ((Status != STATUS_TIMEOUT));
3683
3684 /* The Thread has Ended */
3685 return 0;
3686}
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:700
HANDLE SockAsyncCompletionPort
Definition: dllmain.c:28
VOID(* PASYNC_COMPLETION_ROUTINE)(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
Definition: msafd.h:542
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, OUT PVOID *KeyContext, OUT PVOID *ApcContext, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: iocomp.c:445
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define THREAD_PRIORITY_ABOVE_NORMAL
Definition: winbase.h:301

Referenced by SockCreateOrReferenceAsyncThread().

◆ SockBuildSockaddr()

INT WSPAPI SockBuildSockaddr ( OUT PSOCKADDR  Sockaddr,
OUT PINT  SockaddrLength,
IN PTRANSPORT_ADDRESS  TdiAddress 
)

◆ SockBuildTdiAddress()

INT WSPAPI SockBuildTdiAddress ( OUT PTRANSPORT_ADDRESS  TdiAddress,
IN PSOCKADDR  Sockaddr,
IN INT  SockaddrLength 
)

◆ SockCancelIo()

VOID WSPAPI SockCancelIo ( IN SOCKET  Handle)

◆ SockCheckAndInitAsyncSelectHelper()

BOOLEAN WSPAPI SockCheckAndInitAsyncSelectHelper ( VOID  )

◆ SockCheckAndReferenceAsyncThread()

BOOLEAN WSPAPI SockCheckAndReferenceAsyncThread ( VOID  )

◆ SockCloseSocket()

INT WSPAPI SockCloseSocket ( IN PSOCKET_INFORMATION  Socket)

◆ SockCreateAsyncQueuePort()

INT WSPAPI SockCreateAsyncQueuePort ( VOID  )

◆ SockDeleteRwLock()

NTSTATUS WSPAPI SockDeleteRwLock ( IN PSOCK_RW_LOCK  Lock)

◆ SockDereferenceHelperDll()

FORCEINLINE VOID WSPAPI SockDereferenceHelperDll ( IN PHELPER_DATA  Helper)

Definition at line 420 of file msafdlib.h.

421{
422 /* Dereference and see if it's the last count */
423 if (!InterlockedDecrement(&Helper->RefCount))
424 {
425 /* Destroy the Helper DLL */
426 SockFreeHelperDll(Helper);
427 }
428}
#define InterlockedDecrement
Definition: armddk.h:52
VOID WSPAPI SockFreeHelperDll(IN PHELPER_DATA Helper)

◆ SockDereferenceSocket()

VOID WSPAPI SockDereferenceSocket ( IN PSOCKET_INFORMATION  Socket)

◆ SockEnterApiFast()

FORCEINLINE INT WSPAPI SockEnterApiFast ( OUT PWINSOCK_TEB_DATA ThreadData)

Definition at line 402 of file msafdlib.h.

403{
404 /* Make sure we aren't terminating and get our thread data */
405 if (!(SockProcessTerminating) &&
406 (SockWspStartupCount > 0) &&
407 ((*ThreadData = NtCurrentTeb()->WinSockData)))
408 {
409 /* Everything is good, return */
410 return NO_ERROR;
411 }
412
413 /* Something didn't work out, use the slow path */
415}
#define NO_ERROR
Definition: dderror.h:5
#define NtCurrentTeb
LONG SockWspStartupCount
INT WSPAPI SockEnterApiSlow(OUT PWINSOCK_TEB_DATA *ThreadData)
BOOL SockProcessTerminating

◆ SockEnterApiSlow()

INT WSPAPI SockEnterApiSlow ( OUT PWINSOCK_TEB_DATA ThreadData)

Referenced by SockEnterApiFast().

◆ SockEventSelectHelper()

INT WSPAPI SockEventSelectHelper ( IN PSOCKET_INFORMATION  Socket,
IN WSAEVENT  EventObject,
IN LONG  Events 
)

◆ SockFindAndReferenceSocket()

PSOCKET_INFORMATION WSPAPI SockFindAndReferenceSocket ( IN SOCKET  Handle,
IN BOOLEAN  Import 
)

◆ SockFreeHelperDll()

VOID WSPAPI SockFreeHelperDll ( IN PHELPER_DATA  Helper)

◆ SockGetConnectData()

INT WSPAPI SockGetConnectData ( IN PSOCKET_INFORMATION  Socket,
IN ULONG  Ioctl,
IN PVOID  Buffer,
IN ULONG  BufferLength,
OUT PULONG  BufferReturned 
)

◆ SockGetInformation()

INT WSPAPI SockGetInformation ( IN PSOCKET_INFORMATION  Socket,
IN ULONG  AfdInformationClass,
IN PVOID ExtraData  OPTIONAL,
IN ULONG  ExtraDataSize,
IN OUT PBOOLEAN Boolean  OPTIONAL,
IN OUT PULONG Ulong  OPTIONAL,
IN OUT PLARGE_INTEGER LargeInteger  OPTIONAL 
)

◆ SockGetTdiHandles()

INT WSPAPI SockGetTdiHandles ( IN PSOCKET_INFORMATION  Socket)

◆ SockGetTdiName()

INT WSPAPI SockGetTdiName ( PINT  AddressFamily,
PINT  SocketType,
PINT  Protocol,
LPGUID  ProviderId,
GROUP  Group,
DWORD  Flags,
PUNICODE_STRING  TransportName,
PVOID HelperDllContext,
PHELPER_DATA HelperDllData,
PDWORD  Events 
)

◆ SockHandleAsyncIndication()

VOID WSPAPI SockHandleAsyncIndication ( IN PASYNC_COMPLETION_ROUTINE  Callback,
IN PVOID  Context,
IN PIO_STATUS_BLOCK  IoStatusBlock 
)

◆ SockInitializeHeap()

PVOID WSPAPI SockInitializeHeap ( IN HANDLE  Heap,
IN ULONG  Flags,
IN ULONG  Size 
)

◆ SockInitializeRwLockAndSpinCount()

NTSTATUS WSPAPI SockInitializeRwLockAndSpinCount ( IN PSOCK_RW_LOCK  Lock,
IN ULONG  SpinCount 
)

◆ SockIoCompletion()

VOID WSPAPI SockIoCompletion ( IN PVOID  ApcContext,
IN PIO_STATUS_BLOCK  IoStatusBlock,
DWORD  Reserved 
)

◆ SockIsAddressConsistentWithConstrainedGroup()

INT WSPAPI SockIsAddressConsistentWithConstrainedGroup ( IN PSOCKET_INFORMATION  Socket,
IN GROUP  Group,
IN PSOCKADDR  SocketAddress,
IN INT  SocketAddressLength 
)

◆ SockIsSocketConnected()

BOOLEAN WSPAPI SockIsSocketConnected ( IN PSOCKET_INFORMATION  Socket)

◆ SockIsTripleInMapping()

BOOL WSPAPI SockIsTripleInMapping ( IN PWINSOCK_MAPPING  Mapping,
IN INT  AddressFamily,
OUT PBOOLEAN  AfMatch,
IN INT  SocketType,
OUT PBOOLEAN  SockMatch,
IN INT  Protocol,
OUT PBOOLEAN  ProtoMatch 
)

◆ SockLoadHelperDll()

INT WSPAPI SockLoadHelperDll ( PWSTR  TransportName,
PWINSOCK_MAPPING  Mapping,
PHELPER_DATA HelperDllData 
)

Definition at line 298 of file helpers.c.

302{
303 PHELPER_DATA HelperData;
304 PWSTR HelperDllName;
305 PWSTR FullHelperDllName;
306 PWSTR HelperKey;
309 LONG Status;
310
311 /* Allocate space for the Helper Structure and TransportName */
312 HelperData = HeapAlloc(GlobalHeap, 0, sizeof(*HelperData) + (wcslen(TransportName) + 1) * sizeof(WCHAR));
313
314 /* Check for error */
315 if (HelperData == NULL) {
316 ERR("Buffer allocation failed\n");
317 return WSAEINVAL;
318 }
319
320 /* Allocate Space for the Helper DLL Key */
321 HelperKey = HeapAlloc(GlobalHeap, 0, (54 + wcslen(TransportName)) * sizeof(WCHAR));
322
323 /* Check for error */
324 if (HelperKey == NULL) {
325 ERR("Buffer allocation failed\n");
326 HeapFree(GlobalHeap, 0, HelperData);
327 return WSAEINVAL;
328 }
329
330 /* Generate the right key name */
331 wcscpy(HelperKey, L"System\\CurrentControlSet\\Services\\");
332 wcscat(HelperKey, TransportName);
333 wcscat(HelperKey, L"\\Parameters\\Winsock");
334
335 /* Open the Key */
337
338 HeapFree(GlobalHeap, 0, HelperKey);
339
340 /* Check for error */
341 if (Status) {
342 ERR("Error reading helper DLL parameters\n");
343 HeapFree(GlobalHeap, 0, HelperData);
344 return WSAEINVAL;
345 }
346
347 /* Read Size of SockAddr Structures */
348 DataSize = sizeof(HelperData->MinWSAddressLength);
349 HelperData->MinWSAddressLength = 16;
351 L"MinSockaddrLength",
352 NULL,
353 NULL,
354 (LPBYTE)&HelperData->MinWSAddressLength,
355 &DataSize);
356 DataSize = sizeof(HelperData->MinWSAddressLength);
357 HelperData->MaxWSAddressLength = 16;
359 L"MaxSockaddrLength",
360 NULL,
361 NULL,
362 (LPBYTE)&HelperData->MaxWSAddressLength,
363 &DataSize);
364
365 /* Size of TDI Structures */
366 HelperData->MinTDIAddressLength = HelperData->MinWSAddressLength + 6;
367 HelperData->MaxTDIAddressLength = HelperData->MaxWSAddressLength + 6;
368
369 /* Read Delayed Acceptance Setting */
370 DataSize = sizeof(DWORD);
371 HelperData->UseDelayedAcceptance = FALSE;
373 L"UseDelayedAcceptance",
374 NULL,
375 NULL,
376 (LPBYTE)&HelperData->UseDelayedAcceptance,
377 &DataSize);
378
379 /* Allocate Space for the Helper DLL Names */
380 HelperDllName = HeapAlloc(GlobalHeap, 0, 512);
381
382 /* Check for error */
383 if (HelperDllName == NULL) {
384 ERR("Buffer allocation failed\n");
385 HeapFree(GlobalHeap, 0, HelperData);
386 return WSAEINVAL;
387 }
388
389 FullHelperDllName = HeapAlloc(GlobalHeap, 0, 512);
390
391 /* Check for error */
392 if (FullHelperDllName == NULL) {
393 ERR("Buffer allocation failed\n");
394 HeapFree(GlobalHeap, 0, HelperDllName);
395 HeapFree(GlobalHeap, 0, HelperData);
396 return WSAEINVAL;
397 }
398
399 /* Get the name of the Helper DLL*/
400 DataSize = 512;
402 L"HelperDllName",
403 NULL,
404 NULL,
405 (LPBYTE)HelperDllName,
406 &DataSize);
407
408 /* Check for error */
409 if (Status) {
410 ERR("Error reading helper DLL parameters\n");
411 HeapFree(GlobalHeap, 0, FullHelperDllName);
412 HeapFree(GlobalHeap, 0, HelperDllName);
413 HeapFree(GlobalHeap, 0, HelperData);
414 return WSAEINVAL;
415 }
416
417 /* Get the Full name, expanding Environment Strings */
418 ExpandEnvironmentStringsW (HelperDllName,
419 FullHelperDllName,
420 256);
421
422 /* Load the DLL */
423 HelperData->hInstance = LoadLibraryW(FullHelperDllName);
424
425 HeapFree(GlobalHeap, 0, HelperDllName);
426 HeapFree(GlobalHeap, 0, FullHelperDllName);
427
428 if (HelperData->hInstance == NULL) {
429 ERR("Error loading helper DLL\n");
430 HeapFree(GlobalHeap, 0, HelperData);
431 return WSAEINVAL;
432 }
433
434 /* Close Key */
436
437 /* Get the Pointers to the Helper Routines */
438 HelperData->WSHOpenSocket = (PWSH_OPEN_SOCKET)
439 GetProcAddress(HelperData->hInstance,
440 "WSHOpenSocket");
441 HelperData->WSHOpenSocket2 = (PWSH_OPEN_SOCKET2)
442 GetProcAddress(HelperData->hInstance,
443 "WSHOpenSocket2");
444 HelperData->WSHJoinLeaf = (PWSH_JOIN_LEAF)
445 GetProcAddress(HelperData->hInstance,
446 "WSHJoinLeaf");
447 HelperData->WSHNotify = (PWSH_NOTIFY)
448 GetProcAddress(HelperData->hInstance, "WSHNotify");
450 GetProcAddress(HelperData->hInstance,
451 "WSHGetSocketInformation");
453 GetProcAddress(HelperData->hInstance,
454 "WSHSetSocketInformation");
456 GetProcAddress(HelperData->hInstance,
457 "WSHGetSockaddrType");
459 GetProcAddress(HelperData->hInstance,
460 "WSHGetWildcardSockaddr");
462 GetProcAddress(HelperData->hInstance,
463 "WSHGetBroadcastSockaddr");
465 GetProcAddress(HelperData->hInstance,
466 "WSHAddressToString");
468 GetProcAddress(HelperData->hInstance,
469 "WSHStringToAddress");
470 HelperData->WSHIoctl = (PWSH_IOCTL)
471 GetProcAddress(HelperData->hInstance,
472 "WSHIoctl");
473
474 /* Save the Mapping Structure and transport name */
475 HelperData->Mapping = Mapping;
476 wcscpy(HelperData->TransportName, TransportName);
477
478 /* Increment Reference Count */
479 HelperData->RefCount = 1;
480
481 /* Add it to our list */
483
484 /* Return Pointers */
485 *HelperDllData = HelperData;
486 return 0;
487}
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
LIST_ENTRY SockHelpersListHead
Definition: dllmain.c:25
HANDLE GlobalHeap
Definition: dllmain.c:19
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
#define InsertHeadList(ListHead, Entry)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOLEAN UseDelayedAcceptance
Definition: helpers.h:20
INT MaxTDIAddressLength
Definition: helpers.h:19
PWSH_GET_SOCKADDR_TYPE WSHGetSockaddrType
Definition: helpers.h:28
PWSH_JOIN_LEAF WSHJoinLeaf
Definition: helpers.h:24
HANDLE hInstance
Definition: helpers.h:15
PWSH_GET_SOCKET_INFORMATION WSHGetSocketInformation
Definition: helpers.h:26
INT MinWSAddressLength
Definition: helpers.h:16
PWSH_STRING_TO_ADDRESS WSHStringToAddress
Definition: helpers.h:32
PWSH_ADDRESS_TO_STRING WSHAddressToString
Definition: helpers.h:31
PWSH_IOCTL WSHIoctl
Definition: helpers.h:33
PWSH_OPEN_SOCKET WSHOpenSocket
Definition: helpers.h:22
PWSH_SET_SOCKET_INFORMATION WSHSetSocketInformation
Definition: helpers.h:27
PWSH_NOTIFY WSHNotify
Definition: helpers.h:25
INT MaxWSAddressLength
Definition: helpers.h:17
PWSH_GET_BROADCAST_SOCKADDR WSHGetBroadcastSockaddr
Definition: helpers.h:30
PWINSOCK_MAPPING Mapping
Definition: helpers.h:21
INT MinTDIAddressLength
Definition: helpers.h:18
LONG RefCount
Definition: helpers.h:14
WCHAR TransportName[1]
Definition: helpers.h:34
LIST_ENTRY Helpers
Definition: helpers.h:13
PWSH_OPEN_SOCKET2 WSHOpenSocket2
Definition: helpers.h:23
PWSH_GET_WILDCARD_SOCKADDR WSHGetWildcardSockaddr
Definition: helpers.h:29
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define WSAEINVAL
Definition: winerror.h:1946
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
INT(WINAPI * PWSH_GET_BROADCAST_SOCKADDR)(PVOID, PSOCKADDR, PINT)
Definition: wsahelp.h:69
INT(WINAPI * PWSH_GET_WILDCARD_SOCKADDR)(PVOID, PSOCKADDR, PINT)
Definition: wsahelp.h:73
INT(WINAPI * PWSH_SET_SOCKET_INFORMATION)(PVOID, SOCKET, HANDLE, HANDLE, INT, INT, PCHAR, INT)
Definition: wsahelp.h:83
INT(WINAPI * PWSH_GET_SOCKADDR_TYPE)(PSOCKADDR, DWORD, PSOCKADDR_INFO)
Definition: wsahelp.h:71
INT(WINAPI * PWSH_OPEN_SOCKET2)(PINT, PINT, PINT, GROUP, DWORD, PUNICODE_STRING, PVOID *, PDWORD)
Definition: wsahelp.h:82
INT(WINAPI * PWSH_NOTIFY)(PVOID, SOCKET, HANDLE, HANDLE, DWORD)
Definition: wsahelp.h:80
INT(WINAPI * PWSH_JOIN_LEAF)(PVOID, SOCKET, HANDLE, HANDLE, PVOID, SOCKET, PSOCKADDR, DWORD, LPWSABUF, LPWSABUF, LPQOS, LPQOS, DWORD)
Definition: wsahelp.h:78
INT(WINAPI * PWSH_STRING_TO_ADDRESS)(LPWSTR, DWORD, LPWSAPROTOCOL_INFOW, LPSOCKADDR, LPDWORD)
Definition: wsahelp.h:84
INT(WINAPI * PWSH_OPEN_SOCKET)(PINT, PINT, PINT, PUNICODE_STRING, PVOID, PDWORD)
Definition: wsahelp.h:81
INT(WINAPI * PWSH_IOCTL)(PVOID, SOCKET, HANDLE, HANDLE, DWORD, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE, LPBOOL)
Definition: wsahelp.h:76
INT(WINAPI * PWSH_ADDRESS_TO_STRING)(LPSOCKADDR, INT, LPWSAPROTOCOL_INFOW, LPWSTR, LPDWORD)
Definition: wsahelp.h:67
INT(WINAPI * PWSH_GET_SOCKET_INFORMATION)(PVOID, SOCKET, HANDLE, HANDLE, INT, INT, PCHAR, LPINT)
Definition: wsahelp.h:72
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by SockGetTdiName().

◆ SockLoadTransportList()

INT WSPAPI SockLoadTransportList ( PWSTR TransportList)

Definition at line 232 of file helpers.c.

234{
235 ULONG TransportListSize;
237 LONG Status;
238
239 TRACE("Called\n");
240
241 /* Open the Transports Key */
243 L"SYSTEM\\CurrentControlSet\\Services\\Winsock\\Parameters",
244 0,
245 KEY_READ,
246 &KeyHandle);
247
248 /* Check for error */
249 if (Status) {
250 ERR("Error reading transport list registry\n");
251 return WSAEINVAL;
252 }
253
254 /* Get the Transport List Size */
256 L"Transports",
257 NULL,
258 NULL,
259 NULL,
260 &TransportListSize);
261
262 /* Check for error */
263 if (Status) {
264 ERR("Error reading transport list registry\n");
265 return WSAEINVAL;
266 }
267
268 /* Allocate Memory for the Transport List */
269 *TransportList = HeapAlloc(GlobalHeap, 0, TransportListSize);
270
271 /* Check for error */
272 if (*TransportList == NULL) {
273 ERR("Buffer allocation failed\n");
274 return WSAEINVAL;
275 }
276
277 /* Get the Transports */
279 L"Transports",
280 NULL,
281 NULL,
282 (LPBYTE)*TransportList,
283 &TransportListSize);
284
285 /* Check for error */
286 if (Status) {
287 ERR("Error reading transport list registry\n");
288 HeapFree(GlobalHeap, 0, *TransportList);
289 return WSAEINVAL;
290 }
291
292 /* Close key and return */
294 return 0;
295}
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by SockGetTdiName().

◆ SockLoadTransportMapping()

INT WSPAPI SockLoadTransportMapping ( PWSTR  TransportName,
PWINSOCK_MAPPING Mapping 
)

Definition at line 161 of file helpers.c.

164{
165 PWSTR TransportKey;
167 ULONG MappingSize;
168 LONG Status;
169
170 TRACE("TransportName %ws\n", TransportName);
171
172 /* Allocate a Buffer */
173 TransportKey = HeapAlloc(GlobalHeap, 0, (54 + wcslen(TransportName)) * sizeof(WCHAR));
174
175 /* Check for error */
176 if (TransportKey == NULL) {
177 ERR("Buffer allocation failed\n");
178 return WSAEINVAL;
179 }
180
181 /* Generate the right key name */
182 wcscpy(TransportKey, L"System\\CurrentControlSet\\Services\\");
183 wcscat(TransportKey, TransportName);
184 wcscat(TransportKey, L"\\Parameters\\Winsock");
185
186 /* Open the Key */
188
189 /* We don't need the Transport Key anymore */
190 HeapFree(GlobalHeap, 0, TransportKey);
191
192 /* Check for error */
193 if (Status) {
194 ERR("Error reading transport mapping registry\n");
195 return WSAEINVAL;
196 }
197
198 /* Find out how much space we need for the Mapping */
199 Status = RegQueryValueExW(KeyHandle, L"Mapping", NULL, NULL, NULL, &MappingSize);
200
201 /* Check for error */
202 if (Status) {
203 ERR("Error reading transport mapping registry\n");
204 return WSAEINVAL;
205 }
206
207 /* Allocate Memory for the Mapping */
208 *Mapping = HeapAlloc(GlobalHeap, 0, MappingSize);
209
210 /* Check for error */
211 if (*Mapping == NULL) {
212 ERR("Buffer allocation failed\n");
213 return WSAEINVAL;
214 }
215
216 /* Read the Mapping */
217 Status = RegQueryValueExW(KeyHandle, L"Mapping", NULL, NULL, (LPBYTE)*Mapping, &MappingSize);
218
219 /* Check for error */
220 if (Status) {
221 ERR("Error reading transport mapping registry\n");
223 return WSAEINVAL;
224 }
225
226 /* Close key and return */
228 return 0;
229}

Referenced by SockGetTdiName().

◆ SockNotifyHelperDll()

INT WSPAPI SockNotifyHelperDll ( IN PSOCKET_INFORMATION  Socket,
IN DWORD  Event 
)

◆ SockProcessAsyncSelect()

VOID WSPAPI SockProcessAsyncSelect ( PSOCKET_INFORMATION  Socket,
PASYNC_DATA  AsyncData 
)

Definition at line 3879 of file dllmain.c.

3880{
3881
3882 ULONG lNetworkEvents;
3884
3885 /* Set up the Async Data Event Info */
3886 AsyncData->AsyncSelectInfo.Timeout.HighPart = 0x7FFFFFFF;
3887 AsyncData->AsyncSelectInfo.Timeout.LowPart = 0xFFFFFFFF;
3888 AsyncData->AsyncSelectInfo.HandleCount = 1;
3889 AsyncData->AsyncSelectInfo.Exclusive = TRUE;
3890 AsyncData->AsyncSelectInfo.Handles[0].Handle = Socket->Handle;
3891 AsyncData->AsyncSelectInfo.Handles[0].Events = 0;
3892
3893 /* Remove unwanted events */
3894 lNetworkEvents = Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents);
3895
3896 /* Set Events to wait for */
3897 if (lNetworkEvents & FD_READ)
3898 {
3900 }
3901
3902 if (lNetworkEvents & FD_WRITE)
3903 {
3905 }
3906
3907 if (lNetworkEvents & FD_OOB)
3908 {
3910 }
3911
3912 if (lNetworkEvents & FD_ACCEPT)
3913 {
3915 }
3916
3917 /* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
3918 if (lNetworkEvents & FD_CONNECT)
3919 {
3921 }
3922
3923 if (lNetworkEvents & FD_CLOSE)
3924 {
3926 }
3927
3928 if (lNetworkEvents & FD_QOS)
3929 {
3931 }
3932
3933 if (lNetworkEvents & FD_GROUP_QOS)
3934 {
3936 }
3937
3938 /* Send IOCTL */
3940 NULL,
3941 NULL,
3942 AsyncData,
3943 &AsyncData->IoStatusBlock,
3945 &AsyncData->AsyncSelectInfo,
3946 sizeof(AsyncData->AsyncSelectInfo),
3947 &AsyncData->AsyncSelectInfo,
3948 sizeof(AsyncData->AsyncSelectInfo));
3949
3950 /* I/O Manager Won't call the completion routine, let's do it manually */
3951 if (NT_SUCCESS(Status))
3952 {
3953 return;
3954 }
3955 else
3956 {
3957 AsyncData->IoStatusBlock.Status = Status;
3958 SockAsyncSelectCompletionRoutine(AsyncData, &AsyncData->IoStatusBlock);
3959 }
3960}
#define TRUE
Definition: types.h:120
VOID SockAsyncSelectCompletionRoutine(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
Definition: dllmain.c:3750
HANDLE SockAsyncHelperAfdHandle
Definition: dllmain.c:27
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define AFD_EVENT_ACCEPT
Definition: shared.h:210
#define AFD_EVENT_SEND
Definition: shared.h:205
#define AFD_EVENT_OOB_RECEIVE
Definition: shared.h:204
#define AFD_EVENT_CONNECT_FAIL
Definition: shared.h:211
#define AFD_EVENT_RECEIVE
Definition: shared.h:203
#define IOCTL_AFD_SELECT
Definition: shared.h:285
#define AFD_EVENT_DISCONNECT
Definition: shared.h:206
#define AFD_EVENT_ABORT
Definition: shared.h:207
#define AFD_EVENT_QOS
Definition: shared.h:212
#define AFD_EVENT_CLOSE
Definition: shared.h:208
#define AFD_EVENT_CONNECT
Definition: shared.h:209
#define AFD_EVENT_GROUP_QOS
Definition: shared.h:213
SOCKET Handle
Definition: shared.h:50
ULONG Events
Definition: shared.h:51
LARGE_INTEGER Timeout
Definition: shared.h:56
ULONG HandleCount
Definition: shared.h:57
AFD_HANDLE Handles[1]
Definition: shared.h:59
ULONG_PTR Exclusive
Definition: shared.h:58
AFD_POLL_INFO AsyncSelectInfo
Definition: msafd.h:133
IO_STATUS_BLOCK IoStatusBlock
Definition: msafd.h:132
PSOCK_SHARED_INFO SharedData
Definition: msafd.h:100
SOCKET Handle
Definition: msafd.h:99
LONG AsyncEvents
Definition: msafd.h:92
ULONG LowPart
Definition: typedefs.h:106
#define FD_QOS
Definition: winsock2.h:306
#define FD_GROUP_QOS
Definition: winsock2.h:308
#define FD_READ
Definition: winsock.h:405
#define FD_WRITE
Definition: winsock.h:406
#define FD_CLOSE
Definition: winsock.h:410
#define FD_CONNECT
Definition: winsock.h:409
#define FD_OOB
Definition: winsock.h:407
#define FD_ACCEPT
Definition: winsock.h:408

Referenced by SockAsyncSelectCompletionRoutine(), and SockProcessQueuedAsyncSelect().

◆ SockProcessQueuedAsyncSelect()

VOID WSPAPI SockProcessQueuedAsyncSelect ( PVOID  Context,
PIO_STATUS_BLOCK  IoStatusBlock 
)

Definition at line 3962 of file dllmain.c.

3963{
3964 PASYNC_DATA AsyncData = Context;
3965 BOOL FreeContext = TRUE;
3966 PSOCKET_INFORMATION Socket;
3967
3968 /* Get the Socket */
3969 Socket = AsyncData->ParentSocket;
3970
3971 /* If someone closed it, stop the function */
3972 if (Socket->SharedData->State != SocketClosed)
3973 {
3974 /* Check if the Sequence Number changed by now, in which case quit */
3975 if (AsyncData->SequenceNumber == Socket->SharedData->SequenceNumber)
3976 {
3977 /* Do the actual select, if needed */
3978 if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)))
3979 {
3980 SockProcessAsyncSelect(Socket, AsyncData);
3981 FreeContext = FALSE;
3982 }
3983 }
3984 }
3985
3986 /* Free the Context */
3987 if (FreeContext)
3988 {
3989 HeapFree(GetProcessHeap(), 0, AsyncData);
3990 }
3991
3992 return;
3993}
#define GetProcessHeap()
Definition: compat.h:736
VOID SockProcessAsyncSelect(PSOCKET_INFORMATION Socket, PASYNC_DATA AsyncData)
Definition: dllmain.c:3879
@ SocketClosed
Definition: msafd.h:50
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD SequenceNumber
Definition: msafd.h:131
PSOCKET_INFORMATION ParentSocket
Definition: msafd.h:130
LONG AsyncDisabledEvents
Definition: msafd.h:93
SOCKET_STATE State
Definition: msafd.h:54
DWORD SequenceNumber
Definition: msafd.h:90

Referenced by SockReenableAsyncSelectEvent(), and WSPAsyncSelect().

◆ SockReenableAsyncSelectEvent()

INT WSPAPI SockReenableAsyncSelectEvent ( IN PSOCKET_INFORMATION  Socket,
IN ULONG  Event 
)

Definition at line 3996 of file dllmain.c.

3998{
3999 PASYNC_DATA AsyncData;
4000
4001 /* Make sure the event is actually disabled */
4002 if (!(Socket->SharedData->AsyncDisabledEvents & Event))
4003 {
4004 return;
4005 }
4006
4007 /* Re-enable it */
4008 Socket->SharedData->AsyncDisabledEvents &= ~Event;
4009
4010 /* Return if no more events are being polled */
4011 if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)) == 0 )
4012 {
4013 return;
4014 }
4015
4016 /* Wait on new events */
4017 AsyncData = HeapAlloc(GetProcessHeap(), 0, sizeof(ASYNC_DATA));
4018 if (!AsyncData) return;
4019
4020 /* Create the Asynch Thread if Needed */
4022
4023 /* Increase the sequence number to stop anything else */
4024 Socket->SharedData->SequenceNumber++;
4025
4026 /* Set up the Async Data */
4027 AsyncData->ParentSocket = Socket;
4028 AsyncData->SequenceNumber = Socket->SharedData->SequenceNumber;
4029
4030 /* Begin Async Select by using I/O Completion */
4033 AsyncData,
4034 0,
4035 0);
4036
4037 /* All done */
4038 return;
4039}
BOOLEAN SockCreateOrReferenceAsyncThread(VOID)
Definition: dllmain.c:3593
VOID SockProcessQueuedAsyncSelect(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
Definition: dllmain.c:3962
NTSTATUS NTAPI NtSetIoCompletion(IN HANDLE IoCompletionPortHandle, IN PVOID CompletionKey, IN PVOID CompletionContext, IN NTSTATUS CompletionStatus, IN ULONG CompletionInformation)
Definition: iocomp.c:569

Referenced by AfdAPC(), WSPAccept(), WSPConnect(), WSPGetOverlappedResult(), WSPRecv(), WSPRecvFrom(), WSPSend(), and WSPSendTo().

◆ SockReleaseRwLockExclusive()

VOID WSPAPI SockReleaseRwLockExclusive ( IN PSOCK_RW_LOCK  Lock)

◆ SockReleaseRwLockShared()

VOID WSPAPI SockReleaseRwLockShared ( IN PSOCK_RW_LOCK  Lock)

◆ SockSanGetTcpipCatalogId()

VOID WSPAPI SockSanGetTcpipCatalogId ( VOID  )

◆ SockSanInitialize()

VOID WSPAPI SockSanInitialize ( VOID  )

◆ SockSetHandleContext()

INT WSPAPI SockSetHandleContext ( IN PSOCKET_INFORMATION  Socket)

◆ SockSetInformation()

INT WSPAPI SockSetInformation ( IN PSOCKET_INFORMATION  Socket,
IN ULONG  AfdInformationClass,
IN PBOOLEAN Boolean  OPTIONAL,
IN PULONG Ulong  OPTIONAL,
IN PLARGE_INTEGER LargeInteger  OPTIONAL 
)

◆ SockSocket()

INT WSPAPI SockSocket ( INT  AddressFamily,
INT  SocketType,
INT  Protocol,
LPGUID  ProviderId,
GROUP  g,
DWORD  dwFlags,
DWORD  ProviderFlags,
DWORD  ServiceFlags,
DWORD  CatalogEntryId,
PSOCKET_INFORMATION NewSocket 
)

◆ SockUpdateWindowSizes()

INT WSPAPI SockUpdateWindowSizes ( IN PSOCKET_INFORMATION  Socket,
IN BOOLEAN  Force 
)

◆ SockWaitForSingleObject()

BOOL WSPAPI SockWaitForSingleObject ( IN HANDLE  Handle,
IN SOCKET  SocketHandle,
IN DWORD  BlockingFlags,
IN DWORD  TimeoutFlags 
)

◆ WSPAccept()

SOCKET WSPAPI WSPAccept ( IN SOCKET  s,
OUT LPSOCKADDR  addr,
IN OUT LPINT  addrlen,
IN LPCONDITIONPROC  lpfnCondition,
IN DWORD  dwCallbackData,
OUT LPINT  lpErrno 
)

◆ WSPAddressToString()

INT WSPAPI WSPAddressToString ( IN LPSOCKADDR  lpsaAddress,
IN DWORD  dwAddressLength,
IN LPWSAPROTOCOL_INFOW  lpProtocolInfo,
OUT LPWSTR  lpszAddressString,
IN OUT LPDWORD  lpdwAddressStringLength,
OUT LPINT  lpErrno 
)

Definition at line 3063 of file dllmain.c.

3069{
3070 SIZE_T size;
3071 WCHAR buffer[54]; /* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */
3072 WCHAR *p;
3073
3074 if (!lpsaAddress || !lpszAddressString || !lpdwAddressStringLength)
3075 {
3076 if (lpErrno) *lpErrno = WSAEFAULT;
3077 return SOCKET_ERROR;
3078 }
3079
3080 switch (lpsaAddress->sa_family)
3081 {
3082 case AF_INET:
3083 if (dwAddressLength < sizeof(SOCKADDR_IN))
3084 {
3085 if (lpErrno) *lpErrno = WSAEINVAL;
3086 return SOCKET_ERROR;
3087 }
3089 L"%u.%u.%u.%u:%u",
3090 (unsigned int)(ntohl(((SOCKADDR_IN *)lpsaAddress)->sin_addr.s_addr) >> 24 & 0xff),
3091 (unsigned int)(ntohl(((SOCKADDR_IN *)lpsaAddress)->sin_addr.s_addr) >> 16 & 0xff),
3092 (unsigned int)(ntohl(((SOCKADDR_IN *)lpsaAddress)->sin_addr.s_addr) >> 8 & 0xff),
3093 (unsigned int)(ntohl(((SOCKADDR_IN *)lpsaAddress)->sin_addr.s_addr) & 0xff),
3094 ntohs(((SOCKADDR_IN *)lpsaAddress)->sin_port));
3095
3096 p = wcschr(buffer, L':');
3097 if (!((SOCKADDR_IN *)lpsaAddress)->sin_port)
3098 {
3099 *p = 0;
3100 }
3101 break;
3102 default:
3103 if (lpErrno) *lpErrno = WSAEINVAL;
3104 return SOCKET_ERROR;
3105 }
3106
3107 size = wcslen(buffer) + 1;
3108
3109 if (*lpdwAddressStringLength < size)
3110 {
3111 *lpdwAddressStringLength = size;
3112 if (lpErrno) *lpErrno = WSAEFAULT;
3113 return SOCKET_ERROR;
3114 }
3115
3116 *lpdwAddressStringLength = size;
3117 wcscpy(lpszAddressString, buffer);
3118 return 0;
3119}
#define wcschr
Definition: compat.h:17
#define swprintf
Definition: precomp.h:40
#define AF_INET
Definition: tcpip.h:117
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat p
Definition: glext.h:8902
#define ntohl(x)
Definition: module.h:205
#define ntohs(x)
Definition: module.h:210
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define WSAEFAULT
Definition: winerror.h:1945
#define SOCKET_ERROR
Definition: winsock.h:333

Referenced by WSPStartup().

◆ WSPAsyncSelect()

INT WSPAPI WSPAsyncSelect ( IN SOCKET  s,
IN HWND  hWnd,
IN UINT  wMsg,
IN LONG  lEvent,
OUT LPINT  lpErrno 
)

Definition at line 17 of file sndrcv.c.

22{
24 PASYNC_DATA AsyncData;
25 BOOLEAN BlockMode;
26
27 /* Get the Socket Structure associated to this Socket */
28 Socket = GetSocketStructure(Handle);
29 if (!Socket)
30 {
31 *lpErrno = WSAENOTSOCK;
32 return SOCKET_ERROR;
33 }
34
35 /* Allocate the Async Data Structure to pass on to the Thread later */
36 AsyncData = HeapAlloc(GetProcessHeap(), 0, sizeof(*AsyncData));
37 if (!AsyncData)
38 {
40 return INVALID_SOCKET;
41 }
42
43 /* Change the Socket to Non Blocking */
44 BlockMode = TRUE;
46 Socket->SharedData->NonBlocking = TRUE;
47
48 /* Deactivate WSPEventSelect */
49 if (Socket->SharedData->AsyncEvents)
50 {
51 if (WSPEventSelect(Handle, NULL, 0, lpErrno) == SOCKET_ERROR)
52 {
53 HeapFree(GetProcessHeap(), 0, AsyncData);
54 return SOCKET_ERROR;
55 }
56 }
57
58 /* Create the Asynch Thread if Needed */
60
61 /* Open a Handle to AFD's Async Helper */
63
64 /* Store Socket Data */
65 Socket->SharedData->hWnd = hWnd;
66 Socket->SharedData->wMsg = wMsg;
67 Socket->SharedData->AsyncEvents = lEvent;
69 Socket->SharedData->SequenceNumber++;
70
71 /* Return if there are no more Events */
72 if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)) == 0)
73 {
74 HeapFree(GetProcessHeap(), 0, AsyncData);
75 return 0;
76 }
77
78 /* Set up the Async Data */
79 AsyncData->ParentSocket = Socket;
80 AsyncData->SequenceNumber = Socket->SharedData->SequenceNumber;
81
82 /* Begin Async Select by using I/O Completion */
85 AsyncData,
86 0,
87 0);
88
89 /* Return */
90 return ERROR_SUCCESS;
91}
unsigned char BOOLEAN
HWND hWnd
Definition: settings.c:17
#define ERROR_SUCCESS
Definition: deptool.c:10
PSOCKET_INFORMATION GetSocketStructure(SOCKET Handle)
Definition: dllmain.c:3520
int SetSocketInformation(PSOCKET_INFORMATION Socket, ULONG AfdInformationClass, PBOOLEAN Boolean OPTIONAL, PULONG Ulong OPTIONAL, PLARGE_INTEGER LargeInteger OPTIONAL, LPWSAOVERLAPPED Overlapped OPTIONAL, LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine OPTIONAL)
Definition: dllmain.c:3397
BOOLEAN SockGetAsyncSelectHelperAfdHandle(VOID)
Definition: dllmain.c:3688
int WSPAPI WSPEventSelect(IN SOCKET Handle, IN WSAEVENT hEventObject, IN long lNetworkEvents, OUT LPINT lpErrno)
Definition: event.c:17
FORCEINLINE DWORD MsafdReturnWithErrno(NTSTATUS Status, LPINT Errno, DWORD Received, LPDWORD ReturnedBytes)
Definition: msafd.h:546
ULONG Handle
Definition: gdb_input.c:15
#define AFD_INFO_BLOCKING_MODE
Definition: shared.h:183
BOOLEAN NonBlocking
Definition: msafd.h:74
HANDLE lEvent
Definition: tftpd.cpp:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WSAENOTSOCK
Definition: winerror.h:1951
#define INVALID_SOCKET
Definition: winsock.h:332

Referenced by WSPStartup().

◆ WSPBind()

INT WSPAPI WSPBind ( IN SOCKET  s,
IN CONST SOCKADDR name,
IN INT  namelen,
OUT LPINT  lpErrno 
)

◆ WSPCancelBlockingCall()

INT WSPAPI WSPCancelBlockingCall ( OUT LPINT  lpErrno)

Definition at line 15 of file stubs.c.

17{
19
20 return 0;
21}
#define UNIMPLEMENTED
Definition: stubs.c:6

Referenced by WSPStartup().

◆ WSPCleanup()

INT WSPAPI WSPCleanup ( OUT LPINT  lpErrno)

Definition at line 3247 of file dllmain.c.

3249{
3250 TRACE("Leaving.\n");
3251
3252 if (lpErrno) *lpErrno = NO_ERROR;
3253
3254 return 0;
3255}

Referenced by WSPStartup(), and WsTpWSPCleanup().

◆ WSPCloseSocket()

INT WSPAPI WSPCloseSocket ( IN SOCKET  s,
OUT LPINT  lpErrno 
)

Definition at line 623 of file dllmain.c.

625{
627 PSOCKET_INFORMATION Socket = NULL, CurrentSocket;
630 AFD_DISCONNECT_INFO DisconnectInfo;
631 SOCKET_STATE OldState;
632 LONG LingerWait = -1;
633 DWORD References;
634
635 /* Get the Socket Structure associate to this Socket*/
636 Socket = GetSocketStructure(Handle);
637 if (!Socket)
638 {
639 if (lpErrno) *lpErrno = WSAENOTSOCK;
640 return SOCKET_ERROR;
641 }
642
643 /* Create the Wait Event */
646 NULL,
648 FALSE);
649
650 if(!NT_SUCCESS(Status))
651 {
652 ERR("NtCreateEvent failed: 0x%08x\n", Status);
653 return SOCKET_ERROR;
654 }
655
656 if (Socket->HelperEvents & WSH_NOTIFY_CLOSE)
657 {
658 Status = Socket->HelperData->WSHNotify(Socket->HelperContext,
659 Socket->Handle,
660 Socket->TdiAddressHandle,
661 Socket->TdiConnectionHandle,
663
664 if (Status)
665 {
666 if (lpErrno) *lpErrno = Status;
667 ERR("WSHNotify failed. Error 0x%#x\n", Status);
669 return SOCKET_ERROR;
670 }
671 }
672
673 /* If a Close is already in Process, give up */
674 if (Socket->SharedData->State == SocketClosed)
675 {
676 WARN("Socket is closing.\n");
678 if (lpErrno) *lpErrno = WSAENOTSOCK;
679 return SOCKET_ERROR;
680 }
681
682 /* Decrement reference count on SharedData */
683 References = InterlockedDecrement(&Socket->SharedData->RefCount);
684 if (References)
685 goto ok;
686
687 /* Set the state to close */
688 OldState = Socket->SharedData->State;
689 Socket->SharedData->State = SocketClosed;
690
691 /* If SO_LINGER is ON and the Socket is connected, we need to disconnect */
692 /* FIXME: Should we do this on Datagram Sockets too? */
693 if ((OldState == SocketConnected) && (Socket->SharedData->LingerData.l_onoff))
694 {
695 ULONG SendsInProgress;
696 ULONG SleepWait;
697
698 /* We need to respect the timeout */
699 SleepWait = 100;
700 LingerWait = Socket->SharedData->LingerData.l_linger * 1000;
701
702 /* Loop until no more sends are pending, within the timeout */
703 while (LingerWait)
704 {
705 /* Find out how many Sends are in Progress */
706 if (GetSocketInformation(Socket,
708 NULL,
709 &SendsInProgress,
710 NULL,
711 NULL,
712 NULL))
713 {
714 /* Bail out if anything but NO_ERROR */
715 LingerWait = 0;
716 break;
717 }
718
719 /* Bail out if no more sends are pending */
720 if (!SendsInProgress)
721 {
722 LingerWait = -1;
723 break;
724 }
725
726 /*
727 * We have to execute a sleep, so it's kind of like
728 * a block. If the socket is Nonblock, we cannot
729 * go on since asynchronous operation is expected
730 * and we cannot offer it
731 */
732 if (Socket->SharedData->NonBlocking)
733 {
734 WARN("Would block!\n");
736 Socket->SharedData->State = OldState;
737 if (lpErrno) *lpErrno = WSAEWOULDBLOCK;
738 return SOCKET_ERROR;
739 }
740
741 /* Now we can sleep, and decrement the linger wait */
742 /*
743 * FIXME: It seems Windows does some funky acceleration
744 * since the waiting seems to be longer and longer. I
745 * don't think this improves performance so much, so we
746 * wait a fixed time instead.
747 */
748 Sleep(SleepWait);
749 LingerWait -= SleepWait;
750 }
751 }
752
753 if (OldState == SocketConnected)
754 {
755 if (LingerWait <= 0)
756 {
757 DisconnectInfo.Timeout = RtlConvertLongToLargeInteger(0);
758 DisconnectInfo.DisconnectType = LingerWait < 0 ? AFD_DISCONNECT_SEND : AFD_DISCONNECT_ABORT;
759
760 if (((DisconnectInfo.DisconnectType & AFD_DISCONNECT_SEND) && (!Socket->SharedData->SendShutdown)) ||
761 ((DisconnectInfo.DisconnectType & AFD_DISCONNECT_ABORT) && (!Socket->SharedData->ReceiveShutdown)))
762 {
763 /* Send IOCTL */
765 SockEvent,
766 NULL,
767 NULL,
770 &DisconnectInfo,
771 sizeof(DisconnectInfo),
772 NULL,
773 0);
774
775 /* Wait for return */
776 if (Status == STATUS_PENDING)
777 {
780 }
781 }
782 }
783 }
784
785 /* Cleanup Time! */
786 Socket->HelperContext = NULL;
787 Socket->SharedData->AsyncDisabledEvents = -1;
788 NtClose(Socket->TdiAddressHandle);
789 Socket->TdiAddressHandle = NULL;
791 Socket->TdiConnectionHandle = NULL;
792ok:
794 if (SocketListHead == Socket)
795 {
797 }
798 else
799 {
800 CurrentSocket = SocketListHead;
801 while (CurrentSocket->NextSocket)
802 {
803 if (CurrentSocket->NextSocket == Socket)
804 {
805 CurrentSocket->NextSocket = CurrentSocket->NextSocket->NextSocket;
806 break;
807 }
808
809 CurrentSocket = CurrentSocket->NextSocket;
810 }
811 }
813
814 /* Close the handle */
817
819 {
820 /* It is a duplicated socket, so unmap the memory */
822 NtClose(Socket->SharedDataHandle);
823 Socket->SharedData = NULL;
824 }
825 if( !References && Socket->SharedData )
826 {
827 HeapFree(GlobalHeap, 0, Socket->SharedData);
828 }
829 HeapFree(GlobalHeap, 0, Socket);
830 return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
831}
#define ok(value,...)
Definition: atltest.h:57
#define WARN(fmt,...)
Definition: precomp.h:61
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define UnmapViewOfFile
Definition: compat.h:746
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
int GetSocketInformation(PSOCKET_INFORMATION Socket, ULONG AfdInformationClass, PBOOLEAN Boolean OPTIONAL, PULONG Ulong OPTIONAL, PLARGE_INTEGER LargeInteger OPTIONAL, LPWSAOVERLAPPED Overlapped OPTIONAL, LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine OPTIONAL)
Definition: dllmain.c:3270
PSOCKET_INFORMATION SocketListHead
Definition: dllmain.c:23
CRITICAL_SECTION SocketListLock
Definition: dllmain.c:24
enum _SOCKET_STATE SOCKET_STATE
HANDLE SockEvent
@ SocketConnected
Definition: msafd.h:49
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI LONGLONG WINAPI RtlConvertLongToLargeInteger(LONG)
Definition: largeint.c:31
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
@ SynchronizationEvent
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:96
#define AFD_DISCONNECT_ABORT
Definition: shared.h:199
#define IOCTL_AFD_DISCONNECT
Definition: shared.h:287
#define AFD_INFO_SENDS_IN_PROGRESS
Definition: shared.h:184
#define AFD_DISCONNECT_SEND
Definition: shared.h:197
LARGE_INTEGER Timeout
Definition: shared.h:137
ULONG DisconnectType
Definition: shared.h:136
PVOID HelperContext
Definition: msafd.h:104
HANDLE TdiConnectionHandle
Definition: msafd.h:108
struct _SOCKET_INFORMATION * NextSocket
Definition: msafd.h:116
HANDLE SharedDataHandle
Definition: msafd.h:101
PHELPER_DATA HelperData
Definition: msafd.h:103
HANDLE TdiAddressHandle
Definition: msafd.h:107
DWORD HelperEvents
Definition: msafd.h:102
BOOLEAN SendShutdown
Definition: msafd.h:77
LONG RefCount
Definition: msafd.h:55
struct linger LingerData
Definition: msafd.h:61
BOOLEAN ReceiveShutdown
Definition: msafd.h:76
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define WSH_NOTIFY_CLOSE
Definition: wsahelp.h:17

Referenced by WSPAccept(), and WSPStartup().

◆ WSPConnect()

INT WSPAPI WSPConnect ( IN SOCKET  s,
IN CONST SOCKADDR name,
IN INT  namelen,
IN LPWSABUF  lpCallerData,
OUT LPWSABUF  lpCalleeData,
IN LPQOS  lpSQOS,
IN LPQOS  lpGQOS,
OUT LPINT  lpErrno 
)

◆ WSPDuplicateSocket()

INT WSPAPI WSPDuplicateSocket ( IN SOCKET  s,
IN DWORD  dwProcessId,
OUT LPWSAPROTOCOL_INFOW  lpProtocolInfo,
OUT LPINT  lpErrno 
)

Definition at line 449 of file dllmain.c.

454{
455 HANDLE hProcess, hDuplicatedSharedData, hDuplicatedHandle;
456 PSOCKET_INFORMATION Socket;
457 PSOCK_SHARED_INFO pSharedData, pOldSharedData;
458 BOOL bDuplicated;
459
460 if (Handle == INVALID_SOCKET)
462 Socket = GetSocketStructure(Handle);
463 if( !Socket )
464 {
465 if( lpErrno )
466 *lpErrno = WSAENOTSOCK;
467 return SOCKET_ERROR;
468 }
469 if ( !(hProcess = OpenProcess(PROCESS_DUP_HANDLE, FALSE, dwProcessId)) )
471
472 /* It is a not yet duplicated socket, so map the memory, copy the SharedData and free heap */
474 {
476 NULL,
478 0,
479 (sizeof(SOCK_SHARED_INFO) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1),
480 NULL);
483 pSharedData = MapViewOfFile(Socket->SharedDataHandle,
485 0,
486 0,
487 sizeof(SOCK_SHARED_INFO));
488
489 RtlCopyMemory(pSharedData, Socket->SharedData, sizeof(SOCK_SHARED_INFO));
490 pOldSharedData = Socket->SharedData;
491 Socket->SharedData = pSharedData;
492 HeapFree(GlobalHeap, 0, pOldSharedData);
493 }
494 /* Duplicate the handles for the new process */
495 bDuplicated = DuplicateHandle(GetCurrentProcess(),
496 Socket->SharedDataHandle,
497 hProcess,
498 (LPHANDLE)&hDuplicatedSharedData,
499 0,
500 FALSE,
502 if (!bDuplicated)
503 {
506 }
507 bDuplicated = DuplicateHandle(GetCurrentProcess(),
508 (HANDLE)Socket->Handle,
509 hProcess,
510 (LPHANDLE)&hDuplicatedHandle,
511 0,
512 FALSE,
515 if( !bDuplicated )
517
518
519 if (!lpProtocolInfo)
521
522 RtlCopyMemory(lpProtocolInfo, &Socket->ProtocolInfo, sizeof(*lpProtocolInfo));
523
524 lpProtocolInfo->iAddressFamily = Socket->SharedData->AddressFamily;
525 lpProtocolInfo->iProtocol = Socket->SharedData->Protocol;
526 lpProtocolInfo->iSocketType = Socket->SharedData->SocketType;
527 lpProtocolInfo->dwServiceFlags3 = HandleToUlong(hDuplicatedSharedData);
528 lpProtocolInfo->dwServiceFlags4 = HandleToUlong(hDuplicatedHandle);
529
530 if( lpErrno )
531 *lpErrno = NO_ERROR;
532
533 return NO_ERROR;
534}
#define HandleToUlong(h)
Definition: basetsd.h:79
#define GetCurrentProcess()
Definition: compat.h:759
#define MapViewOfFile
Definition: compat.h:745
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PROCESS_DUP_HANDLE
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define SEC_COMMIT
Definition: mmtypes.h:100
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
WSAPROTOCOL_INFOW ProtocolInfo
Definition: msafd.h:115
INT AddressFamily
Definition: msafd.h:56
INT SocketType
Definition: msafd.h:57
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define CreateFileMapping
Definition: winbase.h:3775
#define FILE_MAP_ALL_ACCESS
Definition: winbase.h:157
#define DUPLICATE_SAME_ACCESS

Referenced by WSPStartup().

◆ WSPEnumNetworkEvents()

INT WSPAPI WSPEnumNetworkEvents ( IN SOCKET  s,
IN WSAEVENT  hEventObject,
OUT LPWSANETWORKEVENTS  lpNetworkEvents,
OUT LPINT  lpErrno 
)

Definition at line 133 of file event.c.

138{
140 IO_STATUS_BLOCK IOSB;
141 PSOCKET_INFORMATION Socket = NULL;
144
145 TRACE("Called (lpNetworkEvents %x)\n", lpNetworkEvents);
146
147 /* Get the Socket Structure associate to this Socket*/
148 Socket = GetSocketStructure(Handle);
149 if (!Socket)
150 {
151 if (lpErrno) *lpErrno = WSAENOTSOCK;
152 return SOCKET_ERROR;
153 }
154 if (!lpNetworkEvents)
155 {
156 if (lpErrno) *lpErrno = WSAEFAULT;
157 return SOCKET_ERROR;
158 }
159
162
163 if( !NT_SUCCESS(Status) ) {
164 ERR("Could not make an event %x\n", Status);
165 return SOCKET_ERROR;
166 }
167
168 EnumReq.Event = hEventObject;
169
170 /* Send IOCTL */
172 SockEvent,
173 NULL,
174 NULL,
175 &IOSB,
177 &EnumReq,
178 sizeof(EnumReq),
179 NULL,
180 0);
181
182 /* Wait for return */
183 if (Status == STATUS_PENDING) {
185 Status = IOSB.Status;
186 }
187
189
190 if (Status != STATUS_SUCCESS)
191 {
192 ERR("Status 0x%08x\n", Status);
193 return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
194 }
195
196 lpNetworkEvents->lNetworkEvents = 0;
197
198 /* Set Events to wait for */
199 if (EnumReq.PollEvents & AFD_EVENT_RECEIVE) {
200 lpNetworkEvents->lNetworkEvents |= FD_READ;
201 lpNetworkEvents->iErrorCode[FD_READ_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_READ_BIT]);
202 }
203
204 if (EnumReq.PollEvents & AFD_EVENT_SEND) {
205 lpNetworkEvents->lNetworkEvents |= FD_WRITE;
206 lpNetworkEvents->iErrorCode[FD_WRITE_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_WRITE_BIT]);
207 }
208
209 if (EnumReq.PollEvents & AFD_EVENT_OOB_RECEIVE) {
210 lpNetworkEvents->lNetworkEvents |= FD_OOB;
211 lpNetworkEvents->iErrorCode[FD_OOB_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_OOB_BIT]);
212 }
213
214 if (EnumReq.PollEvents & AFD_EVENT_ACCEPT) {
215 lpNetworkEvents->lNetworkEvents |= FD_ACCEPT;
216 lpNetworkEvents->iErrorCode[FD_ACCEPT_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_ACCEPT_BIT]);
217 }
218
219 if (EnumReq.PollEvents &
221 lpNetworkEvents->lNetworkEvents |= FD_CONNECT;
222 lpNetworkEvents->iErrorCode[FD_CONNECT_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_CONNECT_BIT]);
223 }
224
225 if (EnumReq.PollEvents &
227 lpNetworkEvents->lNetworkEvents |= FD_CLOSE;
228 lpNetworkEvents->iErrorCode[FD_CLOSE_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_CLOSE_BIT]);
229 }
230
231 if (EnumReq.PollEvents & AFD_EVENT_QOS) {
232 lpNetworkEvents->lNetworkEvents |= FD_QOS;
233 lpNetworkEvents->iErrorCode[FD_QOS_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_QOS_BIT]);
234 }
235
236 if (EnumReq.PollEvents & AFD_EVENT_GROUP_QOS) {
237 lpNetworkEvents->lNetworkEvents |= FD_GROUP_QOS;
238 lpNetworkEvents->iErrorCode[FD_GROUP_QOS_BIT] = TranslateNtStatusError(EnumReq.EventStatus[FD_GROUP_QOS_BIT]);
239 }
240
241 TRACE("Leaving\n");
242
243 return MsafdReturnWithErrno(STATUS_SUCCESS, lpErrno, 0, NULL);
244}
INT TranslateNtStatusError(NTSTATUS Status)
Definition: dllmain.c:537
#define IOCTL_AFD_ENUM_NETWORK_EVENTS
Definition: shared.h:335
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS EventStatus[AFD_MAX_EVENTS]
Definition: shared.h:132
#define FD_CONNECT_BIT
Definition: winsock2.h:301
#define FD_CLOSE_BIT
Definition: winsock2.h:303
#define FD_OOB_BIT
Definition: winsock2.h:297
#define FD_GROUP_QOS_BIT
Definition: winsock2.h:307
#define FD_ACCEPT_BIT
Definition: winsock2.h:299
#define FD_READ_BIT
Definition: winsock2.h:293
#define FD_QOS_BIT
Definition: winsock2.h:305
#define FD_WRITE_BIT
Definition: winsock2.h:295

Referenced by WSPStartup().

◆ WSPEventSelect()

INT WSPAPI WSPEventSelect ( IN SOCKET  s,
IN WSAEVENT  hEventObject,
IN LONG  lNetworkEvents,
OUT LPINT  lpErrno 
)

Definition at line 17 of file event.c.

22{
23 IO_STATUS_BLOCK IOSB;
24 AFD_EVENT_SELECT_INFO EventSelectInfo;
27 BOOLEAN BlockMode;
29
30 TRACE("WSPEventSelect (%lx) %lx %lx\n", Handle, hEventObject, lNetworkEvents);
31
32 /* Get the Socket Structure associate to this Socket*/
33 Socket = GetSocketStructure(Handle);
34 if (!Socket)
35 {
36 if (lpErrno) *lpErrno = WSAENOTSOCK;
37 return SOCKET_ERROR;
38 }
39
42
43 if (!NT_SUCCESS(Status)) return SOCKET_ERROR;
44
45 /* Set Socket to Non-Blocking */
46 BlockMode = TRUE;
48 Socket->SharedData->NonBlocking = TRUE;
49
50 /* Deactivate Async Select if there is one */
51 if (Socket->EventObject) {
52 Socket->SharedData->hWnd = NULL;
53 Socket->SharedData->wMsg = 0;
54 Socket->SharedData->AsyncEvents = 0;
55 Socket->SharedData->SequenceNumber++; // This will kill Async Select after the next completion
56 }
57
58 /* Set Structure Info */
59 EventSelectInfo.EventObject = hEventObject;
60 EventSelectInfo.Events = 0;
61
62 /* Set Events to wait for */
63 if (lNetworkEvents & FD_READ) {
64 EventSelectInfo.Events |= AFD_EVENT_RECEIVE;
65 }
66
67 if (lNetworkEvents & FD_WRITE) {
68 EventSelectInfo.Events |= AFD_EVENT_SEND;
69 }
70
71 if (lNetworkEvents & FD_OOB) {
72 EventSelectInfo.Events |= AFD_EVENT_OOB_RECEIVE;
73 }
74
75 if (lNetworkEvents & FD_ACCEPT) {
76 EventSelectInfo.Events |= AFD_EVENT_ACCEPT;
77 }
78
79 if (lNetworkEvents & FD_CONNECT) {
81 }
82
83 if (lNetworkEvents & FD_CLOSE) {
85 }
86
87 if (lNetworkEvents & FD_QOS) {
88 EventSelectInfo.Events |= AFD_EVENT_QOS;
89 }
90
91 if (lNetworkEvents & FD_GROUP_QOS) {
92 EventSelectInfo.Events |= AFD_EVENT_GROUP_QOS;
93 }
94
95 /* Send IOCTL */
98 NULL,
99 NULL,
100 &IOSB,
102 &EventSelectInfo,
103 sizeof(EventSelectInfo),
104 NULL,
105 0);
106
107 /* Wait for return */
108 if (Status == STATUS_PENDING) {
110 Status = IOSB.Status;
111 }
112
114
115 if (Status != STATUS_SUCCESS)
116 {
117 ERR("Got status 0x%08x.\n", Status);
118 return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
119 }
120
121 /* Set Socket Data*/
122 Socket->EventObject = hEventObject;
123 Socket->NetworkEvents = lNetworkEvents;
124
125 TRACE("Leaving\n");
126
127 return 0;
128}
#define IOCTL_AFD_EVENT_SELECT
Definition: shared.h:329
LONG NetworkEvents
Definition: msafd.h:111
HANDLE EventObject
Definition: msafd.h:110

Referenced by WSPAsyncSelect(), and WSPStartup().

◆ WSPGetOverlappedResult()

BOOL WSPAPI WSPGetOverlappedResult ( IN SOCKET  s,
IN LPWSAOVERLAPPED  lpOverlapped,
OUT LPDWORD  lpcbTransfer,
IN BOOL  fWait,
OUT LPDWORD  lpdwFlags,
OUT LPINT  lpErrno 
)

Definition at line 96 of file sndrcv.c.

103{
104 PSOCKET_INFORMATION Socket;
105 BOOL Ret;
106
107 TRACE("Called (%x)\n", Handle);
108
109 /* Get the Socket Structure associate to this Socket*/
110 Socket = GetSocketStructure(Handle);
111 if (!Socket)
112 {
113 if(lpErrno)
114 *lpErrno = WSAENOTSOCK;
115 return FALSE;
116 }
117 if (!lpOverlapped || !lpdwBytes || !lpdwFlags)
118 {
119 if (lpErrno)
120 *lpErrno = WSAEFAULT;
121 return FALSE;
122 }
123 Ret = GetOverlappedResult((HANDLE)Handle, lpOverlapped, lpdwBytes, fWait);
124
125 if (Ret)
126 {
127 *lpdwFlags = 0;
128
129 /* Re-enable Async Event */
133 }
134
135 return Ret;
136}
VOID SockReenableAsyncSelectEvent(IN PSOCKET_INFORMATION Socket, IN ULONG Event)
Definition: dllmain.c:3996
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93

Referenced by WSPStartup().

◆ WSPGetPeerName()

INT WSPAPI WSPGetPeerName ( IN SOCKET  s,
OUT LPSOCKADDR  name,
IN OUT LPINT  namelen,
OUT LPINT  lpErrno 
)

Definition at line 2258 of file dllmain.c.

2262{
2263 IO_STATUS_BLOCK IOSB;
2264 ULONG TdiAddressSize;
2265 PTRANSPORT_ADDRESS SocketAddress;
2266 PSOCKET_INFORMATION Socket = NULL;
2269
2270 /* Get the Socket Structure associate to this Socket*/
2271 Socket = GetSocketStructure(s);
2272 if (!Socket)
2273 {
2274 if (lpErrno) *lpErrno = WSAENOTSOCK;
2275 return SOCKET_ERROR;
2276 }
2277
2278 if (Socket->SharedData->State != SocketConnected)
2279 {
2280 if (lpErrno) *lpErrno = WSAENOTCONN;
2281 return SOCKET_ERROR;
2282 }
2283
2284 if (!Name || !NameLength)
2285 {
2286 if (lpErrno) *lpErrno = WSAEFAULT;
2287 return SOCKET_ERROR;
2288 }
2289
2292 NULL,
2294 FALSE);
2295
2296 if( !NT_SUCCESS(Status) )
2297 return SOCKET_ERROR;
2298
2299 /* Allocate a buffer for the address */
2300 TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + Socket->SharedData->SizeOfRemoteAddress;
2301 SocketAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize);
2302
2303 if ( SocketAddress == NULL )
2304 {
2305 NtClose( SockEvent );
2306 if (lpErrno) *lpErrno = WSAENOBUFS;
2307 return SOCKET_ERROR;
2308 }
2309
2310 /* Send IOCTL */
2312 SockEvent,
2313 NULL,
2314 NULL,
2315 &IOSB,
2317 NULL,
2318 0,
2319 SocketAddress,
2320 TdiAddressSize);
2321
2322 /* Wait for return */
2323 if (Status == STATUS_PENDING)
2324 {
2326 Status = IOSB.Status;
2327 }
2328
2329 NtClose( SockEvent );
2330
2331 if (NT_SUCCESS(Status))
2332 {
2333 if (*NameLength >= Socket->SharedData->SizeOfRemoteAddress)
2334 {
2335 Name->sa_family = SocketAddress->Address[0].AddressType;
2336 RtlCopyMemory (Name->sa_data,
2337 SocketAddress->Address[0].Address,
2338 SocketAddress->Address[0].AddressLength);
2339 *NameLength = Socket->SharedData->SizeOfRemoteAddress;
2340 TRACE("NameLength %d Address: %x Port %x\n",
2341 *NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr,
2342 ((struct sockaddr_in *)Name)->sin_port);
2343 HeapFree(GlobalHeap, 0, SocketAddress);
2344 return 0;
2345 }
2346 else
2347 {
2348 HeapFree(GlobalHeap, 0, SocketAddress);
2349 if (lpErrno) *lpErrno = WSAEFAULT;
2350 return SOCKET_ERROR;
2351 }
2352 }
2353
2354 HeapFree(GlobalHeap, 0, SocketAddress);
2355
2356 return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL );
2357}
GLdouble s
Definition: gl.h:2039
#define IOCTL_AFD_GET_PEER_NAME
Definition: shared.h:291
INT SizeOfRemoteAddress
Definition: msafd.h:60
UCHAR Address[1]
Definition: tdi.h:340
USHORT AddressLength
Definition: tdi.h:338
USHORT AddressType
Definition: tdi.h:339
TA_ADDRESS Address[1]
Definition: tdi.h:377
struct _TRANSPORT_ADDRESS TRANSPORT_ADDRESS
#define WSAENOBUFS
Definition: winerror.h:1968
#define WSAENOTCONN
Definition: winerror.h:1970

Referenced by WSPStartup().

◆ WSPGetQOSByName()

BOOL WSPAPI WSPGetQOSByName ( IN SOCKET  s,
IN OUT LPWSABUF  lpQOSName,
OUT LPQOS  lpQOS,
OUT LPINT  lpErrno 
)

Definition at line 26 of file stubs.c.

31{
33
34 return FALSE;
35}

Referenced by WSPStartup().

◆ WSPGetSockName()

INT WSPAPI WSPGetSockName ( IN SOCKET  s,
OUT LPSOCKADDR  name,
IN OUT LPINT  namelen,
OUT LPINT  lpErrno 
)

Definition at line 2156 of file dllmain.c.

2160{
2161 IO_STATUS_BLOCK IOSB;
2162 ULONG TdiAddressSize;
2163 PTDI_ADDRESS_INFO TdiAddress;
2164 PTRANSPORT_ADDRESS SocketAddress;
2165 PSOCKET_INFORMATION Socket = NULL;
2168
2169 /* Get the Socket Structure associate to this Socket*/
2170 Socket = GetSocketStructure(Handle);
2171 if (!Socket)
2172 {
2173 if (lpErrno) *lpErrno = WSAENOTSOCK;
2174 return SOCKET_ERROR;
2175 }
2176
2177 if (!Name || !NameLength)
2178 {
2179 if (lpErrno) *lpErrno = WSAEFAULT;
2180 return SOCKET_ERROR;
2181 }
2182
2185 NULL,
2187 FALSE);
2188
2189 if( !NT_SUCCESS(Status) )
2190 return SOCKET_ERROR;
2191
2192 /* Allocate a buffer for the address */
2193 TdiAddressSize =
2195 TdiAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize);
2196
2197 if ( TdiAddress == NULL )
2198 {
2199 NtClose( SockEvent );
2200 if (lpErrno) *lpErrno = WSAENOBUFS;
2201 return SOCKET_ERROR;
2202 }
2203
2204 SocketAddress = &TdiAddress->Address;
2205
2206 /* Send IOCTL */
2208 SockEvent,
2209 NULL,
2210 NULL,
2211 &IOSB,
2213 NULL,
2214 0,
2215 TdiAddress,
2216 TdiAddressSize);
2217
2218 /* Wait for return */
2219 if (Status == STATUS_PENDING)
2220 {
2222 Status = IOSB.Status;
2223 }
2224
2225 NtClose( SockEvent );
2226
2227 if (NT_SUCCESS(Status))
2228 {
2229 if (*NameLength >= Socket->SharedData->SizeOfLocalAddress)
2230 {
2231 Name->sa_family = SocketAddress->Address[0].AddressType;
2232 RtlCopyMemory (Name->sa_data,
2233 SocketAddress->Address[0].Address,
2234 SocketAddress->Address[0].AddressLength);
2235 *NameLength = Socket->SharedData->SizeOfLocalAddress;
2236 TRACE("NameLength %d Address: %x Port %x\n",
2237 *NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr,
2238 ((struct sockaddr_in *)Name)->sin_port);
2239 HeapFree(GlobalHeap, 0, TdiAddress);
2240 return 0;
2241 }
2242 else
2243 {
2244 HeapFree(GlobalHeap, 0, TdiAddress);
2245 if (lpErrno) *lpErrno = WSAEFAULT;
2246 return SOCKET_ERROR;
2247 }
2248 }
2249
2250 HeapFree(GlobalHeap, 0, TdiAddress);
2251
2252 return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL );
2253}
#define IOCTL_AFD_GET_SOCK_NAME
Definition: shared.h:289
INT SizeOfLocalAddress
Definition: msafd.h:59
TRANSPORT_ADDRESS Address
Definition: tdi.h:388

Referenced by WSPStartup().

◆ WSPGetSockOpt()

INT WSPAPI WSPGetSockOpt ( IN SOCKET  s,
IN INT  level,
IN INT  optname,
OUT CHAR FAR optval,
IN OUT LPINT  optlen,
OUT LPINT  lpErrno 
)

Definition at line 2609 of file dllmain.c.

2615{
2616 PSOCKET_INFORMATION Socket = NULL;
2617 PVOID Buffer;
2619 BOOL BoolBuffer;
2620 DWORD DwordBuffer;
2621 INT Errno;
2622
2623 TRACE("Called\n");
2624
2625 /* Get the Socket Structure associate to this Socket*/
2626 Socket = GetSocketStructure(Handle);
2627 if (Socket == NULL)
2628 {
2629 if (lpErrno) *lpErrno = WSAENOTSOCK;
2630 return SOCKET_ERROR;
2631 }
2632 if (!OptionLength || !OptionValue)
2633 {
2634 if (lpErrno) *lpErrno = WSAEFAULT;
2635 return SOCKET_ERROR;
2636 }
2637
2638 switch (Level)
2639 {
2640 case SOL_SOCKET:
2641 switch (OptionName)
2642 {
2643 case SO_TYPE:
2644 Buffer = &Socket->SharedData->SocketType;
2645 BufferSize = sizeof(INT);
2646 break;
2647
2648 case SO_RCVBUF:
2650 BufferSize = sizeof(ULONG);
2651 break;
2652
2653 case SO_SNDBUF:
2655 BufferSize = sizeof(ULONG);
2656 break;
2657
2658 case SO_ACCEPTCONN:
2659 BoolBuffer = Socket->SharedData->Listening;
2660 Buffer = &BoolBuffer;
2661 BufferSize = sizeof(BOOL);
2662 break;
2663
2664 case SO_BROADCAST:
2665 BoolBuffer = Socket->SharedData->Broadcast;
2666 Buffer = &BoolBuffer;
2667 BufferSize = sizeof(BOOL);
2668 break;
2669
2670 case SO_DEBUG:
2671 BoolBuffer = Socket->SharedData->Debug;
2672 Buffer = &BoolBuffer;
2673 BufferSize = sizeof(BOOL);
2674 break;
2675
2676 case SO_DONTLINGER:
2677 BoolBuffer = (Socket->SharedData->LingerData.l_onoff == 0);
2678 Buffer = &BoolBuffer;
2679 BufferSize = sizeof(BOOL);
2680 break;
2681
2682 case SO_LINGER:
2683 if (Socket->SharedData->SocketType == SOCK_DGRAM)
2684 {
2685 if (lpErrno) *lpErrno = WSAENOPROTOOPT;
2686 return SOCKET_ERROR;
2687 }
2688 Buffer = &Socket->SharedData->LingerData;
2689 BufferSize = sizeof(struct linger);
2690 break;
2691
2692 case SO_OOBINLINE:
2693 BoolBuffer = (Socket->SharedData->OobInline != 0);
2694 Buffer = &BoolBuffer;
2695 BufferSize = sizeof(BOOL);
2696 break;
2697
2698 case SO_KEEPALIVE:
2699 case SO_DONTROUTE:
2700 /* These guys go directly to the helper */
2701 goto SendToHelper;
2702
2704 BoolBuffer = (Socket->SharedData->UseDelayedAcceptance != 0);
2705 Buffer = &BoolBuffer;
2706 BufferSize = sizeof(BOOL);
2707 break;
2708
2709 case SO_REUSEADDR:
2710 BoolBuffer = (Socket->SharedData->ReuseAddresses != 0);
2711 Buffer = &BoolBuffer;
2712 BufferSize = sizeof(BOOL);
2713 break;
2714
2716 BoolBuffer = (Socket->SharedData->ExclusiveAddressUse != 0);
2717 Buffer = &BoolBuffer;
2718 BufferSize = sizeof(BOOL);
2719 break;
2720
2721 case SO_ERROR:
2722 Buffer = &Socket->SharedData->SocketLastError;
2723 BufferSize = sizeof(INT);
2724 break;
2725
2726 case SO_CONNECT_TIME:
2727 DwordBuffer = GetCurrentTimeInSeconds() - Socket->SharedData->ConnectTime;
2728 Buffer = &DwordBuffer;
2729 BufferSize = sizeof(DWORD);
2730 break;
2731
2732 case SO_SNDTIMEO:
2733 Buffer = &Socket->SharedData->SendTimeout;
2734 BufferSize = sizeof(DWORD);
2735 break;
2736 case SO_RCVTIMEO:
2737 Buffer = &Socket->SharedData->RecvTimeout;
2738 BufferSize = sizeof(DWORD);
2739 break;
2740 case SO_PROTOCOL_INFOW:
2741 Buffer = &Socket->ProtocolInfo;
2742 BufferSize = sizeof(Socket->ProtocolInfo);
2743 break;
2744
2745 case SO_GROUP_ID:
2746 case SO_GROUP_PRIORITY:
2747 case SO_MAX_MSG_SIZE:
2748
2749 default:
2750 DbgPrint("MSAFD: Get unknown optname %x\n", OptionName);
2751 if (lpErrno) *lpErrno = WSAENOPROTOOPT;
2752 return SOCKET_ERROR;
2753 }
2754
2755 if (*OptionLength < BufferSize)
2756 {
2757 if (lpErrno) *lpErrno = WSAEFAULT;
2758 *OptionLength = BufferSize;
2759 return SOCKET_ERROR;
2760 }
2761 RtlCopyMemory(OptionValue, Buffer, BufferSize);
2762
2763 return 0;
2764
2765 default:
2766 if (lpErrno) *lpErrno = WSAEINVAL;
2767 return SOCKET_ERROR;
2768 }
2769
2770SendToHelper:
2771 Errno = Socket->HelperData->WSHGetSocketInformation(Socket->HelperContext,
2772 Handle,
2773 Socket->TdiAddressHandle,
2774 Socket->TdiConnectionHandle,
2775 Level,
2776 OptionName,
2777 OptionValue,
2778 (LPINT)OptionLength);
2779 if (lpErrno) *lpErrno = Errno;
2780 return (Errno == NO_ERROR) ? NO_ERROR : SOCKET_ERROR;
2781}
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
DWORD GetCurrentTimeInSeconds(VOID)
Definition: dllmain.c:1417
#define DbgPrint
Definition: hal.h:12
#define SO_CONNECT_TIME
Definition: mswsock.h:36
#define BOOL
Definition: nt_native.h:43
#define INT
Definition: polytest.cpp:20
BOOLEAN Broadcast
Definition: msafd.h:69
BOOLEAN Debug
Definition: msafd.h:70
ULONG RecvTimeout
Definition: msafd.h:63
BOOLEAN ExclusiveAddressUse
Definition: msafd.h:73
BOOLEAN OobInline
Definition: msafd.h:71
ULONG SizeOfSendBuffer
Definition: msafd.h:65
BOOLEAN ReuseAddresses
Definition: msafd.h:72
ULONG SizeOfRecvBuffer
Definition: msafd.h:64
INT SocketLastError
Definition: msafd.h:87
ULONG SendTimeout
Definition: msafd.h:62
BOOLEAN Listening
Definition: msafd.h:68
BOOLEAN UseDelayedAcceptance
Definition: msafd.h:78
ULONG ConnectTime
Definition: msafd.h:66
int32_t INT
Definition: typedefs.h:58
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
int * LPINT
Definition: windef.h:178
#define WSAENOPROTOOPT
Definition: winerror.h:1955
#define SO_PROTOCOL_INFOW
Definition: winsock2.h:249
#define SO_ERROR
Definition: winsock.h:194
#define SO_KEEPALIVE
Definition: winsock.h:181
#define SO_RCVBUF
Definition: winsock.h:189
#define SO_OOBINLINE
Definition: winsock.h:186
#define SO_DONTROUTE
Definition: winsock.h:182
#define SO_ACCEPTCONN
Definition: winsock.h:179
#define SOCK_DGRAM
Definition: winsock.h:336
#define SO_LINGER
Definition: winsock.h:185
#define SO_REUSEADDR
Definition: winsock.h:180
#define SO_TYPE
Definition: winsock.h:195
#define SOL_SOCKET
Definition: winsock.h:398
#define SO_DEBUG
Definition: winsock.h:178
#define SO_SNDTIMEO
Definition: winsock.h:192
#define SO_BROADCAST
Definition: winsock.h:183
#define SO_DONTLINGER
Definition: winsock.h:187
#define SO_RCVTIMEO
Definition: winsock.h:193
#define SO_SNDBUF
Definition: winsock.h:188
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
#define SO_CONDITIONAL_ACCEPT
Definition: ws2def.h:121
#define SO_EXCLUSIVEADDRUSE
Definition: ws2def.h:105
#define SO_GROUP_ID
Definition: ws2def.h:117
#define SO_MAX_MSG_SIZE
Definition: ws2def.h:119
#define SO_GROUP_PRIORITY
Definition: ws2def.h:118

Referenced by WSPStartup().

◆ WSPIoctl()

INT WSPAPI WSPIoctl ( 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,
IN LPWSATHREADID  lpThreadId,
OUT LPINT  lpErrno 
)

Definition at line 2361 of file dllmain.c.

2372{
2373 PSOCKET_INFORMATION Socket = NULL;
2374 BOOL NeedsCompletion = lpOverlapped != NULL;
2375 BOOLEAN NonBlocking;
2376 INT Errno = NO_ERROR, Ret = SOCKET_ERROR;
2377 DWORD cbRet = 0;
2378
2379 /* Get the Socket Structure associate to this Socket*/
2380 Socket = GetSocketStructure(Handle);
2381 if (!Socket)
2382 {
2383 if(lpErrno)
2384 *lpErrno = WSAENOTSOCK;
2385 return SOCKET_ERROR;
2386 }
2387
2388 if (!lpcbBytesReturned && !lpOverlapped)
2389 {
2390 if(lpErrno)
2391 *lpErrno = WSAEFAULT;
2392 return SOCKET_ERROR;
2393 }
2394
2395 switch( dwIoControlCode )
2396 {
2397 case FIONBIO:
2398 if( cbInBuffer < sizeof(INT) || IS_INTRESOURCE(lpvInBuffer) )
2399 {
2400 Errno = WSAEFAULT;
2401 break;
2402 }
2403 NonBlocking = *((PULONG)lpvInBuffer) ? TRUE : FALSE;
2404 /* Don't allow to go in blocking mode if WSPAsyncSelect or WSPEventSelect is pending */
2405 if (!NonBlocking)
2406 {
2407 /* If there is an WSPAsyncSelect pending, fail with WSAEINVAL */
2408 if (Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents))
2409 {
2410 Errno = WSAEINVAL;
2411 break;
2412 }
2413 /* If there is an WSPEventSelect pending, fail with WSAEINVAL */
2414 if (Socket->NetworkEvents)
2415 {
2416 Errno = WSAEINVAL;
2417 break;
2418 }
2419 }
2420 Socket->SharedData->NonBlocking = NonBlocking ? 1 : 0;
2421 NeedsCompletion = FALSE;
2422 Errno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &NonBlocking, NULL, NULL, lpOverlapped, lpCompletionRoutine);
2423 if (Errno == NO_ERROR)
2424 Ret = NO_ERROR;
2425 break;
2426 case FIONREAD:
2427 if (IS_INTRESOURCE(lpvOutBuffer) || cbOutBuffer == 0)
2428 {
2429 cbRet = sizeof(ULONG);
2430 Errno = WSAEFAULT;
2431 break;
2432 }
2433 if (cbOutBuffer < sizeof(ULONG))
2434 {
2435 Errno = WSAEINVAL;
2436 break;
2437 }
2438 NeedsCompletion = FALSE;
2439 Errno = GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE, NULL, (PULONG)lpvOutBuffer, NULL, lpOverlapped, lpCompletionRoutine);
2440 if (Errno == NO_ERROR)
2441 {
2442 cbRet = sizeof(ULONG);
2443 Ret = NO_ERROR;
2444 }
2445 break;
2446 case SIOCATMARK:
2447 if (IS_INTRESOURCE(lpvOutBuffer) || cbOutBuffer == 0)
2448 {
2449 cbRet = sizeof(BOOL);
2450 Errno = WSAEFAULT;
2451 break;
2452 }
2453 if (cbOutBuffer < sizeof(BOOL))
2454 {
2455 Errno = WSAEINVAL;
2456 break;
2457 }
2458 if (Socket->SharedData->SocketType != SOCK_STREAM)
2459 {
2460 Errno = WSAEINVAL;
2461 break;
2462 }
2463
2464 /* FIXME: Return false if OOBINLINE is true for now
2465 We should MSG_PEEK|MSG_OOB check with driver
2466 */
2467 *(BOOL*)lpvOutBuffer = !Socket->SharedData->OobInline;
2468
2469 cbRet = sizeof(BOOL);
2470 Errno = NO_ERROR;
2471 Ret = NO_ERROR;
2472 break;
2474 if (cbOutBuffer == 0)
2475 {
2476 cbRet = sizeof(PVOID);
2477 Errno = WSAEFAULT;
2478 break;
2479 }
2480
2481 if (cbInBuffer < sizeof(GUID) ||
2482 cbOutBuffer < sizeof(PVOID))
2483 {
2484 Errno = WSAEINVAL;
2485 break;
2486 }
2487
2488 {
2489 GUID AcceptExGUID = WSAID_ACCEPTEX;
2490 GUID ConnectExGUID = WSAID_CONNECTEX;
2491 GUID DisconnectExGUID = WSAID_DISCONNECTEX;
2492 GUID GetAcceptExSockaddrsGUID = WSAID_GETACCEPTEXSOCKADDRS;
2493
2494 if (IsEqualGUID(&AcceptExGUID, lpvInBuffer))
2495 {
2496 *((PVOID *)lpvOutBuffer) = WSPAcceptEx;
2497 cbRet = sizeof(PVOID);
2498 Errno = NO_ERROR;
2499 Ret = NO_ERROR;
2500 }
2501 else if (IsEqualGUID(&ConnectExGUID, lpvInBuffer))
2502 {
2503 *((PVOID *)lpvOutBuffer) = WSPConnectEx;
2504 cbRet = sizeof(PVOID);
2505 Errno = NO_ERROR;
2506 Ret = NO_ERROR;
2507 }
2508 else if (IsEqualGUID(&DisconnectExGUID, lpvInBuffer))
2509 {
2510 *((PVOID *)lpvOutBuffer) = WSPDisconnectEx;
2511 cbRet = sizeof(PVOID);
2512 Errno = NO_ERROR;
2513 Ret = NO_ERROR;
2514 }
2515 else if (IsEqualGUID(&GetAcceptExSockaddrsGUID, lpvInBuffer))
2516 {
2517 *((PVOID *)lpvOutBuffer) = WSPGetAcceptExSockaddrs;
2518 cbRet = sizeof(PVOID);
2519 Errno = NO_ERROR;
2520 /* See CORE-14966 and associated commits.
2521 * Original line below was 'Ret = NO_ERROR:'.
2522 * This caused winetest ws2_32:sock to hang.
2523 * This new Ret value allows the test to complete. */
2524 ERR("SIO_GET_EXTENSION_FUNCTION_POINTER UNIMPLEMENTED\n");
2525 Ret = SOCKET_ERROR;
2526 }
2527 else
2528 {
2529 ERR("Querying unknown extension function: %x\n", ((GUID*)lpvInBuffer)->Data1);
2530 Errno = WSAEOPNOTSUPP;
2531 }
2532 }
2533
2534 break;
2536 if (IS_INTRESOURCE(lpvOutBuffer) || cbOutBuffer == 0)
2537 {
2538 cbRet = sizeof(SOCKET_ADDRESS_LIST) + sizeof(Socket->SharedData->WSLocalAddress);
2539 Errno = WSAEFAULT;
2540 break;
2541 }
2542 if (cbOutBuffer < sizeof(INT))
2543 {
2544 Errno = WSAEINVAL;
2545 break;
2546 }
2547
2548 cbRet = sizeof(SOCKET_ADDRESS_LIST) + sizeof(Socket->SharedData->WSLocalAddress);
2549
2550 ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->iAddressCount = 1;
2551
2552 if (cbOutBuffer < (sizeof(SOCKET_ADDRESS_LIST) + sizeof(Socket->SharedData->WSLocalAddress)))
2553 {
2554 Errno = WSAEFAULT;
2555 break;
2556 }
2557
2558 ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->Address[0].iSockaddrLength = sizeof(Socket->SharedData->WSLocalAddress);
2559 ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->Address[0].lpSockaddr = &Socket->SharedData->WSLocalAddress;
2560
2561 Errno = NO_ERROR;
2562 Ret = NO_ERROR;
2563 break;
2564 default:
2565 Errno = Socket->HelperData->WSHIoctl(Socket->HelperContext,
2566 Handle,
2567 Socket->TdiAddressHandle,
2568 Socket->TdiConnectionHandle,
2570 lpvInBuffer,
2571 cbInBuffer,
2572 lpvOutBuffer,
2573 cbOutBuffer,
2574 &cbRet,
2576 lpCompletionRoutine,
2577 &NeedsCompletion);
2578
2579 if (Errno == NO_ERROR)
2580 Ret = NO_ERROR;
2581 break;
2582 }
2583 if (lpOverlapped && NeedsCompletion)
2584 {
2585 lpOverlapped->Internal = Errno;
2586 lpOverlapped->InternalHigh = cbRet;
2587 if (lpCompletionRoutine != NULL)
2588 {
2589 lpCompletionRoutine(Errno, cbRet, lpOverlapped, 0);
2590 }
2591 if (lpOverlapped->hEvent)
2592 SetEvent(lpOverlapped->hEvent);
2594 {
2595 ERR("PostQueuedCompletionStatus failed %d\n", GetLastError());
2596 }
2597 return NO_ERROR;
2598 }
2599 if (lpErrno)
2600 *lpErrno = Errno;
2601 if (lpcbBytesReturned)
2602 *lpcbBytesReturned = cbRet;
2603 return Ret;
2604}
BOOL WSPAPI WSPConnectEx(IN SOCKET s, IN const struct sockaddr *name, IN int namelen, IN PVOID lpSendBuffer, IN DWORD dwSendDataLength, OUT LPDWORD lpdwBytesSent, IN OUT LPOVERLAPPED lpOverlapped)
Definition: stubs.c:75
BOOL WSPAPI WSPAcceptEx(IN SOCKET sListenSocket, IN SOCKET sAcceptSocket, OUT PVOID lpOutputBuffer, IN DWORD dwReceiveDataLength, IN DWORD dwLocalAddressLength, IN DWORD dwRemoteAddressLength, OUT LPDWORD lpdwBytesReceived, IN OUT LPOVERLAPPED lpOverlapped)
Definition: stubs.c:58
VOID WSPAPI WSPGetAcceptExSockaddrs(IN PVOID lpOutputBuffer, IN DWORD dwReceiveDataLength, IN DWORD dwLocalAddressLength, IN DWORD dwRemoteAddressLength, OUT struct sockaddr **LocalSockaddr, OUT LPINT LocalSockaddrLength, OUT struct sockaddr **RemoteSockaddr, OUT LPINT RemoteSockaddrLength)
Definition: stubs.c:104
BOOL WSPAPI WSPDisconnectEx(IN SOCKET hSocket, IN LPOVERLAPPED lpOverlapped, IN DWORD dwFlags, IN DWORD reserved)
Definition: stubs.c:91
#define SOCK_STREAM
Definition: tcpip.h:118
BOOL WINAPI PostQueuedCompletionStatus(IN HANDLE CompletionHandle, IN DWORD dwNumberOfBytesTransferred, IN ULONG_PTR dwCompletionKey, IN LPOVERLAPPED lpOverlapped)
Definition: iocompl.c:192
#define WSAID_GETACCEPTEXSOCKADDRS
Definition: mswsock.h:77
#define WSAID_ACCEPTEX
Definition: mswsock.h:74
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define AFD_INFO_RECEIVE_CONTENT_SIZE
Definition: shared.h:188
SOCKADDR WSLocalAddress
Definition: msafd.h:94
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ DWORD dwIoControlCode
Definition: winddi.h:1700
#define WSAEOPNOTSUPP
Definition: winerror.h:1958
#define SIOCATMARK
Definition: winsock.h:253
#define FIONREAD
Definition: winsock.h:247
#define FIONBIO
Definition: winsock.h:149
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define SIO_ADDRESS_LIST_QUERY
Definition: ws2def.h:177
struct _SOCKET_ADDRESS_LIST SOCKET_ADDRESS_LIST
#define SIO_GET_EXTENSION_FUNCTION_POINTER
Definition: ws2def.h:167

Referenced by WSPStartup().

◆ WSPJoinLeaf()

SOCKET WSPAPI WSPJoinLeaf ( IN SOCKET  s,
IN CONST SOCKADDR name,
IN INT  namelen,
IN LPWSABUF  lpCallerData,
OUT LPWSABUF  lpCalleeData,
IN LPQOS  lpSQOS,
IN LPQOS  lpGQOS,
IN DWORD  dwFlags,
OUT LPINT  lpErrno 
)

Definition at line 40 of file stubs.c.

50{
52
53 return (SOCKET)0;
54}
UINT_PTR SOCKET
Definition: winsock.h:47

Referenced by WSPStartup().

◆ WSPListen()

INT WSPAPI WSPListen ( IN SOCKET  s,
IN INT  backlog,
OUT LPINT  lpErrno 
)

◆ WSPRecv()

INT WSPAPI WSPRecv ( IN SOCKET  s,
IN OUT LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesRecvd,
IN OUT LPDWORD  lpFlags,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine,
IN LPWSATHREADID  lpThreadId,
OUT LPINT  lpErrno 
)

◆ WSPRecvDisconnect()

INT WSPAPI WSPRecvDisconnect ( IN SOCKET  s,
OUT LPWSABUF  lpInboundDisconnectData,
OUT LPINT  lpErrno 
)

Definition at line 926 of file sndrcv.c.

929{
931 return 0;
932}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15

Referenced by WSPStartup().

◆ WSPRecvFrom()

INT WSPAPI WSPRecvFrom ( IN SOCKET  s,
IN OUT LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesRecvd,
IN OUT LPDWORD  lpFlags,
OUT LPSOCKADDR  lpFrom,
IN OUT LPINT  lpFromlen,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine,
IN LPWSATHREADID  lpThreadId,
OUT LPINT  lpErrno 
)

◆ WSPSelect()

INT WSPAPI WSPSelect ( IN INT  nfds,
IN OUT LPFD_SET  readfds,
IN OUT LPFD_SET  writefds,
IN OUT LPFD_SET  exceptfds,
IN CONST LPTIMEVAL  timeout,
OUT LPINT  lpErrno 
)

◆ WSPSend()

INT WSPAPI WSPSend ( IN SOCKET  s,
IN LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesSent,
IN DWORD  dwFlags,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine,
IN LPWSATHREADID  lpThreadId,
OUT LPINT  lpErrno 
)

◆ WSPSendDisconnect()

INT WSPAPI WSPSendDisconnect ( IN SOCKET  s,
IN LPWSABUF  lpOutboundDisconnectData,
OUT LPINT  lpErrno 
)

Definition at line 938 of file sndrcv.c.

941{
943 return 0;
944}

Referenced by WSPStartup().

◆ WSPSendTo()

INT WSPAPI WSPSendTo ( IN SOCKET  s,
IN LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesSent,
IN DWORD  dwFlags,
IN CONST SOCKADDR lpTo,
IN INT  iTolen,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine,
IN LPWSATHREADID  lpThreadId,
OUT LPINT  lpErrno 
)

◆ WSPSetSockOpt()

INT WSPAPI WSPSetSockOpt ( IN SOCKET  s,
IN INT  level,
IN INT  optname,
IN CONST CHAR FAR optval,
IN INT  optlen,
OUT LPINT  lpErrno 
)

Definition at line 2785 of file dllmain.c.

2792{
2793 PSOCKET_INFORMATION Socket;
2794 INT Errno;
2795
2796 /* Get the Socket Structure associate to this Socket*/
2797 Socket = GetSocketStructure(s);
2798 if (Socket == NULL)
2799 {
2800 if (lpErrno) *lpErrno = WSAENOTSOCK;
2801 return SOCKET_ERROR;
2802 }
2803 if (!optval)
2804 {
2805 if (lpErrno) *lpErrno = WSAEFAULT;
2806 return SOCKET_ERROR;
2807 }
2808
2809
2810 /* FIXME: We should handle some more cases here */
2811 if (level == SOL_SOCKET)
2812 {
2813 switch (optname)
2814 {
2815 case SO_BROADCAST:
2816 if (optlen < sizeof(BOOL))
2817 {
2818 if (lpErrno) *lpErrno = WSAEFAULT;
2819 return SOCKET_ERROR;
2820 }
2821 Socket->SharedData->Broadcast = (*optval != 0) ? 1 : 0;
2822 return NO_ERROR;
2823
2824 case SO_OOBINLINE:
2825 if (optlen < sizeof(BOOL))
2826 {
2827 if (lpErrno) *lpErrno = WSAEFAULT;
2828 return SOCKET_ERROR;
2829 }
2830 Socket->SharedData->OobInline = (*optval != 0) ? 1 : 0;
2831 return NO_ERROR;
2832
2833 case SO_DONTLINGER:
2834 if (optlen < sizeof(BOOL))
2835 {
2836 if (lpErrno) *lpErrno = WSAEFAULT;
2837 return SOCKET_ERROR;
2838 }
2839 Socket->SharedData->LingerData.l_onoff = (*optval != 0) ? 0 : 1;
2840 return NO_ERROR;
2841
2842 case SO_REUSEADDR:
2843 if (optlen < sizeof(BOOL))
2844 {
2845 if (lpErrno) *lpErrno = WSAEFAULT;
2846 return SOCKET_ERROR;
2847 }
2848 Socket->SharedData->ReuseAddresses = (*optval != 0) ? 1 : 0;
2849 return NO_ERROR;
2850
2852 if (optlen < sizeof(BOOL))
2853 {
2854 if (lpErrno) *lpErrno = WSAEFAULT;
2855 return SOCKET_ERROR;
2856 }
2857 Socket->SharedData->ExclusiveAddressUse = (*optval != 0) ? 1 : 0;
2858 return NO_ERROR;
2859
2860 case SO_LINGER:
2861 if (optlen < sizeof(struct linger))
2862 {
2863 if (lpErrno) *lpErrno = WSAEFAULT;
2864 return SOCKET_ERROR;
2865 }
2867 optval,
2868 sizeof(struct linger));
2869 return NO_ERROR;
2870
2871 case SO_SNDBUF:
2872 if (optlen < sizeof(ULONG))
2873 {
2874 if (lpErrno) *lpErrno = WSAEFAULT;
2875 return SOCKET_ERROR;
2876 }
2877
2878 SetSocketInformation(Socket,
2880 NULL,
2881 (PULONG)optval,
2882 NULL,
2883 NULL,
2884 NULL);
2885 GetSocketInformation(Socket,
2887 NULL,
2888 &Socket->SharedData->SizeOfSendBuffer,
2889 NULL,
2890 NULL,
2891 NULL);
2892
2893 return NO_ERROR;
2894
2895 case SO_RCVBUF:
2896 if (optlen < sizeof(ULONG))
2897 {
2898 if (lpErrno) *lpErrno = WSAEFAULT;
2899 return SOCKET_ERROR;
2900 }
2901
2902 /* FIXME: We should not have to limit the packet receive buffer size like this. workaround for CORE-15804 */
2903 if (*(PULONG)optval > 0x2000)
2904 *(PULONG)optval = 0x2000;
2905
2906 SetSocketInformation(Socket,
2908 NULL,
2909 (PULONG)optval,
2910 NULL,
2911 NULL,
2912 NULL);
2913 GetSocketInformation(Socket,
2915 NULL,
2916 &Socket->SharedData->SizeOfRecvBuffer,
2917 NULL,
2918 NULL,
2919 NULL);
2920
2921 return NO_ERROR;
2922
2923 case SO_ERROR:
2924 if (optlen < sizeof(INT))
2925 {
2926 if (lpErrno) *lpErrno = WSAEFAULT;
2927 return SOCKET_ERROR;
2928 }
2929
2931 optval,
2932 sizeof(INT));
2933 return NO_ERROR;
2934
2935 case SO_SNDTIMEO:
2936 if (optlen < sizeof(DWORD))
2937 {
2938 if (lpErrno) *lpErrno = WSAEFAULT;
2939 return SOCKET_ERROR;
2940 }
2941
2943 optval,
2944 sizeof(DWORD));
2945 return NO_ERROR;
2946
2947 case SO_RCVTIMEO:
2948 if (optlen < sizeof(DWORD))
2949 {
2950 if (lpErrno) *lpErrno = WSAEFAULT;
2951 return SOCKET_ERROR;
2952 }
2953
2955 optval,
2956 sizeof(DWORD));
2957 return NO_ERROR;
2958
2959 case SO_KEEPALIVE:
2960 case SO_DONTROUTE:
2961 /* These go directly to the helper dll */
2962 goto SendToHelper;
2963
2964 default:
2965 /* Obviously this is a hack */
2966 ERR("MSAFD: Set unknown optname %x\n", optname);
2967 return NO_ERROR;
2968 }
2969 }
2970
2971SendToHelper:
2972 Errno = Socket->HelperData->WSHSetSocketInformation(Socket->HelperContext,
2973 s,
2974 Socket->TdiAddressHandle,
2975 Socket->TdiConnectionHandle,
2976 level,
2977 optname,
2978 (PCHAR)optval,
2979 optlen);
2980 if (lpErrno) *lpErrno = Errno;
2981 return (Errno == NO_ERROR) ? NO_ERROR : SOCKET_ERROR;
2982}
GLint level
Definition: gl.h:1546
#define AFD_INFO_SEND_WINDOW_SIZE
Definition: shared.h:186
#define AFD_INFO_RECEIVE_WINDOW_SIZE
Definition: shared.h:185
char * PCHAR
Definition: typedefs.h:51

Referenced by WSPStartup().

◆ WSPShutdown()

INT WSPAPI WSPShutdown ( IN SOCKET  s,
IN INT  how,
OUT LPINT  lpErrno 
)

◆ WSPSocket()

SOCKET WSPAPI WSPSocket ( IN INT  af,
IN INT  type,
IN INT  protocol,
IN LPWSAPROTOCOL_INFOW  lpProtocolInfo,
IN GROUP  g,
IN DWORD  dwFlags,
OUT LPINT  lpErrno 
)

◆ WSPStringToAddress()

INT WSPAPI WSPStringToAddress ( IN LPWSTR  AddressString,
IN INT  AddressFamily,
IN LPWSAPROTOCOL_INFOW  lpProtocolInfo,
OUT LPSOCKADDR  lpAddress,
IN OUT LPINT  lpAddressLength,
OUT LPINT  lpErrno 
)

Definition at line 3123 of file dllmain.c.

3129{
3130 int numdots = 0;
3131 USHORT port;
3132 LONG inetaddr = 0, ip_part;
3133 LPWSTR *bp = NULL;
3135
3136 if (!lpAddressLength || !lpAddress || !AddressString)
3137 {
3138 if (lpErrno) *lpErrno = WSAEINVAL;
3139 return SOCKET_ERROR;
3140 }
3141
3142 sockaddr = (SOCKADDR_IN *)lpAddress;
3143
3144 /* Set right address family */
3145 if (lpProtocolInfo != NULL)
3146 {
3147 sockaddr->sin_family = lpProtocolInfo->iAddressFamily;
3148 }
3149 else
3150 {
3151 sockaddr->sin_family = AddressFamily;
3152 }
3153
3154 /* Report size */
3155 if (AddressFamily == AF_INET)
3156 {
3157 if (*lpAddressLength < (INT)sizeof(SOCKADDR_IN))
3158 {
3159 if (lpErrno) *lpErrno = WSAEFAULT;
3160 }
3161 else
3162 {
3163 // translate ip string to ip
3164
3165 /* Get ip number */
3166 bp = &AddressString;
3167 inetaddr = 0;
3168
3169 while (*bp < &AddressString[wcslen(AddressString)])
3170 {
3171 ip_part = wcstol(*bp, bp, 10);
3172 /* ip part number should be in range 0-255 */
3173 if (ip_part < 0 || ip_part > 255)
3174 {
3175 if (lpErrno) *lpErrno = WSAEINVAL;
3176 return SOCKET_ERROR;
3177 }
3178 inetaddr = (inetaddr << 8) + ip_part;
3179 /* we end on string end or port separator */
3180 if ((*bp)[0] == 0 || (*bp)[0] == L':')
3181 break;
3182 /* ip parts are dot separated. verify it */
3183 if ((*bp)[0] != L'.')
3184 {
3185 if (lpErrno) *lpErrno = WSAEINVAL;
3186 return SOCKET_ERROR;
3187 }
3188 /* count the dots */
3189 numdots++;
3190 /* move over the dot to next ip part */
3191 (*bp)++;
3192 }
3193
3194 /* check dots count */
3195 if (numdots != 3)
3196 {
3197 if (lpErrno) *lpErrno = WSAEINVAL;
3198 return SOCKET_ERROR;
3199 }
3200
3201 /* Get port number */
3202 if ((*bp)[0] == L':')
3203 {
3204 /* move over the column to port part */
3205 (*bp)++;
3206 /* next char should be numeric */
3207 if ((*bp)[0] < L'0' || (*bp)[0] > L'9')
3208 {
3209 if (lpErrno) *lpErrno = WSAEINVAL;
3210 return SOCKET_ERROR;
3211 }
3212 port = wcstol(*bp, bp, 10);
3213 }
3214 else
3215 {
3216 port = 0;
3217 }
3218
3219 if (lpErrno) *lpErrno = NO_ERROR;
3220 /* rest sockaddr.sin_addr.s_addr
3221 for we need to be sure it is zero when we come to while */
3222 *lpAddressLength = sizeof(*sockaddr);
3223 memset(lpAddress, 0, sizeof(*sockaddr));
3224 sockaddr->sin_family = AF_INET;
3225 sockaddr->sin_addr.s_addr = inetaddr;
3226 sockaddr->sin_port = port;
3227 }
3228 }
3229
3230 if (lpErrno && !*lpErrno)
3231 {
3232 return 0;
3233 }
3234
3235 return SOCKET_ERROR;
3236}
USHORT port
Definition: uri.c:228
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
unsigned short USHORT
Definition: pedump.c:61
#define memset(x, y, z)
Definition: compat.h:39
struct sockaddr_in SOCKADDR_IN
Definition: winsock.h:487
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WSPStartup().

Variable Documentation

◆ g_fRnrLockInit

BOOLEAN g_fRnrLockInit
extern

◆ g_RnrLock

CRITICAL_SECTION g_RnrLock
extern

◆ gWSM_NSPCallRef

LONG gWSM_NSPCallRef
extern

◆ gWSM_NSPStartupRef

LONG gWSM_NSPStartupRef
extern

◆ MSWSOCK_SocketLock

CRITICAL_SECTION MSWSOCK_SocketLock
extern

◆ NlsMsgSourcemModuleHandle

HINSTANCE NlsMsgSourcemModuleHandle
extern

◆ SockAllocateHeapRoutine

PRTL_HEAP_ALLOCATE SockAllocateHeapRoutine
extern

◆ SockAsyncQueuePort

HANDLE SockAsyncQueuePort
extern

◆ SockAsyncSelectCalled

BOOLEAN SockAsyncSelectCalled
extern

Definition at line 29 of file dllmain.c.

Referenced by SockGetAsyncSelectHelperAfdHandle().

◆ SockAsyncThreadReferenceCount

LONG SockAsyncThreadReferenceCount
extern

◆ SockBufferKeyTable

PVOID SockBufferKeyTable
extern

◆ SockBufferKeyTableSize

ULONG SockBufferKeyTableSize
extern

◆ SockContextTable

PWAH_HANDLE_TABLE SockContextTable
extern

◆ SocketGlobalLock

SOCK_RW_LOCK SocketGlobalLock
extern

◆ SockHelperDllListHead

LIST_ENTRY SockHelperDllListHead
extern

◆ SockModuleHandle

HINSTANCE SockModuleHandle
extern

◆ SockPrivateHeap

HANDLE SockPrivateHeap
extern

◆ SockProcessPendingAPCCount

LONG SockProcessPendingAPCCount
extern

◆ SockProcessTerminating

BOOL SockProcessTerminating
extern

Referenced by SockEnterApiFast().

◆ SockReceiveBufferWindow

DWORD SockReceiveBufferWindow
extern

◆ SockSanCleanUpCompleteEvent

HANDLE SockSanCleanUpCompleteEvent
extern

◆ SockSanEnabled

BOOLEAN SockSanEnabled
extern

◆ SockSendBufferWindow

DWORD SockSendBufferWindow
extern

◆ SockTcpProviderInfo

WSAPROTOCOL_INFOW SockTcpProviderInfo
extern

◆ SockUpcallTable

LPWSPUPCALLTABLE SockUpcallTable
extern

◆ SockWspStartupCount

LONG SockWspStartupCount
extern

Referenced by SockEnterApiFast().