ws2_32: Wrapped WSASendTo/WSARecvFrom with a different function name.

This commit is contained in:
Howell Tam 2010-07-18 10:53:06 +10:00 committed by Alexandre Julliard
parent 2c1e8decfc
commit 8b7ec05bd2
1 changed files with 63 additions and 21 deletions

View File

@ -169,6 +169,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(winsock); WINE_DEFAULT_DEBUG_CHANNEL(winsock);
WINE_DECLARE_DEBUG_CHANNEL(winediag); WINE_DECLARE_DEBUG_CHANNEL(winediag);
/*
* The actual definition of WSASendTo/WSARecvFrom, wrapped in a different
* function name, so that internal calls from ws2_32 itself will not trigger
* programs like Garena, which hooks WSASendTo/WSARecvFrom calls.
*/
static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent, DWORD dwFlags,
const struct WS_sockaddr *to, int tolen,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
static int WS2_recvfrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags,
struct WS_sockaddr *lpFrom,
LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
/* critical section to protect some non-reentrant net function */ /* critical section to protect some non-reentrant net function */
static CRITICAL_SECTION csWSgetXXXbyYYY; static CRITICAL_SECTION csWSgetXXXbyYYY;
static CRITICAL_SECTION_DEBUG critsect_debug = static CRITICAL_SECTION_DEBUG critsect_debug =
@ -2922,7 +2940,7 @@ int WINAPI WS_recv(SOCKET s, char *buf, int len, int flags)
wsabuf.len = len; wsabuf.len = len;
wsabuf.buf = buf; wsabuf.buf = buf;
if ( WSARecvFrom(s, &wsabuf, 1, &n, &dwFlags, NULL, NULL, NULL, NULL) == SOCKET_ERROR ) if ( WS2_recvfrom(s, &wsabuf, 1, &n, &dwFlags, NULL, NULL, NULL, NULL) == SOCKET_ERROR )
return SOCKET_ERROR; return SOCKET_ERROR;
else else
return n; return n;
@ -2940,7 +2958,7 @@ int WINAPI WS_recvfrom(SOCKET s, char *buf, INT len, int flags,
wsabuf.len = len; wsabuf.len = len;
wsabuf.buf = buf; wsabuf.buf = buf;
if ( WSARecvFrom(s, &wsabuf, 1, &n, &dwFlags, from, fromlen, NULL, NULL) == SOCKET_ERROR ) if ( WS2_recvfrom(s, &wsabuf, 1, &n, &dwFlags, from, fromlen, NULL, NULL) == SOCKET_ERROR )
return SOCKET_ERROR; return SOCKET_ERROR;
else else
return n; return n;
@ -3127,7 +3145,7 @@ int WINAPI WS_send(SOCKET s, const char *buf, int len, int flags)
wsabuf.len = len; wsabuf.len = len;
wsabuf.buf = (char*) buf; wsabuf.buf = (char*) buf;
if ( WSASendTo( s, &wsabuf, 1, &n, flags, NULL, 0, NULL, NULL) == SOCKET_ERROR ) if ( WS2_sendto( s, &wsabuf, 1, &n, flags, NULL, 0, NULL, NULL) == SOCKET_ERROR )
return SOCKET_ERROR; return SOCKET_ERROR;
else else
return n; return n;
@ -3141,7 +3159,7 @@ INT WINAPI WSASend( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine ) LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine )
{ {
return WSASendTo( s, lpBuffers, dwBufferCount, lpNumberOfBytesSent, dwFlags, return WS2_sendto( s, lpBuffers, dwBufferCount, lpNumberOfBytesSent, dwFlags,
NULL, 0, lpOverlapped, lpCompletionRoutine ); NULL, 0, lpOverlapped, lpCompletionRoutine );
} }
@ -3154,10 +3172,7 @@ INT WINAPI WSASendDisconnect( SOCKET s, LPWSABUF lpBuffers )
} }
/*********************************************************************** static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
* WSASendTo (WS2_32.74)
*/
INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent, DWORD dwFlags, LPDWORD lpNumberOfBytesSent, DWORD dwFlags,
const struct WS_sockaddr *to, int tolen, const struct WS_sockaddr *to, int tolen,
LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED lpOverlapped,
@ -3336,6 +3351,21 @@ error:
return SOCKET_ERROR; return SOCKET_ERROR;
} }
/***********************************************************************
* WSASendTo (WS2_32.74)
*/
INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent, DWORD dwFlags,
const struct WS_sockaddr *to, int tolen,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine )
{
return WS2_sendto( s, lpBuffers, dwBufferCount,
lpNumberOfBytesSent, dwFlags,
to, tolen,
lpOverlapped, lpCompletionRoutine );
}
/*********************************************************************** /***********************************************************************
* sendto (WS2_32.20) * sendto (WS2_32.20)
*/ */
@ -3348,7 +3378,7 @@ int WINAPI WS_sendto(SOCKET s, const char *buf, int len, int flags,
wsabuf.len = len; wsabuf.len = len;
wsabuf.buf = (char*) buf; wsabuf.buf = (char*) buf;
if ( WSASendTo(s, &wsabuf, 1, &n, flags, to, tolen, NULL, NULL) == SOCKET_ERROR ) if ( WS2_sendto(s, &wsabuf, 1, &n, flags, to, tolen, NULL, NULL) == SOCKET_ERROR )
return SOCKET_ERROR; return SOCKET_ERROR;
else else
return n; return n;
@ -4932,14 +4962,11 @@ int WINAPI WSARecv(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{ {
return WSARecvFrom(s, lpBuffers, dwBufferCount, NumberOfBytesReceived, lpFlags, return WS2_recvfrom(s, lpBuffers, dwBufferCount, NumberOfBytesReceived, lpFlags,
NULL, NULL, lpOverlapped, lpCompletionRoutine); NULL, NULL, lpOverlapped, lpCompletionRoutine);
} }
/*********************************************************************** static int WS2_recvfrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
* WSARecvFrom (WS2_32.69)
*/
INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, struct WS_sockaddr *lpFrom, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, struct WS_sockaddr *lpFrom,
LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped, LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine ) LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine )
@ -5095,6 +5122,21 @@ error:
return SOCKET_ERROR; return SOCKET_ERROR;
} }
/***********************************************************************
* WSARecvFrom (WS2_32.69)
*/
INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, struct WS_sockaddr *lpFrom,
LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine )
{
return WS2_recvfrom( s, lpBuffers, dwBufferCount,
lpNumberOfBytesRecvd, lpFlags,
lpFrom, lpFromlen,
lpOverlapped, lpCompletionRoutine );
}
/*********************************************************************** /***********************************************************************
* WSCInstallProvider (WS2_32.88) * WSCInstallProvider (WS2_32.88)
*/ */