Skip to content

Commit 9e7dd59

Browse files
add version check
1 parent 543e991 commit 9e7dd59

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Thunks/WS2_32.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <winsock2.h>
22
#include <ws2tcpip.h>
3+
#include <VersionHelpers.h>
34

45
#ifdef FreeAddrInfoEx
56
#undef FreeAddrInfoEx
@@ -1484,8 +1485,12 @@ namespace YY::Thunks
14841485
{
14851486
if (auto const pWSASocketW = try_get_WSASocketW())
14861487
{
1487-
// This flag is supported on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later
1488-
dwFlags &= ~WSA_FLAG_NO_HANDLE_INHERIT;
1488+
if (!IsWindows7SP1OrGreater())
1489+
{
1490+
// This flag is supported on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later
1491+
// So we strip it to prevent error
1492+
dwFlags &= ~WSA_FLAG_NO_HANDLE_INHERIT;
1493+
}
14891494
return pWSASocketW(af, type, protocol, lpProtocolInfo, g, dwFlags);
14901495
}
14911496
return INVALID_SOCKET;

0 commit comments

Comments
 (0)