1 /* Direct Play Lobby 2 & 3 Implementation
3 * Copyright 1998,1999,2000 - Peter Hunnisett
5 * <presently under construction - contact hunnise@nortelnetworks.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/debug.h"
30 #include "dplayx_global.h"
31 #include "dplayx_messages.h"
32 #include "dplayx_queue.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(dplay
);
36 /*****************************************************************************
37 * Predeclare the interface implementation structures
39 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyAImpl
;
40 typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyWImpl
;
41 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2AImpl
;
42 typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2WImpl
;
43 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3AImpl
;
44 typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3WImpl
;
46 /* Forward declarations for this module helper methods */
47 HRESULT
DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements
, DWORD dwElementCount
,
48 LPVOID lpAddress
, LPDWORD lpdwAddressSize
, BOOL bAnsiInterface
);
50 HRESULT
DPL_CreateAddress( REFGUID guidSP
, REFGUID guidDataType
, LPCVOID lpData
, DWORD dwDataSize
,
51 LPVOID lpAddress
, LPDWORD lpdwAddressSize
, BOOL bAnsiInterface
);
55 extern HRESULT
DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
, LPCVOID lpAddress
,
56 DWORD dwAddressSize
, LPVOID lpContext
);
58 static HRESULT WINAPI
DPL_ConnectEx( IDirectPlayLobbyAImpl
* This
,
59 DWORD dwFlags
, REFIID riid
,
60 LPVOID
* lplpDP
, IUnknown
* pUnk
);
62 BOOL
DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId
, HANDLE hDestProcess
,
63 LPHANDLE lphStart
, LPHANDLE lphDeath
,
67 /*****************************************************************************
68 * IDirectPlayLobby {1,2,3} implementation structure
70 * The philosophy behind this extra pointer derefernce is that I wanted to
71 * have the same structure for all types of objects without having to do
72 * alot of casting. I also only wanted to implement an interface in the
73 * object it was "released" with IUnknown interface being implemented in the 1 version.
74 * Of course, with these new interfaces comes the data required to keep the state required
75 * by these interfaces. So, basically, the pointers contain the data associated with
76 * a release. If you use the data associated with release 3 in a release 2 object, you'll
77 * get a run time trap, as that won't have any data.
82 DPQ_ENTRY( DPLMSG
) msgs
; /* Link to next queued message */
84 typedef struct DPLMSG
* LPDPLMSG
;
86 typedef struct tagDirectPlayLobbyIUnknownData
89 CRITICAL_SECTION DPL_lock
;
90 } DirectPlayLobbyIUnknownData
;
92 typedef struct tagDirectPlayLobbyData
94 HKEY hkCallbackKeyHack
;
96 DPQ_HEAD( DPLMSG
) msgs
; /* List of messages received */
97 } DirectPlayLobbyData
;
99 typedef struct tagDirectPlayLobby2Data
102 } DirectPlayLobby2Data
;
104 typedef struct tagDirectPlayLobby3Data
107 } DirectPlayLobby3Data
;
109 #define DPL_IMPL_FIELDS \
110 ULONG ulInterfaceRef; \
111 DirectPlayLobbyIUnknownData* unk; \
112 DirectPlayLobbyData* dpl; \
113 DirectPlayLobby2Data* dpl2; \
114 DirectPlayLobby3Data* dpl3;
116 struct IDirectPlayLobbyImpl
118 ICOM_VFIELD(IDirectPlayLobby
);
122 struct IDirectPlayLobby2Impl
124 ICOM_VFIELD(IDirectPlayLobby2
);
128 struct IDirectPlayLobby3Impl
130 ICOM_VFIELD(IDirectPlayLobby3
);
135 /* Forward declarations of virtual tables */
136 static ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyWVT
;
137 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2WVT
;
138 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3WVT
;
140 static ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyAVT
;
141 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2AVT
;
142 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3AVT
;
147 static BOOL
DPL_CreateIUnknown( LPVOID lpDPL
)
149 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
151 This
->unk
= (DirectPlayLobbyIUnknownData
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
152 sizeof( *(This
->unk
) ) );
153 if ( This
->unk
== NULL
)
158 InitializeCriticalSection( &This
->unk
->DPL_lock
);
163 static BOOL
DPL_DestroyIUnknown( LPVOID lpDPL
)
165 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
167 DeleteCriticalSection( &This
->unk
->DPL_lock
);
168 HeapFree( GetProcessHeap(), 0, This
->unk
);
173 static BOOL
DPL_CreateLobby1( LPVOID lpDPL
)
175 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
177 This
->dpl
= (DirectPlayLobbyData
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
178 sizeof( *(This
->dpl
) ) );
179 if ( This
->dpl
== NULL
)
184 DPQ_INIT( This
->dpl
->msgs
);
189 static BOOL
DPL_DestroyLobby1( LPVOID lpDPL
)
191 ICOM_THIS(IDirectPlayLobbyAImpl
,lpDPL
);
193 if( This
->dpl
->dwMsgThread
)
195 FIXME( "Should kill the msg thread\n" );
198 DPQ_DELETEQ( This
->dpl
->msgs
, msgs
, LPDPLMSG
, cbDeleteElemFromHeap
);
200 /* Delete the contents */
201 HeapFree( GetProcessHeap(), 0, This
->dpl
);
206 static BOOL
DPL_CreateLobby2( LPVOID lpDPL
)
208 ICOM_THIS(IDirectPlayLobby2AImpl
,lpDPL
);
210 This
->dpl2
= (DirectPlayLobby2Data
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
211 sizeof( *(This
->dpl2
) ) );
212 if ( This
->dpl2
== NULL
)
220 static BOOL
DPL_DestroyLobby2( LPVOID lpDPL
)
222 ICOM_THIS(IDirectPlayLobby2AImpl
,lpDPL
);
224 HeapFree( GetProcessHeap(), 0, This
->dpl2
);
229 static BOOL
DPL_CreateLobby3( LPVOID lpDPL
)
231 ICOM_THIS(IDirectPlayLobby3AImpl
,lpDPL
);
233 This
->dpl3
= (DirectPlayLobby3Data
*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
234 sizeof( *(This
->dpl3
) ) );
235 if ( This
->dpl3
== NULL
)
243 static BOOL
DPL_DestroyLobby3( LPVOID lpDPL
)
245 ICOM_THIS(IDirectPlayLobby3AImpl
,lpDPL
);
247 HeapFree( GetProcessHeap(), 0, This
->dpl3
);
253 /* The COM interface for upversioning an interface
254 * We've been given a GUID (riid) and we need to replace the present
255 * interface with that of the requested interface.
257 * Snip from some Microsoft document:
258 * There are four requirements for implementations of QueryInterface (In these
259 * cases, "must succeed" means "must succeed barring catastrophic failure."):
261 * * The set of interfaces accessible on an object through
262 * IUnknown::QueryInterface must be static, not dynamic. This means that
263 * if a call to QueryInterface for a pointer to a specified interface
264 * succeeds the first time, it must succeed again, and if it fails the
265 * first time, it must fail on all subsequent queries.
266 * * It must be symmetric ~W if a client holds a pointer to an interface on
267 * an object, and queries for that interface, the call must succeed.
268 * * It must be reflexive ~W if a client holding a pointer to one interface
269 * queries successfully for another, a query through the obtained pointer
270 * for the first interface must succeed.
271 * * It must be transitive ~W if a client holding a pointer to one interface
272 * queries successfully for a second, and through that pointer queries
273 * successfully for a third interface, a query for the first interface
274 * through the pointer for the third interface must succeed.
277 HRESULT DPL_CreateInterface
278 ( REFIID riid
, LPVOID
* ppvObj
)
280 TRACE( " for %s\n", debugstr_guid( riid
) );
282 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
283 sizeof( IDirectPlayLobbyWImpl
) );
285 if( *ppvObj
== NULL
)
287 return DPERR_OUTOFMEMORY
;
290 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
292 ICOM_THIS(IDirectPlayLobbyWImpl
,*ppvObj
);
293 ICOM_VTBL(This
) = &directPlayLobbyWVT
;
295 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
297 ICOM_THIS(IDirectPlayLobbyAImpl
,*ppvObj
);
298 ICOM_VTBL(This
) = &directPlayLobbyAVT
;
300 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
302 ICOM_THIS(IDirectPlayLobby2WImpl
,*ppvObj
);
303 ICOM_VTBL(This
) = &directPlayLobby2WVT
;
305 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
307 ICOM_THIS(IDirectPlayLobby2AImpl
,*ppvObj
);
308 ICOM_VTBL(This
) = &directPlayLobby2AVT
;
310 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
312 ICOM_THIS(IDirectPlayLobby3WImpl
,*ppvObj
);
313 ICOM_VTBL(This
) = &directPlayLobby3WVT
;
315 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
317 ICOM_THIS(IDirectPlayLobby3AImpl
,*ppvObj
);
318 ICOM_VTBL(This
) = &directPlayLobby3AVT
;
322 /* Unsupported interface */
323 HeapFree( GetProcessHeap(), 0, *ppvObj
);
326 return E_NOINTERFACE
;
330 if ( DPL_CreateIUnknown( *ppvObj
) &&
331 DPL_CreateLobby1( *ppvObj
) &&
332 DPL_CreateLobby2( *ppvObj
) &&
333 DPL_CreateLobby3( *ppvObj
)
336 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
340 /* Initialize failed, destroy it */
341 DPL_DestroyLobby3( *ppvObj
);
342 DPL_DestroyLobby2( *ppvObj
);
343 DPL_DestroyLobby1( *ppvObj
);
344 DPL_DestroyIUnknown( *ppvObj
);
345 HeapFree( GetProcessHeap(), 0, *ppvObj
);
348 return DPERR_NOMEMORY
;
351 static HRESULT WINAPI DPL_QueryInterface
352 ( LPDIRECTPLAYLOBBYA iface
,
356 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
357 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid( riid
), ppvObj
);
359 *ppvObj
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
362 if( *ppvObj
== NULL
)
364 return DPERR_OUTOFMEMORY
;
367 CopyMemory( *ppvObj
, This
, sizeof( *This
) );
368 (*(IDirectPlayLobbyAImpl
**)ppvObj
)->ulInterfaceRef
= 0;
370 if( IsEqualGUID( &IID_IDirectPlayLobby
, riid
) )
372 ICOM_THIS(IDirectPlayLobbyWImpl
,*ppvObj
);
373 ICOM_VTBL(This
) = &directPlayLobbyWVT
;
375 else if( IsEqualGUID( &IID_IDirectPlayLobbyA
, riid
) )
377 ICOM_THIS(IDirectPlayLobbyAImpl
,*ppvObj
);
378 ICOM_VTBL(This
) = &directPlayLobbyAVT
;
380 else if( IsEqualGUID( &IID_IDirectPlayLobby2
, riid
) )
382 ICOM_THIS(IDirectPlayLobby2WImpl
,*ppvObj
);
383 ICOM_VTBL(This
) = &directPlayLobby2WVT
;
385 else if( IsEqualGUID( &IID_IDirectPlayLobby2A
, riid
) )
387 ICOM_THIS(IDirectPlayLobby2AImpl
,*ppvObj
);
388 ICOM_VTBL(This
) = &directPlayLobby2AVT
;
390 else if( IsEqualGUID( &IID_IDirectPlayLobby3
, riid
) )
392 ICOM_THIS(IDirectPlayLobby3WImpl
,*ppvObj
);
393 ICOM_VTBL(This
) = &directPlayLobby3WVT
;
395 else if( IsEqualGUID( &IID_IDirectPlayLobby3A
, riid
) )
397 ICOM_THIS(IDirectPlayLobby3AImpl
,*ppvObj
);
398 ICOM_VTBL(This
) = &directPlayLobby3AVT
;
402 /* Unsupported interface */
403 HeapFree( GetProcessHeap(), 0, *ppvObj
);
406 return E_NOINTERFACE
;
409 IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY
)*ppvObj
);
415 * Simple procedure. Just increment the reference count to this
416 * structure and return the new reference count.
418 static ULONG WINAPI DPL_AddRef
419 ( LPDIRECTPLAYLOBBY iface
)
421 ULONG ulInterfaceRefCount
, ulObjRefCount
;
422 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
424 ulObjRefCount
= InterlockedIncrement( &This
->unk
->ulObjRef
);
425 ulInterfaceRefCount
= InterlockedIncrement( &This
->ulInterfaceRef
);
427 TRACE( "ref count incremented to %lu:%lu for %p\n",
428 ulInterfaceRefCount
, ulObjRefCount
, This
);
430 return ulObjRefCount
;
434 * Simple COM procedure. Decrease the reference count to this object.
435 * If the object no longer has any reference counts, free up the associated
438 static ULONG WINAPI DPL_Release
439 ( LPDIRECTPLAYLOBBYA iface
)
441 ULONG ulInterfaceRefCount
, ulObjRefCount
;
442 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
444 ulObjRefCount
= InterlockedDecrement( &This
->unk
->ulObjRef
);
445 ulInterfaceRefCount
= InterlockedDecrement( &This
->ulInterfaceRef
);
447 TRACE( "ref count decremented to %lu:%lu for %p\n",
448 ulInterfaceRefCount
, ulObjRefCount
, This
);
450 /* Deallocate if this is the last reference to the object */
451 if( ulObjRefCount
== 0 )
453 DPL_DestroyLobby3( This
);
454 DPL_DestroyLobby2( This
);
455 DPL_DestroyLobby1( This
);
456 DPL_DestroyIUnknown( This
);
459 if( ulInterfaceRefCount
== 0 )
461 HeapFree( GetProcessHeap(), 0, This
);
464 return ulInterfaceRefCount
;
468 /********************************************************************
470 * Connects an application to the session specified by the DPLCONNECTION
471 * structure currently stored with the DirectPlayLobby object.
473 * Returns a IDirectPlay interface.
476 static HRESULT WINAPI DPL_ConnectEx
477 ( IDirectPlayLobbyAImpl
* This
,
484 DWORD dwOpenFlags
= 0;
485 DWORD dwConnSize
= 0;
486 LPDPLCONNECTION lpConn
;
488 FIXME("(%p)->(0x%08lx,%p,%p): semi stub\n", This
, dwFlags
, lplpDP
, pUnk
);
492 return DPERR_INVALIDPARAMS
;
495 /* Backwards compatibility */
498 dwFlags
= DPCONNECT_RETURNSTATUS
;
501 /* Create the DirectPlay interface */
502 if( ( hr
= DP_CreateInterface( riid
, lplpDP
) ) != DP_OK
)
504 ERR( "error creating interface for %s:%s.\n",
505 debugstr_guid( riid
), DPLAYX_HresultToString( hr
) );
509 /* FIXME: Is it safe/correct to use appID of 0? */
510 hr
= IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY
)This
,
511 0, NULL
, &dwConnSize
);
512 if( hr
!= DPERR_BUFFERTOOSMALL
)
517 lpConn
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwConnSize
);
521 return DPERR_NOMEMORY
;
524 /* FIXME: Is it safe/correct to use appID of 0? */
525 hr
= IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY
)This
,
526 0, lpConn
, &dwConnSize
);
533 /* - Need to call IDirectPlay::EnumConnections with the service provider to get that good information
534 * - Need to call CreateAddress to create the lpConnection param for IDirectPlay::InitializeConnection
535 * - Call IDirectPlay::InitializeConnection
538 /* Now initialize the Service Provider */
539 hr
= IDirectPlayX_InitializeConnection( (*(LPDIRECTPLAY2
*)lplpDP
),
543 /* Setup flags to pass into DirectPlay::Open */
544 if( dwFlags
& DPCONNECT_RETURNSTATUS
)
546 dwOpenFlags
|= DPOPEN_RETURNSTATUS
;
548 dwOpenFlags
|= lpConn
->dwFlags
;
550 hr
= IDirectPlayX_Open( (*(LPDIRECTPLAY2
*)lplpDP
), lpConn
->lpSessionDesc
,
553 HeapFree( GetProcessHeap(), 0, lpConn
);
558 static HRESULT WINAPI IDirectPlayLobbyAImpl_Connect
559 ( LPDIRECTPLAYLOBBYA iface
,
561 LPDIRECTPLAY2A
* lplpDP
,
564 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
565 return DPL_ConnectEx( This
, dwFlags
, &IID_IDirectPlay2A
,
566 (LPVOID
)lplpDP
, pUnk
);
569 static HRESULT WINAPI IDirectPlayLobbyWImpl_Connect
570 ( LPDIRECTPLAYLOBBY iface
,
572 LPDIRECTPLAY2
* lplpDP
,
575 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
); /* Yes cast to A */
576 return DPL_ConnectEx( This
, dwFlags
, &IID_IDirectPlay2
,
577 (LPVOID
)lplpDP
, pUnk
);
580 /********************************************************************
582 * Creates a DirectPlay Address, given a service provider-specific network
584 * Returns an address contains the globally unique identifier
585 * (GUID) of the service provider and data that the service provider can
586 * interpret as a network address.
588 * NOTE: It appears that this method is supposed to be really really stupid
589 * with no error checking on the contents.
591 static HRESULT WINAPI IDirectPlayLobbyAImpl_CreateAddress
592 ( LPDIRECTPLAYLOBBYA iface
,
594 REFGUID guidDataType
,
598 LPDWORD lpdwAddressSize
)
600 return DPL_CreateAddress( guidSP
, guidDataType
, lpData
, dwDataSize
,
601 lpAddress
, lpdwAddressSize
, TRUE
);
604 static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress
605 ( LPDIRECTPLAYLOBBY iface
,
607 REFGUID guidDataType
,
611 LPDWORD lpdwAddressSize
)
613 return DPL_CreateAddress( guidSP
, guidDataType
, lpData
, dwDataSize
,
614 lpAddress
, lpdwAddressSize
, FALSE
);
617 HRESULT
DPL_CreateAddress(
619 REFGUID guidDataType
,
623 LPDWORD lpdwAddressSize
,
624 BOOL bAnsiInterface
)
626 const DWORD dwNumAddElements
= 2; /* Service Provide & address data type */
627 DPCOMPOUNDADDRESSELEMENT addressElements
[ 2 /* dwNumAddElements */ ];
629 TRACE( "(%p)->(%p,%p,0x%08lx,%p,%p,%d)\n", guidSP
, guidDataType
, lpData
, dwDataSize
,
630 lpAddress
, lpdwAddressSize
, bAnsiInterface
);
632 addressElements
[ 0 ].guidDataType
= DPAID_ServiceProvider
;
633 addressElements
[ 0 ].dwDataSize
= sizeof( GUID
);
634 addressElements
[ 0 ].lpData
= (LPVOID
)guidSP
;
636 addressElements
[ 1 ].guidDataType
= *guidDataType
;
637 addressElements
[ 1 ].dwDataSize
= dwDataSize
;
638 addressElements
[ 1 ].lpData
= (LPVOID
)lpData
;
640 /* Call CreateCompoundAddress to cut down on code.
641 NOTE: We can do this because we don't support DPL 1 interfaces! */
642 return DPL_CreateCompoundAddress( addressElements
, dwNumAddElements
,
643 lpAddress
, lpdwAddressSize
, bAnsiInterface
);
648 /********************************************************************
650 * Parses out chunks from the DirectPlay Address buffer by calling the
651 * given callback function, with lpContext, for each of the chunks.
654 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress
655 ( LPDIRECTPLAYLOBBYA iface
,
656 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
,
661 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
663 TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
664 dwAddressSize
, lpContext
);
666 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
669 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress
670 ( LPDIRECTPLAYLOBBY iface
,
671 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
,
676 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
678 TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This
, lpEnumAddressCallback
, lpAddress
,
679 dwAddressSize
, lpContext
);
681 return DPL_EnumAddress( lpEnumAddressCallback
, lpAddress
, dwAddressSize
, lpContext
);
684 extern HRESULT
DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback
, LPCVOID lpAddress
,
685 DWORD dwAddressSize
, LPVOID lpContext
)
687 DWORD dwTotalSizeEnumerated
= 0;
689 /* FIXME: First chunk is always the total size chunk - Should we report it? */
691 while ( dwTotalSizeEnumerated
< dwAddressSize
)
693 LPDPADDRESS lpElements
= (LPDPADDRESS
)lpAddress
;
694 DWORD dwSizeThisEnumeration
;
696 /* Invoke the enum method. If false is returned, stop enumeration */
697 if ( !lpEnumAddressCallback( &lpElements
->guidDataType
,
698 lpElements
->dwDataSize
,
699 (BYTE
*)lpElements
+ sizeof( DPADDRESS
),
705 dwSizeThisEnumeration
= sizeof( DPADDRESS
) + lpElements
->dwDataSize
;
706 lpAddress
= (BYTE
*) lpAddress
+ dwSizeThisEnumeration
;
707 dwTotalSizeEnumerated
+= dwSizeThisEnumeration
;
713 /********************************************************************
715 * Enumerates all the address types that a given service provider needs to
716 * build the DirectPlay Address.
719 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
720 ( LPDIRECTPLAYLOBBYA iface
,
721 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback
,
726 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
729 LPCSTR searchSubKey
= "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
730 DWORD dwIndex
, sizeOfSubKeyName
=50;
734 TRACE(" (%p)->(%p,%p,%p,0x%08lx)\n", This
, lpEnumAddressTypeCallback
, guidSP
, lpContext
, dwFlags
);
738 return DPERR_INVALIDPARAMS
;
741 if( !lpEnumAddressTypeCallback
|| !*lpEnumAddressTypeCallback
)
743 return DPERR_INVALIDPARAMS
;
748 return DPERR_INVALIDOBJECT
;
751 /* Need to loop over the service providers in the registry */
752 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE
, searchSubKey
,
753 0, KEY_READ
, &hkResult
) != ERROR_SUCCESS
)
755 /* Hmmm. Does this mean that there are no service providers? */
756 ERR(": no service providers?\n");
760 /* Traverse all the service providers we have available */
762 RegEnumKeyExA( hkResult
, dwIndex
, subKeyName
, &sizeOfSubKeyName
,
763 NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
764 ++dwIndex
, sizeOfSubKeyName
=50 )
767 HKEY hkServiceProvider
, hkServiceProviderAt
;
768 GUID serviceProviderGUID
;
769 DWORD returnTypeGUID
, sizeOfReturnBuffer
= 50;
771 char returnBuffer
[51];
774 LPSTR atKey
= "Address Types";
775 LPSTR guidDataSubKey
= "Guid";
779 TRACE(" this time through: %s\n", subKeyName
);
781 /* Get a handle for this particular service provider */
782 if( RegOpenKeyExA( hkResult
, subKeyName
, 0, KEY_READ
,
783 &hkServiceProvider
) != ERROR_SUCCESS
)
785 ERR(": what the heck is going on?\n" );
789 if( RegQueryValueExA( hkServiceProvider
, guidDataSubKey
,
790 NULL
, &returnTypeGUID
, returnBuffer
,
791 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
793 ERR(": missing GUID registry data members\n" );
797 /* FIXME: Check return types to ensure we're interpreting data right */
798 MultiByteToWideChar( CP_ACP
, 0, returnBuffer
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
799 CLSIDFromString( (LPCOLESTR
)buff
, &serviceProviderGUID
);
800 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
802 /* Determine if this is the Service Provider that the user asked for */
803 if( !IsEqualGUID( &serviceProviderGUID
, guidSP
) )
808 /* Get a handle for this particular service provider */
809 if( RegOpenKeyExA( hkServiceProvider
, atKey
, 0, KEY_READ
,
810 &hkServiceProviderAt
) != ERROR_SUCCESS
)
812 TRACE(": No Address Types registry data sub key/members\n" );
816 /* Traverse all the address type we have available */
818 RegEnumKeyExA( hkServiceProviderAt
, dwAtIndex
, atSubKey
, &sizeOfSubKeyName
,
819 NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
820 ++dwAtIndex
, sizeOfSubKeyName
=50 )
822 TRACE( "Found Address Type GUID %s\n", atSubKey
);
824 /* FIXME: Check return types to ensure we're interpreting data right */
825 MultiByteToWideChar( CP_ACP
, 0, atSubKey
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
826 CLSIDFromString( (LPCOLESTR
)buff
, &serviceProviderGUID
);
827 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
829 /* The enumeration will return FALSE if we are not to continue */
830 if( !lpEnumAddressTypeCallback( &serviceProviderGUID
, lpContext
, 0 ) )
832 WARN("lpEnumCallback returning FALSE\n" );
833 break; /* FIXME: This most likely has to break from the procedure...*/
838 /* We only enumerate address types for 1 GUID. We've found it, so quit looking */
845 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddressTypes
846 ( LPDIRECTPLAYLOBBY iface
,
847 LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback
,
853 return DPERR_OUTOFMEMORY
;
856 /********************************************************************
858 * Enumerates what applications are registered with DirectPlay by
859 * invoking the callback function with lpContext.
862 static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications
863 ( LPDIRECTPLAYLOBBY iface
,
864 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback
,
868 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
870 FIXME("(%p)->(%p,%p,0x%08lx):stub\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
872 return DPERR_OUTOFMEMORY
;
875 static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
876 ( LPDIRECTPLAYLOBBYA iface
,
877 LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback
,
881 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
884 LPCSTR searchSubKey
= "SOFTWARE\\Microsoft\\DirectPlay\\Applications";
885 LPSTR guidDataSubKey
= "Guid";
886 DWORD dwIndex
, sizeOfSubKeyName
=50;
890 TRACE("(%p)->(%p,%p,0x%08lx)\n", This
, lpEnumLocalAppCallback
, lpContext
, dwFlags
);
894 return DPERR_INVALIDPARAMS
;
897 if( !lpEnumLocalAppCallback
|| !*lpEnumLocalAppCallback
)
899 return DPERR_INVALIDPARAMS
;
902 /* Need to loop over the service providers in the registry */
903 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE
, searchSubKey
,
904 0, KEY_READ
, &hkResult
) != ERROR_SUCCESS
)
906 /* Hmmm. Does this mean that there are no service providers? */
907 ERR(": no service providers?\n");
911 /* Traverse all registered applications */
913 RegEnumKeyExA( hkResult
, dwIndex
, subKeyName
, &sizeOfSubKeyName
, NULL
, NULL
, NULL
, &filetime
) != ERROR_NO_MORE_ITEMS
;
914 ++dwIndex
, sizeOfSubKeyName
=50 )
917 HKEY hkServiceProvider
;
918 GUID serviceProviderGUID
;
919 DWORD returnTypeGUID
, sizeOfReturnBuffer
= 50;
920 char returnBuffer
[51];
922 DPLAPPINFO dplAppInfo
;
924 TRACE(" this time through: %s\n", subKeyName
);
926 /* Get a handle for this particular service provider */
927 if( RegOpenKeyExA( hkResult
, subKeyName
, 0, KEY_READ
,
928 &hkServiceProvider
) != ERROR_SUCCESS
)
930 ERR(": what the heck is going on?\n" );
934 if( RegQueryValueExA( hkServiceProvider
, guidDataSubKey
,
935 NULL
, &returnTypeGUID
, returnBuffer
,
936 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
938 ERR(": missing GUID registry data members\n" );
942 /* FIXME: Check return types to ensure we're interpreting data right */
943 MultiByteToWideChar( CP_ACP
, 0, returnBuffer
, -1, buff
, sizeof(buff
)/sizeof(WCHAR
) );
944 CLSIDFromString( (LPCOLESTR
)buff
, &serviceProviderGUID
);
945 /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
947 dplAppInfo
.dwSize
= sizeof( dplAppInfo
);
948 dplAppInfo
.guidApplication
= serviceProviderGUID
;
949 dplAppInfo
.u
.lpszAppNameA
= subKeyName
;
951 EnterCriticalSection( &This
->unk
->DPL_lock
);
953 memcpy( &This
->dpl
->hkCallbackKeyHack
, &hkServiceProvider
, sizeof( hkServiceProvider
) );
955 if( !lpEnumLocalAppCallback( &dplAppInfo
, lpContext
, dwFlags
) )
957 LeaveCriticalSection( &This
->unk
->DPL_lock
);
961 LeaveCriticalSection( &This
->unk
->DPL_lock
);
967 /********************************************************************
969 * Retrieves the DPLCONNECTION structure that contains all the information
970 * needed to start and connect an application. This was generated using
971 * either the RunApplication or SetConnectionSettings methods.
973 * NOTES: If lpData is NULL then just return lpdwDataSize. This allows
974 * the data structure to be allocated by our caller which can then
975 * call this procedure/method again with a valid data pointer.
977 static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings
978 ( LPDIRECTPLAYLOBBYA iface
,
981 LPDWORD lpdwDataSize
)
983 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
986 TRACE("(%p)->(0x%08lx,%p,%p)\n", This
, dwAppID
, lpData
, lpdwDataSize
);
988 EnterCriticalSection( &This
->unk
->DPL_lock
);
990 hr
= DPLAYX_GetConnectionSettingsA( dwAppID
,
995 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1000 static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings
1001 ( LPDIRECTPLAYLOBBY iface
,
1004 LPDWORD lpdwDataSize
)
1006 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1009 TRACE("(%p)->(0x%08lx,%p,%p)\n", This
, dwAppID
, lpData
, lpdwDataSize
);
1011 EnterCriticalSection( &This
->unk
->DPL_lock
);
1013 hr
= DPLAYX_GetConnectionSettingsW( dwAppID
,
1018 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1023 /********************************************************************
1025 * Retrieves the message sent between a lobby client and a DirectPlay
1026 * application. All messages are queued until received.
1029 static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage
1030 ( LPDIRECTPLAYLOBBYA iface
,
1033 LPDWORD lpdwMessageFlags
,
1035 LPDWORD lpdwDataSize
)
1037 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
1038 FIXME(":stub %p %08lx %08lx %p %p %p\n", This
, dwFlags
, dwAppID
, lpdwMessageFlags
, lpData
,
1040 return DPERR_OUTOFMEMORY
;
1043 static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage
1044 ( LPDIRECTPLAYLOBBY iface
,
1047 LPDWORD lpdwMessageFlags
,
1049 LPDWORD lpdwDataSize
)
1051 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1052 FIXME(":stub %p %08lx %08lx %p %p %p\n", This
, dwFlags
, dwAppID
, lpdwMessageFlags
, lpData
,
1054 return DPERR_OUTOFMEMORY
;
1057 typedef struct tagRunApplicationEnumStruct
1059 IDirectPlayLobbyAImpl
* This
;
1064 LPSTR lpszCommandLine
;
1065 LPSTR lpszCurrentDirectory
;
1066 } RunApplicationEnumStruct
, *lpRunApplicationEnumStruct
;
1068 /* To be called by RunApplication to find how to invoke the function */
1069 static BOOL CALLBACK RunApplicationA_EnumLocalApplications
1070 ( LPCDPLAPPINFO lpAppInfo
,
1074 lpRunApplicationEnumStruct lpData
= (lpRunApplicationEnumStruct
)lpContext
;
1076 if( IsEqualGUID( &lpAppInfo
->guidApplication
, &lpData
->appGUID
) )
1078 char returnBuffer
[200];
1079 DWORD returnType
, sizeOfReturnBuffer
;
1080 LPSTR clSubKey
= "CommandLine";
1081 LPSTR cdSubKey
= "CurrentDirectory";
1082 LPSTR fileSubKey
= "File";
1083 LPSTR pathSubKey
= "Path";
1085 /* FIXME: Lazy man hack - dplay struct has the present reg key saved */
1087 sizeOfReturnBuffer
= 200;
1089 /* Get all the appropriate data from the registry */
1090 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, clSubKey
,
1091 NULL
, &returnType
, returnBuffer
,
1092 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1094 ERR( ": missing CommandLine registry data member\n" );
1098 if ((lpData
->lpszCommandLine
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1099 strcpy( lpData
->lpszCommandLine
, returnBuffer
);
1102 sizeOfReturnBuffer
= 200;
1104 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, cdSubKey
,
1105 NULL
, &returnType
, returnBuffer
,
1106 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1108 ERR( ": missing CurrentDirectory registry data member\n" );
1112 if ((lpData
->lpszCurrentDirectory
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1113 strcpy( lpData
->lpszCurrentDirectory
, returnBuffer
);
1116 sizeOfReturnBuffer
= 200;
1118 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, fileSubKey
,
1119 NULL
, &returnType
, returnBuffer
,
1120 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1122 ERR( ": missing File registry data member\n" );
1126 if ((lpData
->lpszFileName
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1127 strcpy( lpData
->lpszFileName
, returnBuffer
);
1130 sizeOfReturnBuffer
= 200;
1132 if( RegQueryValueExA( lpData
->This
->dpl
->hkCallbackKeyHack
, pathSubKey
,
1133 NULL
, &returnType
, returnBuffer
,
1134 &sizeOfReturnBuffer
) != ERROR_SUCCESS
)
1136 ERR( ": missing Path registry data member\n" );
1140 if ((lpData
->lpszPath
= HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer
)+1 )))
1141 strcpy( lpData
->lpszPath
, returnBuffer
);
1144 return FALSE
; /* No need to keep going as we found what we wanted */
1147 return TRUE
; /* Keep enumerating, haven't found the application yet */
1150 BOOL
DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId
, HANDLE hDestProcess
,
1151 LPHANDLE lphStart
, LPHANDLE lphDeath
,
1154 /* These are the handles for the created process */
1155 HANDLE hAppStart
, hAppDeath
, hAppRead
, hTemp
;
1156 SECURITY_ATTRIBUTES s_attrib
;
1158 s_attrib
.nLength
= sizeof( s_attrib
);
1159 s_attrib
.lpSecurityDescriptor
= NULL
;
1160 s_attrib
.bInheritHandle
= TRUE
;
1162 /* FIXME: Is there a handle leak here? */
1163 hTemp
= CreateEventA( &s_attrib
, TRUE
, FALSE
, NULL
);
1164 *lphStart
= ConvertToGlobalHandle( hTemp
);
1166 hTemp
= CreateEventA( &s_attrib
, TRUE
, FALSE
, NULL
);
1167 *lphDeath
= ConvertToGlobalHandle( hTemp
);
1169 hTemp
= CreateEventA( &s_attrib
, TRUE
, FALSE
, NULL
);
1170 *lphRead
= ConvertToGlobalHandle( hTemp
);
1172 if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart
,
1173 hDestProcess
, &hAppStart
,
1174 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) ||
1175 ( !DuplicateHandle( GetCurrentProcess(), *lphDeath
,
1176 hDestProcess
, &hAppDeath
,
1177 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) ||
1178 ( !DuplicateHandle( GetCurrentProcess(), *lphRead
,
1179 hDestProcess
, &hAppRead
,
1180 0, FALSE
, DUPLICATE_SAME_ACCESS
) )
1183 /* FIXME: Handle leak... */
1184 ERR( "Unable to dup handles\n" );
1188 if( !DPLAYX_SetLobbyHandles( dwDestProcessId
,
1189 hAppStart
, hAppDeath
, hAppRead
) )
1198 /********************************************************************
1200 * Starts an application and passes to it all the information to
1201 * connect to a session.
1204 static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
1205 ( LPDIRECTPLAYLOBBYA iface
,
1208 LPDPLCONNECTION lpConn
,
1209 HANDLE hReceiveEvent
)
1211 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
1213 RunApplicationEnumStruct enumData
;
1215 STARTUPINFOA startupInfo
;
1216 PROCESS_INFORMATION newProcessInfo
;
1218 DWORD dwSuspendCount
;
1219 HANDLE hStart
, hDeath
, hSettingRead
;
1221 TRACE( "(%p)->(0x%08lx,%p,%p,%x)\n",
1222 This
, dwFlags
, lpdwAppID
, lpConn
, hReceiveEvent
);
1226 return DPERR_INVALIDPARAMS
;
1229 if( DPLAYX_AnyLobbiesWaitingForConnSettings() )
1231 FIXME( "Waiting lobby not being handled correctly\n" );
1234 EnterCriticalSection( &This
->unk
->DPL_lock
);
1236 ZeroMemory( &enumData
, sizeof( enumData
) );
1237 enumData
.This
= This
;
1238 enumData
.appGUID
= lpConn
->lpSessionDesc
->guidApplication
;
1240 /* Our callback function will fill up the enumData structure with all the information
1241 required to start a new process */
1242 IDirectPlayLobby_EnumLocalApplications( iface
, RunApplicationA_EnumLocalApplications
,
1243 (LPVOID
)(&enumData
), 0 );
1245 /* First the application name */
1246 strcpy( temp
, enumData
.lpszPath
);
1247 strcat( temp
, "\\" );
1248 strcat( temp
, enumData
.lpszFileName
);
1249 HeapFree( GetProcessHeap(), 0, enumData
.lpszPath
);
1250 HeapFree( GetProcessHeap(), 0, enumData
.lpszFileName
);
1251 if ((appName
= HeapAlloc( GetProcessHeap(), 0, strlen(temp
)+1 ))) strcpy( appName
, temp
);
1253 /* Now the command line */
1254 strcat( temp
, " " );
1255 strcat( temp
, enumData
.lpszCommandLine
);
1256 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1257 if ((enumData
.lpszCommandLine
= HeapAlloc( GetProcessHeap(), 0, strlen(temp
)+1 )))
1258 strcpy( enumData
.lpszCommandLine
, temp
);
1260 ZeroMemory( &startupInfo
, sizeof( startupInfo
) );
1261 startupInfo
.cb
= sizeof( startupInfo
);
1262 /* FIXME: Should any fields be filled in? */
1264 ZeroMemory( &newProcessInfo
, sizeof( newProcessInfo
) );
1266 if( !CreateProcessA( appName
,
1267 enumData
.lpszCommandLine
,
1271 CREATE_DEFAULT_ERROR_MODE
| CREATE_NEW_CONSOLE
| CREATE_SUSPENDED
, /* Creation Flags */
1273 enumData
.lpszCurrentDirectory
,
1279 ERR( "Failed to create process for app %s\n", appName
);
1281 HeapFree( GetProcessHeap(), 0, appName
);
1282 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1283 HeapFree( GetProcessHeap(), 0, enumData
.lpszCurrentDirectory
);
1285 return DPERR_CANTCREATEPROCESS
;
1288 HeapFree( GetProcessHeap(), 0, appName
);
1289 HeapFree( GetProcessHeap(), 0, enumData
.lpszCommandLine
);
1290 HeapFree( GetProcessHeap(), 0, enumData
.lpszCurrentDirectory
);
1292 /* Reserve this global application id! */
1293 if( !DPLAYX_CreateLobbyApplication( newProcessInfo
.dwProcessId
) )
1295 ERR( "Unable to create global application data for 0x%08lx\n",
1296 newProcessInfo
.dwProcessId
);
1299 hr
= IDirectPlayLobby_SetConnectionSettings( iface
, 0, newProcessInfo
.dwProcessId
, lpConn
);
1303 ERR( "SetConnectionSettings failure %s\n", DPLAYX_HresultToString( hr
) );
1307 /* Setup the handles for application notification */
1308 DPL_CreateAndSetLobbyHandles( newProcessInfo
.dwProcessId
,
1309 newProcessInfo
.hProcess
,
1310 &hStart
, &hDeath
, &hSettingRead
);
1312 /* Setup the message thread ID */
1313 This
->dpl
->dwMsgThread
=
1314 CreateLobbyMessageReceptionThread( hReceiveEvent
, hStart
, hDeath
, hSettingRead
);
1316 DPLAYX_SetLobbyMsgThreadId( newProcessInfo
.dwProcessId
, This
->dpl
->dwMsgThread
);
1318 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1320 /* Everything seems to have been set correctly, update the dwAppID */
1321 *lpdwAppID
= newProcessInfo
.dwProcessId
;
1323 /* Unsuspend the process - should return the prev suspension count */
1324 if( ( dwSuspendCount
= ResumeThread( newProcessInfo
.hThread
) ) != 1 )
1326 ERR( "ResumeThread failed with 0x%08lx\n", dwSuspendCount
);
1332 static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication
1333 ( LPDIRECTPLAYLOBBY iface
,
1336 LPDPLCONNECTION lpConn
,
1337 HANDLE hReceiveEvent
)
1339 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1340 FIXME( "(%p)->(0x%08lx,%p,%p,%p):stub\n", This
, dwFlags
, lpdwAppID
, lpConn
, (void *)hReceiveEvent
);
1341 return DPERR_OUTOFMEMORY
;
1344 /********************************************************************
1346 * Sends a message between the application and the lobby client.
1347 * All messages are queued until received.
1350 static HRESULT WINAPI IDirectPlayLobbyAImpl_SendLobbyMessage
1351 ( LPDIRECTPLAYLOBBYA iface
,
1358 return DPERR_OUTOFMEMORY
;
1361 static HRESULT WINAPI IDirectPlayLobbyWImpl_SendLobbyMessage
1362 ( LPDIRECTPLAYLOBBY iface
,
1369 return DPERR_OUTOFMEMORY
;
1372 /********************************************************************
1374 * Modifies the DPLCONNECTION structure to contain all information
1375 * needed to start and connect an application.
1378 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings
1379 ( LPDIRECTPLAYLOBBY iface
,
1382 LPDPLCONNECTION lpConn
)
1384 ICOM_THIS(IDirectPlayLobbyWImpl
,iface
);
1387 TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This
, dwFlags
, dwAppID
, lpConn
);
1389 EnterCriticalSection( &This
->unk
->DPL_lock
);
1391 hr
= DPLAYX_SetConnectionSettingsW( dwFlags
, dwAppID
, lpConn
);
1393 /* FIXME: Don't think that this is supposed to fail, but the docuementation
1394 is somewhat sketchy. I'll try creating a lobby application
1396 if( hr
== DPERR_NOTLOBBIED
)
1398 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1401 dwAppID
= GetCurrentProcessId();
1403 DPLAYX_CreateLobbyApplication( dwAppID
);
1404 hr
= DPLAYX_SetConnectionSettingsW( dwFlags
, dwAppID
, lpConn
);
1407 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1412 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings
1413 ( LPDIRECTPLAYLOBBYA iface
,
1416 LPDPLCONNECTION lpConn
)
1418 ICOM_THIS(IDirectPlayLobbyAImpl
,iface
);
1421 TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This
, dwFlags
, dwAppID
, lpConn
);
1423 EnterCriticalSection( &This
->unk
->DPL_lock
);
1425 hr
= DPLAYX_SetConnectionSettingsA( dwFlags
, dwAppID
, lpConn
);
1427 /* FIXME: Don't think that this is supposed to fail, but the docuementation
1428 is somewhat sketchy. I'll try creating a lobby application
1430 if( hr
== DPERR_NOTLOBBIED
)
1432 FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
1433 dwAppID
= GetCurrentProcessId();
1434 DPLAYX_CreateLobbyApplication( dwAppID
);
1435 hr
= DPLAYX_SetConnectionSettingsA( dwFlags
, dwAppID
, lpConn
);
1438 LeaveCriticalSection( &This
->unk
->DPL_lock
);
1443 /********************************************************************
1445 * Registers an event that will be set when a lobby message is received.
1448 static HRESULT WINAPI IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1449 ( LPDIRECTPLAYLOBBYA iface
,
1452 HANDLE hReceiveEvent
)
1455 return DPERR_OUTOFMEMORY
;
1458 static HRESULT WINAPI IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1459 ( LPDIRECTPLAYLOBBY iface
,
1462 HANDLE hReceiveEvent
)
1465 return DPERR_OUTOFMEMORY
;
1470 static HRESULT WINAPI IDirectPlayLobby2WImpl_CreateCompoundAddress
1471 ( LPDIRECTPLAYLOBBY2 iface
,
1472 LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1473 DWORD dwElementCount
,
1475 LPDWORD lpdwAddressSize
)
1477 return DPL_CreateCompoundAddress( lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
, FALSE
);
1480 static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress
1481 ( LPDIRECTPLAYLOBBY2A iface
,
1482 LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1483 DWORD dwElementCount
,
1485 LPDWORD lpdwAddressSize
)
1487 return DPL_CreateCompoundAddress( lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
, TRUE
);
1490 HRESULT DPL_CreateCompoundAddress
1491 ( LPCDPCOMPOUNDADDRESSELEMENT lpElements
,
1492 DWORD dwElementCount
,
1494 LPDWORD lpdwAddressSize
,
1495 BOOL bAnsiInterface
)
1497 DWORD dwSizeRequired
= 0;
1499 LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements
= lpElements
;
1501 TRACE("(%p,0x%08lx,%p,%p)\n", lpElements
, dwElementCount
, lpAddress
, lpdwAddressSize
);
1503 /* Parameter check */
1504 if( ( lpElements
== NULL
) ||
1505 ( dwElementCount
== 0 ) /* FIXME: Not sure if this is a failure case */
1508 return DPERR_INVALIDPARAMS
;
1511 /* Add the total size chunk */
1512 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( DWORD
);
1514 /* Calculate the size of the buffer required */
1515 for ( dwElements
= dwElementCount
; dwElements
> 0; --dwElements
, ++lpElements
)
1517 if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ServiceProvider
) ) ||
1518 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_LobbyProvider
) )
1521 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( GUID
);
1523 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Phone
) ) ||
1524 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Modem
) ) ||
1525 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INet
) )
1528 if( !bAnsiInterface
)
1530 ERR( "Ansi GUIDs used for unicode interface\n" );
1531 return DPERR_INVALIDFLAGS
;
1534 dwSizeRequired
+= sizeof( DPADDRESS
) + lpElements
->dwDataSize
;
1536 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1537 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1538 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1541 if( bAnsiInterface
)
1543 ERR( "Unicode GUIDs used for ansi interface\n" );
1544 return DPERR_INVALIDFLAGS
;
1547 FIXME( "Right size for unicode interface?\n" );
1548 dwSizeRequired
+= sizeof( DPADDRESS
) + lpElements
->dwDataSize
* sizeof( WCHAR
);
1550 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1552 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( WORD
);
1554 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1556 FIXME( "Right size for unicode interface?\n" );
1557 dwSizeRequired
+= sizeof( DPADDRESS
) + sizeof( DPCOMPORTADDRESS
); /* FIXME: Right size? */
1561 ERR( "Unknown GUID %s\n", debugstr_guid(&lpElements
->guidDataType
) );
1562 return DPERR_INVALIDFLAGS
;
1566 /* The user wants to know how big a buffer to allocate for us */
1567 if( ( lpAddress
== NULL
) ||
1568 ( *lpdwAddressSize
< dwSizeRequired
)
1571 *lpdwAddressSize
= dwSizeRequired
;
1572 return DPERR_BUFFERTOOSMALL
;
1575 /* Add the total size chunk */
1577 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1579 CopyMemory( &lpdpAddress
->guidDataType
, &DPAID_TotalSize
, sizeof( GUID
) );
1580 lpdpAddress
->dwDataSize
= sizeof( DWORD
);
1581 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1583 *(LPDWORD
)lpAddress
= dwSizeRequired
;
1584 lpAddress
= (char *) lpAddress
+ sizeof( DWORD
);
1587 /* Calculate the size of the buffer required */
1588 for( dwElements
= dwElementCount
, lpElements
= lpOrigElements
;
1590 --dwElements
, ++lpElements
)
1592 if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ServiceProvider
) ) ||
1593 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_LobbyProvider
) )
1596 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1598 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1600 lpdpAddress
->dwDataSize
= sizeof( GUID
);
1601 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1603 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( GUID
) );
1604 lpAddress
= (char *) lpAddress
+ sizeof( GUID
);
1606 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Phone
) ) ||
1607 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_Modem
) ) ||
1608 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INet
) )
1611 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1613 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1615 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1616 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1618 lstrcpynA( (LPSTR
)lpAddress
,
1619 (LPCSTR
)lpElements
->lpData
,
1620 lpElements
->dwDataSize
);
1621 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
;
1623 else if ( ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_PhoneW
) ) ||
1624 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ModemW
) ) ||
1625 ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetW
) )
1628 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1630 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1632 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1633 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1635 lstrcpynW( (LPWSTR
)lpAddress
,
1636 (LPCWSTR
)lpElements
->lpData
,
1637 lpElements
->dwDataSize
);
1638 lpAddress
= (char *) lpAddress
+ lpElements
->dwDataSize
* sizeof( WCHAR
);
1640 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_INetPort
) )
1642 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1644 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1646 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1647 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1649 *((LPWORD
)lpAddress
) = *((LPWORD
)lpElements
->lpData
);
1650 lpAddress
= (char *) lpAddress
+ sizeof( WORD
);
1652 else if ( IsEqualGUID( &lpElements
->guidDataType
, &DPAID_ComPort
) )
1654 LPDPADDRESS lpdpAddress
= (LPDPADDRESS
)lpAddress
;
1656 CopyMemory( &lpdpAddress
->guidDataType
, &lpElements
->guidDataType
,
1658 lpdpAddress
->dwDataSize
= lpElements
->dwDataSize
;
1659 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1661 CopyMemory( lpAddress
, lpElements
->lpData
, sizeof( DPADDRESS
) );
1662 lpAddress
= (char *) lpAddress
+ sizeof( DPADDRESS
);
1671 static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
1672 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFIID riid
,
1673 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1675 ICOM_THIS( IDirectPlayLobbyAImpl
, iface
);
1676 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1679 static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
1680 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFIID riid
,
1681 LPVOID
* lplpDP
, IUnknown
* pUnk
)
1683 ICOM_THIS( IDirectPlayLobbyAImpl
, iface
);
1684 return DPL_ConnectEx( This
, dwFlags
, riid
, lplpDP
, pUnk
);
1687 static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
1688 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1694 static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
1695 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, LPDPAPPLICATIONDESC lpAppDesc
)
1701 static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
1702 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1708 static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
1709 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
, REFGUID lpAppDesc
)
1715 static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
1716 ( LPDIRECTPLAYLOBBY3 iface
, DWORD dwFlags
)
1719 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1721 TRACE( "(%p)->(0x%08lx)\n", iface
, dwFlags
);
1723 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1725 /* FIXME: What is the correct error return code? */
1726 hr
= DPERR_NOTLOBBIED
;
1732 static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
1733 ( LPDIRECTPLAYLOBBY3A iface
, DWORD dwFlags
)
1736 BOOL bStartWait
= (dwFlags
& DPLWAIT_CANCEL
) ? FALSE
: TRUE
;
1738 TRACE( "(%p)->(0x%08lx)\n", iface
, dwFlags
);
1740 if( DPLAYX_WaitForConnectionSettings( bStartWait
) )
1742 /* FIXME: What is the correct error return code? */
1743 hr
= DPERR_NOTLOBBIED
;
1750 /* Virtual Table definitions for DPL{1,2,3}{A,W} */
1752 /* Note: Hack so we can reuse the old functions without compiler warnings */
1753 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1754 # define XCAST(fun) (typeof(directPlayLobbyAVT.fun))
1756 # define XCAST(fun) (void*)
1759 /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
1760 /* All lobby 1 methods are exactly the same except QueryInterface */
1761 static struct ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyAVT
=
1763 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1765 XCAST(QueryInterface
)DPL_QueryInterface
,
1766 XCAST(AddRef
)DPL_AddRef
,
1767 XCAST(Release
)DPL_Release
,
1769 IDirectPlayLobbyAImpl_Connect
,
1770 IDirectPlayLobbyAImpl_CreateAddress
,
1771 IDirectPlayLobbyAImpl_EnumAddress
,
1772 IDirectPlayLobbyAImpl_EnumAddressTypes
,
1773 IDirectPlayLobbyAImpl_EnumLocalApplications
,
1774 IDirectPlayLobbyAImpl_GetConnectionSettings
,
1775 IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1776 IDirectPlayLobbyAImpl_RunApplication
,
1777 IDirectPlayLobbyAImpl_SendLobbyMessage
,
1778 IDirectPlayLobbyAImpl_SetConnectionSettings
,
1779 IDirectPlayLobbyAImpl_SetLobbyMessageEvent
1784 /* Note: Hack so we can reuse the old functions without compiler warnings */
1785 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1786 # define XCAST(fun) (typeof(directPlayLobbyWVT.fun))
1788 # define XCAST(fun) (void*)
1791 /* Direct Play Lobby 1 (unicode) Virtual Table for methods */
1792 static ICOM_VTABLE(IDirectPlayLobby
) directPlayLobbyWVT
=
1794 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1796 XCAST(QueryInterface
)DPL_QueryInterface
,
1797 XCAST(AddRef
)DPL_AddRef
,
1798 XCAST(Release
)DPL_Release
,
1800 IDirectPlayLobbyWImpl_Connect
,
1801 IDirectPlayLobbyWImpl_CreateAddress
,
1802 IDirectPlayLobbyWImpl_EnumAddress
,
1803 IDirectPlayLobbyWImpl_EnumAddressTypes
,
1804 IDirectPlayLobbyWImpl_EnumLocalApplications
,
1805 IDirectPlayLobbyWImpl_GetConnectionSettings
,
1806 IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1807 IDirectPlayLobbyWImpl_RunApplication
,
1808 IDirectPlayLobbyWImpl_SendLobbyMessage
,
1809 IDirectPlayLobbyWImpl_SetConnectionSettings
,
1810 IDirectPlayLobbyWImpl_SetLobbyMessageEvent
1814 /* Note: Hack so we can reuse the old functions without compiler warnings */
1815 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1816 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1818 # define XCAST(fun) (void*)
1821 /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
1822 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2AVT
=
1824 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1826 XCAST(QueryInterface
)DPL_QueryInterface
,
1827 XCAST(AddRef
)DPL_AddRef
,
1828 XCAST(Release
)DPL_Release
,
1830 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1831 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1832 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1833 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1834 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1835 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1836 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1837 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1838 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1839 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1840 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1842 IDirectPlayLobby2AImpl_CreateCompoundAddress
1846 /* Note: Hack so we can reuse the old functions without compiler warnings */
1847 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1848 # define XCAST(fun) (typeof(directPlayLobby2AVT.fun))
1850 # define XCAST(fun) (void*)
1853 /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
1854 static ICOM_VTABLE(IDirectPlayLobby2
) directPlayLobby2WVT
=
1856 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1858 XCAST(QueryInterface
)DPL_QueryInterface
,
1859 XCAST(AddRef
)DPL_AddRef
,
1860 XCAST(Release
)DPL_Release
,
1862 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1863 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1864 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1865 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1866 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1867 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1868 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1869 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1870 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1871 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1872 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1874 IDirectPlayLobby2WImpl_CreateCompoundAddress
1878 /* Direct Play Lobby 3 (ascii) Virtual Table for methods */
1880 /* Note: Hack so we can reuse the old functions without compiler warnings */
1881 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1882 # define XCAST(fun) (typeof(directPlayLobby3AVT.fun))
1884 # define XCAST(fun) (void*)
1887 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3AVT
=
1889 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1890 XCAST(QueryInterface
)DPL_QueryInterface
,
1891 XCAST(AddRef
)DPL_AddRef
,
1892 XCAST(Release
)DPL_Release
,
1894 XCAST(Connect
)IDirectPlayLobbyAImpl_Connect
,
1895 XCAST(CreateAddress
)IDirectPlayLobbyAImpl_CreateAddress
,
1896 XCAST(EnumAddress
)IDirectPlayLobbyAImpl_EnumAddress
,
1897 XCAST(EnumAddressTypes
)IDirectPlayLobbyAImpl_EnumAddressTypes
,
1898 XCAST(EnumLocalApplications
)IDirectPlayLobbyAImpl_EnumLocalApplications
,
1899 XCAST(GetConnectionSettings
)IDirectPlayLobbyAImpl_GetConnectionSettings
,
1900 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyAImpl_ReceiveLobbyMessage
,
1901 XCAST(RunApplication
)IDirectPlayLobbyAImpl_RunApplication
,
1902 XCAST(SendLobbyMessage
)IDirectPlayLobbyAImpl_SendLobbyMessage
,
1903 XCAST(SetConnectionSettings
)IDirectPlayLobbyAImpl_SetConnectionSettings
,
1904 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyAImpl_SetLobbyMessageEvent
,
1906 XCAST(CreateCompoundAddress
)IDirectPlayLobby2AImpl_CreateCompoundAddress
,
1908 IDirectPlayLobby3AImpl_ConnectEx
,
1909 IDirectPlayLobby3AImpl_RegisterApplication
,
1910 IDirectPlayLobby3AImpl_UnregisterApplication
,
1911 IDirectPlayLobby3AImpl_WaitForConnectionSettings
1915 /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
1917 /* Note: Hack so we can reuse the old functions without compiler warnings */
1918 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1919 # define XCAST(fun) (typeof(directPlayLobby3WVT.fun))
1921 # define XCAST(fun) (void*)
1924 static ICOM_VTABLE(IDirectPlayLobby3
) directPlayLobby3WVT
=
1926 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1927 XCAST(QueryInterface
)DPL_QueryInterface
,
1928 XCAST(AddRef
)DPL_AddRef
,
1929 XCAST(Release
)DPL_Release
,
1931 XCAST(Connect
)IDirectPlayLobbyWImpl_Connect
,
1932 XCAST(CreateAddress
)IDirectPlayLobbyWImpl_CreateAddress
,
1933 XCAST(EnumAddress
)IDirectPlayLobbyWImpl_EnumAddress
,
1934 XCAST(EnumAddressTypes
)IDirectPlayLobbyWImpl_EnumAddressTypes
,
1935 XCAST(EnumLocalApplications
)IDirectPlayLobbyWImpl_EnumLocalApplications
,
1936 XCAST(GetConnectionSettings
)IDirectPlayLobbyWImpl_GetConnectionSettings
,
1937 XCAST(ReceiveLobbyMessage
)IDirectPlayLobbyWImpl_ReceiveLobbyMessage
,
1938 XCAST(RunApplication
)IDirectPlayLobbyWImpl_RunApplication
,
1939 XCAST(SendLobbyMessage
)IDirectPlayLobbyWImpl_SendLobbyMessage
,
1940 XCAST(SetConnectionSettings
)IDirectPlayLobbyWImpl_SetConnectionSettings
,
1941 XCAST(SetLobbyMessageEvent
)IDirectPlayLobbyWImpl_SetLobbyMessageEvent
,
1943 XCAST(CreateCompoundAddress
)IDirectPlayLobby2WImpl_CreateCompoundAddress
,
1945 IDirectPlayLobby3WImpl_ConnectEx
,
1946 IDirectPlayLobby3WImpl_RegisterApplication
,
1947 IDirectPlayLobby3WImpl_UnregisterApplication
,
1948 IDirectPlayLobby3WImpl_WaitForConnectionSettings
1953 /*********************************************************
1955 * Direct Play Lobby Interface Implementation
1957 *********************************************************/
1959 /***************************************************************************
1960 * DirectPlayLobbyCreateA (DPLAYX.4)
1963 HRESULT WINAPI
DirectPlayLobbyCreateA( LPGUID lpGUIDDSP
,
1964 LPDIRECTPLAYLOBBYA
*lplpDPL
,
1969 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\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
)
1978 return DPERR_INVALIDPARAMS
;
1984 ERR("Bad parameters!\n" );
1985 return CLASS_E_NOAGGREGATION
;
1988 return DPL_CreateInterface( &IID_IDirectPlayLobbyA
, (void**)lplpDPL
);
1991 /***************************************************************************
1992 * DirectPlayLobbyCreateW (DPLAYX.5)
1995 HRESULT WINAPI
DirectPlayLobbyCreateW( LPGUID lpGUIDDSP
,
1996 LPDIRECTPLAYLOBBY
*lplpDPL
,
2001 TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
2002 lpGUIDDSP
,lplpDPL
,lpUnk
,lpData
,dwDataSize
);
2004 /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
2005 * equal 0. These fields are mostly for future expansion.
2007 if ( lpGUIDDSP
|| lpData
|| dwDataSize
)
2010 ERR("Bad parameters!\n" );
2011 return DPERR_INVALIDPARAMS
;
2017 ERR("Bad parameters!\n" );
2018 return CLASS_E_NOAGGREGATION
;
2021 return DPL_CreateInterface( &IID_IDirectPlayLobby
, (void**)lplpDPL
);