1 /* Direct Play Lobby 2 & 3 Implementation
3 * Copyright 1998,1999,2000 - Peter Hunnisett
5 * <presently under construction - contact hunnise@nortelnetworks.com>
12 #include "debugtools.h"
16 #include "dplayx_global.h"
17 #include "dplayx_messages.h"
18 #include "dplayx_queue.h"
20 DEFAULT_DEBUG_CHANNEL(dplay
);
22 /*****************************************************************************
23 * Predeclare the interface implementation structures
25 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyAImpl
;
26 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyWImpl
;
27 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2AImpl
;
28 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2WImpl
;
29 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3AImpl
;
30 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3WImpl
;
32 /* Forward declarations for this module helper methods */
33 HRESULT
DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements
, DWORD dwElementCount
,
34 LPVOID lpAddress
, LPDWORD lpdwAddressSize
, BOOL bAnsiInterface
);
36 HRESULT
DPL_CreateAddress( REFGUID guidSP
, REFGUID guidDataType
, LPCVOID lpData
, DWORD dwDataSize
,
37 LPVOID lpAddress
, LPDWORD lpdwAddressSize
, BOOL bAnsiInterface
);
41 extern HRESULT
DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
, LPCVOID lpAddress
,
42 DWORD dwAddressSize
, LPVOID lpContext
);
44 static HRESULT WINAPI
DPL_ConnectEx( IDirectPlayLobbyAImpl
* This
,
45 DWORD dwFlags
, REFIID riid
,
46 LPVOID
* lplpDP
, IUnknown
* pUnk
);
48 BOOL
DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId
, HANDLE hDestProcess
,
49 LPHANDLE lphStart
, LPHANDLE lphDeath
,
53 /*****************************************************************************
54 * IDirectPlayLobby {1,2,3} implementation structure
56 * The philosophy behind this extra pointer derefernce is that I wanted to
57 * have the same structure for all types of objects without having to do
58 * alot of casting. I also only wanted to implement an interface in the
59 * object it was "released" with IUnknown interface being implemented in the 1 version.
60 * Of course, with these new interfaces comes the data required to keep the state required
61 * by these interfaces. So, basically, the pointers contain the data associated with
62 * a release. If you use the data associated with release 3 in a release 2 object, you'll
63 * get a run time trap, as that won't have any data.
68 DPQ_ENTRY( DPLMSG
) msgs
; /* Link to next queued message */
70 typedef struct DPLMSG
* LPDPLMSG
;
72 typedef struct tagDirectPlayLobbyIUnknownData
75 CRITICAL_SECTION DPL_lock
;
76 } DirectPlayLobbyIUnknownData
;
78 typedef struct tagDirectPlayLobbyData
80 HKEY hkCallbackKeyHack
;
82 DPQ_HEAD( DPLMSG
) msgs
; /* List of messages received */
83 } DirectPlayLobbyData
;
85 typedef struct tagDirectPlayLobby2Data
88 } DirectPlayLobby2Data
;
90 typedef struct tagDirectPlayLobby3Data
93 } DirectPlayLobby3Data
;
95 #define DPL_IMPL_FIELDS \
96 ULONG ulInterfaceRef; \
97 DirectPlayLobbyIUnknownData* unk; \
98 DirectPlayLobbyData* dpl; \
99 DirectPlayLobby2Data* dpl2; \
100 DirectPlayLobby3Data* dpl3;
102 struct IDirectPlayLobbyImpl
104 ICOM_VFIELD(IDirectPlayLobby
);
108 struct IDirectPlayLobby2Impl
110 ICOM_VFIELD(IDirectPlayLobby2
);
114 struct IDirectPlayLobby3Impl
116 ICOM_VFIELD(IDirectPlayLobby3
);
121 /* Forward declarations of virtual tables */
122 static ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyWVT
;
123 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2WVT
;
124 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3WVT
;
126 static ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyAVT
;
127 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2AVT
;
128 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3AVT
;
133 static BOOL
DPL_CreateIUnknown( LPVOID lpDPL
)
135 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
137 This
->unk
= (DirectPlayLobbyIUnknownData
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
138 sizeof( *(This
->unk
) ) );
139 if ( This
->unk
== NULL
)
144 InitializeCriticalSection( &This
->unk
->DPL_lock
);
149 static BOOL
DPL_DestroyIUnknown( LPVOID lpDPL
)
151 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
153 DeleteCriticalSection( &This
->unk
->DPL_lock
);
154 HeapFree( GetProcessHeap(), 0, This
->unk
);
159 static BOOL
DPL_CreateLobby1( LPVOID lpDPL
)
161 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
163 This
->dpl
= (DirectPlayLobbyData
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
164 sizeof( *(This
->dpl
) ) );
165 if ( This
->dpl
== NULL
)
170 DPQ_INIT( This
->dpl
->msgs
);
175 static BOOL
DPL_DestroyLobby1( LPVOID lpDPL
)
177 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
179 if( This
->dpl
->dwMsgThread
)
181 FIXME( "Should kill the msg thread\n" );
184 DPQ_DELETEQ( This
->dpl
->msgs
, msgs
, LPDPLMSG
, cbDeleteElemFromHeap
);
186 /* Delete the contents */
187 HeapFree( GetProcessHeap(), 0, This
->dpl
);
192 static BOOL
DPL_CreateLobby2( LPVOID lpDPL
)
194 ICOM_THIS(IDirectPlayLobby2AImpl
,lpDPL
);
196 This
->dpl2
= (DirectPlayLobby2Data
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
197 sizeof( *(This
->dpl2
) ) );
198 if ( This
->dpl2
== NULL
)
206 static BOOL
DPL_DestroyLobby2( LPVOID lpDPL
)
208 ICOM_THIS(IDirectPlayLobby2AImpl
,lpDPL
);
210 HeapFree( GetProcessHeap(), 0, This
->dpl2
);
215 static BOOL
DPL_CreateLobby3( LPVOID lpDPL
)
217 ICOM_THIS(IDirectPlayLobby3AImpl
,lpDPL
);
219 This
->dpl3
= (DirectPlayLobby3Data
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
220 sizeof( *(This
->dpl3
) ) );
221 if ( This
->dpl3
== NULL
)
229 static BOOL
DPL_DestroyLobby3( LPVOID lpDPL
)
231 ICOM_THIS(IDirectPlayLobby3AImpl
,lpDPL
);
233 HeapFree( GetProcessHeap(), 0, This
->dpl3
);
239 /* The COM interface for upversioning an interface
240 * We've been given a GUID (riid) and we need to replace the present
241 * interface with that of the requested interface.
243 * Snip from some Microsoft document:
244 * There are four requirements for implementations of QueryInterface (In these
245 * cases, "must succeed" means "must succeed barring catastrophic failure."):
247 * * The set of interfaces accessible on an object through
248 * IUnknown::QueryInterface must be static, not dynamic. This means that
249 * if a call to QueryInterface for a pointer to a specified interface
250 * succeeds the first time, it must succeed again, and if it fails the
251 * first time, it must fail on all subsequent queries.
252 * * It must be symmetric ~W if a client holds a pointer to an interface on
253 * an object, and queries for that interface, the call must succeed.
254 * * It must be reflexive ~W if a client holding a pointer to one interface
255 * queries successfully for another, a query through the obtained pointer
256 * for the first interface must succeed.
257 * * It must be transitive ~W if a client holding a pointer to one interface
258 * queries successfully for a second, and through that pointer queries
259 * successfully for a third interface, a query for the first interface
260 * through the pointer for the third interface must succeed.
263 HRESULT DPL_CreateInterface
264 ( REFIID riid
, LPVOID
* ppvObj
)
266 TRACE( " for %s\n", debugstr_guid( riid
) );
268 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
269 sizeof( IDirectPlayLobbyWImpl
) );
271 if( *ppvObj
== NULL
)
273 return DPERR_OUTOFMEMORY
;
276 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
278 ICOM_THIS(IDirectPlayLobbyWImpl
,*ppvObj
);
279 ICOM_VTBL(This
) = &directPlayLobbyWVT
;
281 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
283 ICOM_THIS(IDirectPlayLobbyAImpl
,*ppvObj
);
284 ICOM_VTBL(This
) = &directPlayLobbyAVT
;
286 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
288 ICOM_THIS(IDirectPlayLobby2WImpl
,*ppvObj
);
289 ICOM_VTBL(This
) = &directPlayLobby2WVT
;
291 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
293 ICOM_THIS(IDirectPlayLobby2AImpl
,*ppvObj
);
294 ICOM_VTBL(This
) = &directPlayLobby2AVT
;
296 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
298 ICOM_THIS(IDirectPlayLobby3WImpl
,*ppvObj
);
299 ICOM_VTBL(This
) = &directPlayLobby3WVT
;
301 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
303 ICOM_THIS(IDirectPlayLobby3AImpl
,*ppvObj
);
304 ICOM_VTBL(This
) = &directPlayLobby3AVT
;
308 /* Unsupported interface */
309 HeapFree( GetProcessHeap(), 0, *ppvObj
);
312 return E_NOINTERFACE
;
316 if ( DPL_CreateIUnknown( *ppvObj
) &&
317 DPL_CreateLobby1( *ppvObj
) &&
318 DPL_CreateLobby2( *ppvObj
) &&
319 DPL_CreateLobby3( *ppvObj
)
322 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
326 /* Initialize failed, destroy it */
327 DPL_DestroyLobby3( *ppvObj
);
328 DPL_DestroyLobby2( *ppvObj
);
329 DPL_DestroyLobby1( *ppvObj
);
330 DPL_DestroyIUnknown( *ppvObj
);
331 HeapFree( GetProcessHeap(), 0, *ppvObj
);
334 return DPERR_NOMEMORY
;
337 static HRESULT WINAPI DPL_QueryInterface
338 ( LPDIRECTPLAYLOBBYA iface
,
342 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
343 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid( riid
), ppvObj
);
345 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
348 if( *ppvObj
== NULL
)
350 return DPERR_OUTOFMEMORY
;
353 CopyMemory( *ppvObj
, This
, sizeof( *This
) );
354 (*(IDirectPlayLobbyAImpl
**)ppvObj
)->ulInterfaceRef
= 0;
356 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
358 ICOM_THIS(IDirectPlayLobbyWImpl
,*ppvObj
);
359 ICOM_VTBL(This
) = &directPlayLobbyWVT
;
361 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
363 ICOM_THIS(IDirectPlayLobbyAImpl
,*ppvObj
);
364 ICOM_VTBL(This
) = &directPlayLobbyAVT
;
366 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
368 ICOM_THIS(IDirectPlayLobby2WImpl
,*ppvObj
);
369 ICOM_VTBL(This
) = &directPlayLobby2WVT
;
371 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
373 ICOM_THIS(IDirectPlayLobby2AImpl
,*ppvObj
);
374 ICOM_VTBL(This
) = &directPlayLobby2AVT
;
376 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
378 ICOM_THIS(IDirectPlayLobby3WImpl
,*ppvObj
);
379 ICOM_VTBL(This
) = &directPlayLobby3WVT
;
381 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
383 ICOM_THIS(IDirectPlayLobby3AImpl
,*ppvObj
);
384 ICOM_VTBL(This
) = &directPlayLobby3AVT
;
388 /* Unsupported interface */
389 HeapFree( GetProcessHeap(), 0, *ppvObj
);
392 return E_NOINTERFACE
;
395 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
401 * Simple procedure. Just increment the reference count to this
402 * structure and return the new reference count.
404 static ULONG WINAPI DPL_AddRef
405 ( LPDIRECTPLAYLOBBY iface
)
407 ULONG ulInterfaceRefCount
, ulObjRefCount
;
408 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
410 ulObjRefCount
= InterlockedIncrement( &This
->unk
->ulObjRef
);
411 ulInterfaceRefCount
= InterlockedIncrement( &This
->ulInterfaceRef
);
413 TRACE( "ref count incremented to %lu:%lu for %p\n",
414 ulInterfaceRefCount
, ulObjRefCount
, This
);
416 return ulObjRefCount
;
420 * Simple COM procedure. Decrease the reference count to this object.
421 * If the object no longer has any reference counts, free up the associated
424 static ULONG WINAPI DPL_Release
425 ( LPDIRECTPLAYLOBBYA iface
)
427 ULONG ulInterfaceRefCount
, ulObjRefCount
;
428 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
430 ulObjRefCount
= InterlockedDecrement( &This
->unk
->ulObjRef
);
431 ulInterfaceRefCount
= InterlockedDecrement( &This
->ulInterfaceRef
);
433 TRACE( "ref count decremented to %lu:%lu for %p\n",
434 ulInterfaceRefCount
, ulObjRefCount
, This
);
436 /* Deallocate if this is the last reference to the object */
437 if( ulObjRefCount
== 0 )
439 DPL_DestroyLobby3( This
);
440 DPL_DestroyLobby2( This
);
441 DPL_DestroyLobby1( This
);
442 DPL_DestroyIUnknown( This
);
445 if( ulInterfaceRefCount
== 0 )
447 HeapFree( GetProcessHeap(), 0, This
);
450 return ulInterfaceRefCount
;
454 /********************************************************************
456 * Connects an application to the session specified by the DPLCONNECTION
457 * structure currently stored with the DirectPlayLobby object.
459 * Returns a IDirectPlay interface.
462 static HRESULT WINAPI DPL_ConnectEx
463 ( IDirectPlayLobbyAImpl
* This
,
470 DWORD dwOpenFlags
= 0;
471 DWORD dwConnSize
= 0;
472 LPDPLCONNECTION lpConn
;
474 FIXME("(%p)->(0x%08lx,%p,%p): semi stub\n", This
, dwFlags
, lplpDP
, pUnk
);
478 return DPERR_INVALIDPARAMS
;
481 /* Backwards compatibility */
484 dwFlags
= DPCONNECT_RETURNSTATUS
;
487 /* Create the DirectPlay interface */
488 if( ( hr
= DP_CreateInterface( riid
, lplpDP
) ) != DP_OK
)
490 ERR( "error creating interface for %s:%s.\n",
491 debugstr_guid( riid
), DPLAYX_HresultToString( hr
) );
495 /* FIXME: Is it safe/correct to use appID of 0? */
496 hr
= IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY
)This
,
497 0, NULL
, &dwConnSize
);
498 if( hr
!= DPERR_BUFFERTOOSMALL
)
503 lpConn
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwConnSize
);
507 return DPERR_NOMEMORY
;
510 /* FIXME: Is it safe/correct to use appID of 0? */
511 hr
= IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY
)This
,
512 0, lpConn
, &dwConnSize
);
519 /* - Need to call IDirectPlay::EnumConnections with the service provider to get that good information
520 * - Need to call CreateAddress to create the lpConnection param for IDirectPlay::InitializeConnection
521 * - Call IDirectPlay::InitializeConnection
524 /* Now initialize the Service Provider */
525 hr
= IDirectPlayX_InitializeConnection( (*(LPDIRECTPLAY2
*)lplpDP
),
529 /* Setup flags to pass into DirectPlay::Open */
530 if( dwFlags
& DPCONNECT_RETURNSTATUS
)
532 dwOpenFlags
|= DPOPEN_RETURNSTATUS
;
534 dwOpenFlags
|= lpConn
->dwFlags
;
536 hr
= IDirectPlayX_Open( (*(LPDIRECTPLAY2
*)lplpDP
), lpConn
->lpSessionDesc
,
539 HeapFree( GetProcessHeap(), 0, lpConn
);
544 static HRESULT WINAPI IDirectPlayLobbyAImpl_Connect
545 ( LPDIRECTPLAYLOBBYA iface
,
547 LPDIRECTPLAY2A
* lplpDP
,
550 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
551 return DPL_ConnectEx( This
, dwFlags
, &IID_IDirectPlay2A
,
552 (LPVOID
)lplpDP
, pUnk
);
555 static HRESULT WINAPI IDirectPlayLobbyWImpl_Connect
556 ( LPDIRECTPLAYLOBBY iface
,
558 LPDIRECTPLAY2
* lplpDP
,
561 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
); /* Yes cast to A */
562 return DPL_ConnectEx( This
, dwFlags
, &IID_IDirectPlay2
,
563 (LPVOID
)lplpDP
, pUnk
);
566 /********************************************************************
568 * Creates a DirectPlay Address, given a service provider-specific network
570 * Returns an address contains the globally unique identifier
571 * (GUID) of the service provider and data that the service provider can
572 * interpret as a network address.
574 * NOTE: It appears that this method is supposed to be really really stupid
575 * with no error checking on the contents.
577 static HRESULT WINAPI IDirectPlayLobbyAImpl_CreateAddress
578 ( LPDIRECTPLAYLOBBYA iface
,
580 REFGUID guidDataType
,
584 LPDWORD lpdwAddressSize
)
586 return DPL_CreateAddress( guidSP
, guidDataType
, lpData
, dwDataSize
,
587 lpAddress
, lpdwAddressSize
, TRUE
);
590 static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress
591 ( LPDIRECTPLAYLOBBY iface
,
593 REFGUID guidDataType
,
597 LPDWORD lpdwAddressSize
)
599 return DPL_CreateAddress( guidSP
, guidDataType
, lpData
, dwDataSize
,
600 lpAddress
, lpdwAddressSize
, FALSE
);
603 HRESULT
DPL_CreateAddress(
605 REFGUID guidDataType
,
609 LPDWORD lpdwAddressSize
,
610 BOOL bAnsiInterface
)
612 const DWORD dwNumAddElements
= 2; /* Service Provide & address data type */
613 DPCOMPOUNDADDRESSELEMENT addressElements
[ 2 /* dwNumAddElements */ ];
615 TRACE( "(%p)->(%p,%p,0x%08lx,%p,%p,%d)\n", guidSP
, guidDataType
, lpData
, dwDataSize
,
616 lpAddress
, lpdwAddressSize
, bAnsiInterface
);
618 addressElements
[ 0 ].guidDataType
= DPAID_ServiceProvider
;
619 addressElements
[ 0 ].dwDataSize
= sizeof( GUID
);
620 addressElements
[ 0 ].lpData
= (LPVOID
)guidSP
;
622 addressElements
[ 1 ].guidDataType
= *guidDataType
;
623 addressElements
[ 1 ].dwDataSize
= dwDataSize
;
624 addressElements
[ 1 ].lpData
= (LPVOID
)lpData
;
626 /* Call CreateCompoundAddress to cut down on code.
627 NOTE: We can do this because we don't support DPL 1 interfaces! */
628 return DPL_CreateCompoundAddress( addressElements
, dwNumAddElements
,
629 lpAddress
, lpdwAddressSize
, bAnsiInterface
);
634 /********************************************************************
636 * Parses out chunks from the DirectPlay Address buffer by calling the
637 * given callback function, with lpContext, for each of the chunks.
640 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress
641 ( LPDIRECTPLAYLOBBYA iface
,
642 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
,
647 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
649 TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
650 dwAddressSize
, lpContext
);
652 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
655 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress
656 ( LPDIRECTPLAYLOBBY iface
,
657 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
,
662 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
664 TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
665 dwAddressSize
, lpContext
);
667 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
670 extern HRESULT
DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
, LPCVOID lpAddress
,
671 DWORD dwAddressSize
, LPVOID lpContext
)
673 DWORD dwTotalSizeEnumerated
= 0;
675 /* FIXME: First chunk is always the total size chunk - Should we report it? */
677 while ( dwTotalSizeEnumerated
< dwAddressSize
)
679 LPDPADDRESS lpElements
= (LPDPADDRESS
)lpAddress
;
680 DWORD dwSizeThisEnumeration
;
682 /* Invoke the enum method. If false is returned, stop enumeration */
683 if ( !lpEnumAddressCallback( &lpElements
->guidDataType
,
684 lpElements
->dwDataSize
,
685 (BYTE
*)lpElements
+ sizeof( DPADDRESS
),
691 dwSizeThisEnumeration
= sizeof( DPADDRESS
) + lpElements
->dwDataSize
;
692 lpAddress
= (BYTE
*) lpAddress
+ dwSizeThisEnumeration
;
693 dwTotalSizeEnumerated
+= dwSizeThisEnumeration
;
699 /********************************************************************
701 * Enumerates all the address types that a given service provider needs to
702 * build the DirectPlay Address.
705 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
706 ( LPDIRECTPLAYLOBBYA iface
,
707 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback
,
712 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
715 LPCSTR searchSubKey
= "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
716 DWORD dwIndex
, sizeOfSubKeyName
=50;
720 TRACE(" (%p)->(%p,%p,%p,0x%08lx)\n", This
, lpEnumAddressTypeCallback
, guidSP
, lpContext
, dwFlags
);
724 return DPERR_INVALIDPARAMS
;
727 if( !lpEnumAddressTypeCallback
|| !*lpEnumAddressTypeCallback
)
729 return DPERR_INVALIDPARAMS
;
734 return DPERR_INVALIDOBJECT
;
737 /* Need to loop over the service providers in the registry */
738 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE
, searchSubKey
,
739 0, KEY_READ
, &hkResult
) != ERROR_SUCCESS
)
741 /* Hmmm. Does this mean that there are no service providers? */
742 ERR(": no service providers?\n");
746 /* Traverse all the service providers we have available */
748 RegEnumKeyExA( hkResult
, dwIndex
, subKeyName
, &sizeOfSubKeyName
,
749 NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
750 ++dwIndex
, sizeOfSubKeyName
=50 )
753 HKEY hkServiceProvider
, hkServiceProviderAt
;
754 GUID serviceProviderGUID
;
755 DWORD returnTypeGUID
, sizeOfReturnBuffer
= 50;
757 char returnBuffer
[51];
760 LPSTR atKey
= "Address Types";
761 LPSTR guidDataSubKey
= "Guid";
765 TRACE(" this time through: %s\n", subKeyName
);
767 /* Get a handle for this particular service provider */
768 if( RegOpenKeyExA( hkResult
, subKeyName
, 0, KEY_READ
,
769 &hkServiceProvider
) != ERROR_SUCCESS
)
771 ERR(": what the heck is going on?\n" );
775 if( RegQueryValueExA( hkServiceProvider
, guidDataSubKey
,
776 NULL
, &returnTypeGUID
, returnBuffer
,
777 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
779 ERR(": missing GUID registry data members\n" );
783 /* FIXME: Check return types to ensure we're interpreting data right */
784 MultiByteToWideChar( CP_ACP
, 0, returnBuffer
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
785 CLSIDFromString( (LPCOLESTR
)buff
, &serviceProviderGUID
);
786 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
788 /* Determine if this is the Service Provider that the user asked for */
789 if( !IsEqualGUID( &serviceProviderGUID
, guidSP
) )
794 /* Get a handle for this particular service provider */
795 if( RegOpenKeyExA( hkServiceProvider
, atKey
, 0, KEY_READ
,
796 &hkServiceProviderAt
) != ERROR_SUCCESS
)
798 TRACE(": No Address Types registry data sub key/members\n" );
802 /* Traverse all the address type we have available */
804 RegEnumKeyExA( hkServiceProviderAt
, dwAtIndex
, atSubKey
, &sizeOfSubKeyName
,
805 NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
806 ++dwAtIndex
, sizeOfSubKeyName
=50 )
808 TRACE( "Found Address Type GUID %s\n", atSubKey
);
810 /* FIXME: Check return types to ensure we're interpreting data right */
811 MultiByteToWideChar( CP_ACP
, 0, atSubKey
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
812 CLSIDFromString( (LPCOLESTR
)buff
, &serviceProviderGUID
);
813 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
815 /* The enumeration will return FALSE if we are not to continue */
816 if( !lpEnumAddressTypeCallback( &serviceProviderGUID
, lpContext
, 0 ) )
818 WARN("lpEnumCallback returning FALSE\n" );
819 break; /* FIXME: This most likely has to break from the procedure...*/
824 /* We only enumerate address types for 1 GUID. We've found it, so quit looking */
831 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddressTypes
832 ( LPDIRECTPLAYLOBBY iface
,
833 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback
,
839 return DPERR_OUTOFMEMORY
;
842 /********************************************************************
844 * Enumerates what applications are registered with DirectPlay by
845 * invoking the callback function with lpContext.
848 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications
849 ( LPDIRECTPLAYLOBBY iface
,
850 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback
,
854 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
856 FIXME("(%p)->(%p,%p,0x%08lx):stub\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
858 return DPERR_OUTOFMEMORY
;
861 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
862 ( LPDIRECTPLAYLOBBYA iface
,
863 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback
,
867 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
870 LPCSTR searchSubKey
= "SOFTWARE\\Microsoft\\DirectPlay\\Applications";
871 LPSTR guidDataSubKey
= "Guid";
872 DWORD dwIndex
, sizeOfSubKeyName
=50;
876 TRACE("(%p)->(%p,%p,0x%08lx)\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
880 return DPERR_INVALIDPARAMS
;
883 if( !lpEnumLocalAppCallback
|| !*lpEnumLocalAppCallback
)
885 return DPERR_INVALIDPARAMS
;
888 /* Need to loop over the service providers in the registry */
889 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE
, searchSubKey
,
890 0, KEY_READ
, &hkResult
) != ERROR_SUCCESS
)
892 /* Hmmm. Does this mean that there are no service providers? */
893 ERR(": no service providers?\n");
897 /* Traverse all registered applications */
899 RegEnumKeyExA( hkResult
, dwIndex
, subKeyName
, &sizeOfSubKeyName
, NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
900 ++dwIndex
, sizeOfSubKeyName
=50 )
903 HKEY hkServiceProvider
;
904 GUID serviceProviderGUID
;
905 DWORD returnTypeGUID
, sizeOfReturnBuffer
= 50;
906 char returnBuffer
[51];
908 DPLAPPINFO dplAppInfo
;
910 TRACE(" this time through: %s\n", subKeyName
);
912 /* Get a handle for this particular service provider */
913 if( RegOpenKeyExA( hkResult
, subKeyName
, 0, KEY_READ
,
914 &hkServiceProvider
) != ERROR_SUCCESS
)
916 ERR(": what the heck is going on?\n" );
920 if( RegQueryValueExA( hkServiceProvider
, guidDataSubKey
,
921 NULL
, &returnTypeGUID
, returnBuffer
,
922 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
924 ERR(": missing GUID registry data members\n" );
928 /* FIXME: Check return types to ensure we're interpreting data right */
929 MultiByteToWideChar( CP_ACP
, 0, returnBuffer
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
930 CLSIDFromString( (LPCOLESTR
)buff
, &serviceProviderGUID
);
931 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
933 dplAppInfo
.dwSize
= sizeof( dplAppInfo
);
934 dplAppInfo
.guidApplication
= serviceProviderGUID
;
935 dplAppInfo
.u
.lpszAppNameA
= subKeyName
;
937 EnterCriticalSection( &This
->unk
->DPL_lock
);
939 memcpy( &This
->dpl
->hkCallbackKeyHack
, &hkServiceProvider
, sizeof( hkServiceProvider
) );
941 if( !lpEnumLocalAppCallback( &dplAppInfo
, lpContext
, dwFlags
) )
943 LeaveCriticalSection( &This
->unk
->DPL_lock
);
947 LeaveCriticalSection( &This
->unk
->DPL_lock
);
953 /********************************************************************
955 * Retrieves the DPLCONNECTION structure that contains all the information
956 * needed to start and connect an application. This was generated using
957 * either the RunApplication or SetConnectionSettings methods.
959 * NOTES: If lpData is NULL then just return lpdwDataSize. This allows
960 * the data structure to be allocated by our caller which can then
961 * call this procedure/method again with a valid data pointer.
963 static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings
964 ( LPDIRECTPLAYLOBBYA iface
,
967 LPDWORD lpdwDataSize
)
969 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
972 TRACE("(%p)->(0x%08lx,%p,%p)\n", This
, dwAppID
, lpData
, lpdwDataSize
);
974 EnterCriticalSection( &This
->unk
->DPL_lock
);
976 hr
= DPLAYX_GetConnectionSettingsA( dwAppID
,
981 LeaveCriticalSection( &This
->unk
->DPL_lock
);
986 static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings
987 ( LPDIRECTPLAYLOBBY iface
,
990 LPDWORD lpdwDataSize
)
992 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
995 TRACE("(%p)->(0x%08lx,%p,%p)\n", This
, dwAppID
, lpData
, lpdwDataSize
);
997 EnterCriticalSection( &This
->unk
->DPL_lock
);
999 hr
= DPLAYX_GetConnectionSettingsW( dwAppID
,
1004 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1009 /********************************************************************
1011 * Retrieves the message sent between a lobby client and a DirectPlay
1012 * application. All messages are queued until received.
1015 static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage
1016 ( LPDIRECTPLAYLOBBYA iface
,
1019 LPDWORD lpdwMessageFlags
,
1021 LPDWORD lpdwDataSize
)
1023 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
1024 FIXME(":stub %p %08lx %08lx %p %p %p\n", This
, dwFlags
, dwAppID
, lpdwMessageFlags
, lpData
,
1026 return DPERR_OUTOFMEMORY
;
1029 static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage
1030 ( LPDIRECTPLAYLOBBY iface
,
1033 LPDWORD lpdwMessageFlags
,
1035 LPDWORD lpdwDataSize
)
1037 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1038 FIXME(":stub %p %08lx %08lx %p %p %p\n", This
, dwFlags
, dwAppID
, lpdwMessageFlags
, lpData
,
1040 return DPERR_OUTOFMEMORY
;
1043 typedef struct tagRunApplicationEnumStruct
1045 IDirectPlayLobbyAImpl
* This
;
1050 LPSTR lpszCommandLine
;
1051 LPSTR lpszCurrentDirectory
;
1052 } RunApplicationEnumStruct
, *lpRunApplicationEnumStruct
;
1054 /* To be called by RunApplication to find how to invoke the function */
1055 static BOOL CALLBACK RunApplicationA_EnumLocalApplications
1056 ( LPCDPLAPPINFO lpAppInfo
,
1060 lpRunApplicationEnumStruct lpData
= (lpRunApplicationEnumStruct
)lpContext
;
1062 if( IsEqualGUID( &lpAppInfo
->guidApplication
, &lpData
->appGUID
) )
1064 char returnBuffer
[200];
1065 DWORD returnType
, sizeOfReturnBuffer
;
1066 LPSTR clSubKey
= "CommandLine";
1067 LPSTR cdSubKey
= "CurrentDirectory";
1068 LPSTR fileSubKey
= "File";
1069 LPSTR pathSubKey
= "Path";
1071 /* FIXME: Lazy man hack - dplay struct has the present reg key saved */
1073 sizeOfReturnBuffer
= 200;
1075 /* Get all the appropriate data from the registry */
1076 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, clSubKey
,
1077 NULL
, &returnType
, returnBuffer
,
1078 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1080 ERR( ": missing CommandLine registry data member\n" );
1084 if ((lpData
->lpszCommandLine
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1085 strcpy( lpData
->lpszCommandLine
, returnBuffer
);
1088 sizeOfReturnBuffer
= 200;
1090 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, cdSubKey
,
1091 NULL
, &returnType
, returnBuffer
,
1092 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1094 ERR( ": missing CurrentDirectory registry data member\n" );
1098 if ((lpData
->lpszCurrentDirectory
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1099 strcpy( lpData
->lpszCurrentDirectory
, returnBuffer
);
1102 sizeOfReturnBuffer
= 200;
1104 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, fileSubKey
,
1105 NULL
, &returnType
, returnBuffer
,
1106 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1108 ERR( ": missing File registry data member\n" );
1112 if ((lpData
->lpszFileName
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1113 strcpy( lpData
->lpszFileName
, returnBuffer
);
1116 sizeOfReturnBuffer
= 200;
1118 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, pathSubKey
,
1119 NULL
, &returnType
, returnBuffer
,
1120 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1122 ERR( ": missing Path registry data member\n" );
1126 if ((lpData
->lpszPath
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1127 strcpy( lpData
->lpszPath
, returnBuffer
);
1130 return FALSE
; /* No need to keep going as we found what we wanted */
1133 return TRUE
; /* Keep enumerating, haven't found the application yet */
1136 BOOL
DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId
, HANDLE hDestProcess
,
1137 LPHANDLE lphStart
, LPHANDLE lphDeath
,
1140 /* These are the handles for the created process */
1141 HANDLE hAppStart
, hAppDeath
, hAppRead
, hTemp
;
1142 SECURITY_ATTRIBUTES s_attrib
;
1144 s_attrib
.nLength
= sizeof( s_attrib
);
1145 s_attrib
.lpSecurityDescriptor
= NULL
;
1146 s_attrib
.bInheritHandle
= TRUE
;
1148 /* FIXME: Is there a handle leak here? */
1149 hTemp
= CreateEventA( &s_attrib
, TRUE
, FALSE
, NULL
);
1150 *lphStart
= ConvertToGlobalHandle( hTemp
);
1152 hTemp
= CreateEventA( &s_attrib
, TRUE
, FALSE
, NULL
);
1153 *lphDeath
= ConvertToGlobalHandle( hTemp
);
1155 hTemp
= CreateEventA( &s_attrib
, TRUE
, FALSE
, NULL
);
1156 *lphRead
= ConvertToGlobalHandle( hTemp
);
1158 if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart
,
1159 hDestProcess
, &hAppStart
,
1160 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) ||
1161 ( !DuplicateHandle( GetCurrentProcess(), *lphDeath
,
1162 hDestProcess
, &hAppDeath
,
1163 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) ||
1164 ( !DuplicateHandle( GetCurrentProcess(), *lphRead
,
1165 hDestProcess
, &hAppRead
,
1166 0, FALSE
, DUPLICATE_SAME_ACCESS
) )
1169 /* FIXME: Handle leak... */
1170 ERR( "Unable to dup handles\n" );
1174 if( !DPLAYX_SetLobbyHandles( dwDestProcessId
,
1175 hAppStart
, hAppDeath
, hAppRead
) )
1184 /********************************************************************
1186 * Starts an application and passes to it all the information to
1187 * connect to a session.
1190 static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
1191 ( LPDIRECTPLAYLOBBYA iface
,
1194 LPDPLCONNECTION lpConn
,
1195 HANDLE hReceiveEvent
)
1197 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
1199 RunApplicationEnumStruct enumData
;
1201 STARTUPINFOA startupInfo
;
1202 PROCESS_INFORMATION newProcessInfo
;
1204 DWORD dwSuspendCount
;
1205 HANDLE hStart
, hDeath
, hSettingRead
;
1207 TRACE( "(%p)->(0x%08lx,%p,%p,%x)\n",
1208 This
, dwFlags
, lpdwAppID
, lpConn
, hReceiveEvent
);
1212 return DPERR_INVALIDPARAMS
;
1215 if( DPLAYX_AnyLobbiesWaitingForConnSettings() )
1217 FIXME( "Waiting lobby not being handled correctly\n" );
1220 EnterCriticalSection( &This
->unk
->DPL_lock
);
1222 ZeroMemory( &enumData
, sizeof( enumData
) );
1223 enumData
.This
= This
;
1224 enumData
.appGUID
= lpConn
->lpSessionDesc
->guidApplication
;
1226 /* Our callback function will fill up the enumData structure with all the information
1227 required to start a new process */
1228 IDirectPlayLobby_EnumLocalApplications( iface
, RunApplicationA_EnumLocalApplications
,
1229 (LPVOID
)(&enumData
), 0 );
1231 /* First the application name */
1232 strcpy( temp
, enumData
.lpszPath
);
1233 strcat( temp
, "\\" );
1234 strcat( temp
, enumData
.lpszFileName
);
1235 HeapFree( GetProcessHeap(), 0, enumData
.lpszPath
);
1236 HeapFree( GetProcessHeap(), 0, enumData
.lpszFileName
);
1237 if ((appName
= HeapAlloc( GetProcessHeap(), 0, strlen(temp
)+1 ))) strcpy( appName
, temp
);
1239 /* Now the command line */
1240 strcat( temp
, " " );
1241 strcat( temp
, enumData
.lpszCommandLine
);
1242 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1243 if ((enumData
.lpszCommandLine
= HeapAlloc( GetProcessHeap(), 0, strlen(temp
)+1 )))
1244 strcpy( enumData
.lpszCommandLine
, temp
);
1246 ZeroMemory( &startupInfo
, sizeof( startupInfo
) );
1247 startupInfo
.cb
= sizeof( startupInfo
);
1248 /* FIXME: Should any fields be filled in? */
1250 ZeroMemory( &newProcessInfo
, sizeof( newProcessInfo
) );
1252 if( !CreateProcessA( appName
,
1253 enumData
.lpszCommandLine
,
1257 CREATE_DEFAULT_ERROR_MODE
| CREATE_NEW_CONSOLE
| CREATE_SUSPENDED
, /* Creation Flags */
1259 enumData
.lpszCurrentDirectory
,
1265 ERR( "Failed to create process for app %s\n", appName
);
1267 HeapFree( GetProcessHeap(), 0, appName
);
1268 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1269 HeapFree( GetProcessHeap(), 0, enumData
.lpszCurrentDirectory
);
1271 return DPERR_CANTCREATEPROCESS
;
1274 HeapFree( GetProcessHeap(), 0, appName
);
1275 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1276 HeapFree( GetProcessHeap(), 0, enumData
.lpszCurrentDirectory
);
1278 /* Reserve this global application id! */
1279 if( !DPLAYX_CreateLobbyApplication( newProcessInfo
.dwProcessId
) )
1281 ERR( "Unable to create global application data for 0x%08lx\n",
1282 newProcessInfo
.dwProcessId
);
1285 hr
= IDirectPlayLobby_SetConnectionSettings( iface
, 0, newProcessInfo
.dwProcessId
, lpConn
);
1289 ERR( "SetConnectionSettings failure %s\n", DPLAYX_HresultToString( hr
) );
1293 /* Setup the handles for application notification */
1294 DPL_CreateAndSetLobbyHandles( newProcessInfo
.dwProcessId
,
1295 newProcessInfo
.hProcess
,
1296 &hStart
, &hDeath
, &hSettingRead
);
1298 /* Setup the message thread ID */
1299 This
->dpl
->dwMsgThread
=
1300 CreateLobbyMessageReceptionThread( hReceiveEvent
, hStart
, hDeath
, hSettingRead
);
1302 DPLAYX_SetLobbyMsgThreadId( newProcessInfo
.dwProcessId
, This
->dpl
->dwMsgThread
);
1304 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1306 /* Everything seems to have been set correctly, update the dwAppID */
1307 *lpdwAppID
= newProcessInfo
.dwProcessId
;
1309 /* Unsuspend the process - should return the prev suspension count */
1310 if( ( dwSuspendCount
= ResumeThread( newProcessInfo
.hThread
) ) != 1 )
1312 ERR( "ResumeThread failed with 0x%08lx\n", dwSuspendCount
);
1318 static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication
1319 ( LPDIRECTPLAYLOBBY iface
,
1322 LPDPLCONNECTION lpConn
,
1323 HANDLE hReceiveEvent
)
1325 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1326 FIXME( "(%p)->(0x%08lx,%p,%p,%p):stub\n", This
, dwFlags
, lpdwAppID
, lpConn
, (void *)hReceiveEvent
);
1327 return DPERR_OUTOFMEMORY
;
1330 /********************************************************************
1332 * Sends a message between the application and the lobby client.
1333 * All messages are queued until received.
1336 static HRESULT WINAPI IDirectPlayLobbyAImpl_SendLobbyMessage
1337 ( LPDIRECTPLAYLOBBYA iface
,
1344 return DPERR_OUTOFMEMORY
;
1347 static HRESULT WINAPI IDirectPlayLobbyWImpl_SendLobbyMessage
1348 ( LPDIRECTPLAYLOBBY iface
,
1355 return DPERR_OUTOFMEMORY
;
1358 /********************************************************************
1360 * Modifies the DPLCONNECTION structure to contain all information
1361 * needed to start and connect an application.
1364 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings
1365 ( LPDIRECTPLAYLOBBY iface
,
1368 LPDPLCONNECTION lpConn
)
1370 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1373 TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This
, dwFlags
, dwAppID
, lpConn
);
1375 EnterCriticalSection( &This
->unk
->DPL_lock
);
1377 hr
= DPLAYX_SetConnectionSettingsW( dwFlags
, dwAppID
, lpConn
);
1379 /* FIXME: Don't think that this is supposed to fail, but the docuementation
1380 is somewhat sketchy. I'll try creating a lobby application
1382 if( hr
== DPERR_NOTLOBBIED
)
1384 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1387 dwAppID
= GetCurrentProcessId();
1389 DPLAYX_CreateLobbyApplication( dwAppID
);
1390 hr
= DPLAYX_SetConnectionSettingsW( dwFlags
, dwAppID
, lpConn
);
1393 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1398 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings
1399 ( LPDIRECTPLAYLOBBYA iface
,
1402 LPDPLCONNECTION lpConn
)
1404 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
1407 TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This
, dwFlags
, dwAppID
, lpConn
);
1409 EnterCriticalSection( &This
->unk
->DPL_lock
);
1411 hr
= DPLAYX_SetConnectionSettingsA( dwFlags
, dwAppID
, lpConn
);
1413 /* FIXME: Don't think that this is supposed to fail, but the docuementation
1414 is somewhat sketchy. I'll try creating a lobby application
1416 if( hr
== DPERR_NOTLOBBIED
)
1418 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1419 dwAppID
= GetCurrentProcessId();
1420 DPLAYX_CreateLobbyApplication( dwAppID
);
1421 hr
= DPLAYX_SetConnectionSettingsA( dwFlags
, dwAppID
, lpConn
);
1424 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1429 /********************************************************************
1431 * Registers an event that will be set when a lobby message is received.
1434 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1435 ( LPDIRECTPLAYLOBBYA iface
,
1438 HANDLE hReceiveEvent
)
1441 return DPERR_OUTOFMEMORY
;
1444 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1445 ( LPDIRECTPLAYLOBBY iface
,
1448 HANDLE hReceiveEvent
)
1451 return DPERR_OUTOFMEMORY
;
1456 static HRESULT WINAPI IDirectPlayLobby2WImpl_CreateCompoundAddress
1457 ( LPDIRECTPLAYLOBBY2 iface
,
1458 LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1459 DWORD dwElementCount
,
1461 LPDWORD lpdwAddressSize
)
1463 return DPL_CreateCompoundAddress( lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
, FALSE
);
1466 static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress
1467 ( LPDIRECTPLAYLOBBY2A iface
,
1468 LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1469 DWORD dwElementCount
,
1471 LPDWORD lpdwAddressSize
)
1473 return DPL_CreateCompoundAddress( lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
, TRUE
);
1476 HRESULT DPL_CreateCompoundAddress
1477 ( LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1478 DWORD dwElementCount
,
1480 LPDWORD lpdwAddressSize
,
1481 BOOL bAnsiInterface
)
1483 DWORD dwSizeRequired
= 0;
1485 LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements
= lpElements
;
1487 TRACE("(%p,0x%08lx,%p,%p)\n", lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
);
1489 /* Parameter check */
1490 if( ( lpElements
== NULL
) ||
1491 ( dwElementCount
== 0 ) /* FIXME: Not sure if this is a failure case */
1494 return DPERR_INVALIDPARAMS
;
1497 /* Add the total size chunk */
1498 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( DWORD
);
1500 /* Calculate the size of the buffer required */
1501 for ( dwElements
= dwElementCount
; dwElements
> 0; --dwElements
, ++lpElements
)
1503 if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ServiceProvider
) ) ||
1504 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_LobbyProvider
) )
1507 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( GUID
);
1509 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Phone
) ) ||
1510 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Modem
) ) ||
1511 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INet
) )
1514 if( !bAnsiInterface
)
1516 ERR( "Ansi GUIDs used for unicode interface\n" );
1517 return DPERR_INVALIDFLAGS
;
1520 dwSizeRequired
+= sizeof( DPADDRESS
) + lpElements
->dwDataSize
;
1522 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1523 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1524 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1527 if( bAnsiInterface
)
1529 ERR( "Unicode GUIDs used for ansi interface\n" );
1530 return DPERR_INVALIDFLAGS
;
1533 FIXME( "Right size for unicode interface?\n" );
1534 dwSizeRequired
+= sizeof( DPADDRESS
) + lpElements
->dwDataSize
* sizeof( WCHAR
);
1536 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1538 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( WORD
);
1540 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1542 FIXME( "Right size for unicode interface?\n" );
1543 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( DPCOMPORTADDRESS
); /* FIXME: Right size? */
1547 ERR( "Unknown GUID %s\n", debugstr_guid(&lpElements
->guidDataType
) );
1548 return DPERR_INVALIDFLAGS
;
1552 /* The user wants to know how big a buffer to allocate for us */
1553 if( ( lpAddress
== NULL
) ||
1554 ( *lpdwAddressSize
< dwSizeRequired
)
1557 *lpdwAddressSize
= dwSizeRequired
;
1558 return DPERR_BUFFERTOOSMALL
;
1561 /* Add the total size chunk */
1563 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1565 CopyMemory( &lpdpAddress
->guidDataType
, &DPAID_TotalSize
, sizeof( GUID
) );
1566 lpdpAddress
->dwDataSize
= sizeof( DWORD
);
1567 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1569 *(LPDWORD
)lpAddress
= dwSizeRequired
;
1570 lpAddress
= (char *) lpAddress
+ sizeof( DWORD
);
1573 /* Calculate the size of the buffer required */
1574 for( dwElements
= dwElementCount
, lpElements
= lpOrigElements
;
1576 --dwElements
, ++lpElements
)
1578 if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ServiceProvider
) ) ||
1579 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_LobbyProvider
) )
1582 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1584 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1586 lpdpAddress
->dwDataSize
= sizeof( GUID
);
1587 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1589 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( GUID
) );
1590 lpAddress
= (char *) lpAddress
+ sizeof( GUID
);
1592 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Phone
) ) ||
1593 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Modem
) ) ||
1594 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INet
) )
1597 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1599 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1601 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1602 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1604 lstrcpynA( (LPSTR
)lpAddress
,
1605 (LPCSTR
)lpElements
->lpData
,
1606 lpElements
->dwDataSize
);
1607 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
;
1609 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1610 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1611 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1614 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1616 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1618 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1619 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1621 lstrcpynW( (LPWSTR
)lpAddress
,
1622 (LPCWSTR
)lpElements
->lpData
,
1623 lpElements
->dwDataSize
);
1624 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
* sizeof( WCHAR
);
1626 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1628 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1630 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1632 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1633 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1635 *((LPWORD
)lpAddress
) = *((LPWORD
)lpElements
->lpData
);
1636 lpAddress
= (char *) lpAddress
+ sizeof( WORD
);
1638 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1640 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1642 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1644 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1645 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1647 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( DPADDRESS
) );
1648 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1657 static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
1658 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFIID riid
,
1659 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1661 ICOM_THIS( IDirectPlayLobbyAImpl
, iface
);
1662 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1665 static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
1666 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFIID riid
,
1667 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1669 ICOM_THIS( IDirectPlayLobbyAImpl
, iface
);
1670 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1673 static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
1674 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1680 static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
1681 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1687 static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
1688 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1694 static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
1695 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1701 static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
1702 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
)
1705 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1707 TRACE( "(%p)->(0x%08lx)\n", iface
, dwFlags
);
1709 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1711 /* FIXME: What is the correct error return code? */
1712 hr
= DPERR_NOTLOBBIED
;
1718 static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
1719 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
)
1722 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1724 TRACE( "(%p)->(0x%08lx)\n", iface
, dwFlags
);
1726 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1728 /* FIXME: What is the correct error return code? */
1729 hr
= DPERR_NOTLOBBIED
;
1736 /* Virtual Table definitions for DPL{1,2,3}{A,W} */
1738 /* Note: Hack so we can reuse the old functions without compiler warnings */
1739 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1740 # define XCAST(fun) (typeof(directPlayLobbyAVT.fun))
1742 # define XCAST(fun) (void*)
1745 /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
1746 /* All lobby 1 methods are exactly the same except QueryInterface */
1747 static struct ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyAVT
=
1749 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
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 ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyWVT
=
1780 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1782 XCAST(QueryInterface
)DPL_QueryInterface
,
1783 XCAST(AddRef
)DPL_AddRef
,
1784 XCAST(Release
)DPL_Release
,
1786 IDirectPlayLobbyWImpl_Connect
,
1787 IDirectPlayLobbyWImpl_CreateAddress
,
1788 IDirectPlayLobbyWImpl_EnumAddress
,
1789 IDirectPlayLobbyWImpl_EnumAddressTypes
,
1790 IDirectPlayLobbyWImpl_EnumLocalApplications
,
1791 IDirectPlayLobbyWImpl_GetConnectionSettings
,
1792 IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1793 IDirectPlayLobbyWImpl_RunApplication
,
1794 IDirectPlayLobbyWImpl_SendLobbyMessage
,
1795 IDirectPlayLobbyWImpl_SetConnectionSettings
,
1796 IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1800 /* Note: Hack so we can reuse the old functions without compiler warnings */
1801 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1802 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1804 # define XCAST(fun) (void*)
1807 /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
1808 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2AVT
=
1810 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1812 XCAST(QueryInterface
)DPL_QueryInterface
,
1813 XCAST(AddRef
)DPL_AddRef
,
1814 XCAST(Release
)DPL_Release
,
1816 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1817 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1818 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1819 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1820 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1821 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1822 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1823 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1824 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1825 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1826 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1828 IDirectPlayLobby2AImpl_CreateCompoundAddress
1832 /* Note: Hack so we can reuse the old functions without compiler warnings */
1833 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1834 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1836 # define XCAST(fun) (void*)
1839 /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
1840 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2WVT
=
1842 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1844 XCAST(QueryInterface
)DPL_QueryInterface
,
1845 XCAST(AddRef
)DPL_AddRef
,
1846 XCAST(Release
)DPL_Release
,
1848 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1849 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1850 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1851 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1852 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1853 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1854 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1855 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1856 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1857 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1858 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1860 IDirectPlayLobby2WImpl_CreateCompoundAddress
1864 /* Direct Play Lobby 3 (ascii) Virtual Table for methods */
1866 /* Note: Hack so we can reuse the old functions without compiler warnings */
1867 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1868 # define XCAST(fun) (typeof(directPlayLobby3AVT.fun))
1870 # define XCAST(fun) (void*)
1873 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3AVT
=
1875 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1876 XCAST(QueryInterface
)DPL_QueryInterface
,
1877 XCAST(AddRef
)DPL_AddRef
,
1878 XCAST(Release
)DPL_Release
,
1880 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1881 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1882 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1883 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1884 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1885 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1886 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1887 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1888 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1889 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1890 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1892 XCAST(CreateCompoundAddress
)IDirectPlayLobby2AImpl_CreateCompoundAddress
,
1894 IDirectPlayLobby3AImpl_ConnectEx
,
1895 IDirectPlayLobby3AImpl_RegisterApplication
,
1896 IDirectPlayLobby3AImpl_UnregisterApplication
,
1897 IDirectPlayLobby3AImpl_WaitForConnectionSettings
1901 /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
1903 /* Note: Hack so we can reuse the old functions without compiler warnings */
1904 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1905 # define XCAST(fun) (typeof(directPlayLobby3WVT.fun))
1907 # define XCAST(fun) (void*)
1910 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3WVT
=
1912 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1913 XCAST(QueryInterface
)DPL_QueryInterface
,
1914 XCAST(AddRef
)DPL_AddRef
,
1915 XCAST(Release
)DPL_Release
,
1917 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1918 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1919 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1920 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1921 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1922 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1923 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1924 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1925 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1926 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1927 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1929 XCAST(CreateCompoundAddress
)IDirectPlayLobby2WImpl_CreateCompoundAddress
,
1931 IDirectPlayLobby3WImpl_ConnectEx
,
1932 IDirectPlayLobby3WImpl_RegisterApplication
,
1933 IDirectPlayLobby3WImpl_UnregisterApplication
,
1934 IDirectPlayLobby3WImpl_WaitForConnectionSettings
1939 /*********************************************************
1941 * Direct Play Lobby Interface Implementation
1943 *********************************************************/
1945 /***************************************************************************
1946 * DirectPlayLobbyCreateA (DPLAYX.4)
1949 HRESULT WINAPI
DirectPlayLobbyCreateA( LPGUID lpGUIDDSP
,
1950 LPDIRECTPLAYLOBBYA
*lplpDPL
,
1955 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
1956 lpGUIDDSP
,lplpDPL
,lpUnk
,lpData
,dwDataSize
);
1958 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1959 * equal 0. These fields are mostly for future expansion.
1961 if ( lpGUIDDSP
|| lpData
|| dwDataSize
)
1964 return DPERR_INVALIDPARAMS
;
1970 ERR("Bad parameters!\n" );
1971 return CLASS_E_NOAGGREGATION
;
1974 return DPL_CreateInterface( &IID_IDirectPlayLobbyA
, (void**)lplpDPL
);
1977 /***************************************************************************
1978 * DirectPlayLobbyCreateW (DPLAYX.5)
1981 HRESULT WINAPI
DirectPlayLobbyCreateW( LPGUID lpGUIDDSP
,
1982 LPDIRECTPLAYLOBBY
*lplpDPL
,
1987 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
1988 lpGUIDDSP
,lplpDPL
,lpUnk
,lpData
,dwDataSize
);
1990 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1991 * equal 0. These fields are mostly for future expansion.
1993 if ( lpGUIDDSP
|| lpData
|| dwDataSize
)
1996 ERR("Bad parameters!\n" );
1997 return DPERR_INVALIDPARAMS
;
2003 ERR("Bad parameters!\n" );
2004 return CLASS_E_NOAGGREGATION
;
2007 return DPL_CreateInterface( &IID_IDirectPlayLobby
, (void**)lplpDPL
);