From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplayx_messages.c | 1 + dlls/dplayx/tests/dplayx.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/dplayx/dplayx_messages.c b/dlls/dplayx/dplayx_messages.c index 8e4f8750283..2b673e49441 100644 --- a/dlls/dplayx/dplayx_messages.c +++ b/dlls/dplayx/dplayx_messages.c @@ -330,6 +330,7 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer ) #endif
/* Compose body of message */ + msgBody.unknown = 0; msgBody.dpidAppServer = dpidServer; msgBody.unknown2[0] = 0x0; msgBody.unknown2[1] = 0x1c; diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 58f6903efdd..e0d92b1f8e5 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -1251,8 +1251,7 @@ static unsigned short receiveAddForwardRequest_( int line, SOCKET sock, DPID exp
port = checkSpHeader_( line, &request.spHeader, expectedSize, expectedPasswordSize != 2 ); checkMessageHeader_( line, &request.request.header, 19 ); - todo_wine_if( request.request.toId ) ok_( __FILE__, line )( !request.request.toId, "got destination id %#lx.\n", - request.request.toId ); + 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", request.request.playerId ); ok_( __FILE__, line )( !request.request.groupId, "got group id %#lx.\n", request.request.groupId );
From: Anton Baskanov baskanov@gmail.com
--- dlls/dpwsockx/dpwsockx_dll.h | 6 +++++ dlls/dpwsockx/dpwsockx_main.c | 45 ++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/dlls/dpwsockx/dpwsockx_dll.h b/dlls/dpwsockx/dpwsockx_dll.h index 1b80fa02004..88eb26ae220 100644 --- a/dlls/dpwsockx/dpwsockx_dll.h +++ b/dlls/dpwsockx/dpwsockx_dll.h @@ -45,6 +45,12 @@ typedef struct tagDPSP_MSG_HEADER } DPSP_MSG_HEADER, *LPDPSP_MSG_HEADER; typedef const DPSP_MSG_HEADER* LPCDPSP_MSG_HEADER;
+typedef struct +{ + SOCKADDR_IN tcpAddr; + SOCKADDR_IN udpAddr; +} DPWS_PLAYERDATA; + #include "poppack.h"
typedef struct tagDPWS_IN_CONNECTION DPWS_IN_CONNECTION; diff --git a/dlls/dpwsockx/dpwsockx_main.c b/dlls/dpwsockx/dpwsockx_main.c index 7ff3484a3c2..74a22751996 100644 --- a/dlls/dpwsockx/dpwsockx_main.c +++ b/dlls/dpwsockx/dpwsockx_main.c @@ -452,9 +452,52 @@ static HRESULT WINAPI DPWSCB_Send( LPDPSP_SENDDATA data )
static HRESULT WINAPI DPWSCB_CreatePlayer( LPDPSP_CREATEPLAYERDATA data ) { - FIXME( "(%ld,0x%08lx,%p,%p) stub\n", + DPWS_PLAYERDATA *playerData; + DWORD playerDataSize; + DPWS_DATA *dpwsData; + DWORD dpwsDataSize; + HRESULT hr; + + TRACE( "(%ld,0x%08lx,%p,%p)\n", data->idPlayer, data->dwFlags, data->lpSPMessageHeader, data->lpISP ); + + hr = IDirectPlaySP_GetSPData( data->lpISP, (void **) &dpwsData, &dpwsDataSize, DPSET_LOCAL ); + if ( FAILED( hr ) ) + return hr; + + if ( !data->lpSPMessageHeader ) + { + DPWS_PLAYERDATA playerDataPlaceholder = { 0 }; + hr = IDirectPlaySP_SetSPPlayerData( data->lpISP, data->idPlayer, + (void *) &playerDataPlaceholder, + sizeof( playerDataPlaceholder ), DPSET_REMOTE ); + if ( FAILED( hr ) ) + return hr; + } + + hr = IDirectPlaySP_GetSPPlayerData( data->lpISP, data->idPlayer, (void **) &playerData, + &playerDataSize, DPSET_REMOTE ); + if ( FAILED( hr ) ) + return hr; + if ( playerDataSize != sizeof( DPWS_PLAYERDATA ) ) + return DPERR_GENERIC; + + if ( data->lpSPMessageHeader ) + { + DPSP_MSG_HEADER *header = data->lpSPMessageHeader; + if ( !playerData->tcpAddr.sin_addr.s_addr ) + playerData->tcpAddr.sin_addr = header->SockAddr.sin_addr; + if ( !playerData->udpAddr.sin_addr.s_addr ) + playerData->udpAddr.sin_addr = header->SockAddr.sin_addr; + } + else + { + playerData->tcpAddr.sin_family = AF_INET; + playerData->tcpAddr.sin_port = dpwsData->tcpAddr.sin_port; + playerData->udpAddr.sin_family = AF_INET; + } + return DP_OK; }
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplayx_messages.c | 105 ++++++++++++---------------------- dlls/dplayx/dplayx_messages.h | 40 +++++++------ dlls/dplayx/name_server.c | 8 --- dlls/dplayx/name_server.h | 1 - 4 files changed, 58 insertions(+), 96 deletions(-)
diff --git a/dlls/dplayx/dplayx_messages.c b/dlls/dplayx/dplayx_messages.c index 2b673e49441..8fe2d6c3010 100644 --- a/dlls/dplayx/dplayx_messages.c +++ b/dlls/dplayx/dplayx_messages.c @@ -297,87 +297,56 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer ) LPVOID lpMsg; DPMSG_FORWARDADDPLAYER msgBody; DWORD dwMsgSize; - HRESULT hr = DP_OK; + DPLAYI_PACKEDPLAYER playerInfo; + void *spPlayerData; + DWORD spPlayerDataSize; + const WCHAR *password = L""; + HRESULT hr; + + hr = IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, dpidServer, + &spPlayerData, &spPlayerDataSize, DPSET_REMOTE ); + if( FAILED( hr ) ) + return hr;
- /* Compose dplay message envelope */ msgBody.envelope.dwMagic = DPMSGMAGIC_DPLAYMSG; msgBody.envelope.wCommandId = DPMSGCMD_FORWARDADDPLAYER; msgBody.envelope.wVersion = DPMSGVER_DP6; - -#if 0 - { - LPBYTE lpPData; - DWORD dwDataSize; - - /* SP Player remote data needs to be propagated at some point - is this the point? */ - IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, 0, &lpPData, &dwDataSize, DPSET_REMOTE ); - - ERR( "Player Data size is 0x%08lx\n" - "[%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x]\n" - "[%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x]\n", - - dwDataSize, - lpPData[0], lpPData[1], lpPData[2], lpPData[3], lpPData[4], - lpPData[5], lpPData[6], lpPData[7], lpPData[8], lpPData[9], - lpPData[10], lpPData[11], lpPData[12], lpPData[13], lpPData[14], - lpPData[15], lpPData[16], lpPData[17], lpPData[18], lpPData[19], - lpPData[20], lpPData[21], lpPData[22], lpPData[23], lpPData[24], - lpPData[25], lpPData[26], lpPData[27], lpPData[28], lpPData[29], - lpPData[30], lpPData[31] - ); - DebugBreak(); - } -#endif - - /* Compose body of message */ - msgBody.unknown = 0; - msgBody.dpidAppServer = dpidServer; - msgBody.unknown2[0] = 0x0; - msgBody.unknown2[1] = 0x1c; - msgBody.unknown2[2] = 0x6c; - msgBody.unknown2[3] = 0x50; - msgBody.unknown2[4] = 0x9; - - msgBody.dpidAppServer2 = dpidServer; - msgBody.unknown3[0] = 0x0; - msgBody.unknown3[1] = 0x0; - msgBody.unknown3[2] = 0x20; - msgBody.unknown3[3] = 0x0; - msgBody.unknown3[4] = 0x0; - - msgBody.dpidAppServer3 = dpidServer; - msgBody.unknown4[0] = 0x30; - msgBody.unknown4[1] = 0xb; - msgBody.unknown4[2] = 0x0; - - msgBody.unknown4[3] = NS_GetNsMagic( This->dp2->lpNameServerData ) - - 0x02000000; - TRACE( "Setting first magic to 0x%08lx\n", msgBody.unknown4[3] ); - - msgBody.unknown4[4] = 0x0; - msgBody.unknown4[5] = 0x0; - msgBody.unknown4[6] = 0x0; - - msgBody.unknown4[7] = NS_GetNsMagic( This->dp2->lpNameServerData ); - TRACE( "Setting second magic to 0x%08lx\n", msgBody.unknown4[7] ); - - msgBody.unknown4[8] = 0x0; - msgBody.unknown4[9] = 0x0; - msgBody.unknown4[10] = 0x0; - msgBody.unknown4[11] = 0x0; - - msgBody.unknown5[0] = 0x0; - msgBody.unknown5[1] = 0x0; + msgBody.toId = 0; + msgBody.playerId = dpidServer; + msgBody.groupId = 0; + msgBody.createOffset = sizeof( msgBody ); + msgBody.passwordOffset = sizeof( msgBody ) + sizeof( playerInfo ) + spPlayerDataSize; + + playerInfo.size = sizeof( playerInfo ) + spPlayerDataSize; + playerInfo.flags = DPLAYI_PLAYER_SYSPLAYER | DPLAYI_PLAYER_PLAYERLOCAL; + playerInfo.id = dpidServer; + playerInfo.shortNameLength = 0; + playerInfo.longNameLength = 0; + playerInfo.spDataLength = spPlayerDataSize; + playerInfo.playerDataLength = 0; + playerInfo.playerCount = 0; + playerInfo.systemPlayerId = dpidServer; + playerInfo.fixedSize = sizeof( playerInfo ); + playerInfo.version = DPMSGVER_DP6; + playerInfo.parentId = 0;
/* Send the message */ { WORD replyCommands[] = { DPMSGCMD_GETNAMETABLEREPLY, DPMSGCMD_SUPERENUMPLAYERSREPLY }; - SGBUFFER buffers[ 2 ] = { 0 }; + SGBUFFER buffers[ 6 ] = { 0 }; DPSP_SENDEXDATA data = { 0 };
buffers[ 0 ].len = This->dp2->spData.dwSPHeaderSize; buffers[ 1 ].len = sizeof( msgBody ); buffers[ 1 ].pData = (UCHAR *) &msgBody; + buffers[ 2 ].len = sizeof( playerInfo ); + 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[ 5 ].len = sizeof( This->dp2->lpSessionDesc->dwReserved1 ); + buffers[ 5 ].pData = (UCHAR *) &This->dp2->lpSessionDesc->dwReserved1;
data.lpISP = This->dp2->spData.lpISP; data.dwFlags = DPSEND_GUARANTEED; diff --git a/dlls/dplayx/dplayx_messages.h b/dlls/dplayx/dplayx_messages.h index 6c2a210cb1d..f14ed1f4371 100644 --- a/dlls/dplayx/dplayx_messages.h +++ b/dlls/dplayx/dplayx_messages.h @@ -50,6 +50,22 @@ void DP_MSG_ToSelf( IDirectPlayImpl *This, DPID dpidSelf ); /* Message types etc. */ #include "pshpack1.h"
+typedef struct +{ + DWORD size; + DWORD flags; + DPID id; + DWORD shortNameLength; + DWORD longNameLength; + DWORD spDataLength; + DWORD playerDataLength; + DWORD playerCount; + DPID systemPlayerId; + DWORD fixedSize; + DWORD version; + DPID parentId; +} DPLAYI_PACKEDPLAYER; + /* Non provided messages for DPLAY - guess work which may be wrong :( */ #define DPMSGCMD_ENUMSESSIONSREPLY 1 #define DPMSGCMD_ENUMSESSIONSREQUEST 2 @@ -186,25 +202,11 @@ typedef struct tagDPMSG_FORWARDADDPLAYER { DPMSG_SENDENVELOPE envelope;
- DWORD unknown; /* 0 */ - - DPID dpidAppServer; /* Remote application server id */ - DWORD unknown2[5]; /* 0x0, 0x1c, 0x6c, 0x50, 0x9 */ - - DPID dpidAppServer2; /* Remote application server id again !? */ - DWORD unknown3[5]; /* 0x0, 0x0, 0x20, 0x0, 0x0 */ - - DPID dpidAppServer3; /* Remote application server id again !? */ - - DWORD unknown4[12]; /* ??? - Is this a clump of 5 and then 8? */ - /* NOTE: 1 byte in front of the two 0x??090002 entries changes! - * Is it a timestamp of some sort? 1st always smaller than - * other... - */ -#define FORWARDADDPLAYER_UNKNOWN4_INIT { 0x30, 0xb, 0x0, 0x1e090002, 0x0, 0x0, 0x0, 0x32090002, 0x0, 0x0, 0x0, 0x0 } - - BYTE unknown5[2]; /* 2 bytes at the end. This may be a part of something! ( 0x0, 0x0) */ - + DPID toId; + DPID playerId; + DPID groupId; + DWORD createOffset; + DWORD passwordOffset; } DPMSG_FORWARDADDPLAYER, *LPDPMSG_FORWARDADDPLAYER; typedef const DPMSG_FORWARDADDPLAYER* LPCDPMSG_FORWARDADDPLAYER;
diff --git a/dlls/dplayx/name_server.c b/dlls/dplayx/name_server.c index 1342cb7b962..44af9a8d566 100644 --- a/dlls/dplayx/name_server.c +++ b/dlls/dplayx/name_server.c @@ -184,14 +184,6 @@ LPVOID NS_GetNSAddr( LPVOID lpNSInfo ) #endif }
-/* Get the magic number associated with the Name Server */ -DWORD NS_GetNsMagic( LPVOID lpNSInfo ) -{ - LPDWORD lpHdrInfo = NS_GetNSAddr( lpNSInfo ); - - return lpHdrInfo[1]; -} - void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ) { lpNSCache lpCache = (lpNSCache)lpNSInfo; diff --git a/dlls/dplayx/name_server.h b/dlls/dplayx/name_server.h index b946e9e1fd9..e4fb11db22e 100644 --- a/dlls/dplayx/name_server.h +++ b/dlls/dplayx/name_server.h @@ -35,7 +35,6 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpNSAddrHdr, DWORD msgSize, LPVOID lpNSInfo ); LPVOID NS_GetNSAddr( LPVOID lpNSInfo ); -DWORD NS_GetNsMagic( LPVOID lpNSInfo ); void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize );
void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg,
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 45 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index e09a5a76a11..f0560fadd4e 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -68,9 +68,8 @@ static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf,
static DPID DP_GetRemoteNextObjectId(void);
-static DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ); -static void DP_CopySessionDesc( LPDPSESSIONDESC2 destSessionDesc, - LPCDPSESSIONDESC2 srcSessDesc, BOOL bAnsi ); +static DWORD DP_CopySessionDesc( LPDPSESSIONDESC2 destSessionDesc, + LPCDPSESSIONDESC2 srcSessDesc, BOOL bAnsi );
#define DPID_NOPARENT_GROUP 0 /* Magic number to indicate no parent of group */ @@ -3186,8 +3185,7 @@ static HRESULT DP_GetSessionDesc( IDirectPlayImpl *This, void *lpData, DWORD *lp return DPERR_INVALIDPARAMS; }
- /* FIXME: Get from This->dp2->lpSessionDesc */ - dwRequiredSize = DP_CalcSessionDescSize( This->dp2->lpSessionDesc, bAnsi ); + dwRequiredSize = DP_CopySessionDesc( NULL, This->dp2->lpSessionDesc, bAnsi );
if ( ( lpData == NULL ) || ( *lpdwDataSize < dwRequiredSize ) @@ -3876,7 +3874,7 @@ static HRESULT DP_SetSessionDesc( IDirectPlayImpl *This, const DPSESSIONDESC2 *l }
/* FIXME: Copy into This->dp2->lpSessionDesc */ - dwRequiredSize = DP_CalcSessionDescSize( lpSessDesc, bAnsi ); + dwRequiredSize = DP_CopySessionDesc( NULL, lpSessDesc, bAnsi ); lpTempSessDesc = calloc( 1, dwRequiredSize );
if( lpTempSessDesc == NULL ) @@ -3949,43 +3947,20 @@ static HRESULT WINAPI IDirectPlay4Impl_SetSessionDesc( IDirectPlay4 *iface, return DP_SetSessionDesc( This, lpSessDesc, dwFlags, FALSE, TRUE ); }
-/* FIXME: See about merging some of this stuff with dplayx_global.c stuff */ -static DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ) -{ - DWORD dwSize = 0; - - if( lpSessDesc == NULL ) - { - /* Hmmm..don't need any size? */ - ERR( "NULL lpSessDesc\n" ); - return dwSize; - } - - dwSize += sizeof( *lpSessDesc ); - dwSize += DP_CopyString( NULL, lpSessDesc->lpszSessionNameA, bAnsi, bAnsi, NULL, 0 ); - dwSize += DP_CopyString( NULL, lpSessDesc->lpszPasswordA, bAnsi, bAnsi, NULL, 0 ); - - return dwSize; -} - -/* Assumes that contiguous buffers are already allocated. */ -static void DP_CopySessionDesc( LPDPSESSIONDESC2 lpSessionDest, - LPCDPSESSIONDESC2 lpSessionSrc, BOOL bAnsi ) +static DWORD DP_CopySessionDesc( LPDPSESSIONDESC2 lpSessionDest, + LPCDPSESSIONDESC2 lpSessionSrc, BOOL bAnsi ) { DWORD offset = sizeof( DPSESSIONDESC2 );
- if( lpSessionDest == NULL ) - { - ERR( "NULL lpSessionDest\n" ); - return; - } - - CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) ); + if( lpSessionDest ) + CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) );
offset += DP_CopyString( &lpSessionDest->lpszSessionNameA, lpSessionSrc->lpszSessionNameA, bAnsi, bAnsi, lpSessionDest, offset ); offset += DP_CopyString( &lpSessionDest->lpszPasswordA, lpSessionSrc->lpszPasswordA, bAnsi, bAnsi, lpSessionDest, offset ); + + return offset; }
static HRESULT WINAPI IDirectPlay3AImpl_AddGroupToGroup( IDirectPlay3A *iface, DPID parent,
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 45 ++++++++++++++++++++++---------------- dlls/dplayx/dplay_global.h | 1 + dlls/dplayx/name_server.c | 17 +++++--------- 3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index f0560fadd4e..125d50c5524 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -69,7 +69,7 @@ static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf, static DPID DP_GetRemoteNextObjectId(void);
static DWORD DP_CopySessionDesc( LPDPSESSIONDESC2 destSessionDesc, - LPCDPSESSIONDESC2 srcSessDesc, BOOL bAnsi ); + LPCDPSESSIONDESC2 srcSessDesc, BOOL dstAnsi, BOOL srcAnsi );
#define DPID_NOPARENT_GROUP 0 /* Magic number to indicate no parent of group */ @@ -3185,7 +3185,7 @@ static HRESULT DP_GetSessionDesc( IDirectPlayImpl *This, void *lpData, DWORD *lp return DPERR_INVALIDPARAMS; }
- dwRequiredSize = DP_CopySessionDesc( NULL, This->dp2->lpSessionDesc, bAnsi ); + dwRequiredSize = DP_CopySessionDesc( NULL, This->dp2->lpSessionDesc, bAnsi, bAnsi );
if ( ( lpData == NULL ) || ( *lpdwDataSize < dwRequiredSize ) @@ -3195,7 +3195,7 @@ static HRESULT DP_GetSessionDesc( IDirectPlayImpl *This, void *lpData, DWORD *lp return DPERR_BUFFERTOOSMALL; }
- DP_CopySessionDesc( lpData, This->dp2->lpSessionDesc, bAnsi ); + DP_CopySessionDesc( lpData, This->dp2->lpSessionDesc, bAnsi, bAnsi );
return DP_OK; } @@ -3851,7 +3851,6 @@ static HRESULT WINAPI IDirectPlay4Impl_SetPlayerName( IDirectPlay4 *iface, DPID static HRESULT DP_SetSessionDesc( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpSessDesc, DWORD dwFlags, BOOL bInitial, BOOL bAnsi ) { - DWORD dwRequiredSize; LPDPSESSIONDESC2 lpTempSessDesc;
TRACE( "(%p)->(%p,0x%08lx,%u,%u)\n", @@ -3873,9 +3872,7 @@ static HRESULT DP_SetSessionDesc( IDirectPlayImpl *This, const DPSESSIONDESC2 *l return DPERR_ACCESSDENIED; }
- /* FIXME: Copy into This->dp2->lpSessionDesc */ - dwRequiredSize = DP_CopySessionDesc( NULL, lpSessDesc, bAnsi ); - lpTempSessDesc = calloc( 1, dwRequiredSize ); + lpTempSessDesc = DP_DuplicateSessionDesc( lpSessDesc, bAnsi, bAnsi );
if( lpTempSessDesc == NULL ) { @@ -3886,13 +3883,7 @@ static HRESULT DP_SetSessionDesc( IDirectPlayImpl *This, const DPSESSIONDESC2 *l free( This->dp2->lpSessionDesc );
This->dp2->lpSessionDesc = lpTempSessDesc; - /* Set the new */ - DP_CopySessionDesc( This->dp2->lpSessionDesc, lpSessDesc, bAnsi ); - if( bInitial ) - { - /*Initializing session GUID*/ - CoCreateGuid( &(This->dp2->lpSessionDesc->guidInstance) ); - } + /* If this is an external invocation of the interface, we should be * letting everyone know that things have changed. Otherwise this is * just an initialization and it doesn't need to be propagated. @@ -3948,21 +3939,37 @@ static HRESULT WINAPI IDirectPlay4Impl_SetSessionDesc( IDirectPlay4 *iface, }
static DWORD DP_CopySessionDesc( LPDPSESSIONDESC2 lpSessionDest, - LPCDPSESSIONDESC2 lpSessionSrc, BOOL bAnsi ) + LPCDPSESSIONDESC2 lpSessionSrc, BOOL dstAnsi, BOOL srcAnsi ) { DWORD offset = sizeof( DPSESSIONDESC2 );
if( lpSessionDest ) CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) );
- offset += DP_CopyString( &lpSessionDest->lpszSessionNameA, lpSessionSrc->lpszSessionNameA, bAnsi, - bAnsi, lpSessionDest, offset ); - offset += DP_CopyString( &lpSessionDest->lpszPasswordA, lpSessionSrc->lpszPasswordA, bAnsi, - bAnsi, lpSessionDest, offset ); + offset += DP_CopyString( &lpSessionDest->lpszSessionNameA, lpSessionSrc->lpszSessionNameA, + dstAnsi, srcAnsi, lpSessionDest, offset ); + offset += DP_CopyString( &lpSessionDest->lpszPasswordA, lpSessionSrc->lpszPasswordA, + dstAnsi, srcAnsi, lpSessionDest, offset );
return offset; }
+DPSESSIONDESC2 *DP_DuplicateSessionDesc( const DPSESSIONDESC2 *src, BOOL dstAnsi, BOOL srcAnsi ) +{ + DPSESSIONDESC2 *dst; + DWORD size; + + size = DP_CopySessionDesc( NULL, src, dstAnsi, srcAnsi ); + + dst = malloc( size ); + if ( !dst ) + return NULL; + + DP_CopySessionDesc( dst, src, dstAnsi, srcAnsi ); + + return dst; +} + static HRESULT WINAPI IDirectPlay3AImpl_AddGroupToGroup( IDirectPlay3A *iface, DPID parent, DPID group ) { diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index 097f0839d84..6536d9e3f9c 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -200,6 +200,7 @@ typedef struct IDirectPlayImpl HRESULT DP_HandleMessage( IDirectPlayImpl *This, const void *lpMessageBody, DWORD dwMessageBodySize, const void *lpMessageHeader, WORD wCommandId, WORD wVersion, void **lplpReply, DWORD *lpdwMsgSize ); +DPSESSIONDESC2 *DP_DuplicateSessionDesc( const DPSESSIONDESC2 *src, BOOL dstAnsi, BOOL srcAnsi );
/* DP SP external interfaces into DirectPlay */ extern HRESULT DP_GetSPPlayerData( IDirectPlayImpl *lpDP, DPID idPlayer, void **lplpData ); diff --git a/dlls/dplayx/name_server.c b/dlls/dplayx/name_server.c index 44af9a8d566..3ea895c269d 100644 --- a/dlls/dplayx/name_server.c +++ b/dlls/dplayx/name_server.c @@ -92,9 +92,9 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr DWORD msgSize, LPVOID lpNSInfo ) { - DWORD len; lpNSCache lpCache = (lpNSCache)lpNSInfo; lpNSCacheData lpCacheNode; + DPSESSIONDESC2 dpsd; DWORD maxNameLength; DWORD nameLength;
@@ -131,7 +131,11 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr lpCacheNode->lpNSAddrHdr = malloc( dwHdrSize ); CopyMemory( lpCacheNode->lpNSAddrHdr, lpcNSAddrHdr, dwHdrSize );
- lpCacheNode->data = calloc( 1, sizeof( *(lpCacheNode->data) ) ); + dpsd = lpcMsg->sd; + dpsd.lpszSessionName = (WCHAR *) (lpcMsg + 1); + dpsd.lpszPassword = NULL; + + lpCacheNode->data = DP_DuplicateSessionDesc( &dpsd, TRUE, FALSE );
if( lpCacheNode->data == NULL ) { @@ -140,14 +144,6 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr return; }
- *lpCacheNode->data = lpcMsg->sd; - len = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1, NULL, 0, NULL, NULL ); - if ((lpCacheNode->data->lpszSessionNameA = malloc( len ))) - { - WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1, - lpCacheNode->data->lpszSessionNameA, len, NULL, NULL ); - } - lpCacheNode->ref = 1; lpCacheNode->dwTime = timeGetTime();
@@ -242,7 +238,6 @@ static DPQ_DECL_DELETECB( cbReleaseNSNode, lpNSCacheData ) if ( ref ) return;
- /* FIXME: Memory leak on data (contained ptrs) */ free( elem->data ); free( elem->lpNSAddrHdr ); free( elem );
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 14 +++++++++++--- dlls/dplayx/name_server.c | 30 ++++-------------------------- dlls/dplayx/name_server.h | 3 +-- 3 files changed, 16 insertions(+), 31 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 125d50c5524..d77a6375748 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -2344,7 +2344,7 @@ static BOOL DP_InvokeEnumSessionCallbacks
/* Enumerate all sessions */ /* FIXME: Need to indicate ANSI */ - while( (lpSessionDesc = NS_WalkSessions( lpNSInfo ) ) != NULL ) + while( (lpSessionDesc = NS_WalkSessions( lpNSInfo, NULL ) ) != NULL ) { TRACE( "EnumSessionsCallback2 invoked\n" ); if( !lpEnumSessionsCallback2( lpSessionDesc, timeout, 0, lpContext ) ) @@ -3328,8 +3328,16 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, } else { - spMessageHeader = NS_GetNSAddr( This->dp2->lpNameServerData ); - if ( !spMessageHeader ) + DPSESSIONDESC2 *sessionDesc; + + EnterCriticalSection( &This->lock ); + + NS_ResetSessionEnumeration( This->dp2->lpNameServerData ); + + LeaveCriticalSection( &This->lock ); + + sessionDesc = NS_WalkSessions( This->dp2->lpNameServerData, &spMessageHeader ); + if ( !sessionDesc ) return DPERR_NOSESSIONS; }
diff --git a/dlls/dplayx/name_server.c b/dlls/dplayx/name_server.c index 3ea895c269d..755288a4e57 100644 --- a/dlls/dplayx/name_server.c +++ b/dlls/dplayx/name_server.c @@ -155,31 +155,6 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr NS_PruneSessionCache( lpNSInfo ); }
-LPVOID NS_GetNSAddr( LPVOID lpNSInfo ) -{ - lpNSCache lpCache = (lpNSCache)lpNSInfo; - - FIXME( ":quick stub\n" ); - - /* Ok. Cheat and don't search for the correct stuff just take the first. - * FIXME: In the future how are we to know what is _THE_ enum we used? - * This is going to have to go into dplay somehow. Perhaps it - * comes back with app server id for the join command! Oh... that - * must be it. That would make this method obsolete once that's - * in place. - */ -#if 1 - if ( lpCache->walkFirst.lpQHFirst ) - return lpCache->walkFirst.lpQHFirst->lpNSAddrHdr; - - return NULL; -#else - /* FIXME: Should convert over to this */ - return lpCache->bNsIsLocal ? lpCache->lpLocalAddrHdr - : lpCache->lpRemoteAddrHdr; -#endif -} - void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ) { lpNSCache lpCache = (lpNSCache)lpNSInfo; @@ -305,7 +280,7 @@ void NS_ResetSessionEnumeration( LPVOID lpNSInfo ) ((lpNSCache)lpNSInfo)->present = ((lpNSCache)lpNSInfo)->walkFirst.lpQHFirst; }
-LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo ) +LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo, void **spMessageHeader ) { LPDPSESSIONDESC2 lpSessionDesc; lpNSCache lpCache = (lpNSCache)lpNSInfo; @@ -318,6 +293,9 @@ LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo )
lpSessionDesc = lpCache->present->data;
+ if( spMessageHeader ) + *spMessageHeader = lpCache->present->lpNSAddrHdr; + /* Advance tracking pointer */ lpCache->present = lpCache->present->walkNext.lpQNext;
diff --git a/dlls/dplayx/name_server.h b/dlls/dplayx/name_server.h index e4fb11db22e..ad51a550b9c 100644 --- a/dlls/dplayx/name_server.h +++ b/dlls/dplayx/name_server.h @@ -34,7 +34,6 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpNSAddrHdr, LPCDPMSG_ENUMSESSIONSREPLY lpcMsg, DWORD msgSize, LPVOID lpNSInfo ); -LPVOID NS_GetNSAddr( LPVOID lpNSInfo ); void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize );
void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg, @@ -54,7 +53,7 @@ void NS_InvalidateSessionCache( LPVOID lpNSInfo );
void NS_ResetSessionEnumeration( LPVOID lpNSInfo ); -LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo ); +LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo, void **spMessageHeader ); void NS_PruneSessionCache( LPVOID lpNSInfo );
#endif /* __WINE_DPLAYX_NAMESERVER */
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 4 ++++ dlls/dplayx/tests/dplayx.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index d77a6375748..cecc4d62657 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3339,6 +3339,10 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd, sessionDesc = NS_WalkSessions( This->dp2->lpNameServerData, &spMessageHeader ); if ( !sessionDesc ) return DPERR_NOSESSIONS; + + This->dp2->lpSessionDesc = DP_DuplicateSessionDesc( sessionDesc, bAnsi, bAnsi ); + if ( !This->dp2->lpSessionDesc ) + return DPERR_OUTOFMEMORY; }
/* Invoke the conditional callback for the service provider */ diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index e0d92b1f8e5..105de7f9618 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -1274,7 +1274,8 @@ static unsigned short receiveAddForwardRequest_( int line, SOCKET sock, DPID exp
todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( wsResult == sizeof( DWORD ), "recv() returned %d.\n", wsResult ); - todo_wine ok_( __FILE__, line )( tickCount == expectedTickCount, "got tick count %#lx.\n", tickCount ); + todo_wine_if( expectedPasswordSize != 2 ) ok_( __FILE__, line )( tickCount == expectedTickCount, + "got tick count %#lx.\n", tickCount );
return port; }
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=148688
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
dplayx: dplayx.c:2134: Test failed: got flags 0.
This merge request was approved by Alistair Leslie-Hughes.