dpwsockx: Broadcast enumeration request in EnumSessions().

This commit is contained in:
Anton Baskanov 2023-10-13 12:54:41 +07:00 committed by Alexandre Julliard
parent 28fdca5ea5
commit 78bdd23406
Notes: Alexandre Julliard 2024-09-11 23:40:30 +02:00
Approved-by: Alistair Leslie-Hughes (@alesliehughes)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6468
2 changed files with 50 additions and 15 deletions

View file

@ -784,12 +784,7 @@ static SOCKET connectTcp_( int line, unsigned short port )
addr.sin_port = htons( port );
addr.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
wsResult = connect( sock, (SOCKADDR *) &addr, sizeof( addr ) );
todo_wine ok_( __FILE__, line)( !wsResult, "connect returned %d.\n", wsResult );
if ( wsResult == SOCKET_ERROR )
{
closesocket( sock );
return INVALID_SOCKET;
}
ok_( __FILE__, line)( !wsResult, "connect returned %d.\n", wsResult );
return sock;
}
@ -870,8 +865,8 @@ static unsigned short receiveEnumSessionsRequest_( int line, SOCKET sock, const
expectedSize = sizeof( request.spHeader ) + sizeof( request.request ) + expectedPasswordSize;
wsResult = receiveMessage_( line, sock, &request, sizeof( request ) );
todo_wine ok_( __FILE__, line )( wsResult == expectedSize, "recv() returned %d.\n",
wsResult );
todo_wine_if( expectedPassword ) ok_( __FILE__, line )( wsResult == expectedSize, "recv() returned %d.\n",
wsResult );
if ( wsResult == SOCKET_ERROR )
return 0;
@ -881,10 +876,10 @@ static unsigned short receiveEnumSessionsRequest_( int line, SOCKET sock, const
wine_dbgstr_guid( &request.request.appGuid ) );
if ( expectedPassword )
{
ok_( __FILE__, line )( request.request.passwordOffset == 32, "got password offset %lu.\n",
request.request.passwordOffset );
ok_( __FILE__, line )( !lstrcmpW( request.password, expectedPassword ), "got password %s.\n",
wine_dbgstr_w( request.password ) );
todo_wine ok_( __FILE__, line )( request.request.passwordOffset == 32, "got password offset %lu.\n",
request.request.passwordOffset );
todo_wine ok_( __FILE__, line )( !lstrcmpW( request.password, expectedPassword ), "got password %s.\n",
wine_dbgstr_w( request.password ) );
}
else
{

View file

@ -30,6 +30,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(dplay);
#define DPWS_PORT 47624
#define DPWS_START_TCP_PORT 2300
#define DPWS_END_TCP_PORT 2350
@ -105,15 +106,19 @@ static void DPWS_Stop( DPWS_DATA *dpwsData )
static HRESULT WINAPI DPWSCB_EnumSessions( LPDPSP_ENUMSESSIONSDATA data )
{
DPSP_MSG_HEADER *header = (DPSP_MSG_HEADER *) data->lpMessage;
DPWS_DATA *dpwsData;
DWORD dpwsDataSize;
SOCKADDR_IN addr;
BOOL true = TRUE;
SOCKET sock;
HRESULT hr;
FIXME( "(%p,%ld,%p,%u) stub\n",
TRACE( "(%p,%ld,%p,%u)\n",
data->lpMessage, data->dwMessageSize,
data->lpISP, data->bReturnStatus );
hr = IDirectPlaySP_GetSPData( data->lpISP, (void **)&dpwsData, &dpwsDataSize, DPSET_LOCAL );
hr = IDirectPlaySP_GetSPData( data->lpISP, (void **) &dpwsData, &dpwsDataSize, DPSET_LOCAL );
if ( FAILED( hr ) )
return hr;
@ -121,7 +126,42 @@ static HRESULT WINAPI DPWSCB_EnumSessions( LPDPSP_ENUMSESSIONSDATA data )
if ( FAILED (hr) )
return hr;
return S_OK;
sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
if ( sock == INVALID_SOCKET )
{
ERR( "socket() failed\n" );
return DPERR_UNAVAILABLE;
}
if ( SOCKET_ERROR == setsockopt( sock, SOL_SOCKET, SO_BROADCAST, (const char *) &true,
sizeof( true ) ) )
{
ERR( "setsockopt() failed\n" );
closesocket( sock );
return DPERR_UNAVAILABLE;
}
memset( header, 0, sizeof( DPSP_MSG_HEADER ) );
header->mixed = DPSP_MSG_MAKE_MIXED( data->dwMessageSize, DPSP_MSG_TOKEN_REMOTE );
header->SockAddr.sin_family = AF_INET;
header->SockAddr.sin_port = dpwsData->tcpAddr.sin_port;
memset( &addr, 0, sizeof( addr ) );
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl( INADDR_BROADCAST );
addr.sin_port = htons( DPWS_PORT );
if ( SOCKET_ERROR == sendto( sock, data->lpMessage, data->dwMessageSize, 0, (SOCKADDR *) &addr,
sizeof( addr ) ) )
{
ERR( "sendto() failed\n" );
closesocket( sock );
return DPERR_UNAVAILABLE;
}
closesocket( sock );
return DP_OK;
}
static HRESULT WINAPI DPWSCB_Reply( LPDPSP_REPLYDATA data )