dplayx: Remove superfluous forward declarations.
[wine.git] / dlls / dplayx / dplobby.c
blobcbdd128282a0ed4e633503171c76b25db6c780db
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
19 #include <stdarg.h>
20 #include <string.h>
22 #define NONAMELESSUNION
23 #define NONAMELESSSTRUCT
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "winreg.h"
28 #include "winnls.h"
29 #include "wine/debug.h"
31 #include "dplayx_global.h"
32 #include "dplayx_messages.h"
33 #include "dplayx_queue.h"
34 #include "dplobby.h"
35 #include "dpinit.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
39 /*****************************************************************************
40 * Predeclare the interface implementation structures
42 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyAImpl;
43 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyWImpl;
44 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2AImpl;
45 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2WImpl;
46 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3AImpl;
47 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3WImpl;
49 /* Forward declarations for this module helper methods */
50 HRESULT DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements, DWORD dwElementCount,
51 LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface )DECLSPEC_HIDDEN;
53 static HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize,
54 LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface );
57 /*****************************************************************************
58 * IDirectPlayLobby {1,2,3} implementation structure
60 * The philosophy behind this extra pointer dereference is that I wanted to
61 * have the same structure for all types of objects without having to do
62 * a lot of casting. I also only wanted to implement an interface in the
63 * object it was "released" with IUnknown interface being implemented in the 1 version.
64 * Of course, with these new interfaces comes the data required to keep the state required
65 * by these interfaces. So, basically, the pointers contain the data associated with
66 * a release. If you use the data associated with release 3 in a release 2 object, you'll
67 * get a run time trap, as that won't have any data.
70 struct DPLMSG
72 DPQ_ENTRY( DPLMSG ) msgs; /* Link to next queued message */
74 typedef struct DPLMSG* LPDPLMSG;
76 typedef struct tagDirectPlayLobbyIUnknownData
78 LONG ulObjRef;
79 CRITICAL_SECTION DPL_lock;
80 } DirectPlayLobbyIUnknownData;
82 typedef struct tagDirectPlayLobbyData
84 HKEY hkCallbackKeyHack;
85 DWORD dwMsgThread;
86 DPQ_HEAD( DPLMSG ) msgs; /* List of messages received */
87 } DirectPlayLobbyData;
89 typedef struct tagDirectPlayLobby2Data
91 BOOL dummy;
92 } DirectPlayLobby2Data;
94 typedef struct tagDirectPlayLobby3Data
96 BOOL dummy;
97 } DirectPlayLobby3Data;
99 #define DPL_IMPL_FIELDS \
100 LONG ulInterfaceRef; \
101 DirectPlayLobbyIUnknownData* unk; \
102 DirectPlayLobbyData* dpl; \
103 DirectPlayLobby2Data* dpl2; \
104 DirectPlayLobby3Data* dpl3;
106 struct IDirectPlayLobbyImpl
108 const IDirectPlayLobbyVtbl *lpVtbl;
109 DPL_IMPL_FIELDS
112 struct IDirectPlayLobby2Impl
114 const IDirectPlayLobby2Vtbl *lpVtbl;
115 DPL_IMPL_FIELDS
118 struct IDirectPlayLobby3Impl
120 const IDirectPlayLobby3Vtbl *lpVtbl;
121 DPL_IMPL_FIELDS
124 /* Forward declarations of virtual tables */
125 static const IDirectPlayLobbyVtbl directPlayLobbyWVT;
126 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT;
127 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT;
129 static const IDirectPlayLobbyVtbl directPlayLobbyAVT;
130 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT;
131 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT;
133 static BOOL DPL_CreateIUnknown( LPVOID lpDPL )
135 IDirectPlayLobbyAImpl *This = lpDPL;
137 This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
138 if ( This->unk == NULL )
140 return FALSE;
143 InitializeCriticalSection( &This->unk->DPL_lock );
144 This->unk->DPL_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayLobbyAImpl*->DirectPlayLobbyIUnknownData*->DPL_lock");
146 return TRUE;
149 static BOOL DPL_DestroyIUnknown( LPVOID lpDPL )
151 IDirectPlayLobbyAImpl *This = lpDPL;
153 This->unk->DPL_lock.DebugInfo->Spare[0] = 0;
154 DeleteCriticalSection( &This->unk->DPL_lock );
155 HeapFree( GetProcessHeap(), 0, This->unk );
157 return TRUE;
160 static BOOL DPL_CreateLobby1( LPVOID lpDPL )
162 IDirectPlayLobbyAImpl *This = lpDPL;
164 This->dpl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl) ) );
165 if ( This->dpl == NULL )
167 return FALSE;
170 DPQ_INIT( This->dpl->msgs );
172 return TRUE;
175 static BOOL DPL_DestroyLobby1( LPVOID lpDPL )
177 IDirectPlayLobbyAImpl *This = lpDPL;
179 if( This->dpl->dwMsgThread )
181 FIXME( "Should kill the msg thread\n" );
184 DPQ_DELETEQ( This->dpl->msgs, msgs, LPDPLMSG, cbDeleteElemFromHeap );
186 /* Delete the contents */
187 HeapFree( GetProcessHeap(), 0, This->dpl );
189 return TRUE;
192 static BOOL DPL_CreateLobby2( LPVOID lpDPL )
194 IDirectPlayLobby2AImpl *This = lpDPL;
196 This->dpl2 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl2) ) );
197 if ( This->dpl2 == NULL )
199 return FALSE;
202 return TRUE;
205 static BOOL DPL_DestroyLobby2( LPVOID lpDPL )
207 IDirectPlayLobby2AImpl *This = lpDPL;
209 HeapFree( GetProcessHeap(), 0, This->dpl2 );
211 return TRUE;
214 static BOOL DPL_CreateLobby3( LPVOID lpDPL )
216 IDirectPlayLobby3AImpl *This = lpDPL;
218 This->dpl3 = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->dpl3) ) );
219 if ( This->dpl3 == NULL )
221 return FALSE;
224 return TRUE;
227 static BOOL DPL_DestroyLobby3( LPVOID lpDPL )
229 IDirectPlayLobby3AImpl *This = lpDPL;
231 HeapFree( GetProcessHeap(), 0, This->dpl3 );
233 return TRUE;
237 /* The COM interface for upversioning an interface
238 * We've been given a GUID (riid) and we need to replace the present
239 * interface with that of the requested interface.
241 * Snip from some Microsoft document:
242 * There are four requirements for implementations of QueryInterface (In these
243 * cases, "must succeed" means "must succeed barring catastrophic failure."):
245 * * The set of interfaces accessible on an object through
246 * IUnknown::QueryInterface must be static, not dynamic. This means that
247 * if a call to QueryInterface for a pointer to a specified interface
248 * succeeds the first time, it must succeed again, and if it fails the
249 * first time, it must fail on all subsequent queries.
250 * * It must be symmetric ~W if a client holds a pointer to an interface on
251 * an object, and queries for that interface, the call must succeed.
252 * * It must be reflexive ~W if a client holding a pointer to one interface
253 * queries successfully for another, a query through the obtained pointer
254 * for the first interface must succeed.
255 * * It must be transitive ~W if a client holding a pointer to one interface
256 * queries successfully for a second, and through that pointer queries
257 * successfully for a third interface, a query for the first interface
258 * through the pointer for the third interface must succeed.
260 HRESULT DPL_CreateInterface
261 ( REFIID riid, LPVOID* ppvObj )
263 TRACE( " for %s\n", debugstr_guid( riid ) );
265 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
266 sizeof( IDirectPlayLobbyWImpl ) );
268 if( *ppvObj == NULL )
270 return DPERR_OUTOFMEMORY;
273 if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
275 IDirectPlayLobbyWImpl *This = *ppvObj;
276 This->lpVtbl = &directPlayLobbyWVT;
278 else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
280 IDirectPlayLobbyAImpl *This = *ppvObj;
281 This->lpVtbl = &directPlayLobbyAVT;
283 else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
285 IDirectPlayLobby2WImpl *This = *ppvObj;
286 This->lpVtbl = &directPlayLobby2WVT;
288 else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
290 IDirectPlayLobby2AImpl *This = *ppvObj;
291 This->lpVtbl = &directPlayLobby2AVT;
293 else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
295 IDirectPlayLobby3WImpl *This = *ppvObj;
296 This->lpVtbl = &directPlayLobby3WVT;
298 else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
300 IDirectPlayLobby3AImpl *This = *ppvObj;
301 This->lpVtbl = &directPlayLobby3AVT;
303 else
305 /* Unsupported interface */
306 HeapFree( GetProcessHeap(), 0, *ppvObj );
307 *ppvObj = NULL;
309 return E_NOINTERFACE;
312 /* Initialize it */
313 if ( DPL_CreateIUnknown( *ppvObj ) &&
314 DPL_CreateLobby1( *ppvObj ) &&
315 DPL_CreateLobby2( *ppvObj ) &&
316 DPL_CreateLobby3( *ppvObj )
319 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY)*ppvObj );
320 return S_OK;
323 /* Initialize failed, destroy it */
324 DPL_DestroyLobby3( *ppvObj );
325 DPL_DestroyLobby2( *ppvObj );
326 DPL_DestroyLobby1( *ppvObj );
327 DPL_DestroyIUnknown( *ppvObj );
328 HeapFree( GetProcessHeap(), 0, *ppvObj );
330 *ppvObj = NULL;
331 return DPERR_NOMEMORY;
334 static HRESULT WINAPI DPL_QueryInterface
335 ( LPDIRECTPLAYLOBBYA iface,
336 REFIID riid,
337 LPVOID* ppvObj )
339 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
340 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj );
342 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
343 sizeof( *This ) );
345 if( *ppvObj == NULL )
347 return DPERR_OUTOFMEMORY;
350 CopyMemory( *ppvObj, This, sizeof( *This ) );
351 (*(IDirectPlayLobbyAImpl**)ppvObj)->ulInterfaceRef = 0;
353 if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
355 IDirectPlayLobbyWImpl *This = *ppvObj;
356 This->lpVtbl = &directPlayLobbyWVT;
358 else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
360 IDirectPlayLobbyAImpl *This = *ppvObj;
361 This->lpVtbl = &directPlayLobbyAVT;
363 else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
365 IDirectPlayLobby2WImpl *This = *ppvObj;
366 This->lpVtbl = &directPlayLobby2WVT;
368 else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
370 IDirectPlayLobby2AImpl *This = *ppvObj;
371 This->lpVtbl = &directPlayLobby2AVT;
373 else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
375 IDirectPlayLobby3WImpl *This = *ppvObj;
376 This->lpVtbl = &directPlayLobby3WVT;
378 else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
380 IDirectPlayLobby3AImpl *This = *ppvObj;
381 This->lpVtbl = &directPlayLobby3AVT;
383 else
385 /* Unsupported interface */
386 HeapFree( GetProcessHeap(), 0, *ppvObj );
387 *ppvObj = NULL;
389 return E_NOINTERFACE;
392 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY)*ppvObj );
394 return S_OK;
398 * Simple procedure. Just increment the reference count to this
399 * structure and return the new reference count.
401 static ULONG WINAPI DPL_AddRef
402 ( LPDIRECTPLAYLOBBY iface )
404 ULONG ulInterfaceRefCount, ulObjRefCount;
405 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
407 ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
408 ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
410 TRACE( "ref count incremented to %u:%u for %p\n",
411 ulInterfaceRefCount, ulObjRefCount, This );
413 return ulObjRefCount;
417 * Simple COM procedure. Decrease the reference count to this object.
418 * If the object no longer has any reference counts, free up the associated
419 * memory.
421 static ULONG WINAPI DPL_Release
422 ( LPDIRECTPLAYLOBBYA iface )
424 ULONG ulInterfaceRefCount, ulObjRefCount;
425 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
427 ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
428 ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
430 TRACE( "ref count decremented to %u:%u for %p\n",
431 ulInterfaceRefCount, ulObjRefCount, This );
433 /* Deallocate if this is the last reference to the object */
434 if( ulObjRefCount == 0 )
436 DPL_DestroyLobby3( This );
437 DPL_DestroyLobby2( This );
438 DPL_DestroyLobby1( This );
439 DPL_DestroyIUnknown( This );
442 if( ulInterfaceRefCount == 0 )
444 HeapFree( GetProcessHeap(), 0, This );
447 return ulInterfaceRefCount;
451 /********************************************************************
453 * Connects an application to the session specified by the DPLCONNECTION
454 * structure currently stored with the DirectPlayLobby object.
456 * Returns an IDirectPlay interface.
459 static HRESULT DPL_ConnectEx
460 ( IDirectPlayLobbyAImpl* This,
461 DWORD dwFlags,
462 REFIID riid,
463 LPVOID* lplpDP,
464 IUnknown* pUnk)
466 HRESULT hr;
467 DWORD dwOpenFlags = 0;
468 DWORD dwConnSize = 0;
469 LPDPLCONNECTION lpConn;
471 FIXME("(%p)->(0x%08x,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk );
473 if( pUnk )
475 return DPERR_INVALIDPARAMS;
478 /* Backwards compatibility */
479 if( dwFlags == 0 )
481 dwFlags = DPCONNECT_RETURNSTATUS;
484 if ( ( hr = dplay_create( riid, lplpDP ) ) != DP_OK )
486 ERR( "error creating interface for %s:%s.\n",
487 debugstr_guid( riid ), DPLAYX_HresultToString( hr ) );
488 return hr;
491 /* FIXME: Is it safe/correct to use appID of 0? */
492 hr = IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY)This,
493 0, NULL, &dwConnSize );
494 if( hr != DPERR_BUFFERTOOSMALL )
496 return hr;
499 lpConn = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwConnSize );
501 if( lpConn == NULL )
503 return DPERR_NOMEMORY;
506 /* FIXME: Is it safe/correct to use appID of 0? */
507 hr = IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY)This,
508 0, lpConn, &dwConnSize );
509 if( FAILED( hr ) )
511 HeapFree( GetProcessHeap(), 0, lpConn );
512 return hr;
515 #if 0
516 /* - Need to call IDirectPlay::EnumConnections with the service provider to get that good information
517 * - Need to call CreateAddress to create the lpConnection param for IDirectPlay::InitializeConnection
518 * - Call IDirectPlay::InitializeConnection
521 /* Now initialize the Service Provider */
522 hr = IDirectPlayX_InitializeConnection( (*(LPDIRECTPLAY2*)lplpDP),
523 #endif
526 /* Setup flags to pass into DirectPlay::Open */
527 if( dwFlags & DPCONNECT_RETURNSTATUS )
529 dwOpenFlags |= DPOPEN_RETURNSTATUS;
531 dwOpenFlags |= lpConn->dwFlags;
533 hr = IDirectPlayX_Open( (*(LPDIRECTPLAY2*)lplpDP), lpConn->lpSessionDesc,
534 dwOpenFlags );
536 HeapFree( GetProcessHeap(), 0, lpConn );
538 return hr;
541 static HRESULT WINAPI IDirectPlayLobbyAImpl_Connect
542 ( LPDIRECTPLAYLOBBYA iface,
543 DWORD dwFlags,
544 LPDIRECTPLAY2A* lplpDP,
545 IUnknown* pUnk)
547 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
548 return DPL_ConnectEx( This, dwFlags, &IID_IDirectPlay2A,
549 (LPVOID)lplpDP, pUnk );
552 static HRESULT WINAPI IDirectPlayLobbyWImpl_Connect
553 ( LPDIRECTPLAYLOBBY iface,
554 DWORD dwFlags,
555 LPDIRECTPLAY2* lplpDP,
556 IUnknown* pUnk)
558 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface; /* Yes cast to A */
559 return DPL_ConnectEx( This, dwFlags, &IID_IDirectPlay2,
560 (LPVOID)lplpDP, pUnk );
563 /********************************************************************
565 * Creates a DirectPlay Address, given a service provider-specific network
566 * address.
567 * Returns an address contains the globally unique identifier
568 * (GUID) of the service provider and data that the service provider can
569 * interpret as a network address.
571 * NOTE: It appears that this method is supposed to be really really stupid
572 * with no error checking on the contents.
574 static HRESULT WINAPI IDirectPlayLobbyAImpl_CreateAddress
575 ( LPDIRECTPLAYLOBBYA iface,
576 REFGUID guidSP,
577 REFGUID guidDataType,
578 LPCVOID lpData,
579 DWORD dwDataSize,
580 LPVOID lpAddress,
581 LPDWORD lpdwAddressSize )
583 return DPL_CreateAddress( guidSP, guidDataType, lpData, dwDataSize,
584 lpAddress, lpdwAddressSize, TRUE );
587 static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress
588 ( LPDIRECTPLAYLOBBY iface,
589 REFGUID guidSP,
590 REFGUID guidDataType,
591 LPCVOID lpData,
592 DWORD dwDataSize,
593 LPVOID lpAddress,
594 LPDWORD lpdwAddressSize )
596 return DPL_CreateAddress( guidSP, guidDataType, lpData, dwDataSize,
597 lpAddress, lpdwAddressSize, FALSE );
600 static HRESULT DPL_CreateAddress(
601 REFGUID guidSP,
602 REFGUID guidDataType,
603 LPCVOID lpData,
604 DWORD dwDataSize,
605 LPVOID lpAddress,
606 LPDWORD lpdwAddressSize,
607 BOOL bAnsiInterface )
609 const DWORD dwNumAddElements = 2; /* Service Provide & address data type */
610 DPCOMPOUNDADDRESSELEMENT addressElements[ 2 /* dwNumAddElements */ ];
612 TRACE( "(%p)->(%p,%p,0x%08x,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize,
613 lpAddress, lpdwAddressSize, bAnsiInterface );
615 addressElements[ 0 ].guidDataType = DPAID_ServiceProvider;
616 addressElements[ 0 ].dwDataSize = sizeof( GUID );
617 addressElements[ 0 ].lpData = (LPVOID)guidSP;
619 addressElements[ 1 ].guidDataType = *guidDataType;
620 addressElements[ 1 ].dwDataSize = dwDataSize;
621 addressElements[ 1 ].lpData = (LPVOID)lpData;
623 /* Call CreateCompoundAddress to cut down on code.
624 NOTE: We can do this because we don't support DPL 1 interfaces! */
625 return DPL_CreateCompoundAddress( addressElements, dwNumAddElements,
626 lpAddress, lpdwAddressSize, bAnsiInterface );
631 /********************************************************************
633 * Parses out chunks from the DirectPlay Address buffer by calling the
634 * given callback function, with lpContext, for each of the chunks.
637 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress
638 ( LPDIRECTPLAYLOBBYA iface,
639 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
640 LPCVOID lpAddress,
641 DWORD dwAddressSize,
642 LPVOID lpContext )
644 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
646 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress,
647 dwAddressSize, lpContext );
649 return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
652 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress
653 ( LPDIRECTPLAYLOBBY iface,
654 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
655 LPCVOID lpAddress,
656 DWORD dwAddressSize,
657 LPVOID lpContext )
659 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
661 TRACE("(%p)->(%p,%p,0x%08x,%p)\n", This, lpEnumAddressCallback, lpAddress,
662 dwAddressSize, lpContext );
664 return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
667 HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
668 DWORD dwAddressSize, LPVOID lpContext )
670 DWORD dwTotalSizeEnumerated = 0;
672 /* FIXME: First chunk is always the total size chunk - Should we report it? */
674 while ( dwTotalSizeEnumerated < dwAddressSize )
676 const DPADDRESS* lpElements = lpAddress;
677 DWORD dwSizeThisEnumeration;
679 /* Invoke the enum method. If false is returned, stop enumeration */
680 if ( !lpEnumAddressCallback( &lpElements->guidDataType,
681 lpElements->dwDataSize,
682 (const BYTE *)lpElements + sizeof( DPADDRESS ),
683 lpContext ) )
685 break;
688 dwSizeThisEnumeration = sizeof( DPADDRESS ) + lpElements->dwDataSize;
689 lpAddress = (const BYTE*) lpAddress + dwSizeThisEnumeration;
690 dwTotalSizeEnumerated += dwSizeThisEnumeration;
693 return DP_OK;
696 /********************************************************************
698 * Enumerates all the address types that a given service provider needs to
699 * build the DirectPlay Address.
702 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
703 ( LPDIRECTPLAYLOBBYA iface,
704 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback,
705 REFGUID guidSP,
706 LPVOID lpContext,
707 DWORD dwFlags )
709 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
711 HKEY hkResult;
712 LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
713 DWORD dwIndex, sizeOfSubKeyName=50;
714 char subKeyName[51];
715 FILETIME filetime;
717 TRACE(" (%p)->(%p,%p,%p,0x%08x)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags );
719 if( dwFlags != 0 )
721 return DPERR_INVALIDPARAMS;
724 if( !lpEnumAddressTypeCallback )
726 return DPERR_INVALIDPARAMS;
729 if( guidSP == NULL )
731 return DPERR_INVALIDOBJECT;
734 /* Need to loop over the service providers in the registry */
735 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
736 0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
738 /* Hmmm. Does this mean that there are no service providers? */
739 ERR(": no service providers?\n");
740 return DP_OK;
743 /* Traverse all the service providers we have available */
744 for( dwIndex=0;
745 RegEnumKeyExA( hkResult, dwIndex, subKeyName, &sizeOfSubKeyName,
746 NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
747 ++dwIndex, sizeOfSubKeyName=50 )
750 HKEY hkServiceProvider, hkServiceProviderAt;
751 GUID serviceProviderGUID;
752 DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
753 char atSubKey[51];
754 char returnBuffer[51];
755 WCHAR buff[51];
756 DWORD dwAtIndex;
757 LPCSTR atKey = "Address Types";
758 LPCSTR guidDataSubKey = "Guid";
759 FILETIME filetime;
762 TRACE(" this time through: %s\n", subKeyName );
764 /* Get a handle for this particular service provider */
765 if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_READ,
766 &hkServiceProvider ) != ERROR_SUCCESS )
768 ERR(": what the heck is going on?\n" );
769 continue;
772 if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
773 NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
774 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
776 ERR(": missing GUID registry data members\n" );
777 continue;
780 /* FIXME: Check return types to ensure we're interpreting data right */
781 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
782 CLSIDFromString( buff, &serviceProviderGUID );
783 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
785 /* Determine if this is the Service Provider that the user asked for */
786 if( !IsEqualGUID( &serviceProviderGUID, guidSP ) )
788 continue;
791 /* Get a handle for this particular service provider */
792 if( RegOpenKeyExA( hkServiceProvider, atKey, 0, KEY_READ,
793 &hkServiceProviderAt ) != ERROR_SUCCESS )
795 TRACE(": No Address Types registry data sub key/members\n" );
796 break;
799 /* Traverse all the address type we have available */
800 for( dwAtIndex=0;
801 RegEnumKeyExA( hkServiceProviderAt, dwAtIndex, atSubKey, &sizeOfSubKeyName,
802 NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
803 ++dwAtIndex, sizeOfSubKeyName=50 )
805 TRACE( "Found Address Type GUID %s\n", atSubKey );
807 /* FIXME: Check return types to ensure we're interpreting data right */
808 MultiByteToWideChar( CP_ACP, 0, atSubKey, -1, buff, sizeof(buff)/sizeof(WCHAR) );
809 CLSIDFromString( buff, &serviceProviderGUID );
810 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
812 /* The enumeration will return FALSE if we are not to continue */
813 if( !lpEnumAddressTypeCallback( &serviceProviderGUID, lpContext, 0 ) )
815 WARN("lpEnumCallback returning FALSE\n" );
816 break; /* FIXME: This most likely has to break from the procedure...*/
821 /* We only enumerate address types for 1 GUID. We've found it, so quit looking */
822 break;
825 return DP_OK;
828 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddressTypes
829 ( LPDIRECTPLAYLOBBY iface,
830 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback,
831 REFGUID guidSP,
832 LPVOID lpContext,
833 DWORD dwFlags )
835 FIXME(":stub\n");
836 return DPERR_OUTOFMEMORY;
839 /********************************************************************
841 * Enumerates what applications are registered with DirectPlay by
842 * invoking the callback function with lpContext.
845 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications
846 ( LPDIRECTPLAYLOBBY iface,
847 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback,
848 LPVOID lpContext,
849 DWORD dwFlags )
851 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
853 FIXME("(%p)->(%p,%p,0x%08x):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
855 return DPERR_OUTOFMEMORY;
858 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
859 ( LPDIRECTPLAYLOBBYA iface,
860 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback,
861 LPVOID lpContext,
862 DWORD dwFlags )
864 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
866 HKEY hkResult;
867 LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Applications";
868 LPCSTR guidDataSubKey = "Guid";
869 DWORD dwIndex, sizeOfSubKeyName=50;
870 char subKeyName[51];
871 FILETIME filetime;
873 TRACE("(%p)->(%p,%p,0x%08x)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
875 if( dwFlags != 0 )
877 return DPERR_INVALIDPARAMS;
880 if( !lpEnumLocalAppCallback )
882 return DPERR_INVALIDPARAMS;
885 /* Need to loop over the service providers in the registry */
886 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
887 0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
889 /* Hmmm. Does this mean that there are no service providers? */
890 ERR(": no service providers?\n");
891 return DP_OK;
894 /* Traverse all registered applications */
895 for( dwIndex=0;
896 RegEnumKeyExA( hkResult, dwIndex, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
897 ++dwIndex, sizeOfSubKeyName=50 )
900 HKEY hkServiceProvider;
901 GUID serviceProviderGUID;
902 DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
903 char returnBuffer[51];
904 WCHAR buff[51];
905 DPLAPPINFO dplAppInfo;
907 TRACE(" this time through: %s\n", subKeyName );
909 /* Get a handle for this particular service provider */
910 if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_READ,
911 &hkServiceProvider ) != ERROR_SUCCESS )
913 ERR(": what the heck is going on?\n" );
914 continue;
917 if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
918 NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
919 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
921 ERR(": missing GUID registry data members\n" );
922 continue;
925 /* FIXME: Check return types to ensure we're interpreting data right */
926 MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
927 CLSIDFromString( buff, &serviceProviderGUID );
928 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
930 dplAppInfo.dwSize = sizeof( dplAppInfo );
931 dplAppInfo.guidApplication = serviceProviderGUID;
932 dplAppInfo.u.lpszAppNameA = subKeyName;
934 EnterCriticalSection( &This->unk->DPL_lock );
936 memcpy( &This->dpl->hkCallbackKeyHack, &hkServiceProvider, sizeof( hkServiceProvider ) );
938 if( !lpEnumLocalAppCallback( &dplAppInfo, lpContext, dwFlags ) )
940 LeaveCriticalSection( &This->unk->DPL_lock );
941 break;
944 LeaveCriticalSection( &This->unk->DPL_lock );
947 return DP_OK;
950 /********************************************************************
952 * Retrieves the DPLCONNECTION structure that contains all the information
953 * needed to start and connect an application. This was generated using
954 * either the RunApplication or SetConnectionSettings methods.
956 * NOTES: If lpData is NULL then just return lpdwDataSize. This allows
957 * the data structure to be allocated by our caller which can then
958 * call this procedure/method again with a valid data pointer.
960 static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings
961 ( LPDIRECTPLAYLOBBYA iface,
962 DWORD dwAppID,
963 LPVOID lpData,
964 LPDWORD lpdwDataSize )
966 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
967 HRESULT hr;
969 TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
971 EnterCriticalSection( &This->unk->DPL_lock );
973 hr = DPLAYX_GetConnectionSettingsA( dwAppID,
974 lpData,
975 lpdwDataSize
978 LeaveCriticalSection( &This->unk->DPL_lock );
980 return hr;
983 static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings
984 ( LPDIRECTPLAYLOBBY iface,
985 DWORD dwAppID,
986 LPVOID lpData,
987 LPDWORD lpdwDataSize )
989 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
990 HRESULT hr;
992 TRACE("(%p)->(0x%08x,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
994 EnterCriticalSection( &This->unk->DPL_lock );
996 hr = DPLAYX_GetConnectionSettingsW( dwAppID,
997 lpData,
998 lpdwDataSize
1001 LeaveCriticalSection( &This->unk->DPL_lock );
1003 return hr;
1006 /********************************************************************
1008 * Retrieves the message sent between a lobby client and a DirectPlay
1009 * application. All messages are queued until received.
1012 static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage
1013 ( LPDIRECTPLAYLOBBYA iface,
1014 DWORD dwFlags,
1015 DWORD dwAppID,
1016 LPDWORD lpdwMessageFlags,
1017 LPVOID lpData,
1018 LPDWORD lpdwDataSize )
1020 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
1021 FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
1022 lpdwDataSize );
1023 return DPERR_OUTOFMEMORY;
1026 static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage
1027 ( LPDIRECTPLAYLOBBY iface,
1028 DWORD dwFlags,
1029 DWORD dwAppID,
1030 LPDWORD lpdwMessageFlags,
1031 LPVOID lpData,
1032 LPDWORD lpdwDataSize )
1034 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1035 FIXME(":stub %p %08x %08x %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
1036 lpdwDataSize );
1037 return DPERR_OUTOFMEMORY;
1040 typedef struct tagRunApplicationEnumStruct
1042 IDirectPlayLobbyAImpl* This;
1044 GUID appGUID;
1045 LPSTR lpszPath;
1046 LPSTR lpszFileName;
1047 LPSTR lpszCommandLine;
1048 LPSTR lpszCurrentDirectory;
1049 } RunApplicationEnumStruct, *lpRunApplicationEnumStruct;
1051 /* To be called by RunApplication to find how to invoke the function */
1052 static BOOL CALLBACK RunApplicationA_EnumLocalApplications
1053 ( LPCDPLAPPINFO lpAppInfo,
1054 LPVOID lpContext,
1055 DWORD dwFlags )
1057 lpRunApplicationEnumStruct lpData = (lpRunApplicationEnumStruct)lpContext;
1059 if( IsEqualGUID( &lpAppInfo->guidApplication, &lpData->appGUID ) )
1061 char returnBuffer[200];
1062 DWORD returnType, sizeOfReturnBuffer;
1063 LPCSTR clSubKey = "CommandLine";
1064 LPCSTR cdSubKey = "CurrentDirectory";
1065 LPCSTR fileSubKey = "File";
1066 LPCSTR pathSubKey = "Path";
1068 /* FIXME: Lazy man hack - dplay struct has the present reg key saved */
1070 sizeOfReturnBuffer = 200;
1072 /* Get all the appropriate data from the registry */
1073 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, clSubKey,
1074 NULL, &returnType, (LPBYTE)returnBuffer,
1075 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1077 ERR( ": missing CommandLine registry data member\n" );
1079 else
1081 if ((lpData->lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1082 strcpy( lpData->lpszCommandLine, returnBuffer );
1085 sizeOfReturnBuffer = 200;
1087 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, cdSubKey,
1088 NULL, &returnType, (LPBYTE)returnBuffer,
1089 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1091 ERR( ": missing CurrentDirectory registry data member\n" );
1093 else
1095 if ((lpData->lpszCurrentDirectory = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1096 strcpy( lpData->lpszCurrentDirectory, returnBuffer );
1099 sizeOfReturnBuffer = 200;
1101 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, fileSubKey,
1102 NULL, &returnType, (LPBYTE)returnBuffer,
1103 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1105 ERR( ": missing File registry data member\n" );
1107 else
1109 if ((lpData->lpszFileName = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1110 strcpy( lpData->lpszFileName, returnBuffer );
1113 sizeOfReturnBuffer = 200;
1115 if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, pathSubKey,
1116 NULL, &returnType, (LPBYTE)returnBuffer,
1117 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
1119 ERR( ": missing Path registry data member\n" );
1121 else
1123 if ((lpData->lpszPath = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
1124 strcpy( lpData->lpszPath, returnBuffer );
1127 return FALSE; /* No need to keep going as we found what we wanted */
1130 return TRUE; /* Keep enumerating, haven't found the application yet */
1133 static BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
1134 LPHANDLE lphStart, LPHANDLE lphDeath,
1135 LPHANDLE lphRead )
1137 /* These are the handles for the created process */
1138 HANDLE hAppStart = 0, hAppDeath = 0, hAppRead = 0;
1139 SECURITY_ATTRIBUTES s_attrib;
1141 s_attrib.nLength = sizeof( s_attrib );
1142 s_attrib.lpSecurityDescriptor = NULL;
1143 s_attrib.bInheritHandle = TRUE;
1145 *lphStart = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
1146 *lphDeath = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
1147 *lphRead = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
1149 if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart,
1150 hDestProcess, &hAppStart,
1151 0, FALSE, DUPLICATE_SAME_ACCESS ) ) ||
1152 ( !DuplicateHandle( GetCurrentProcess(), *lphDeath,
1153 hDestProcess, &hAppDeath,
1154 0, FALSE, DUPLICATE_SAME_ACCESS ) ) ||
1155 ( !DuplicateHandle( GetCurrentProcess(), *lphRead,
1156 hDestProcess, &hAppRead,
1157 0, FALSE, DUPLICATE_SAME_ACCESS ) )
1160 if (*lphStart) { CloseHandle(*lphStart); *lphStart = 0; }
1161 if (*lphDeath) { CloseHandle(*lphDeath); *lphDeath = 0; }
1162 if (*lphRead) { CloseHandle(*lphRead); *lphRead = 0; }
1163 /* FIXME: Handle leak... */
1164 ERR( "Unable to dup handles\n" );
1165 return FALSE;
1168 if( !DPLAYX_SetLobbyHandles( dwDestProcessId,
1169 hAppStart, hAppDeath, hAppRead ) )
1171 /* FIXME: Handle leak... */
1172 return FALSE;
1175 return TRUE;
1179 /********************************************************************
1181 * Starts an application and passes to it all the information to
1182 * connect to a session.
1185 static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
1186 ( LPDIRECTPLAYLOBBYA iface,
1187 DWORD dwFlags,
1188 LPDWORD lpdwAppID,
1189 LPDPLCONNECTION lpConn,
1190 HANDLE hReceiveEvent )
1192 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
1193 HRESULT hr;
1194 RunApplicationEnumStruct enumData;
1195 char temp[200];
1196 STARTUPINFOA startupInfo;
1197 PROCESS_INFORMATION newProcessInfo;
1198 LPSTR appName;
1199 DWORD dwSuspendCount;
1200 HANDLE hStart, hDeath, hSettingRead;
1202 TRACE( "(%p)->(0x%08x,%p,%p,%p)\n",
1203 This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
1205 if( dwFlags != 0 )
1207 return DPERR_INVALIDPARAMS;
1210 if( DPLAYX_AnyLobbiesWaitingForConnSettings() )
1212 FIXME( "Waiting lobby not being handled correctly\n" );
1215 EnterCriticalSection( &This->unk->DPL_lock );
1217 ZeroMemory( &enumData, sizeof( enumData ) );
1218 enumData.This = This;
1219 enumData.appGUID = lpConn->lpSessionDesc->guidApplication;
1221 /* Our callback function will fill up the enumData structure with all the information
1222 required to start a new process */
1223 IDirectPlayLobby_EnumLocalApplications( iface, RunApplicationA_EnumLocalApplications,
1224 (&enumData), 0 );
1226 /* First the application name */
1227 strcpy( temp, enumData.lpszPath );
1228 strcat( temp, "\\" );
1229 strcat( temp, enumData.lpszFileName );
1230 HeapFree( GetProcessHeap(), 0, enumData.lpszPath );
1231 HeapFree( GetProcessHeap(), 0, enumData.lpszFileName );
1232 if ((appName = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) strcpy( appName, temp );
1234 /* Now the command line */
1235 strcat( temp, " " );
1236 strcat( temp, enumData.lpszCommandLine );
1237 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
1238 if ((enumData.lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 )))
1239 strcpy( enumData.lpszCommandLine, temp );
1241 ZeroMemory( &startupInfo, sizeof( startupInfo ) );
1242 startupInfo.cb = sizeof( startupInfo );
1243 /* FIXME: Should any fields be filled in? */
1245 ZeroMemory( &newProcessInfo, sizeof( newProcessInfo ) );
1247 if( !CreateProcessA( appName,
1248 enumData.lpszCommandLine,
1249 NULL,
1250 NULL,
1251 FALSE,
1252 CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_SUSPENDED, /* Creation Flags */
1253 NULL,
1254 enumData.lpszCurrentDirectory,
1255 &startupInfo,
1256 &newProcessInfo
1260 ERR( "Failed to create process for app %s\n", appName );
1262 HeapFree( GetProcessHeap(), 0, appName );
1263 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
1264 HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
1266 LeaveCriticalSection( &This->unk->DPL_lock );
1267 return DPERR_CANTCREATEPROCESS;
1270 HeapFree( GetProcessHeap(), 0, appName );
1271 HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
1272 HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
1274 /* Reserve this global application id! */
1275 if( !DPLAYX_CreateLobbyApplication( newProcessInfo.dwProcessId ) )
1277 ERR( "Unable to create global application data for 0x%08x\n",
1278 newProcessInfo.dwProcessId );
1281 hr = IDirectPlayLobby_SetConnectionSettings( iface, 0, newProcessInfo.dwProcessId, lpConn );
1283 if( hr != DP_OK )
1285 ERR( "SetConnectionSettings failure %s\n", DPLAYX_HresultToString( hr ) );
1286 LeaveCriticalSection( &This->unk->DPL_lock );
1287 return hr;
1290 /* Setup the handles for application notification */
1291 DPL_CreateAndSetLobbyHandles( newProcessInfo.dwProcessId,
1292 newProcessInfo.hProcess,
1293 &hStart, &hDeath, &hSettingRead );
1295 /* Setup the message thread ID */
1296 This->dpl->dwMsgThread =
1297 CreateLobbyMessageReceptionThread( hReceiveEvent, hStart, hDeath, hSettingRead );
1299 DPLAYX_SetLobbyMsgThreadId( newProcessInfo.dwProcessId, This->dpl->dwMsgThread );
1301 LeaveCriticalSection( &This->unk->DPL_lock );
1303 /* Everything seems to have been set correctly, update the dwAppID */
1304 *lpdwAppID = newProcessInfo.dwProcessId;
1306 /* Unsuspend the process - should return the prev suspension count */
1307 if( ( dwSuspendCount = ResumeThread( newProcessInfo.hThread ) ) != 1 )
1309 ERR( "ResumeThread failed with 0x%08x\n", dwSuspendCount );
1312 return DP_OK;
1315 static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication
1316 ( LPDIRECTPLAYLOBBY iface,
1317 DWORD dwFlags,
1318 LPDWORD lpdwAppID,
1319 LPDPLCONNECTION lpConn,
1320 HANDLE hReceiveEvent )
1322 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1323 FIXME( "(%p)->(0x%08x,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
1324 return DPERR_OUTOFMEMORY;
1327 /********************************************************************
1329 * Sends a message between the application and the lobby client.
1330 * All messages are queued until received.
1333 static HRESULT WINAPI IDirectPlayLobbyAImpl_SendLobbyMessage
1334 ( LPDIRECTPLAYLOBBYA iface,
1335 DWORD dwFlags,
1336 DWORD dwAppID,
1337 LPVOID lpData,
1338 DWORD dwDataSize )
1340 FIXME(":stub\n");
1341 return DPERR_OUTOFMEMORY;
1344 static HRESULT WINAPI IDirectPlayLobbyWImpl_SendLobbyMessage
1345 ( LPDIRECTPLAYLOBBY iface,
1346 DWORD dwFlags,
1347 DWORD dwAppID,
1348 LPVOID lpData,
1349 DWORD dwDataSize )
1351 FIXME(":stub\n");
1352 return DPERR_OUTOFMEMORY;
1355 /********************************************************************
1357 * Modifies the DPLCONNECTION structure to contain all information
1358 * needed to start and connect an application.
1361 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings
1362 ( LPDIRECTPLAYLOBBY iface,
1363 DWORD dwFlags,
1364 DWORD dwAppID,
1365 LPDPLCONNECTION lpConn )
1367 IDirectPlayLobbyWImpl *This = (IDirectPlayLobbyWImpl *)iface;
1368 HRESULT hr;
1370 TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn );
1372 EnterCriticalSection( &This->unk->DPL_lock );
1374 hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
1376 /* FIXME: Don't think that this is supposed to fail, but the documentation
1377 is somewhat sketchy. I'll try creating a lobby application
1378 for this... */
1379 if( hr == DPERR_NOTLOBBIED )
1381 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1382 if( dwAppID == 0 )
1384 dwAppID = GetCurrentProcessId();
1386 DPLAYX_CreateLobbyApplication( dwAppID );
1387 hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
1390 LeaveCriticalSection( &This->unk->DPL_lock );
1392 return hr;
1395 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings
1396 ( LPDIRECTPLAYLOBBYA iface,
1397 DWORD dwFlags,
1398 DWORD dwAppID,
1399 LPDPLCONNECTION lpConn )
1401 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface;
1402 HRESULT hr;
1404 TRACE("(%p)->(0x%08x,0x%08x,%p)\n", This, dwFlags, dwAppID, lpConn );
1406 EnterCriticalSection( &This->unk->DPL_lock );
1408 hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
1410 /* FIXME: Don't think that this is supposed to fail, but the documentation
1411 is somewhat sketchy. I'll try creating a lobby application
1412 for this... */
1413 if( hr == DPERR_NOTLOBBIED )
1415 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1416 dwAppID = GetCurrentProcessId();
1417 DPLAYX_CreateLobbyApplication( dwAppID );
1418 hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
1421 LeaveCriticalSection( &This->unk->DPL_lock );
1423 return hr;
1426 /********************************************************************
1428 * Registers an event that will be set when a lobby message is received.
1431 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1432 ( LPDIRECTPLAYLOBBYA iface,
1433 DWORD dwFlags,
1434 DWORD dwAppID,
1435 HANDLE hReceiveEvent )
1437 FIXME(":stub\n");
1438 return DPERR_OUTOFMEMORY;
1441 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1442 ( LPDIRECTPLAYLOBBY iface,
1443 DWORD dwFlags,
1444 DWORD dwAppID,
1445 HANDLE hReceiveEvent )
1447 FIXME(":stub\n");
1448 return DPERR_OUTOFMEMORY;
1452 /* DPL 2 methods */
1453 static HRESULT WINAPI IDirectPlayLobby2WImpl_CreateCompoundAddress
1454 ( LPDIRECTPLAYLOBBY2 iface,
1455 LPCDPCOMPOUNDADDRESSELEMENT lpElements,
1456 DWORD dwElementCount,
1457 LPVOID lpAddress,
1458 LPDWORD lpdwAddressSize )
1460 return DPL_CreateCompoundAddress( lpElements, dwElementCount, lpAddress, lpdwAddressSize, FALSE );
1463 static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress
1464 ( LPDIRECTPLAYLOBBY2A iface,
1465 LPCDPCOMPOUNDADDRESSELEMENT lpElements,
1466 DWORD dwElementCount,
1467 LPVOID lpAddress,
1468 LPDWORD lpdwAddressSize )
1470 return DPL_CreateCompoundAddress( lpElements, dwElementCount, lpAddress, lpdwAddressSize, TRUE );
1473 HRESULT DPL_CreateCompoundAddress
1474 ( LPCDPCOMPOUNDADDRESSELEMENT lpElements,
1475 DWORD dwElementCount,
1476 LPVOID lpAddress,
1477 LPDWORD lpdwAddressSize,
1478 BOOL bAnsiInterface )
1480 DWORD dwSizeRequired = 0;
1481 DWORD dwElements;
1482 LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements = lpElements;
1484 TRACE("(%p,0x%08x,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize );
1486 /* Parameter check */
1487 if( ( lpElements == NULL ) ||
1488 ( dwElementCount == 0 ) /* FIXME: Not sure if this is a failure case */
1491 return DPERR_INVALIDPARAMS;
1494 /* Add the total size chunk */
1495 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( DWORD );
1497 /* Calculate the size of the buffer required */
1498 for ( dwElements = dwElementCount; dwElements > 0; --dwElements, ++lpElements )
1500 if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ServiceProvider ) ) ||
1501 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
1504 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( GUID );
1506 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Phone ) ) ||
1507 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Modem ) ) ||
1508 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
1511 if( !bAnsiInterface )
1513 ERR( "Ansi GUIDs used for unicode interface\n" );
1514 return DPERR_INVALIDFLAGS;
1517 dwSizeRequired += sizeof( DPADDRESS ) + lpElements->dwDataSize;
1519 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
1520 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ModemW ) ) ||
1521 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
1524 if( bAnsiInterface )
1526 ERR( "Unicode GUIDs used for ansi interface\n" );
1527 return DPERR_INVALIDFLAGS;
1530 FIXME( "Right size for unicode interface?\n" );
1531 dwSizeRequired += sizeof( DPADDRESS ) + lpElements->dwDataSize * sizeof( WCHAR );
1533 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
1535 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( WORD );
1537 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
1539 FIXME( "Right size for unicode interface?\n" );
1540 dwSizeRequired += sizeof( DPADDRESS ) + sizeof( DPCOMPORTADDRESS ); /* FIXME: Right size? */
1542 else
1544 ERR( "Unknown GUID %s\n", debugstr_guid(&lpElements->guidDataType) );
1545 return DPERR_INVALIDFLAGS;
1549 /* The user wants to know how big a buffer to allocate for us */
1550 if( ( lpAddress == NULL ) ||
1551 ( *lpdwAddressSize < dwSizeRequired )
1554 *lpdwAddressSize = dwSizeRequired;
1555 return DPERR_BUFFERTOOSMALL;
1558 /* Add the total size chunk */
1560 LPDPADDRESS lpdpAddress = lpAddress;
1562 lpdpAddress->guidDataType = DPAID_TotalSize;
1563 lpdpAddress->dwDataSize = sizeof( DWORD );
1564 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1566 *(LPDWORD)lpAddress = dwSizeRequired;
1567 lpAddress = (char *) lpAddress + sizeof( DWORD );
1570 /* Calculate the size of the buffer required */
1571 for( dwElements = dwElementCount, lpElements = lpOrigElements;
1572 dwElements > 0;
1573 --dwElements, ++lpElements )
1575 if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ServiceProvider ) ) ||
1576 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
1579 LPDPADDRESS lpdpAddress = lpAddress;
1581 lpdpAddress->guidDataType = lpElements->guidDataType;
1582 lpdpAddress->dwDataSize = sizeof( GUID );
1583 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1585 CopyMemory( lpAddress, lpElements->lpData, sizeof( GUID ) );
1586 lpAddress = (char *) lpAddress + sizeof( GUID );
1588 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Phone ) ) ||
1589 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Modem ) ) ||
1590 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
1593 LPDPADDRESS lpdpAddress = lpAddress;
1595 lpdpAddress->guidDataType = lpElements->guidDataType;
1596 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1597 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1599 lstrcpynA( lpAddress, lpElements->lpData, lpElements->dwDataSize );
1600 lpAddress = (char *) lpAddress + lpElements->dwDataSize;
1602 else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
1603 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ModemW ) ) ||
1604 ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
1607 LPDPADDRESS lpdpAddress = lpAddress;
1609 lpdpAddress->guidDataType = lpElements->guidDataType;
1610 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1611 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1613 lstrcpynW( lpAddress, lpElements->lpData, lpElements->dwDataSize );
1614 lpAddress = (char *) lpAddress + lpElements->dwDataSize * sizeof( WCHAR );
1616 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
1618 LPDPADDRESS lpdpAddress = lpAddress;
1620 lpdpAddress->guidDataType = lpElements->guidDataType;
1621 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1622 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1624 *((LPWORD)lpAddress) = *((LPWORD)lpElements->lpData);
1625 lpAddress = (char *) lpAddress + sizeof( WORD );
1627 else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
1629 LPDPADDRESS lpdpAddress = lpAddress;
1631 lpdpAddress->guidDataType = lpElements->guidDataType;
1632 lpdpAddress->dwDataSize = lpElements->dwDataSize;
1633 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1635 CopyMemory( lpAddress, lpElements->lpData, sizeof( DPADDRESS ) );
1636 lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
1640 return DP_OK;
1643 /* DPL 3 methods */
1645 static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
1646 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, REFIID riid,
1647 LPVOID* lplpDP, IUnknown* pUnk )
1649 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface ;
1650 return DPL_ConnectEx( This, dwFlags, riid, lplpDP, pUnk );
1653 static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
1654 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, REFIID riid,
1655 LPVOID* lplpDP, IUnknown* pUnk )
1657 IDirectPlayLobbyAImpl *This = (IDirectPlayLobbyAImpl *)iface ;
1658 return DPL_ConnectEx( This, dwFlags, riid, lplpDP, pUnk );
1661 static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
1662 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, LPDPAPPLICATIONDESC lpAppDesc )
1664 FIXME(":stub\n");
1665 return DP_OK;
1668 static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
1669 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, LPDPAPPLICATIONDESC lpAppDesc )
1671 FIXME(":stub\n");
1672 return DP_OK;
1675 static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
1676 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, REFGUID lpAppDesc )
1678 FIXME(":stub\n");
1679 return DP_OK;
1682 static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
1683 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, REFGUID lpAppDesc )
1685 FIXME(":stub\n");
1686 return DP_OK;
1689 static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
1690 ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags )
1692 HRESULT hr = DP_OK;
1693 BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL);
1695 TRACE( "(%p)->(0x%08x)\n", iface, dwFlags );
1697 if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
1699 /* FIXME: What is the correct error return code? */
1700 hr = DPERR_NOTLOBBIED;
1703 return hr;
1706 static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
1707 ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags )
1709 HRESULT hr = DP_OK;
1710 BOOL bStartWait = !(dwFlags & DPLWAIT_CANCEL);
1712 TRACE( "(%p)->(0x%08x)\n", iface, dwFlags );
1714 if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
1716 /* FIXME: What is the correct error return code? */
1717 hr = DPERR_NOTLOBBIED;
1720 return hr;
1724 /* Virtual Table definitions for DPL{1,2,3}{A,W} */
1726 /* Note: Hack so we can reuse the old functions without compiler warnings */
1727 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1728 # define XCAST(fun) (typeof(directPlayLobbyAVT.fun))
1729 #else
1730 # define XCAST(fun) (void*)
1731 #endif
1733 /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
1734 /* All lobby 1 methods are exactly the same except QueryInterface */
1735 static const IDirectPlayLobbyVtbl directPlayLobbyAVT =
1738 XCAST(QueryInterface)DPL_QueryInterface,
1739 XCAST(AddRef)DPL_AddRef,
1740 XCAST(Release)DPL_Release,
1742 IDirectPlayLobbyAImpl_Connect,
1743 IDirectPlayLobbyAImpl_CreateAddress,
1744 IDirectPlayLobbyAImpl_EnumAddress,
1745 IDirectPlayLobbyAImpl_EnumAddressTypes,
1746 IDirectPlayLobbyAImpl_EnumLocalApplications,
1747 IDirectPlayLobbyAImpl_GetConnectionSettings,
1748 IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
1749 IDirectPlayLobbyAImpl_RunApplication,
1750 IDirectPlayLobbyAImpl_SendLobbyMessage,
1751 IDirectPlayLobbyAImpl_SetConnectionSettings,
1752 IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1754 #undef XCAST
1757 /* Note: Hack so we can reuse the old functions without compiler warnings */
1758 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1759 # define XCAST(fun) (typeof(directPlayLobbyWVT.fun))
1760 #else
1761 # define XCAST(fun) (void*)
1762 #endif
1764 /* Direct Play Lobby 1 (unicode) Virtual Table for methods */
1765 static const IDirectPlayLobbyVtbl directPlayLobbyWVT =
1768 XCAST(QueryInterface)DPL_QueryInterface,
1769 XCAST(AddRef)DPL_AddRef,
1770 XCAST(Release)DPL_Release,
1772 IDirectPlayLobbyWImpl_Connect,
1773 IDirectPlayLobbyWImpl_CreateAddress,
1774 IDirectPlayLobbyWImpl_EnumAddress,
1775 IDirectPlayLobbyWImpl_EnumAddressTypes,
1776 IDirectPlayLobbyWImpl_EnumLocalApplications,
1777 IDirectPlayLobbyWImpl_GetConnectionSettings,
1778 IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
1779 IDirectPlayLobbyWImpl_RunApplication,
1780 IDirectPlayLobbyWImpl_SendLobbyMessage,
1781 IDirectPlayLobbyWImpl_SetConnectionSettings,
1782 IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1784 #undef XCAST
1786 /* Note: Hack so we can reuse the old functions without compiler warnings */
1787 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1788 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1789 #else
1790 # define XCAST(fun) (void*)
1791 #endif
1793 /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
1794 static const IDirectPlayLobby2Vtbl directPlayLobby2AVT =
1797 XCAST(QueryInterface)DPL_QueryInterface,
1798 XCAST(AddRef)DPL_AddRef,
1799 XCAST(Release)DPL_Release,
1801 XCAST(Connect)IDirectPlayLobbyAImpl_Connect,
1802 XCAST(CreateAddress)IDirectPlayLobbyAImpl_CreateAddress,
1803 XCAST(EnumAddress)IDirectPlayLobbyAImpl_EnumAddress,
1804 XCAST(EnumAddressTypes)IDirectPlayLobbyAImpl_EnumAddressTypes,
1805 XCAST(EnumLocalApplications)IDirectPlayLobbyAImpl_EnumLocalApplications,
1806 XCAST(GetConnectionSettings)IDirectPlayLobbyAImpl_GetConnectionSettings,
1807 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
1808 XCAST(RunApplication)IDirectPlayLobbyAImpl_RunApplication,
1809 XCAST(SendLobbyMessage)IDirectPlayLobbyAImpl_SendLobbyMessage,
1810 XCAST(SetConnectionSettings)IDirectPlayLobbyAImpl_SetConnectionSettings,
1811 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyAImpl_SetLobbyMessageEvent,
1813 IDirectPlayLobby2AImpl_CreateCompoundAddress
1815 #undef XCAST
1817 /* Note: Hack so we can reuse the old functions without compiler warnings */
1818 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1819 # define XCAST(fun) (typeof(directPlayLobby2WVT.fun))
1820 #else
1821 # define XCAST(fun) (void*)
1822 #endif
1824 /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
1825 static const IDirectPlayLobby2Vtbl directPlayLobby2WVT =
1828 XCAST(QueryInterface)DPL_QueryInterface,
1829 XCAST(AddRef)DPL_AddRef,
1830 XCAST(Release)DPL_Release,
1832 XCAST(Connect)IDirectPlayLobbyWImpl_Connect,
1833 XCAST(CreateAddress)IDirectPlayLobbyWImpl_CreateAddress,
1834 XCAST(EnumAddress)IDirectPlayLobbyWImpl_EnumAddress,
1835 XCAST(EnumAddressTypes)IDirectPlayLobbyWImpl_EnumAddressTypes,
1836 XCAST(EnumLocalApplications)IDirectPlayLobbyWImpl_EnumLocalApplications,
1837 XCAST(GetConnectionSettings)IDirectPlayLobbyWImpl_GetConnectionSettings,
1838 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
1839 XCAST(RunApplication)IDirectPlayLobbyWImpl_RunApplication,
1840 XCAST(SendLobbyMessage)IDirectPlayLobbyWImpl_SendLobbyMessage,
1841 XCAST(SetConnectionSettings)IDirectPlayLobbyWImpl_SetConnectionSettings,
1842 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyWImpl_SetLobbyMessageEvent,
1844 IDirectPlayLobby2WImpl_CreateCompoundAddress
1846 #undef XCAST
1848 /* Direct Play Lobby 3 (ascii) Virtual Table for methods */
1850 /* Note: Hack so we can reuse the old functions without compiler warnings */
1851 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1852 # define XCAST(fun) (typeof(directPlayLobby3AVT.fun))
1853 #else
1854 # define XCAST(fun) (void*)
1855 #endif
1857 static const IDirectPlayLobby3Vtbl directPlayLobby3AVT =
1859 XCAST(QueryInterface)DPL_QueryInterface,
1860 XCAST(AddRef)DPL_AddRef,
1861 XCAST(Release)DPL_Release,
1863 XCAST(Connect)IDirectPlayLobbyAImpl_Connect,
1864 XCAST(CreateAddress)IDirectPlayLobbyAImpl_CreateAddress,
1865 XCAST(EnumAddress)IDirectPlayLobbyAImpl_EnumAddress,
1866 XCAST(EnumAddressTypes)IDirectPlayLobbyAImpl_EnumAddressTypes,
1867 XCAST(EnumLocalApplications)IDirectPlayLobbyAImpl_EnumLocalApplications,
1868 XCAST(GetConnectionSettings)IDirectPlayLobbyAImpl_GetConnectionSettings,
1869 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
1870 XCAST(RunApplication)IDirectPlayLobbyAImpl_RunApplication,
1871 XCAST(SendLobbyMessage)IDirectPlayLobbyAImpl_SendLobbyMessage,
1872 XCAST(SetConnectionSettings)IDirectPlayLobbyAImpl_SetConnectionSettings,
1873 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyAImpl_SetLobbyMessageEvent,
1875 XCAST(CreateCompoundAddress)IDirectPlayLobby2AImpl_CreateCompoundAddress,
1877 IDirectPlayLobby3AImpl_ConnectEx,
1878 IDirectPlayLobby3AImpl_RegisterApplication,
1879 IDirectPlayLobby3AImpl_UnregisterApplication,
1880 IDirectPlayLobby3AImpl_WaitForConnectionSettings
1882 #undef XCAST
1884 /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
1886 /* Note: Hack so we can reuse the old functions without compiler warnings */
1887 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1888 # define XCAST(fun) (typeof(directPlayLobby3WVT.fun))
1889 #else
1890 # define XCAST(fun) (void*)
1891 #endif
1893 static const IDirectPlayLobby3Vtbl directPlayLobby3WVT =
1895 XCAST(QueryInterface)DPL_QueryInterface,
1896 XCAST(AddRef)DPL_AddRef,
1897 XCAST(Release)DPL_Release,
1899 XCAST(Connect)IDirectPlayLobbyWImpl_Connect,
1900 XCAST(CreateAddress)IDirectPlayLobbyWImpl_CreateAddress,
1901 XCAST(EnumAddress)IDirectPlayLobbyWImpl_EnumAddress,
1902 XCAST(EnumAddressTypes)IDirectPlayLobbyWImpl_EnumAddressTypes,
1903 XCAST(EnumLocalApplications)IDirectPlayLobbyWImpl_EnumLocalApplications,
1904 XCAST(GetConnectionSettings)IDirectPlayLobbyWImpl_GetConnectionSettings,
1905 XCAST(ReceiveLobbyMessage)IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
1906 XCAST(RunApplication)IDirectPlayLobbyWImpl_RunApplication,
1907 XCAST(SendLobbyMessage)IDirectPlayLobbyWImpl_SendLobbyMessage,
1908 XCAST(SetConnectionSettings)IDirectPlayLobbyWImpl_SetConnectionSettings,
1909 XCAST(SetLobbyMessageEvent)IDirectPlayLobbyWImpl_SetLobbyMessageEvent,
1911 XCAST(CreateCompoundAddress)IDirectPlayLobby2WImpl_CreateCompoundAddress,
1913 IDirectPlayLobby3WImpl_ConnectEx,
1914 IDirectPlayLobby3WImpl_RegisterApplication,
1915 IDirectPlayLobby3WImpl_UnregisterApplication,
1916 IDirectPlayLobby3WImpl_WaitForConnectionSettings
1918 #undef XCAST
1921 /*********************************************************
1923 * Direct Play Lobby Interface Implementation
1925 *********************************************************/
1927 /***************************************************************************
1928 * DirectPlayLobbyCreateA (DPLAYX.4)
1931 HRESULT WINAPI DirectPlayLobbyCreateA( LPGUID lpGUIDDSP,
1932 LPDIRECTPLAYLOBBYA *lplpDPL,
1933 IUnknown *lpUnk,
1934 LPVOID lpData,
1935 DWORD dwDataSize )
1937 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n",
1938 lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
1940 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1941 * equal 0. These fields are mostly for future expansion.
1943 if ( lpGUIDDSP || lpData || dwDataSize )
1945 *lplpDPL = NULL;
1946 return DPERR_INVALIDPARAMS;
1949 if( lpUnk )
1951 *lplpDPL = NULL;
1952 ERR("Bad parameters!\n" );
1953 return CLASS_E_NOAGGREGATION;
1956 return DPL_CreateInterface( &IID_IDirectPlayLobbyA, (void**)lplpDPL );
1959 /***************************************************************************
1960 * DirectPlayLobbyCreateW (DPLAYX.5)
1963 HRESULT WINAPI DirectPlayLobbyCreateW( LPGUID lpGUIDDSP,
1964 LPDIRECTPLAYLOBBY *lplpDPL,
1965 IUnknown *lpUnk,
1966 LPVOID lpData,
1967 DWORD dwDataSize )
1969 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08x\n",
1970 lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
1972 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
1973 * equal 0. These fields are mostly for future expansion.
1975 if ( lpGUIDDSP || lpData || dwDataSize )
1977 *lplpDPL = NULL;
1978 ERR("Bad parameters!\n" );
1979 return DPERR_INVALIDPARAMS;
1982 if( lpUnk )
1984 *lplpDPL = NULL;
1985 ERR("Bad parameters!\n" );
1986 return CLASS_E_NOAGGREGATION;
1989 return DPL_CreateInterface( &IID_IDirectPlayLobby, (void**)lplpDPL );