From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 6b9001360ca..ddc784ac305 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3301,7 +3301,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, const DPSECURITYDESC *lpSecurity, const DPCREDENTIALS *lpCredentials, BOOL bAnsi ) { void *spMessageHeader = NULL; - HRESULT hr = DP_OK; + HRESULT hr;
FIXME( "(%p)->(%p,0x%08lx,%p,%p): partial stub\n", This, lpsd, dwFlags, lpSecurity, lpCredentials ); @@ -3398,6 +3398,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
if( dwFlags & DPOPEN_JOIN ) { + DWORD createFlags = DPLAYI_PLAYER_SYSPLAYER | DPLAYI_PLAYER_PLAYERLOCAL; DPID dpidServerId = DPID_UNKNOWN;
/* Create the server player for this interface. This way we can receive @@ -3408,26 +3409,34 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, * up. DPlay would then trigger the hEvent for the player the * message is directed to. */ - hr = DP_IF_CreatePlayer( This, NULL, &dpidServerId, NULL, 0, NULL, - 0, - DPPLAYER_SERVERPLAYER | DPPLAYER_LOCAL , bAnsi ); + hr = DP_MSG_SendRequestPlayerId( This, createFlags, &dpidServerId ); + if( FAILED( hr ) ) + { + ERR( "Request for ID failed: %s\n", DPLAYX_HresultToString( hr ) ); + return hr; + }
+ hr = DP_CreatePlayer( This, NULL, &dpidServerId, NULL, NULL, 0, NULL, 0, createFlags, NULL, + bAnsi ); + if( FAILED( hr ) ) + return hr; + + hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId ); + if( FAILED( hr ) ) + return hr; } else if( dwFlags & DPOPEN_CREATE ) { - DPID dpidNameServerId = DPID_NAME_SERVER; - - hr = DP_IF_CreatePlayer( This, NULL, &dpidNameServerId, NULL, 0, NULL, - 0, DPPLAYER_SERVERPLAYER, bAnsi ); - } + DWORD createFlags = DPLAYI_PLAYER_APPSERVER | DPLAYI_PLAYER_PLAYERLOCAL; + DPID dpidNameServerId = DP_NextObjectId();
- if( FAILED(hr) ) - { - ERR( "Couldn't create name server/system player: %s\n", - DPLAYX_HresultToString(hr) ); + hr = DP_CreatePlayer( This, NULL, &dpidNameServerId, NULL, NULL, 0, NULL, 0, createFlags, NULL, + bAnsi ); + if( FAILED( hr ) ) + return hr; }
- return hr; + return DP_OK; }
static HRESULT WINAPI IDirectPlay2AImpl_Open( IDirectPlay2A *iface, DPSESSIONDESC2 *sdesc,
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index ddc784ac305..933abd8bfe9 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3360,6 +3360,7 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, break; }
+ free( This->dp2->lpSessionDesc ); This->dp2->lpSessionDesc = DP_DuplicateSessionDesc( sessionDesc, bAnsi, bAnsi ); if ( !This->dp2->lpSessionDesc ) return DPERR_OUTOFMEMORY;
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 933abd8bfe9..9b5c4857b44 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3394,7 +3394,15 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
hr = DP_IF_CreateGroup( This, NULL, &systemGroup, NULL, NULL, 0, 0, TRUE ); - + if ( FAILED( hr ) ) + { + if( This->dp2->spData.lpCB->CloseEx ) + { + DPSP_CLOSEDATA data; + data.lpISP = This->dp2->spData.lpISP; + (*This->dp2->spData.lpCB->CloseEx)( &data ); + } + } }
if( dwFlags & DPOPEN_JOIN ) @@ -3414,17 +3422,43 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, if( FAILED( hr ) ) { ERR( "Request for ID failed: %s\n", DPLAYX_HresultToString( hr ) ); + 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 hr; }
hr = DP_CreatePlayer( This, NULL, &dpidServerId, NULL, NULL, 0, NULL, 0, createFlags, NULL, bAnsi ); if( FAILED( hr ) ) + { + 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 hr; + }
hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId ); if( FAILED( hr ) ) + { + DP_DeletePlayer( This, dpidServerId ); + 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 hr; + } } else if( dwFlags & DPOPEN_CREATE ) { @@ -3434,7 +3468,16 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, hr = DP_CreatePlayer( This, NULL, &dpidNameServerId, NULL, NULL, 0, NULL, 0, createFlags, NULL, bAnsi ); if( FAILED( hr ) ) + { + 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 hr; + } }
return DP_OK;
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; }
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplayx_messages.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dlls/dplayx/dplayx_messages.c b/dlls/dplayx/dplayx_messages.c index 04e0fc06d5b..4ecee05d79e 100644 --- a/dlls/dplayx/dplayx_messages.c +++ b/dlls/dplayx/dplayx_messages.c @@ -274,6 +274,11 @@ HRESULT DP_MSG_SendRequestPlayerId( IDirectPlayImpl *This, DWORD dwFlags, DPID * { LPCDPMSG_NEWPLAYERIDREPLY lpcReply;
+ if ( dwMsgSize < sizeof( DPMSG_NEWPLAYERIDREPLY ) ) + { + free( lpMsg ); + return DPERR_GENERIC; + } lpcReply = lpMsg;
*lpdpidAllocatedId = lpcReply->dpidNewPlayerId;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=148876
Your paranoid android.
=== w7u_el (32 bit report) ===
dplayx: dplayx.c:2345: Test failed: got flags 0.
=== w10pro64 (32 bit report) ===
dplayx: dplayx.c:2954: Test failed: select() returned 1.
=== debian11 (32 bit hi:IN report) ===
dplayx: dplayx.c:2366: Test failed: got mixed 0xfab00086. dplayx.c:2366: Test failed: recv() returned 6. dplayx.c:2366: Test failed: got password L"". dplayx.c:2366: Test failed: recv() returned -1. dplayx.c:2366: Test failed: got tick count 0xcccccccc.
=== debian11b (64 bit WoW report) ===
kernel32: comm.c:1574: Test failed: AbortWaitCts hComPortEvent failed comm.c:1586: Test failed: Unexpected time 1001, expected around 500
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 0000000000C700EA, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032
This merge request was approved by Alistair Leslie-Hughes.