* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define COBJMACROS
-#include <config.h>
-//#include "wine/port.h"
-
-//#include <stdarg.h>
-//#include <string.h>
-
-#define NONAMELESSUNION
-#define NONAMELESSSTRUCT
-#include <windef.h>
-//#include "winerror.h"
-//#include "winbase.h"
-//#include "winnt.h"
-#include <winreg.h>
-//#include "winnls.h"
-#include <wine/unicode.h>
-#include <wine/debug.h>
-
#include "dplayx_global.h"
-#include "name_server.h"
-//#include "dplayx_queue.h"
-//#include "dplaysp.h"
-//#include "dplay_global.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dplay);
/* FIXME: Should this be externed? */
extern HRESULT DPL_CreateCompoundAddress
This->dp2->spData.lpCB->dwVersion = DPSP_MAJORVERSION;
/* This is the pointer to the service provider */
- if( FAILED( DPSP_CreateInterface( &IID_IDirectPlaySP,
- (LPVOID*)&This->dp2->spData.lpISP, This ) )
- )
+ if ( FAILED( dplaysp_create( &IID_IDirectPlaySP, (void**)&This->dp2->spData.lpISP, This ) ) )
{
/* FIXME: Memory leak */
return FALSE;
sizeof( *This->dp2->dplspData.lpCB ) );
This->dp2->dplspData.lpCB->dwSize = sizeof( *This->dp2->dplspData.lpCB );
- if( FAILED( DPLSP_CreateInterface( &IID_IDPLobbySP,
- (LPVOID*)&This->dp2->dplspData.lpISP, This ) )
+ if( FAILED( dplobbysp_create( &IID_IDPLobbySP, (void**)&This->dp2->dplspData.lpISP, This ) )
)
{
/* FIXME: Memory leak */
NS_DeleteSessionCache( This->dp2->lpNameServerData );
+ HeapFree( GetProcessHeap(), 0, This->dp2->dplspData.lpCB);
HeapFree( GetProcessHeap(), 0, This->dp2->lpSessionDesc );
IDirectPlaySP_Release( This->dp2->spData.lpISP );
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%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 */
-#endif
break;
case DPMSGCMD_FORWARDADDPLAYERNACK:
player total */
lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwCreateFlags,
hEvent, bAnsi );
-
- if( lpPData == NULL )
- {
- return DPERR_CANTADDPLAYER;
- }
-
/* Create the list object and link it in */
lpPList = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpPList ) );
- if( lpPList == NULL )
+ if( !lpPData || !lpPList )
{
- FIXME( "Memory leak\n" );
+ HeapFree( GetProcessHeap(), 0, lpPData );
+ HeapFree( GetProcessHeap(), 0, lpPList );
return DPERR_CANTADDPLAYER;
}
}
#if 1
- if( This->dp2->bHostInterface == FALSE )
+ if( !This->dp2->bHostInterface )
{
/* Let the name server know about the creation of this player */
/* FIXME: Is this only to be done for the creation of a server player or
TRACE( "(%p)->(0x%08x,%p,0x%08x)\n", This, player, caps, flags);
+ if ( !caps )
+ return DPERR_INVALIDPARAMS;
+
if ( This->dp2->connectionInitialized == NO_PROVIDER )
return DPERR_UNINITIALIZED;
+ if( caps->dwSize != sizeof(DPCAPS) )
+ return DPERR_INVALIDPARAMS;
+
/* Query the service provider */
data.idPlayer = player;
data.dwFlags = flags;
if( !lpEnumCallback( &serviceProviderGUID, lpAddressBuffer, dwAddressBufferSize,
&dpName, dwFlags, lpContext ) )
{
+ HeapFree( GetProcessHeap(), 0, lpAddressBuffer );
return DP_OK;
}
+ HeapFree( GetProcessHeap(), 0, lpAddressBuffer );
}
}
if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
{
- /* Hmmm. Does this mean that there are no service providers? */
- ERR(": no service providers?\n");
+ TRACE("No Lobby Providers have been registered.\n");
return DP_OK;
}
const GUID *application, LPDPENUMCONNECTIONSCALLBACK enumcb, void *context, DWORD flags )
{
IDirectPlayImpl *This = impl_from_IDirectPlay4( iface );
- FIXME( "(%p)->(%p,%p,%p,0x%08x): stub\n", This, application, enumcb, context, flags );
- return DP_OK;
+ return IDirectPlayX_EnumConnections( &This->IDirectPlay4A_iface, application, enumcb, context,
+ flags );
}
static HRESULT WINAPI IDirectPlay3AImpl_EnumGroupsInGroup( IDirectPlay3A *iface, DPID group,
FILETIME filetime;
(i == 0) ? (searchSubKey = spSubKey ) : (searchSubKey = lpSubKey );
- *lpbIsDpSp = (i == 0) ? TRUE : FALSE;
+ *lpbIsDpSp = (i == 0);
/* Need to loop over the service providers in the registry */
DWORD max_sizeOfDescriptionA = 0;
WCHAR *descriptionW = NULL;
DWORD max_sizeOfDescriptionW = 0;
+ DWORD sizeOfSubKeyName;
+ WCHAR subKeyName[255]; /* 255 is the maximum key size according to MSDN */
+ LONG ret_value;
+ static GUID *guid_cache;
+ static int cache_count;
if (!lpEnumCallbackA && !lpEnumCallbackW)
{
ERR(": no service provider key in the registry - check your Wine installation !!!\n");
return DPERR_GENERIC;
}
-
+
+ dwIndex = 0;
+ do
+ {
+ sizeOfSubKeyName = sizeof(subKeyName) / sizeof(WCHAR);
+ ret_value = RegEnumKeyW(hkResult, dwIndex, subKeyName, sizeOfSubKeyName);
+ dwIndex++;
+ }
+ while (ret_value == ERROR_SUCCESS);
+ /* The game Swing from bug 37185 expects GUID values to persist after
+ * the end of the enumeration. */
+ if (cache_count < dwIndex)
+ {
+ HeapFree(GetProcessHeap(), 0, guid_cache);
+ guid_cache = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID) * dwIndex);
+ if (!guid_cache)
+ {
+ ERR(": failed to allocate required memory.\n");
+ return DPERR_EXCEPTION;
+ }
+ cache_count = dwIndex;
+ }
/* Traverse all the service providers we have available */
dwIndex = 0;
while (1)
{
- WCHAR subKeyName[255]; /* 255 is the maximum key size according to MSDN */
- DWORD sizeOfSubKeyName = sizeof(subKeyName) / sizeof(WCHAR);
HKEY hkServiceProvider;
- GUID serviceProviderGUID;
WCHAR guidKeyContent[(2 * 16) + 1 + 6 /* This corresponds to '{....-..-..-..-......}' */ ];
DWORD sizeOfGuidKeyContent = sizeof(guidKeyContent);
- LONG ret_value;
+ sizeOfSubKeyName = sizeof(subKeyName) / sizeof(WCHAR);
ret_value = RegEnumKeyExW(hkResult, dwIndex, subKeyName, &sizeOfSubKeyName,
NULL, NULL, NULL, &filetime);
if (ret_value == ERROR_NO_MORE_ITEMS)
ERR(": invalid format for the GUID registry data member for service provider %s (%s).\n", debugstr_w(subKeyName), debugstr_w(guidKeyContent));
continue;
}
- CLSIDFromString(guidKeyContent, &serviceProviderGUID );
+ CLSIDFromString(guidKeyContent, &guid_cache[dwIndex]);
/* The enumeration will return FALSE if we are not to continue.
*
RegQueryValueExA(hkServiceProvider, "DescriptionA",
NULL, NULL, (LPBYTE) descriptionA, &sizeOfDescription);
- if (!lpEnumCallbackA(&serviceProviderGUID, descriptionA, 6, 0, lpContext))
+ if (!lpEnumCallbackA(&guid_cache[dwIndex], descriptionA, 6, 0, lpContext))
goto end;
}
else
RegQueryValueExW(hkServiceProvider, descW,
NULL, NULL, (LPBYTE) descriptionW, &sizeOfDescription);
- if (!lpEnumCallbackW(&serviceProviderGUID, descriptionW, 6, 0, lpContext))
+ if (!lpEnumCallbackW(&guid_cache[dwIndex], descriptionW, 6, 0, lpContext))
goto end;
}