Skip to content

Commit 6ff9858

Browse files
baskanovjulliard
authored andcommitted
dplayx: Send password in player creation forward request.
1 parent 70f711f commit 6ff9858

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

dlls/dplayx/dplay.c

+19-2
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID *
17791779
DP_MSG_ToSelf( This, *lpidPlayer ); /* This is a hack right now */
17801780
#endif
17811781

1782-
hr = DP_MSG_ForwardPlayerCreation( This, *lpidPlayer);
1782+
hr = DP_MSG_ForwardPlayerCreation( This, *lpidPlayer, NULL );
17831783
}
17841784
#else
17851785
/* Inform all other peers of the creation of a new player. If there are
@@ -3409,6 +3409,20 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
34093409
{
34103410
DWORD createFlags = DPLAYI_PLAYER_SYSPLAYER | DPLAYI_PLAYER_PLAYERLOCAL;
34113411
DPID dpidServerId = DPID_UNKNOWN;
3412+
WCHAR *password;
3413+
3414+
password = DP_DuplicateString( lpsd->lpszPassword, FALSE, bAnsi );
3415+
if ( !password && lpsd->lpszPassword )
3416+
{
3417+
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
3418+
if( This->dp2->spData.lpCB->CloseEx )
3419+
{
3420+
DPSP_CLOSEDATA data;
3421+
data.lpISP = This->dp2->spData.lpISP;
3422+
(*This->dp2->spData.lpCB->CloseEx)( &data );
3423+
}
3424+
return DPERR_OUTOFMEMORY;
3425+
}
34123426

34133427
/* Create the server player for this interface. This way we can receive
34143428
* messages for this session.
@@ -3422,6 +3436,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
34223436
if( FAILED( hr ) )
34233437
{
34243438
ERR( "Request for ID failed: %s\n", DPLAYX_HresultToString( hr ) );
3439+
free( password );
34253440
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
34263441
if( This->dp2->spData.lpCB->CloseEx )
34273442
{
@@ -3436,6 +3451,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
34363451
bAnsi );
34373452
if( FAILED( hr ) )
34383453
{
3454+
free( password );
34393455
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
34403456
if( This->dp2->spData.lpCB->CloseEx )
34413457
{
@@ -3446,7 +3462,8 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
34463462
return hr;
34473463
}
34483464

3449-
hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId );
3465+
hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId, password );
3466+
free( password );
34503467
if( FAILED( hr ) )
34513468
{
34523469
DP_DeletePlayer( This, dpidServerId );

dlls/dplayx/dplayx_messages.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,14 @@ static HRESULT DP_MSG_ReadSuperPackedPlayer( char *data, DWORD *inoutOffset, DWO
449449
return S_OK;
450450
}
451451

452-
HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer )
452+
HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer, WCHAR *password )
453453
{
454454
LPVOID lpMsg;
455455
DPMSG_FORWARDADDPLAYER msgBody;
456456
DWORD dwMsgSize;
457457
DPLAYI_PACKEDPLAYER playerInfo;
458458
void *spPlayerData;
459459
DWORD spPlayerDataSize;
460-
const WCHAR *password = L"";
461460
void *msgHeader;
462461
HRESULT hr;
463462

@@ -501,8 +500,8 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer )
501500
buffers[ 2 ].pData = (UCHAR *) &playerInfo;
502501
buffers[ 3 ].len = spPlayerDataSize;
503502
buffers[ 3 ].pData = (UCHAR *) spPlayerData;
504-
buffers[ 4 ].len = (lstrlenW( password ) + 1) * sizeof( WCHAR );
505-
buffers[ 4 ].pData = (UCHAR *) password;
503+
buffers[ 4 ].len = (password ? (lstrlenW( password ) + 1) : 1) * sizeof( WCHAR );
504+
buffers[ 4 ].pData = (UCHAR *) (password ? password : L"");
506505
buffers[ 5 ].len = sizeof( This->dp2->lpSessionDesc->dwReserved1 );
507506
buffers[ 5 ].pData = (UCHAR *) &This->dp2->lpSessionDesc->dwReserved1;
508507

dlls/dplayx/dplayx_messages.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart,
5050

5151
HRESULT DP_MSG_SendRequestPlayerId( IDirectPlayImpl *This, DWORD dwFlags,
5252
LPDPID lpdipidAllocatedId );
53-
HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer );
53+
HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer, WCHAR *password );
5454

5555
void DP_MSG_ReplyReceived( IDirectPlayImpl *This, WORD wCommandId,
5656
LPCVOID lpMsgBody, DWORD dwMsgBodySize,

dlls/dplayx/tests/dplayx.c

+5-9
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ static unsigned short receiveAddForwardRequest_( int line, SOCKET sock, DPID exp
12471247
if ( wsResult == SOCKET_ERROR )
12481248
return 0;
12491249

1250-
port = checkSpHeader_( line, &request.spHeader, expectedSize, expectedPasswordSize != 2 );
1250+
port = checkSpHeader_( line, &request.spHeader, expectedSize, FALSE );
12511251
checkMessageHeader_( line, &request.request.header, 19 );
12521252
ok_( __FILE__, line )( !request.request.toId, "got destination id %#lx.\n", request.request.toId );
12531253
ok_( __FILE__, line )( request.request.playerId == expectedPlayerId, "got player id %#lx.\n",
@@ -1263,17 +1263,13 @@ static unsigned short receiveAddForwardRequest_( int line, SOCKET sock, DPID exp
12631263

12641264
wsResult = receiveMessage_( line, sock, password, expectedPasswordSize );
12651265

1266-
todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( wsResult == expectedPasswordSize,
1267-
"recv() returned %d.\n", wsResult );
1268-
todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( !lstrcmpW( password, expectedPassword ),
1269-
"got password %s.\n", wine_dbgstr_w( password ) );
1266+
ok_( __FILE__, line )( wsResult == expectedPasswordSize, "recv() returned %d.\n", wsResult );
1267+
ok_( __FILE__, line )( !lstrcmpW( password, expectedPassword ), "got password %s.\n", wine_dbgstr_w( password ) );
12701268

12711269
wsResult = receiveMessage_( line, sock, &tickCount, sizeof( DWORD ) );
12721270

1273-
todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( wsResult == sizeof( DWORD ),
1274-
"recv() returned %d.\n", wsResult );
1275-
todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( tickCount == expectedTickCount,
1276-
"got tick count %#lx.\n", tickCount );
1271+
ok_( __FILE__, line )( wsResult == sizeof( DWORD ), "recv() returned %d.\n", wsResult );
1272+
ok_( __FILE__, line )( tickCount == expectedTickCount, "got tick count %#lx.\n", tickCount );
12771273

12781274
return port;
12791275
}

0 commit comments

Comments
 (0)