diff --git a/reactos/dll/directx/dplay/CMakeLists.txt b/reactos/dll/directx/dplay/CMakeLists.txt index 86dee460725..fd1e6e4bc59 100644 --- a/reactos/dll/directx/dplay/CMakeLists.txt +++ b/reactos/dll/directx/dplay/CMakeLists.txt @@ -1,5 +1,4 @@ - include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) spec2def(dplay.dll dplay.spec) @@ -10,23 +9,6 @@ add_library(dplay SHARED ${CMAKE_CURRENT_BINARY_DIR}/dplay.def) set_module_type(dplay win32dll UNICODE) - -target_link_libraries(dplay - uuid - wine) - -add_importlibs(dplay - msvcrt - user32 - advapi32 - ole32 - winmm - dinput - dplayx - kernel32 - ntdll) - +add_importlibs(dplay dplayx msvcrt kernel32 ntdll) add_dependencies(dplay psdk) - add_cd_file(TARGET dplay DESTINATION reactos/system32 FOR all) - diff --git a/reactos/dll/directx/dplay/version.rc b/reactos/dll/directx/dplay/version.rc index 6069c768af3..ed04c977ead 100644 --- a/reactos/dll/directx/dplay/version.rc +++ b/reactos/dll/directx/dplay/version.rc @@ -13,15 +13,15 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WINE_OLESELFREGISTER #define WINE_FILEDESCRIPTION_STR "Wine DirectPlay" #define WINE_FILENAME_STR "dplay.dll" #define WINE_FILEVERSION 5,3,0,900 #define WINE_FILEVERSION_STR "5.3.0.900" #define WINE_PRODUCTVERSION 5,3,0,900 #define WINE_PRODUCTVERSION_STR "5.3" +#define WINE_EXTRAVALUES VALUE "OLESelfRegister","" -#include "wine/wine_common_ver.rc" +#include diff --git a/reactos/dll/directx/dplayx/CMakeLists.txt b/reactos/dll/directx/dplayx/CMakeLists.txt index fbf7cea98f9..dfb38fdaf5d 100644 --- a/reactos/dll/directx/dplayx/CMakeLists.txt +++ b/reactos/dll/directx/dplayx/CMakeLists.txt @@ -1,4 +1,10 @@ +add_definitions( + -DCOM_NO_WINDOWS_H + -D__WINESRC__) + +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) + spec2def(dplayx.dll dplayx.spec ADD_IMPORTLIB) list(APPEND SOURCE @@ -11,23 +17,10 @@ list(APPEND SOURCE dplobby.c lobbysp.c name_server.c - regsvr.c - version.rc ${CMAKE_CURRENT_BINARY_DIR}/dplayx.def) -include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) - -add_library(dplayx SHARED ${SOURCE}) +add_library(dplayx SHARED ${SOURCE} version.rc) set_module_type(dplayx win32dll) -target_link_libraries(dplayx wine uuid dxguid) - -add_importlibs(dplayx - advapi32 - ole32 - user32 - winmm - msvcrt - kernel32 - ntdll) - +target_link_libraries(dplayx dxguid uuid wine) +add_importlibs(dplayx winmm ole32 user32 advapi32 msvcrt kernel32 ntdll) add_cd_file(TARGET dplayx DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/directx/dplayx/dpclassfactory.c b/reactos/dll/directx/dplayx/dpclassfactory.c index 55181b7cb2e..0f80b627780 100644 --- a/reactos/dll/directx/dplayx/dpclassfactory.c +++ b/reactos/dll/directx/dplayx/dpclassfactory.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ //#include @@ -27,6 +27,9 @@ //#include "objbase.h" //#include "winerror.h" #include +//#include "dplay.h" +//#include "dplobby.h" +//#include "initguid.h" #include "dpinit.h" WINE_DEFAULT_DEBUG_CHANNEL(dplay); @@ -39,13 +42,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(dplay); typedef struct { /* IUnknown fields */ - const IClassFactoryVtbl *lpVtbl; - LONG ref; + IClassFactory IClassFactory_iface; + LONG ref; } IClassFactoryImpl; +static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) +{ + return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface); +} + static HRESULT WINAPI DP_and_DPL_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + IClassFactoryImpl *This = impl_from_IClassFactory(iface); FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj); @@ -54,12 +62,12 @@ DP_and_DPL_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static ULONG WINAPI DP_and_DPL_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + IClassFactoryImpl *This = impl_from_IClassFactory(iface); return InterlockedIncrement(&This->ref); } static ULONG WINAPI DP_and_DPL_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + IClassFactoryImpl *This = impl_from_IClassFactory(iface); /* static class (reference starts @ 1), won't ever be freed */ return InterlockedDecrement(&This->ref); } @@ -67,7 +75,7 @@ static ULONG WINAPI DP_and_DPL_Release(LPCLASSFACTORY iface) { static HRESULT WINAPI DP_and_DPL_CreateInstance( LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj ) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + IClassFactoryImpl *This = impl_from_IClassFactory(iface); TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj); @@ -84,7 +92,7 @@ static HRESULT WINAPI DP_and_DPL_CreateInstance( } static HRESULT WINAPI DP_and_DPL_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + IClassFactoryImpl *This = impl_from_IClassFactory(iface); FIXME("(%p)->(%d),stub!\n",This,dolock); return S_OK; } @@ -97,7 +105,7 @@ static const IClassFactoryVtbl DP_and_DPL_Vtbl = { DP_and_DPL_LockServer }; -static IClassFactoryImpl DP_and_DPL_CF = {&DP_and_DPL_Vtbl, 1 }; +static IClassFactoryImpl DP_and_DPL_CF = {{&DP_and_DPL_Vtbl}, 1 }; /******************************************************************************* @@ -119,16 +127,16 @@ static IClassFactoryImpl DP_and_DPL_CF = {&DP_and_DPL_Vtbl, 1 }; */ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { - TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); + TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); if ( IsEqualCLSID( riid, &IID_IClassFactory ) ) { - *ppv = (LPVOID)&DP_and_DPL_CF; + *ppv = &DP_and_DPL_CF; IClassFactory_AddRef( (IClassFactory*)*ppv ); return S_OK; } - ERR("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); + ERR("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/reactos/dll/directx/dplayx/dpinit.h b/reactos/dll/directx/dplayx/dpinit.h index 1fac19dd889..17da5936306 100644 --- a/reactos/dll/directx/dplayx/dpinit.h +++ b/reactos/dll/directx/dplayx/dpinit.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DPINIT_H @@ -26,12 +26,12 @@ //#include "wtypes.h" #include "dplay_global.h" -extern HRESULT DP_CreateInterface( REFIID riid, LPVOID* ppvObj ); -extern HRESULT DPL_CreateInterface( REFIID riid, LPVOID* ppvObj ); +extern HRESULT DP_CreateInterface( REFIID riid, LPVOID* ppvObj ) DECLSPEC_HIDDEN; +extern HRESULT DPL_CreateInterface( REFIID riid, LPVOID* ppvObj ) DECLSPEC_HIDDEN; extern HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj, - IDirectPlay2Impl* dp ); + IDirectPlay2Impl* dp ) DECLSPEC_HIDDEN; extern HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj, - IDirectPlay2Impl* dp ); + IDirectPlay2Impl* dp ) DECLSPEC_HIDDEN; #endif diff --git a/reactos/dll/directx/dplayx/dplay.c b/reactos/dll/directx/dplayx/dplay.c index 2d036622512..c22dc2d30ff 100644 --- a/reactos/dll/directx/dplayx/dplay.c +++ b/reactos/dll/directx/dplayx/dplay.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include @@ -54,12 +54,12 @@ static lpPlayerList DP_FindPlayer( IDirectPlay2AImpl* This, DPID dpid ); static lpPlayerData DP_CreatePlayer( IDirectPlay2Impl* iface, LPDPID lpid, LPDPNAME lpName, DWORD dwFlags, HANDLE hEvent, BOOL bAnsi ); -static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, LPDPNAME lpSrc, BOOL bAnsi ); +static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, const DPNAME *lpSrc, BOOL bAnsi ); static void DP_SetPlayerData( lpPlayerData lpPData, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize ); -static lpGroupData DP_CreateGroup( IDirectPlay2AImpl* iface, LPDPID lpid, - LPDPNAME lpName, DWORD dwFlags, +static lpGroupData DP_CreateGroup( IDirectPlay2AImpl* iface, const DPID *lpid, + const DPNAME *lpName, DWORD dwFlags, DPID idParent, BOOL bAnsi ); static void DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize ); @@ -86,123 +86,123 @@ static const IDirectPlay3Vtbl directPlay3WVT; static const IDirectPlay4Vtbl directPlay4WVT; /* Helper methods for player/group interfaces */ -static HRESULT WINAPI DP_IF_DeletePlayerFromGroup +static HRESULT DP_IF_DeletePlayerFromGroup ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, DPID idPlayer, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_CreatePlayer +static HRESULT DP_IF_CreatePlayer ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, LPDPID lpidPlayer, LPDPNAME lpPlayerName, HANDLE hEvent, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_DestroyGroup +static HRESULT DP_IF_DestroyGroup ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_DestroyPlayer +static HRESULT DP_IF_DestroyPlayer ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idPlayer, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_EnumGroupPlayers +static HRESULT DP_IF_EnumGroupPlayers ( IDirectPlay2Impl* This, DPID idGroup, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_EnumGroups +static HRESULT DP_IF_EnumGroups ( IDirectPlay2Impl* This, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_EnumPlayers +static HRESULT DP_IF_EnumPlayers ( IDirectPlay2Impl* This, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetGroupData +static HRESULT DP_IF_GetGroupData ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetGroupName +static HRESULT DP_IF_GetGroupName ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetPlayerData +static HRESULT DP_IF_GetPlayerData ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetPlayerName +static HRESULT DP_IF_GetPlayerName ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_SetGroupName +static HRESULT DP_IF_SetGroupName ( IDirectPlay2Impl* This, DPID idGroup, LPDPNAME lpGroupName, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_SetPlayerData +static HRESULT DP_IF_SetPlayerData ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_SetPlayerName +static HRESULT DP_IF_SetPlayerName ( IDirectPlay2Impl* This, DPID idPlayer, LPDPNAME lpPlayerName, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_AddGroupToGroup +static HRESULT DP_IF_AddGroupToGroup ( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup ); -static HRESULT WINAPI DP_IF_CreateGroup +static HRESULT DP_IF_CreateGroup ( IDirectPlay2AImpl* This, LPVOID lpMsgHdr, LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_CreateGroupInGroup +static HRESULT DP_IF_CreateGroupInGroup ( IDirectPlay3Impl* This, LPVOID lpMsgHdr, DPID idParentGroup, LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_AddPlayerToGroup +static HRESULT DP_IF_AddPlayerToGroup ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, DPID idPlayer, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_DeleteGroupFromGroup +static HRESULT DP_IF_DeleteGroupFromGroup ( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup ); -static HRESULT WINAPI DP_SetSessionDesc +static HRESULT DP_SetSessionDesc ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpSessDesc, DWORD dwFlags, BOOL bInitial, BOOL bAnsi ); -static HRESULT WINAPI DP_SecureOpen +static HRESULT DP_SecureOpen ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpsd, DWORD dwFlags, LPCDPSECURITYDESC lpSecurity, LPCDPCREDENTIALS lpCredentials, BOOL bAnsi ); -static HRESULT WINAPI DP_SendEx +static HRESULT DP_SendEx ( IDirectPlay2Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, LPVOID lpContext, LPDWORD lpdwMsgID, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_Receive +static HRESULT DP_IF_Receive ( IDirectPlay2Impl* This, LPDPID lpidFrom, LPDPID lpidTo, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetMessageQueue +static HRESULT DP_IF_GetMessageQueue ( IDirectPlay4Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags, LPDWORD lpdwNumMsgs, LPDWORD lpdwNumBytes, BOOL bAnsi ); -static HRESULT WINAPI DP_SP_SendEx +static HRESULT DP_SP_SendEx ( IDirectPlay2Impl* This, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, LPVOID lpContext, LPDWORD lpdwMsgID ); -static HRESULT WINAPI DP_IF_SetGroupData +static HRESULT DP_IF_SetGroupData ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetPlayerCaps +static HRESULT DP_IF_GetPlayerCaps ( IDirectPlay2Impl* This, DPID idPlayer, LPDPCAPS lpDPCaps, DWORD dwFlags ); -static HRESULT WINAPI DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_CancelMessage +static HRESULT DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi ); +static HRESULT DP_IF_CancelMessage ( IDirectPlay4Impl* This, DWORD dwMsgID, DWORD dwFlags, DWORD dwMinPriority, DWORD dwMaxPriority, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_EnumGroupsInGroup +static HRESULT DP_IF_EnumGroupsInGroup ( IDirectPlay3AImpl* This, DPID idGroup, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetGroupParent +static HRESULT DP_IF_GetGroupParent ( IDirectPlay3AImpl* This, DPID idGroup, LPDPID lpidGroup, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_GetCaps +static HRESULT DP_IF_GetCaps ( IDirectPlay2Impl* This, LPDPCAPS lpDPCaps, DWORD dwFlags ); -static HRESULT WINAPI DP_IF_EnumSessions +static HRESULT DP_IF_EnumSessions ( IDirectPlay2Impl* This, LPDPSESSIONDESC2 lpsd, DWORD dwTimeout, LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ); -static HRESULT WINAPI DP_IF_InitializeConnection +static HRESULT DP_IF_InitializeConnection ( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi ); static BOOL CALLBACK cbDPCreateEnumConnections( LPCGUID lpguidSP, LPVOID lpConnection, DWORD dwConnectionSize, LPCDPNAME lpName, DWORD dwFlags, LPVOID lpContext ); -static BOOL WINAPI DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf, - LPDWORD lpdwBufSize ); +static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf, + LPDWORD lpdwBufSize ); static inline DPID DP_NextObjectId(void); static DPID DP_GetRemoteNextObjectId(void); - +static DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ); static void DP_CopySessionDesc( LPDPSESSIONDESC2 destSessionDesc, LPCDPSESSIONDESC2 srcSessDesc, BOOL bAnsi ); @@ -234,7 +234,7 @@ static LONG kludgePlayerGroupId = 1000; static BOOL DP_CreateIUnknown( LPVOID lpDP ) { - IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP; + IDirectPlay2AImpl *This = lpDP; This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) ); if ( This->unk == NULL ) @@ -243,14 +243,16 @@ static BOOL DP_CreateIUnknown( LPVOID lpDP ) } InitializeCriticalSection( &This->unk->DP_lock ); + This->unk->DP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlay2AImpl*->DirectPlayIUnknownData*->DP_lock"); return TRUE; } static BOOL DP_DestroyIUnknown( LPVOID lpDP ) { - IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP; + IDirectPlay2AImpl *This = lpDP; + This->unk->DP_lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &This->unk->DP_lock ); HeapFree( GetProcessHeap(), 0, This->unk ); @@ -259,7 +261,7 @@ static BOOL DP_DestroyIUnknown( LPVOID lpDP ) static BOOL DP_CreateDirectPlay2( LPVOID lpDP ) { - IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP; + IDirectPlay2AImpl *This = lpDP; This->dp2 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dp2) ) ); if ( This->dp2 == NULL ) @@ -270,12 +272,13 @@ static BOOL DP_CreateDirectPlay2( LPVOID lpDP ) This->dp2->bConnectionOpen = FALSE; This->dp2->hEnumSessionThread = INVALID_HANDLE_VALUE; + This->dp2->dwEnumSessionLock = 0; This->dp2->bHostInterface = FALSE; DPQ_INIT(This->dp2->receiveMsgs); DPQ_INIT(This->dp2->sendMsgs); - DPQ_INIT(This->dp2->replysExpected); + DPQ_INIT(This->dp2->repliesExpected); if( !NS_InitializeSessionCache( &This->dp2->lpNameServerData ) ) { @@ -335,36 +338,9 @@ DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID ) HeapFree( GetProcessHeap(), 0, elem ); } -/* Function to delete the list of groups with this interface. Needs to - * delete the group and player lists associated with this group as well - * as the group data associated with this group. It should not delete - * player data as that is shared with the top player list and will be - * deleted with that. - */ -DPQ_DECL_DELETECB( cbDeleteGroupsElem, lpGroupList ); -DPQ_DECL_DELETECB( cbDeleteGroupsElem, lpGroupList ) -{ - DPQ_DELETEQ( elem->lpGData->groups, groups, - lpGroupList, cbDeleteElemFromHeap ); - DPQ_DELETEQ( elem->lpGData->players, players, - lpPlayerList, cbDeleteElemFromHeap ); - HeapFree( GetProcessHeap(), 0, elem->lpGData ); - HeapFree( GetProcessHeap(), 0, elem ); -} - -/* Function to delete the list of players with this interface. Needs to - * delete the player data for all players as well. - */ -DPQ_DECL_DELETECB( cbDeletePlayerElem, lpPlayerList ); -DPQ_DECL_DELETECB( cbDeletePlayerElem, lpPlayerList ) -{ - HeapFree( GetProcessHeap(), 0, elem->lpPData ); - HeapFree( GetProcessHeap(), 0, elem ); -} - static BOOL DP_DestroyDirectPlay2( LPVOID lpDP ) { - IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)lpDP; + IDirectPlay2AImpl *This = lpDP; if( This->dp2->hEnumSessionThread != INVALID_HANDLE_VALUE ) { @@ -401,11 +377,6 @@ static BOOL DP_DestroyDirectPlay2( LPVOID lpDP ) FreeLibrary( This->dp2->hDPLobbyProvider ); } -#if 0 - DPQ_DELETEQ( This->dp2->players, players, lpPlayerList, cbDeletePlayerElem ); - DPQ_DELETEQ( This->dp2->groups, groups, lpGroupList, cbDeleteGroupsElem ); -#endif - /* FIXME: Need to delete receive and send msgs queue contents */ NS_DeleteSessionCache( This->dp2->lpNameServerData ); @@ -422,7 +393,7 @@ static BOOL DP_DestroyDirectPlay2( LPVOID lpDP ) static BOOL DP_CreateDirectPlay3( LPVOID lpDP ) { - IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)lpDP; + IDirectPlay3AImpl *This = lpDP; This->dp3 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dp3) ) ); if ( This->dp3 == NULL ) @@ -435,7 +406,7 @@ static BOOL DP_CreateDirectPlay3( LPVOID lpDP ) static BOOL DP_DestroyDirectPlay3( LPVOID lpDP ) { - IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)lpDP; + IDirectPlay3AImpl *This = lpDP; /* Delete the contents */ HeapFree( GetProcessHeap(), 0, This->dp3 ); @@ -445,7 +416,7 @@ static BOOL DP_DestroyDirectPlay3( LPVOID lpDP ) static BOOL DP_CreateDirectPlay4( LPVOID lpDP ) { - IDirectPlay4AImpl *This = (IDirectPlay4AImpl *)lpDP; + IDirectPlay4AImpl *This = lpDP; This->dp4 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dp4) ) ); if ( This->dp4 == NULL ) @@ -458,7 +429,7 @@ static BOOL DP_CreateDirectPlay4( LPVOID lpDP ) static BOOL DP_DestroyDirectPlay4( LPVOID lpDP ) { - IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)lpDP; + IDirectPlay3AImpl *This = lpDP; /* Delete the contents */ HeapFree( GetProcessHeap(), 0, This->dp4 ); @@ -468,7 +439,6 @@ static BOOL DP_DestroyDirectPlay4( LPVOID lpDP ) /* Create a new interface */ -extern HRESULT DP_CreateInterface ( REFIID riid, LPVOID* ppvObj ) { @@ -484,32 +454,32 @@ HRESULT DP_CreateInterface if( IsEqualGUID( &IID_IDirectPlay2, riid ) ) { - IDirectPlay2Impl *This = (IDirectPlay2Impl *)*ppvObj; + IDirectPlay2Impl *This = *ppvObj; This->lpVtbl = &directPlay2WVT; } else if( IsEqualGUID( &IID_IDirectPlay2A, riid ) ) { - IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)*ppvObj; + IDirectPlay2AImpl *This = *ppvObj; This->lpVtbl = &directPlay2AVT; } else if( IsEqualGUID( &IID_IDirectPlay3, riid ) ) { - IDirectPlay3Impl *This = (IDirectPlay3Impl *)*ppvObj; + IDirectPlay3Impl *This = *ppvObj; This->lpVtbl = &directPlay3WVT; } else if( IsEqualGUID( &IID_IDirectPlay3A, riid ) ) { - IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)*ppvObj; + IDirectPlay3AImpl *This = *ppvObj; This->lpVtbl = &directPlay3AVT; } else if( IsEqualGUID( &IID_IDirectPlay4, riid ) ) { - IDirectPlay4Impl *This = (IDirectPlay4Impl *)*ppvObj; + IDirectPlay4Impl *This = *ppvObj; This->lpVtbl = &directPlay4WVT; } else if( IsEqualGUID( &IID_IDirectPlay4A, riid ) ) { - IDirectPlay4AImpl *This = (IDirectPlay4AImpl *)*ppvObj; + IDirectPlay4AImpl *This = *ppvObj; This->lpVtbl = &directPlay4AVT; } else @@ -568,32 +538,32 @@ static HRESULT WINAPI DP_QueryInterface if( IsEqualGUID( &IID_IDirectPlay2, riid ) ) { - IDirectPlay2Impl *This = (IDirectPlay2Impl *)*ppvObj; + IDirectPlay2Impl *This = *ppvObj; This->lpVtbl = &directPlay2WVT; } else if( IsEqualGUID( &IID_IDirectPlay2A, riid ) ) { - IDirectPlay2AImpl *This = (IDirectPlay2AImpl *)*ppvObj; + IDirectPlay2AImpl *This = *ppvObj; This->lpVtbl = &directPlay2AVT; } else if( IsEqualGUID( &IID_IDirectPlay3, riid ) ) { - IDirectPlay3Impl *This = (IDirectPlay3Impl *)*ppvObj; + IDirectPlay3Impl *This = *ppvObj; This->lpVtbl = &directPlay3WVT; } else if( IsEqualGUID( &IID_IDirectPlay3A, riid ) ) { - IDirectPlay3AImpl *This = (IDirectPlay3AImpl *)*ppvObj; + IDirectPlay3AImpl *This = *ppvObj; This->lpVtbl = &directPlay3AVT; } else if( IsEqualGUID( &IID_IDirectPlay4, riid ) ) { - IDirectPlay4Impl *This = (IDirectPlay4Impl *)*ppvObj; + IDirectPlay4Impl *This = *ppvObj; This->lpVtbl = &directPlay4WVT; } else if( IsEqualGUID( &IID_IDirectPlay4A, riid ) ) { - IDirectPlay4AImpl *This = (IDirectPlay4AImpl *)*ppvObj; + IDirectPlay4AImpl *This = *ppvObj; This->lpVtbl = &directPlay4AVT; } else @@ -620,7 +590,7 @@ static ULONG WINAPI DP_AddRef ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef ); - TRACE( "ref count incremented to %lu:%lu for %p\n", + TRACE( "ref count incremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); return ulObjRefCount; @@ -636,7 +606,7 @@ static ULONG WINAPI DP_Release ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef ); - TRACE( "ref count decremented to %lu:%lu for %p\n", + TRACE( "ref count decremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); /* Deallocate if this is the last reference to the object */ @@ -670,7 +640,7 @@ HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody, WORD wCommandId, WORD wVersion, LPVOID* lplpReply, LPDWORD lpdwMsgSize ) { - TRACE( "(%p)->(%p,0x%08lx,%p,%u,%u)\n", + TRACE( "(%p)->(%p,0x%08x,%p,%u,%u)\n", This, lpcMessageBody, dwMessageBodySize, lpcMessageHeader, wCommandId, wVersion ); @@ -678,28 +648,22 @@ HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody, { /* Name server needs to handle this request */ case DPMSGCMD_ENUMSESSIONSREQUEST: - { /* Reply expected */ NS_ReplyToEnumSessionsRequest( lpcMessageBody, lplpReply, lpdwMsgSize, This ); - break; - } /* Name server needs to handle this request */ case DPMSGCMD_ENUMSESSIONSREPLY: - { /* No reply expected */ NS_AddRemoteComputerAsNameServer( lpcMessageHeader, This->dp2->spData.dwSPHeaderSize, - (LPDPMSG_ENUMSESSIONSREPLY)lpcMessageBody, + lpcMessageBody, This->dp2->lpNameServerData ); break; - } case DPMSGCMD_REQUESTNEWPLAYERID: { - LPCDPMSG_REQUESTNEWPLAYERID lpcMsg = - (LPCDPMSG_REQUESTNEWPLAYERID)lpcMessageBody; + LPCDPMSG_REQUESTNEWPLAYERID lpcMsg = lpcMessageBody; LPDPMSG_NEWPLAYERIDREPLY lpReply; @@ -707,7 +671,7 @@ HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody, *lplpReply = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, *lpdwMsgSize ); - FIXME( "Ignoring dwFlags 0x%08lx in request msg\n", + FIXME( "Ignoring dwFlags 0x%08x in request msg\n", lpcMsg->dwFlags ); /* Setup the reply */ @@ -720,58 +684,45 @@ HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody, lpReply->dpidNewPlayerId = DP_NextObjectId(); - TRACE( "Allocating new playerid 0x%08lx from remote request\n", + TRACE( "Allocating new playerid 0x%08x from remote request\n", lpReply->dpidNewPlayerId ); - break; } case DPMSGCMD_GETNAMETABLEREPLY: case DPMSGCMD_NEWPLAYERIDREPLY: - { - #if 0 if( wCommandId == DPMSGCMD_NEWPLAYERIDREPLY ) DebugBreak(); #endif DP_MSG_ReplyReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize ); - break; - } #if 1 case DPMSGCMD_JUSTENVELOPE: - { - TRACE( "GOT THE SELF MESSAGE: %p -> 0x%08lx\n", lpcMessageHeader, ((LPDWORD)lpcMessageHeader)[1] ); + TRACE( "GOT THE SELF MESSAGE: %p -> 0x%08x\n", lpcMessageHeader, ((const DWORD *)lpcMessageHeader)[1] ); NS_SetLocalAddr( This->dp2->lpNameServerData, lpcMessageHeader, 20 ); DP_MSG_ReplyReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize ); - } #endif case DPMSGCMD_FORWARDADDPLAYER: - { #if 0 DebugBreak(); #endif #if 1 - TRACE( "Sending message to self to get my addr\n" ); - DP_MSG_ToSelf( This, 1 ); /* This is a hack right now */ + TRACE( "Sending message to self to get my addr\n" ); + DP_MSG_ToSelf( This, 1 ); /* This is a hack right now */ #endif break; - } case DPMSGCMD_FORWARDADDPLAYERNACK: - { DP_MSG_ErrorReceived( This, wCommandId, lpcMessageBody, dwMessageBodySize ); break; - } default: - { FIXME( "Unknown wCommandId %u. Ignoring message\n", wCommandId ); DebugBreak(); break; - } } /* FIXME: There is code in dplaysp.c to handle dplay commands. Move to here. */ @@ -780,7 +731,7 @@ HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpcMessageBody, } -static HRESULT WINAPI DP_IF_AddPlayerToGroup +static HRESULT DP_IF_AddPlayerToGroup ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, DPID idPlayer, BOOL bAnsi ) { @@ -788,9 +739,14 @@ static HRESULT WINAPI DP_IF_AddPlayerToGroup lpPlayerList lpPList; lpPlayerList lpNewPList; - TRACE( "(%p)->(%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(%p,0x%08x,0x%08x,%u)\n", This, lpMsgHdr, idGroup, idPlayer, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + /* Find the group */ if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL ) { @@ -869,7 +825,7 @@ static HRESULT WINAPI DirectPlay2WImpl_AddPlayerToGroup return DP_IF_AddPlayerToGroup( This, NULL, idGroup, idPlayer, FALSE ); } -static HRESULT WINAPI DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi ) +static HRESULT DP_IF_Close( IDirectPlay2Impl* This, BOOL bAnsi ) { HRESULT hr = DP_OK; @@ -916,8 +872,8 @@ static HRESULT WINAPI DirectPlay2WImpl_Close } static -lpGroupData DP_CreateGroup( IDirectPlay2AImpl* This, LPDPID lpid, - LPDPNAME lpName, DWORD dwFlags, +lpGroupData DP_CreateGroup( IDirectPlay2AImpl* This, const DPID *lpid, + const DPNAME *lpName, DWORD dwFlags, DPID idParent, BOOL bAnsi ) { lpGroupData lpGData; @@ -944,7 +900,7 @@ lpGroupData DP_CreateGroup( IDirectPlay2AImpl* This, LPDPID lpid, /* FIXME: Should we validate the dwFlags? */ lpGData->dwFlags = dwFlags; - TRACE( "Created group id 0x%08lx\n", *lpid ); + TRACE( "Created group id 0x%08x\n", *lpid ); return lpGData; } @@ -955,13 +911,13 @@ DP_DeleteGroup( IDirectPlay2Impl* This, DPID dpid ) { lpGroupList lpGList; - TRACE( "(%p)->(0x%08lx)\n", This, dpid ); + TRACE( "(%p)->(0x%08x)\n", This, dpid ); DPQ_REMOVE_ENTRY( This->dp2->lpSysGroup->groups, groups, lpGData->dpid, ==, dpid, lpGList ); if( lpGList == NULL ) { - ERR( "DPID 0x%08lx not found\n", dpid ); + ERR( "DPID 0x%08x not found\n", dpid ); return; } @@ -984,7 +940,7 @@ static lpGroupData DP_FindAnyGroup( IDirectPlay2AImpl* This, DPID dpid ) { lpGroupList lpGroups; - TRACE( "(%p)->(0x%08lx)\n", This, dpid ); + TRACE( "(%p)->(0x%08x)\n", This, dpid ); if( dpid == DPID_SYSTEM_GROUP ) { @@ -1003,17 +959,22 @@ static lpGroupData DP_FindAnyGroup( IDirectPlay2AImpl* This, DPID dpid ) return lpGroups->lpGData; } -static HRESULT WINAPI DP_IF_CreateGroup +static HRESULT DP_IF_CreateGroup ( IDirectPlay2AImpl* This, LPVOID lpMsgHdr, LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ) { lpGroupData lpGData; - TRACE( "(%p)->(%p,%p,%p,%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(%p,%p,%p,%p,0x%08x,0x%08x,%u)\n", This, lpMsgHdr, lpidGroup, lpGroupName, lpData, dwDataSize, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + /* If the name is not specified, we must provide one */ if( DPID_UNKNOWN == *lpidGroup ) { @@ -1165,10 +1126,6 @@ DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags, /* Reallocate for new data */ if( lpData != NULL ) { - LPVOID lpNewData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof( dwDataSize ) ); - CopyMemory( lpNewData, lpData, dwDataSize ); - if( dwFlags & DPSET_LOCAL ) { lpGData->lpLocalData = lpData; @@ -1176,7 +1133,8 @@ DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags, } else { - lpGData->lpRemoteData = lpNewData; + lpGData->lpRemoteData = HeapAlloc( GetProcessHeap(), 0, dwDataSize ); + CopyMemory( lpGData->lpRemoteData, lpData, dwDataSize ); lpGData->dwRemoteDataSize = dwDataSize; } } @@ -1223,7 +1181,10 @@ lpPlayerData DP_CreatePlayer( IDirectPlay2Impl* This, LPDPID lpid, /* Initialize the SP data section */ lpPData->lpSPPlayerData = DPSP_CreateSPPlayerData(); - TRACE( "Created player id 0x%08lx\n", *lpid ); + TRACE( "Created player id 0x%08x\n", *lpid ); + + if( ~dwFlags & DPLAYI_PLAYER_SYSPLAYER ) + This->dp2->lpSessionDesc->dwCurrentPlayers++; return lpPData; } @@ -1232,8 +1193,8 @@ lpPlayerData DP_CreatePlayer( IDirectPlay2Impl* This, LPDPID lpid, static void DP_DeleteDPNameStruct( LPDPNAME lpDPName ) { - HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->lpszShortNameA ); - HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->lpszLongNameA ); + HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->u1.lpszShortNameA ); + HeapFree( GetProcessHeap(), HEAP_ZERO_MEMORY, lpDPName->u2.lpszLongNameA ); } /* This method assumes that all links to it are already deleted */ @@ -1242,13 +1203,13 @@ DP_DeletePlayer( IDirectPlay2Impl* This, DPID dpid ) { lpPlayerList lpPList; - TRACE( "(%p)->(0x%08lx)\n", This, dpid ); + TRACE( "(%p)->(0x%08x)\n", This, dpid ); DPQ_REMOVE_ENTRY( This->dp2->lpSysGroup->players, players, lpPData->dpid, ==, dpid, lpPList ); if( lpPList == NULL ) { - ERR( "DPID 0x%08lx not found\n", dpid ); + ERR( "DPID 0x%08x not found\n", dpid ); return; } @@ -1273,7 +1234,10 @@ static lpPlayerList DP_FindPlayer( IDirectPlay2AImpl* This, DPID dpid ) { lpPlayerList lpPlayers; - TRACE( "(%p)->(0x%08lx)\n", This, dpid ); + TRACE( "(%p)->(0x%08x)\n", This, dpid ); + + if(This->dp2->lpSysGroup == NULL) + return NULL; DPQ_FIND_ENTRY( This->dp2->lpSysGroup->players, players, lpPData->dpid, ==, dpid, lpPlayers ); @@ -1281,7 +1245,7 @@ static lpPlayerList DP_FindPlayer( IDirectPlay2AImpl* This, DPID dpid ) } /* Basic area for Dst must already be allocated */ -static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, LPDPNAME lpSrc, BOOL bAnsi ) +static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, const DPNAME *lpSrc, BOOL bAnsi ) { if( lpSrc == NULL ) { @@ -1296,40 +1260,40 @@ static BOOL DP_CopyDPNAMEStruct( LPDPNAME lpDst, LPDPNAME lpSrc, BOOL bAnsi ) } /* Delete any existing pointers */ - HeapFree( GetProcessHeap(), 0, lpDst->lpszShortNameA ); - HeapFree( GetProcessHeap(), 0, lpDst->lpszLongNameA ); + HeapFree( GetProcessHeap(), 0, lpDst->u1.lpszShortNameA ); + HeapFree( GetProcessHeap(), 0, lpDst->u2.lpszLongNameA ); /* Copy as required */ CopyMemory( lpDst, lpSrc, lpSrc->dwSize ); if( bAnsi ) { - if( lpSrc->lpszShortNameA ) + if( lpSrc->u1.lpszShortNameA ) { - lpDst->lpszShortNameA = HeapAlloc( GetProcessHeap(), 0, - strlen(lpSrc->lpszShortNameA)+1 ); - strcpy( lpDst->lpszShortNameA, lpSrc->lpszShortNameA ); + lpDst->u1.lpszShortNameA = HeapAlloc( GetProcessHeap(), 0, + strlen(lpSrc->u1.lpszShortNameA)+1 ); + strcpy( lpDst->u1.lpszShortNameA, lpSrc->u1.lpszShortNameA ); } - if( lpSrc->lpszLongNameA ) + if( lpSrc->u2.lpszLongNameA ) { - lpDst->lpszLongNameA = HeapAlloc( GetProcessHeap(), 0, - strlen(lpSrc->lpszLongNameA)+1 ); - strcpy( lpDst->lpszLongNameA, lpSrc->lpszLongNameA ); + lpDst->u2.lpszLongNameA = HeapAlloc( GetProcessHeap(), 0, + strlen(lpSrc->u2.lpszLongNameA)+1 ); + strcpy( lpDst->u2.lpszLongNameA, lpSrc->u2.lpszLongNameA ); } } else { - if( lpSrc->lpszShortNameA ) + if( lpSrc->u1.lpszShortNameA ) { - lpDst->lpszShortName = HeapAlloc( GetProcessHeap(), 0, - (strlenW(lpSrc->lpszShortName)+1)*sizeof(WCHAR) ); - strcpyW( lpDst->lpszShortName, lpSrc->lpszShortName ); + lpDst->u1.lpszShortName = HeapAlloc( GetProcessHeap(), 0, + (strlenW(lpSrc->u1.lpszShortName)+1)*sizeof(WCHAR) ); + strcpyW( lpDst->u1.lpszShortName, lpSrc->u1.lpszShortName ); } - if( lpSrc->lpszLongNameA ) + if( lpSrc->u2.lpszLongNameA ) { - lpDst->lpszLongName = HeapAlloc( GetProcessHeap(), 0, - (strlenW(lpSrc->lpszLongName)+1)*sizeof(WCHAR) ); - strcpyW( lpDst->lpszLongName, lpSrc->lpszLongName ); + lpDst->u2.lpszLongName = HeapAlloc( GetProcessHeap(), 0, + (strlenW(lpSrc->u2.lpszLongName)+1)*sizeof(WCHAR) ); + strcpyW( lpDst->u2.lpszLongName, lpSrc->u2.lpszLongName ); } } @@ -1363,9 +1327,6 @@ DP_SetPlayerData( lpPlayerData lpPData, DWORD dwFlags, /* Reallocate for new data */ if( lpData != NULL ) { - LPVOID lpNewData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof( dwDataSize ) ); - CopyMemory( lpNewData, lpData, dwDataSize ); if( dwFlags & DPSET_LOCAL ) { @@ -1374,14 +1335,15 @@ DP_SetPlayerData( lpPlayerData lpPData, DWORD dwFlags, } else { - lpPData->lpRemoteData = lpNewData; + lpPData->lpRemoteData = HeapAlloc( GetProcessHeap(), 0, dwDataSize ); + CopyMemory( lpPData->lpRemoteData, lpData, dwDataSize ); lpPData->dwRemoteDataSize = dwDataSize; } } } -static HRESULT WINAPI DP_IF_CreatePlayer +static HRESULT DP_IF_CreatePlayer ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, /* NULL for local creation, non NULL for remote creation */ LPDPID lpidPlayer, @@ -1397,9 +1359,13 @@ static HRESULT WINAPI DP_IF_CreatePlayer lpPlayerList lpPList; DWORD dwCreateFlags = 0; - TRACE( "(%p)->(%p,%p,%p,%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(%p,%p,%p,%p,0x%08x,0x%08x,%u)\n", This, lpidPlayer, lpPlayerName, hEvent, lpData, dwDataSize, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } if( dwFlags == 0 ) { @@ -1447,7 +1413,7 @@ static HRESULT WINAPI DP_IF_CreatePlayer ) { /* Assume non fatal failure */ - ERR( "unknown dwFlags = 0x%08lx\n", dwFlags ); + ERR( "unknown dwFlags = 0x%08x\n", dwFlags ); } /* If the name is not specified, we must provide one */ @@ -1476,8 +1442,9 @@ static HRESULT WINAPI DP_IF_CreatePlayer */ } - /* FIXME: Should we be storing these dwFlags or the creation ones? */ - lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwFlags, + /* We pass creation flags, so we can distinguish sysplayers and not count them in the current + player total */ + lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwCreateFlags, hEvent, bAnsi ); if( lpPData == NULL ) @@ -1512,7 +1479,7 @@ static HRESULT WINAPI DP_IF_CreatePlayer data.lpSPMessageHeader = lpMsgHdr; data.lpISP = This->dp2->spData.lpISP; - TRACE( "Calling SP CreatePlayer 0x%08lx: dwFlags: 0x%08lx lpMsgHdr: %p\n", + TRACE( "Calling SP CreatePlayer 0x%08x: dwFlags: 0x%08x lpMsgHdr: %p\n", *lpidPlayer, data.dwFlags, data.lpSPMessageHeader ); hr = (*This->dp2->spData.lpCB->CreatePlayer)( &data ); @@ -1598,6 +1565,11 @@ static HRESULT WINAPI DirectPlay2AImpl_CreatePlayer { IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface; + if( lpidPlayer == NULL ) + { + return DPERR_INVALIDPARAMS; + } + if( dwFlags & DPPLAYER_SERVERPLAYER ) { *lpidPlayer = DPID_SERVERPLAYER; @@ -1617,6 +1589,11 @@ static HRESULT WINAPI DirectPlay2WImpl_CreatePlayer { IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface; + if( lpidPlayer == NULL ) + { + return DPERR_INVALIDPARAMS; + } + if( dwFlags & DPPLAYER_SERVERPLAYER ) { *lpidPlayer = DPID_SERVERPLAYER; @@ -1638,7 +1615,7 @@ static DPID DP_GetRemoteNextObjectId(void) return DP_NextObjectId(); } -static HRESULT WINAPI DP_IF_DeletePlayerFromGroup +static HRESULT DP_IF_DeletePlayerFromGroup ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, DPID idPlayer, BOOL bAnsi ) { @@ -1647,7 +1624,7 @@ static HRESULT WINAPI DP_IF_DeletePlayerFromGroup lpGroupData lpGData; lpPlayerList lpPList; - TRACE( "(%p)->(%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(%p,0x%08x,0x%08x,%u)\n", This, lpMsgHdr, idGroup, idPlayer, bAnsi ); /* Find the group */ @@ -1727,7 +1704,7 @@ cbRemoveGroupOrPlayer( { lpDPRGOPContext lpCtxt = (lpDPRGOPContext)lpContext; - TRACE( "Removing element:0x%08lx (type:0x%08lx) from element:0x%08lx\n", + TRACE( "Removing element:0x%08x (type:0x%08x) from element:0x%08x\n", dpId, dwPlayerType, lpCtxt->idGroup ); if( dwPlayerType == DPPLAYERTYPE_GROUP ) @@ -1737,7 +1714,7 @@ cbRemoveGroupOrPlayer( ) ) { - ERR( "Unable to delete group 0x%08lx from group 0x%08lx\n", + ERR( "Unable to delete group 0x%08x from group 0x%08x\n", dpId, lpCtxt->idGroup ); } } @@ -1749,7 +1726,7 @@ cbRemoveGroupOrPlayer( ) ) { - ERR( "Unable to delete player 0x%08lx from grp 0x%08lx\n", + ERR( "Unable to delete player 0x%08x from grp 0x%08x\n", dpId, lpCtxt->idGroup ); } } @@ -1757,13 +1734,13 @@ cbRemoveGroupOrPlayer( return TRUE; /* Continue enumeration */ } -static HRESULT WINAPI DP_IF_DestroyGroup +static HRESULT DP_IF_DestroyGroup ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idGroup, BOOL bAnsi ) { lpGroupData lpGData; DPRGOPContext context; - FIXME( "(%p)->(%p,0x%08lx,%u): semi stub\n", + FIXME( "(%p)->(%p,0x%08x,%u): semi stub\n", This, lpMsgHdr, idGroup, bAnsi ); /* Find the group */ @@ -1778,7 +1755,7 @@ static HRESULT WINAPI DP_IF_DestroyGroup /* Remove all players that this group has */ DP_IF_EnumGroupPlayers( This, idGroup, NULL, - cbRemoveGroupOrPlayer, (LPVOID)&context, 0, bAnsi ); + cbRemoveGroupOrPlayer, &context, 0, bAnsi ); /* Remove all links to groups that this group has since this is dp3 */ DP_IF_EnumGroupsInGroup( (IDirectPlay3Impl*)This, idGroup, NULL, @@ -1836,12 +1813,12 @@ typedef struct _DPFAGContext BOOL bAnsi; } DPFAGContext, *lpDPFAGContext; -static HRESULT WINAPI DP_IF_DestroyPlayer +static HRESULT DP_IF_DestroyPlayer ( IDirectPlay2Impl* This, LPVOID lpMsgHdr, DPID idPlayer, BOOL bAnsi ) { DPFAGContext cbContext; - FIXME( "(%p)->(%p,0x%08lx,%u): semi stub\n", + FIXME( "(%p)->(%p,0x%08x,%u): semi stub\n", This, lpMsgHdr, idPlayer, bAnsi ); if( This->dp2->connectionInitialized == NO_PROVIDER ) @@ -1863,7 +1840,7 @@ static HRESULT WINAPI DP_IF_DestroyPlayer /* Find each group and call DeletePlayerFromGroup if the player is a member of the group */ DP_IF_EnumGroups( This, NULL, cbDeletePlayerFromAllGroups, - (LPVOID)&cbContext, DPENUMGROUPS_ALL, bAnsi ); + &cbContext, DPENUMGROUPS_ALL, bAnsi ); /* Now delete player and player list from the sys group */ DP_DeletePlayer( This, idPlayer ); @@ -1908,13 +1885,13 @@ cbDeletePlayerFromAllGroups( DP_IF_EnumGroupsInGroup( (IDirectPlay3Impl*)lpCtxt->This, dpId, NULL, cbDeletePlayerFromAllGroups, - (LPVOID)lpContext, DPENUMGROUPS_ALL, + lpContext, DPENUMGROUPS_ALL, lpCtxt->bAnsi ); } else { - ERR( "Group callback has dwPlayerType = 0x%08lx\n", dwPlayerType ); + ERR( "Group callback has dwPlayerType = 0x%08x\n", dwPlayerType ); } return TRUE; @@ -1934,7 +1911,7 @@ static HRESULT WINAPI DirectPlay2WImpl_DestroyPlayer return DP_IF_DestroyPlayer( This, NULL, idPlayer, FALSE ); } -static HRESULT WINAPI DP_IF_EnumGroupPlayers +static HRESULT DP_IF_EnumGroupPlayers ( IDirectPlay2Impl* This, DPID idGroup, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ) @@ -1942,7 +1919,7 @@ static HRESULT WINAPI DP_IF_EnumGroupPlayers lpGroupData lpGData; lpPlayerList lpPList; - FIXME("(%p)->(0x%08lx,%p,%p,%p,0x%08lx,%u): semi stub\n", + FIXME("(%p)->(0x%08x,%p,%p,%p,0x%08x,%u): semi stub\n", This, idGroup, lpguidInstance, lpEnumPlayersCallback2, lpContext, dwFlags, bAnsi ); @@ -1968,7 +1945,7 @@ static HRESULT WINAPI DP_IF_EnumGroupPlayers for( ;; ) { /* We do not enum the name server or app server as they are of no - * concequence to the end user. + * consequence to the end user. */ if( ( lpPList->lpPData->dpid != DPID_NAME_SERVER ) && ( lpPList->lpPData->dpid != DPID_SERVERPLAYER ) @@ -2022,7 +1999,7 @@ static HRESULT WINAPI DirectPlay2WImpl_EnumGroupPlayers } /* NOTE: This only enumerates top level groups (created with CreateGroup) */ -static HRESULT WINAPI DP_IF_EnumGroups +static HRESULT DP_IF_EnumGroups ( IDirectPlay2Impl* This, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ) @@ -2053,7 +2030,7 @@ static HRESULT WINAPI DirectPlay2WImpl_EnumGroups lpContext, dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_EnumPlayers +static HRESULT DP_IF_EnumPlayers ( IDirectPlay2Impl* This, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ) @@ -2118,11 +2095,11 @@ static void DP_InvokeEnumSessionCallbacks static DWORD CALLBACK DP_EnumSessionsSendAsyncRequestThread( LPVOID lpContext ) { - EnumSessionAsyncCallbackData* data = (EnumSessionAsyncCallbackData*)lpContext; + EnumSessionAsyncCallbackData* data = lpContext; HANDLE hSuicideRequest = data->hSuicideRequest; DWORD dwTimeout = data->dwTimeout; - TRACE( "Thread started with timeout = 0x%08lx\n", dwTimeout ); + TRACE( "Thread started with timeout = 0x%08x\n", dwTimeout ); for( ;; ) { @@ -2183,16 +2160,20 @@ static void DP_KillEnumSessionThread( IDirectPlay2Impl* This ) } } -static HRESULT WINAPI DP_IF_EnumSessions +static HRESULT DP_IF_EnumSessions ( IDirectPlay2Impl* This, LPDPSESSIONDESC2 lpsd, DWORD dwTimeout, LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ) { HRESULT hr = DP_OK; - TRACE( "(%p)->(%p,0x%08lx,%p,%p,0x%08lx,%u)\n", + TRACE( "(%p)->(%p,0x%08x,%p,%p,0x%08x,%u)\n", This, lpsd, dwTimeout, lpEnumSessionsCallback2, lpContext, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } /* Can't enumerate if the interface is already open */ if( This->dp2->bConnectionOpen ) @@ -2264,7 +2245,6 @@ static HRESULT WINAPI DP_IF_EnumSessions return hr; } - /* FIXME: Interface locking sucks in this method */ if( ( dwFlags & DPENUMSESSIONS_ASYNC ) ) { /* Enumerate everything presently in the local session cache */ @@ -2272,11 +2252,14 @@ static HRESULT WINAPI DP_IF_EnumSessions This->dp2->lpNameServerData, dwTimeout, lpContext ); + if( This->dp2->dwEnumSessionLock != 0 ) + return DPERR_CONNECTING; /* See if we've already created a thread to service this interface */ if( This->dp2->hEnumSessionThread == INVALID_HANDLE_VALUE ) { DWORD dwThreadId; + This->dp2->dwEnumSessionLock++; /* Send the first enum request inline since the user may cancel a dialog * if one is presented. Also, may also have a connecting return code. @@ -2284,14 +2267,14 @@ static HRESULT WINAPI DP_IF_EnumSessions hr = NS_SendSessionRequestBroadcast( &lpsd->guidApplication, dwFlags, &This->dp2->spData ); - if( !FAILED(hr) ) + if( SUCCEEDED(hr) ) { EnumSessionAsyncCallbackData* lpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpData ) ); /* FIXME: need to kill the thread on object deletion */ lpData->lpSpData = &This->dp2->spData; - CopyMemory( &lpData->requestGuid, &lpsd->guidApplication, sizeof(GUID) ); + lpData->requestGuid = lpsd->guidApplication; lpData->dwEnumSessionFlags = dwFlags; lpData->dwTimeout = dwTimeout; @@ -2317,6 +2300,7 @@ static HRESULT WINAPI DP_IF_EnumSessions 0, &dwThreadId ); } + This->dp2->dwEnumSessionLock--; } } else @@ -2360,13 +2344,18 @@ static HRESULT WINAPI DirectPlay2WImpl_EnumSessions lpContext, dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_GetPlayerCaps +static HRESULT DP_IF_GetPlayerCaps ( IDirectPlay2Impl* This, DPID idPlayer, LPDPCAPS lpDPCaps, DWORD dwFlags ) { DPSP_GETCAPSDATA data; - TRACE("(%p)->(0x%08lx,%p,0x%08lx)\n", This, idPlayer, lpDPCaps, dwFlags); + TRACE("(%p)->(0x%08x,%p,0x%08x)\n", This, idPlayer, lpDPCaps, dwFlags); + + if ( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } /* Query the service provider */ data.idPlayer = idPlayer; @@ -2377,7 +2366,7 @@ static HRESULT WINAPI DP_IF_GetPlayerCaps return (*This->dp2->spData.lpCB->GetCaps)( &data ); } -static HRESULT WINAPI DP_IF_GetCaps +static HRESULT DP_IF_GetCaps ( IDirectPlay2Impl* This, LPDPCAPS lpDPCaps, DWORD dwFlags ) { return DP_IF_GetPlayerCaps( This, DPID_ALLPLAYERS, lpDPCaps, dwFlags ); @@ -2397,7 +2386,7 @@ static HRESULT WINAPI DirectPlay2WImpl_GetCaps return DP_IF_GetCaps( This, lpDPCaps, dwFlags ); } -static HRESULT WINAPI DP_IF_GetGroupData +static HRESULT DP_IF_GetGroupData ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi ) { @@ -2405,7 +2394,7 @@ static HRESULT WINAPI DP_IF_GetGroupData DWORD dwRequiredBufferSize; LPVOID lpCopyDataFrom; - TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx,%u)\n", + TRACE( "(%p)->(0x%08x,%p,%p,0x%08x,%u)\n", This, idGroup, lpData, lpdwDataSize, dwFlags, bAnsi ); if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL ) @@ -2457,15 +2446,15 @@ static HRESULT WINAPI DirectPlay2WImpl_GetGroupData dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_GetGroupName +static HRESULT DP_IF_GetGroupName ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ) { lpGroupData lpGData; - LPDPNAME lpName = (LPDPNAME)lpData; + LPDPNAME lpName = lpData; DWORD dwRequiredDataSize; - FIXME("(%p)->(0x%08lx,%p,%p,%u) ANSI ignored\n", + FIXME("(%p)->(0x%08x,%p,%p,%u) ANSI ignored\n", This, idGroup, lpData, lpdwDataSize, bAnsi ); if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL ) @@ -2475,14 +2464,14 @@ static HRESULT WINAPI DP_IF_GetGroupName dwRequiredDataSize = lpGData->name.dwSize; - if( lpGData->name.lpszShortNameA ) + if( lpGData->name.u1.lpszShortNameA ) { - dwRequiredDataSize += strlen( lpGData->name.lpszShortNameA ) + 1; + dwRequiredDataSize += strlen( lpGData->name.u1.lpszShortNameA ) + 1; } - if( lpGData->name.lpszLongNameA ) + if( lpGData->name.u2.lpszLongNameA ) { - dwRequiredDataSize += strlen( lpGData->name.lpszLongNameA ) + 1; + dwRequiredDataSize += strlen( lpGData->name.u2.lpszLongNameA ) + 1; } if( ( lpData == NULL ) || @@ -2496,24 +2485,24 @@ static HRESULT WINAPI DP_IF_GetGroupName /* Copy the structure */ CopyMemory( lpName, &lpGData->name, lpGData->name.dwSize ); - if( lpGData->name.lpszShortNameA ) + if( lpGData->name.u1.lpszShortNameA ) { strcpy( ((char*)lpName)+lpGData->name.dwSize, - lpGData->name.lpszShortNameA ); + lpGData->name.u1.lpszShortNameA ); } else { - lpName->lpszShortNameA = NULL; + lpName->u1.lpszShortNameA = NULL; } - if( lpGData->name.lpszShortNameA ) + if( lpGData->name.u1.lpszShortNameA ) { strcpy( ((char*)lpName)+lpGData->name.dwSize, - lpGData->name.lpszLongNameA ); + lpGData->name.u2.lpszLongNameA ); } else { - lpName->lpszLongNameA = NULL; + lpName->u2.lpszLongNameA = NULL; } return DP_OK; @@ -2535,11 +2524,11 @@ static HRESULT WINAPI DirectPlay2WImpl_GetGroupName return DP_IF_GetGroupName( This, idGroup, lpData, lpdwDataSize, FALSE ); } -static HRESULT WINAPI DP_IF_GetMessageCount +static HRESULT DP_IF_GetMessageCount ( IDirectPlay2Impl* This, DPID idPlayer, LPDWORD lpdwCount, BOOL bAnsi ) { - FIXME("(%p)->(0x%08lx,%p,%u): stub\n", This, idPlayer, lpdwCount, bAnsi ); + FIXME("(%p)->(0x%08x,%p,%u): stub\n", This, idPlayer, lpdwCount, bAnsi ); return DP_IF_GetMessageQueue( (IDirectPlay4Impl*)This, 0, idPlayer, DPMESSAGEQUEUE_RECEIVE, lpdwCount, NULL, bAnsi ); @@ -2563,7 +2552,7 @@ static HRESULT WINAPI DirectPlay2AImpl_GetPlayerAddress ( LPDIRECTPLAY2A iface, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize ) { IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface; - FIXME("(%p)->(0x%08lx,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize ); + FIXME("(%p)->(0x%08x,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize ); return DP_OK; } @@ -2571,7 +2560,7 @@ static HRESULT WINAPI DirectPlay2WImpl_GetPlayerAddress ( LPDIRECTPLAY2 iface, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize ) { IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface; - FIXME("(%p)->(0x%08lx,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize ); + FIXME("(%p)->(0x%08x,%p,%p): stub\n", This, idPlayer, lpData, lpdwDataSize ); return DP_OK; } @@ -2591,7 +2580,7 @@ static HRESULT WINAPI DirectPlay2WImpl_GetPlayerCaps return DP_IF_GetPlayerCaps( This, idPlayer, lpPlayerCaps, dwFlags ); } -static HRESULT WINAPI DP_IF_GetPlayerData +static HRESULT DP_IF_GetPlayerData ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi ) { @@ -2599,7 +2588,7 @@ static HRESULT WINAPI DP_IF_GetPlayerData DWORD dwRequiredBufferSize; LPVOID lpCopyDataFrom; - TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx,%u)\n", + TRACE( "(%p)->(0x%08x,%p,%p,0x%08x,%u)\n", This, idPlayer, lpData, lpdwDataSize, dwFlags, bAnsi ); if( This->dp2->connectionInitialized == NO_PROVIDER ) @@ -2656,17 +2645,22 @@ static HRESULT WINAPI DirectPlay2WImpl_GetPlayerData dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_GetPlayerName +static HRESULT DP_IF_GetPlayerName ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ) { lpPlayerList lpPList; - LPDPNAME lpName = (LPDPNAME)lpData; + LPDPNAME lpName = lpData; DWORD dwRequiredDataSize; - FIXME( "(%p)->(0x%08lx,%p,%p,%u): ANSI\n", + FIXME( "(%p)->(0x%08x,%p,%p,%u): ANSI\n", This, idPlayer, lpData, lpdwDataSize, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + if( ( lpPList = DP_FindPlayer( This, idPlayer ) ) == NULL ) { return DPERR_INVALIDPLAYER; @@ -2674,14 +2668,14 @@ static HRESULT WINAPI DP_IF_GetPlayerName dwRequiredDataSize = lpPList->lpPData->name.dwSize; - if( lpPList->lpPData->name.lpszShortNameA ) + if( lpPList->lpPData->name.u1.lpszShortNameA ) { - dwRequiredDataSize += strlen( lpPList->lpPData->name.lpszShortNameA ) + 1; + dwRequiredDataSize += strlen( lpPList->lpPData->name.u1.lpszShortNameA ) + 1; } - if( lpPList->lpPData->name.lpszLongNameA ) + if( lpPList->lpPData->name.u2.lpszLongNameA ) { - dwRequiredDataSize += strlen( lpPList->lpPData->name.lpszLongNameA ) + 1; + dwRequiredDataSize += strlen( lpPList->lpPData->name.u2.lpszLongNameA ) + 1; } if( ( lpData == NULL ) || @@ -2695,24 +2689,24 @@ static HRESULT WINAPI DP_IF_GetPlayerName /* Copy the structure */ CopyMemory( lpName, &lpPList->lpPData->name, lpPList->lpPData->name.dwSize ); - if( lpPList->lpPData->name.lpszShortNameA ) + if( lpPList->lpPData->name.u1.lpszShortNameA ) { strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize, - lpPList->lpPData->name.lpszShortNameA ); + lpPList->lpPData->name.u1.lpszShortNameA ); } else { - lpName->lpszShortNameA = NULL; + lpName->u1.lpszShortNameA = NULL; } - if( lpPList->lpPData->name.lpszShortNameA ) + if( lpPList->lpPData->name.u1.lpszShortNameA ) { strcpy( ((char*)lpName)+lpPList->lpPData->name.dwSize, - lpPList->lpPData->name.lpszLongNameA ); + lpPList->lpPData->name.u2.lpszLongNameA ); } else { - lpName->lpszLongNameA = NULL; + lpName->u2.lpszLongNameA = NULL; } return DP_OK; @@ -2734,7 +2728,7 @@ static HRESULT WINAPI DirectPlay2WImpl_GetPlayerName return DP_IF_GetPlayerName( This, idPlayer, lpData, lpdwDataSize, FALSE ); } -static HRESULT WINAPI DP_GetSessionDesc +static HRESULT DP_GetSessionDesc ( IDirectPlay2Impl* This, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ) { @@ -2801,16 +2795,27 @@ static HRESULT WINAPI DirectPlay2WImpl_Initialize } -static HRESULT WINAPI DP_SecureOpen +static HRESULT DP_SecureOpen ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpsd, DWORD dwFlags, LPCDPSECURITYDESC lpSecurity, LPCDPCREDENTIALS lpCredentials, BOOL bAnsi ) { HRESULT hr = DP_OK; - FIXME( "(%p)->(%p,0x%08lx,%p,%p): partial stub\n", + FIXME( "(%p)->(%p,0x%08x,%p,%p): partial stub\n", This, lpsd, dwFlags, lpSecurity, lpCredentials ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + + if( lpsd->dwSize != sizeof(DPSESSIONDESC2) ) + { + TRACE( ": rejecting invalid dpsd size (%d).\n", lpsd->dwSize ); + return DPERR_INVALIDPARAMS; + } + if( This->dp2->bConnectionOpen ) { TRACE( ": rejecting already open connection.\n" ); @@ -2843,11 +2848,11 @@ static HRESULT WINAPI DP_SecureOpen FIXME( "Not all data fields are correct. Need new parameter\n" ); - data.bCreate = (dwFlags & DPOPEN_CREATE ) ? TRUE : FALSE; + data.bCreate = (dwFlags & DPOPEN_CREATE ) != 0; data.lpSPMessageHeader = (dwFlags & DPOPEN_CREATE ) ? NULL : NS_GetNSAddr( This->dp2->lpNameServerData ); data.lpISP = This->dp2->spData.lpISP; - data.bReturnStatus = (dwFlags & DPOPEN_RETURNSTATUS) ? TRUE : FALSE; + data.bReturnStatus = (dwFlags & DPOPEN_RETURNSTATUS) != 0; data.dwOpenFlags = dwFlags; data.dwSessionFlags = This->dp2->lpSessionDesc->dwFlags; @@ -2906,7 +2911,7 @@ static HRESULT WINAPI DirectPlay2AImpl_Open ( LPDIRECTPLAY2A iface, LPDPSESSIONDESC2 lpsd, DWORD dwFlags ) { IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface; - TRACE("(%p)->(%p,0x%08lx)\n", This, lpsd, dwFlags ); + TRACE("(%p)->(%p,0x%08x)\n", This, lpsd, dwFlags ); return DP_SecureOpen( This, lpsd, dwFlags, NULL, NULL, TRUE ); } @@ -2914,17 +2919,17 @@ static HRESULT WINAPI DirectPlay2WImpl_Open ( LPDIRECTPLAY2 iface, LPDPSESSIONDESC2 lpsd, DWORD dwFlags ) { IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface; - TRACE("(%p)->(%p,0x%08lx)\n", This, lpsd, dwFlags ); + TRACE("(%p)->(%p,0x%08x)\n", This, lpsd, dwFlags ); return DP_SecureOpen( This, lpsd, dwFlags, NULL, NULL, FALSE ); } -static HRESULT WINAPI DP_IF_Receive +static HRESULT DP_IF_Receive ( IDirectPlay2Impl* This, LPDPID lpidFrom, LPDPID lpidTo, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize, BOOL bAnsi ) { LPDPMSG lpMsg = NULL; - FIXME( "(%p)->(%p,%p,0x%08lx,%p,%p,%u): stub\n", + FIXME( "(%p)->(%p,%p,0x%08x,%p,%p,%u): stub\n", This, lpidFrom, lpidTo, dwFlags, lpData, lpdwDataSize, bAnsi ); if( This->dp2->connectionInitialized == NO_PROVIDER ) @@ -2958,11 +2963,11 @@ static HRESULT WINAPI DP_IF_Receive ( dwFlags & DPRECEIVE_FROMPLAYER ) ) { - FIXME( "Find matching message 0x%08lx\n", dwFlags ); + FIXME( "Find matching message 0x%08x\n", dwFlags ); } else { - ERR( "Hmmm..dwFlags 0x%08lx\n", dwFlags ); + ERR( "Hmmm..dwFlags 0x%08x\n", dwFlags ); } if( lpMsg == NULL ) @@ -2971,7 +2976,7 @@ static HRESULT WINAPI DP_IF_Receive } /* Copy into the provided buffer */ - CopyMemory( lpData, lpMsg->msg, *lpdwDataSize ); + if (lpData) CopyMemory( lpData, lpMsg->msg, *lpdwDataSize ); return DP_OK; } @@ -3010,13 +3015,13 @@ static HRESULT WINAPI DirectPlay2WImpl_Send 0, 0, NULL, NULL, FALSE ); } -static HRESULT WINAPI DP_IF_SetGroupData +static HRESULT DP_IF_SetGroupData ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ) { lpGroupData lpGData; - TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x,%u)\n", This, idGroup, lpData, dwDataSize, dwFlags, bAnsi ); /* Parameter check */ @@ -3070,13 +3075,13 @@ static HRESULT WINAPI DirectPlay2WImpl_SetGroupData return DP_IF_SetGroupData( This, idGroup, lpData, dwDataSize, dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_SetGroupName +static HRESULT DP_IF_SetGroupName ( IDirectPlay2Impl* This, DPID idGroup, LPDPNAME lpGroupName, DWORD dwFlags, BOOL bAnsi ) { lpGroupData lpGData; - TRACE( "(%p)->(0x%08lx,%p,0x%08lx,%u)\n", This, idGroup, + TRACE( "(%p)->(0x%08x,%p,0x%08x,%u)\n", This, idGroup, lpGroupName, dwFlags, bAnsi ); if( ( lpGData = DP_FindAnyGroup( This, idGroup ) ) == NULL ) @@ -3108,15 +3113,20 @@ static HRESULT WINAPI DirectPlay2WImpl_SetGroupName return DP_IF_SetGroupName( This, idGroup, lpGroupName, dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_SetPlayerData +static HRESULT DP_IF_SetPlayerData ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ) { lpPlayerList lpPList; - TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x,%u)\n", This, idPlayer, lpData, dwDataSize, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + /* Parameter check */ if( ( lpData == NULL ) && ( dwDataSize != 0 ) @@ -3167,15 +3177,20 @@ static HRESULT WINAPI DirectPlay2WImpl_SetPlayerData dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_SetPlayerName +static HRESULT DP_IF_SetPlayerName ( IDirectPlay2Impl* This, DPID idPlayer, LPDPNAME lpPlayerName, DWORD dwFlags, BOOL bAnsi ) { lpPlayerList lpPList; - TRACE( "(%p)->(0x%08lx,%p,0x%08lx,%u)\n", + TRACE( "(%p)->(0x%08x,%p,0x%08x,%u)\n", This, idPlayer, lpPlayerName, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + if( ( lpPList = DP_FindPlayer( This, idPlayer ) ) == NULL ) { return DPERR_INVALIDGROUP; @@ -3205,14 +3220,14 @@ static HRESULT WINAPI DirectPlay2WImpl_SetPlayerName return DP_IF_SetPlayerName( This, idPlayer, lpPlayerName, dwFlags, FALSE ); } -static HRESULT WINAPI DP_SetSessionDesc +static HRESULT DP_SetSessionDesc ( IDirectPlay2Impl* This, LPCDPSESSIONDESC2 lpSessDesc, DWORD dwFlags, BOOL bInitial, BOOL bAnsi ) { DWORD dwRequiredSize; LPDPSESSIONDESC2 lpTempSessDesc; - TRACE( "(%p)->(%p,0x%08lx,%u,%u)\n", + TRACE( "(%p)->(%p,0x%08x,%u,%u)\n", This, lpSessDesc, dwFlags, bInitial, bAnsi ); if( This->dp2->connectionInitialized == NO_PROVIDER ) @@ -3244,10 +3259,13 @@ static HRESULT WINAPI DP_SetSessionDesc HeapFree( GetProcessHeap(), 0, 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. @@ -3275,7 +3293,7 @@ static HRESULT WINAPI DirectPlay2WImpl_SetSessionDesc } /* FIXME: See about merging some of this stuff with dplayx_global.c stuff */ -DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ) +static DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ) { DWORD dwSize = 0; @@ -3290,35 +3308,35 @@ DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ) if( bAnsi ) { - if( lpSessDesc->lpszSessionNameA ) + if( lpSessDesc->u1.lpszSessionNameA ) { - dwSize += lstrlenA( lpSessDesc->lpszSessionNameA ) + 1; + dwSize += lstrlenA( lpSessDesc->u1.lpszSessionNameA ) + 1; } - if( lpSessDesc->lpszPasswordA ) + if( lpSessDesc->u2.lpszPasswordA ) { - dwSize += lstrlenA( lpSessDesc->lpszPasswordA ) + 1; + dwSize += lstrlenA( lpSessDesc->u2.lpszPasswordA ) + 1; } } else /* UNICODE */ { - if( lpSessDesc->lpszSessionName ) + if( lpSessDesc->u1.lpszSessionName ) { dwSize += sizeof( WCHAR ) * - ( lstrlenW( lpSessDesc->lpszSessionName ) + 1 ); + ( lstrlenW( lpSessDesc->u1.lpszSessionName ) + 1 ); } - if( lpSessDesc->lpszPassword ) + if( lpSessDesc->u2.lpszPassword ) { dwSize += sizeof( WCHAR ) * - ( lstrlenW( lpSessDesc->lpszPassword ) + 1 ); + ( lstrlenW( lpSessDesc->u2.lpszPassword ) + 1 ); } } return dwSize; } -/* Assumes that contugous buffers are already allocated. */ +/* Assumes that contiguous buffers are already allocated. */ static void DP_CopySessionDesc( LPDPSESSIONDESC2 lpSessionDest, LPCDPSESSIONDESC2 lpSessionSrc, BOOL bAnsi ) { @@ -3336,57 +3354,57 @@ static void DP_CopySessionDesc( LPDPSESSIONDESC2 lpSessionDest, if( bAnsi ) { - if( lpSessionSrc->lpszSessionNameA ) + if( lpSessionSrc->u1.lpszSessionNameA ) { lstrcpyA( (LPSTR)lpStartOfFreeSpace, - lpSessionDest->lpszSessionNameA ); - lpSessionDest->lpszSessionNameA = (LPSTR)lpStartOfFreeSpace; + lpSessionDest->u1.lpszSessionNameA ); + lpSessionDest->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace; lpStartOfFreeSpace += - lstrlenA( (LPSTR)lpSessionDest->lpszSessionNameA ) + 1; + lstrlenA( lpSessionDest->u1.lpszSessionNameA ) + 1; } - if( lpSessionSrc->lpszPasswordA ) + if( lpSessionSrc->u2.lpszPasswordA ) { lstrcpyA( (LPSTR)lpStartOfFreeSpace, - lpSessionDest->lpszPasswordA ); - lpSessionDest->lpszPasswordA = (LPSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += - lstrlenA( (LPSTR)lpSessionDest->lpszPasswordA ) + 1; + lpSessionDest->u2.lpszPasswordA ); + lpSessionDest->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace; } } else /* UNICODE */ { - if( lpSessionSrc->lpszSessionName ) + if( lpSessionSrc->u1.lpszSessionName ) { lstrcpyW( (LPWSTR)lpStartOfFreeSpace, - lpSessionDest->lpszSessionName ); - lpSessionDest->lpszSessionName = (LPWSTR)lpStartOfFreeSpace; + lpSessionDest->u1.lpszSessionName ); + lpSessionDest->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace; lpStartOfFreeSpace += sizeof(WCHAR) * - ( lstrlenW( (LPWSTR)lpSessionDest->lpszSessionName ) + 1 ); + ( lstrlenW( lpSessionDest->u1.lpszSessionName ) + 1 ); } - if( lpSessionSrc->lpszPassword ) + if( lpSessionSrc->u2.lpszPassword ) { lstrcpyW( (LPWSTR)lpStartOfFreeSpace, - lpSessionDest->lpszPassword ); - lpSessionDest->lpszPassword = (LPWSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof(WCHAR) * - ( lstrlenW( (LPWSTR)lpSessionDest->lpszPassword ) + 1 ); + lpSessionDest->u2.lpszPassword ); + lpSessionDest->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace; } } } -static HRESULT WINAPI DP_IF_AddGroupToGroup +static HRESULT DP_IF_AddGroupToGroup ( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup ) { - lpGroupData lpGParentData; lpGroupData lpGData; lpGroupList lpNewGList; - TRACE( "(%p)->(0x%08lx,0x%08lx)\n", This, idParentGroup, idGroup ); + TRACE( "(%p)->(0x%08x,0x%08x)\n", This, idParentGroup, idGroup ); - if( ( lpGParentData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) ) == NULL ) + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + + if( DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) == NULL ) { return DPERR_INVALIDGROUP; } @@ -3430,7 +3448,7 @@ static HRESULT WINAPI DirectPlay3WImpl_AddGroupToGroup return DP_IF_AddGroupToGroup( This, idParentGroup, idGroup ); } -static HRESULT WINAPI DP_IF_CreateGroupInGroup +static HRESULT DP_IF_CreateGroupInGroup ( IDirectPlay3Impl* This, LPVOID lpMsgHdr, DPID idParentGroup, LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags, BOOL bAnsi ) @@ -3439,10 +3457,15 @@ static HRESULT WINAPI DP_IF_CreateGroupInGroup lpGroupList lpGList; lpGroupData lpGData; - TRACE( "(%p)->(0x%08lx,%p,%p,%p,0x%08lx,0x%08lx,%u)\n", + TRACE( "(%p)->(0x%08x,%p,%p,%p,0x%08x,0x%08x,%u)\n", This, idParentGroup, lpidGroup, lpGroupName, lpData, dwDataSize, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + /* Verify that the specified parent is valid */ if( ( lpGParentData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) ) == NULL @@ -3547,13 +3570,13 @@ static HRESULT WINAPI DirectPlay3WImpl_CreateGroupInGroup dwFlags, FALSE ); } -static HRESULT WINAPI DP_IF_DeleteGroupFromGroup +static HRESULT DP_IF_DeleteGroupFromGroup ( IDirectPlay3Impl* This, DPID idParentGroup, DPID idGroup ) { lpGroupList lpGList; lpGroupData lpGParentData; - TRACE("(%p)->(0x%08lx,0x%08lx)\n", This, idParentGroup, idGroup ); + TRACE("(%p)->(0x%08x,0x%08x)\n", This, idParentGroup, idGroup ); /* Is the parent group valid? */ if( ( lpGParentData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idParentGroup ) ) == NULL ) @@ -3595,16 +3618,14 @@ static HRESULT WINAPI DirectPlay3WImpl_DeleteGroupFromGroup return DP_IF_DeleteGroupFromGroup( This, idParentGroup, idGroup ); } -static -BOOL WINAPI DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf, +static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf, LPDWORD lpdwBufSize ) { DPCOMPOUNDADDRESSELEMENT dpCompoundAddress; HRESULT hr; dpCompoundAddress.dwDataSize = sizeof( GUID ); - memcpy( &dpCompoundAddress.guidDataType, &DPAID_ServiceProvider, - sizeof( GUID ) ) ; + dpCompoundAddress.guidDataType = DPAID_ServiceProvider; dpCompoundAddress.lpData = lpcSpGuid; *lplpAddrBuf = NULL; @@ -3638,7 +3659,7 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections ( LPDIRECTPLAY3A iface, LPCGUID lpguidApplication, LPDPENUMCONNECTIONSCALLBACK lpEnumCallback, LPVOID lpContext, DWORD dwFlags ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - TRACE("(%p)->(%p,%p,%p,0x%08lx)\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags ); + TRACE("(%p)->(%p,%p,%p,0x%08x)\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags ); /* A default dwFlags (0) is backwards compatible -- DPCONNECTION_DIRECTPLAY */ if( dwFlags == 0 ) @@ -3653,7 +3674,7 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections return DPERR_INVALIDFLAGS; } - if( !lpEnumCallback || !*lpEnumCallback ) + if( !lpEnumCallback ) { return DPERR_INVALIDPARAMS; } @@ -3711,8 +3732,10 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); + RegCloseKey(hkServiceProvider); continue; } + RegCloseKey(hkServiceProvider); /* FIXME: Check return types to ensure we're interpreting data right */ MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); @@ -3722,8 +3745,8 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections /* Fill in the DPNAME struct for the service provider */ dpName.dwSize = sizeof( dpName ); dpName.dwFlags = 0; - dpName.lpszShortNameA = subKeyName; - dpName.lpszLongNameA = NULL; + dpName.u1.lpszShortNameA = subKeyName; + dpName.u2.lpszLongNameA = NULL; /* Create the compound address for the service provider. * NOTE: This is a gruesome architectural scar right now. DP @@ -3745,7 +3768,7 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections /* The enumeration will return FALSE if we are not to continue */ if( !lpEnumCallback( &serviceProviderGUID, lpAddressBuffer, dwAddressBufferSize, - &dpName, DPCONNECTION_DIRECTPLAY, lpContext ) ) + &dpName, dwFlags, lpContext ) ) { return DP_OK; } @@ -3806,8 +3829,10 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); + RegCloseKey(hkServiceProvider); continue; } + RegCloseKey(hkServiceProvider); /* FIXME: Check return types to ensure we're interpreting data right */ MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) ); @@ -3817,8 +3842,8 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections /* Fill in the DPNAME struct for the service provider */ dpName.dwSize = sizeof( dpName ); dpName.dwFlags = 0; - dpName.lpszShortNameA = subKeyName; - dpName.lpszLongNameA = NULL; + dpName.u1.lpszShortNameA = subKeyName; + dpName.u2.lpszLongNameA = NULL; /* Create the compound address for the service provider. NOTE: This is a gruesome architectural scar right now. DP uses DPL and DPL uses DP @@ -3845,15 +3870,18 @@ static HRESULT WINAPI DirectPlay3AImpl_EnumConnections &dwAddressBufferSize, TRUE ) ) != DP_OK ) { ERR( "can't create address: %s\n", DPLAYX_HresultToString( hr ) ); + HeapFree( GetProcessHeap(), 0, lpAddressBuffer ); return hr; } /* The enumeration will return FALSE if we are not to continue */ if( !lpEnumCallback( &serviceProviderGUID, lpAddressBuffer, dwAddressBufferSize, - &dpName, DPCONNECTION_DIRECTPLAYLOBBY, lpContext ) ) + &dpName, dwFlags, lpContext ) ) { + HeapFree( GetProcessHeap(), 0, lpAddressBuffer ); return DP_OK; } + HeapFree( GetProcessHeap(), 0, lpAddressBuffer ); } } @@ -3864,11 +3892,11 @@ static HRESULT WINAPI DirectPlay3WImpl_EnumConnections ( LPDIRECTPLAY3 iface, LPCGUID lpguidApplication, LPDPENUMCONNECTIONSCALLBACK lpEnumCallback, LPVOID lpContext, DWORD dwFlags ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(%p,%p,%p,0x%08lx): stub\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags ); + FIXME("(%p)->(%p,%p,%p,0x%08x): stub\n", This, lpguidApplication, lpEnumCallback, lpContext, dwFlags ); return DP_OK; } -static HRESULT WINAPI DP_IF_EnumGroupsInGroup +static HRESULT DP_IF_EnumGroupsInGroup ( IDirectPlay3AImpl* This, DPID idGroup, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags, BOOL bAnsi ) @@ -3876,10 +3904,15 @@ static HRESULT WINAPI DP_IF_EnumGroupsInGroup lpGroupList lpGList; lpGroupData lpGData; - FIXME( "(%p)->(0x%08lx,%p,%p,%p,0x%08lx,%u): semi stub\n", + FIXME( "(%p)->(0x%08x,%p,%p,%p,0x%08x,%u): semi stub\n", This, idGroup, lpguidInstance, lpEnumPlayersCallback2, lpContext, dwFlags, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + if( ( lpGData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idGroup ) ) == NULL ) { return DPERR_INVALIDGROUP; @@ -3941,7 +3974,7 @@ static HRESULT WINAPI DirectPlay3AImpl_GetGroupConnectionSettings ( LPDIRECTPLAY3A iface, DWORD dwFlags, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize ); + FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize ); return DP_OK; } @@ -3949,7 +3982,7 @@ static HRESULT WINAPI DirectPlay3WImpl_GetGroupConnectionSettings ( LPDIRECTPLAY3 iface, DWORD dwFlags, DPID idGroup, LPVOID lpData, LPDWORD lpdwDataSize ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize ); + FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, dwFlags, idGroup, lpData, lpdwDataSize ); return DP_OK; } @@ -3964,12 +3997,12 @@ static BOOL CALLBACK DP_GetSpLpGuidFromCompoundAddress( ( IsEqualGUID( guidDataType, &DPAID_LobbyProvider ) ) ) { - TRACE( "Found SP/LP (%s) %s (data size = 0x%08lx)\n", + TRACE( "Found SP/LP (%s) %s (data size = 0x%08x)\n", debugstr_guid( guidDataType ), debugstr_guid( lpData ), dwDataSize ); if( dwDataSize != sizeof( GUID ) ) { - ERR( "Invalid sp/lp guid size 0x%08lx\n", dwDataSize ); + ERR( "Invalid sp/lp guid size 0x%08x\n", dwDataSize ); } memcpy( lpContext, lpData, dwDataSize ); @@ -4103,7 +4136,7 @@ static HMODULE DP_LoadSP( LPCGUID lpcGuid, LPSPINITDATA lpSpData, LPBOOL lpbIsDp NULL, NULL, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) ) != ERROR_SUCCESS ) { - ERR(": missing PATH registry data members: 0x%08lx\n", dwTemp ); + ERR(": missing PATH registry data members: 0x%08x\n", dwTemp ); continue; } @@ -4196,7 +4229,7 @@ HRESULT DP_InitializeDPLSP( IDirectPlay3Impl* This, HMODULE hLobbyProvider ) return hr; } -static HRESULT WINAPI DP_IF_InitializeConnection +static HRESULT DP_IF_InitializeConnection ( IDirectPlay3Impl* This, LPVOID lpConnection, DWORD dwFlags, BOOL bAnsi ) { HMODULE hServiceProvider; @@ -4205,13 +4238,23 @@ static HRESULT WINAPI DP_IF_InitializeConnection const DWORD dwAddrSize = 80; /* FIXME: Need to calculate it correctly */ BOOL bIsDpSp; /* TRUE if Direct Play SP, FALSE if Direct Play Lobby SP */ - TRACE("(%p)->(%p,0x%08lx,%u)\n", This, lpConnection, dwFlags, bAnsi ); + TRACE("(%p)->(%p,0x%08x,%u)\n", This, lpConnection, dwFlags, bAnsi ); + + if ( lpConnection == NULL ) + { + return DPERR_INVALIDPARAMS; + } if( dwFlags != 0 ) { return DPERR_INVALIDFLAGS; } + if( This->dp2->connectionInitialized != NO_PROVIDER ) + { + return DPERR_ALREADYINITIALIZED; + } + /* Find out what the requested SP is and how large this buffer is */ hr = DPL_EnumAddress( DP_GetSpLpGuidFromCompoundAddress, lpConnection, dwAddrSize, &guidSP ); @@ -4227,7 +4270,7 @@ static HRESULT WINAPI DP_IF_InitializeConnection if( hServiceProvider == 0 ) { - ERR( "Unable to load service provider\n" ); + ERR( "Unable to load service provider %s\n", debugstr_guid(&guidSP) ); return DPERR_UNAVAILABLE; } @@ -4305,7 +4348,7 @@ static HRESULT WINAPI DirectPlay3AImpl_SendChatMessage ( LPDIRECTPLAY3A iface, DPID idFrom, DPID idTo, DWORD dwFlags, LPDPCHAT lpChatMessage ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,0x%08lx,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage ); + FIXME("(%p)->(0x%08x,0x%08x,0x%08x,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage ); return DP_OK; } @@ -4313,7 +4356,7 @@ static HRESULT WINAPI DirectPlay3WImpl_SendChatMessage ( LPDIRECTPLAY3 iface, DPID idFrom, DPID idTo, DWORD dwFlags, LPDPCHAT lpChatMessage ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,0x%08lx,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage ); + FIXME("(%p)->(0x%08x,0x%08x,0x%08x,%p): stub\n", This, idFrom, idTo, dwFlags, lpChatMessage ); return DP_OK; } @@ -4321,7 +4364,7 @@ static HRESULT WINAPI DirectPlay3AImpl_SetGroupConnectionSettings ( LPDIRECTPLAY3A iface, DWORD dwFlags, DPID idGroup, LPDPLCONNECTION lpConnection ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,%p): stub\n", This, dwFlags, idGroup, lpConnection ); + FIXME("(%p)->(0x%08x,0x%08x,%p): stub\n", This, dwFlags, idGroup, lpConnection ); return DP_OK; } @@ -4329,7 +4372,7 @@ static HRESULT WINAPI DirectPlay3WImpl_SetGroupConnectionSettings ( LPDIRECTPLAY3 iface, DWORD dwFlags, DPID idGroup, LPDPLCONNECTION lpConnection ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,%p): stub\n", This, dwFlags, idGroup, lpConnection ); + FIXME("(%p)->(0x%08x,0x%08x,%p): stub\n", This, dwFlags, idGroup, lpConnection ); return DP_OK; } @@ -4337,7 +4380,7 @@ static HRESULT WINAPI DirectPlay3AImpl_StartSession ( LPDIRECTPLAY3A iface, DWORD dwFlags, DPID idGroup ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, dwFlags, idGroup ); + FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, dwFlags, idGroup ); return DP_OK; } @@ -4345,7 +4388,7 @@ static HRESULT WINAPI DirectPlay3WImpl_StartSession ( LPDIRECTPLAY3 iface, DWORD dwFlags, DPID idGroup ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, dwFlags, idGroup ); + FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, dwFlags, idGroup ); return DP_OK; } @@ -4353,7 +4396,7 @@ static HRESULT WINAPI DirectPlay3AImpl_GetGroupFlags ( LPDIRECTPLAY3A iface, DPID idGroup, LPDWORD lpdwFlags ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpdwFlags ); + FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpdwFlags ); return DP_OK; } @@ -4361,17 +4404,17 @@ static HRESULT WINAPI DirectPlay3WImpl_GetGroupFlags ( LPDIRECTPLAY3 iface, DPID idGroup, LPDWORD lpdwFlags ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpdwFlags ); + FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpdwFlags ); return DP_OK; } -static HRESULT WINAPI DP_IF_GetGroupParent +static HRESULT DP_IF_GetGroupParent ( IDirectPlay3AImpl* This, DPID idGroup, LPDPID lpidGroup, BOOL bAnsi ) { lpGroupData lpGData; - TRACE("(%p)->(0x%08lx,%p,%u)\n", This, idGroup, lpidGroup, bAnsi ); + TRACE("(%p)->(0x%08x,%p,%u)\n", This, idGroup, lpidGroup, bAnsi ); if( ( lpGData = DP_FindAnyGroup( (IDirectPlay2AImpl*)This, idGroup ) ) == NULL ) { @@ -4400,7 +4443,7 @@ static HRESULT WINAPI DirectPlay3AImpl_GetPlayerAccount ( LPDIRECTPLAY3A iface, DPID idPlayer, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize ); + FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize ); return DP_OK; } @@ -4408,7 +4451,7 @@ static HRESULT WINAPI DirectPlay3WImpl_GetPlayerAccount ( LPDIRECTPLAY3 iface, DPID idPlayer, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize ); + FIXME("(%p)->(0x%08x,0x%08x,%p,%p): stub\n", This, idPlayer, dwFlags, lpData, lpdwDataSize ); return DP_OK; } @@ -4416,7 +4459,7 @@ static HRESULT WINAPI DirectPlay3AImpl_GetPlayerFlags ( LPDIRECTPLAY3A iface, DPID idPlayer, LPDWORD lpdwFlags ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,%p): stub\n", This, idPlayer, lpdwFlags ); + FIXME("(%p)->(0x%08x,%p): stub\n", This, idPlayer, lpdwFlags ); return DP_OK; } @@ -4424,7 +4467,7 @@ static HRESULT WINAPI DirectPlay3WImpl_GetPlayerFlags ( LPDIRECTPLAY3 iface, DPID idPlayer, LPDWORD lpdwFlags ) { IDirectPlay3Impl *This = (IDirectPlay3Impl *)iface; - FIXME("(%p)->(0x%08lx,%p): stub\n", This, idPlayer, lpdwFlags ); + FIXME("(%p)->(0x%08x,%p): stub\n", This, idPlayer, lpdwFlags ); return DP_OK; } @@ -4432,7 +4475,7 @@ static HRESULT WINAPI DirectPlay4AImpl_GetGroupOwner ( LPDIRECTPLAY4A iface, DPID idGroup, LPDPID lpidGroupOwner ) { IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface; - FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpidGroupOwner ); + FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpidGroupOwner ); return DP_OK; } @@ -4440,7 +4483,7 @@ static HRESULT WINAPI DirectPlay4WImpl_GetGroupOwner ( LPDIRECTPLAY4 iface, DPID idGroup, LPDPID lpidGroupOwner ) { IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface; - FIXME("(%p)->(0x%08lx,%p): stub\n", This, idGroup, lpidGroupOwner ); + FIXME("(%p)->(0x%08x,%p): stub\n", This, idGroup, lpidGroupOwner ); return DP_OK; } @@ -4448,7 +4491,7 @@ static HRESULT WINAPI DirectPlay4AImpl_SetGroupOwner ( LPDIRECTPLAY4A iface, DPID idGroup , DPID idGroupOwner ) { IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, idGroup, idGroupOwner ); + FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, idGroup, idGroupOwner ); return DP_OK; } @@ -4456,26 +4499,29 @@ static HRESULT WINAPI DirectPlay4WImpl_SetGroupOwner ( LPDIRECTPLAY4 iface, DPID idGroup , DPID idGroupOwner ) { IDirectPlay4Impl *This = (IDirectPlay4Impl *)iface; - FIXME("(%p)->(0x%08lx,0x%08lx): stub\n", This, idGroup, idGroupOwner ); + FIXME("(%p)->(0x%08x,0x%08x): stub\n", This, idGroup, idGroupOwner ); return DP_OK; } -static HRESULT WINAPI DP_SendEx +static HRESULT DP_SendEx ( IDirectPlay2Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, LPVOID lpContext, LPDWORD lpdwMsgID, BOOL bAnsi ) { - lpPlayerList lpPList; - lpGroupData lpGData; BOOL bValidDestination = FALSE; - FIXME( "(%p)->(0x%08lx,0x%08lx,0x%08lx,%p,0x%08lx,0x%08lx,0x%08lx,%p,%p,%u)" + FIXME( "(%p)->(0x%08x,0x%08x,0x%08x,%p,0x%08x,0x%08x,0x%08x,%p,%p,%u)" ": stub\n", This, idFrom, idTo, dwFlags, lpData, dwDataSize, dwPriority, dwTimeout, lpContext, lpdwMsgID, bAnsi ); + if( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + /* FIXME: Add parameter checking */ - /* FIXME: First call to this needs to aquire a message id which will be + /* FIXME: First call to this needs to acquire a message id which will be * used for multiple sends */ @@ -4486,9 +4532,9 @@ static HRESULT WINAPI DP_SendEx */ if( idFrom != DPID_UNKNOWN ) { - if( ( lpPList = DP_FindPlayer( This, idFrom ) ) == NULL ) + if( DP_FindPlayer( This, idFrom ) == NULL ) { - WARN( "INFO: Invalid from player 0x%08lx\n", idFrom ); + WARN( "INFO: Invalid from player 0x%08x\n", idFrom ); return DPERR_INVALIDPLAYER; } } @@ -4520,8 +4566,6 @@ static HRESULT WINAPI DP_SendEx ( DP_FindPlayer( This, idTo ) != NULL ) ) { - bValidDestination = TRUE; - /* Have the service provider send this message */ /* FIXME: Could optimize for local interface sends */ return DP_SP_SendEx( This, dwFlags, lpData, dwDataSize, dwPriority, @@ -4529,7 +4573,7 @@ static HRESULT WINAPI DP_SendEx } if( ( !bValidDestination ) && - ( ( lpGData = DP_FindAnyGroup( This, idTo ) ) != NULL ) + ( DP_FindAnyGroup( This, idTo ) != NULL ) ) { bValidDestination = TRUE; @@ -4596,7 +4640,7 @@ static HRESULT WINAPI DirectPlay4WImpl_SendEx dwPriority, dwTimeout, lpContext, lpdwMsgID, FALSE ); } -static HRESULT WINAPI DP_SP_SendEx +static HRESULT DP_SP_SendEx ( IDirectPlay2Impl* This, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, LPVOID lpContext, LPDWORD lpdwMsgID ) @@ -4618,13 +4662,13 @@ static HRESULT WINAPI DP_SP_SendEx return DP_OK; } -static HRESULT WINAPI DP_IF_GetMessageQueue +static HRESULT DP_IF_GetMessageQueue ( IDirectPlay4Impl* This, DPID idFrom, DPID idTo, DWORD dwFlags, LPDWORD lpdwNumMsgs, LPDWORD lpdwNumBytes, BOOL bAnsi ) { HRESULT hr = DP_OK; - FIXME( "(%p)->(0x%08lx,0x%08lx,0x%08lx,%p,%p,%u): semi stub\n", + FIXME( "(%p)->(0x%08x,0x%08x,0x%08x,%p,%p,%u): semi stub\n", This, idFrom, idTo, dwFlags, lpdwNumMsgs, lpdwNumBytes, bAnsi ); /* FIXME: Do we need to do idFrom and idTo sanity checking here? */ @@ -4673,13 +4717,13 @@ static HRESULT WINAPI DirectPlay4WImpl_GetMessageQueue lpdwNumBytes, FALSE ); } -static HRESULT WINAPI DP_IF_CancelMessage +static HRESULT DP_IF_CancelMessage ( IDirectPlay4Impl* This, DWORD dwMsgID, DWORD dwFlags, DWORD dwMinPriority, DWORD dwMaxPriority, BOOL bAnsi ) { HRESULT hr = DP_OK; - FIXME( "(%p)->(0x%08lx,0x%08lx,%u): semi stub\n", + FIXME( "(%p)->(0x%08x,0x%08x,%u): semi stub\n", This, dwMsgID, dwFlags, bAnsi ); if( This->dp2->spData.lpCB->Cancel ) @@ -5120,7 +5164,6 @@ static const IDirectPlay4Vtbl directPlay4AVT = }; #undef XCAST -extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData ) @@ -5137,7 +5180,6 @@ HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, return DP_OK; } -extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData ) @@ -5188,7 +5230,7 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, 'S', 'e', 'r', 'v', 'i', 'c', 'e', ' ', 'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r', 's', 0 }; static const WCHAR guidKey[] = { 'G', 'u', 'i', 'd', 0 }; static const WCHAR descW[] = { 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'i', 'o', 'n', 'W', 0 }; - + DWORD dwIndex; FILETIME filetime; @@ -5196,12 +5238,12 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, DWORD max_sizeOfDescriptionA = 0; WCHAR *descriptionW = NULL; DWORD max_sizeOfDescriptionW = 0; - + if (!lpEnumCallbackA && !lpEnumCallbackW) { return DPERR_INVALIDPARAMS; } - + /* Need to loop over the service providers in the registry */ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, searchSubKey, 0, KEY_READ, &hkResult) != ERROR_SUCCESS) @@ -5210,7 +5252,7 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, ERR(": no service provider key in the registry - check your Wine installation !!!\n"); return DPERR_GENERIC; } - + /* Traverse all the service providers we have available */ dwIndex = 0; while (1) @@ -5222,7 +5264,7 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, WCHAR guidKeyContent[(2 * 16) + 1 + 6 /* This corresponds to '{....-..-..-..-......}' */ ]; DWORD sizeOfGuidKeyContent = sizeof(guidKeyContent); LONG ret_value; - + ret_value = RegEnumKeyExW(hkResult, dwIndex, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, &filetime); if (ret_value == ERROR_NO_MORE_ITEMS) @@ -5233,14 +5275,14 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, return DPERR_EXCEPTION; } TRACE(" this time through sub-key %s.\n", debugstr_w(subKeyName)); - + /* Open the key for this service provider */ if (RegOpenKeyExW(hkResult, subKeyName, 0, KEY_READ, &hkServiceProvider) != ERROR_SUCCESS) { ERR(": could not open registry key for service provider %s.\n", debugstr_w(subKeyName)); continue; } - + /* Get the GUID from the registry */ if (RegQueryValueExW(hkServiceProvider, guidKey, NULL, NULL, (LPBYTE) guidKeyContent, &sizeOfGuidKeyContent) != ERROR_SUCCESS) @@ -5254,18 +5296,18 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, continue; } CLSIDFromString(guidKeyContent, &serviceProviderGUID ); - + /* The enumeration will return FALSE if we are not to continue. * * Note: on my windows box, major / minor version is 6 / 0 for all service providers - * and have no relations to any of the two dwReserved1 and dwReserved2 keys. + * and have no relation to any of the two dwReserved1 and dwReserved2 keys. * I think that it simply means that they are in-line with DirectX 6.0 */ if (lpEnumCallbackA) { DWORD sizeOfDescription = 0; - - /* Note that this the the A case of this function, so use the A variant to get the description string */ + + /* Note that this is the A case of this function, so use the A variant to get the description string */ if (RegQueryValueExA(hkServiceProvider, "DescriptionA", NULL, NULL, NULL, &sizeOfDescription) != ERROR_SUCCESS) { @@ -5276,19 +5318,18 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, { HeapFree(GetProcessHeap(), 0, descriptionA); max_sizeOfDescriptionA = sizeOfDescription; - descriptionA = HeapAlloc(GetProcessHeap(), 0, max_sizeOfDescriptionA); } descriptionA = HeapAlloc(GetProcessHeap(), 0, sizeOfDescription); RegQueryValueExA(hkServiceProvider, "DescriptionA", NULL, NULL, (LPBYTE) descriptionA, &sizeOfDescription); - + if (!lpEnumCallbackA(&serviceProviderGUID, descriptionA, 6, 0, lpContext)) goto end; } else { DWORD sizeOfDescription = 0; - + if (RegQueryValueExW(hkServiceProvider, descW, NULL, NULL, NULL, &sizeOfDescription) != ERROR_SUCCESS) { @@ -5299,7 +5340,6 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, { HeapFree(GetProcessHeap(), 0, descriptionW); max_sizeOfDescriptionW = sizeOfDescription; - descriptionW = HeapAlloc(GetProcessHeap(), 0, max_sizeOfDescriptionW); } descriptionW = HeapAlloc(GetProcessHeap(), 0, sizeOfDescription); RegQueryValueExW(hkServiceProvider, descW, @@ -5308,14 +5348,14 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, if (!lpEnumCallbackW(&serviceProviderGUID, descriptionW, 6, 0, lpContext)) goto end; } - + dwIndex++; } end: HeapFree(GetProcessHeap(), 0, descriptionA); HeapFree(GetProcessHeap(), 0, descriptionW); - + return DP_OK; } @@ -5326,7 +5366,7 @@ static HRESULT DirectPlayEnumerateAW(LPDPENUMDPCALLBACKA lpEnumCallbackA, HRESULT WINAPI DirectPlayEnumerateA(LPDPENUMDPCALLBACKA lpEnumCallback, LPVOID lpContext ) { TRACE("(%p,%p)\n", lpEnumCallback, lpContext); - + return DirectPlayEnumerateAW(lpEnumCallback, NULL, lpContext); } @@ -5336,7 +5376,7 @@ HRESULT WINAPI DirectPlayEnumerateA(LPDPENUMDPCALLBACKA lpEnumCallback, LPVOID l HRESULT WINAPI DirectPlayEnumerateW(LPDPENUMDPCALLBACKW lpEnumCallback, LPVOID lpContext ) { TRACE("(%p,%p)\n", lpEnumCallback, lpContext); - + return DirectPlayEnumerateAW(NULL, lpEnumCallback, lpContext); } @@ -5379,7 +5419,7 @@ static BOOL CALLBACK cbDPCreateEnumConnections( * */ HRESULT WINAPI DirectPlayCreate -( LPGUID lpGUID, LPDIRECTPLAY2 *lplpDP, IUnknown *pUnk) +( LPGUID lpGUID, LPDIRECTPLAY *lplpDP, IUnknown *pUnk ) { HRESULT hr; LPDIRECTPLAY3A lpDP3A; @@ -5392,6 +5432,12 @@ HRESULT WINAPI DirectPlayCreate return CLASS_E_NOAGGREGATION; } + if( (lplpDP == NULL) || (lpGUID == NULL) ) + { + return DPERR_INVALIDPARAMS; + } + + /* Create an IDirectPlay object. We don't support that so we'll cheat and give them an IDirectPlay2A object and hope that doesn't cause problems */ if( DP_CreateInterface( &IID_IDirectPlay2A, (LPVOID*)lplpDP ) != DP_OK ) diff --git a/reactos/dll/directx/dplayx/dplay_global.h b/reactos/dll/directx/dplayx/dplay_global.h index 516a61b3200..086801e29cd 100644 --- a/reactos/dll/directx/dplayx/dplay_global.h +++ b/reactos/dll/directx/dplayx/dplay_global.h @@ -13,12 +13,15 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DPLAY_GLOBAL_INCLUDED #define __WINE_DPLAY_GLOBAL_INCLUDED +#define WIN32_NO_STATUS +#define _INC_WINDOWS + //#include //#include "windef.h" @@ -29,9 +32,7 @@ extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress, DWORD dwAddressSize, - LPVOID lpContext ); - -extern DWORD DP_CalcSessionDescSize( LPCDPSESSIONDESC2 lpSessDesc, BOOL bAnsi ); + LPVOID lpContext ) DECLSPEC_HIDDEN; /***************************************************************************** * Predeclare the interface implementation structures @@ -69,7 +70,7 @@ typedef struct tagDP_MSG_REPLY_STRUCT typedef struct tagDP_MSG_REPLY_STRUCT_LIST { - DPQ_ENTRY(tagDP_MSG_REPLY_STRUCT_LIST) replysExpected; + DPQ_ENTRY(tagDP_MSG_REPLY_STRUCT_LIST) repliesExpected; DP_MSG_REPLY_STRUCT replyExpected; } DP_MSG_REPLY_STRUCT_LIST, *LPDP_MSG_REPLY_STRUCT_LIST; @@ -164,6 +165,7 @@ typedef struct tagDirectPlay2Data /* For async EnumSessions requests */ HANDLE hEnumSessionThread; HANDLE hKillEnumSessionThreadEvent; + DWORD dwEnumSessionLock; LPVOID lpNameServerData; /* DPlay interface doesn't know contents */ @@ -194,7 +196,7 @@ typedef struct tagDirectPlay2Data enum SPSTATE connectionInitialized; /* Expected messages queue */ - DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) replysExpected; + DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) repliesExpected; } DirectPlay2Data; typedef struct tagDirectPlay3Data @@ -234,13 +236,13 @@ struct IDirectPlay4Impl HRESULT DP_HandleMessage( IDirectPlay2Impl* This, LPCVOID lpMessageBody, DWORD dwMessageBodySize, LPCVOID lpMessageHeader, WORD wCommandId, WORD wVersion, - LPVOID* lplpReply, LPDWORD lpdwMsgSize ); + LPVOID* lplpReply, LPDWORD lpdwMsgSize ) DECLSPEC_HIDDEN; /* DP SP external interfaces into DirectPlay */ -extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData ); -extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData ); +extern HRESULT DP_GetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID* lplpData ) DECLSPEC_HIDDEN; +extern HRESULT DP_SetSPPlayerData( IDirectPlay2Impl* lpDP, DPID idPlayer, LPVOID lpData ) DECLSPEC_HIDDEN; /* DP external interfaces to call into DPSP interface */ -extern LPVOID DPSP_CreateSPPlayerData(void); +extern LPVOID DPSP_CreateSPPlayerData(void) DECLSPEC_HIDDEN; #endif /* __WINE_DPLAY_GLOBAL_INCLUDED */ diff --git a/reactos/dll/directx/dplayx/dplaysp.c b/reactos/dll/directx/dplayx/dplaysp.c index 29087ca99f3..e4f458c9ad6 100644 --- a/reactos/dll/directx/dplayx/dplaysp.c +++ b/reactos/dll/directx/dplayx/dplaysp.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ //#include @@ -86,7 +86,6 @@ typedef struct tagDP_SPPLAYERDATA } DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA; /* Create the SP interface */ -extern HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp ) { TRACE( " for %s\n", debugstr_guid( riid ) ); @@ -101,7 +100,7 @@ HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp if( IsEqualGUID( &IID_IDirectPlaySP, riid ) ) { - IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)*ppvObj; + IDirectPlaySPImpl *This = *ppvObj; This->lpVtbl = &directPlaySPVT; } else @@ -134,7 +133,7 @@ HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp static BOOL DPSP_CreateIUnknown( LPVOID lpSP ) { - IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP; + IDirectPlaySPImpl *This = lpSP; This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) ); @@ -144,14 +143,16 @@ static BOOL DPSP_CreateIUnknown( LPVOID lpSP ) } InitializeCriticalSection( &This->unk->DPSP_lock ); + This->unk->DPSP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlaySPImpl*->DirectPlaySPIUnknownData*->DPSP_lock"); return TRUE; } static BOOL DPSP_DestroyIUnknown( LPVOID lpSP ) { - IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP; + IDirectPlaySPImpl *This = lpSP; + This->unk->DPSP_lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &This->unk->DPSP_lock ); HeapFree( GetProcessHeap(), 0, This->unk ); @@ -161,7 +162,7 @@ static BOOL DPSP_DestroyIUnknown( LPVOID lpSP ) static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp ) { - IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP; + IDirectPlaySPImpl *This = lpSP; This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) ); @@ -192,7 +193,7 @@ static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp ) static BOOL DPSP_DestroyDirectPlaySP( LPVOID lpSP ) { - IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP; + IDirectPlaySPImpl *This = lpSP; /* Normally we should be keeping a reference, but since only the dplay * interface that created us can destroy us, we do not keep a reference @@ -234,7 +235,7 @@ static HRESULT WINAPI DPSP_QueryInterface if( IsEqualGUID( &IID_IDirectPlaySP, riid ) ) { - IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)*ppvObj; + IDirectPlaySPImpl *This = *ppvObj; This->lpVtbl = &directPlaySPVT; } else @@ -260,7 +261,7 @@ static ULONG WINAPI DPSP_AddRef ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef ); - TRACE( "ref count incremented to %lu:%lu for %p\n", + TRACE( "ref count incremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); return ulObjRefCount; @@ -275,7 +276,7 @@ static ULONG WINAPI DPSP_Release ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef ); - TRACE( "ref count decremented to %lu:%lu for %p\n", + TRACE( "ref count decremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); /* Deallocate if this is the last reference to the object */ @@ -306,7 +307,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_AddMRUEntry /* Should be able to call the comctl32 undocumented MRU routines. I suspect that the interface works appropriately */ - FIXME( "(%p)->(%p,%p%p,0x%08lx,0x%08lx): stub\n", + FIXME( "(%p)->(%p,%p%p,0x%08x,0x%08x): stub\n", This, lpSection, lpKey, lpData, dwDataSize, dwMaxEntries ); return DP_OK; @@ -324,7 +325,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_CreateAddress { IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - FIXME( "(%p)->(%s,%s,%p,0x%08lx,%p,%p): stub\n", + FIXME( "(%p)->(%s,%s,%p,0x%08x,%p,%p): stub\n", This, debugstr_guid(guidSP), debugstr_guid(guidDataType), lpData, dwDataSize, lpAddress, lpdwAddressSize ); @@ -341,7 +342,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_EnumAddress { IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - TRACE( "(%p)->(%p,%p,0x%08lx,%p)\n", + TRACE( "(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext ); DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext ); @@ -375,7 +376,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_GetPlayerFlags { IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - FIXME( "(%p)->(0x%08lx,%p): stub\n", + FIXME( "(%p)->(0x%08x,%p): stub\n", This, idPlayer, lpdwPlayerFlags ); return DP_OK; @@ -393,7 +394,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_GetSPPlayerData LPDP_SPPLAYERDATA lpPlayerData; IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx)\n", + TRACE( "(%p)->(0x%08x,%p,%p,0x%08x)\n", This, idPlayer, lplpData, lpdwDataSize, dwFlags ); hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerData ); @@ -433,7 +434,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage LPVOID lpMessageHeader ) { - LPDPMSG_SENDENVELOPE lpMsg = (LPDPMSG_SENDENVELOPE)lpMessageBody; + LPDPMSG_SENDENVELOPE lpMsg = lpMessageBody; HRESULT hr = DPERR_GENERIC; WORD wCommandId; WORD wVersion; @@ -441,24 +442,24 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n", + FIXME( "(%p)->(%p,0x%08x,%p): mostly stub\n", This, lpMessageBody, dwMessageBodySize, lpMessageHeader ); wCommandId = lpMsg->wCommandId; wVersion = lpMsg->wVersion; - TRACE( "Incoming message has envelope of 0x%08lx, %u, %u\n", + TRACE( "Incoming message has envelope of 0x%08x, %u, %u\n", lpMsg->dwMagic, wCommandId, wVersion ); if( lpMsg->dwMagic != DPMSGMAGIC_DPLAYMSG ) { - ERR( "Unknown magic 0x%08lx!\n", lpMsg->dwMagic ); + ERR( "Unknown magic 0x%08x!\n", lpMsg->dwMagic ); return DPERR_GENERIC; } #if 0 { - const LPDWORD lpcHeader = (LPDWORD)lpMessageHeader; + const LPDWORD lpcHeader = lpMessageHeader; TRACE( "lpMessageHeader = [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx]\n", lpcHeader[0], lpcHeader[1], lpcHeader[2], lpcHeader[3], lpcHeader[4] ); @@ -499,7 +500,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage #if 0 HRESULT hr = DP_OK; HANDLE hReceiveEvent = 0; - /* FIXME: Aquire some sort of interface lock */ + /* FIXME: Acquire some sort of interface lock */ /* FIXME: Need some sort of context for this callback. Need to determine * how this is actually done with the SP */ @@ -508,7 +509,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage { case DPSYS_CREATEPLAYERORGROUP: { - LPDPMSG_CREATEPLAYERORGROUP msg = (LPDPMSG_CREATEPLAYERORGROUP)lpMsg; + LPDPMSG_CREATEPLAYERORGROUP msg = lpMsg; if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER ) { @@ -543,7 +544,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_DESTROYPLAYERORGROUP: { - LPDPMSG_DESTROYPLAYERORGROUP msg = (LPDPMSG_DESTROYPLAYERORGROUP)lpMsg; + LPDPMSG_DESTROYPLAYERORGROUP msg = lpMsg; if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER ) { @@ -564,7 +565,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_ADDPLAYERTOGROUP: { - LPDPMSG_ADDPLAYERTOGROUP msg = (LPDPMSG_ADDPLAYERTOGROUP)lpMsg; + LPDPMSG_ADDPLAYERTOGROUP msg = lpMsg; hr = DP_IF_AddPlayerToGroup( This, msg->dpIdGroup, msg->dpIdPlayer, ... ); break; @@ -572,7 +573,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_DELETEPLAYERFROMGROUP: { - LPDPMSG_DELETEPLAYERFROMGROUP msg = (LPDPMSG_DELETEPLAYERFROMGROUP)lpMsg; + LPDPMSG_DELETEPLAYERFROMGROUP msg = lpMsg; hr = DP_IF_DeletePlayerFromGroup( This, msg->dpIdGroup, msg->dpIdPlayer, ... ); @@ -582,7 +583,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SESSIONLOST: { - LPDPMSG_SESSIONLOST msg = (LPDPMSG_SESSIONLOST)lpMsg; + LPDPMSG_SESSIONLOST msg = lpMsg; FIXME( "DPSYS_SESSIONLOST not handled\n" ); @@ -591,7 +592,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_HOST: { - LPDPMSG_HOST msg = (LPDPMSG_HOST)lpMsg; + LPDPMSG_HOST msg = lpMsg; FIXME( "DPSYS_HOST not handled\n" ); @@ -600,7 +601,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SETPLAYERORGROUPDATA: { - LPDPMSG_SETPLAYERORGROUPDATA msg = (LPDPMSG_SETPLAYERORGROUPDATA)lpMsg; + LPDPMSG_SETPLAYERORGROUPDATA msg = lpMsg; if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER ) { @@ -622,7 +623,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SETPLAYERORGROUPNAME: { - LPDPMSG_SETPLAYERORGROUPNAME msg = (LPDPMSG_SETPLAYERORGROUPNAME)lpMsg; + LPDPMSG_SETPLAYERORGROUPNAME msg = lpMsg; if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER ) { @@ -643,7 +644,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SETSESSIONDESC; { - LPDPMSG_SETSESSIONDESC msg = (LPDPMSG_SETSESSIONDESC)lpMsg; + LPDPMSG_SETSESSIONDESC msg = lpMsg; hr = DP_IF_SetSessionDesc( This, &msg->dpDesc ); @@ -652,7 +653,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_ADDGROUPTOGROUP: { - LPDPMSG_ADDGROUPTOGROUP msg = (LPDPMSG_ADDGROUPTOGROUP)lpMsg; + LPDPMSG_ADDGROUPTOGROUP msg = lpMsg; hr = DP_IF_AddGroupToGroup( This, msg->dpIdParentGroup, msg->dpIdGroup, ... ); @@ -662,7 +663,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_DELETEGROUPFROMGROUP: { - LPDPMSG_DELETEGROUPFROMGROUP msg = (LPDPMSG_DELETEGROUPFROMGROUP)lpMsg; + LPDPMSG_DELETEGROUPFROMGROUP msg = lpMsg; hr = DP_IF_DeleteGroupFromGroup( This, msg->dpIdParentGroup, msg->dpIdGroup, ... ); @@ -672,7 +673,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SECUREMESSAGE: { - LPDPMSG_SECUREMESSAGE msg = (LPDPMSG_SECUREMESSAGE)lpMsg; + LPDPMSG_SECUREMESSAGE msg = lpMsg; FIXME( "DPSYS_SECUREMESSAGE not implemented\n" ); @@ -681,7 +682,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_STARTSESSION: { - LPDPMSG_STARTSESSION msg = (LPDPMSG_STARTSESSION)lpMsg; + LPDPMSG_STARTSESSION msg = lpMsg; FIXME( "DPSYS_STARTSESSION not implemented\n" ); @@ -690,7 +691,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_CHAT: { - LPDPMSG_CHAT msg = (LPDPMSG_CHAT)lpMsg; + LPDPMSG_CHAT msg = lpMsg; FIXME( "DPSYS_CHAT not implemeneted\n" ); @@ -699,7 +700,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SETGROUPOWNER: { - LPDPMSG_SETGROUPOWNER msg = (LPDPMSG_SETGROUPOWNER)lpMsg; + LPDPMSG_SETGROUPOWNER msg = lpMsg; FIXME( "DPSYS_SETGROUPOWNER not implemented\n" ); @@ -708,7 +709,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage case DPSYS_SENDCOMPLETE: { - LPDPMSG_SENDCOMPLETE msg = (LPDPMSG_SENDCOMPLETE)lpMsg; + LPDPMSG_SENDCOMPLETE msg = lpMsg; FIXME( "DPSYS_SENDCOMPLETE not implemented\n" ); @@ -755,7 +756,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_SetSPPlayerData IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ - TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx)\n", + TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x)\n", This, idPlayer, lpData, dwDataSize, dwFlags ); hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerEntry ); @@ -794,7 +795,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_CreateCompoundAddress { IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - FIXME( "(%p)->(%p,0x%08lx,%p,%p): stub\n", + FIXME( "(%p)->(%p,0x%08x,%p,%p): stub\n", This, lpElements, dwElementCount, lpAddress, lpdwAddressSize ); return DP_OK; @@ -811,7 +812,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_GetSPData IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ - TRACE( "(%p)->(%p,%p,0x%08lx)\n", + TRACE( "(%p)->(%p,%p,0x%08x)\n", This, lplpData, lpdwDataSize, dwFlags ); #if 0 @@ -827,7 +828,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_GetSPData */ if( dwFlags != DPSET_REMOTE ) { - TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags ); + TRACE( "Undocumented dwFlags 0x%08x used\n", dwFlags ); } #endif @@ -870,7 +871,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_SetSPData IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ - TRACE( "(%p)->(%p,0x%08lx,0x%08lx)\n", + TRACE( "(%p)->(%p,0x%08x,0x%08x)\n", This, lpData, dwDataSize, dwFlags ); #if 0 @@ -886,7 +887,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_SetSPData */ if( dwFlags != DPSET_REMOTE ) { - TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags ); + TRACE( "Undocumented dwFlags 0x%08x used\n", dwFlags ); } #endif @@ -918,7 +919,7 @@ static VOID WINAPI IDirectPlaySPImpl_SendComplete { IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface; - FIXME( "(%p)->(%p,0x%08lx): stub\n", + FIXME( "(%p)->(%p,0x%08x): stub\n", This, unknownA, unknownB ); } @@ -947,7 +948,7 @@ static const IDirectPlaySPVtbl directPlaySPVT = /* DP external interfaces to call into DPSP interface */ /* Allocate the structure */ -extern LPVOID DPSP_CreateSPPlayerData(void) +LPVOID DPSP_CreateSPPlayerData(void) { TRACE( "Creating SPPlayer data struct\n" ); return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, diff --git a/reactos/dll/directx/dplayx/dplayx.idl b/reactos/dll/directx/dplayx/dplayx.idl new file mode 100644 index 00000000000..cf9dd206535 --- /dev/null +++ b/reactos/dll/directx/dplayx/dplayx.idl @@ -0,0 +1,33 @@ +/* + * COM Classes for dplayx + * + * Copyright 2010 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + helpstring("DirectPlay Object"), + threading(both), + uuid(d1eb6d20-8923-11d0-9d97-00a0c90a43cb) +] +coclass DirectPlay { interface IDirectPlay; } + +[ + helpstring("DirectPlayLobby Object"), + threading(both), + uuid(2fe8f810-b2a5-11d0-a787-0000f803abfc) +] +coclass DirectPlayLobby { interface IDirectPlayLobby; } diff --git a/reactos/dll/directx/dplayx/dplayx.rgs b/reactos/dll/directx/dplayx/dplayx.rgs new file mode 100644 index 00000000000..5e35076d64c --- /dev/null +++ b/reactos/dll/directx/dplayx/dplayx.rgs @@ -0,0 +1,17 @@ +HKCR +{ + NoRemove Interface + { + } + NoRemove CLSID + { + '{D1EB6D20-8923-11D0-9D97-00A0C90A43CB}' = s 'DirectPlay Object' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } + } + '{2FE8F810-B2A5-11D0-A787-0000F803ABFC}' = s 'DirectPlayLobby Object' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } + } + } +} diff --git a/reactos/dll/directx/dplayx/dplayx_global.c b/reactos/dll/directx/dplayx/dplayx_global.c index fc3fa41232d..86551b55846 100644 --- a/reactos/dll/directx/dplayx/dplayx_global.c +++ b/reactos/dll/directx/dplayx/dplayx_global.c @@ -15,14 +15,14 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * - * NOTES: + * NOTES: * o Implementation of all things which are associated with dplay on - * the computer - ie shared resources and such. Methods in this - * compilation unit should not call anything out side this unit - * excepting base windows services and an interface to start the + * the computer - i.e. shared resources and such. Methods in this + * compilation unit should not call anything outside of this unit + * except base windows services and an interface to start the * messaging thread. * o Methods that begin with DPLAYX_ are used for dealing with * dplayx.dll data which is accessible from all processes. @@ -51,16 +51,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(dplay); /* FIXME: Need to do all that fun other dll referencing type of stuff */ /* Static data for all processes */ -static LPCSTR lpszDplayxSemaName = "WINE_DPLAYX_SM"; +static const char lpszDplayxSemaName[] = "WINE_DPLAYX_SM"; static HANDLE hDplayxSema; -static LPCSTR lpszDplayxFileMapping = "WINE_DPLAYX_FM"; +static const char lpszDplayxFileMapping[] = "WINE_DPLAYX_FM"; static HANDLE hDplayxSharedMem; static LPVOID lpSharedStaticData = NULL; -#define DPLAYX_AquireSemaphore() TRACE( "Waiting for DPLAYX semaphore\n" ); \ +#define DPLAYX_AcquireSemaphore() TRACE( "Waiting for DPLAYX semaphore\n" ); \ WaitForSingleObject( hDplayxSema, INFINITE );\ TRACE( "Through wait\n" ) @@ -89,8 +89,7 @@ typedef struct static DPLAYX_MEM_SLICE* lpMemArea; -void DPLAYX_PrivHeapFree( LPVOID addr ); -void DPLAYX_PrivHeapFree( LPVOID addr ) +static void DPLAYX_PrivHeapFree( LPVOID addr ) { LPVOID lpAddrStart; DWORD dwBlockUsed; @@ -107,16 +106,14 @@ void DPLAYX_PrivHeapFree( LPVOID addr ) lpMemArea[ dwBlockUsed ].used = 0; } -/* FIXME: This should be static, but is being used for a hack right now */ -LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size ); -LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size ) +static LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size ) { LPVOID lpvArea = NULL; UINT uBlockUsed; if( size > (dwBlockSize - sizeof(DWORD)) ) { - FIXME( "Size exceeded. Request of 0x%08lx\n", size ); + FIXME( "Size exceeded. Request of 0x%08x\n", size ); size = dwBlockSize - sizeof(DWORD); } @@ -128,7 +125,7 @@ LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size ) { /* Set the area used */ lpMemArea[ uBlockUsed ].used = 1; - lpvArea = &(lpMemArea[ uBlockUsed ].data); + lpvArea = lpMemArea[ uBlockUsed ].data; } else { @@ -144,27 +141,6 @@ LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size ) return lpvArea; } -LPSTR DPLAYX_strdupA( DWORD flags, LPCSTR str ); -LPSTR DPLAYX_strdupA( DWORD flags, LPCSTR str ) -{ - LPSTR p = DPLAYX_PrivHeapAlloc( flags, strlen(str) + 1 ); - if(p) { - strcpy( p, str ); - } - return p; -} - -LPWSTR DPLAYX_strdupW( DWORD flags, LPCWSTR str ); -LPWSTR DPLAYX_strdupW( DWORD flags, LPCWSTR str ) -{ - INT len = strlenW(str) + 1; - LPWSTR p = DPLAYX_PrivHeapAlloc( flags, len * sizeof(WCHAR) ); - if(p) { - strcpyW( p, str ); - } - return p; -} - enum { numSupportedLobbies = 32, numSupportedSessions = 32 }; typedef struct tagDPLAYX_LOBBYDATA @@ -198,17 +174,181 @@ static DPLAYX_LOBBYDATA* lobbyData = NULL; static DPSESSIONDESC2* sessionData = NULL; /* static DPSESSIONDESC2* sessionData[ numSupportedSessions ]; */ -/* Function prototypes */ -DWORD DPLAYX_SizeOfLobbyDataA( LPDPLCONNECTION lpDplData ); -DWORD DPLAYX_SizeOfLobbyDataW( LPDPLCONNECTION lpDplData ); -void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, LPDPLCONNECTION src ); -void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, LPDPLCONNECTION src ); -BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppId, LPDPLAYX_LOBBYDATA* dplData ); -void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData ); -BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest, - LPCDPSESSIONDESC2 lpSessionSrc ); +static void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData ) +{ + ZeroMemory( lpData, sizeof( *lpData ) ); +} +/* NOTE: This must be called with the semaphore acquired. + * TRUE/FALSE with a pointer to it's data returned. Pointer data is + * is only valid if TRUE is returned. + */ +static BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppID, LPDPLAYX_LOBBYDATA* lplpDplData ) +{ + UINT i; + + *lplpDplData = NULL; + + if( dwAppID == 0 ) + { + dwAppID = GetCurrentProcessId(); + TRACE( "Translated dwAppID == 0 into 0x%08x\n", dwAppID ); + } + + for( i=0; i < numSupportedLobbies; i++ ) + { + if( lobbyData[ i ].dwAppID == dwAppID ) + { + /* This process is lobbied */ + TRACE( "Found 0x%08x @ %u\n", dwAppID, i ); + *lplpDplData = &lobbyData[ i ]; + return TRUE; + } + } + + return FALSE; +} + +/* Reserve a spot for the new application. TRUE means success and FALSE failure. */ +BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID ) +{ + UINT i; + + /* 0 is the marker for unused application data slots */ + if( dwAppID == 0 ) + { + return FALSE; + } + + DPLAYX_AcquireSemaphore(); + + /* Find an empty space in the list and insert the data */ + for( i=0; i < numSupportedLobbies; i++ ) + { + if( lobbyData[ i ].dwAppID == 0 ) + { + /* This process is now lobbied */ + TRACE( "Setting lobbyData[%u] for (0x%08x,0x%08x)\n", + i, dwAppID, GetCurrentProcessId() ); + + lobbyData[ i ].dwAppID = dwAppID; + lobbyData[ i ].dwAppLaunchedFromID = GetCurrentProcessId(); + + /* FIXME: Where is the best place for this? In interface or here? */ + lobbyData[ i ].hInformOnAppStart = 0; + lobbyData[ i ].hInformOnAppDeath = 0; + lobbyData[ i ].hInformOnSettingRead = 0; + + DPLAYX_ReleaseSemaphore(); + return TRUE; + } + } + + ERR( "No empty lobbies\n" ); + + DPLAYX_ReleaseSemaphore(); + return FALSE; +} + +BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID, + HANDLE hStart, HANDLE hDeath, HANDLE hConnRead ) +{ + LPDPLAYX_LOBBYDATA lpLData; + + /* Need to explicitly give lobby application. Can't set for yourself */ + if( dwAppID == 0 ) + { + return FALSE; + } + + DPLAYX_AcquireSemaphore(); + + if( !DPLAYX_IsAppIdLobbied( dwAppID, &lpLData ) ) + { + DPLAYX_ReleaseSemaphore(); + return FALSE; + } + + lpLData->hInformOnAppStart = hStart; + lpLData->hInformOnAppDeath = hDeath; + lpLData->hInformOnSettingRead = hConnRead; + + DPLAYX_ReleaseSemaphore(); + + return TRUE; +} + +static BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart, + LPHANDLE lphDeath, + LPHANDLE lphConnRead, + BOOL bClearSetHandles ) +{ + LPDPLAYX_LOBBYDATA lpLData; + + DPLAYX_AcquireSemaphore(); + + if( !DPLAYX_IsAppIdLobbied( 0, &lpLData ) ) + { + DPLAYX_ReleaseSemaphore(); + return FALSE; + } + + if( lphStart != NULL ) + { + if( lpLData->hInformOnAppStart == 0 ) + { + DPLAYX_ReleaseSemaphore(); + return FALSE; + } + + *lphStart = lpLData->hInformOnAppStart; + + if( bClearSetHandles ) + { + CloseHandle( lpLData->hInformOnAppStart ); + lpLData->hInformOnAppStart = 0; + } + } + + if( lphDeath != NULL ) + { + if( lpLData->hInformOnAppDeath == 0 ) + { + DPLAYX_ReleaseSemaphore(); + return FALSE; + } + + *lphDeath = lpLData->hInformOnAppDeath; + + if( bClearSetHandles ) + { + CloseHandle( lpLData->hInformOnAppDeath ); + lpLData->hInformOnAppDeath = 0; + } + } + + if( lphConnRead != NULL ) + { + if( lpLData->hInformOnSettingRead == 0 ) + { + DPLAYX_ReleaseSemaphore(); + return FALSE; + } + + *lphConnRead = lpLData->hInformOnSettingRead; + + if( bClearSetHandles ) + { + CloseHandle( lpLData->hInformOnSettingRead ); + lpLData->hInformOnSettingRead = 0; + } + } + + DPLAYX_ReleaseSemaphore(); + + return TRUE; +} /*************************************************************************** * Called to initialize the global data. This will only be used on the @@ -229,7 +369,7 @@ BOOL DPLAYX_ConstructData(void) s_attrib.lpSecurityDescriptor = NULL; s_attrib.nLength = sizeof(s_attrib); - hDplayxSema = CreateSemaphoreA( &s_attrib, 1, 1, lpszDplayxSemaName ); + hDplayxSema = CreateSemaphoreA( &s_attrib, 0, 1, lpszDplayxSemaName ); /* First instance creates the semaphore. Others just use it */ if( GetLastError() == ERROR_SUCCESS ) @@ -242,17 +382,16 @@ BOOL DPLAYX_ConstructData(void) else if ( GetLastError() == ERROR_ALREADY_EXISTS ) { TRACE( "Found semaphore handle %p\n", hDplayxSema ); + DPLAYX_AcquireSemaphore(); } else { - ERR( ": semaphore error %ld\n", GetLastError() ); + ERR( ": semaphore error %d\n", GetLastError() ); return FALSE; } SetLastError( ERROR_SUCCESS ); - DPLAYX_AquireSemaphore(); - hDplayxSharedMem = CreateFileMappingA( INVALID_HANDLE_VALUE, &s_attrib, PAGE_READWRITE | SEC_COMMIT, @@ -270,7 +409,8 @@ BOOL DPLAYX_ConstructData(void) } else { - ERR( ": unable to create shared memory (%ld)\n", GetLastError() ); + ERR( ": unable to create shared memory (%d)\n", GetLastError() ); + DPLAYX_ReleaseSemaphore(); return FALSE; } @@ -280,8 +420,9 @@ BOOL DPLAYX_ConstructData(void) if( lpSharedStaticData == NULL ) { - ERR( ": unable to map static data into process memory space (%ld)\n", + ERR( ": unable to map static data into process memory space (%d)\n", GetLastError() ); + DPLAYX_ReleaseSemaphore(); return FALSE; } else @@ -293,7 +434,7 @@ BOOL DPLAYX_ConstructData(void) else { /* Presently the shared data structures use pointers. If the - * files are no mapped into the same area, the pointers will no + * files are not mapped into the same area, the pointers will no * longer make any sense :( * FIXME: In the future make the shared data structures have some * sort of fixup to make them independent between data spaces. @@ -308,7 +449,7 @@ BOOL DPLAYX_ConstructData(void) lpMemArea = (LPVOID)((BYTE*)lpSharedStaticData + dwStaticSharedSize); /* FIXME: Crude hack */ - lobbyData = (DPLAYX_LOBBYDATA*)lpSharedStaticData; + lobbyData = lpSharedStaticData; sessionData = (DPSESSIONDESC2*)((BYTE*)lpSharedStaticData + (dwStaticSharedSize/2)); /* Initialize shared data segments. */ @@ -330,7 +471,7 @@ BOOL DPLAYX_ConstructData(void) sessionData[i].dwSize = 0; } - /* Zero out the dynmaic area */ + /* Zero out the dynamic area */ ZeroMemory( lpMemArea, dwDynamicSharedSize ); /* Just for fun sync the whole data area */ @@ -395,209 +536,241 @@ BOOL DPLAYX_DestructData(void) } -void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData ) +/* Assumption: Enough contiguous space was allocated at dest */ +static void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, const DPLCONNECTION *src ) { - ZeroMemory( lpData, sizeof( *lpData ) ); + BYTE* lpStartOfFreeSpace; + + *dest = *src; + + lpStartOfFreeSpace = ((BYTE*)dest) + sizeof( DPLCONNECTION ); + + /* Copy the LPDPSESSIONDESC2 structure if it exists */ + if( src->lpSessionDesc ) + { + dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 ); + *dest->lpSessionDesc = *src->lpSessionDesc; + + /* Session names may or may not exist */ + if( src->lpSessionDesc->u1.lpszSessionNameA ) + { + strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionNameA ); + dest->lpSessionDesc->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += + strlen( dest->lpSessionDesc->u1.lpszSessionNameA ) + 1; + } + + if( src->lpSessionDesc->u2.lpszPasswordA ) + { + strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPasswordA ); + dest->lpSessionDesc->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += + strlen( dest->lpSessionDesc->u2.lpszPasswordA ) + 1; + } + } + + /* DPNAME structure is optional */ + if( src->lpPlayerName ) + { + dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof( DPNAME ); + *dest->lpPlayerName = *src->lpPlayerName; + + if( src->lpPlayerName->u1.lpszShortNameA ) + { + strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortNameA ); + dest->lpPlayerName->u1.lpszShortNameA = (LPSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += + strlen( dest->lpPlayerName->u1.lpszShortNameA ) + 1; + } + + if( src->lpPlayerName->u2.lpszLongNameA ) + { + strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongNameA ); + dest->lpPlayerName->u2.lpszLongNameA = (LPSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += + strlen( (LPSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ; + } + + } + + /* Copy address if it exists */ + if( src->lpAddress ) + { + dest->lpAddress = lpStartOfFreeSpace; + CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize ); + /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */ + } } -/* NOTE: This must be called with the semaphore aquired. - * TRUE/FALSE with a pointer to it's data returned. Pointer data is - * is only valid if TRUE is returned. - */ -BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppID, LPDPLAYX_LOBBYDATA* lplpDplData ) +/* Assumption: Enough contiguous space was allocated at dest */ +static void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, const DPLCONNECTION *src ) { - UINT i; + BYTE* lpStartOfFreeSpace; - *lplpDplData = NULL; + *dest = *src; - if( dwAppID == 0 ) + lpStartOfFreeSpace = ( (BYTE*)dest) + sizeof( DPLCONNECTION ); + + /* Copy the LPDPSESSIONDESC2 structure if it exists */ + if( src->lpSessionDesc ) { - dwAppID = GetCurrentProcessId(); - TRACE( "Translated dwAppID == 0 into 0x%08lx\n", dwAppID ); - } + dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 ); + *dest->lpSessionDesc = *src->lpSessionDesc; - for( i=0; i < numSupportedLobbies; i++ ) - { - if( lobbyData[ i ].dwAppID == dwAppID ) + /* Session names may or may not exist */ + if( src->lpSessionDesc->u1.lpszSessionName ) { - /* This process is lobbied */ - TRACE( "Found 0x%08lx @ %u\n", dwAppID, i ); - *lplpDplData = &lobbyData[ i ]; - return TRUE; + strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionName ); + dest->lpSessionDesc->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof(WCHAR) * + ( strlenW( dest->lpSessionDesc->u1.lpszSessionName ) + 1 ); + } + + if( src->lpSessionDesc->u2.lpszPassword ) + { + strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPassword ); + dest->lpSessionDesc->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof(WCHAR) * + ( strlenW( dest->lpSessionDesc->u2.lpszPassword ) + 1 ); } } - return FALSE; + /* DPNAME structure is optional */ + if( src->lpPlayerName ) + { + dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof( DPNAME ); + *dest->lpPlayerName = *src->lpPlayerName; + + if( src->lpPlayerName->u1.lpszShortName ) + { + strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortName ); + dest->lpPlayerName->u1.lpszShortName = (LPWSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof(WCHAR) * + ( strlenW( dest->lpPlayerName->u1.lpszShortName ) + 1 ); + } + + if( src->lpPlayerName->u2.lpszLongName ) + { + strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongName ); + dest->lpPlayerName->u2.lpszLongName = (LPWSTR)lpStartOfFreeSpace; + lpStartOfFreeSpace += sizeof(WCHAR) * + ( strlenW( dest->lpPlayerName->u2.lpszLongName ) + 1 ); + } + + } + + /* Copy address if it exists */ + if( src->lpAddress ) + { + dest->lpAddress = lpStartOfFreeSpace; + CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize ); + /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */ + } + } -/* Reserve a spot for the new appliction. TRUE means success and FALSE failure. */ -BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID ) +static DWORD DPLAYX_SizeOfLobbyDataA( const DPLCONNECTION *lpConn ) { - UINT i; + DWORD dwTotalSize = sizeof( DPLCONNECTION ); - /* 0 is the marker for unused application data slots */ - if( dwAppID == 0 ) + /* Just a safety check */ + if( lpConn == NULL ) { - return FALSE; + ERR( "lpConn is NULL\n" ); + return 0; } - DPLAYX_AquireSemaphore(); - - /* Find an empty space in the list and insert the data */ - for( i=0; i < numSupportedLobbies; i++ ) + if( lpConn->lpSessionDesc != NULL ) { - if( lobbyData[ i ].dwAppID == 0 ) + dwTotalSize += sizeof( DPSESSIONDESC2 ); + + if( lpConn->lpSessionDesc->u1.lpszSessionNameA ) { - /* This process is now lobbied */ - TRACE( "Setting lobbyData[%u] for (0x%08lx,0x%08lx)\n", - i, dwAppID, GetCurrentProcessId() ); + dwTotalSize += strlen( lpConn->lpSessionDesc->u1.lpszSessionNameA ) + 1; + } - lobbyData[ i ].dwAppID = dwAppID; - lobbyData[ i ].dwAppLaunchedFromID = GetCurrentProcessId(); - - /* FIXME: Where is the best place for this? In interface or here? */ - lobbyData[ i ].hInformOnAppStart = 0; - lobbyData[ i ].hInformOnAppDeath = 0; - lobbyData[ i ].hInformOnSettingRead = 0; - - DPLAYX_ReleaseSemaphore(); - return TRUE; + if( lpConn->lpSessionDesc->u2.lpszPasswordA ) + { + dwTotalSize += strlen( lpConn->lpSessionDesc->u2.lpszPasswordA ) + 1; } } - ERR( "No empty lobbies\n" ); + if( lpConn->lpPlayerName != NULL ) + { + dwTotalSize += sizeof( DPNAME ); - DPLAYX_ReleaseSemaphore(); - return FALSE; + if( lpConn->lpPlayerName->u1.lpszShortNameA ) + { + dwTotalSize += strlen( lpConn->lpPlayerName->u1.lpszShortNameA ) + 1; + } + + if( lpConn->lpPlayerName->u2.lpszLongNameA ) + { + dwTotalSize += strlen( lpConn->lpPlayerName->u2.lpszLongNameA ) + 1; + } + + } + + dwTotalSize += lpConn->dwAddressSize; + + return dwTotalSize; } -/* I'm not sure when I'm going to need this, but here it is */ -BOOL DPLAYX_DestroyLobbyApplication( DWORD dwAppID ) +static DWORD DPLAYX_SizeOfLobbyDataW( const DPLCONNECTION *lpConn ) { - UINT i; + DWORD dwTotalSize = sizeof( DPLCONNECTION ); - DPLAYX_AquireSemaphore(); - - /* Find an empty space in the list and insert the data */ - for( i=0; i < numSupportedLobbies; i++ ) + /* Just a safety check */ + if( lpConn == NULL ) { - if( lobbyData[ i ].dwAppID == dwAppID ) - { - /* FIXME: Should free up anything unused. Tisk tisk :0 */ - /* Mark this entry unused */ - TRACE( "Marking lobbyData[%u] unused\n", i ); - DPLAYX_InitializeLobbyDataEntry( &lobbyData[ i ] ); + ERR( "lpConn is NULL\n" ); + return 0; + } - DPLAYX_ReleaseSemaphore(); - return TRUE; + if( lpConn->lpSessionDesc != NULL ) + { + dwTotalSize += sizeof( DPSESSIONDESC2 ); + + if( lpConn->lpSessionDesc->u1.lpszSessionName ) + { + dwTotalSize += sizeof( WCHAR ) * + ( strlenW( lpConn->lpSessionDesc->u1.lpszSessionName ) + 1 ); + } + + if( lpConn->lpSessionDesc->u2.lpszPassword ) + { + dwTotalSize += sizeof( WCHAR ) * + ( strlenW( lpConn->lpSessionDesc->u2.lpszPassword ) + 1 ); } } - DPLAYX_ReleaseSemaphore(); - ERR( "Unable to find global entry for application\n" ); - return FALSE; + if( lpConn->lpPlayerName != NULL ) + { + dwTotalSize += sizeof( DPNAME ); + + if( lpConn->lpPlayerName->u1.lpszShortName ) + { + dwTotalSize += sizeof( WCHAR ) * + ( strlenW( lpConn->lpPlayerName->u1.lpszShortName ) + 1 ); + } + + if( lpConn->lpPlayerName->u2.lpszLongName ) + { + dwTotalSize += sizeof( WCHAR ) * + ( strlenW( lpConn->lpPlayerName->u2.lpszLongName ) + 1 ); + } + + } + + dwTotalSize += lpConn->dwAddressSize; + + return dwTotalSize; } -BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID, - HANDLE hStart, HANDLE hDeath, HANDLE hConnRead ) -{ - LPDPLAYX_LOBBYDATA lpLData; - - /* Need to explictly give lobby application. Can't set for yourself */ - if( dwAppID == 0 ) - { - return FALSE; - } - - DPLAYX_AquireSemaphore(); - - if( !DPLAYX_IsAppIdLobbied( dwAppID, &lpLData ) ) - { - DPLAYX_ReleaseSemaphore(); - return FALSE; - } - - lpLData->hInformOnAppStart = hStart; - lpLData->hInformOnAppDeath = hDeath; - lpLData->hInformOnSettingRead = hConnRead; - - DPLAYX_ReleaseSemaphore(); - - return TRUE; -} - -BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart, - LPHANDLE lphDeath, - LPHANDLE lphConnRead, - BOOL bClearSetHandles ) -{ - LPDPLAYX_LOBBYDATA lpLData; - - DPLAYX_AquireSemaphore(); - - if( !DPLAYX_IsAppIdLobbied( 0, &lpLData ) ) - { - DPLAYX_ReleaseSemaphore(); - return FALSE; - } - - if( lphStart != NULL ) - { - if( lpLData->hInformOnAppStart == 0 ) - { - DPLAYX_ReleaseSemaphore(); - return FALSE; - } - - *lphStart = lpLData->hInformOnAppStart; - - if( bClearSetHandles ) - { - CloseHandle( lpLData->hInformOnAppStart ); - lpLData->hInformOnAppStart = 0; - } - } - - if( lphDeath != NULL ) - { - if( lpLData->hInformOnAppDeath == 0 ) - { - DPLAYX_ReleaseSemaphore(); - return FALSE; - } - - *lphDeath = lpLData->hInformOnAppDeath; - - if( bClearSetHandles ) - { - CloseHandle( lpLData->hInformOnAppDeath ); - lpLData->hInformOnAppDeath = 0; - } - } - - if( lphConnRead != NULL ) - { - if( lpLData->hInformOnSettingRead == 0 ) - { - DPLAYX_ReleaseSemaphore(); - return FALSE; - } - - *lphConnRead = lpLData->hInformOnSettingRead; - - if( bClearSetHandles ) - { - CloseHandle( lpLData->hInformOnSettingRead ); - lpLData->hInformOnSettingRead = 0; - } - } - - DPLAYX_ReleaseSemaphore(); - - return TRUE; -} - - HRESULT DPLAYX_GetConnectionSettingsA ( DWORD dwAppID, LPVOID lpData, @@ -607,13 +780,13 @@ HRESULT DPLAYX_GetConnectionSettingsA DWORD dwRequiredDataSize = 0; HANDLE hInformOnSettingRead; - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) ) { DPLAYX_ReleaseSemaphore(); - TRACE( "Application 0x%08lx is not lobbied\n", dwAppID ); + TRACE( "Application 0x%08x is not lobbied\n", dwAppID ); return DPERR_NOTLOBBIED; } @@ -633,7 +806,7 @@ HRESULT DPLAYX_GetConnectionSettingsA return DPERR_BUFFERTOOSMALL; } - DPLAYX_CopyConnStructA( (LPDPLCONNECTION)lpData, lpDplData->lpConn ); + DPLAYX_CopyConnStructA( lpData, lpDplData->lpConn ); DPLAYX_ReleaseSemaphore(); @@ -654,74 +827,6 @@ HRESULT DPLAYX_GetConnectionSettingsA return DP_OK; } -/* Assumption: Enough contiguous space was allocated at dest */ -void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, LPDPLCONNECTION src ) -{ - BYTE* lpStartOfFreeSpace; - - CopyMemory( dest, src, sizeof( DPLCONNECTION ) ); - - lpStartOfFreeSpace = ((BYTE*)dest) + sizeof( DPLCONNECTION ); - - /* Copy the LPDPSESSIONDESC2 structure if it exists */ - if( src->lpSessionDesc ) - { - dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 ); - CopyMemory( dest->lpSessionDesc, src->lpSessionDesc, sizeof( DPSESSIONDESC2 ) ); - - /* Session names may or may not exist */ - if( src->lpSessionDesc->lpszSessionNameA ) - { - strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->lpszSessionNameA ); - dest->lpSessionDesc->lpszSessionNameA = (LPSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += - strlen( (LPSTR)dest->lpSessionDesc->lpszSessionNameA ) + 1; - } - - if( src->lpSessionDesc->lpszPasswordA ) - { - strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->lpszPasswordA ); - dest->lpSessionDesc->lpszPasswordA = (LPSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += - strlen( (LPSTR)dest->lpSessionDesc->lpszPasswordA ) + 1; - } - } - - /* DPNAME structure is optional */ - if( src->lpPlayerName ) - { - dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof( DPNAME ); - CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) ); - - if( src->lpPlayerName->lpszShortNameA ) - { - strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszShortNameA ); - dest->lpPlayerName->lpszShortNameA = (LPSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += - strlen( (LPSTR)dest->lpPlayerName->lpszShortNameA ) + 1; - } - - if( src->lpPlayerName->lpszLongNameA ) - { - strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszLongNameA ); - dest->lpPlayerName->lpszLongNameA = (LPSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += - strlen( (LPSTR)dest->lpPlayerName->lpszLongName ) + 1 ; - } - - } - - /* Copy address if it exists */ - if( src->lpAddress ) - { - dest->lpAddress = (LPVOID)lpStartOfFreeSpace; - CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize ); - /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */ - } -} - HRESULT DPLAYX_GetConnectionSettingsW ( DWORD dwAppID, LPVOID lpData, @@ -731,7 +836,7 @@ HRESULT DPLAYX_GetConnectionSettingsW DWORD dwRequiredDataSize = 0; HANDLE hInformOnSettingRead; - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) ) { @@ -755,7 +860,7 @@ HRESULT DPLAYX_GetConnectionSettingsW return DPERR_BUFFERTOOSMALL; } - DPLAYX_CopyConnStructW( (LPDPLCONNECTION)lpData, lpDplData->lpConn ); + DPLAYX_CopyConnStructW( lpData, lpDplData->lpConn ); DPLAYX_ReleaseSemaphore(); @@ -776,83 +881,14 @@ HRESULT DPLAYX_GetConnectionSettingsW return DP_OK; } -/* Assumption: Enough contiguous space was allocated at dest */ -void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, LPDPLCONNECTION src ) -{ - BYTE* lpStartOfFreeSpace; - - CopyMemory( dest, src, sizeof( DPLCONNECTION ) ); - - lpStartOfFreeSpace = ( (BYTE*)dest) + sizeof( DPLCONNECTION ); - - /* Copy the LPDPSESSIONDESC2 structure if it exists */ - if( src->lpSessionDesc ) - { - dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 ); - CopyMemory( dest->lpSessionDesc, src->lpSessionDesc, sizeof( DPSESSIONDESC2 ) ); - - /* Session names may or may not exist */ - if( src->lpSessionDesc->lpszSessionName ) - { - strcpyW( (LPWSTR)lpStartOfFreeSpace, dest->lpSessionDesc->lpszSessionName ); - src->lpSessionDesc->lpszSessionName = (LPWSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof(WCHAR) * - ( strlenW( (LPWSTR)dest->lpSessionDesc->lpszSessionName ) + 1 ); - } - - if( src->lpSessionDesc->lpszPassword ) - { - strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->lpszPassword ); - dest->lpSessionDesc->lpszPassword = (LPWSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof(WCHAR) * - ( strlenW( (LPWSTR)dest->lpSessionDesc->lpszPassword ) + 1 ); - } - } - - /* DPNAME structure is optional */ - if( src->lpPlayerName ) - { - dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof( DPNAME ); - CopyMemory( dest->lpPlayerName, src->lpPlayerName, sizeof( DPNAME ) ); - - if( src->lpPlayerName->lpszShortName ) - { - strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszShortName ); - dest->lpPlayerName->lpszShortName = (LPWSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof(WCHAR) * - ( strlenW( (LPWSTR)dest->lpPlayerName->lpszShortName ) + 1 ); - } - - if( src->lpPlayerName->lpszLongName ) - { - strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->lpszLongName ); - dest->lpPlayerName->lpszLongName = (LPWSTR)lpStartOfFreeSpace; - lpStartOfFreeSpace += sizeof(WCHAR) * - ( strlenW( (LPWSTR)dest->lpPlayerName->lpszLongName ) + 1 ); - } - - } - - /* Copy address if it exists */ - if( src->lpAddress ) - { - dest->lpAddress = (LPVOID)lpStartOfFreeSpace; - CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize ); - /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */ - } - -} - -/* Store the structure into the shared data structre. Ensure that allocs for +/* Store the structure into the shared data structure. Ensure that allocs for * variable length strings come from the shared data structure. - * FIXME: We need to free information as well + * FIXME: We need to free information as well. */ HRESULT DPLAYX_SetConnectionSettingsA ( DWORD dwFlags, DWORD dwAppID, - LPDPLCONNECTION lpConn ) + const DPLCONNECTION *lpConn ) { LPDPLAYX_LOBBYDATA lpDplData; @@ -866,13 +902,12 @@ HRESULT DPLAYX_SetConnectionSettingsA /* Store information */ if( lpConn->dwSize != sizeof(DPLCONNECTION) ) { - ERR(": old/new DPLCONNECTION type? Size=%08lx vs. expected=%ul bytes\n", - lpConn->dwSize, sizeof( DPLCONNECTION ) ); + ERR(": old/new DPLCONNECTION type? Size=%08x\n", lpConn->dwSize ); return DPERR_INVALIDPARAMS; } - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) ) { @@ -887,8 +922,8 @@ HRESULT DPLAYX_SetConnectionSettingsA { DPLAYX_ReleaseSemaphore(); - ERR("DPSESSIONDESC passed in? Size=%lu vs. expected=%u bytes\n", - lpConn->lpSessionDesc->dwSize, sizeof( DPSESSIONDESC2 ) ); + ERR("DPSESSIONDESC passed in? Size=%u\n", + lpConn->lpSessionDesc?lpConn->lpSessionDesc->dwSize:0 ); return DPERR_INVALIDPARAMS; } @@ -909,14 +944,14 @@ HRESULT DPLAYX_SetConnectionSettingsA return DP_OK; } -/* Store the structure into the shared data structre. Ensure that allocs for +/* Store the structure into the shared data structure. Ensure that allocs for * variable length strings come from the shared data structure. * FIXME: We need to free information as well */ HRESULT DPLAYX_SetConnectionSettingsW ( DWORD dwFlags, DWORD dwAppID, - LPDPLCONNECTION lpConn ) + const DPLCONNECTION *lpConn ) { LPDPLAYX_LOBBYDATA lpDplData; @@ -930,13 +965,12 @@ HRESULT DPLAYX_SetConnectionSettingsW /* Store information */ if( lpConn->dwSize != sizeof(DPLCONNECTION) ) { - ERR(": old/new DPLCONNECTION type? Size=%lu vs. expected=%u bytes\n", - lpConn->dwSize, sizeof( DPLCONNECTION ) ); + ERR(": old/new DPLCONNECTION type? Size=%u\n", lpConn->dwSize ); return DPERR_INVALIDPARAMS; } - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); if ( ! DPLAYX_IsAppIdLobbied( dwAppID, &lpDplData ) ) { @@ -961,193 +995,11 @@ HRESULT DPLAYX_SetConnectionSettingsW return DP_OK; } -DWORD DPLAYX_SizeOfLobbyDataA( LPDPLCONNECTION lpConn ) -{ - DWORD dwTotalSize = sizeof( DPLCONNECTION ); - - /* Just a safety check */ - if( lpConn == NULL ) - { - ERR( "lpConn is NULL\n" ); - return 0; - } - - if( lpConn->lpSessionDesc != NULL ) - { - dwTotalSize += sizeof( DPSESSIONDESC2 ); - - if( lpConn->lpSessionDesc->lpszSessionNameA ) - { - dwTotalSize += strlen( lpConn->lpSessionDesc->lpszSessionNameA ) + 1; - } - - if( lpConn->lpSessionDesc->lpszPasswordA ) - { - dwTotalSize += strlen( lpConn->lpSessionDesc->lpszPasswordA ) + 1; - } - } - - if( lpConn->lpPlayerName != NULL ) - { - dwTotalSize += sizeof( DPNAME ); - - if( lpConn->lpPlayerName->lpszShortNameA ) - { - dwTotalSize += strlen( lpConn->lpPlayerName->lpszShortNameA ) + 1; - } - - if( lpConn->lpPlayerName->lpszLongNameA ) - { - dwTotalSize += strlen( lpConn->lpPlayerName->lpszLongNameA ) + 1; - } - - } - - dwTotalSize += lpConn->dwAddressSize; - - return dwTotalSize; -} - -DWORD DPLAYX_SizeOfLobbyDataW( LPDPLCONNECTION lpConn ) -{ - DWORD dwTotalSize = sizeof( DPLCONNECTION ); - - /* Just a safety check */ - if( lpConn == NULL ) - { - ERR( "lpConn is NULL\n" ); - return 0; - } - - if( lpConn->lpSessionDesc != NULL ) - { - dwTotalSize += sizeof( DPSESSIONDESC2 ); - - if( lpConn->lpSessionDesc->lpszSessionName ) - { - dwTotalSize += sizeof( WCHAR ) * - ( strlenW( lpConn->lpSessionDesc->lpszSessionName ) + 1 ); - } - - if( lpConn->lpSessionDesc->lpszPassword ) - { - dwTotalSize += sizeof( WCHAR ) * - ( strlenW( lpConn->lpSessionDesc->lpszPassword ) + 1 ); - } - } - - if( lpConn->lpPlayerName != NULL ) - { - dwTotalSize += sizeof( DPNAME ); - - if( lpConn->lpPlayerName->lpszShortName ) - { - dwTotalSize += sizeof( WCHAR ) * - ( strlenW( lpConn->lpPlayerName->lpszShortName ) + 1 ); - } - - if( lpConn->lpPlayerName->lpszLongName ) - { - dwTotalSize += sizeof( WCHAR ) * - ( strlenW( lpConn->lpPlayerName->lpszLongName ) + 1 ); - } - - } - - dwTotalSize += lpConn->dwAddressSize; - - return dwTotalSize; -} - - - -static LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateSessionDesc2A( LPCDPSESSIONDESC2 lpSessionSrc ) -{ - LPDPSESSIONDESC2 lpSessionDest = - HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpSessionSrc ) ); - DPLAYX_CopyIntoSessionDesc2A( lpSessionDest, lpSessionSrc ); - - return lpSessionDest; -} - -/* Copy an ANSI session desc structure to the given buffer */ -BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest, - LPCDPSESSIONDESC2 lpSessionSrc ) -{ - CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) ); - - if( lpSessionSrc->lpszSessionNameA ) - { - if ((lpSessionDest->lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, - strlen(lpSessionSrc->lpszSessionNameA)+1 ))) - strcpy( lpSessionDest->lpszSessionNameA, lpSessionSrc->lpszSessionNameA ); - } - if( lpSessionSrc->lpszPasswordA ) - { - if ((lpSessionDest->lpszPasswordA = HeapAlloc( GetProcessHeap(), 0, - strlen(lpSessionSrc->lpszPasswordA)+1 ))) - strcpy( lpSessionDest->lpszPasswordA, lpSessionSrc->lpszPasswordA ); - } - - return TRUE; -} - -/* Start the index at 0. index will be updated to equal that which should - be passed back into this function for the next element */ -LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateLocalSession( UINT* index ) -{ - for( ; (*index) < numSupportedSessions; (*index)++ ) - { - if( sessionData[(*index)].dwSize != 0 ) - { - return DPLAYX_CopyAndAllocateSessionDesc2A( &sessionData[(*index)++] ); - } - } - - /* No more sessions */ - return NULL; -} - -/* Start the index at 0. index will be updated to equal that which should - be passed back into this function for the next element */ -BOOL DPLAYX_CopyLocalSession( UINT* index, LPDPSESSIONDESC2 lpsd ) -{ - for( ; (*index) < numSupportedSessions; (*index)++ ) - { - if( sessionData[(*index)].dwSize != 0 ) - { - return DPLAYX_CopyIntoSessionDesc2A( lpsd, &sessionData[(*index)++] ); - } - } - - /* No more sessions */ - return FALSE; -} - -void DPLAYX_SetLocalSession( LPCDPSESSIONDESC2 lpsd ) -{ - UINT i; - - /* FIXME: Is this an error if it exists already? */ - - /* Crude/wrong implementation for now. Just always add to first empty spot */ - for( i=0; i < numSupportedSessions; i++ ) - { - /* Is this one empty? */ - if( sessionData[i].dwSize == 0 ) - { - DPLAYX_CopyIntoSessionDesc2A( &sessionData[i], lpsd ); - break; - } - } - -} - BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait ) { LPDPLAYX_LOBBYDATA lpLobbyData; - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); if( !DPLAYX_IsAppIdLobbied( 0, &lpLobbyData ) ) { @@ -1167,7 +1019,7 @@ BOOL DPLAYX_AnyLobbiesWaitingForConnSettings(void) UINT i; BOOL bFound = FALSE; - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); for( i=0; i < numSupportedLobbies; i++ ) { @@ -1189,7 +1041,7 @@ BOOL DPLAYX_SetLobbyMsgThreadId( DWORD dwAppId, DWORD dwThreadId ) { LPDPLAYX_LOBBYDATA lpLobbyData; - DPLAYX_AquireSemaphore(); + DPLAYX_AcquireSemaphore(); if( !DPLAYX_IsAppIdLobbied( dwAppId, &lpLobbyData ) ) { @@ -1347,7 +1199,7 @@ LPCSTR DPLAYX_HresultToString(HRESULT hr) default: /* For errors not in the list, return HRESULT as a string This part is not thread safe */ - WARN( "Unknown error 0x%08lx\n", hr ); + WARN( "Unknown error 0x%08x\n", hr ); wsprintfA( szTempStr, "0x%08lx", hr ); return szTempStr; } diff --git a/reactos/dll/directx/dplayx/dplayx_global.h b/reactos/dll/directx/dplayx/dplayx_global.h index 4d9571eeb7a..db86a90529c 100644 --- a/reactos/dll/directx/dplayx/dplayx_global.h +++ b/reactos/dll/directx/dplayx/dplayx_global.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DPLAYX_GLOBAL @@ -21,7 +21,6 @@ #define WIN32_NO_STATUS #define _INC_WINDOWS -#define COM_NO_WINDOWS_H #include @@ -30,51 +29,35 @@ //#include "winuser.h" #include -BOOL DPLAYX_ConstructData(void); -BOOL DPLAYX_DestructData(void); +BOOL DPLAYX_ConstructData(void) DECLSPEC_HIDDEN; +BOOL DPLAYX_DestructData(void) DECLSPEC_HIDDEN; HRESULT DPLAYX_GetConnectionSettingsA ( DWORD dwAppID, LPVOID lpData, - LPDWORD lpdwDataSize ); + LPDWORD lpdwDataSize ) DECLSPEC_HIDDEN; HRESULT DPLAYX_GetConnectionSettingsW ( DWORD dwAppID, LPVOID lpData, - LPDWORD lpdwDataSize ); + LPDWORD lpdwDataSize ) DECLSPEC_HIDDEN; HRESULT DPLAYX_SetConnectionSettingsA ( DWORD dwFlags, DWORD dwAppID, - LPDPLCONNECTION lpConn ); + const DPLCONNECTION *lpConn ) DECLSPEC_HIDDEN; HRESULT DPLAYX_SetConnectionSettingsW ( DWORD dwFlags, DWORD dwAppID, - LPDPLCONNECTION lpConn ); + const DPLCONNECTION *lpConn ) DECLSPEC_HIDDEN; -BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID ); -BOOL DPLAYX_DestroyLobbyApplication( DWORD dwAppID ); +BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID ) DECLSPEC_HIDDEN; -BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait ); -BOOL DPLAYX_AnyLobbiesWaitingForConnSettings(void); +BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait ) DECLSPEC_HIDDEN; +BOOL DPLAYX_AnyLobbiesWaitingForConnSettings(void) DECLSPEC_HIDDEN; BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID, - HANDLE hStart, HANDLE hDeath, HANDLE hConnRead ); -BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart, - LPHANDLE lphDeath, - LPHANDLE lphConnRead, BOOL bClearSetHandles ); + HANDLE hStart, HANDLE hDeath, HANDLE hConnRead ) DECLSPEC_HIDDEN; -LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateLocalSession( UINT* index ); -BOOL DPLAYX_CopyLocalSession( UINT* index, LPDPSESSIONDESC2 lpsd ); -void DPLAYX_SetLocalSession( LPCDPSESSIONDESC2 lpsd ); - -BOOL DPLAYX_SetLobbyMsgThreadId( DWORD dwAppId, DWORD dwThreadId ); - -/* FIXME: This should not be here */ -LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size ); -void DPLAYX_PrivHeapFree( LPVOID addr ); - -LPSTR DPLAYX_strdupA( DWORD flags, LPCSTR str ); -LPWSTR DPLAYX_strdupW( DWORD flags, LPCWSTR str ); -/* FIXME: End shared data alloc which should be local */ +BOOL DPLAYX_SetLobbyMsgThreadId( DWORD dwAppId, DWORD dwThreadId ) DECLSPEC_HIDDEN; /* Convert a DP or DPL HRESULT code into a string for human consumption */ -LPCSTR DPLAYX_HresultToString( HRESULT hr ); +LPCSTR DPLAYX_HresultToString( HRESULT hr ) DECLSPEC_HIDDEN; #endif /* __WINE_DPLAYX_GLOBAL */ diff --git a/reactos/dll/directx/dplayx/dplayx_main.c b/reactos/dll/directx/dplayx/dplayx_main.c index 822c5c70663..ac8eb9cc4a7 100644 --- a/reactos/dll/directx/dplayx/dplayx_main.c +++ b/reactos/dll/directx/dplayx/dplayx_main.c @@ -16,21 +16,21 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * NOTES * o DPMSGCMD_ENUMSESSIONSREPLY & DPMSGCMD_ENUMSESSIONSREQUEST * Have most fields understood, but not all. Everything seems to work. * o DPMSGCMD_REQUESTNEWPLAYERID & DPMSGCMD_NEWPLAYERIDREPLY - * Barely work. This needs to be completed for sessions to start. + * Barely works. This needs to be completed for sessions to start. * o A small issue will be the fact that DirectX 6.1(ie. DirectPlay4) - * introduces a layer of functionality inside the DP objects which + * introduces a layer of functionality inside the DP objects which * provide guaranteed protocol delivery. This is even if the native * protocol, IPX or modem for instance, doesn't guarantee it. I'm going - * to leave this kind of implementation to as close to the end as - * possible. However, I will implement an abstraction layer, where - * possible, for this functionality. It will do nothing to start, but - * will require only the implementation of the guaranteness to give + * to leave this kind of implementation to as close to the end as + * possible. However, I will implement an abstraction layer, where + * possible, for this functionality. It will do nothing to start, but + * will require only the implementation of the guarantee to give * final implementation. * * TODO: @@ -41,31 +41,39 @@ * - Change RegEnumKeyEx enumeration pattern to allow error handling and to * share registry implementation (or at least simplify). * - Add in appropriate RegCloseKey calls for all the opening we're doing... - * - Fix all the buffer sizes for registry calls. They're off by one - + * - Fix all the buffer sizes for registry calls. They're off by one - * but in a safe direction. * - Fix race condition on interface destruction * - Handles need to be correctly reference counted - * - Check if we need to deallocate any list objects when destroying + * - Check if we need to deallocate any list objects when destroying * a dplay interface - * - RunApplication process spawning needs to have correct syncronization. + * - RunApplication process spawning needs to have correct synchronization. * - Need to get inter lobby messages working. - * - Decypher dplay messages between applications and implement... + * - Decipher dplay messages between applications and implement... * - Need to implement lobby session spawning. * - Improve footprint and realtime blocking by setting up a separate data share * between lobby application and client since there can be multiple apps per * client. Also get rid of offset dependency by making data offset independent * somehow. */ -//#include + +#define WIN32_NO_STATUS +#define _INC_WINDOWS + +#include //#include "winerror.h" -//#include "windef.h" -//#include "winbase.h" +#include +#include +#include +#include #include #include "dplayx_global.h" WINE_DEFAULT_DEBUG_CHANNEL(dplay); +static HINSTANCE instance; + /* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */ DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */ @@ -73,11 +81,12 @@ DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { - TRACE( "(%p,%ld,%p)\n", hinstDLL, fdwReason, lpvReserved ); + TRACE( "(%p,%d,%p)\n", hinstDLL, fdwReason, lpvReserved ); switch ( fdwReason ) { case DLL_PROCESS_ATTACH: + instance = hinstDLL; DisableThreadLibraryCalls(hinstDLL); /* First instance perform construction of global processor data */ return DPLAYX_ConstructData(); @@ -102,10 +111,26 @@ HRESULT WINAPI DllCanUnloadNow(void) HRESULT hr = ( gdwDPlaySPRefCount > 0 ) ? S_FALSE : S_OK; /* FIXME: Should I be putting a check in for class factory objects - * as well + * as well? */ - TRACE( ": returning 0x%08lx\n", hr ); + TRACE( ": returning 0x%08x\n", hr ); return hr; } + +/*********************************************************************** + * DllRegisterServer (DPLAYX.@) + */ +HRESULT WINAPI DllRegisterServer(void) +{ + return __wine_register_resources( instance ); +} + +/*********************************************************************** + * DllUnregisterServer (DPLAYX.@) + */ +HRESULT WINAPI DllUnregisterServer(void) +{ + return __wine_unregister_resources( instance ); +} diff --git a/reactos/dll/directx/dplayx/dplayx_messages.c b/reactos/dll/directx/dplayx/dplayx_messages.c index e6d1f130d99..ed3ddebb699 100644 --- a/reactos/dll/directx/dplayx/dplayx_messages.c +++ b/reactos/dll/directx/dplayx/dplayx_messages.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * NOTES * o Messaging interface required for both DirectPlay and DirectPlayLobby. @@ -110,7 +110,7 @@ error: static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext ) { - LPMSGTHREADINFO lpThreadInfo = (LPMSGTHREADINFO)lpContext; + LPMSGTHREADINFO lpThreadInfo = lpContext; DWORD dwWaitResult; TRACE( "Msg thread created. Waiting on app startup\n" ); @@ -119,7 +119,7 @@ static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext ) dwWaitResult = WaitForSingleObject( lpThreadInfo->hStart, 10000 /* 10 sec */ ); if( dwWaitResult == WAIT_TIMEOUT ) { - FIXME( "Should signal app/wait creation failure (0x%08lx)\n", dwWaitResult ); + FIXME( "Should signal app/wait creation failure (0x%08x)\n", dwWaitResult ); goto end_of_thread; } @@ -131,14 +131,14 @@ static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext ) dwWaitResult = WaitForSingleObject( lpThreadInfo->hSettingRead, INFINITE ); if( dwWaitResult == WAIT_TIMEOUT ) { - ERR( "App Read connection setting timeout fail (0x%08lx)\n", dwWaitResult ); + ERR( "App Read connection setting timeout fail (0x%08x)\n", dwWaitResult ); } /* Close this handle as it's not needed anymore */ CloseHandle( lpThreadInfo->hSettingRead ); lpThreadInfo->hSettingRead = 0; - TRACE( "App created && intialized starting main message reception loop\n" ); + TRACE( "App created && initialized starting main message reception loop\n" ); for ( ;; ) { @@ -153,7 +153,7 @@ end_of_thread: return 0; } -/* DP messageing stuff */ +/* DP messaging stuff */ static HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This, LPDP_MSG_REPLY_STRUCT_LIST lpReplyStructList, WORD wReplyCommandId ); @@ -172,7 +172,7 @@ HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This, /* Insert into the message queue while locked */ EnterCriticalSection( &This->unk->DP_lock ); - DPQ_INSERT( This->dp2->replysExpected, lpReplyStructList, replysExpected ); + DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected ); LeaveCriticalSection( &This->unk->DP_lock ); return lpReplyStructList->replyExpected.hReceipt; @@ -225,7 +225,7 @@ HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags, data.bSystemMessage = TRUE; /* Allow reply to be sent */ data.lpISP = This->dp2->spData.lpISP; - TRACE( "Asking for player id w/ dwFlags 0x%08lx\n", + TRACE( "Asking for player id w/ dwFlags 0x%08x\n", lpMsgBody->dwFlags ); DP_MSG_ExpectReply( This, &data, DPMSG_DEFAULT_WAIT_TIME, DPMSGCMD_NEWPLAYERIDREPLY, @@ -233,20 +233,20 @@ HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags, } /* Need to examine the data and extract the new player id */ - if( !FAILED(hr) ) + if( SUCCEEDED(hr) ) { LPCDPMSG_NEWPLAYERIDREPLY lpcReply; - lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY)lpMsg; + lpcReply = lpMsg; *lpdpidAllocatedId = lpcReply->dpidNewPlayerId; - TRACE( "Received reply for id = 0x%08lx\n", lpcReply->dpidNewPlayerId ); + TRACE( "Received reply for id = 0x%08x\n", lpcReply->dpidNewPlayerId ); /* FIXME: I think that the rest of the message has something to do * with remote data for the player that perhaps I need to setup. * However, with the information that is passed, all that it could - * be used for is a standardized intialization value, which I'm + * be used for is a standardized initialization value, which I'm * guessing we can do without. Unless the message content is the same * for several different messages? */ @@ -282,7 +282,7 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) DWORD dwDataSize; /* SP Player remote data needs to be propagated at some point - is this the point? */ - IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, 0, (LPVOID*)&lpPData, &dwDataSize, DPSET_REMOTE ); + 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" @@ -323,18 +323,14 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) lpMsgBody->unknown4[3] = NS_GetNsMagic( This->dp2->lpNameServerData ) - 0x02000000; - TRACE( "Setting first magic to 0x%08lx\n", lpMsgBody->unknown4[3] ); + TRACE( "Setting first magic to 0x%08x\n", lpMsgBody->unknown4[3] ); lpMsgBody->unknown4[4] = 0x0; lpMsgBody->unknown4[5] = 0x0; lpMsgBody->unknown4[6] = 0x0; -#if 0 - lpMsgBody->unknown4[7] = NS_GetOtherMagic( This->dp2->lpNameServerData ) -#else lpMsgBody->unknown4[7] = NS_GetNsMagic( This->dp2->lpNameServerData ); -#endif - TRACE( "Setting second magic to 0x%08lx\n", lpMsgBody->unknown4[7] ); + TRACE( "Setting second magic to 0x%08x\n", lpMsgBody->unknown4[7] ); lpMsgBody->unknown4[8] = 0x0; lpMsgBody->unknown4[9] = 0x0; @@ -356,7 +352,7 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) data.bSystemMessage = TRUE; /* Allow reply to be sent */ data.lpISP = This->dp2->spData.lpISP; - TRACE( "Sending forward player request with 0x%08lx\n", dpidServer ); + TRACE( "Sending forward player request with 0x%08x\n", dpidServer ); lpMsg = DP_MSG_ExpectReply( This, &data, DPMSG_WAIT_60_SECS, @@ -393,7 +389,7 @@ LPVOID DP_MSG_ExpectReply( IDirectPlay2AImpl* This, LPDPSP_SENDDATA lpData, hMsgReceipt = DP_MSG_BuildAndLinkReplyStruct( This, &replyStructList, wReplyCommandId ); - TRACE( "Sending msg and expecting cmd %u in reply within %lu ticks\n", + TRACE( "Sending msg and expecting cmd %u in reply within %u ticks\n", wReplyCommandId, dwWaitTime ); hr = (*This->dp2->spData.lpCB->Send)( lpData ); @@ -409,7 +405,7 @@ LPVOID DP_MSG_ExpectReply( IDirectPlay2AImpl* This, LPDPSP_SENDDATA lpData, dwWaitReturn = WaitForSingleObject( hMsgReceipt, dwWaitTime ); if( dwWaitReturn != WAIT_OBJECT_0 ) { - ERR( "Wait failed 0x%08lx\n", dwWaitReturn ); + ERR( "Wait failed 0x%08x\n", dwWaitReturn ); return NULL; } @@ -437,7 +433,7 @@ void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId, * avoid problems. */ EnterCriticalSection( &This->unk->DP_lock ); - DPQ_REMOVE_ENTRY( This->dp2->replysExpected, replysExpected, replyExpected.wExpectedReply,\ + DPQ_REMOVE_ENTRY( This->dp2->repliesExpected, repliesExpected, replyExpected.wExpectedReply, ==, wCommandId, lpReplyList ); LeaveCriticalSection( &This->unk->DP_lock ); @@ -502,7 +498,7 @@ void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId, { LPCDPMSG_FORWARDADDPLAYERNACK lpcErrorMsg; - lpcErrorMsg = (LPCDPMSG_FORWARDADDPLAYERNACK)lpMsgBody; + lpcErrorMsg = lpMsgBody; ERR( "Received error message %u. Error is %s\n", wCommandId, DPLAYX_HresultToString( lpcErrorMsg->errorCode) ); diff --git a/reactos/dll/directx/dplayx/dplayx_messages.h b/reactos/dll/directx/dplayx/dplayx_messages.h index 60f08576475..fbf6b33be6e 100644 --- a/reactos/dll/directx/dplayx/dplayx_messages.h +++ b/reactos/dll/directx/dplayx/dplayx_messages.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DPLAYX_MESSAGES__ @@ -29,17 +29,17 @@ #include "dplay_global.h" DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart, - HANDLE hDeath, HANDLE hConnRead ); + HANDLE hDeath, HANDLE hConnRead ) DECLSPEC_HIDDEN; HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags, - LPDPID lpdipidAllocatedId ); -HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ); + LPDPID lpdipidAllocatedId ) DECLSPEC_HIDDEN; +HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer ) DECLSPEC_HIDDEN; void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId, - LPCVOID lpMsgBody, DWORD dwMsgBodySize ); + LPCVOID lpMsgBody, DWORD dwMsgBodySize ) DECLSPEC_HIDDEN; void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId, - LPCVOID lpMsgBody, DWORD dwMsgBodySize ); -void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf ); + LPCVOID lpMsgBody, DWORD dwMsgBodySize ) DECLSPEC_HIDDEN; +void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf ) DECLSPEC_HIDDEN; /* Timings -> 1000 ticks/sec */ #define DPMSG_WAIT_5_SECS 5000 diff --git a/reactos/dll/directx/dplayx/dplayx_queue.h b/reactos/dll/directx/dplayx/dplayx_queue.h index 9bad0cc56ba..33467ee895e 100644 --- a/reactos/dll/directx/dplayx/dplayx_queue.h +++ b/reactos/dll/directx/dplayx/dplayx_queue.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * NOTES * o Linked list implementation for dplay/dplobby. Based off of the BSD @@ -122,7 +122,7 @@ do { \ * elm - how to find the next element * field - to be concatenated to rc to compare with fieldToCompare * fieldToCompare - The value that we're comparing against - * compare_cb - Callback to invoke to determine if comparision should continue. + * compare_cb - Callback to invoke to determine if comparison should continue. * Callback must be defined with DPQ_DECL_COMPARECB. * rc - Variable to put the return code. Same type as (head).lpQHFirst */ @@ -174,7 +174,7 @@ do { \ * elm - how to find the next element * field - to be concatenated to rc to compare with fieldToCompare * fieldToCompare - The value that we're comparing against - * compare_cb - Callback to invoke to determine if comparision should continue. + * compare_cb - Callback to invoke to determine if comparison should continue. * Callback must be defined with DPQ_DECL_COMPARECB. * rc - Variable to put the return code. Same type as (head).lpQHFirst */ @@ -211,6 +211,6 @@ do \ #define DPQ_DECL_DELETECB( name, type ) void name( type elem ) /* Prototype of a method which just performs a HeapFree on the elem */ -DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID ); +DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID ) DECLSPEC_HIDDEN; #endif /* __WINE_DPLAYX_QUEUE_H */ diff --git a/reactos/dll/directx/dplayx/dplobby.c b/reactos/dll/directx/dplayx/dplobby.c index 7bfc9ce0434..b8500334df3 100644 --- a/reactos/dll/directx/dplayx/dplobby.c +++ b/reactos/dll/directx/dplayx/dplobby.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include //#include @@ -48,9 +48,9 @@ typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3WImpl; /* Forward declarations for this module helper methods */ HRESULT DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements, DWORD dwElementCount, - LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface ); + LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface )DECLSPEC_HIDDEN; -HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize, +static HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize, LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface ); @@ -58,11 +58,11 @@ HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress, DWORD dwAddressSize, LPVOID lpContext ); -static HRESULT WINAPI DPL_ConnectEx( IDirectPlayLobbyAImpl* This, - DWORD dwFlags, REFIID riid, - LPVOID* lplpDP, IUnknown* pUnk ); +static HRESULT DPL_ConnectEx( IDirectPlayLobbyAImpl* This, + DWORD dwFlags, REFIID riid, + LPVOID* lplpDP, IUnknown* pUnk ); -BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess, +static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess, LPHANDLE lphStart, LPHANDLE lphDeath, LPHANDLE lphRead ); @@ -145,7 +145,7 @@ static const IDirectPlayLobby3Vtbl directPlayLobby3AVT; static BOOL DPL_CreateIUnknown( LPVOID lpDPL ) { - IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL; + IDirectPlayLobbyAImpl *This = lpDPL; This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) ); if ( This->unk == NULL ) @@ -154,14 +154,16 @@ static BOOL DPL_CreateIUnknown( LPVOID lpDPL ) } InitializeCriticalSection( &This->unk->DPL_lock ); + This->unk->DPL_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayLobbyAImpl*->DirectPlayLobbyIUnknownData*->DPL_lock"); return TRUE; } static BOOL DPL_DestroyIUnknown( LPVOID lpDPL ) { - IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL; + IDirectPlayLobbyAImpl *This = lpDPL; + This->unk->DPL_lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &This->unk->DPL_lock ); HeapFree( GetProcessHeap(), 0, This->unk ); @@ -170,7 +172,7 @@ static BOOL DPL_DestroyIUnknown( LPVOID lpDPL ) static BOOL DPL_CreateLobby1( LPVOID lpDPL ) { - IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL; + IDirectPlayLobbyAImpl *This = lpDPL; This->dpl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl) ) ); if ( This->dpl == NULL ) @@ -185,7 +187,7 @@ static BOOL DPL_CreateLobby1( LPVOID lpDPL ) static BOOL DPL_DestroyLobby1( LPVOID lpDPL ) { - IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)lpDPL; + IDirectPlayLobbyAImpl *This = lpDPL; if( This->dpl->dwMsgThread ) { @@ -202,7 +204,7 @@ static BOOL DPL_DestroyLobby1( LPVOID lpDPL ) static BOOL DPL_CreateLobby2( LPVOID lpDPL ) { - IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)lpDPL; + IDirectPlayLobby2AImpl *This = lpDPL; This->dpl2 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl2) ) ); if ( This->dpl2 == NULL ) @@ -215,7 +217,7 @@ static BOOL DPL_CreateLobby2( LPVOID lpDPL ) static BOOL DPL_DestroyLobby2( LPVOID lpDPL ) { - IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)lpDPL; + IDirectPlayLobby2AImpl *This = lpDPL; HeapFree( GetProcessHeap(), 0, This->dpl2 ); @@ -224,7 +226,7 @@ static BOOL DPL_DestroyLobby2( LPVOID lpDPL ) static BOOL DPL_CreateLobby3( LPVOID lpDPL ) { - IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)lpDPL; + IDirectPlayLobby3AImpl *This = lpDPL; This->dpl3 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl3) ) ); if ( This->dpl3 == NULL ) @@ -237,7 +239,7 @@ static BOOL DPL_CreateLobby3( LPVOID lpDPL ) static BOOL DPL_DestroyLobby3( LPVOID lpDPL ) { - IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)lpDPL; + IDirectPlayLobby3AImpl *This = lpDPL; HeapFree( GetProcessHeap(), 0, This->dpl3 ); @@ -268,7 +270,6 @@ static BOOL DPL_DestroyLobby3( LPVOID lpDPL ) * successfully for a third interface, a query for the first interface * through the pointer for the third interface must succeed. */ -extern HRESULT DPL_CreateInterface ( REFIID riid, LPVOID* ppvObj ) { @@ -284,32 +285,32 @@ HRESULT DPL_CreateInterface if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) ) { - IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)*ppvObj; + IDirectPlayLobbyWImpl *This = *ppvObj; This->lpVtbl = &directPlayLobbyWVT; } else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) ) { - IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)*ppvObj; + IDirectPlayLobbyAImpl *This = *ppvObj; This->lpVtbl = &directPlayLobbyAVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) ) { - IDirectPlayLobby2WImpl *This = (IDirectPlayLobby2WImpl *)*ppvObj; + IDirectPlayLobby2WImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby2WVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) ) { - IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)*ppvObj; + IDirectPlayLobby2AImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby2AVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) ) { - IDirectPlayLobby3WImpl *This = (IDirectPlayLobby3WImpl *)*ppvObj; + IDirectPlayLobby3WImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby3WVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) ) { - IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)*ppvObj; + IDirectPlayLobby3AImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby3AVT; } else @@ -364,32 +365,32 @@ static HRESULT WINAPI DPL_QueryInterface if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) ) { - IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)*ppvObj; + IDirectPlayLobbyWImpl *This = *ppvObj; This->lpVtbl = &directPlayLobbyWVT; } else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) ) { - IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)*ppvObj; + IDirectPlayLobbyAImpl *This = *ppvObj; This->lpVtbl = &directPlayLobbyAVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) ) { - IDirectPlayLobby2WImpl *This = (IDirectPlayLobby2WImpl *)*ppvObj; + IDirectPlayLobby2WImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby2WVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) ) { - IDirectPlayLobby2AImpl *This = (IDirectPlayLobby2AImpl *)*ppvObj; + IDirectPlayLobby2AImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby2AVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) ) { - IDirectPlayLobby3WImpl *This = (IDirectPlayLobby3WImpl *)*ppvObj; + IDirectPlayLobby3WImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby3WVT; } else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) ) { - IDirectPlayLobby3AImpl *This = (IDirectPlayLobby3AImpl *)*ppvObj; + IDirectPlayLobby3AImpl *This = *ppvObj; This->lpVtbl = &directPlayLobby3AVT; } else @@ -419,7 +420,7 @@ static ULONG WINAPI DPL_AddRef ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef ); - TRACE( "ref count incremented to %lu:%lu for %p\n", + TRACE( "ref count incremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); return ulObjRefCount; @@ -439,7 +440,7 @@ static ULONG WINAPI DPL_Release ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef ); - TRACE( "ref count decremented to %lu:%lu for %p\n", + TRACE( "ref count decremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); /* Deallocate if this is the last reference to the object */ @@ -468,7 +469,7 @@ static ULONG WINAPI DPL_Release * Returns an IDirectPlay interface. * */ -static HRESULT WINAPI DPL_ConnectEx +static HRESULT DPL_ConnectEx ( IDirectPlayLobbyAImpl* This, DWORD dwFlags, REFIID riid, @@ -480,7 +481,7 @@ static HRESULT WINAPI DPL_ConnectEx DWORD dwConnSize = 0; LPDPLCONNECTION lpConn; - FIXME("(%p)->(0x%08lx,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk ); + FIXME("(%p)->(0x%08x,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk ); if( pUnk ) { @@ -610,7 +611,7 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress lpAddress, lpdwAddressSize, FALSE ); } -HRESULT DPL_CreateAddress( +static HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, @@ -622,7 +623,7 @@ HRESULT DPL_CreateAddress( const DWORD dwNumAddElements = 2; /* Service Provide & address data type */ DPCOMPOUNDADDRESSELEMENT addressElements[ 2 /* dwNumAddElements */ ]; - TRACE( "(%p)->(%p,%p,0x%08lx,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize, + TRACE( "(%p)->(%p,%p,0x%08x,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize, lpAddress, lpdwAddressSize, bAnsiInterface ); addressElements[ 0 ].guidDataType = DPAID_ServiceProvider; @@ -656,7 +657,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress { IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface; - TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This, lpEnumAddressCallback, lpAddress, + TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext ); return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext ); @@ -671,14 +672,14 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress { IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface; - TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This, lpEnumAddressCallback, lpAddress, + TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext ); return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext ); } -extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress, - DWORD dwAddressSize, LPVOID lpContext ) +HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress, + DWORD dwAddressSize, LPVOID lpContext ) { DWORD dwTotalSizeEnumerated = 0; @@ -686,13 +687,13 @@ extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, L while ( dwTotalSizeEnumerated < dwAddressSize ) { - const DPADDRESS* lpElements = (const DPADDRESS*)lpAddress; + const DPADDRESS* lpElements = lpAddress; DWORD dwSizeThisEnumeration; /* Invoke the enum method. If false is returned, stop enumeration */ if ( !lpEnumAddressCallback( &lpElements->guidDataType, lpElements->dwDataSize, - (BYTE*)lpElements + sizeof( DPADDRESS ), + (const BYTE *)lpElements + sizeof( DPADDRESS ), lpContext ) ) { break; @@ -727,14 +728,14 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes char subKeyName[51]; FILETIME filetime; - TRACE(" (%p)->(%p,%p,%p,0x%08lx)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags ); + TRACE(" (%p)->(%p,%p,%p,0x%08x)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags ); if( dwFlags != 0 ) { return DPERR_INVALIDPARAMS; } - if( !lpEnumAddressTypeCallback || !*lpEnumAddressTypeCallback ) + if( !lpEnumAddressTypeCallback ) { return DPERR_INVALIDPARAMS; } @@ -863,7 +864,7 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications { IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface; - FIXME("(%p)->(%p,%p,0x%08lx):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags ); + FIXME("(%p)->(%p,%p,0x%08x):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags ); return DPERR_OUTOFMEMORY; } @@ -883,14 +884,14 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications char subKeyName[51]; FILETIME filetime; - TRACE("(%p)->(%p,%p,0x%08lx)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags ); + TRACE("(%p)->(%p,%p,0x%08x)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags ); if( dwFlags != 0 ) { return DPERR_INVALIDPARAMS; } - if( !lpEnumLocalAppCallback || !*lpEnumLocalAppCallback ) + if( !lpEnumLocalAppCallback ) { return DPERR_INVALIDPARAMS; } @@ -979,7 +980,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface; HRESULT hr; - TRACE("(%p)->(0x%08lx,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize ); + TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize ); EnterCriticalSection( &This->unk->DPL_lock ); @@ -1002,7 +1003,7 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface; HRESULT hr; - TRACE("(%p)->(0x%08lx,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize ); + TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize ); EnterCriticalSection( &This->unk->DPL_lock ); @@ -1031,7 +1032,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage LPDWORD lpdwDataSize ) { IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface; - FIXME(":stub %p %08lx %08lx %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData, + FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData, lpdwDataSize ); return DPERR_OUTOFMEMORY; } @@ -1045,7 +1046,7 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage LPDWORD lpdwDataSize ) { IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface; - FIXME(":stub %p %08lx %08lx %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData, + FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData, lpdwDataSize ); return DPERR_OUTOFMEMORY; } @@ -1143,7 +1144,7 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications return TRUE; /* Keep enumerating, haven't found the application yet */ } -BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess, +static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess, LPHANDLE lphStart, LPHANDLE lphDeath, LPHANDLE lphRead ) { @@ -1212,7 +1213,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication DWORD dwSuspendCount; HANDLE hStart, hDeath, hSettingRead; - TRACE( "(%p)->(0x%08lx,%p,%p,%p)\n", + TRACE( "(%p)->(0x%08x,%p,%p,%p)\n", This, dwFlags, lpdwAppID, lpConn, hReceiveEvent ); if( dwFlags != 0 ) @@ -1234,7 +1235,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication /* Our callback function will fill up the enumData structure with all the information required to start a new process */ IDirectPlayLobby_EnumLocalApplications( iface, RunApplicationA_EnumLocalApplications, - (LPVOID)(&enumData), 0 ); + (&enumData), 0 ); /* First the application name */ strcpy( temp, enumData.lpszPath ); @@ -1287,7 +1288,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication /* Reserve this global application id! */ if( !DPLAYX_CreateLobbyApplication( newProcessInfo.dwProcessId ) ) { - ERR( "Unable to create global application data for 0x%08lx\n", + ERR( "Unable to create global application data for 0x%08x\n", newProcessInfo.dwProcessId ); } @@ -1319,7 +1320,7 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication /* Unsuspend the process - should return the prev suspension count */ if( ( dwSuspendCount = ResumeThread( newProcessInfo.hThread ) ) != 1 ) { - ERR( "ResumeThread failed with 0x%08lx\n", dwSuspendCount ); + ERR( "ResumeThread failed with 0x%08x\n", dwSuspendCount ); } return DP_OK; @@ -1333,7 +1334,7 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication HANDLE hReceiveEvent ) { IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface; - FIXME( "(%p)->(0x%08lx,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, (void *)hReceiveEvent ); + FIXME( "(%p)->(0x%08x,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, hReceiveEvent ); return DPERR_OUTOFMEMORY; } @@ -1380,13 +1381,13 @@ static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface; HRESULT hr; - TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This, dwFlags, dwAppID, lpConn ); + TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn ); EnterCriticalSection( &This->unk->DPL_lock ); hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn ); - /* FIXME: Don't think that this is supposed to fail, but the docuementation + /* FIXME: Don't think that this is supposed to fail, but the documentation is somewhat sketchy. I'll try creating a lobby application for this... */ if( hr == DPERR_NOTLOBBIED ) @@ -1414,13 +1415,13 @@ static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface; HRESULT hr; - TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This, dwFlags, dwAppID, lpConn ); + TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn ); EnterCriticalSection( &This->unk->DPL_lock ); hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn ); - /* FIXME: Don't think that this is supposed to fail, but the docuementation + /* FIXME: Don't think that this is supposed to fail, but the documentation is somewhat sketchy. I'll try creating a lobby application for this... */ if( hr == DPERR_NOTLOBBIED ) @@ -1494,7 +1495,7 @@ HRESULT DPL_CreateCompoundAddress DWORD dwElements; LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements = lpElements; - TRACE("(%p,0x%08lx,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize ); + TRACE("(%p,0x%08x,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize ); /* Parameter check */ if( ( lpElements == NULL ) || @@ -1570,9 +1571,9 @@ HRESULT DPL_CreateCompoundAddress /* Add the total size chunk */ { - LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress; + LPDPADDRESS lpdpAddress = lpAddress; - CopyMemory( &lpdpAddress->guidDataType, &DPAID_TotalSize, sizeof( GUID ) ); + lpdpAddress->guidDataType = DPAID_TotalSize; lpdpAddress->dwDataSize = sizeof( DWORD ); lpAddress = (char *) lpAddress + sizeof( DPADDRESS ); @@ -1589,10 +1590,9 @@ HRESULT DPL_CreateCompoundAddress ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) ) ) { - LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress; + LPDPADDRESS lpdpAddress = lpAddress; - CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType, - sizeof( GUID ) ); + lpdpAddress->guidDataType = lpElements->guidDataType; lpdpAddress->dwDataSize = sizeof( GUID ); lpAddress = (char *) lpAddress + sizeof( DPADDRESS ); @@ -1604,16 +1604,13 @@ HRESULT DPL_CreateCompoundAddress ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) ) ) { - LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress; + LPDPADDRESS lpdpAddress = lpAddress; - CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType, - sizeof( GUID ) ); + lpdpAddress->guidDataType = lpElements->guidDataType; lpdpAddress->dwDataSize = lpElements->dwDataSize; lpAddress = (char *) lpAddress + sizeof( DPADDRESS ); - lstrcpynA( (LPSTR)lpAddress, - (LPCSTR)lpElements->lpData, - lpElements->dwDataSize ); + lstrcpynA( lpAddress, lpElements->lpData, lpElements->dwDataSize ); lpAddress = (char *) lpAddress + lpElements->dwDataSize; } else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) || @@ -1621,24 +1618,20 @@ HRESULT DPL_CreateCompoundAddress ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) ) ) { - LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress; + LPDPADDRESS lpdpAddress = lpAddress; - CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType, - sizeof( GUID ) ); + lpdpAddress->guidDataType = lpElements->guidDataType; lpdpAddress->dwDataSize = lpElements->dwDataSize; lpAddress = (char *) lpAddress + sizeof( DPADDRESS ); - lstrcpynW( (LPWSTR)lpAddress, - (LPCWSTR)lpElements->lpData, - lpElements->dwDataSize ); + lstrcpynW( lpAddress, lpElements->lpData, lpElements->dwDataSize ); lpAddress = (char *) lpAddress + lpElements->dwDataSize * sizeof( WCHAR ); } else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) ) { - LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress; + LPDPADDRESS lpdpAddress = lpAddress; - CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType, - sizeof( GUID ) ); + lpdpAddress->guidDataType = lpElements->guidDataType; lpdpAddress->dwDataSize = lpElements->dwDataSize; lpAddress = (char *) lpAddress + sizeof( DPADDRESS ); @@ -1647,10 +1640,9 @@ HRESULT DPL_CreateCompoundAddress } else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) ) { - LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress; + LPDPADDRESS lpdpAddress = lpAddress; - CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType, - sizeof( GUID ) ); + lpdpAddress->guidDataType = lpElements->guidDataType; lpdpAddress->dwDataSize = lpElements->dwDataSize; lpAddress = (char *) lpAddress + sizeof( DPADDRESS ); @@ -1712,9 +1704,9 @@ static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags ) { HRESULT hr = DP_OK; - BOOL bStartWait = (dwFlags & DPLWAIT_CANCEL) ? FALSE : TRUE; + BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL); - TRACE( "(%p)->(0x%08lx)\n", iface, dwFlags ); + TRACE( "(%p)->(0x%08x)\n", iface, dwFlags ); if( DPLAYX_WaitForConnectionSettings( bStartWait ) ) { @@ -1729,9 +1721,9 @@ static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags ) { HRESULT hr = DP_OK; - BOOL bStartWait = (dwFlags & DPLWAIT_CANCEL) ? FALSE : TRUE; + BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL); - TRACE( "(%p)->(0x%08lx)\n", iface, dwFlags ); + TRACE( "(%p)->(0x%08x)\n", iface, dwFlags ); if( DPLAYX_WaitForConnectionSettings( bStartWait ) ) { @@ -1838,7 +1830,7 @@ static const IDirectPlayLobby2Vtbl directPlayLobby2AVT = /* Note: Hack so we can reuse the old functions without compiler warnings */ #if !defined(__STRICT_ANSI__) && defined(__GNUC__) -# define XCAST(fun) (typeof(directPlayLobby2AVT.fun)) +# define XCAST(fun) (typeof(directPlayLobby2WVT.fun)) #else # define XCAST(fun) (void*) #endif @@ -1956,7 +1948,7 @@ HRESULT WINAPI DirectPlayLobbyCreateA( LPGUID lpGUIDDSP, LPVOID lpData, DWORD dwDataSize ) { - TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n", + TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n", lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize); /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must @@ -1988,7 +1980,7 @@ HRESULT WINAPI DirectPlayLobbyCreateW( LPGUID lpGUIDDSP, LPVOID lpData, DWORD dwDataSize ) { - TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n", + TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n", lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize); /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must diff --git a/reactos/dll/directx/dplayx/lobbysp.c b/reactos/dll/directx/dplayx/lobbysp.c index 18e4165e24b..4574d154e54 100644 --- a/reactos/dll/directx/dplayx/lobbysp.c +++ b/reactos/dll/directx/dplayx/lobbysp.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ //#include "winerror.h" @@ -76,7 +76,7 @@ HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp if( IsEqualGUID( &IID_IDPLobbySP, riid ) ) { - IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj; + IDPLobbySPImpl *This = *ppvObj; This->lpVtbl = &dpLobbySPVT; } else @@ -109,7 +109,7 @@ HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp static BOOL DPLSP_CreateIUnknown( LPVOID lpSP ) { - IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; + IDPLobbySPImpl *This = lpSP; This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) ); @@ -119,14 +119,16 @@ static BOOL DPLSP_CreateIUnknown( LPVOID lpSP ) } InitializeCriticalSection( &This->unk->DPLSP_lock ); + This->unk->DPLSP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDPLobbySPImpl*->DPLobbySPIUnknownData*->DPLSP_lock"); return TRUE; } static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP ) { - IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; + IDPLobbySPImpl *This = lpSP; + This->unk->DPLSP_lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &This->unk->DPLSP_lock ); HeapFree( GetProcessHeap(), 0, This->unk ); @@ -135,7 +137,7 @@ static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP ) static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp ) { - IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; + IDPLobbySPImpl *This = lpSP; This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) ); @@ -167,7 +169,7 @@ static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp ) static BOOL DPLSP_DestroyDPLobbySP( LPVOID lpSP ) { - IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; + IDPLobbySPImpl *This = lpSP; HeapFree( GetProcessHeap(), 0, This->sp ); @@ -197,7 +199,7 @@ HRESULT WINAPI DPLSP_QueryInterface if( IsEqualGUID( &IID_IDPLobbySP, riid ) ) { - IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj; + IDPLobbySPImpl *This = *ppvObj; This->lpVtbl = &dpLobbySPVT; } else @@ -224,7 +226,7 @@ ULONG WINAPI DPLSP_AddRef ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef ); - TRACE( "ref count incremented to %lu:%lu for %p\n", + TRACE( "ref count incremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); return ulObjRefCount; @@ -240,7 +242,7 @@ ULONG WINAPI DPLSP_Release ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef ); ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef ); - TRACE( "ref count decremented to %lu:%lu for %p\n", + TRACE( "ref count decremented to %u:%u for %p\n", ulInterfaceRefCount, ulObjRefCount, This ); /* Deallocate if this is the last reference to the object */ diff --git a/reactos/dll/directx/dplayx/lobbysp.h b/reactos/dll/directx/dplayx/lobbysp.h index 8897201c616..df446da010b 100644 --- a/reactos/dll/directx/dplayx/lobbysp.h +++ b/reactos/dll/directx/dplayx/lobbysp.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_LOBBY_SP_H @@ -70,14 +70,14 @@ typedef struct SPDATA_ADDREMOTEPLAYERTOGROUP LPDPNAME lpName; } SPDATA_ADDREMOTEPLAYERTOGROUP, *LPSPDATA_ADDREMOTEPLAYERTOGROUP; -typedef struct SPDATA_BUILDPARENTALHEIRARCHY +typedef struct SPDATA_BUILDPARENTALHIERARCHY { DWORD dwSize; LPDPLOBBYSP lpISP; DWORD dwGroupID; DWORD dwMessage; DWORD dwParentID; -} SPDATA_BUILDPARENTALHEIRARCHY, *LPSPDATA_BUILDPARENTALHEIRARCHY; +} SPDATA_BUILDPARENTALHIERARCHY, *LPSPDATA_BUILDPARENTALHIERARCHY; typedef struct SPDATA_CLOSE { @@ -388,7 +388,7 @@ typedef struct SPDATA_STARTSESSIONCOMMAND /* Prototypes for callbacks returned by DPLSPInit */ typedef HRESULT (WINAPI *LPSP_ADDGROUPTOGROUP)(LPSPDATA_ADDGROUPTOGROUP); typedef HRESULT (WINAPI *LPSP_ADDPLAYERTOGROUP)(LPSPDATA_ADDPLAYERTOGROUP); -typedef HRESULT (WINAPI *LPSP_BUILDPARENTALHEIRARCHY)(LPSPDATA_BUILDPARENTALHEIRARCHY); +typedef HRESULT (WINAPI *LPSP_BUILDPARENTALHIERARCHY)(LPSPDATA_BUILDPARENTALHIERARCHY); typedef HRESULT (WINAPI *LPSP_CLOSE)(LPSPDATA_CLOSE); typedef HRESULT (WINAPI *LPSP_CREATEGROUP)(LPSPDATA_CREATEGROUP); typedef HRESULT (WINAPI *LPSP_CREATEGROUPINGROUP)(LPSPDATA_CREATEGROUPINGROUP); @@ -422,7 +422,7 @@ typedef struct SP_CALLBACKS DWORD dwFlags; LPSP_ADDGROUPTOGROUP AddGroupToGroup; LPSP_ADDPLAYERTOGROUP AddPlayerToGroup; - LPSP_BUILDPARENTALHEIRARCHY BuildParentalHeirarchy; + LPSP_BUILDPARENTALHIERARCHY BuildParentalHierarchy; LPSP_CLOSE Close; LPSP_CREATEGROUP CreateGroup; LPSP_CREATEGROUPINGROUP CreateGroupInGroup; @@ -458,7 +458,7 @@ typedef struct SPDATA_INIT } SPDATA_INIT, *LPSPDATA_INIT; typedef HRESULT (WINAPI *LPSP_INIT)(LPSPDATA_INIT); -HRESULT WINAPI DPLSPInit(LPSPDATA_INIT); +HRESULT WINAPI DPLSPInit(LPSPDATA_INIT) DECLSPEC_HIDDEN; /* Define the COM interface */ #define INTERFACE IDPLobbySP @@ -515,6 +515,6 @@ DECLARE_INTERFACE_(IDPLobbySP,IUnknown) /* This variable is exported from the DLL at ordinal 6 to be accessed by the * SP directly. This is the same variable that the DP SP will use. */ -extern DWORD gdwDPlaySPRefCount; +extern DWORD gdwDPlaySPRefCount DECLSPEC_HIDDEN; #endif diff --git a/reactos/dll/directx/dplayx/name_server.c b/reactos/dll/directx/dplayx/name_server.c index ec47bd97968..fee13cd72a3 100644 --- a/reactos/dll/directx/dplayx/name_server.c +++ b/reactos/dll/directx/dplayx/name_server.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ /* NOTE: Methods with the NS_ prefix are name server methods */ @@ -67,50 +67,38 @@ struct NSCache typedef struct NSCache NSCache, *lpNSCache; /* Function prototypes */ -DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData ); +static DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData ); /* Name Server functions * --------------------- */ void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ) { -#if 0 - /* FIXME: Remove this method? */ - DPLAYX_SetLocalSession( lpsd ); -#endif lpNSCache lpCache = (lpNSCache)lpNSInfo; lpCache->bNsIsLocal = TRUE; } -void NS_SetRemoteComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ) -{ - lpNSCache lpCache = (lpNSCache)lpNSInfo; - - lpCache->bNsIsLocal = FALSE; -} - static DPQ_DECL_COMPARECB( cbUglyPig, GUID ) { return IsEqualGUID( elem1, elem2 ); } /* Store the given NS remote address for future reference */ -/* FIXME: LPDPMSG_ENUMSESSIONSREPLY should be const */ -void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr, - DWORD dwHdrSize, - LPDPMSG_ENUMSESSIONSREPLY lpMsg, - LPVOID lpNSInfo ) +void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr, + DWORD dwHdrSize, + LPCDPMSG_ENUMSESSIONSREPLY lpcMsg, + LPVOID lpNSInfo ) { DWORD len; lpNSCache lpCache = (lpNSCache)lpNSInfo; lpNSCacheData lpCacheNode; - TRACE( "%p, %p, %p\n", lpcNSAddrHdr, lpMsg, lpNSInfo ); + TRACE( "%p, %p, %p\n", lpcNSAddrHdr, lpcMsg, lpNSInfo ); /* See if we can find this session. If we can, remove it as it's a dup */ DPQ_REMOVE_ENTRY_CB( lpCache->first, next, data->guidInstance, cbUglyPig, - lpMsg->sd.guidInstance, lpCacheNode ); + lpcMsg->sd.guidInstance, lpCacheNode ); if( lpCacheNode != NULL ) { @@ -137,15 +125,16 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr, if( lpCacheNode->data == NULL ) { ERR( "no memory for SESSIONDESC2\n" ); + HeapFree( GetProcessHeap(), 0, lpCacheNode ); return; } - CopyMemory( lpCacheNode->data, &lpMsg->sd, sizeof( *lpCacheNode->data ) ); - len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, NULL, 0, NULL, NULL ); - if ((lpCacheNode->data->lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len ))) + *lpCacheNode->data = lpcMsg->sd; + len = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1, NULL, 0, NULL, NULL ); + if ((lpCacheNode->data->u1.lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len ))) { - WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, - lpCacheNode->data->lpszSessionNameA, len, NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1, + lpCacheNode->data->u1.lpszSessionNameA, len, NULL, NULL ); } lpCacheNode->dwTime = timeGetTime(); @@ -169,7 +158,7 @@ LPVOID NS_GetNSAddr( LPVOID lpNSInfo ) /* 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 + * 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. */ @@ -185,19 +174,11 @@ LPVOID NS_GetNSAddr( LPVOID lpNSInfo ) /* Get the magic number associated with the Name Server */ DWORD NS_GetNsMagic( LPVOID lpNSInfo ) { - LPDWORD lpHdrInfo = (LPDWORD)NS_GetNSAddr( lpNSInfo ); + LPDWORD lpHdrInfo = NS_GetNSAddr( lpNSInfo ); return lpHdrInfo[1]; } -/* Get the magic number associated with the non NS end */ -DWORD NS_GetOtherMagic( LPVOID lpNSInfo ) -{ - lpNSCache lpCache = (lpNSCache)lpNSInfo; - - return ((LPDWORD)lpCache->lpLocalAddrHdr)[1]; -} - void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ) { lpNSCache lpCache = (lpNSCache)lpNSInfo; @@ -212,7 +193,7 @@ void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ) */ HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid, DWORD dwFlags, - LPSPINITDATA lpSpData ) + const SPINITDATA *lpSpData ) { DPSP_ENUMSESSIONSDATA data; @@ -227,7 +208,7 @@ HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid, data.lpMessage = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, data.dwMessageSize ); data.lpISP = lpSpData->lpISP; - data.bReturnStatus = (dwFlags & DPENUMSESSIONS_RETURNSTATUS) ? TRUE : FALSE; + data.bReturnStatus = (dwFlags & DPENUMSESSIONS_RETURNSTATUS) != 0; lpMsg = (LPDPMSG_ENUMSESSIONSREQUEST)(((BYTE*)data.lpMessage)+lpSpData->dwSPHeaderSize); @@ -240,13 +221,13 @@ HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid, lpMsg->dwPasswordSize = 0; /* FIXME: If enumerating passwords..? */ lpMsg->dwFlags = dwFlags; - CopyMemory( &lpMsg->guidApplication, lpcGuid, sizeof( *lpcGuid ) ); + lpMsg->guidApplication = *lpcGuid; return (lpSpData->lpCB->EnumSessions)( &data ); } /* Delete a name server node which has been allocated on the heap */ -DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData ) +static DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData ) { /* NOTE: This proc doesn't deal with the walking pointer */ @@ -381,21 +362,13 @@ void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg, DWORD dwVariableSize; DWORD dwVariableLen; /* LPCDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpcMsg; */ - BOOL bAnsi = TRUE; /* FIXME: This needs to be in the DPLAY interface */ - FIXME( ": few fixed + need to check request for response\n" ); - - if (bAnsi) - { - dwVariableLen = MultiByteToWideChar( CP_ACP, 0, - lpDP->dp2->lpSessionDesc->lpszSessionNameA, - -1, NULL, 0 ); - } - else - { - dwVariableLen = strlenW( lpDP->dp2->lpSessionDesc->lpszSessionName ) + 1; - } + /* FIXME: Should handle ANSI or WIDECHAR input. Currently just ANSI input */ + FIXME( ": few fixed + need to check request for response, might need UNICODE input ability.\n" ); + dwVariableLen = MultiByteToWideChar( CP_ACP, 0, + lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA, + -1, NULL, 0 ); dwVariableSize = dwVariableLen * sizeof( WCHAR ); *lpdwReplySize = lpDP->dp2->spData.dwSPHeaderSize + @@ -411,15 +384,8 @@ void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg, rmsg->envelope.wVersion = DPMSGVER_DP6; CopyMemory( &rmsg->sd, lpDP->dp2->lpSessionDesc, - sizeof( lpDP->dp2->lpSessionDesc->dwSize ) ); + lpDP->dp2->lpSessionDesc->dwSize ); rmsg->dwUnknown = 0x0000005c; - if( bAnsi ) - { - MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->lpszSessionNameA, -1, - (LPWSTR)(rmsg+1), dwVariableLen ); - } - else - { - strcpyW( (LPWSTR)(rmsg+1), lpDP->dp2->lpSessionDesc->lpszSessionName ); - } + MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA, -1, + (LPWSTR)(rmsg+1), dwVariableLen ); } diff --git a/reactos/dll/directx/dplayx/name_server.h b/reactos/dll/directx/dplayx/name_server.h index 15fdde5f5cf..ab39e3c724b 100644 --- a/reactos/dll/directx/dplayx/name_server.h +++ b/reactos/dll/directx/dplayx/name_server.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DPLAYX_NAMESERVER @@ -28,34 +28,32 @@ #include "dplayx_messages.h" //#include "dplay_global.h" -void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ); -void NS_SetRemoteComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ); +void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ) DECLSPEC_HIDDEN; void NS_AddRemoteComputerAsNameServer( LPCVOID lpNSAddrHdr, DWORD dwHdrSize, - LPDPMSG_ENUMSESSIONSREPLY lpMsg, - LPVOID lpNSInfo ); -LPVOID NS_GetNSAddr( LPVOID lpNSInfo ); -DWORD NS_GetNsMagic( LPVOID lpNSInfo ); -DWORD NS_GetOtherMagic( LPVOID lpNSInfo ); -void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ); + LPCDPMSG_ENUMSESSIONSREPLY lpcMsg, + LPVOID lpNSInfo ) DECLSPEC_HIDDEN; +LPVOID NS_GetNSAddr( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; +DWORD NS_GetNsMagic( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; +void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize ) DECLSPEC_HIDDEN; void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg, LPVOID* lplpReplyData, LPDWORD lpdwReplySize, - IDirectPlay2Impl* lpDP ); + IDirectPlay2Impl* lpDP ) DECLSPEC_HIDDEN; HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid, DWORD dwFlags, - LPSPINITDATA lpSpData ); + const SPINITDATA *lpSpData ) DECLSPEC_HIDDEN; -BOOL NS_InitializeSessionCache( LPVOID* lplpNSInfo ); -void NS_DeleteSessionCache( LPVOID lpNSInfo ); -void NS_InvalidateSessionCache( LPVOID lpNSInfo ); +BOOL NS_InitializeSessionCache( LPVOID* lplpNSInfo ) DECLSPEC_HIDDEN; +void NS_DeleteSessionCache( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; +void NS_InvalidateSessionCache( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; -void NS_ResetSessionEnumeration( LPVOID lpNSInfo ); -LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo ); -void NS_PruneSessionCache( LPVOID lpNSInfo ); +void NS_ResetSessionEnumeration( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; +LPDPSESSIONDESC2 NS_WalkSessions( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; +void NS_PruneSessionCache( LPVOID lpNSInfo ) DECLSPEC_HIDDEN; #endif /* __WINE_DPLAYX_NAMESERVER */ diff --git a/reactos/dll/directx/dplayx/regsvr.c b/reactos/dll/directx/dplayx/regsvr.c deleted file mode 100644 index c8579b180ec..00000000000 --- a/reactos/dll/directx/dplayx/regsvr.c +++ /dev/null @@ -1,560 +0,0 @@ -/* - * self-registerable dll functions for dplayx.dll - * - * Copyright (C) 2003 John K. Hohm - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#include -//#include - -#include -#include -//#include "winuser.h" -#include -//#include "winerror.h" - -//#include "dplay.h" -#include - -#include - -WINE_DEFAULT_DEBUG_CHANNEL(dplayx); - -/* - * Near the bottom of this file are the exported DllRegisterServer and - * DllUnregisterServer, which make all this worthwhile. - */ - -/*********************************************************************** - * interface for self-registering - */ -struct regsvr_interface -{ - IID const *iid; /* NULL for end of list */ - LPCSTR name; /* can be NULL to omit */ - IID const *base_iid; /* can be NULL to omit */ - int num_methods; /* can be <0 to omit */ - CLSID const *ps_clsid; /* can be NULL to omit */ - CLSID const *ps_clsid32; /* can be NULL to omit */ -}; - -static HRESULT register_interfaces(struct regsvr_interface const *list); -static HRESULT unregister_interfaces(struct regsvr_interface const *list); - -struct regsvr_coclass -{ - CLSID const *clsid; /* NULL for end of list */ - LPCSTR name; /* can be NULL to omit */ - LPCSTR ips; /* can be NULL to omit */ - LPCSTR ips32; /* can be NULL to omit */ - LPCSTR ips32_tmodel; /* can be NULL to omit */ - LPCSTR progid; /* can be NULL to omit */ - LPCSTR viprogid; /* can be NULL to omit */ - LPCSTR progid_extra; /* can be NULL to omit */ -}; - -static HRESULT register_coclasses(struct regsvr_coclass const *list); -static HRESULT unregister_coclasses(struct regsvr_coclass const *list); - -/*********************************************************************** - * static string constants - */ -static WCHAR const interface_keyname[10] = { - 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 }; -static WCHAR const base_ifa_keyname[14] = { - 'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', - 'e', 0 }; -static WCHAR const num_methods_keyname[11] = { - 'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 }; -static WCHAR const ps_clsid_keyname[15] = { - 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's', - 'i', 'd', 0 }; -static WCHAR const ps_clsid32_keyname[17] = { - 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's', - 'i', 'd', '3', '2', 0 }; -static WCHAR const clsid_keyname[6] = { - 'C', 'L', 'S', 'I', 'D', 0 }; -static WCHAR const curver_keyname[7] = { - 'C', 'u', 'r', 'V', 'e', 'r', 0 }; -static WCHAR const ips_keyname[13] = { - 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r', - 0 }; -static WCHAR const ips32_keyname[15] = { - 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r', - '3', '2', 0 }; -static WCHAR const progid_keyname[7] = { - 'P', 'r', 'o', 'g', 'I', 'D', 0 }; -static WCHAR const viprogid_keyname[25] = { - 'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p', - 'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D', - 0 }; -static char const tmodel_valuename[] = "ThreadingModel"; - -/*********************************************************************** - * static helper functions - */ -static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid); -static LONG register_key_defvalueW(HKEY base, WCHAR const *name, - WCHAR const *value); -static LONG register_key_defvalueA(HKEY base, WCHAR const *name, - char const *value); -static LONG register_progid(WCHAR const *clsid, - char const *progid, char const *curver_progid, - char const *name, char const *extra); -static LONG recursive_delete_key(HKEY key); -static LONG recursive_delete_keyA(HKEY base, char const *name); -static LONG recursive_delete_keyW(HKEY base, WCHAR const *name); - -/*********************************************************************** - * register_interfaces - */ -static HRESULT register_interfaces(struct regsvr_interface const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY interface_key; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &interface_key, NULL); - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->iid; ++list) { - WCHAR buf[39]; - HKEY iid_key; - - StringFromGUID2(list->iid, buf, 39); - res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &iid_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_interface_key; - - if (list->name) { - res = RegSetValueExA(iid_key, NULL, 0, REG_SZ, - (CONST BYTE*)(list->name), - strlen(list->name) + 1); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (list->base_iid) { - register_key_guid(iid_key, base_ifa_keyname, list->base_iid); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (0 <= list->num_methods) { - static WCHAR const fmt[3] = { '%', 'd', 0 }; - HKEY key; - - res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - - wsprintfW(buf, fmt, list->num_methods); - res = RegSetValueExW(key, NULL, 0, REG_SZ, - (CONST BYTE*)buf, - (lstrlenW(buf) + 1) * sizeof(WCHAR)); - RegCloseKey(key); - - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (list->ps_clsid) { - register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (list->ps_clsid32) { - register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - error_close_iid_key: - RegCloseKey(iid_key); - } - -error_close_interface_key: - RegCloseKey(interface_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_interfaces - */ -static HRESULT unregister_interfaces(struct regsvr_interface const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY interface_key; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, - KEY_READ | KEY_WRITE, &interface_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->iid; ++list) { - WCHAR buf[39]; - - StringFromGUID2(list->iid, buf, 39); - res = recursive_delete_keyW(interface_key, buf); - } - - RegCloseKey(interface_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * register_coclasses - */ -static HRESULT register_coclasses(struct regsvr_coclass const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY coclass_key; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL); - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->clsid; ++list) { - WCHAR buf[39]; - HKEY clsid_key; - - StringFromGUID2(list->clsid, buf, 39); - res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - - if (list->name) { - res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ, - (CONST BYTE*)(list->name), - strlen(list->name) + 1); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->ips) { - res = register_key_defvalueA(clsid_key, ips_keyname, list->ips); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->ips32) { - HKEY ips32_key; - - res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, - &ips32_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ, - (CONST BYTE*)list->ips32, - lstrlenA(list->ips32) + 1); - if (res == ERROR_SUCCESS && list->ips32_tmodel) - res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ, - (CONST BYTE*)list->ips32_tmodel, - strlen(list->ips32_tmodel) + 1); - RegCloseKey(ips32_key); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->progid) { - res = register_key_defvalueA(clsid_key, progid_keyname, - list->progid); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = register_progid(buf, list->progid, NULL, - list->name, list->progid_extra); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->viprogid) { - res = register_key_defvalueA(clsid_key, viprogid_keyname, - list->viprogid); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = register_progid(buf, list->viprogid, list->progid, - list->name, list->progid_extra); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - error_close_clsid_key: - RegCloseKey(clsid_key); - } - -error_close_coclass_key: - RegCloseKey(coclass_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_coclasses - */ -static HRESULT unregister_coclasses(struct regsvr_coclass const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY coclass_key; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, - KEY_READ | KEY_WRITE, &coclass_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->clsid; ++list) { - WCHAR buf[39]; - - StringFromGUID2(list->clsid, buf, 39); - res = recursive_delete_keyW(coclass_key, buf); - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - - if (list->progid) { - res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid); - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - } - - if (list->viprogid) { - res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid); - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - } - } - -error_close_coclass_key: - RegCloseKey(coclass_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * regsvr_key_guid - */ -static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid) -{ - WCHAR buf[39]; - - StringFromGUID2(guid, buf, 39); - return register_key_defvalueW(base, name, buf); -} - -/*********************************************************************** - * regsvr_key_defvalueW - */ -static LONG register_key_defvalueW( - HKEY base, - WCHAR const *name, - WCHAR const *value) -{ - LONG res; - HKEY key; - - res = RegCreateKeyExW(base, name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) return res; - res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value, - (lstrlenW(value) + 1) * sizeof(WCHAR)); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * regsvr_key_defvalueA - */ -static LONG register_key_defvalueA( - HKEY base, - WCHAR const *name, - char const *value) -{ - LONG res; - HKEY key; - - res = RegCreateKeyExW(base, name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) return res; - res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value, - lstrlenA(value) + 1); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * regsvr_progid - */ -static LONG register_progid( - WCHAR const *clsid, - char const *progid, - char const *curver_progid, - char const *name, - char const *extra) -{ - LONG res; - HKEY progid_key; - - res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0, - NULL, 0, KEY_READ | KEY_WRITE, NULL, - &progid_key, NULL); - if (res != ERROR_SUCCESS) return res; - - if (name) { - res = RegSetValueExA(progid_key, NULL, 0, REG_SZ, - (CONST BYTE*)name, strlen(name) + 1); - if (res != ERROR_SUCCESS) goto error_close_progid_key; - } - - if (clsid) { - res = register_key_defvalueW(progid_key, clsid_keyname, clsid); - if (res != ERROR_SUCCESS) goto error_close_progid_key; - } - - if (curver_progid) { - res = register_key_defvalueA(progid_key, curver_keyname, - curver_progid); - if (res != ERROR_SUCCESS) goto error_close_progid_key; - } - - if (extra) { - HKEY extra_key; - - res = RegCreateKeyExA(progid_key, extra, 0, - NULL, 0, KEY_READ | KEY_WRITE, NULL, - &extra_key, NULL); - if (res == ERROR_SUCCESS) - RegCloseKey(extra_key); - } - -error_close_progid_key: - RegCloseKey(progid_key); - return res; -} - -/*********************************************************************** - * recursive_delete_key - */ -static LONG recursive_delete_key(HKEY key) -{ - LONG res; - WCHAR subkey_name[MAX_PATH]; - DWORD cName; - HKEY subkey; - - for (;;) { - cName = sizeof(subkey_name) / sizeof(WCHAR); - res = RegEnumKeyExW(key, 0, subkey_name, &cName, - NULL, NULL, NULL, NULL); - if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) { - res = ERROR_SUCCESS; /* presumably we're done enumerating */ - break; - } - res = RegOpenKeyExW(key, subkey_name, 0, - KEY_READ | KEY_WRITE, &subkey); - if (res == ERROR_FILE_NOT_FOUND) continue; - if (res != ERROR_SUCCESS) break; - - res = recursive_delete_key(subkey); - RegCloseKey(subkey); - if (res != ERROR_SUCCESS) break; - } - - if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0); - return res; -} - -/*********************************************************************** - * recursive_delete_keyA - */ -static LONG recursive_delete_keyA(HKEY base, char const *name) -{ - LONG res; - HKEY key; - - res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key); - if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS; - if (res != ERROR_SUCCESS) return res; - res = recursive_delete_key(key); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * recursive_delete_keyW - */ -static LONG recursive_delete_keyW(HKEY base, WCHAR const *name) -{ - LONG res; - HKEY key; - - res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key); - if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS; - if (res != ERROR_SUCCESS) return res; - res = recursive_delete_key(key); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * coclass list - */ -static struct regsvr_coclass const coclass_list[] = { - { &CLSID_DirectPlay, - "DirectPlay Object", - NULL, - "dplayx.dll", - "Both" - }, - { &CLSID_DirectPlayLobby, - "DirectPlayLobby Object", - NULL, - "dplayx.dll", - "Both" - }, - { NULL } /* list terminator */ -}; - -/*********************************************************************** - * interface list - */ - -static struct regsvr_interface const interface_list[] = { - { NULL } /* list terminator */ -}; - -/*********************************************************************** - * DllRegisterServer (DPLAYX.@) - */ -HRESULT WINAPI DllRegisterServer(void) -{ - HRESULT hr; - - TRACE("\n"); - - hr = register_coclasses(coclass_list); - if (SUCCEEDED(hr)) - hr = register_interfaces(interface_list); - return hr; -} - -/*********************************************************************** - * DllUnregisterServer (DPLAYX.@) - */ -HRESULT WINAPI DllUnregisterServer(void) -{ - HRESULT hr; - - TRACE("\n"); - - hr = unregister_coclasses(coclass_list); - if (SUCCEEDED(hr)) - hr = unregister_interfaces(interface_list); - return hr; -} diff --git a/reactos/dll/directx/dplayx/version.rc b/reactos/dll/directx/dplayx/version.rc index 4b0f15a06dc..9a0e12f522c 100644 --- a/reactos/dll/directx/dplayx/version.rc +++ b/reactos/dll/directx/dplayx/version.rc @@ -13,15 +13,17 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WINE_OLESELFREGISTER +1 WINE_REGISTRY dplayx.rgs + #define WINE_FILEDESCRIPTION_STR "Wine DirectPlay" #define WINE_FILENAME_STR "dplayx.dll" -#define WINE_FILEVERSION 5,3,0,900 -#define WINE_FILEVERSION_STR "5.3.0.900" -#define WINE_PRODUCTVERSION 5,3,0,900 -#define WINE_PRODUCTVERSION_STR "5.3" +#define WINE_FILEVERSION 5,3,1,904 +#define WINE_FILEVERSION_STR "5.3.1.904" +#define WINE_PRODUCTVERSION 5,3,1,904 +#define WINE_PRODUCTVERSION_STR "5.3.1.904" +#define WINE_EXTRAVALUES VALUE "OLESelfRegister","" -#include "wine/wine_common_ver.rc" +#include diff --git a/reactos/include/psdk/dplay.h b/reactos/include/psdk/dplay.h index 929a1f0401d..2294ba851fa 100644 --- a/reactos/include/psdk/dplay.h +++ b/reactos/include/psdk/dplay.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DPLAY_H @@ -192,18 +192,16 @@ typedef struct tagDPNAME { LPWSTR lpszShortName; LPSTR lpszShortNameA; - }; + } DUMMYUNIONNAME1; union /*playerLongName */ /* Player's formal/real name */ { LPWSTR lpszLongName; LPSTR lpszLongNameA; - }; + } DUMMYUNIONNAME2; } DPNAME, *LPDPNAME; - - #define DPLONGNAMELEN 52 #define DPSHORTNAMELEN 20 #define DPSESSIONNAMELEN 32 @@ -244,13 +242,13 @@ typedef struct tagDPSESSIONDESC2 { LPWSTR lpszSessionName; LPSTR lpszSessionNameA; - }; + } DUMMYUNIONNAME1; union /* Optional password */ { LPWSTR lpszPassword; LPSTR lpszPasswordA; - }; + } DUMMYUNIONNAME2; DWORD dwReserved1; DWORD dwReserved2; @@ -260,8 +258,6 @@ typedef struct tagDPSESSIONDESC2 DWORD dwUser3; DWORD dwUser4; } DPSESSIONDESC2, *LPDPSESSIONDESC2; - - typedef const DPSESSIONDESC2* LPCDPSESSIONDESC2; #define DPOPEN_JOIN 0x00000001 @@ -279,6 +275,9 @@ typedef const DPSESSIONDESC2* LPCDPSESSIONDESC2; #define DPSESSION_PASSWORDREQUIRED 0x00000400 #define DPSESSION_MULTICASTSERVER 0x00000800 #define DPSESSION_CLIENTSERVER 0x00001000 +#define DPSESSION_DIRECTPLAYPROTOCOL 0x00002000 +#define DPSESSION_NOPRESERVEORDER 0x00004000 +#define DPSESSION_OPTIMIZELATENCY 0x00008000 typedef struct tagDPLCONNECTION { @@ -396,7 +395,7 @@ typedef BOOL (CALLBACK *LPDPENUMSESSIONSCALLBACK)( extern HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA, LPVOID ); extern HRESULT WINAPI DirectPlayEnumerateW( LPDPENUMDPCALLBACKW, LPVOID ); -extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY2 *lplpDP, IUnknown *pUnk); +extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY *lplpDP, IUnknown *pUnk ); typedef BOOL (CALLBACK *LPDPENUMPLAYERSCALLBACK)( DPID dpId, @@ -1065,6 +1064,20 @@ DECLARE_INTERFACE_(IDirectPlay4,IDirectPlay3) /* DirectPlay::Connect */ #define DPCONNECT_RETURNSTATUS (DPENUMSESSIONS_RETURNSTATUS) +/* DirectPlay::GetCaps and DirectPlay::GetPlayerCaps */ +#define DPCAPS_ISHOST 0x00000002 +#define DPCAPS_GROUPOPTIMIZED 0x00000008 +#define DPCAPS_KEEPALIVEOPTIMIZED 0x00000010 +#define DPCAPS_GUARANTEEDOPTIMIZED 0x00000020 +#define DPCAPS_GUARANTEEDSUPPORTED 0x00000040 +#define DPCAPS_SIGNINGSUPPORTED 0x00000080 +#define DPCAPS_ENCRYPTIONSUPPORTED 0x00000100 +#define DPPLAYERCAPS_LOCAL 0x00000800 +#define DPCAPS_ASYNCCANCELSUPPORTED 0x00001000 +#define DPCAPS_ASYNCCANCELALLSUPPORTED 0x00002000 +#define DPCAPS_SENDTIMEOUTSUPPORTED 0x00004000 +#define DPCAPS_SENDPRIORITYSUPPORTED 0x00008000 +#define DPCAPS_ASYNCSUPPORTED 0x00010000 /** DirectPlay system messages **/ diff --git a/reactos/dll/directx/dplayx/dplaysp.h b/reactos/include/reactos/wine/dplaysp.h similarity index 97% rename from reactos/dll/directx/dplayx/dplaysp.h rename to reactos/include/reactos/wine/dplaysp.h index d83cd291934..95361d1bf65 100644 --- a/reactos/dll/directx/dplayx/dplaysp.h +++ b/reactos/include/reactos/wine/dplaysp.h @@ -13,23 +13,19 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef __WINE_DIRECT_PLAY_SP_H #define __WINE_DIRECT_PLAY_SP_H -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H +#include -//#include - -//#include "windef.h" -#include -//#include "winuser.h" -//#include "dplay.h" -#include +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "dplay.h" +#include "dplobby.h" /* GUID for IDirectPlaySP {0C9F6360-CC61-11cf-ACEC-00AA006886E3} */ DEFINE_GUID(IID_IDirectPlaySP, 0xc9f6360, 0xcc61, 0x11cf, 0xac, 0xec, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3); diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 62d51775a7d..bd09611dbb2 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -31,8 +31,8 @@ reactos/dll/directx/amstream # Synced to Wine-1.3.37 reactos/dll/directx/dinput # Synced to Wine-20090208 reactos/dll/directx/dinput8 # Synced to Wine-20090208 reactos/dll/directx/dmusic # Synced to Wine-1_1_23 -reactos/dll/directx/dplay # Synced to Wine-0_9_5 -reactos/dll/directx/dplayx # Synced to Wine-0_9_5 +reactos/dll/directx/dplay # Synced to Wine-1.5.26 +reactos/dll/directx/dplayx # Synced to Wine-1.5.26 reactos/dll/directx/dxdiagn # Synced to Wine-0_9_5 reactos/dll/directx/msdmo # Autosync reactos/dll/directx/qedit # Autosync