From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 21 +++++++++++++++++++-- dlls/dplayx/dplayx_messages.c | 7 +++---- dlls/dplayx/dplayx_messages.h | 2 +- dlls/dplayx/tests/dplayx.c | 14 +++++--------- 4 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 9b5c4857b44..26dfd0279a1 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -1779,7 +1779,7 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID * DP_MSG_ToSelf( This, *lpidPlayer ); /* This is a hack right now */ #endif
- hr = DP_MSG_ForwardPlayerCreation( This, *lpidPlayer); + hr = DP_MSG_ForwardPlayerCreation( This, *lpidPlayer, NULL ); } #else /* 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, { DWORD createFlags = DPLAYI_PLAYER_SYSPLAYER | DPLAYI_PLAYER_PLAYERLOCAL; DPID dpidServerId = DPID_UNKNOWN; + WCHAR *password; + + password = DP_DuplicateString( lpsd->lpszPassword, FALSE, bAnsi ); + if ( !password && lpsd->lpszPassword ) + { + DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE ); + if( This->dp2->spData.lpCB->CloseEx ) + { + DPSP_CLOSEDATA data; + data.lpISP = This->dp2->spData.lpISP; + (*This->dp2->spData.lpCB->CloseEx)( &data ); + } + return DPERR_OUTOFMEMORY; + }
/* Create the server player for this interface. This way we can receive * messages for this session. @@ -3422,6 +3436,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, if( FAILED( hr ) ) { ERR( "Request for ID failed: %s\n", DPLAYX_HresultToString( hr ) ); + free( password ); DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE ); if( This->dp2->spData.lpCB->CloseEx ) { @@ -3436,6 +3451,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, bAnsi ); if( FAILED( hr ) ) { + free( password ); DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE ); if( This->dp2->spData.lpCB->CloseEx ) { @@ -3446,7 +3462,8 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, return hr; }
- hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId ); + hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId, password ); + free( password ); if( FAILED( hr ) ) { DP_DeletePlayer( This, dpidServerId ); diff --git a/dlls/dplayx/dplayx_messages.c b/dlls/dplayx/dplayx_messages.c index 371caebb893..04e0fc06d5b 100644 --- a/dlls/dplayx/dplayx_messages.c +++ b/dlls/dplayx/dplayx_messages.c @@ -449,7 +449,7 @@ static HRESULT DP_MSG_ReadSuperPackedPlayer( char *data, DWORD *inoutOffset, DWO return S_OK; }
-HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer ) +HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer, WCHAR *password ) { LPVOID lpMsg; DPMSG_FORWARDADDPLAYER msgBody; @@ -457,7 +457,6 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer ) DPLAYI_PACKEDPLAYER playerInfo; void *spPlayerData; DWORD spPlayerDataSize; - const WCHAR *password = L""; void *msgHeader; HRESULT hr;
@@ -501,8 +500,8 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer ) buffers[ 2 ].pData = (UCHAR *) &playerInfo; buffers[ 3 ].len = spPlayerDataSize; buffers[ 3 ].pData = (UCHAR *) spPlayerData; - buffers[ 4 ].len = (lstrlenW( password ) + 1) * sizeof( WCHAR ); - buffers[ 4 ].pData = (UCHAR *) password; + buffers[ 4 ].len = (password ? (lstrlenW( password ) + 1) : 1) * sizeof( WCHAR ); + buffers[ 4 ].pData = (UCHAR *) (password ? password : L""); buffers[ 5 ].len = sizeof( This->dp2->lpSessionDesc->dwReserved1 ); buffers[ 5 ].pData = (UCHAR *) &This->dp2->lpSessionDesc->dwReserved1;
diff --git a/dlls/dplayx/dplayx_messages.h b/dlls/dplayx/dplayx_messages.h index 09a0ffb03d9..ac0850ef170 100644 --- a/dlls/dplayx/dplayx_messages.h +++ b/dlls/dplayx/dplayx_messages.h @@ -50,7 +50,7 @@ DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart,
HRESULT DP_MSG_SendRequestPlayerId( IDirectPlayImpl *This, DWORD dwFlags, LPDPID lpdipidAllocatedId ); -HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer ); +HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer, WCHAR *password );
void DP_MSG_ReplyReceived( IDirectPlayImpl *This, WORD wCommandId, LPCVOID lpMsgBody, DWORD dwMsgBodySize, diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index a780f93de4c..d5dcd2d9807 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -1247,7 +1247,7 @@ static unsigned short receiveAddForwardRequest_( int line, SOCKET sock, DPID exp if ( wsResult == SOCKET_ERROR ) return 0;
- port = checkSpHeader_( line, &request.spHeader, expectedSize, expectedPasswordSize != 2 ); + port = checkSpHeader_( line, &request.spHeader, expectedSize, FALSE ); checkMessageHeader_( line, &request.request.header, 19 ); ok_( __FILE__, line )( !request.request.toId, "got destination id %#lx.\n", request.request.toId ); 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
wsResult = receiveMessage_( line, sock, password, expectedPasswordSize );
- todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( wsResult == expectedPasswordSize, - "recv() returned %d.\n", wsResult ); - todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( !lstrcmpW( password, expectedPassword ), - "got password %s.\n", wine_dbgstr_w( password ) ); + ok_( __FILE__, line )( wsResult == expectedPasswordSize, "recv() returned %d.\n", wsResult ); + ok_( __FILE__, line )( !lstrcmpW( password, expectedPassword ), "got password %s.\n", wine_dbgstr_w( password ) );
wsResult = receiveMessage_( line, sock, &tickCount, sizeof( DWORD ) );
- todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( wsResult == sizeof( DWORD ), - "recv() returned %d.\n", wsResult ); - todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( tickCount == expectedTickCount, - "got tick count %#lx.\n", tickCount ); + ok_( __FILE__, line )( wsResult == sizeof( DWORD ), "recv() returned %d.\n", wsResult ); + ok_( __FILE__, line )( tickCount == expectedTickCount, "got tick count %#lx.\n", tickCount );
return port; }