From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 56 ++++++++++++++++++++++++++++++++------ dlls/dplayx/dplay_global.h | 2 ++ dlls/dplayx/tests/dplayx.c | 8 +++--- 3 files changed, 54 insertions(+), 12 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 751d902a77d..c1b09627f55 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -1077,13 +1077,21 @@ static lpGroupData DP_CreateGroup( IDirectPlayImpl *This, const DPID *lpid, cons /* Set the desired player ID - no sanity checking to see if it exists */ lpGData->dpid = *lpid;
- lpGData->name = DP_DuplicateName( lpName, bAnsi, bAnsi ); + lpGData->name = DP_DuplicateName( lpName, FALSE, bAnsi ); if ( !lpGData->name ) { free( lpGData ); return NULL; }
+ lpGData->nameA = DP_DuplicateName( lpName, TRUE, bAnsi ); + if ( !lpGData->nameA ) + { + free( lpGData->name ); + free( lpGData ); + return NULL; + } + /* FIXME: Should we check that the parent exists? */ lpGData->parent = idParent;
@@ -1117,6 +1125,7 @@ static void DP_DeleteGroup( IDirectPlayImpl *This, DPID dpid ) }
/* Delete player */ + free( lpGList->lpGData->nameA ); free( lpGList->lpGData->name ); free( lpGList->lpGData );
@@ -1435,13 +1444,21 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN /* Set the desired player ID */ lpPData->dpid = *lpid;
- lpPData->name = DP_DuplicateName( lpName, bAnsi, bAnsi ); + lpPData->name = DP_DuplicateName( lpName, FALSE, bAnsi ); if ( !lpPData->name ) { free( lpPData ); return DPERR_OUTOFMEMORY; }
+ lpPData->nameA = DP_DuplicateName( lpName, TRUE, bAnsi ); + if ( !lpPData->nameA ) + { + free( lpPData->name ); + free( lpPData ); + return DPERR_OUTOFMEMORY; + } + lpPData->dwFlags = dwFlags;
/* If we were given an event handle, duplicate it */ @@ -1466,6 +1483,7 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN { free( lpPData->lpSPPlayerData ); CloseHandle( lpPData->hEvent ); + free( lpPData->nameA ); free( lpPData->name ); free( lpPData ); return DPERR_OUTOFMEMORY; @@ -1488,6 +1506,7 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN free( lpPList ); free( lpPData->lpSPPlayerData ); CloseHandle( lpPData->hEvent ); + free( lpPData->nameA ); free( lpPData->name ); free( lpPData ); return hr; @@ -1501,6 +1520,7 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN free( lpPList ); free( lpPData->lpSPPlayerData ); CloseHandle( lpPData->hEvent ); + free( lpPData->nameA ); free( lpPData->name ); free( lpPData ); return hr; @@ -1537,6 +1557,7 @@ static void DP_DeletePlayer( IDirectPlayImpl *This, DPID dpid ) }
/* Delete player */ + free( lpPList->lpPData->nameA ); free( lpPList->lpPData->name );
CloseHandle( lpPList->lpPData->hEvent ); @@ -2803,7 +2824,7 @@ static HRESULT DP_IF_GetGroupName( IDirectPlayImpl *This, DPID idGroup, void *lp return DPERR_INVALIDGROUP; }
- dwRequiredDataSize = DP_CopyName( NULL, lpGData->name, bAnsi, bAnsi ); + dwRequiredDataSize = DP_CopyName( NULL, bAnsi ? lpGData->nameA : lpGData->name, bAnsi, bAnsi );
if( ( lpData == NULL ) || ( *lpdwDataSize < dwRequiredDataSize ) @@ -2813,7 +2834,7 @@ static HRESULT DP_IF_GetGroupName( IDirectPlayImpl *This, DPID idGroup, void *lp return DPERR_BUFFERTOOSMALL; }
- DP_CopyName( lpData, lpGData->name, bAnsi, bAnsi ); + DP_CopyName( lpData, bAnsi ? lpGData->nameA : lpGData->name, bAnsi, bAnsi );
return DP_OK; } @@ -3098,7 +3119,8 @@ static HRESULT DP_IF_GetPlayerName( IDirectPlayImpl *This, DPID idPlayer, void * return DPERR_INVALIDPLAYER; }
- dwRequiredDataSize = DP_CopyName( NULL, lpPList->lpPData->name, bAnsi, bAnsi ); + dwRequiredDataSize = DP_CopyName( NULL, bAnsi ? lpPList->lpPData->nameA : lpPList->lpPData->name, + bAnsi, bAnsi );
if( ( lpData == NULL ) || ( *lpdwDataSize < dwRequiredDataSize ) @@ -3108,7 +3130,7 @@ static HRESULT DP_IF_GetPlayerName( IDirectPlayImpl *This, DPID idPlayer, void * return DPERR_BUFFERTOOSMALL; }
- DP_CopyName( lpData, lpPList->lpPData->name, bAnsi, bAnsi ); + DP_CopyName( lpData, bAnsi ? lpPList->lpPData->nameA : lpPList->lpPData->name, bAnsi, bAnsi );
return DP_OK; } @@ -3655,6 +3677,7 @@ static HRESULT DP_IF_SetGroupName( IDirectPlayImpl *This, DPID idGroup, DPNAME * DWORD dwFlags, BOOL bAnsi ) { lpGroupData lpGData; + DPNAME *nameA; DPNAME *name;
TRACE( "(%p)->(0x%08lx,%p,0x%08lx,%u)\n", This, idGroup, @@ -3665,11 +3688,19 @@ static HRESULT DP_IF_SetGroupName( IDirectPlayImpl *This, DPID idGroup, DPNAME * return DPERR_INVALIDGROUP; }
- name = DP_DuplicateName( lpGroupName, bAnsi, bAnsi ); + name = DP_DuplicateName( lpGroupName, FALSE, bAnsi ); if ( !name ) return DPERR_OUTOFMEMORY;
+ nameA = DP_DuplicateName( lpGroupName, TRUE, bAnsi ); + if ( !nameA ) + { + free( name ); + return DPERR_OUTOFMEMORY; + } + lpGData->name = name; + lpGData->nameA = nameA;
/* Should send a DPMSG_SETPLAYERORGROUPNAME message */ FIXME( "Message not sent and dwFlags ignored\n" ); @@ -3793,6 +3824,7 @@ static HRESULT DP_IF_SetPlayerName( IDirectPlayImpl *This, DPID idPlayer, DPNAME DWORD dwFlags, BOOL bAnsi ) { lpPlayerList lpPList; + DPNAME *nameA; DPNAME *name;
TRACE( "(%p)->(0x%08lx,%p,0x%08lx,%u)\n", @@ -3808,11 +3840,19 @@ static HRESULT DP_IF_SetPlayerName( IDirectPlayImpl *This, DPID idPlayer, DPNAME return DPERR_INVALIDGROUP; }
- name = DP_DuplicateName( lpPlayerName, bAnsi, bAnsi ); + name = DP_DuplicateName( lpPlayerName, FALSE, bAnsi ); if ( !name ) return DPERR_OUTOFMEMORY;
+ nameA = DP_DuplicateName( lpPlayerName, TRUE, bAnsi ); + if ( !nameA ) + { + free( name ); + return DPERR_OUTOFMEMORY; + } + lpPList->lpPData->name = name; + lpPList->lpPData->nameA = nameA;
/* Should send a DPMSG_SETPLAYERORGROUPNAME message */ FIXME( "Message not sent and dwFlags ignored\n" ); diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index 58fc9de0a52..1bd9908f2dc 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -63,6 +63,7 @@ struct PlayerData DPID dpid;
DPNAME *name; + DPNAME *nameA; HANDLE hEvent;
ULONG uRef; /* What is the reference count on this data? */ @@ -106,6 +107,7 @@ struct GroupData
DPID dpid; DPNAME *name; + DPNAME *nameA;
/* View of local data */ LPVOID lpLocalData; diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 3f3ff59b677..3897cc8e52c 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -2075,8 +2075,8 @@ static BOOL CALLBACK checkPlayerListCallback( DPID dpid, DWORD playerType, const { if ( (char *) nameData <= shortName && shortName < (char *) nameData + nameDataSize ) { - todo_wine ok_( __FILE__, data->line )( shortName && !strcmp( shortName, player->expectedShortName ), - "got short name %s.\n", wine_dbgstr_a( shortName ) ); + ok_( __FILE__, data->line )( shortName && !strcmp( shortName, player->expectedShortName ), + "got short name %s.\n", wine_dbgstr_a( shortName ) ); } else { @@ -2092,8 +2092,8 @@ static BOOL CALLBACK checkPlayerListCallback( DPID dpid, DWORD playerType, const { if ( (char *) nameData <= longName && longName < (char *) nameData + nameDataSize ) { - todo_wine ok_( __FILE__, data->line )( longName && !strcmp( longName, player->expectedLongName ), - "got long name %s.\n", wine_dbgstr_a( longName ) ); + ok_( __FILE__, data->line )( longName && !strcmp( longName, player->expectedLongName ), + "got long name %s.\n", wine_dbgstr_a( longName ) ); } else {