From 6de7daac8f341fb7437feb29124534dc652b0311 Mon Sep 17 00:00:00 2001 From: Ismael Barros Date: Mon, 11 Aug 2008 03:59:16 +0200 Subject: [PATCH] dplayx: Made DP_SetSessionDesc public to use it from external modules Moved parameter checks to the external function so that they only check user input and don't get in the way when we're calling DP_SetSessionDesc internally. --- dlls/dplayx/dplay.c | 65 +++++++++++++++++++++++++++++----------------- dlls/dplayx/dplay_global.h | 4 +++ 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 78f6fa7c7e3..df37609685e 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -144,9 +144,6 @@ static HRESULT DP_IF_AddPlayerToGroup DPID idPlayer, BOOL bAnsi ); static HRESULT DP_IF_DeleteGroupFromGroup ( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup ); -static HRESULT DP_SetSessionDesc - ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpSessDesc, - DWORD dwFlags, BOOL bInitial, BOOL bAnsi ); static HRESULT DP_SecureOpen ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpsd, DWORD dwFlags, LPCDPSECURITYDESC lpSecurity, LPCDPCREDENTIALS lpCredentials, @@ -3423,7 +3420,7 @@ static HRESULT WINAPI DirectPlay2WImpl_SetPlayerName return DP_IF_SetPlayerName( This, idPlayer, lpPlayerName, dwFlags, FALSE ); } -static HRESULT DP_SetSessionDesc +HRESULT DP_SetSessionDesc ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpSessDesc, DWORD dwFlags, BOOL bInitial, BOOL bAnsi ) { @@ -3433,26 +3430,6 @@ static HRESULT DP_SetSessionDesc TRACE( "(%p)->(%p,0x%08x,%u,%u)\n", This, lpSessDesc, dwFlags, bInitial, bAnsi ); - if( dwFlags || (lpSessDesc == NULL) ) - { - return DPERR_INVALIDPARAMS; - } - - /* Illegal combinations of flags */ - if ( ( lpSessDesc->dwFlags & DPSESSION_MIGRATEHOST ) && - ( lpSessDesc->dwFlags & ( DPSESSION_CLIENTSERVER | - DPSESSION_MULTICASTSERVER | - DPSESSION_SECURESERVER ) ) ) - { - return DPERR_INVALIDFLAGS; - } - - /* Only the host is allowed to update the session desc */ - if( !This->dp2->bHostInterface ) - { - return DPERR_ACCESSDENIED; - } - /* FIXME: Copy into This->dp2->lpSessionDesc */ dwRequiredSize = DP_CalcSessionDescSize( lpSessDesc, bAnsi ); lpTempSessDesc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize ); @@ -3500,6 +3477,26 @@ static HRESULT WINAPI DirectPlay2AImpl_SetSessionDesc return DPERR_NOSESSIONS; } + if( dwFlags || (lpSessDesc == NULL) ) + { + return DPERR_INVALIDPARAMS; + } + + /* Illegal combinations of flags */ + if ( ( lpSessDesc->dwFlags & DPSESSION_MIGRATEHOST ) && + ( lpSessDesc->dwFlags & ( DPSESSION_CLIENTSERVER | + DPSESSION_MULTICASTSERVER | + DPSESSION_SECURESERVER ) ) ) + { + return DPERR_INVALIDFLAGS; + } + + /* Only the host is allowed to update the session desc */ + if( !This->dp2->bHostInterface ) + { + return DPERR_ACCESSDENIED; + } + return DP_SetSessionDesc( This, lpSessDesc, dwFlags, FALSE, TRUE ); } @@ -3518,6 +3515,26 @@ static HRESULT WINAPI DirectPlay2WImpl_SetSessionDesc return DPERR_NOSESSIONS; } + if( dwFlags || (lpSessDesc == NULL) ) + { + return DPERR_INVALIDPARAMS; + } + + /* Illegal combinations of flags */ + if ( ( lpSessDesc->dwFlags & DPSESSION_MIGRATEHOST ) && + ( lpSessDesc->dwFlags & ( DPSESSION_CLIENTSERVER | + DPSESSION_MULTICASTSERVER | + DPSESSION_SECURESERVER ) ) ) + { + return DPERR_INVALIDFLAGS; + } + + /* Only the host is allowed to update the session desc */ + if( !This->dp2->bHostInterface ) + { + return DPERR_ACCESSDENIED; + } + return DP_SetSessionDesc( This, lpSessDesc, dwFlags, FALSE, TRUE ); } diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index 994cfd61fbc..9d3b0c57ca3 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -236,6 +236,10 @@ HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpMessageBody, WORD wCommandId, WORD wVersion, LPVOID* lplpReply, LPDWORD lpdwMsgSize ); lpPlayerList DP_FindPlayer( IDirectPlay2AImpl* This, DPID dpid ); +HRESULT DP_SetSessionDesc( IDirectPlay2Impl* This, + LPCDPSESSIONDESC2 lpSessDesc, + DWORD dwFlags, BOOL bInitial, + BOOL bAnsi ); /* DP SP external interfaces into DirectPlay */ extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData ); -- 2.11.4.GIT