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 static HRESULT
DPL_CreateAddress( REFGUID guidSP
, REFGUID guidDataType
, LPCVOID lpData
, DWORD dwDataSize
,
54 LPVOID lpAddress
, LPDWORD lpdwAddressSize
, BOOL bAnsiInterface
);
58 extern HRESULT
DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
, LPCVOID lpAddress
,
59 DWORD dwAddressSize
, LPVOID lpContext
);
61 static HRESULT
DPL_ConnectEx( IDirectPlayLobbyAImpl
* This
,
62 DWORD dwFlags
, REFIID riid
,
63 LPVOID
* lplpDP
, IUnknown
* pUnk
);
65 static BOOL
DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId
, HANDLE hDestProcess
,
66 LPHANDLE lphStart
, LPHANDLE lphDeath
,
70 /*****************************************************************************
71 * IDirectPlayLobby {1,2,3} implementation structure
73 * The philosophy behind this extra pointer dereference is that I wanted to
74 * have the same structure for all types of objects without having to do
75 * a lot of casting. I also only wanted to implement an interface in the
76 * object it was "released" with IUnknown interface being implemented in the 1 version.
77 * Of course, with these new interfaces comes the data required to keep the state required
78 * by these interfaces. So, basically, the pointers contain the data associated with
79 * a release. If you use the data associated with release 3 in a release 2 object, you'll
80 * get a run time trap, as that won't have any data.
85 DPQ_ENTRY( DPLMSG
) msgs
; /* Link to next queued message */
87 typedef struct DPLMSG
* LPDPLMSG
;
89 typedef struct tagDirectPlayLobbyIUnknownData
92 CRITICAL_SECTION DPL_lock
;
93 } DirectPlayLobbyIUnknownData
;
95 typedef struct tagDirectPlayLobbyData
97 HKEY hkCallbackKeyHack
;
99 DPQ_HEAD( DPLMSG
) msgs
; /* List of messages received */
100 } DirectPlayLobbyData
;
102 typedef struct tagDirectPlayLobby2Data
105 } DirectPlayLobby2Data
;
107 typedef struct tagDirectPlayLobby3Data
110 } DirectPlayLobby3Data
;
112 #define DPL_IMPL_FIELDS \
113 LONG ulInterfaceRef; \
114 DirectPlayLobbyIUnknownData* unk; \
115 DirectPlayLobbyData* dpl; \
116 DirectPlayLobby2Data* dpl2; \
117 DirectPlayLobby3Data* dpl3;
119 struct IDirectPlayLobbyImpl
121 const IDirectPlayLobbyVtbl
*lpVtbl
;
125 struct IDirectPlayLobby2Impl
127 const IDirectPlayLobby2Vtbl
*lpVtbl
;
131 struct IDirectPlayLobby3Impl
133 const IDirectPlayLobby3Vtbl
*lpVtbl
;
137 /* Forward declarations of virtual tables */
138 static const IDirectPlayLobbyVtbl directPlayLobbyWVT
;
139 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT
;
140 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT
;
142 static const IDirectPlayLobbyVtbl directPlayLobbyAVT
;
143 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT
;
144 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT
;
146 static BOOL
DPL_CreateIUnknown( LPVOID lpDPL
)
148 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
150 This
->unk
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->unk
) ) );
151 if ( This
->unk
== NULL
)
156 InitializeCriticalSection( &This
->unk
->DPL_lock
);
157 This
->unk
->DPL_lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IDirectPlayLobbyAImpl*->DirectPlayLobbyIUnknownData*->DPL_lock");
162 static BOOL
DPL_DestroyIUnknown( LPVOID lpDPL
)
164 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
166 This
->unk
->DPL_lock
.DebugInfo
->Spare
[0] = 0;
167 DeleteCriticalSection( &This
->unk
->DPL_lock
);
168 HeapFree( GetProcessHeap(), 0, This
->unk
);
173 static BOOL
DPL_CreateLobby1( LPVOID lpDPL
)
175 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
177 This
->dpl
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->dpl
) ) );
178 if ( This
->dpl
== NULL
)
183 DPQ_INIT( This
->dpl
->msgs
);
188 static BOOL
DPL_DestroyLobby1( LPVOID lpDPL
)
190 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)lpDPL
;
192 if( This
->dpl
->dwMsgThread
)
194 FIXME( "Should kill the msg thread\n" );
197 DPQ_DELETEQ( This
->dpl
->msgs
, msgs
, LPDPLMSG
, cbDeleteElemFromHeap
);
199 /* Delete the contents */
200 HeapFree( GetProcessHeap(), 0, This
->dpl
);
205 static BOOL
DPL_CreateLobby2( LPVOID lpDPL
)
207 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)lpDPL
;
209 This
->dpl2
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->dpl2
) ) );
210 if ( This
->dpl2
== NULL
)
218 static BOOL
DPL_DestroyLobby2( LPVOID lpDPL
)
220 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)lpDPL
;
222 HeapFree( GetProcessHeap(), 0, This
->dpl2
);
227 static BOOL
DPL_CreateLobby3( LPVOID lpDPL
)
229 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)lpDPL
;
231 This
->dpl3
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof( *(This
->dpl3
) ) );
232 if ( This
->dpl3
== NULL
)
240 static BOOL
DPL_DestroyLobby3( LPVOID lpDPL
)
242 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)lpDPL
;
244 HeapFree( GetProcessHeap(), 0, This
->dpl3
);
250 /* The COM interface for upversioning an interface
251 * We've been given a GUID (riid) and we need to replace the present
252 * interface with that of the requested interface.
254 * Snip from some Microsoft document:
255 * There are four requirements for implementations of QueryInterface (In these
256 * cases, "must succeed" means "must succeed barring catastrophic failure."):
258 * * The set of interfaces accessible on an object through
259 * IUnknown::QueryInterface must be static, not dynamic. This means that
260 * if a call to QueryInterface for a pointer to a specified interface
261 * succeeds the first time, it must succeed again, and if it fails the
262 * first time, it must fail on all subsequent queries.
263 * * It must be symmetric ~W if a client holds a pointer to an interface on
264 * an object, and queries for that interface, the call must succeed.
265 * * It must be reflexive ~W if a client holding a pointer to one interface
266 * queries successfully for another, a query through the obtained pointer
267 * for the first interface must succeed.
268 * * It must be transitive ~W if a client holding a pointer to one interface
269 * queries successfully for a second, and through that pointer queries
270 * successfully for a third interface, a query for the first interface
271 * through the pointer for the third interface must succeed.
273 HRESULT DPL_CreateInterface
274 ( REFIID riid
, LPVOID
* ppvObj
)
276 TRACE( " for %s\n", debugstr_guid( riid
) );
278 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
279 sizeof( IDirectPlayLobbyWImpl
) );
281 if( *ppvObj
== NULL
)
283 return DPERR_OUTOFMEMORY
;
286 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
288 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)*ppvObj
;
289 This
->lpVtbl
= &directPlayLobbyWVT
;
291 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
293 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)*ppvObj
;
294 This
->lpVtbl
= &directPlayLobbyAVT
;
296 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
298 IDirectPlayLobby2WImpl
*This
= (IDirectPlayLobby2WImpl
*)*ppvObj
;
299 This
->lpVtbl
= &directPlayLobby2WVT
;
301 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
303 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)*ppvObj
;
304 This
->lpVtbl
= &directPlayLobby2AVT
;
306 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
308 IDirectPlayLobby3WImpl
*This
= (IDirectPlayLobby3WImpl
*)*ppvObj
;
309 This
->lpVtbl
= &directPlayLobby3WVT
;
311 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
313 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)*ppvObj
;
314 This
->lpVtbl
= &directPlayLobby3AVT
;
318 /* Unsupported interface */
319 HeapFree( GetProcessHeap(), 0, *ppvObj
);
322 return E_NOINTERFACE
;
326 if ( DPL_CreateIUnknown( *ppvObj
) &&
327 DPL_CreateLobby1( *ppvObj
) &&
328 DPL_CreateLobby2( *ppvObj
) &&
329 DPL_CreateLobby3( *ppvObj
)
332 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
336 /* Initialize failed, destroy it */
337 DPL_DestroyLobby3( *ppvObj
);
338 DPL_DestroyLobby2( *ppvObj
);
339 DPL_DestroyLobby1( *ppvObj
);
340 DPL_DestroyIUnknown( *ppvObj
);
341 HeapFree( GetProcessHeap(), 0, *ppvObj
);
344 return DPERR_NOMEMORY
;
347 static HRESULT WINAPI DPL_QueryInterface
348 ( LPDIRECTPLAYLOBBYA iface
,
352 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
353 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid( riid
), ppvObj
);
355 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
358 if( *ppvObj
== NULL
)
360 return DPERR_OUTOFMEMORY
;
363 CopyMemory( *ppvObj
, This
, sizeof( *This
) );
364 (*(IDirectPlayLobbyAImpl
**)ppvObj
)->ulInterfaceRef
= 0;
366 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
368 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)*ppvObj
;
369 This
->lpVtbl
= &directPlayLobbyWVT
;
371 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
373 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)*ppvObj
;
374 This
->lpVtbl
= &directPlayLobbyAVT
;
376 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
378 IDirectPlayLobby2WImpl
*This
= (IDirectPlayLobby2WImpl
*)*ppvObj
;
379 This
->lpVtbl
= &directPlayLobby2WVT
;
381 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
383 IDirectPlayLobby2AImpl
*This
= (IDirectPlayLobby2AImpl
*)*ppvObj
;
384 This
->lpVtbl
= &directPlayLobby2AVT
;
386 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
388 IDirectPlayLobby3WImpl
*This
= (IDirectPlayLobby3WImpl
*)*ppvObj
;
389 This
->lpVtbl
= &directPlayLobby3WVT
;
391 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
393 IDirectPlayLobby3AImpl
*This
= (IDirectPlayLobby3AImpl
*)*ppvObj
;
394 This
->lpVtbl
= &directPlayLobby3AVT
;
398 /* Unsupported interface */
399 HeapFree( GetProcessHeap(), 0, *ppvObj
);
402 return E_NOINTERFACE
;
405 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
411 * Simple procedure. Just increment the reference count to this
412 * structure and return the new reference count.
414 static ULONG WINAPI DPL_AddRef
415 ( LPDIRECTPLAYLOBBY iface
)
417 ULONG ulInterfaceRefCount
, ulObjRefCount
;
418 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
420 ulObjRefCount
= InterlockedIncrement( &This
->unk
->ulObjRef
);
421 ulInterfaceRefCount
= InterlockedIncrement( &This
->ulInterfaceRef
);
423 TRACE( "ref count incremented to %u:%u for %p\n",
424 ulInterfaceRefCount
, ulObjRefCount
, This
);
426 return ulObjRefCount
;
430 * Simple COM procedure. Decrease the reference count to this object.
431 * If the object no longer has any reference counts, free up the associated
434 static ULONG WINAPI DPL_Release
435 ( LPDIRECTPLAYLOBBYA iface
)
437 ULONG ulInterfaceRefCount
, ulObjRefCount
;
438 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
440 ulObjRefCount
= InterlockedDecrement( &This
->unk
->ulObjRef
);
441 ulInterfaceRefCount
= InterlockedDecrement( &This
->ulInterfaceRef
);
443 TRACE( "ref count decremented to %u:%u for %p\n",
444 ulInterfaceRefCount
, ulObjRefCount
, This
);
446 /* Deallocate if this is the last reference to the object */
447 if( ulObjRefCount
== 0 )
449 DPL_DestroyLobby3( This
);
450 DPL_DestroyLobby2( This
);
451 DPL_DestroyLobby1( This
);
452 DPL_DestroyIUnknown( This
);
455 if( ulInterfaceRefCount
== 0 )
457 HeapFree( GetProcessHeap(), 0, This
);
460 return ulInterfaceRefCount
;
464 /********************************************************************
466 * Connects an application to the session specified by the DPLCONNECTION
467 * structure currently stored with the DirectPlayLobby object.
469 * Returns an IDirectPlay interface.
472 static HRESULT DPL_ConnectEx
473 ( IDirectPlayLobbyAImpl
* This
,
480 DWORD dwOpenFlags
= 0;
481 DWORD dwConnSize
= 0;
482 LPDPLCONNECTION lpConn
;
484 FIXME("(%p)->(0x%08x,%p,%p): semi stub\n", This
, dwFlags
, lplpDP
, pUnk
);
488 return DPERR_INVALIDPARAMS
;
491 /* Backwards compatibility */
494 dwFlags
= DPCONNECT_RETURNSTATUS
;
497 /* Create the DirectPlay interface */
498 if( ( hr
= DP_CreateInterface( riid
, lplpDP
) ) != DP_OK
)
500 ERR( "error creating interface for %s:%s.\n",
501 debugstr_guid( riid
), DPLAYX_HresultToString( hr
) );
505 /* FIXME: Is it safe/correct to use appID of 0? */
506 hr
= IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY
)This
,
507 0, NULL
, &dwConnSize
);
508 if( hr
!= DPERR_BUFFERTOOSMALL
)
513 lpConn
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwConnSize
);
517 return DPERR_NOMEMORY
;
520 /* FIXME: Is it safe/correct to use appID of 0? */
521 hr
= IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY
)This
,
522 0, lpConn
, &dwConnSize
);
525 HeapFree( GetProcessHeap(), 0, lpConn
);
530 /* - Need to call IDirectPlay::EnumConnections with the service provider to get that good information
531 * - Need to call CreateAddress to create the lpConnection param for IDirectPlay::InitializeConnection
532 * - Call IDirectPlay::InitializeConnection
535 /* Now initialize the Service Provider */
536 hr
= IDirectPlayX_InitializeConnection( (*(LPDIRECTPLAY2
*)lplpDP
),
540 /* Setup flags to pass into DirectPlay::Open */
541 if( dwFlags
& DPCONNECT_RETURNSTATUS
)
543 dwOpenFlags
|= DPOPEN_RETURNSTATUS
;
545 dwOpenFlags
|= lpConn
->dwFlags
;
547 hr
= IDirectPlayX_Open( (*(LPDIRECTPLAY2
*)lplpDP
), lpConn
->lpSessionDesc
,
550 HeapFree( GetProcessHeap(), 0, lpConn
);
555 static HRESULT WINAPI IDirectPlayLobbyAImpl_Connect
556 ( LPDIRECTPLAYLOBBYA iface
,
558 LPDIRECTPLAY2A
* lplpDP
,
561 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
562 return DPL_ConnectEx( This
, dwFlags
, &IID_IDirectPlay2A
,
563 (LPVOID
)lplpDP
, pUnk
);
566 static HRESULT WINAPI IDirectPlayLobbyWImpl_Connect
567 ( LPDIRECTPLAYLOBBY iface
,
569 LPDIRECTPLAY2
* lplpDP
,
572 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
; /* Yes cast to A */
573 return DPL_ConnectEx( This
, dwFlags
, &IID_IDirectPlay2
,
574 (LPVOID
)lplpDP
, pUnk
);
577 /********************************************************************
579 * Creates a DirectPlay Address, given a service provider-specific network
581 * Returns an address contains the globally unique identifier
582 * (GUID) of the service provider and data that the service provider can
583 * interpret as a network address.
585 * NOTE: It appears that this method is supposed to be really really stupid
586 * with no error checking on the contents.
588 static HRESULT WINAPI IDirectPlayLobbyAImpl_CreateAddress
589 ( LPDIRECTPLAYLOBBYA iface
,
591 REFGUID guidDataType
,
595 LPDWORD lpdwAddressSize
)
597 return DPL_CreateAddress( guidSP
, guidDataType
, lpData
, dwDataSize
,
598 lpAddress
, lpdwAddressSize
, TRUE
);
601 static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress
602 ( LPDIRECTPLAYLOBBY iface
,
604 REFGUID guidDataType
,
608 LPDWORD lpdwAddressSize
)
610 return DPL_CreateAddress( guidSP
, guidDataType
, lpData
, dwDataSize
,
611 lpAddress
, lpdwAddressSize
, FALSE
);
614 static HRESULT
DPL_CreateAddress(
616 REFGUID guidDataType
,
620 LPDWORD lpdwAddressSize
,
621 BOOL bAnsiInterface
)
623 const DWORD dwNumAddElements
= 2; /* Service Provide & address data type */
624 DPCOMPOUNDADDRESSELEMENT addressElements
[ 2 /* dwNumAddElements */ ];
626 TRACE( "(%p)->(%p,%p,0x%08x,%p,%p,%d)\n", guidSP
, guidDataType
, lpData
, dwDataSize
,
627 lpAddress
, lpdwAddressSize
, bAnsiInterface
);
629 addressElements
[ 0 ].guidDataType
= DPAID_ServiceProvider
;
630 addressElements
[ 0 ].dwDataSize
= sizeof( GUID
);
631 addressElements
[ 0 ].lpData
= (LPVOID
)guidSP
;
633 addressElements
[ 1 ].guidDataType
= *guidDataType
;
634 addressElements
[ 1 ].dwDataSize
= dwDataSize
;
635 addressElements
[ 1 ].lpData
= (LPVOID
)lpData
;
637 /* Call CreateCompoundAddress to cut down on code.
638 NOTE: We can do this because we don't support DPL 1 interfaces! */
639 return DPL_CreateCompoundAddress( addressElements
, dwNumAddElements
,
640 lpAddress
, lpdwAddressSize
, bAnsiInterface
);
645 /********************************************************************
647 * Parses out chunks from the DirectPlay Address buffer by calling the
648 * given callback function, with lpContext, for each of the chunks.
651 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress
652 ( LPDIRECTPLAYLOBBYA iface
,
653 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
,
658 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
660 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
661 dwAddressSize
, lpContext
);
663 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
666 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress
667 ( LPDIRECTPLAYLOBBY iface
,
668 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
,
673 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
675 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
676 dwAddressSize
, lpContext
);
678 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
681 HRESULT
DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
, LPCVOID lpAddress
,
682 DWORD dwAddressSize
, LPVOID lpContext
)
684 DWORD dwTotalSizeEnumerated
= 0;
686 /* FIXME: First chunk is always the total size chunk - Should we report it? */
688 while ( dwTotalSizeEnumerated
< dwAddressSize
)
690 const DPADDRESS
* lpElements
= (const DPADDRESS
*)lpAddress
;
691 DWORD dwSizeThisEnumeration
;
693 /* Invoke the enum method. If false is returned, stop enumeration */
694 if ( !lpEnumAddressCallback( &lpElements
->guidDataType
,
695 lpElements
->dwDataSize
,
696 (const BYTE
*)lpElements
+ sizeof( DPADDRESS
),
702 dwSizeThisEnumeration
= sizeof( DPADDRESS
) + lpElements
->dwDataSize
;
703 lpAddress
= (const BYTE
*) lpAddress
+ dwSizeThisEnumeration
;
704 dwTotalSizeEnumerated
+= dwSizeThisEnumeration
;
710 /********************************************************************
712 * Enumerates all the address types that a given service provider needs to
713 * build the DirectPlay Address.
716 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
717 ( LPDIRECTPLAYLOBBYA iface
,
718 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback
,
723 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
726 LPCSTR searchSubKey
= "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
727 DWORD dwIndex
, sizeOfSubKeyName
=50;
731 TRACE(" (%p)->(%p,%p,%p,0x%08x)\n", This
, lpEnumAddressTypeCallback
, guidSP
, lpContext
, dwFlags
);
735 return DPERR_INVALIDPARAMS
;
738 if( !lpEnumAddressTypeCallback
)
740 return DPERR_INVALIDPARAMS
;
745 return DPERR_INVALIDOBJECT
;
748 /* Need to loop over the service providers in the registry */
749 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE
, searchSubKey
,
750 0, KEY_READ
, &hkResult
) != ERROR_SUCCESS
)
752 /* Hmmm. Does this mean that there are no service providers? */
753 ERR(": no service providers?\n");
757 /* Traverse all the service providers we have available */
759 RegEnumKeyExA( hkResult
, dwIndex
, subKeyName
, &sizeOfSubKeyName
,
760 NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
761 ++dwIndex
, sizeOfSubKeyName
=50 )
764 HKEY hkServiceProvider
, hkServiceProviderAt
;
765 GUID serviceProviderGUID
;
766 DWORD returnTypeGUID
, sizeOfReturnBuffer
= 50;
768 char returnBuffer
[51];
771 LPCSTR atKey
= "Address Types";
772 LPCSTR guidDataSubKey
= "Guid";
776 TRACE(" this time through: %s\n", subKeyName
);
778 /* Get a handle for this particular service provider */
779 if( RegOpenKeyExA( hkResult
, subKeyName
, 0, KEY_READ
,
780 &hkServiceProvider
) != ERROR_SUCCESS
)
782 ERR(": what the heck is going on?\n" );
786 if( RegQueryValueExA( hkServiceProvider
, guidDataSubKey
,
787 NULL
, &returnTypeGUID
, (LPBYTE
)returnBuffer
,
788 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
790 ERR(": missing GUID registry data members\n" );
794 /* FIXME: Check return types to ensure we're interpreting data right */
795 MultiByteToWideChar( CP_ACP
, 0, returnBuffer
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
796 CLSIDFromString( buff
, &serviceProviderGUID
);
797 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
799 /* Determine if this is the Service Provider that the user asked for */
800 if( !IsEqualGUID( &serviceProviderGUID
, guidSP
) )
805 /* Get a handle for this particular service provider */
806 if( RegOpenKeyExA( hkServiceProvider
, atKey
, 0, KEY_READ
,
807 &hkServiceProviderAt
) != ERROR_SUCCESS
)
809 TRACE(": No Address Types registry data sub key/members\n" );
813 /* Traverse all the address type we have available */
815 RegEnumKeyExA( hkServiceProviderAt
, dwAtIndex
, atSubKey
, &sizeOfSubKeyName
,
816 NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
817 ++dwAtIndex
, sizeOfSubKeyName
=50 )
819 TRACE( "Found Address Type GUID %s\n", atSubKey
);
821 /* FIXME: Check return types to ensure we're interpreting data right */
822 MultiByteToWideChar( CP_ACP
, 0, atSubKey
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
823 CLSIDFromString( buff
, &serviceProviderGUID
);
824 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
826 /* The enumeration will return FALSE if we are not to continue */
827 if( !lpEnumAddressTypeCallback( &serviceProviderGUID
, lpContext
, 0 ) )
829 WARN("lpEnumCallback returning FALSE\n" );
830 break; /* FIXME: This most likely has to break from the procedure...*/
835 /* We only enumerate address types for 1 GUID. We've found it, so quit looking */
842 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddressTypes
843 ( LPDIRECTPLAYLOBBY iface
,
844 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback
,
850 return DPERR_OUTOFMEMORY
;
853 /********************************************************************
855 * Enumerates what applications are registered with DirectPlay by
856 * invoking the callback function with lpContext.
859 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications
860 ( LPDIRECTPLAYLOBBY iface
,
861 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback
,
865 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
867 FIXME("(%p)->(%p,%p,0x%08x):stub\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
869 return DPERR_OUTOFMEMORY
;
872 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
873 ( LPDIRECTPLAYLOBBYA iface
,
874 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback
,
878 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
881 LPCSTR searchSubKey
= "SOFTWARE\\Microsoft\\DirectPlay\\Applications";
882 LPCSTR guidDataSubKey
= "Guid";
883 DWORD dwIndex
, sizeOfSubKeyName
=50;
887 TRACE("(%p)->(%p,%p,0x%08x)\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
891 return DPERR_INVALIDPARAMS
;
894 if( !lpEnumLocalAppCallback
)
896 return DPERR_INVALIDPARAMS
;
899 /* Need to loop over the service providers in the registry */
900 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE
, searchSubKey
,
901 0, KEY_READ
, &hkResult
) != ERROR_SUCCESS
)
903 /* Hmmm. Does this mean that there are no service providers? */
904 ERR(": no service providers?\n");
908 /* Traverse all registered applications */
910 RegEnumKeyExA( hkResult
, dwIndex
, subKeyName
, &sizeOfSubKeyName
, NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
911 ++dwIndex
, sizeOfSubKeyName
=50 )
914 HKEY hkServiceProvider
;
915 GUID serviceProviderGUID
;
916 DWORD returnTypeGUID
, sizeOfReturnBuffer
= 50;
917 char returnBuffer
[51];
919 DPLAPPINFO dplAppInfo
;
921 TRACE(" this time through: %s\n", subKeyName
);
923 /* Get a handle for this particular service provider */
924 if( RegOpenKeyExA( hkResult
, subKeyName
, 0, KEY_READ
,
925 &hkServiceProvider
) != ERROR_SUCCESS
)
927 ERR(": what the heck is going on?\n" );
931 if( RegQueryValueExA( hkServiceProvider
, guidDataSubKey
,
932 NULL
, &returnTypeGUID
, (LPBYTE
)returnBuffer
,
933 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
935 ERR(": missing GUID registry data members\n" );
939 /* FIXME: Check return types to ensure we're interpreting data right */
940 MultiByteToWideChar( CP_ACP
, 0, returnBuffer
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
941 CLSIDFromString( buff
, &serviceProviderGUID
);
942 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
944 dplAppInfo
.dwSize
= sizeof( dplAppInfo
);
945 dplAppInfo
.guidApplication
= serviceProviderGUID
;
946 dplAppInfo
.u
.lpszAppNameA
= subKeyName
;
948 EnterCriticalSection( &This
->unk
->DPL_lock
);
950 memcpy( &This
->dpl
->hkCallbackKeyHack
, &hkServiceProvider
, sizeof( hkServiceProvider
) );
952 if( !lpEnumLocalAppCallback( &dplAppInfo
, lpContext
, dwFlags
) )
954 LeaveCriticalSection( &This
->unk
->DPL_lock
);
958 LeaveCriticalSection( &This
->unk
->DPL_lock
);
964 /********************************************************************
966 * Retrieves the DPLCONNECTION structure that contains all the information
967 * needed to start and connect an application. This was generated using
968 * either the RunApplication or SetConnectionSettings methods.
970 * NOTES: If lpData is NULL then just return lpdwDataSize. This allows
971 * the data structure to be allocated by our caller which can then
972 * call this procedure/method again with a valid data pointer.
974 static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings
975 ( LPDIRECTPLAYLOBBYA iface
,
978 LPDWORD lpdwDataSize
)
980 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
983 TRACE("(%p)->(0x%08x,%p,%p)\n", This
, dwAppID
, lpData
, lpdwDataSize
);
985 EnterCriticalSection( &This
->unk
->DPL_lock
);
987 hr
= DPLAYX_GetConnectionSettingsA( dwAppID
,
992 LeaveCriticalSection( &This
->unk
->DPL_lock
);
997 static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings
998 ( LPDIRECTPLAYLOBBY iface
,
1001 LPDWORD lpdwDataSize
)
1003 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
1006 TRACE("(%p)->(0x%08x,%p,%p)\n", This
, dwAppID
, lpData
, lpdwDataSize
);
1008 EnterCriticalSection( &This
->unk
->DPL_lock
);
1010 hr
= DPLAYX_GetConnectionSettingsW( dwAppID
,
1015 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1020 /********************************************************************
1022 * Retrieves the message sent between a lobby client and a DirectPlay
1023 * application. All messages are queued until received.
1026 static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage
1027 ( LPDIRECTPLAYLOBBYA iface
,
1030 LPDWORD lpdwMessageFlags
,
1032 LPDWORD lpdwDataSize
)
1034 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1035 FIXME(":stub %p %08x %08x %p %p %p\n", This
, dwFlags
, dwAppID
, lpdwMessageFlags
, lpData
,
1037 return DPERR_OUTOFMEMORY
;
1040 static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage
1041 ( LPDIRECTPLAYLOBBY iface
,
1044 LPDWORD lpdwMessageFlags
,
1046 LPDWORD lpdwDataSize
)
1048 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
1049 FIXME(":stub %p %08x %08x %p %p %p\n", This
, dwFlags
, dwAppID
, lpdwMessageFlags
, lpData
,
1051 return DPERR_OUTOFMEMORY
;
1054 typedef struct tagRunApplicationEnumStruct
1056 IDirectPlayLobbyAImpl
* This
;
1061 LPSTR lpszCommandLine
;
1062 LPSTR lpszCurrentDirectory
;
1063 } RunApplicationEnumStruct
, *lpRunApplicationEnumStruct
;
1065 /* To be called by RunApplication to find how to invoke the function */
1066 static BOOL CALLBACK RunApplicationA_EnumLocalApplications
1067 ( LPCDPLAPPINFO lpAppInfo
,
1071 lpRunApplicationEnumStruct lpData
= (lpRunApplicationEnumStruct
)lpContext
;
1073 if( IsEqualGUID( &lpAppInfo
->guidApplication
, &lpData
->appGUID
) )
1075 char returnBuffer
[200];
1076 DWORD returnType
, sizeOfReturnBuffer
;
1077 LPCSTR clSubKey
= "CommandLine";
1078 LPCSTR cdSubKey
= "CurrentDirectory";
1079 LPCSTR fileSubKey
= "File";
1080 LPCSTR pathSubKey
= "Path";
1082 /* FIXME: Lazy man hack - dplay struct has the present reg key saved */
1084 sizeOfReturnBuffer
= 200;
1086 /* Get all the appropriate data from the registry */
1087 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, clSubKey
,
1088 NULL
, &returnType
, (LPBYTE
)returnBuffer
,
1089 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1091 ERR( ": missing CommandLine registry data member\n" );
1095 if ((lpData
->lpszCommandLine
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1096 strcpy( lpData
->lpszCommandLine
, returnBuffer
);
1099 sizeOfReturnBuffer
= 200;
1101 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, cdSubKey
,
1102 NULL
, &returnType
, (LPBYTE
)returnBuffer
,
1103 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1105 ERR( ": missing CurrentDirectory registry data member\n" );
1109 if ((lpData
->lpszCurrentDirectory
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1110 strcpy( lpData
->lpszCurrentDirectory
, returnBuffer
);
1113 sizeOfReturnBuffer
= 200;
1115 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, fileSubKey
,
1116 NULL
, &returnType
, (LPBYTE
)returnBuffer
,
1117 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1119 ERR( ": missing File registry data member\n" );
1123 if ((lpData
->lpszFileName
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1124 strcpy( lpData
->lpszFileName
, returnBuffer
);
1127 sizeOfReturnBuffer
= 200;
1129 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, pathSubKey
,
1130 NULL
, &returnType
, (LPBYTE
)returnBuffer
,
1131 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1133 ERR( ": missing Path registry data member\n" );
1137 if ((lpData
->lpszPath
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1138 strcpy( lpData
->lpszPath
, returnBuffer
);
1141 return FALSE
; /* No need to keep going as we found what we wanted */
1144 return TRUE
; /* Keep enumerating, haven't found the application yet */
1147 static BOOL
DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId
, HANDLE hDestProcess
,
1148 LPHANDLE lphStart
, LPHANDLE lphDeath
,
1151 /* These are the handles for the created process */
1152 HANDLE hAppStart
= 0, hAppDeath
= 0, hAppRead
= 0;
1153 SECURITY_ATTRIBUTES s_attrib
;
1155 s_attrib
.nLength
= sizeof( s_attrib
);
1156 s_attrib
.lpSecurityDescriptor
= NULL
;
1157 s_attrib
.bInheritHandle
= TRUE
;
1159 *lphStart
= CreateEventW( &s_attrib
, TRUE
, FALSE
, NULL
);
1160 *lphDeath
= CreateEventW( &s_attrib
, TRUE
, FALSE
, NULL
);
1161 *lphRead
= CreateEventW( &s_attrib
, TRUE
, FALSE
, NULL
);
1163 if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart
,
1164 hDestProcess
, &hAppStart
,
1165 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) ||
1166 ( !DuplicateHandle( GetCurrentProcess(), *lphDeath
,
1167 hDestProcess
, &hAppDeath
,
1168 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) ||
1169 ( !DuplicateHandle( GetCurrentProcess(), *lphRead
,
1170 hDestProcess
, &hAppRead
,
1171 0, FALSE
, DUPLICATE_SAME_ACCESS
) )
1174 if (*lphStart
) { CloseHandle(*lphStart
); *lphStart
= 0; }
1175 if (*lphDeath
) { CloseHandle(*lphDeath
); *lphDeath
= 0; }
1176 if (*lphRead
) { CloseHandle(*lphRead
); *lphRead
= 0; }
1177 /* FIXME: Handle leak... */
1178 ERR( "Unable to dup handles\n" );
1182 if( !DPLAYX_SetLobbyHandles( dwDestProcessId
,
1183 hAppStart
, hAppDeath
, hAppRead
) )
1185 /* FIXME: Handle leak... */
1193 /********************************************************************
1195 * Starts an application and passes to it all the information to
1196 * connect to a session.
1199 static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
1200 ( LPDIRECTPLAYLOBBYA iface
,
1203 LPDPLCONNECTION lpConn
,
1204 HANDLE hReceiveEvent
)
1206 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1208 RunApplicationEnumStruct enumData
;
1210 STARTUPINFOA startupInfo
;
1211 PROCESS_INFORMATION newProcessInfo
;
1213 DWORD dwSuspendCount
;
1214 HANDLE hStart
, hDeath
, hSettingRead
;
1216 TRACE( "(%p)->(0x%08x,%p,%p,%p)\n",
1217 This
, dwFlags
, lpdwAppID
, lpConn
, hReceiveEvent
);
1221 return DPERR_INVALIDPARAMS
;
1224 if( DPLAYX_AnyLobbiesWaitingForConnSettings() )
1226 FIXME( "Waiting lobby not being handled correctly\n" );
1229 EnterCriticalSection( &This
->unk
->DPL_lock
);
1231 ZeroMemory( &enumData
, sizeof( enumData
) );
1232 enumData
.This
= This
;
1233 enumData
.appGUID
= lpConn
->lpSessionDesc
->guidApplication
;
1235 /* Our callback function will fill up the enumData structure with all the information
1236 required to start a new process */
1237 IDirectPlayLobby_EnumLocalApplications( iface
, RunApplicationA_EnumLocalApplications
,
1238 (LPVOID
)(&enumData
), 0 );
1240 /* First the application name */
1241 strcpy( temp
, enumData
.lpszPath
);
1242 strcat( temp
, "\\" );
1243 strcat( temp
, enumData
.lpszFileName
);
1244 HeapFree( GetProcessHeap(), 0, enumData
.lpszPath
);
1245 HeapFree( GetProcessHeap(), 0, enumData
.lpszFileName
);
1246 if ((appName
= HeapAlloc( GetProcessHeap(), 0, strlen(temp
)+1 ))) strcpy( appName
, temp
);
1248 /* Now the command line */
1249 strcat( temp
, " " );
1250 strcat( temp
, enumData
.lpszCommandLine
);
1251 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1252 if ((enumData
.lpszCommandLine
= HeapAlloc( GetProcessHeap(), 0, strlen(temp
)+1 )))
1253 strcpy( enumData
.lpszCommandLine
, temp
);
1255 ZeroMemory( &startupInfo
, sizeof( startupInfo
) );
1256 startupInfo
.cb
= sizeof( startupInfo
);
1257 /* FIXME: Should any fields be filled in? */
1259 ZeroMemory( &newProcessInfo
, sizeof( newProcessInfo
) );
1261 if( !CreateProcessA( appName
,
1262 enumData
.lpszCommandLine
,
1266 CREATE_DEFAULT_ERROR_MODE
| CREATE_NEW_CONSOLE
| CREATE_SUSPENDED
, /* Creation Flags */
1268 enumData
.lpszCurrentDirectory
,
1274 ERR( "Failed to create process for app %s\n", appName
);
1276 HeapFree( GetProcessHeap(), 0, appName
);
1277 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1278 HeapFree( GetProcessHeap(), 0, enumData
.lpszCurrentDirectory
);
1280 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1281 return DPERR_CANTCREATEPROCESS
;
1284 HeapFree( GetProcessHeap(), 0, appName
);
1285 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1286 HeapFree( GetProcessHeap(), 0, enumData
.lpszCurrentDirectory
);
1288 /* Reserve this global application id! */
1289 if( !DPLAYX_CreateLobbyApplication( newProcessInfo
.dwProcessId
) )
1291 ERR( "Unable to create global application data for 0x%08x\n",
1292 newProcessInfo
.dwProcessId
);
1295 hr
= IDirectPlayLobby_SetConnectionSettings( iface
, 0, newProcessInfo
.dwProcessId
, lpConn
);
1299 ERR( "SetConnectionSettings failure %s\n", DPLAYX_HresultToString( hr
) );
1300 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1304 /* Setup the handles for application notification */
1305 DPL_CreateAndSetLobbyHandles( newProcessInfo
.dwProcessId
,
1306 newProcessInfo
.hProcess
,
1307 &hStart
, &hDeath
, &hSettingRead
);
1309 /* Setup the message thread ID */
1310 This
->dpl
->dwMsgThread
=
1311 CreateLobbyMessageReceptionThread( hReceiveEvent
, hStart
, hDeath
, hSettingRead
);
1313 DPLAYX_SetLobbyMsgThreadId( newProcessInfo
.dwProcessId
, This
->dpl
->dwMsgThread
);
1315 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1317 /* Everything seems to have been set correctly, update the dwAppID */
1318 *lpdwAppID
= newProcessInfo
.dwProcessId
;
1320 /* Unsuspend the process - should return the prev suspension count */
1321 if( ( dwSuspendCount
= ResumeThread( newProcessInfo
.hThread
) ) != 1 )
1323 ERR( "ResumeThread failed with 0x%08x\n", dwSuspendCount
);
1329 static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication
1330 ( LPDIRECTPLAYLOBBY iface
,
1333 LPDPLCONNECTION lpConn
,
1334 HANDLE hReceiveEvent
)
1336 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
1337 FIXME( "(%p)->(0x%08x,%p,%p,%p):stub\n", This
, dwFlags
, lpdwAppID
, lpConn
, hReceiveEvent
);
1338 return DPERR_OUTOFMEMORY
;
1341 /********************************************************************
1343 * Sends a message between the application and the lobby client.
1344 * All messages are queued until received.
1347 static HRESULT WINAPI IDirectPlayLobbyAImpl_SendLobbyMessage
1348 ( LPDIRECTPLAYLOBBYA iface
,
1355 return DPERR_OUTOFMEMORY
;
1358 static HRESULT WINAPI IDirectPlayLobbyWImpl_SendLobbyMessage
1359 ( LPDIRECTPLAYLOBBY iface
,
1366 return DPERR_OUTOFMEMORY
;
1369 /********************************************************************
1371 * Modifies the DPLCONNECTION structure to contain all information
1372 * needed to start and connect an application.
1375 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings
1376 ( LPDIRECTPLAYLOBBY iface
,
1379 LPDPLCONNECTION lpConn
)
1381 IDirectPlayLobbyWImpl
*This
= (IDirectPlayLobbyWImpl
*)iface
;
1384 TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This
, dwFlags
, dwAppID
, lpConn
);
1386 EnterCriticalSection( &This
->unk
->DPL_lock
);
1388 hr
= DPLAYX_SetConnectionSettingsW( dwFlags
, dwAppID
, lpConn
);
1390 /* FIXME: Don't think that this is supposed to fail, but the documentation
1391 is somewhat sketchy. I'll try creating a lobby application
1393 if( hr
== DPERR_NOTLOBBIED
)
1395 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1398 dwAppID
= GetCurrentProcessId();
1400 DPLAYX_CreateLobbyApplication( dwAppID
);
1401 hr
= DPLAYX_SetConnectionSettingsW( dwFlags
, dwAppID
, lpConn
);
1404 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1409 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings
1410 ( LPDIRECTPLAYLOBBYA iface
,
1413 LPDPLCONNECTION lpConn
)
1415 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1418 TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This
, dwFlags
, dwAppID
, lpConn
);
1420 EnterCriticalSection( &This
->unk
->DPL_lock
);
1422 hr
= DPLAYX_SetConnectionSettingsA( dwFlags
, dwAppID
, lpConn
);
1424 /* FIXME: Don't think that this is supposed to fail, but the documentation
1425 is somewhat sketchy. I'll try creating a lobby application
1427 if( hr
== DPERR_NOTLOBBIED
)
1429 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1430 dwAppID
= GetCurrentProcessId();
1431 DPLAYX_CreateLobbyApplication( dwAppID
);
1432 hr
= DPLAYX_SetConnectionSettingsA( dwFlags
, dwAppID
, lpConn
);
1435 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1440 /********************************************************************
1442 * Registers an event that will be set when a lobby message is received.
1445 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1446 ( LPDIRECTPLAYLOBBYA iface
,
1449 HANDLE hReceiveEvent
)
1452 return DPERR_OUTOFMEMORY
;
1455 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1456 ( LPDIRECTPLAYLOBBY iface
,
1459 HANDLE hReceiveEvent
)
1462 return DPERR_OUTOFMEMORY
;
1467 static HRESULT WINAPI IDirectPlayLobby2WImpl_CreateCompoundAddress
1468 ( LPDIRECTPLAYLOBBY2 iface
,
1469 LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1470 DWORD dwElementCount
,
1472 LPDWORD lpdwAddressSize
)
1474 return DPL_CreateCompoundAddress( lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
, FALSE
);
1477 static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress
1478 ( LPDIRECTPLAYLOBBY2A iface
,
1479 LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1480 DWORD dwElementCount
,
1482 LPDWORD lpdwAddressSize
)
1484 return DPL_CreateCompoundAddress( lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
, TRUE
);
1487 HRESULT DPL_CreateCompoundAddress
1488 ( LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1489 DWORD dwElementCount
,
1491 LPDWORD lpdwAddressSize
,
1492 BOOL bAnsiInterface
)
1494 DWORD dwSizeRequired
= 0;
1496 LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements
= lpElements
;
1498 TRACE("(%p,0x%08x,%p,%p)\n", lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
);
1500 /* Parameter check */
1501 if( ( lpElements
== NULL
) ||
1502 ( dwElementCount
== 0 ) /* FIXME: Not sure if this is a failure case */
1505 return DPERR_INVALIDPARAMS
;
1508 /* Add the total size chunk */
1509 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( DWORD
);
1511 /* Calculate the size of the buffer required */
1512 for ( dwElements
= dwElementCount
; dwElements
> 0; --dwElements
, ++lpElements
)
1514 if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ServiceProvider
) ) ||
1515 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_LobbyProvider
) )
1518 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( GUID
);
1520 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Phone
) ) ||
1521 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Modem
) ) ||
1522 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INet
) )
1525 if( !bAnsiInterface
)
1527 ERR( "Ansi GUIDs used for unicode interface\n" );
1528 return DPERR_INVALIDFLAGS
;
1531 dwSizeRequired
+= sizeof( DPADDRESS
) + lpElements
->dwDataSize
;
1533 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1534 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1535 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1538 if( bAnsiInterface
)
1540 ERR( "Unicode GUIDs used for ansi interface\n" );
1541 return DPERR_INVALIDFLAGS
;
1544 FIXME( "Right size for unicode interface?\n" );
1545 dwSizeRequired
+= sizeof( DPADDRESS
) + lpElements
->dwDataSize
* sizeof( WCHAR
);
1547 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1549 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( WORD
);
1551 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1553 FIXME( "Right size for unicode interface?\n" );
1554 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( DPCOMPORTADDRESS
); /* FIXME: Right size? */
1558 ERR( "Unknown GUID %s\n", debugstr_guid(&lpElements
->guidDataType
) );
1559 return DPERR_INVALIDFLAGS
;
1563 /* The user wants to know how big a buffer to allocate for us */
1564 if( ( lpAddress
== NULL
) ||
1565 ( *lpdwAddressSize
< dwSizeRequired
)
1568 *lpdwAddressSize
= dwSizeRequired
;
1569 return DPERR_BUFFERTOOSMALL
;
1572 /* Add the total size chunk */
1574 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1576 lpdpAddress
->guidDataType
= DPAID_TotalSize
;
1577 lpdpAddress
->dwDataSize
= sizeof( DWORD
);
1578 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1580 *(LPDWORD
)lpAddress
= dwSizeRequired
;
1581 lpAddress
= (char *) lpAddress
+ sizeof( DWORD
);
1584 /* Calculate the size of the buffer required */
1585 for( dwElements
= dwElementCount
, lpElements
= lpOrigElements
;
1587 --dwElements
, ++lpElements
)
1589 if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ServiceProvider
) ) ||
1590 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_LobbyProvider
) )
1593 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1595 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 lpdpAddress
->guidDataType
= lpElements
->guidDataType
;
1610 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1611 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1613 lstrcpynA( (LPSTR
)lpAddress
,
1614 (LPCSTR
)lpElements
->lpData
,
1615 lpElements
->dwDataSize
);
1616 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
;
1618 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1619 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1620 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1623 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1625 lpdpAddress
->guidDataType
= lpElements
->guidDataType
;
1626 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1627 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1629 lstrcpynW( (LPWSTR
)lpAddress
,
1630 (LPCWSTR
)lpElements
->lpData
,
1631 lpElements
->dwDataSize
);
1632 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
* sizeof( WCHAR
);
1634 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1636 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1638 lpdpAddress
->guidDataType
= lpElements
->guidDataType
;
1639 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1640 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1642 *((LPWORD
)lpAddress
) = *((LPWORD
)lpElements
->lpData
);
1643 lpAddress
= (char *) lpAddress
+ sizeof( WORD
);
1645 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1647 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1649 lpdpAddress
->guidDataType
= lpElements
->guidDataType
;
1650 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1651 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1653 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( DPADDRESS
) );
1654 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1663 static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
1664 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFIID riid
,
1665 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1667 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1668 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1671 static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
1672 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFIID riid
,
1673 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1675 IDirectPlayLobbyAImpl
*This
= (IDirectPlayLobbyAImpl
*)iface
;
1676 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1679 static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
1680 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1686 static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
1687 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1693 static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
1694 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1700 static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
1701 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1707 static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
1708 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
)
1711 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1713 TRACE( "(%p)->(0x%08x)\n", iface
, dwFlags
);
1715 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1717 /* FIXME: What is the correct error return code? */
1718 hr
= DPERR_NOTLOBBIED
;
1724 static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
1725 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
)
1728 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1730 TRACE( "(%p)->(0x%08x)\n", iface
, dwFlags
);
1732 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1734 /* FIXME: What is the correct error return code? */
1735 hr
= DPERR_NOTLOBBIED
;
1742 /* Virtual Table definitions for DPL{1,2,3}{A,W} */
1744 /* Note: Hack so we can reuse the old functions without compiler warnings */
1745 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1746 # define XCAST(fun) (typeof(directPlayLobbyAVT.fun))
1748 # define XCAST(fun) (void*)
1751 /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
1752 /* All lobby 1 methods are exactly the same except QueryInterface */
1753 static const IDirectPlayLobbyVtbl directPlayLobbyAVT
=
1756 XCAST(QueryInterface
)DPL_QueryInterface
,
1757 XCAST(AddRef
)DPL_AddRef
,
1758 XCAST(Release
)DPL_Release
,
1760 IDirectPlayLobbyAImpl_Connect
,
1761 IDirectPlayLobbyAImpl_CreateAddress
,
1762 IDirectPlayLobbyAImpl_EnumAddress
,
1763 IDirectPlayLobbyAImpl_EnumAddressTypes
,
1764 IDirectPlayLobbyAImpl_EnumLocalApplications
,
1765 IDirectPlayLobbyAImpl_GetConnectionSettings
,
1766 IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1767 IDirectPlayLobbyAImpl_RunApplication
,
1768 IDirectPlayLobbyAImpl_SendLobbyMessage
,
1769 IDirectPlayLobbyAImpl_SetConnectionSettings
,
1770 IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1775 /* Note: Hack so we can reuse the old functions without compiler warnings */
1776 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1777 # define XCAST(fun) (typeof(directPlayLobbyWVT.fun))
1779 # define XCAST(fun) (void*)
1782 /* Direct Play Lobby 1 (unicode) Virtual Table for methods */
1783 static const IDirectPlayLobbyVtbl directPlayLobbyWVT
=
1786 XCAST(QueryInterface
)DPL_QueryInterface
,
1787 XCAST(AddRef
)DPL_AddRef
,
1788 XCAST(Release
)DPL_Release
,
1790 IDirectPlayLobbyWImpl_Connect
,
1791 IDirectPlayLobbyWImpl_CreateAddress
,
1792 IDirectPlayLobbyWImpl_EnumAddress
,
1793 IDirectPlayLobbyWImpl_EnumAddressTypes
,
1794 IDirectPlayLobbyWImpl_EnumLocalApplications
,
1795 IDirectPlayLobbyWImpl_GetConnectionSettings
,
1796 IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1797 IDirectPlayLobbyWImpl_RunApplication
,
1798 IDirectPlayLobbyWImpl_SendLobbyMessage
,
1799 IDirectPlayLobbyWImpl_SetConnectionSettings
,
1800 IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1804 /* Note: Hack so we can reuse the old functions without compiler warnings */
1805 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1806 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1808 # define XCAST(fun) (void*)
1811 /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
1812 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT
=
1815 XCAST(QueryInterface
)DPL_QueryInterface
,
1816 XCAST(AddRef
)DPL_AddRef
,
1817 XCAST(Release
)DPL_Release
,
1819 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1820 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1821 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1822 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1823 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1824 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1825 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1826 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1827 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1828 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1829 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1831 IDirectPlayLobby2AImpl_CreateCompoundAddress
1835 /* Note: Hack so we can reuse the old functions without compiler warnings */
1836 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1837 # define XCAST(fun) (typeof(directPlayLobby2WVT.fun))
1839 # define XCAST(fun) (void*)
1842 /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
1843 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT
=
1846 XCAST(QueryInterface
)DPL_QueryInterface
,
1847 XCAST(AddRef
)DPL_AddRef
,
1848 XCAST(Release
)DPL_Release
,
1850 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1851 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1852 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1853 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1854 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1855 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1856 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1857 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1858 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1859 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1860 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1862 IDirectPlayLobby2WImpl_CreateCompoundAddress
1866 /* Direct Play Lobby 3 (ascii) Virtual Table for methods */
1868 /* Note: Hack so we can reuse the old functions without compiler warnings */
1869 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1870 # define XCAST(fun) (typeof(directPlayLobby3AVT.fun))
1872 # define XCAST(fun) (void*)
1875 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT
=
1877 XCAST(QueryInterface
)DPL_QueryInterface
,
1878 XCAST(AddRef
)DPL_AddRef
,
1879 XCAST(Release
)DPL_Release
,
1881 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1882 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1883 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1884 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1885 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1886 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1887 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1888 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1889 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1890 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1891 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1893 XCAST(CreateCompoundAddress
)IDirectPlayLobby2AImpl_CreateCompoundAddress
,
1895 IDirectPlayLobby3AImpl_ConnectEx
,
1896 IDirectPlayLobby3AImpl_RegisterApplication
,
1897 IDirectPlayLobby3AImpl_UnregisterApplication
,
1898 IDirectPlayLobby3AImpl_WaitForConnectionSettings
1902 /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
1904 /* Note: Hack so we can reuse the old functions without compiler warnings */
1905 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1906 # define XCAST(fun) (typeof(directPlayLobby3WVT.fun))
1908 # define XCAST(fun) (void*)
1911 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT
=
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=%08x\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=%08x\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
);