From: Christoph von Wittich Date: Sun, 16 Feb 2014 08:02:38 +0000 (+0000) Subject: [ws2_32] X-Git-Tag: ReactOS-0.3.16-CLT2014~115 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=27d91ad7f2b5d3b369ea4bdd8d44cf23aeb540a3 [ws2_32] merge startup version checks from ws2_32_new/src/startup.c [ws2_32_new] fix typo svn path=/trunk/; revision=62204 --- diff --git a/reactos/dll/win32/ws2_32/misc/dllmain.c b/reactos/dll/win32/ws2_32/misc/dllmain.c index ea5d45f1420..b0d657e67a5 100644 --- a/reactos/dll/win32/ws2_32/misc/dllmain.c +++ b/reactos/dll/win32/ws2_32/misc/dllmain.c @@ -55,7 +55,8 @@ EXPORT WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData) { - BYTE Low, High; + WORD VersionReturned = 0; + DWORD ErrorCode = ERROR_SUCCESS; WS_DbgPrint(MAX_TRACE, ("WSAStartup of ws2_32.dll\n")); @@ -65,48 +66,56 @@ WSAStartup(IN WORD wVersionRequested, if (lpWSAData == NULL) return WSAEFAULT; - Low = LOBYTE(wVersionRequested); - High = HIBYTE(wVersionRequested); - - if (Low < 1) + /* Check which version is being requested */ + switch (LOBYTE(wVersionRequested)) { - WS_DbgPrint(MAX_TRACE, ("Bad winsock version requested, %d,%d", Low, High)); - return WSAVERNOTSUPPORTED; - } + case 0: - if (Low == 1) - { - if (High == 0) - { - lpWSAData->wVersion = wVersionRequested; - } - else - { - lpWSAData->wVersion = MAKEWORD(1, 1); - } - } - else if (Low == 2) - { - if (High <= 2) - { - lpWSAData->wVersion = MAKEWORD(2, High); - } - else - { - lpWSAData->wVersion = MAKEWORD(2, 2); - } - } - else - { - lpWSAData->wVersion = MAKEWORD(2, 2); + /* We don't support this unknown version */ + ErrorCode = WSAVERNOTSUPPORTED; + break; + + case 1: + /* We support only 1.0 and 1.1 */ + if (HIBYTE(wVersionRequested) == 0) + { + /* Caller wants 1.0, return it */ + VersionReturned = wVersionRequested; + } + else + { + /* The only other version we support is 1.1 */ + VersionReturned = MAKEWORD(1, 1); + } + break; + + case 2: + /* We support only 2.0, 2.1 and 2.2 */ + if (HIBYTE(wVersionRequested) <= 2) + { + /* Caller wants 2.0-2.2, return it */ + VersionReturned = MAKEWORD(2, HIBYTE(wVersionRequested)); + } + else + { + /* The highest version we support is 2.2 */ + VersionReturned = MAKEWORD(2, 2); + } + break; + + default: + + /* Return 2.2 */ + VersionReturned = MAKEWORD(2, 2);; + break; } - lpWSAData->wVersion = wVersionRequested; + /* Return the Version Requested, unless error */ + lpWSAData->wVersion = VersionReturned; + lpWSAData->wHighVersion = MAKEWORD(2,2); lstrcpyA(lpWSAData->szDescription, "WinSock 2.0"); lstrcpyA(lpWSAData->szSystemStatus, "Running"); - lpWSAData->iMaxSockets = 0; - lpWSAData->iMaxUdpDg = 0; lpWSAData->lpVendorInfo = NULL; if (LOBYTE(wVersionRequested) == 1) @@ -124,7 +133,7 @@ WSAStartup(IN WORD wVersionRequested, WSASETINITIALIZED; - return NO_ERROR; + return ErrorCode; } diff --git a/reactos/dll/win32/ws2_32_new/src/startup.c b/reactos/dll/win32/ws2_32_new/src/startup.c index 32de9484c1b..aad40099152 100644 --- a/reactos/dll/win32/ws2_32_new/src/startup.c +++ b/reactos/dll/win32/ws2_32_new/src/startup.c @@ -160,7 +160,7 @@ WSAStartup(IN WORD wVersionRequested, break; } - /* Return the Version Requsted, unless error */ + /* Return the Version Requested, unless error */ lpWSAData->wVersion = VersionReturned; /* We support Winsock 2.2 */