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
);
53 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 WINAPI
DPL_ConnectEx( IDirectPlayLobbyAImpl
* This
,
62 DWORD dwFlags
, REFIID riid
,
63 LPVOID
* lplpDP
, IUnknown
* pUnk
);
65 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
= (IDirectPlayLobbyAImpl
*)lpDPL
;
150 This
->unk
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->unk
) ) );
151 if ( This
->unk
== NULL
)
156 InitializeCriticalSection( &This
->unk
->DPL_lock
);
161 static BOOL
DPL_DestroyIUnknown( LPVOID lpDPL
)
163 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
165 DeleteCriticalSection( &This
->unk
->DPL_lock
);
166 HeapFree( GetProcessHeap(), 0, This
->unk
);
171 static BOOL
DPL_CreateLobby1( LPVOID lpDPL
)
173 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
175 This
->dpl
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->dpl
) ) );
176 if ( This
->dpl
== NULL
)
181 DPQ_INIT( This
->dpl
->msgs
);
186 static BOOL
DPL_DestroyLobby1( LPVOID lpDPL
)
188 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
190 if( This
->dpl
->dwMsgThread
)
192 FIXME( "Should kill the msg thread\n" );
195 DPQ_DELETEQ( This
->dpl
->msgs
, msgs
, LPDPLMSG
, cbDeleteElemFromHeap
);
197 /* Delete the contents */
198 HeapFree( GetProcessHeap(), 0, This
->dpl
);
203 static BOOL
DPL_CreateLobby2( LPVOID lpDPL
)
205 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)lpDPL
;
207 This
->dpl2
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->dpl2
) ) );
208 if ( This
->dpl2
== NULL
)
216 static BOOL
DPL_DestroyLobby2( LPVOID lpDPL
)
218 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)lpDPL
;
220 HeapFree( GetProcessHeap(), 0, This
->dpl2
);
225 static BOOL
DPL_CreateLobby3( LPVOID lpDPL
)
227 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)lpDPL
;
229 This
->dpl3
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->dpl3
) ) );
230 if ( This
->dpl3
== NULL
)
238 static BOOL
DPL_DestroyLobby3( LPVOID lpDPL
)
240 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)lpDPL
;
242 HeapFree( GetProcessHeap(), 0, This
->dpl3
);
248 /* The COM interface for upversioning an interface
249 * We've been given a GUID (riid) and we need to replace the present
250 * interface with that of the requested interface.
252 * Snip from some Microsoft document:
253 * There are four requirements for implementations of QueryInterface (In these
254 * cases, "must succeed" means "must succeed barring catastrophic failure."):
256 * * The set of interfaces accessible on an object through
257 * IUnknown::QueryInterface must be static, not dynamic. This means that
258 * if a call to QueryInterface for a pointer to a specified interface
259 * succeeds the first time, it must succeed again, and if it fails the
260 * first time, it must fail on all subsequent queries.
261 * * It must be symmetric ~W if a client holds a pointer to an interface on
262 * an object, and queries for that interface, the call must succeed.
263 * * It must be reflexive ~W if a client holding a pointer to one interface
264 * queries successfully for another, a query through the obtained pointer
265 * for the first interface must succeed.
266 * * It must be transitive ~W if a client holding a pointer to one interface
267 * queries successfully for a second, and through that pointer queries
268 * successfully for a third interface, a query for the first interface
269 * through the pointer for the third interface must succeed.
272 HRESULT DPL_CreateInterface
273 ( REFIID riid
, LPVOID
* ppvObj
)
275 TRACE( " for %s\n", debugstr_guid( riid
) );
277 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
278 sizeof( IDirectPlayLobbyWImpl
) );
280 if( *ppvObj
== NULL
)
282 return DPERR_OUTOFMEMORY
;
285 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
287 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)*ppvObj
;
288 This
->lpVtbl
= &directPlayLobbyWVT
;
290 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
292 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)*ppvObj
;
293 This
->lpVtbl
= &directPlayLobbyAVT
;
295 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
297 IDirectPlayLobby2WImpl
*This
= (IDirectPlayLobby2WImpl
*)*ppvObj
;
298 This
->lpVtbl
= &directPlayLobby2WVT
;
300 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
302 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)*ppvObj
;
303 This
->lpVtbl
= &directPlayLobby2AVT
;
305 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
307 IDirectPlayLobby3WImpl
*This
= (IDirectPlayLobby3WImpl
*)*ppvObj
;
308 This
->lpVtbl
= &directPlayLobby3WVT
;
310 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
312 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)*ppvObj
;
313 This
->lpVtbl
= &directPlayLobby3AVT
;
317 /* Unsupported interface */
318 HeapFree( GetProcessHeap(), 0, *ppvObj
);
321 return E_NOINTERFACE
;
325 if ( DPL_CreateIUnknown( *ppvObj
) &&
326 DPL_CreateLobby1( *ppvObj
) &&
327 DPL_CreateLobby2( *ppvObj
) &&
328 DPL_CreateLobby3( *ppvObj
)
331 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
335 /* Initialize failed, destroy it */
336 DPL_DestroyLobby3( *ppvObj
);
337 DPL_DestroyLobby2( *ppvObj
);
338 DPL_DestroyLobby1( *ppvObj
);
339 DPL_DestroyIUnknown( *ppvObj
);
340 HeapFree( GetProcessHeap(), 0, *ppvObj
);
343 return DPERR_NOMEMORY
;
346 static HRESULT WINAPI DPL_QueryInterface
347 ( LPDIRECTPLAYLOBBYA iface
,
351 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
352 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid( riid
), ppvObj
);
354 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
357 if( *ppvObj
== NULL
)
359 return DPERR_OUTOFMEMORY
;
362 CopyMemory( *ppvObj
, This
, sizeof( *This
) );
363 (*(IDirectPlayLobbyAImpl
**)ppvObj
)->ulInterfaceRef
= 0;
365 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
367 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)*ppvObj
;
368 This
->lpVtbl
= &directPlayLobbyWVT
;
370 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
372 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)*ppvObj
;
373 This
->lpVtbl
= &directPlayLobbyAVT
;
375 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
377 IDirectPlayLobby2WImpl
*This
= (IDirectPlayLobby2WImpl
*)*ppvObj
;
378 This
->lpVtbl
= &directPlayLobby2WVT
;
380 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
382 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)*ppvObj
;
383 This
->lpVtbl
= &directPlayLobby2AVT
;
385 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
387 IDirectPlayLobby3WImpl
*This
= (IDirectPlayLobby3WImpl
*)*ppvObj
;
388 This
->lpVtbl
= &directPlayLobby3WVT
;
390 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
392 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)*ppvObj
;
393 This
->lpVtbl
= &directPlayLobby3AVT
;
397 /* Unsupported interface */
398 HeapFree( GetProcessHeap(), 0, *ppvObj
);
401 return E_NOINTERFACE
;
404 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
410 * Simple procedure. Just increment the reference count to this
411 * structure and return the new reference count.
413 static ULONG WINAPI DPL_AddRef
414 ( LPDIRECTPLAYLOBBY iface
)
416 ULONG ulInterfaceRefCount
, ulObjRefCount
;
417 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
419 ulObjRefCount
= InterlockedIncrement( &This
->unk
->ulObjRef
);
420 ulInterfaceRefCount
= InterlockedIncrement( &This
->ulInterfaceRef
);
422 TRACE( "ref count incremented to %lu:%lu for %p\n",
423 ulInterfaceRefCount
, ulObjRefCount
, This
);
425 return ulObjRefCount
;
429 * Simple COM procedure. Decrease the reference count to this object.
430 * If the object no longer has any reference counts, free up the associated
433 static ULONG WINAPI DPL_Release
434 ( LPDIRECTPLAYLOBBYA iface
)
436 ULONG ulInterfaceRefCount
, ulObjRefCount
;
437 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
439 ulObjRefCount
= InterlockedDecrement( &This
->unk
->ulObjRef
);
440 ulInterfaceRefCount
= InterlockedDecrement( &This
->ulInterfaceRef
);
442 TRACE( "ref count decremented to %lu:%lu for %p\n",
443 ulInterfaceRefCount
, ulObjRefCount
, This
);
445 /* Deallocate if this is the last reference to the object */
446 if( ulObjRefCount
== 0 )
448 DPL_DestroyLobby3( This
);
449 DPL_DestroyLobby2( This
);
450 DPL_DestroyLobby1( This
);
451 DPL_DestroyIUnknown( This
);
454 if( ulInterfaceRefCount
== 0 )
456 HeapFree( GetProcessHeap(), 0, This
);
459 return ulInterfaceRefCount
;
463 /********************************************************************
465 * Connects an application to the session specified by the DPLCONNECTION
466 * structure currently stored with the DirectPlayLobby object.
468 * Returns an IDirectPlay interface.
471 static HRESULT WINAPI DPL_ConnectEx
472 ( IDirectPlayLobbyAImpl
* This
,
479 DWORD dwOpenFlags
= 0;
480 DWORD dwConnSize
= 0;
481 LPDPLCONNECTION lpConn
;
483 FIXME("(%p)->(0x%08lx,%p,%p): semi stub\n", This
, dwFlags
, lplpDP
, pUnk
);
487 return DPERR_INVALIDPARAMS
;
490 /* Backwards compatibility */
493 dwFlags
= DPCONNECT_RETURNSTATUS
;
496 /* Create the DirectPlay interface */
497 if( ( hr
= DP_CreateInterface( 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 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%08lx,%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%08lx,%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%08lx,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
675 dwAddressSize
, lpContext
);
677 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
680 extern 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
= (const DPADDRESS
*)lpAddress
;
690 DWORD dwSizeThisEnumeration
;
692 /* Invoke the enum method. If false is returned, stop enumeration */
693 if ( !lpEnumAddressCallback( &lpElements
->guidDataType
,
694 lpElements
->dwDataSize
,
695 (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%08lx)\n", This
, lpEnumAddressTypeCallback
, guidSP
, lpContext
, dwFlags
);
734 return DPERR_INVALIDPARAMS
;
737 if( !lpEnumAddressTypeCallback
|| !*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%08lx):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%08lx)\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
890 return DPERR_INVALIDPARAMS
;
893 if( !lpEnumLocalAppCallback
|| !*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%08lx,%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%08lx,%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 %08lx %08lx %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 %08lx %08lx %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 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%08lx,%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
,
1237 (LPVOID
)(&enumData
), 0 );
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%08lx\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%08lx\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%08lx,%p,%p,%p):stub\n", This
, dwFlags
, lpdwAppID
, lpConn
, (void *)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%08lx,0x%08lx,%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 docuementation
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%08lx,0x%08lx,%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 docuementation
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%08lx,%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
= (LPDPADDRESS
)lpAddress
;
1575 CopyMemory( &lpdpAddress
->guidDataType
, &DPAID_TotalSize
, sizeof( GUID
) );
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
= (LPDPADDRESS
)lpAddress
;
1594 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1596 lpdpAddress
->dwDataSize
= sizeof( GUID
);
1597 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1599 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( GUID
) );
1600 lpAddress
= (char *) lpAddress
+ sizeof( GUID
);
1602 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Phone
) ) ||
1603 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Modem
) ) ||
1604 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INet
) )
1607 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1609 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1611 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1612 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1614 lstrcpynA( (LPSTR
)lpAddress
,
1615 (LPCSTR
)lpElements
->lpData
,
1616 lpElements
->dwDataSize
);
1617 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
;
1619 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1620 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1621 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1624 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1626 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1628 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1629 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1631 lstrcpynW( (LPWSTR
)lpAddress
,
1632 (LPCWSTR
)lpElements
->lpData
,
1633 lpElements
->dwDataSize
);
1634 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
* sizeof( WCHAR
);
1636 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1638 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1640 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1642 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1643 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1645 *((LPWORD
)lpAddress
) = *((LPWORD
)lpElements
->lpData
);
1646 lpAddress
= (char *) lpAddress
+ sizeof( WORD
);
1648 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1650 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1652 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1654 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1655 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1657 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( DPADDRESS
) );
1658 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1667 static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
1668 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFIID riid
,
1669 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1671 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1672 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1675 static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
1676 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFIID riid
,
1677 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1679 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1680 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1683 static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
1684 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1690 static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
1691 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1697 static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
1698 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1704 static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
1705 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1711 static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
1712 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
)
1715 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1717 TRACE( "(%p)->(0x%08lx)\n", iface
, dwFlags
);
1719 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1721 /* FIXME: What is the correct error return code? */
1722 hr
= DPERR_NOTLOBBIED
;
1728 static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
1729 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
)
1732 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1734 TRACE( "(%p)->(0x%08lx)\n", iface
, dwFlags
);
1736 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1738 /* FIXME: What is the correct error return code? */
1739 hr
= DPERR_NOTLOBBIED
;
1746 /* Virtual Table definitions for DPL{1,2,3}{A,W} */
1748 /* Note: Hack so we can reuse the old functions without compiler warnings */
1749 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1750 # define XCAST(fun) (typeof(directPlayLobbyAVT.fun))
1752 # define XCAST(fun) (void*)
1755 /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
1756 /* All lobby 1 methods are exactly the same except QueryInterface */
1757 static const IDirectPlayLobbyVtbl directPlayLobbyAVT
=
1760 XCAST(QueryInterface
)DPL_QueryInterface
,
1761 XCAST(AddRef
)DPL_AddRef
,
1762 XCAST(Release
)DPL_Release
,
1764 IDirectPlayLobbyAImpl_Connect
,
1765 IDirectPlayLobbyAImpl_CreateAddress
,
1766 IDirectPlayLobbyAImpl_EnumAddress
,
1767 IDirectPlayLobbyAImpl_EnumAddressTypes
,
1768 IDirectPlayLobbyAImpl_EnumLocalApplications
,
1769 IDirectPlayLobbyAImpl_GetConnectionSettings
,
1770 IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1771 IDirectPlayLobbyAImpl_RunApplication
,
1772 IDirectPlayLobbyAImpl_SendLobbyMessage
,
1773 IDirectPlayLobbyAImpl_SetConnectionSettings
,
1774 IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1779 /* Note: Hack so we can reuse the old functions without compiler warnings */
1780 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1781 # define XCAST(fun) (typeof(directPlayLobbyWVT.fun))
1783 # define XCAST(fun) (void*)
1786 /* Direct Play Lobby 1 (unicode) Virtual Table for methods */
1787 static const IDirectPlayLobbyVtbl directPlayLobbyWVT
=
1790 XCAST(QueryInterface
)DPL_QueryInterface
,
1791 XCAST(AddRef
)DPL_AddRef
,
1792 XCAST(Release
)DPL_Release
,
1794 IDirectPlayLobbyWImpl_Connect
,
1795 IDirectPlayLobbyWImpl_CreateAddress
,
1796 IDirectPlayLobbyWImpl_EnumAddress
,
1797 IDirectPlayLobbyWImpl_EnumAddressTypes
,
1798 IDirectPlayLobbyWImpl_EnumLocalApplications
,
1799 IDirectPlayLobbyWImpl_GetConnectionSettings
,
1800 IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1801 IDirectPlayLobbyWImpl_RunApplication
,
1802 IDirectPlayLobbyWImpl_SendLobbyMessage
,
1803 IDirectPlayLobbyWImpl_SetConnectionSettings
,
1804 IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1808 /* Note: Hack so we can reuse the old functions without compiler warnings */
1809 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1810 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1812 # define XCAST(fun) (void*)
1815 /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
1816 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT
=
1819 XCAST(QueryInterface
)DPL_QueryInterface
,
1820 XCAST(AddRef
)DPL_AddRef
,
1821 XCAST(Release
)DPL_Release
,
1823 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1824 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1825 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1826 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1827 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1828 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1829 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1830 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1831 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1832 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1833 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1835 IDirectPlayLobby2AImpl_CreateCompoundAddress
1839 /* Note: Hack so we can reuse the old functions without compiler warnings */
1840 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1841 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1843 # define XCAST(fun) (void*)
1846 /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
1847 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT
=
1850 XCAST(QueryInterface
)DPL_QueryInterface
,
1851 XCAST(AddRef
)DPL_AddRef
,
1852 XCAST(Release
)DPL_Release
,
1854 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1855 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1856 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1857 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1858 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1859 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1860 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1861 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1862 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1863 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1864 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1866 IDirectPlayLobby2WImpl_CreateCompoundAddress
1870 /* Direct Play Lobby 3 (ascii) Virtual Table for methods */
1872 /* Note: Hack so we can reuse the old functions without compiler warnings */
1873 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1874 # define XCAST(fun) (typeof(directPlayLobby3AVT.fun))
1876 # define XCAST(fun) (void*)
1879 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT
=
1881 XCAST(QueryInterface
)DPL_QueryInterface
,
1882 XCAST(AddRef
)DPL_AddRef
,
1883 XCAST(Release
)DPL_Release
,
1885 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1886 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1887 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1888 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1889 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1890 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1891 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1892 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1893 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1894 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1895 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1897 XCAST(CreateCompoundAddress
)IDirectPlayLobby2AImpl_CreateCompoundAddress
,
1899 IDirectPlayLobby3AImpl_ConnectEx
,
1900 IDirectPlayLobby3AImpl_RegisterApplication
,
1901 IDirectPlayLobby3AImpl_UnregisterApplication
,
1902 IDirectPlayLobby3AImpl_WaitForConnectionSettings
1906 /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
1908 /* Note: Hack so we can reuse the old functions without compiler warnings */
1909 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1910 # define XCAST(fun) (typeof(directPlayLobby3WVT.fun))
1912 # define XCAST(fun) (void*)
1915 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT
=
1917 XCAST(QueryInterface
)DPL_QueryInterface
,
1918 XCAST(AddRef
)DPL_AddRef
,
1919 XCAST(Release
)DPL_Release
,
1921 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1922 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1923 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1924 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1925 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1926 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1927 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1928 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1929 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1930 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1931 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1933 XCAST(CreateCompoundAddress
)IDirectPlayLobby2WImpl_CreateCompoundAddress
,
1935 IDirectPlayLobby3WImpl_ConnectEx
,
1936 IDirectPlayLobby3WImpl_RegisterApplication
,
1937 IDirectPlayLobby3WImpl_UnregisterApplication
,
1938 IDirectPlayLobby3WImpl_WaitForConnectionSettings
1943 /*********************************************************
1945 * Direct Play Lobby Interface Implementation
1947 *********************************************************/
1949 /***************************************************************************
1950 * DirectPlayLobbyCreateA (DPLAYX.4)
1953 HRESULT WINAPI
DirectPlayLobbyCreateA( LPGUID lpGUIDDSP
,
1954 LPDIRECTPLAYLOBBYA
*lplpDPL
,
1959 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
1960 lpGUIDDSP
,lplpDPL
,lpUnk
,lpData
,dwDataSize
);
1962 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1963 * equal 0. These fields are mostly for future expansion.
1965 if ( lpGUIDDSP
|| lpData
|| dwDataSize
)
1968 return DPERR_INVALIDPARAMS
;
1974 ERR("Bad parameters!\n" );
1975 return CLASS_E_NOAGGREGATION
;
1978 return DPL_CreateInterface( &IID_IDirectPlayLobbyA
, (void**)lplpDPL
);
1981 /***************************************************************************
1982 * DirectPlayLobbyCreateW (DPLAYX.5)
1985 HRESULT WINAPI
DirectPlayLobbyCreateW( LPGUID lpGUIDDSP
,
1986 LPDIRECTPLAYLOBBY
*lplpDPL
,
1991 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
1992 lpGUIDDSP
,lplpDPL
,lpUnk
,lpData
,dwDataSize
);
1994 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1995 * equal 0. These fields are mostly for future expansion.
1997 if ( lpGUIDDSP
|| lpData
|| dwDataSize
)
2000 ERR("Bad parameters!\n" );
2001 return DPERR_INVALIDPARAMS
;
2007 ERR("Bad parameters!\n" );
2008 return CLASS_E_NOAGGREGATION
;
2011 return DPL_CreateInterface( &IID_IDirectPlayLobby
, (void**)lplpDPL
);