Skip to content

Commit

Permalink
add version check
Browse files Browse the repository at this point in the history
  • Loading branch information
stevefan1999-personal authored and mingkuang-Chuyu committed Oct 19, 2024
1 parent a69718d commit 389b63a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Thunks/WS2_32.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <VersionHelpers.h>

#ifdef FreeAddrInfoEx
#undef FreeAddrInfoEx
Expand Down Expand Up @@ -1489,15 +1490,19 @@ namespace YY::Thunks
if (auto const pWSAIoctl = try_get_WSAIoctl())
{
const auto result = pWSAIoctl(s, dwIoControlCode, lpvInBuffer, cbInBuffer, lpvOutBuffer, cbOutBuffer, lpcbBytesReturned, lpOverlapped, lpCompletionRoutine);
// SIO_BASE_HANDLE is defined in the Mswsock.h header file and supported on Windows Vista and later.
// So while we do have layered service providers in Windows XP or earlier, this specific io control is not supported.
// Worse, LSP is actually deprecated since Windows Server 2012, meaning this io control should likely return the socket input on later OS as well (effectively bypassed the LSPs)
// So almost nobody except mio's library uses this io control...god help...
if (result == SOCKET_ERROR && dwIoControlCode == SIO_BASE_HANDLE)

if (!IsWindowsVistaOrGreater())
{
*(SOCKET *)lpvOutBuffer = s;
*lpcbBytesReturned = sizeof(SOCKET);
return 0;
// SIO_BASE_HANDLE is defined in the Mswsock.h header file and supported on Windows Vista and later.
// So while we do have layered service providers in Windows XP or earlier, this specific io control is not supported.
// Worse, LSP is actually deprecated since Windows Server 2012, meaning this io control should likely return the socket input on later OS as well (effectively bypassed the LSPs)
// So almost nobody except mio's library uses this io control...god help...
if (result == SOCKET_ERROR && dwIoControlCode == SIO_BASE_HANDLE)
{
*(SOCKET *)lpvOutBuffer = s;
*lpcbBytesReturned = sizeof(SOCKET);
return 0;
}
}
return result;
}
Expand Down

0 comments on commit 389b63a

Please sign in to comment.