Howell Tam : ws2_32: Wrapped WSASendTo/ WSARecvFrom with a different function name.
Alexandre Julliard
julliard at winehq.org
Mon Jul 19 11:05:40 CDT 2010
Module: wine
Branch: master
Commit: 8b7ec05bd20359662f4feb7ef68a283b464bd03a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8b7ec05bd20359662f4feb7ef68a283b464bd03a
Author: Howell Tam <pigeon at pigeond.net>
Date: Sun Jul 18 10:53:06 2010 +1000
ws2_32: Wrapped WSASendTo/WSARecvFrom with a different function name.
---
dlls/ws2_32/socket.c | 84 +++++++++++++++++++++++++++++++++++++------------
1 files changed, 63 insertions(+), 21 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 4191f80..2fde6e6 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -169,6 +169,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(winsock);
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 */
static CRITICAL_SECTION csWSgetXXXbyYYY;
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.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;
else
return n;
@@ -2940,7 +2958,7 @@ int WINAPI WS_recvfrom(SOCKET s, char *buf, INT len, int flags,
wsabuf.len = len;
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;
else
return n;
@@ -3127,7 +3145,7 @@ int WINAPI WS_send(SOCKET s, const char *buf, int len, int flags)
wsabuf.len = len;
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;
else
return n;
@@ -3141,7 +3159,7 @@ INT WINAPI WSASend( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine )
{
- return WSASendTo( s, lpBuffers, dwBufferCount, lpNumberOfBytesSent, dwFlags,
+ return WS2_sendto( s, lpBuffers, dwBufferCount, lpNumberOfBytesSent, dwFlags,
NULL, 0, lpOverlapped, lpCompletionRoutine );
}
@@ -3154,14 +3172,11 @@ INT WINAPI WSASendDisconnect( SOCKET s, LPWSABUF lpBuffers )
}
-/***********************************************************************
- * 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 )
+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 )
{
unsigned int i, options;
int n, fd, err;
@@ -3337,6 +3352,21 @@ 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)
*/
int WINAPI WS_sendto(SOCKET s, const char *buf, int len, int flags,
@@ -3348,7 +3378,7 @@ int WINAPI WS_sendto(SOCKET s, const char *buf, int len, int flags,
wsabuf.len = len;
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;
else
return n;
@@ -4932,17 +4962,14 @@ int WINAPI WSARecv(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
- return WSARecvFrom(s, lpBuffers, dwBufferCount, NumberOfBytesReceived, lpFlags,
+ return WS2_recvfrom(s, lpBuffers, dwBufferCount, NumberOfBytesReceived, lpFlags,
NULL, NULL, lpOverlapped, lpCompletionRoutine);
}
-/***********************************************************************
- * 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 )
+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 )
{
unsigned int i, options;
@@ -5096,6 +5123,21 @@ 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)
*/
INT WINAPI WSCInstallProvider( const LPGUID lpProviderId,
More information about the wine-cvs
mailing list