1 /* Direct Play Lobby 2 & 3 Implementation
3 * Copyright 1998,1999,2000 - Peter Hunnisett
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
23 #define NONAMELESSSTRUCT
29 #include "wine/debug.h"
31 #include "dplayx_global.h"
32 #include "dplayx_messages.h"
33 #include "dplayx_queue.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
39 /*****************************************************************************
40 * Predeclare the interface implementation structures
42 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyAImpl;
43 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyWImpl;
44 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2AImpl;
45 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2WImpl;
46 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3AImpl;
47 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3WImpl;
49 /* Forward declarations for this module helper methods */
50 HRESULT DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements, DWORD dwElementCount,
51 LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface )DECLSPEC_HIDDEN;
53 static HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize,
54 LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface );
58 extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
59 DWORD dwAddressSize, LPVOID lpContext );
61 static HRESULT DPL_ConnectEx( IDirectPlayLobbyAImpl* This,
62 DWORD dwFlags, REFIID riid,
63 LPVOID* lplpDP, IUnknown* pUnk );
65 static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
66 LPHANDLE lphStart, LPHANDLE lphDeath,
70 /*****************************************************************************
71 * IDirectPlayLobby {1,2,3} implementation structure
73 * The philosophy behind this extra pointer dereference is that I wanted to
74 * have the same structure for all types of objects without having to do
75 * a lot of casting. I also only wanted to implement an interface in the
76 * object it was "released" with IUnknown interface being implemented in the 1 version.
77 * Of course, with these new interfaces comes the data required to keep the state required
78 * by these interfaces. So, basically, the pointers contain the data associated with
79 * a release. If you use the data associated with release 3 in a release 2 object, you'll
80 * get a run time trap, as that won't have any data.
85 DPQ_ENTRY( DPLMSG ) msgs; /* Link to next queued message */
87 typedef struct DPLMSG* LPDPLMSG;
89 typedef struct tagDirectPlayLobbyIUnknownData
92 CRITICAL_SECTION DPL_lock;
93 } DirectPlayLobbyIUnknownData;
95 typedef struct tagDirectPlayLobbyData
97 HKEY hkCallbackKeyHack;
99 DPQ_HEAD( DPLMSG ) msgs; /* List of messages received */
100 } DirectPlayLobbyData;
102 typedef struct tagDirectPlayLobby2Data
105 } DirectPlayLobby2Data;
107 typedef struct tagDirectPlayLobby3Data
110 } DirectPlayLobby3Data;
112 #define DPL_IMPL_FIELDS \
113 LONG ulInterfaceRef; \
114 DirectPlayLobbyIUnknownData* unk; \
115 DirectPlayLobbyData* dpl; \
116 DirectPlayLobby2Data* dpl2; \
117 DirectPlayLobby3Data* dpl3;
119 struct IDirectPlayLobbyImpl
121 const IDirectPlayLobbyVtbl *lpVtbl;
125 struct IDirectPlayLobby2Impl
127 const IDirectPlayLobby2Vtbl *lpVtbl;
131 struct IDirectPlayLobby3Impl
133 const IDirectPlayLobby3Vtbl *lpVtbl;
137 /* Forward declarations of virtual tables */
138 static const IDirectPlayLobbyVtbl directPlayLobbyWVT;
139 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT;
140 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT;
142 static const IDirectPlayLobbyVtbl directPlayLobbyAVT;
143 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT;
144 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT;
146 static BOOL DPL_CreateIUnknown( LPVOID lpDPL )
148 IDirectPlayLobbyAImpl *This = lpDPL;
150 This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
151 if ( This->unk == NULL )
156 InitializeCriticalSection( &This->unk->DPL_lock );
157 This->unk->DPL_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayLobbyAImpl*->DirectPlayLobbyIUnknownData*->DPL_lock");
162 static BOOL DPL_DestroyIUnknown( LPVOID lpDPL )
164 IDirectPlayLobbyAImpl *This = lpDPL;
166 This->unk->DPL_lock.DebugInfo->Spare[0] = 0;
167 DeleteCriticalSection( &This->unk->DPL_lock );
168 HeapFree( GetProcessHeap(), 0, This->unk );
173 static BOOL DPL_CreateLobby1( LPVOID lpDPL )
175 IDirectPlayLobbyAImpl *This = lpDPL;
177 This->dpl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl) ) );
178 if ( This->dpl == NULL )
183 DPQ_INIT( This->dpl->msgs );
188 static BOOL DPL_DestroyLobby1( LPVOID lpDPL )
190 IDirectPlayLobbyAImpl *This = lpDPL;
192 if( This->dpl->dwMsgThread )
194 FIXME( "Should kill the msg thread\n" );
197 DPQ_DELETEQ( This->dpl->msgs, msgs, LPDPLMSG, cbDeleteElemFromHeap );
199 /* Delete the contents */
200 HeapFree( GetProcessHeap(), 0, This->dpl );
205 static BOOL DPL_CreateLobby2( LPVOID lpDPL )
207 IDirectPlayLobby2AImpl *This = lpDPL;
209 This->dpl2 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl2) ) );
210 if ( This->dpl2 == NULL )
218 static BOOL DPL_DestroyLobby2( LPVOID lpDPL )
220 IDirectPlayLobby2AImpl *This = lpDPL;
222 HeapFree( GetProcessHeap(), 0, This->dpl2 );
227 static BOOL DPL_CreateLobby3( LPVOID lpDPL )
229 IDirectPlayLobby3AImpl *This = lpDPL;
231 This->dpl3 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl3) ) );
232 if ( This->dpl3 == NULL )
240 static BOOL DPL_DestroyLobby3( LPVOID lpDPL )
242 IDirectPlayLobby3AImpl *This = lpDPL;
244 HeapFree( GetProcessHeap(), 0, This->dpl3 );
250 /* The COM interface for upversioning an interface
251 * We've been given a GUID (riid) and we need to replace the present
252 * interface with that of the requested interface.
254 * Snip from some Microsoft document:
255 * There are four requirements for implementations of QueryInterface (In these
256 * cases, "must succeed" means "must succeed barring catastrophic failure."):
258 * * The set of interfaces accessible on an object through
259 * IUnknown::QueryInterface must be static, not dynamic. This means that
260 * if a call to QueryInterface for a pointer to a specified interface
261 * succeeds the first time, it must succeed again, and if it fails the
262 * first time, it must fail on all subsequent queries.
263 * * It must be symmetric ~W if a client holds a pointer to an interface on
264 * an object, and queries for that interface, the call must succeed.
265 * * It must be reflexive ~W if a client holding a pointer to one interface
266 * queries successfully for another, a query through the obtained pointer
267 * for the first interface must succeed.
268 * * It must be transitive ~W if a client holding a pointer to one interface
269 * queries successfully for a second, and through that pointer queries
270 * successfully for a third interface, a query for the first interface
271 * through the pointer for the third interface must succeed.
273 HRESULT DPL_CreateInterface
274 ( REFIID riid, LPVOID* ppvObj )
276 TRACE( " for %s\n", debugstr_guid( riid ) );
278 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
279 sizeof( IDirectPlayLobbyWImpl ) );
281 if( *ppvObj == NULL )
283 return DPERR_OUTOFMEMORY;
286 if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
288 IDirectPlayLobbyWImpl *This = *ppvObj;
289 This->lpVtbl = &directPlayLobbyWVT;
291 else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
293 IDirectPlayLobbyAImpl *This = *ppvObj;
294 This->lpVtbl = &directPlayLobbyAVT;
296 else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
298 IDirectPlayLobby2WImpl *This = *ppvObj;
299 This->lpVtbl = &directPlayLobby2WVT;
301 else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
303 IDirectPlayLobby2AImpl *This = *ppvObj;
304 This->lpVtbl = &directPlayLobby2AVT;
306 else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
308 IDirectPlayLobby3WImpl *This = *ppvObj;
309 This->lpVtbl = &directPlayLobby3WVT;
311 else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
313 IDirectPlayLobby3AImpl *This = *ppvObj;
314 This->lpVtbl = &directPlayLobby3AVT;
318 /* Unsupported interface */
319 HeapFree( GetProcessHeap(), 0, *ppvObj );
322 return E_NOINTERFACE;
326 if ( DPL_CreateIUnknown( *ppvObj ) &&
327 DPL_CreateLobby1( *ppvObj ) &&
328 DPL_CreateLobby2( *ppvObj ) &&
329 DPL_CreateLobby3( *ppvObj )
332 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY)*ppvObj );
336 /* Initialize failed, destroy it */
337 DPL_DestroyLobby3( *ppvObj );
338 DPL_DestroyLobby2( *ppvObj );
339 DPL_DestroyLobby1( *ppvObj );
340 DPL_DestroyIUnknown( *ppvObj );
341 HeapFree( GetProcessHeap(), 0, *ppvObj );
344 return DPERR_NOMEMORY;
347 static HRESULT WINAPI DPL_QueryInterface
348 ( LPDIRECTPLAYLOBBYA iface,
352 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
353 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj );
355 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
358 if( *ppvObj == NULL )
360 return DPERR_OUTOFMEMORY;
363 CopyMemory( *ppvObj, This, sizeof( *This ) );
364 (*(IDirectPlayLobbyAImpl**)ppvObj)->ulInterfaceRef = 0;
366 if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
368 IDirectPlayLobbyWImpl *This = *ppvObj;
369 This->lpVtbl = &directPlayLobbyWVT;
371 else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
373 IDirectPlayLobbyAImpl *This = *ppvObj;
374 This->lpVtbl = &directPlayLobbyAVT;
376 else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
378 IDirectPlayLobby2WImpl *This = *ppvObj;
379 This->lpVtbl = &directPlayLobby2WVT;
381 else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
383 IDirectPlayLobby2AImpl *This = *ppvObj;
384 This->lpVtbl = &directPlayLobby2AVT;
386 else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
388 IDirectPlayLobby3WImpl *This = *ppvObj;
389 This->lpVtbl = &directPlayLobby3WVT;
391 else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
393 IDirectPlayLobby3AImpl *This = *ppvObj;
394 This->lpVtbl = &directPlayLobby3AVT;
398 /* Unsupported interface */
399 HeapFree( GetProcessHeap(), 0, *ppvObj );
402 return E_NOINTERFACE;
405 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY)*ppvObj );
411 * Simple procedure. Just increment the reference count to this
412 * structure and return the new reference count.
414 static ULONG WINAPI DPL_AddRef
415 ( LPDIRECTPLAYLOBBY iface )
417 ULONG ulInterfaceRefCount, ulObjRefCount;
418 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
420 ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
421 ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
423 TRACE( "ref count incremented to %u:%u for %p\n",
424 ulInterfaceRefCount, ulObjRefCount, This );
426 return ulObjRefCount;
430 * Simple COM procedure. Decrease the reference count to this object.
431 * If the object no longer has any reference counts, free up the associated
434 static ULONG WINAPI DPL_Release
435 ( LPDIRECTPLAYLOBBYA iface )
437 ULONG ulInterfaceRefCount, ulObjRefCount;
438 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
440 ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
441 ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
443 TRACE( "ref count decremented to %u:%u for %p\n",
444 ulInterfaceRefCount, ulObjRefCount, This );
446 /* Deallocate if this is the last reference to the object */
447 if( ulObjRefCount == 0 )
449 DPL_DestroyLobby3( This );
450 DPL_DestroyLobby2( This );
451 DPL_DestroyLobby1( This );
452 DPL_DestroyIUnknown( This );
455 if( ulInterfaceRefCount == 0 )
457 HeapFree( GetProcessHeap(), 0, This );
460 return ulInterfaceRefCount;
464 /********************************************************************
466 * Connects an application to the session specified by the DPLCONNECTION
467 * structure currently stored with the DirectPlayLobby object.
469 * Returns an IDirectPlay interface.
472 static HRESULT DPL_ConnectEx
473 ( IDirectPlayLobbyAImpl* This,
480 DWORD dwOpenFlags = 0;
481 DWORD dwConnSize = 0;
482 LPDPLCONNECTION lpConn;
484 FIXME("(%p)->(0x%08x,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk );
488 return DPERR_INVALIDPARAMS;
491 /* Backwards compatibility */
494 dwFlags = DPCONNECT_RETURNSTATUS;
497 if ( ( hr = dplay_create( riid, lplpDP ) ) != DP_OK )
499 ERR( "error creating interface for %s:%s.\n",
500 debugstr_guid( riid ), DPLAYX_HresultToString( hr ) );
504 /* FIXME: Is it safe/correct to use appID of 0? */
505 hr = IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY)This,
506 0, NULL, &dwConnSize );
507 if( hr != DPERR_BUFFERTOOSMALL )
512 lpConn = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwConnSize );
516 return DPERR_NOMEMORY;
519 /* FIXME: Is it safe/correct to use appID of 0? */
520 hr = IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY)This,
521 0, lpConn, &dwConnSize );
524 HeapFree( GetProcessHeap(), 0, lpConn );
529 /* - Need to call IDirectPlay::EnumConnections with the service provider to get that good information
530 * - Need to call CreateAddress to create the lpConnection param for IDirectPlay::InitializeConnection
531 * - Call IDirectPlay::InitializeConnection
534 /* Now initialize the Service Provider */
535 hr = IDirectPlayX_InitializeConnection( (*(LPDIRECTPLAY2*)lplpDP),
539 /* Setup flags to pass into DirectPlay::Open */
540 if( dwFlags & DPCONNECT_RETURNSTATUS )
542 dwOpenFlags |= DPOPEN_RETURNSTATUS;
544 dwOpenFlags |= lpConn->dwFlags;
546 hr = IDirectPlayX_Open( (*(LPDIRECTPLAY2*)lplpDP), lpConn->lpSessionDesc,
549 HeapFree( GetProcessHeap(), 0, lpConn );
554 static HRESULT WINAPI IDirectPlayLobbyAImpl_Connect
555 ( LPDIRECTPLAYLOBBYA iface,
557 LPDIRECTPLAY2A* lplpDP,
560 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
561 return DPL_ConnectEx( This, dwFlags, &IID_IDirectPlay2A,
562 (LPVOID)lplpDP, pUnk );
565 static HRESULT WINAPI IDirectPlayLobbyWImpl_Connect
566 ( LPDIRECTPLAYLOBBY iface,
568 LPDIRECTPLAY2* lplpDP,
571 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface; /* Yes cast to A */
572 return DPL_ConnectEx( This, dwFlags, &IID_IDirectPlay2,
573 (LPVOID)lplpDP, pUnk );
576 /********************************************************************
578 * Creates a DirectPlay Address, given a service provider-specific network
580 * Returns an address contains the globally unique identifier
581 * (GUID) of the service provider and data that the service provider can
582 * interpret as a network address.
584 * NOTE: It appears that this method is supposed to be really really stupid
585 * with no error checking on the contents.
587 static HRESULT WINAPI IDirectPlayLobbyAImpl_CreateAddress
588 ( LPDIRECTPLAYLOBBYA iface,
590 REFGUID guidDataType,
594 LPDWORD lpdwAddressSize )
596 return DPL_CreateAddress( guidSP, guidDataType, lpData, dwDataSize,
597 lpAddress, lpdwAddressSize, TRUE );
600 static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress
601 ( LPDIRECTPLAYLOBBY iface,
603 REFGUID guidDataType,
607 LPDWORD lpdwAddressSize )
609 return DPL_CreateAddress( guidSP, guidDataType, lpData, dwDataSize,
610 lpAddress, lpdwAddressSize, FALSE );
613 static HRESULT DPL_CreateAddress(
615 REFGUID guidDataType,
619 LPDWORD lpdwAddressSize,
620 BOOL bAnsiInterface )
622 const DWORD dwNumAddElements = 2; /* Service Provide & address data type */
623 DPCOMPOUNDADDRESSELEMENT addressElements[ 2 /* dwNumAddElements */ ];
625 TRACE( "(%p)->(%p,%p,0x%08x,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize,
626 lpAddress, lpdwAddressSize, bAnsiInterface );
628 addressElements[ 0 ].guidDataType = DPAID_ServiceProvider;
629 addressElements[ 0 ].dwDataSize = sizeof( GUID );
630 addressElements[ 0 ].lpData = (LPVOID)guidSP;
632 addressElements[ 1 ].guidDataType = *guidDataType;
633 addressElements[ 1 ].dwDataSize = dwDataSize;
634 addressElements[ 1 ].lpData = (LPVOID)lpData;
636 /* Call CreateCompoundAddress to cut down on code.
637 NOTE: We can do this because we don't support DPL 1 interfaces! */
638 return DPL_CreateCompoundAddress( addressElements, dwNumAddElements,
639 lpAddress, lpdwAddressSize, bAnsiInterface );
644 /********************************************************************
646 * Parses out chunks from the DirectPlay Address buffer by calling the
647 * given callback function, with lpContext, for each of the chunks.
650 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress
651 ( LPDIRECTPLAYLOBBYA iface,
652 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
657 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
659 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress,
660 dwAddressSize, lpContext );
662 return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
665 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress
666 ( LPDIRECTPLAYLOBBY iface,
667 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
672 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
674 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress,
675 dwAddressSize, lpContext );
677 return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
680 HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
681 DWORD dwAddressSize, LPVOID lpContext )
683 DWORD dwTotalSizeEnumerated = 0;
685 /* FIXME: First chunk is always the total size chunk - Should we report it? */
687 while ( dwTotalSizeEnumerated < dwAddressSize )
689 const DPADDRESS* lpElements = lpAddress;
690 DWORD dwSizeThisEnumeration;
692 /* Invoke the enum method. If false is returned, stop enumeration */
693 if ( !lpEnumAddressCallback( &lpElements->guidDataType,
694 lpElements->dwDataSize,
695 (const BYTE *)lpElements + sizeof( DPADDRESS ),
701 dwSizeThisEnumeration = sizeof( DPADDRESS ) + lpElements->dwDataSize;
702 lpAddress = (const BYTE*) lpAddress + dwSizeThisEnumeration;
703 dwTotalSizeEnumerated += dwSizeThisEnumeration;
709 /********************************************************************
711 * Enumerates all the address types that a given service provider needs to
712 * build the DirectPlay Address.
715 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
716 ( LPDIRECTPLAYLOBBYA iface,
717 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback,
722 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
725 LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
726 DWORD dwIndex, sizeOfSubKeyName=50;
730 TRACE(" (%p)->(%p,%p,%p,0x%08x)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags );
734 return DPERR_INVALIDPARAMS;
737 if( !lpEnumAddressTypeCallback )
739 return DPERR_INVALIDPARAMS;
744 return DPERR_INVALIDOBJECT;
747 /* Need to loop over the service providers in the registry */
748 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
749 0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
751 /* Hmmm. Does this mean that there are no service providers? */
752 ERR(": no service providers?\n");
756 /* Traverse all the service providers we have available */
758 RegEnumKeyExA( hkResult, dwIndex, subKeyName, &sizeOfSubKeyName,
759 NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
760 ++dwIndex, sizeOfSubKeyName=50 )
763 HKEY hkServiceProvider, hkServiceProviderAt;
764 GUID serviceProviderGUID;
765 DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
767 char returnBuffer[51];
770 LPCSTR atKey = "Address Types";
771 LPCSTR guidDataSubKey = "Guid";
775 TRACE(" this time through: %s\n", subKeyName );
777 /* Get a handle for this particular service provider */
778 if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_READ,
779 &hkServiceProvider ) != ERROR_SUCCESS )
781 ERR(": what the heck is going on?\n" );
785 if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
786 NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
787 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
789 ERR(": missing GUID registry data members\n" );
793 /* FIXME: Check return types to ensure we're interpreting data right */
794 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
795 CLSIDFromString( buff, &serviceProviderGUID );
796 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
798 /* Determine if this is the Service Provider that the user asked for */
799 if( !IsEqualGUID( &serviceProviderGUID, guidSP ) )
804 /* Get a handle for this particular service provider */
805 if( RegOpenKeyExA( hkServiceProvider, atKey, 0, KEY_READ,
806 &hkServiceProviderAt ) != ERROR_SUCCESS )
808 TRACE(": No Address Types registry data sub key/members\n" );
812 /* Traverse all the address type we have available */
814 RegEnumKeyExA( hkServiceProviderAt, dwAtIndex, atSubKey, &sizeOfSubKeyName,
815 NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
816 ++dwAtIndex, sizeOfSubKeyName=50 )
818 TRACE( "Found Address Type GUID %s\n", atSubKey );
820 /* FIXME: Check return types to ensure we're interpreting data right */
821 MultiByteToWideChar( CP_ACP, 0, atSubKey, -1, buff, sizeof(buff)/sizeof(WCHAR) );
822 CLSIDFromString( buff, &serviceProviderGUID );
823 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
825 /* The enumeration will return FALSE if we are not to continue */
826 if( !lpEnumAddressTypeCallback( &serviceProviderGUID, lpContext, 0 ) )
828 WARN("lpEnumCallback returning FALSE\n" );
829 break; /* FIXME: This most likely has to break from the procedure...*/
834 /* We only enumerate address types for 1 GUID. We've found it, so quit looking */
841 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddressTypes
842 ( LPDIRECTPLAYLOBBY iface,
843 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback,
849 return DPERR_OUTOFMEMORY;
852 /********************************************************************
854 * Enumerates what applications are registered with DirectPlay by
855 * invoking the callback function with lpContext.
858 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications
859 ( LPDIRECTPLAYLOBBY iface,
860 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback,
864 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
866 FIXME("(%p)->(%p,%p,0x%08x):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
868 return DPERR_OUTOFMEMORY;
871 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
872 ( LPDIRECTPLAYLOBBYA iface,
873 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback,
877 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
880 LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Applications";
881 LPCSTR guidDataSubKey = "Guid";
882 DWORD dwIndex, sizeOfSubKeyName=50;
886 TRACE("(%p)->(%p,%p,0x%08x)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
890 return DPERR_INVALIDPARAMS;
893 if( !lpEnumLocalAppCallback )
895 return DPERR_INVALIDPARAMS;
898 /* Need to loop over the service providers in the registry */
899 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
900 0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
902 /* Hmmm. Does this mean that there are no service providers? */
903 ERR(": no service providers?\n");
907 /* Traverse all registered applications */
909 RegEnumKeyExA( hkResult, dwIndex, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
910 ++dwIndex, sizeOfSubKeyName=50 )
913 HKEY hkServiceProvider;
914 GUID serviceProviderGUID;
915 DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
916 char returnBuffer[51];
918 DPLAPPINFO dplAppInfo;
920 TRACE(" this time through: %s\n", subKeyName );
922 /* Get a handle for this particular service provider */
923 if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_READ,
924 &hkServiceProvider ) != ERROR_SUCCESS )
926 ERR(": what the heck is going on?\n" );
930 if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
931 NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
932 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
934 ERR(": missing GUID registry data members\n" );
938 /* FIXME: Check return types to ensure we're interpreting data right */
939 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
940 CLSIDFromString( buff, &serviceProviderGUID );
941 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
943 dplAppInfo.dwSize = sizeof( dplAppInfo );
944 dplAppInfo.guidApplication = serviceProviderGUID;
945 dplAppInfo.u.lpszAppNameA = subKeyName;
947 EnterCriticalSection( &This->unk->DPL_lock );
949 memcpy( &This->dpl->hkCallbackKeyHack, &hkServiceProvider, sizeof( hkServiceProvider ) );
951 if( !lpEnumLocalAppCallback( &dplAppInfo, lpContext, dwFlags ) )
953 LeaveCriticalSection( &This->unk->DPL_lock );
957 LeaveCriticalSection( &This->unk->DPL_lock );
963 /********************************************************************
965 * Retrieves the DPLCONNECTION structure that contains all the information
966 * needed to start and connect an application. This was generated using
967 * either the RunApplication or SetConnectionSettings methods.
969 * NOTES: If lpData is NULL then just return lpdwDataSize. This allows
970 * the data structure to be allocated by our caller which can then
971 * call this procedure/method again with a valid data pointer.
973 static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings
974 ( LPDIRECTPLAYLOBBYA iface,
977 LPDWORD lpdwDataSize )
979 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
982 TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
984 EnterCriticalSection( &This->unk->DPL_lock );
986 hr = DPLAYX_GetConnectionSettingsA( dwAppID,
991 LeaveCriticalSection( &This->unk->DPL_lock );
996 static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings
997 ( LPDIRECTPLAYLOBBY iface,
1000 LPDWORD lpdwDataSize )
1002 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1005 TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
1007 EnterCriticalSection( &This->unk->DPL_lock );
1009 hr = DPLAYX_GetConnectionSettingsW( dwAppID,
1014 LeaveCriticalSection( &This->unk->DPL_lock );
1019 /********************************************************************
1021 * Retrieves the message sent between a lobby client and a DirectPlay
1022 * application. All messages are queued until received.
1025 static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage
1026 ( LPDIRECTPLAYLOBBYA iface,
1029 LPDWORD lpdwMessageFlags,
1031 LPDWORD lpdwDataSize )
1033 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
1034 FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
1036 return DPERR_OUTOFMEMORY;
1039 static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage
1040 ( LPDIRECTPLAYLOBBY iface,
1043 LPDWORD lpdwMessageFlags,
1045 LPDWORD lpdwDataSize )
1047 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1048 FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
1050 return DPERR_OUTOFMEMORY;
1053 typedef struct tagRunApplicationEnumStruct
1055 IDirectPlayLobbyAImpl* This;
1060 LPSTR lpszCommandLine;
1061 LPSTR lpszCurrentDirectory;
1062 } RunApplicationEnumStruct, *lpRunApplicationEnumStruct;
1064 /* To be called by RunApplication to find how to invoke the function */
1065 static BOOL CALLBACK RunApplicationA_EnumLocalApplications
1066 ( LPCDPLAPPINFO lpAppInfo,
1070 lpRunApplicationEnumStruct lpData = (lpRunApplicationEnumStruct)lpContext;
1072 if( IsEqualGUID( &lpAppInfo->guidApplication, &lpData->appGUID ) )
1074 char returnBuffer[200];
1075 DWORD returnType, sizeOfReturnBuffer;
1076 LPCSTR clSubKey = "CommandLine";
1077 LPCSTR cdSubKey = "CurrentDirectory";
1078 LPCSTR fileSubKey = "File";
1079 LPCSTR pathSubKey = "Path";
1081 /* FIXME: Lazy man hack - dplay struct has the present reg key saved */
1083 sizeOfReturnBuffer = 200;
1085 /* Get all the appropriate data from the registry */
1086 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, clSubKey,
1087 NULL, &returnType, (LPBYTE)returnBuffer,
1088 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1090 ERR( ": missing CommandLine registry data member\n" );
1094 if ((lpData->lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1095 strcpy( lpData->lpszCommandLine, returnBuffer );
1098 sizeOfReturnBuffer = 200;
1100 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, cdSubKey,
1101 NULL, &returnType, (LPBYTE)returnBuffer,
1102 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1104 ERR( ": missing CurrentDirectory registry data member\n" );
1108 if ((lpData->lpszCurrentDirectory = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1109 strcpy( lpData->lpszCurrentDirectory, returnBuffer );
1112 sizeOfReturnBuffer = 200;
1114 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, fileSubKey,
1115 NULL, &returnType, (LPBYTE)returnBuffer,
1116 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1118 ERR( ": missing File registry data member\n" );
1122 if ((lpData->lpszFileName = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1123 strcpy( lpData->lpszFileName, returnBuffer );
1126 sizeOfReturnBuffer = 200;
1128 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, pathSubKey,
1129 NULL, &returnType, (LPBYTE)returnBuffer,
1130 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1132 ERR( ": missing Path registry data member\n" );
1136 if ((lpData->lpszPath = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1137 strcpy( lpData->lpszPath, returnBuffer );
1140 return FALSE; /* No need to keep going as we found what we wanted */
1143 return TRUE; /* Keep enumerating, haven't found the application yet */
1146 static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
1147 LPHANDLE lphStart, LPHANDLE lphDeath,
1150 /* These are the handles for the created process */
1151 HANDLE hAppStart = 0, hAppDeath = 0, hAppRead = 0;
1152 SECURITY_ATTRIBUTES s_attrib;
1154 s_attrib.nLength = sizeof( s_attrib );
1155 s_attrib.lpSecurityDescriptor = NULL;
1156 s_attrib.bInheritHandle = TRUE;
1158 *lphStart = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
1159 *lphDeath = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
1160 *lphRead = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
1162 if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart,
1163 hDestProcess, &hAppStart,
1164 0, FALSE, DUPLICATE_SAME_ACCESS ) ) ||
1165 ( !DuplicateHandle( GetCurrentProcess(), *lphDeath,
1166 hDestProcess, &hAppDeath,
1167 0, FALSE, DUPLICATE_SAME_ACCESS ) ) ||
1168 ( !DuplicateHandle( GetCurrentProcess(), *lphRead,
1169 hDestProcess, &hAppRead,
1170 0, FALSE, DUPLICATE_SAME_ACCESS ) )
1173 if (*lphStart) { CloseHandle(*lphStart); *lphStart = 0; }
1174 if (*lphDeath) { CloseHandle(*lphDeath); *lphDeath = 0; }
1175 if (*lphRead) { CloseHandle(*lphRead); *lphRead = 0; }
1176 /* FIXME: Handle leak... */
1177 ERR( "Unable to dup handles\n" );
1181 if( !DPLAYX_SetLobbyHandles( dwDestProcessId,
1182 hAppStart, hAppDeath, hAppRead ) )
1184 /* FIXME: Handle leak... */
1192 /********************************************************************
1194 * Starts an application and passes to it all the information to
1195 * connect to a session.
1198 static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
1199 ( LPDIRECTPLAYLOBBYA iface,
1202 LPDPLCONNECTION lpConn,
1203 HANDLE hReceiveEvent )
1205 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
1207 RunApplicationEnumStruct enumData;
1209 STARTUPINFOA startupInfo;
1210 PROCESS_INFORMATION newProcessInfo;
1212 DWORD dwSuspendCount;
1213 HANDLE hStart, hDeath, hSettingRead;
1215 TRACE( "(%p)->(0x%08x,%p,%p,%p)\n",
1216 This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
1220 return DPERR_INVALIDPARAMS;
1223 if( DPLAYX_AnyLobbiesWaitingForConnSettings() )
1225 FIXME( "Waiting lobby not being handled correctly\n" );
1228 EnterCriticalSection( &This->unk->DPL_lock );
1230 ZeroMemory( &enumData, sizeof( enumData ) );
1231 enumData.This = This;
1232 enumData.appGUID = lpConn->lpSessionDesc->guidApplication;
1234 /* Our callback function will fill up the enumData structure with all the information
1235 required to start a new process */
1236 IDirectPlayLobby_EnumLocalApplications( iface, RunApplicationA_EnumLocalApplications,
1239 /* First the application name */
1240 strcpy( temp, enumData.lpszPath );
1241 strcat( temp, "\\" );
1242 strcat( temp, enumData.lpszFileName );
1243 HeapFree( GetProcessHeap(), 0, enumData.lpszPath );
1244 HeapFree( GetProcessHeap(), 0, enumData.lpszFileName );
1245 if ((appName = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) strcpy( appName, temp );
1247 /* Now the command line */
1248 strcat( temp, " " );
1249 strcat( temp, enumData.lpszCommandLine );
1250 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
1251 if ((enumData.lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 )))
1252 strcpy( enumData.lpszCommandLine, temp );
1254 ZeroMemory( &startupInfo, sizeof( startupInfo ) );
1255 startupInfo.cb = sizeof( startupInfo );
1256 /* FIXME: Should any fields be filled in? */
1258 ZeroMemory( &newProcessInfo, sizeof( newProcessInfo ) );
1260 if( !CreateProcessA( appName,
1261 enumData.lpszCommandLine,
1265 CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_SUSPENDED, /* Creation Flags */
1267 enumData.lpszCurrentDirectory,
1273 ERR( "Failed to create process for app %s\n", appName );
1275 HeapFree( GetProcessHeap(), 0, appName );
1276 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
1277 HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
1279 LeaveCriticalSection( &This->unk->DPL_lock );
1280 return DPERR_CANTCREATEPROCESS;
1283 HeapFree( GetProcessHeap(), 0, appName );
1284 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
1285 HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
1287 /* Reserve this global application id! */
1288 if( !DPLAYX_CreateLobbyApplication( newProcessInfo.dwProcessId ) )
1290 ERR( "Unable to create global application data for 0x%08x\n",
1291 newProcessInfo.dwProcessId );
1294 hr = IDirectPlayLobby_SetConnectionSettings( iface, 0, newProcessInfo.dwProcessId, lpConn );
1298 ERR( "SetConnectionSettings failure %s\n", DPLAYX_HresultToString( hr ) );
1299 LeaveCriticalSection( &This->unk->DPL_lock );
1303 /* Setup the handles for application notification */
1304 DPL_CreateAndSetLobbyHandles( newProcessInfo.dwProcessId,
1305 newProcessInfo.hProcess,
1306 &hStart, &hDeath, &hSettingRead );
1308 /* Setup the message thread ID */
1309 This->dpl->dwMsgThread =
1310 CreateLobbyMessageReceptionThread( hReceiveEvent, hStart, hDeath, hSettingRead );
1312 DPLAYX_SetLobbyMsgThreadId( newProcessInfo.dwProcessId, This->dpl->dwMsgThread );
1314 LeaveCriticalSection( &This->unk->DPL_lock );
1316 /* Everything seems to have been set correctly, update the dwAppID */
1317 *lpdwAppID = newProcessInfo.dwProcessId;
1319 /* Unsuspend the process - should return the prev suspension count */
1320 if( ( dwSuspendCount = ResumeThread( newProcessInfo.hThread ) ) != 1 )
1322 ERR( "ResumeThread failed with 0x%08x\n", dwSuspendCount );
1328 static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication
1329 ( LPDIRECTPLAYLOBBY iface,
1332 LPDPLCONNECTION lpConn,
1333 HANDLE hReceiveEvent )
1335 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1336 FIXME( "(%p)->(0x%08x,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
1337 return DPERR_OUTOFMEMORY;
1340 /********************************************************************
1342 * Sends a message between the application and the lobby client.
1343 * All messages are queued until received.
1346 static HRESULT WINAPI IDirectPlayLobbyAImpl_SendLobbyMessage
1347 ( LPDIRECTPLAYLOBBYA iface,
1354 return DPERR_OUTOFMEMORY;
1357 static HRESULT WINAPI IDirectPlayLobbyWImpl_SendLobbyMessage
1358 ( LPDIRECTPLAYLOBBY iface,
1365 return DPERR_OUTOFMEMORY;
1368 /********************************************************************
1370 * Modifies the DPLCONNECTION structure to contain all information
1371 * needed to start and connect an application.
1374 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings
1375 ( LPDIRECTPLAYLOBBY iface,
1378 LPDPLCONNECTION lpConn )
1380 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1383 TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn );
1385 EnterCriticalSection( &This->unk->DPL_lock );
1387 hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
1389 /* FIXME: Don't think that this is supposed to fail, but the documentation
1390 is somewhat sketchy. I'll try creating a lobby application
1392 if( hr == DPERR_NOTLOBBIED )
1394 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1397 dwAppID = GetCurrentProcessId();
1399 DPLAYX_CreateLobbyApplication( dwAppID );
1400 hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
1403 LeaveCriticalSection( &This->unk->DPL_lock );
1408 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings
1409 ( LPDIRECTPLAYLOBBYA iface,
1412 LPDPLCONNECTION lpConn )
1414 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
1417 TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn );
1419 EnterCriticalSection( &This->unk->DPL_lock );
1421 hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
1423 /* FIXME: Don't think that this is supposed to fail, but the documentation
1424 is somewhat sketchy. I'll try creating a lobby application
1426 if( hr == DPERR_NOTLOBBIED )
1428 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1429 dwAppID = GetCurrentProcessId();
1430 DPLAYX_CreateLobbyApplication( dwAppID );
1431 hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
1434 LeaveCriticalSection( &This->unk->DPL_lock );
1439 /********************************************************************
1441 * Registers an event that will be set when a lobby message is received.
1444 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1445 ( LPDIRECTPLAYLOBBYA iface,
1448 HANDLE hReceiveEvent )
1451 return DPERR_OUTOFMEMORY;
1454 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1455 ( LPDIRECTPLAYLOBBY iface,
1458 HANDLE hReceiveEvent )
1461 return DPERR_OUTOFMEMORY;
1466 static HRESULT WINAPI IDirectPlayLobby2WImpl_CreateCompoundAddress
1467 ( LPDIRECTPLAYLOBBY2 iface,
1468 LPCDPCOMPOUNDADDRESSELEMENT lpElements,
1469 DWORD dwElementCount,
1471 LPDWORD lpdwAddressSize )
1473 return DPL_CreateCompoundAddress( lpElements, dwElementCount, lpAddress, lpdwAddressSize, FALSE );
1476 static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress
1477 ( LPDIRECTPLAYLOBBY2A iface,
1478 LPCDPCOMPOUNDADDRESSELEMENT lpElements,
1479 DWORD dwElementCount,
1481 LPDWORD lpdwAddressSize )
1483 return DPL_CreateCompoundAddress( lpElements, dwElementCount, lpAddress, lpdwAddressSize, TRUE );
1486 HRESULT DPL_CreateCompoundAddress
1487 ( LPCDPCOMPOUNDADDRESSELEMENT lpElements,
1488 DWORD dwElementCount,
1490 LPDWORD lpdwAddressSize,
1491 BOOL bAnsiInterface )
1493 DWORD dwSizeRequired = 0;
1495 LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements = lpElements;
1497 TRACE("(%p,0x%08x,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize );
1499 /* Parameter check */
1500 if( ( lpElements == NULL ) ||
1501 ( dwElementCount == 0 ) /* FIXME: Not sure if this is a failure case */
1504 return DPERR_INVALIDPARAMS;
1507 /* Add the total size chunk */
1508 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( DWORD );
1510 /* Calculate the size of the buffer required */
1511 for ( dwElements = dwElementCount; dwElements > 0; --dwElements, ++lpElements )
1513 if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ServiceProvider ) ) ||
1514 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
1517 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( GUID );
1519 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Phone ) ) ||
1520 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Modem ) ) ||
1521 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
1524 if( !bAnsiInterface )
1526 ERR( "Ansi GUIDs used for unicode interface\n" );
1527 return DPERR_INVALIDFLAGS;
1530 dwSizeRequired += sizeof( DPADDRESS ) + lpElements->dwDataSize;
1532 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
1533 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ModemW ) ) ||
1534 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
1537 if( bAnsiInterface )
1539 ERR( "Unicode GUIDs used for ansi interface\n" );
1540 return DPERR_INVALIDFLAGS;
1543 FIXME( "Right size for unicode interface?\n" );
1544 dwSizeRequired += sizeof( DPADDRESS ) + lpElements->dwDataSize * sizeof( WCHAR );
1546 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
1548 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( WORD );
1550 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
1552 FIXME( "Right size for unicode interface?\n" );
1553 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( DPCOMPORTADDRESS ); /* FIXME: Right size? */
1557 ERR( "Unknown GUID %s\n", debugstr_guid(&lpElements->guidDataType) );
1558 return DPERR_INVALIDFLAGS;
1562 /* The user wants to know how big a buffer to allocate for us */
1563 if( ( lpAddress == NULL ) ||
1564 ( *lpdwAddressSize < dwSizeRequired )
1567 *lpdwAddressSize = dwSizeRequired;
1568 return DPERR_BUFFERTOOSMALL;
1571 /* Add the total size chunk */
1573 LPDPADDRESS lpdpAddress = lpAddress;
1575 lpdpAddress->guidDataType = DPAID_TotalSize;
1576 lpdpAddress->dwDataSize = sizeof( DWORD );
1577 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1579 *(LPDWORD)lpAddress = dwSizeRequired;
1580 lpAddress = (char *) lpAddress + sizeof( DWORD );
1583 /* Calculate the size of the buffer required */
1584 for( dwElements = dwElementCount, lpElements = lpOrigElements;
1586 --dwElements, ++lpElements )
1588 if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ServiceProvider ) ) ||
1589 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
1592 LPDPADDRESS lpdpAddress = lpAddress;
1594 lpdpAddress->guidDataType = lpElements->guidDataType;
1595 lpdpAddress->dwDataSize = sizeof( GUID );
1596 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1598 CopyMemory( lpAddress, lpElements->lpData, sizeof( GUID ) );
1599 lpAddress = (char *) lpAddress + sizeof( GUID );
1601 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Phone ) ) ||
1602 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Modem ) ) ||
1603 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
1606 LPDPADDRESS lpdpAddress = lpAddress;
1608 lpdpAddress->guidDataType = lpElements->guidDataType;
1609 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1610 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1612 lstrcpynA( lpAddress, lpElements->lpData, lpElements->dwDataSize );
1613 lpAddress = (char *) lpAddress + lpElements->dwDataSize;
1615 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
1616 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ModemW ) ) ||
1617 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
1620 LPDPADDRESS lpdpAddress = lpAddress;
1622 lpdpAddress->guidDataType = lpElements->guidDataType;
1623 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1624 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1626 lstrcpynW( lpAddress, lpElements->lpData, lpElements->dwDataSize );
1627 lpAddress = (char *) lpAddress + lpElements->dwDataSize * sizeof( WCHAR );
1629 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
1631 LPDPADDRESS lpdpAddress = lpAddress;
1633 lpdpAddress->guidDataType = lpElements->guidDataType;
1634 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1635 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1637 *((LPWORD)lpAddress) = *((LPWORD)lpElements->lpData);
1638 lpAddress = (char *) lpAddress + sizeof( WORD );
1640 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
1642 LPDPADDRESS lpdpAddress = lpAddress;
1644 lpdpAddress->guidDataType = lpElements->guidDataType;
1645 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1646 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1648 CopyMemory( lpAddress, lpElements->lpData, sizeof( DPADDRESS ) );
1649 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1658 static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
1659 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, REFIID riid,
1660 LPVOID* lplpDP, IUnknown* pUnk )
1662 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface ;
1663 return DPL_ConnectEx( This, dwFlags, riid, lplpDP, pUnk );
1666 static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
1667 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, REFIID riid,
1668 LPVOID* lplpDP, IUnknown* pUnk )
1670 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface ;
1671 return DPL_ConnectEx( This, dwFlags, riid, lplpDP, pUnk );
1674 static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
1675 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, LPDPAPPLICATIONDESC lpAppDesc )
1681 static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
1682 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, LPDPAPPLICATIONDESC lpAppDesc )
1688 static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
1689 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, REFGUID lpAppDesc )
1695 static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
1696 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, REFGUID lpAppDesc )
1702 static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
1703 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags )
1706 BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL);
1708 TRACE( "(%p)->(0x%08x)\n", iface, dwFlags );
1710 if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
1712 /* FIXME: What is the correct error return code? */
1713 hr = DPERR_NOTLOBBIED;
1719 static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
1720 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags )
1723 BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL);
1725 TRACE( "(%p)->(0x%08x)\n", iface, dwFlags );
1727 if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
1729 /* FIXME: What is the correct error return code? */
1730 hr = DPERR_NOTLOBBIED;
1737 /* Virtual Table definitions for DPL{1,2,3}{A,W} */
1739 /* Note: Hack so we can reuse the old functions without compiler warnings */
1740 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1741 # define XCAST(fun) (typeof(directPlayLobbyAVT.fun))
1743 # define XCAST(fun) (void*)
1746 /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
1747 /* All lobby 1 methods are exactly the same except QueryInterface */
1748 static const IDirectPlayLobbyVtbl directPlayLobbyAVT =
1751 XCAST(QueryInterface)DPL_QueryInterface,
1752 XCAST(AddRef)DPL_AddRef,
1753 XCAST(Release)DPL_Release,
1755 IDirectPlayLobbyAImpl_Connect,
1756 IDirectPlayLobbyAImpl_CreateAddress,
1757 IDirectPlayLobbyAImpl_EnumAddress,
1758 IDirectPlayLobbyAImpl_EnumAddressTypes,
1759 IDirectPlayLobbyAImpl_EnumLocalApplications,
1760 IDirectPlayLobbyAImpl_GetConnectionSettings,
1761 IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
1762 IDirectPlayLobbyAImpl_RunApplication,
1763 IDirectPlayLobbyAImpl_SendLobbyMessage,
1764 IDirectPlayLobbyAImpl_SetConnectionSettings,
1765 IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1770 /* Note: Hack so we can reuse the old functions without compiler warnings */
1771 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1772 # define XCAST(fun) (typeof(directPlayLobbyWVT.fun))
1774 # define XCAST(fun) (void*)
1777 /* Direct Play Lobby 1 (unicode) Virtual Table for methods */
1778 static const IDirectPlayLobbyVtbl directPlayLobbyWVT =
1781 XCAST(QueryInterface)DPL_QueryInterface,
1782 XCAST(AddRef)DPL_AddRef,
1783 XCAST(Release)DPL_Release,
1785 IDirectPlayLobbyWImpl_Connect,
1786 IDirectPlayLobbyWImpl_CreateAddress,
1787 IDirectPlayLobbyWImpl_EnumAddress,
1788 IDirectPlayLobbyWImpl_EnumAddressTypes,
1789 IDirectPlayLobbyWImpl_EnumLocalApplications,
1790 IDirectPlayLobbyWImpl_GetConnectionSettings,
1791 IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
1792 IDirectPlayLobbyWImpl_RunApplication,
1793 IDirectPlayLobbyWImpl_SendLobbyMessage,
1794 IDirectPlayLobbyWImpl_SetConnectionSettings,
1795 IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1799 /* Note: Hack so we can reuse the old functions without compiler warnings */
1800 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1801 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1803 # define XCAST(fun) (void*)
1806 /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
1807 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT =
1810 XCAST(QueryInterface)DPL_QueryInterface,
1811 XCAST(AddRef)DPL_AddRef,
1812 XCAST(Release)DPL_Release,
1814 XCAST(Connect)IDirectPlayLobbyAImpl_Connect,
1815 XCAST(CreateAddress)IDirectPlayLobbyAImpl_CreateAddress,
1816 XCAST(EnumAddress)IDirectPlayLobbyAImpl_EnumAddress,
1817 XCAST(EnumAddressTypes)IDirectPlayLobbyAImpl_EnumAddressTypes,
1818 XCAST(EnumLocalApplications)IDirectPlayLobbyAImpl_EnumLocalApplications,
1819 XCAST(GetConnectionSettings)IDirectPlayLobbyAImpl_GetConnectionSettings,
1820 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
1821 XCAST(RunApplication)IDirectPlayLobbyAImpl_RunApplication,
1822 XCAST(SendLobbyMessage)IDirectPlayLobbyAImpl_SendLobbyMessage,
1823 XCAST(SetConnectionSettings)IDirectPlayLobbyAImpl_SetConnectionSettings,
1824 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyAImpl_SetLobbyMessageEvent,
1826 IDirectPlayLobby2AImpl_CreateCompoundAddress
1830 /* Note: Hack so we can reuse the old functions without compiler warnings */
1831 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1832 # define XCAST(fun) (typeof(directPlayLobby2WVT.fun))
1834 # define XCAST(fun) (void*)
1837 /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
1838 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT =
1841 XCAST(QueryInterface)DPL_QueryInterface,
1842 XCAST(AddRef)DPL_AddRef,
1843 XCAST(Release)DPL_Release,
1845 XCAST(Connect)IDirectPlayLobbyWImpl_Connect,
1846 XCAST(CreateAddress)IDirectPlayLobbyWImpl_CreateAddress,
1847 XCAST(EnumAddress)IDirectPlayLobbyWImpl_EnumAddress,
1848 XCAST(EnumAddressTypes)IDirectPlayLobbyWImpl_EnumAddressTypes,
1849 XCAST(EnumLocalApplications)IDirectPlayLobbyWImpl_EnumLocalApplications,
1850 XCAST(GetConnectionSettings)IDirectPlayLobbyWImpl_GetConnectionSettings,
1851 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
1852 XCAST(RunApplication)IDirectPlayLobbyWImpl_RunApplication,
1853 XCAST(SendLobbyMessage)IDirectPlayLobbyWImpl_SendLobbyMessage,
1854 XCAST(SetConnectionSettings)IDirectPlayLobbyWImpl_SetConnectionSettings,
1855 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyWImpl_SetLobbyMessageEvent,
1857 IDirectPlayLobby2WImpl_CreateCompoundAddress
1861 /* Direct Play Lobby 3 (ascii) Virtual Table for methods */
1863 /* Note: Hack so we can reuse the old functions without compiler warnings */
1864 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1865 # define XCAST(fun) (typeof(directPlayLobby3AVT.fun))
1867 # define XCAST(fun) (void*)
1870 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT =
1872 XCAST(QueryInterface)DPL_QueryInterface,
1873 XCAST(AddRef)DPL_AddRef,
1874 XCAST(Release)DPL_Release,
1876 XCAST(Connect)IDirectPlayLobbyAImpl_Connect,
1877 XCAST(CreateAddress)IDirectPlayLobbyAImpl_CreateAddress,
1878 XCAST(EnumAddress)IDirectPlayLobbyAImpl_EnumAddress,
1879 XCAST(EnumAddressTypes)IDirectPlayLobbyAImpl_EnumAddressTypes,
1880 XCAST(EnumLocalApplications)IDirectPlayLobbyAImpl_EnumLocalApplications,
1881 XCAST(GetConnectionSettings)IDirectPlayLobbyAImpl_GetConnectionSettings,
1882 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
1883 XCAST(RunApplication)IDirectPlayLobbyAImpl_RunApplication,
1884 XCAST(SendLobbyMessage)IDirectPlayLobbyAImpl_SendLobbyMessage,
1885 XCAST(SetConnectionSettings)IDirectPlayLobbyAImpl_SetConnectionSettings,
1886 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyAImpl_SetLobbyMessageEvent,
1888 XCAST(CreateCompoundAddress)IDirectPlayLobby2AImpl_CreateCompoundAddress,
1890 IDirectPlayLobby3AImpl_ConnectEx,
1891 IDirectPlayLobby3AImpl_RegisterApplication,
1892 IDirectPlayLobby3AImpl_UnregisterApplication,
1893 IDirectPlayLobby3AImpl_WaitForConnectionSettings
1897 /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
1899 /* Note: Hack so we can reuse the old functions without compiler warnings */
1900 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1901 # define XCAST(fun) (typeof(directPlayLobby3WVT.fun))
1903 # define XCAST(fun) (void*)
1906 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT =
1908 XCAST(QueryInterface)DPL_QueryInterface,
1909 XCAST(AddRef)DPL_AddRef,
1910 XCAST(Release)DPL_Release,
1912 XCAST(Connect)IDirectPlayLobbyWImpl_Connect,
1913 XCAST(CreateAddress)IDirectPlayLobbyWImpl_CreateAddress,
1914 XCAST(EnumAddress)IDirectPlayLobbyWImpl_EnumAddress,
1915 XCAST(EnumAddressTypes)IDirectPlayLobbyWImpl_EnumAddressTypes,
1916 XCAST(EnumLocalApplications)IDirectPlayLobbyWImpl_EnumLocalApplications,
1917 XCAST(GetConnectionSettings)IDirectPlayLobbyWImpl_GetConnectionSettings,
1918 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
1919 XCAST(RunApplication)IDirectPlayLobbyWImpl_RunApplication,
1920 XCAST(SendLobbyMessage)IDirectPlayLobbyWImpl_SendLobbyMessage,
1921 XCAST(SetConnectionSettings)IDirectPlayLobbyWImpl_SetConnectionSettings,
1922 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyWImpl_SetLobbyMessageEvent,
1924 XCAST(CreateCompoundAddress)IDirectPlayLobby2WImpl_CreateCompoundAddress,
1926 IDirectPlayLobby3WImpl_ConnectEx,
1927 IDirectPlayLobby3WImpl_RegisterApplication,
1928 IDirectPlayLobby3WImpl_UnregisterApplication,
1929 IDirectPlayLobby3WImpl_WaitForConnectionSettings
1934 /*********************************************************
1936 * Direct Play Lobby Interface Implementation
1938 *********************************************************/
1940 /***************************************************************************
1941 * DirectPlayLobbyCreateA (DPLAYX.4)
1944 HRESULT WINAPI DirectPlayLobbyCreateA( LPGUID lpGUIDDSP,
1945 LPDIRECTPLAYLOBBYA *lplpDPL,
1950 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n",
1951 lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
1953 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1954 * equal 0. These fields are mostly for future expansion.
1956 if ( lpGUIDDSP || lpData || dwDataSize )
1959 return DPERR_INVALIDPARAMS;
1965 ERR("Bad parameters!\n" );
1966 return CLASS_E_NOAGGREGATION;
1969 return DPL_CreateInterface( &IID_IDirectPlayLobbyA, (void**)lplpDPL );
1972 /***************************************************************************
1973 * DirectPlayLobbyCreateW (DPLAYX.5)
1976 HRESULT WINAPI DirectPlayLobbyCreateW( LPGUID lpGUIDDSP,
1977 LPDIRECTPLAYLOBBY *lplpDPL,
1982 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n",
1983 lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
1985 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1986 * equal 0. These fields are mostly for future expansion.
1988 if ( lpGUIDDSP || lpData || dwDataSize )
1991 ERR("Bad parameters!\n" );
1992 return DPERR_INVALIDPARAMS;
1998 ERR("Bad parameters!\n" );
1999 return CLASS_E_NOAGGREGATION;
2002 return DPL_CreateInterface( &IID_IDirectPlayLobby, (void**)lplpDPL );