1 | // $Id: dplobby.cpp,v 1.5 2001-04-16 17:25:23 sandervl Exp $
|
---|
2 | /* Direct Play Lobby 2 & 3 Implementation
|
---|
3 | *
|
---|
4 | * Copyright 1998,1999,2000 - Peter Hunnisett
|
---|
5 | *
|
---|
6 | * <presently under construction - contact hunnise@nortelnetworks.com>
|
---|
7 | *
|
---|
8 | */
|
---|
9 | #include <string.h>
|
---|
10 |
|
---|
11 | #include <odin.h>
|
---|
12 | #define ICOM_CINTERFACE 1
|
---|
13 | #define CINTERFACE
|
---|
14 |
|
---|
15 | #include "winerror.h"
|
---|
16 | #include "winnt.h"
|
---|
17 | #include "winreg.h"
|
---|
18 | #include "winnls.h"
|
---|
19 | #include "heap.h"
|
---|
20 | #include "heapstring.h"
|
---|
21 | #include "debugtools.h"
|
---|
22 |
|
---|
23 | #include "dplobby.h"
|
---|
24 | #include "dpinit.h"
|
---|
25 | #include "dplayx_global.h"
|
---|
26 | #include "dplayx_messages.h"
|
---|
27 | #include "dplayx_queue.h"
|
---|
28 |
|
---|
29 | DEFAULT_DEBUG_CHANNEL(dplay);
|
---|
30 |
|
---|
31 | #undef debugstr_guid
|
---|
32 | #define debugstr_guid(a) a
|
---|
33 |
|
---|
34 | /*****************************************************************************
|
---|
35 | * Predeclare the interface implementation structures
|
---|
36 | */
|
---|
37 | typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyAImpl;
|
---|
38 | typedef struct IDirectPlayLobbyImpl IDirectPlayLobbyWImpl;
|
---|
39 | typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2AImpl;
|
---|
40 | typedef struct IDirectPlayLobby2Impl IDirectPlayLobby2WImpl;
|
---|
41 | typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3AImpl;
|
---|
42 | typedef struct IDirectPlayLobby3Impl IDirectPlayLobby3WImpl;
|
---|
43 |
|
---|
44 | /* Forward declarations for this module helper methods */
|
---|
45 | HRESULT DPL_CreateCompoundAddress ( LPCDPCOMPOUNDADDRESSELEMENT lpElements, DWORD dwElementCount,
|
---|
46 | LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface );
|
---|
47 |
|
---|
48 | HRESULT DPL_CreateAddress( REFGUID guidSP, REFGUID guidDataType, LPCVOID lpData, DWORD dwDataSize,
|
---|
49 | LPVOID lpAddress, LPDWORD lpdwAddressSize, BOOL bAnsiInterface );
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
|
---|
54 | DWORD dwAddressSize, LPVOID lpContext );
|
---|
55 |
|
---|
56 | static HRESULT WINAPI DPL_ConnectEx( IDirectPlayLobbyAImpl* This,
|
---|
57 | DWORD dwFlags, REFIID riid,
|
---|
58 | LPVOID* lplpDP, IUnknown* pUnk );
|
---|
59 |
|
---|
60 | BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
|
---|
61 | LPHANDLE lphStart, LPHANDLE lphDeath,
|
---|
62 | LPHANDLE lphRead );
|
---|
63 |
|
---|
64 |
|
---|
65 | /*****************************************************************************
|
---|
66 | * IDirectPlayLobby {1,2,3} implementation structure
|
---|
67 | *
|
---|
68 | * The philosophy behind this extra pointer derefernce is that I wanted to
|
---|
69 | * have the same structure for all types of objects without having to do
|
---|
70 | * alot of casting. I also only wanted to implement an interface in the
|
---|
71 | * object it was "released" with IUnknown interface being implemented in the 1 version.
|
---|
72 | * Of course, with these new interfaces comes the data required to keep the state required
|
---|
73 | * by these interfaces. So, basically, the pointers contain the data associated with
|
---|
74 | * a release. If you use the data associated with release 3 in a release 2 object, you'll
|
---|
75 | * get a run time trap, as that won't have any data.
|
---|
76 | *
|
---|
77 | */
|
---|
78 | struct DPLMSG
|
---|
79 | {
|
---|
80 | DPQ_ENTRY( DPLMSG ) msgs; /* Link to next queued message */
|
---|
81 | };
|
---|
82 | typedef struct DPLMSG* LPDPLMSG;
|
---|
83 |
|
---|
84 | typedef struct tagDirectPlayLobbyIUnknownData
|
---|
85 | {
|
---|
86 | ULONG ulObjRef;
|
---|
87 | CRITICAL_SECTION DPL_lock;
|
---|
88 | } DirectPlayLobbyIUnknownData;
|
---|
89 |
|
---|
90 | typedef struct tagDirectPlayLobbyData
|
---|
91 | {
|
---|
92 | HKEY hkCallbackKeyHack;
|
---|
93 | DWORD dwMsgThread;
|
---|
94 | DPQ_HEAD( DPLMSG ) msgs; /* List of messages received */
|
---|
95 | } DirectPlayLobbyData;
|
---|
96 |
|
---|
97 | typedef struct tagDirectPlayLobby2Data
|
---|
98 | {
|
---|
99 | BOOL dummy;
|
---|
100 | } DirectPlayLobby2Data;
|
---|
101 |
|
---|
102 | typedef struct tagDirectPlayLobby3Data
|
---|
103 | {
|
---|
104 | BOOL dummy;
|
---|
105 | } DirectPlayLobby3Data;
|
---|
106 |
|
---|
107 | #define DPL_IMPL_FIELDS \
|
---|
108 | ULONG ulInterfaceRef; \
|
---|
109 | DirectPlayLobbyIUnknownData* unk; \
|
---|
110 | DirectPlayLobbyData* dpl; \
|
---|
111 | DirectPlayLobby2Data* dpl2; \
|
---|
112 | DirectPlayLobby3Data* dpl3;
|
---|
113 |
|
---|
114 | struct IDirectPlayLobbyImpl
|
---|
115 | {
|
---|
116 | ICOM_VFIELD(IDirectPlayLobby);
|
---|
117 | DPL_IMPL_FIELDS
|
---|
118 | };
|
---|
119 |
|
---|
120 | struct IDirectPlayLobby2Impl
|
---|
121 | {
|
---|
122 | ICOM_VFIELD(IDirectPlayLobby2);
|
---|
123 | DPL_IMPL_FIELDS
|
---|
124 | };
|
---|
125 |
|
---|
126 | struct IDirectPlayLobby3Impl
|
---|
127 | {
|
---|
128 | ICOM_VFIELD(IDirectPlayLobby3);
|
---|
129 | DPL_IMPL_FIELDS
|
---|
130 | };
|
---|
131 |
|
---|
132 |
|
---|
133 | /* Forward declarations of virtual tables */
|
---|
134 | extern ICOM_VTABLE(IDirectPlayLobby) directPlayLobbyWVT;
|
---|
135 | extern ICOM_VTABLE(IDirectPlayLobby2) directPlayLobby2WVT;
|
---|
136 | extern ICOM_VTABLE(IDirectPlayLobby3) directPlayLobby3WVT;
|
---|
137 |
|
---|
138 | extern ICOM_VTABLE(IDirectPlayLobby) directPlayLobbyAVT;
|
---|
139 | extern ICOM_VTABLE(IDirectPlayLobby2) directPlayLobby2AVT;
|
---|
140 | extern ICOM_VTABLE(IDirectPlayLobby3) directPlayLobby3AVT;
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|
145 | static BOOL DPL_CreateIUnknown( LPVOID lpDPL )
|
---|
146 | {
|
---|
147 | ICOM_THIS(IDirectPlayLobbyAImpl,lpDPL);
|
---|
148 |
|
---|
149 | This->unk = (DirectPlayLobbyIUnknownData*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
150 | sizeof( *(This->unk) ) );
|
---|
151 | if ( This->unk == NULL )
|
---|
152 | {
|
---|
153 | return FALSE;
|
---|
154 | }
|
---|
155 |
|
---|
156 | InitializeCriticalSection( &This->unk->DPL_lock );
|
---|
157 |
|
---|
158 | return TRUE;
|
---|
159 | }
|
---|
160 |
|
---|
161 | static BOOL DPL_DestroyIUnknown( LPVOID lpDPL )
|
---|
162 | {
|
---|
163 | ICOM_THIS(IDirectPlayLobbyAImpl,lpDPL);
|
---|
164 |
|
---|
165 | DeleteCriticalSection( &This->unk->DPL_lock );
|
---|
166 | HeapFree( GetProcessHeap(), 0, This->unk );
|
---|
167 |
|
---|
168 | return TRUE;
|
---|
169 | }
|
---|
170 |
|
---|
171 | static BOOL DPL_CreateLobby1( LPVOID lpDPL )
|
---|
172 | {
|
---|
173 | ICOM_THIS(IDirectPlayLobbyAImpl,lpDPL);
|
---|
174 |
|
---|
175 | This->dpl = (DirectPlayLobbyData*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
176 | sizeof( *(This->dpl) ) );
|
---|
177 | if ( This->dpl == NULL )
|
---|
178 | {
|
---|
179 | return FALSE;
|
---|
180 | }
|
---|
181 |
|
---|
182 | DPQ_INIT( This->dpl->msgs );
|
---|
183 |
|
---|
184 | return TRUE;
|
---|
185 | }
|
---|
186 |
|
---|
187 | static BOOL DPL_DestroyLobby1( LPVOID lpDPL )
|
---|
188 | {
|
---|
189 | ICOM_THIS(IDirectPlayLobbyAImpl,lpDPL);
|
---|
190 |
|
---|
191 | if( This->dpl->dwMsgThread )
|
---|
192 | {
|
---|
193 | FIXME( "Should kill the msg thread\n" );
|
---|
194 | }
|
---|
195 |
|
---|
196 | DPQ_DELETEQ( This->dpl->msgs, msgs, LPDPLMSG, cbDeleteElemFromHeap );
|
---|
197 |
|
---|
198 | /* Delete the contents */
|
---|
199 | HeapFree( GetProcessHeap(), 0, This->dpl );
|
---|
200 |
|
---|
201 | return TRUE;
|
---|
202 | }
|
---|
203 |
|
---|
204 | static BOOL DPL_CreateLobby2( LPVOID lpDPL )
|
---|
205 | {
|
---|
206 | ICOM_THIS(IDirectPlayLobby2AImpl,lpDPL);
|
---|
207 |
|
---|
208 | This->dpl2 = (DirectPlayLobby2Data*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
209 | sizeof( *(This->dpl2) ) );
|
---|
210 | if ( This->dpl2 == NULL )
|
---|
211 | {
|
---|
212 | return FALSE;
|
---|
213 | }
|
---|
214 |
|
---|
215 | return TRUE;
|
---|
216 | }
|
---|
217 |
|
---|
218 | static BOOL DPL_DestroyLobby2( LPVOID lpDPL )
|
---|
219 | {
|
---|
220 | ICOM_THIS(IDirectPlayLobby2AImpl,lpDPL);
|
---|
221 |
|
---|
222 | HeapFree( GetProcessHeap(), 0, This->dpl2 );
|
---|
223 |
|
---|
224 | return TRUE;
|
---|
225 | }
|
---|
226 |
|
---|
227 | static BOOL DPL_CreateLobby3( LPVOID lpDPL )
|
---|
228 | {
|
---|
229 | ICOM_THIS(IDirectPlayLobby3AImpl,lpDPL);
|
---|
230 |
|
---|
231 | This->dpl3 = (DirectPlayLobby3Data*)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
232 | sizeof( *(This->dpl3) ) );
|
---|
233 | if ( This->dpl3 == NULL )
|
---|
234 | {
|
---|
235 | return FALSE;
|
---|
236 | }
|
---|
237 |
|
---|
238 | return TRUE;
|
---|
239 | }
|
---|
240 |
|
---|
241 | static BOOL DPL_DestroyLobby3( LPVOID lpDPL )
|
---|
242 | {
|
---|
243 | ICOM_THIS(IDirectPlayLobby3AImpl,lpDPL);
|
---|
244 |
|
---|
245 | HeapFree( GetProcessHeap(), 0, This->dpl3 );
|
---|
246 |
|
---|
247 | return TRUE;
|
---|
248 | }
|
---|
249 |
|
---|
250 |
|
---|
251 | /* The COM interface for upversioning an interface
|
---|
252 | * We've been given a GUID (riid) and we need to replace the present
|
---|
253 | * interface with that of the requested interface.
|
---|
254 | *
|
---|
255 | * Snip from some Microsoft document:
|
---|
256 | * There are four requirements for implementations of QueryInterface (In these
|
---|
257 | * cases, "must succeed" means "must succeed barring catastrophic failure."):
|
---|
258 | *
|
---|
259 | * * The set of interfaces accessible on an object through
|
---|
260 | * IUnknown::QueryInterface must be static, not dynamic. This means that
|
---|
261 | * if a call to QueryInterface for a pointer to a specified interface
|
---|
262 | * succeeds the first time, it must succeed again, and if it fails the
|
---|
263 | * first time, it must fail on all subsequent queries.
|
---|
264 | * * It must be symmetric ~W if a client holds a pointer to an interface on
|
---|
265 | * an object, and queries for that interface, the call must succeed.
|
---|
266 | * * It must be reflexive ~W if a client holding a pointer to one interface
|
---|
267 | * queries successfully for another, a query through the obtained pointer
|
---|
268 | * for the first interface must succeed.
|
---|
269 | * * It must be transitive ~W if a client holding a pointer to one interface
|
---|
270 | * queries successfully for a second, and through that pointer queries
|
---|
271 | * successfully for a third interface, a query for the first interface
|
---|
272 | * through the pointer for the third interface must succeed.
|
---|
273 | */
|
---|
274 | extern
|
---|
275 | HRESULT DPL_CreateInterface
|
---|
276 | ( REFIID riid, LPVOID* ppvObj )
|
---|
277 | {
|
---|
278 | TRACE( " for %s\n", debugstr_guid( riid ) );
|
---|
279 |
|
---|
280 | *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
281 | sizeof( IDirectPlayLobbyWImpl ) );
|
---|
282 |
|
---|
283 | if( *ppvObj == NULL )
|
---|
284 | {
|
---|
285 | return DPERR_OUTOFMEMORY;
|
---|
286 | }
|
---|
287 |
|
---|
288 | if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
|
---|
289 | {
|
---|
290 | ICOM_THIS(IDirectPlayLobbyWImpl,*ppvObj);
|
---|
291 | ICOM_VTBL(This) = &directPlayLobbyWVT;
|
---|
292 | }
|
---|
293 | else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
|
---|
294 | {
|
---|
295 | ICOM_THIS(IDirectPlayLobbyAImpl,*ppvObj);
|
---|
296 | ICOM_VTBL(This) = &directPlayLobbyAVT;
|
---|
297 | }
|
---|
298 | else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
|
---|
299 | {
|
---|
300 | ICOM_THIS(IDirectPlayLobby2WImpl,*ppvObj);
|
---|
301 | ICOM_VTBL(This) = &directPlayLobby2WVT;
|
---|
302 | }
|
---|
303 | else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
|
---|
304 | {
|
---|
305 | ICOM_THIS(IDirectPlayLobby2AImpl,*ppvObj);
|
---|
306 | ICOM_VTBL(This) = &directPlayLobby2AVT;
|
---|
307 | }
|
---|
308 | else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
|
---|
309 | {
|
---|
310 | ICOM_THIS(IDirectPlayLobby3WImpl,*ppvObj);
|
---|
311 | ICOM_VTBL(This) = &directPlayLobby3WVT;
|
---|
312 | }
|
---|
313 | else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
|
---|
314 | {
|
---|
315 | ICOM_THIS(IDirectPlayLobby3AImpl,*ppvObj);
|
---|
316 | ICOM_VTBL(This) = &directPlayLobby3AVT;
|
---|
317 | }
|
---|
318 | else
|
---|
319 | {
|
---|
320 | /* Unsupported interface */
|
---|
321 | HeapFree( GetProcessHeap(), 0, *ppvObj );
|
---|
322 | *ppvObj = NULL;
|
---|
323 |
|
---|
324 | return E_NOINTERFACE;
|
---|
325 | }
|
---|
326 |
|
---|
327 | /* Initialize it */
|
---|
328 | if ( DPL_CreateIUnknown( *ppvObj ) &&
|
---|
329 | DPL_CreateLobby1( *ppvObj ) &&
|
---|
330 | DPL_CreateLobby2( *ppvObj ) &&
|
---|
331 | DPL_CreateLobby3( *ppvObj )
|
---|
332 | )
|
---|
333 | {
|
---|
334 | IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY)*ppvObj );
|
---|
335 | return S_OK;
|
---|
336 | }
|
---|
337 |
|
---|
338 | /* Initialize failed, destroy it */
|
---|
339 | DPL_DestroyLobby3( *ppvObj );
|
---|
340 | DPL_DestroyLobby2( *ppvObj );
|
---|
341 | DPL_DestroyLobby1( *ppvObj );
|
---|
342 | DPL_DestroyIUnknown( *ppvObj );
|
---|
343 | HeapFree( GetProcessHeap(), 0, *ppvObj );
|
---|
344 |
|
---|
345 | *ppvObj = NULL;
|
---|
346 | return DPERR_NOMEMORY;
|
---|
347 | }
|
---|
348 |
|
---|
349 | static HRESULT WINAPI DPL_QueryInterface
|
---|
350 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
351 | REFIID riid,
|
---|
352 | LPVOID* ppvObj )
|
---|
353 | {
|
---|
354 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
355 | TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj );
|
---|
356 |
|
---|
357 | *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
358 | sizeof( IDirectPlayLobbyWImpl ) );
|
---|
359 |
|
---|
360 | if( *ppvObj == NULL )
|
---|
361 | {
|
---|
362 | return DPERR_OUTOFMEMORY;
|
---|
363 | }
|
---|
364 |
|
---|
365 | CopyMemory( *ppvObj, iface, sizeof( IDirectPlayLobbyWImpl ) );
|
---|
366 | (*(IDirectPlayLobbyAImpl**)ppvObj)->ulInterfaceRef = 0;
|
---|
367 |
|
---|
368 | if( IsEqualGUID( &IID_IDirectPlayLobby, riid ) )
|
---|
369 | {
|
---|
370 | ICOM_THIS(IDirectPlayLobbyWImpl,*ppvObj);
|
---|
371 | ICOM_VTBL(This) = &directPlayLobbyWVT;
|
---|
372 | }
|
---|
373 | else if( IsEqualGUID( &IID_IDirectPlayLobbyA, riid ) )
|
---|
374 | {
|
---|
375 | ICOM_THIS(IDirectPlayLobbyAImpl,*ppvObj);
|
---|
376 | ICOM_VTBL(This) = &directPlayLobbyAVT;
|
---|
377 | }
|
---|
378 | else if( IsEqualGUID( &IID_IDirectPlayLobby2, riid ) )
|
---|
379 | {
|
---|
380 | ICOM_THIS(IDirectPlayLobby2WImpl,*ppvObj);
|
---|
381 | ICOM_VTBL(This) = &directPlayLobby2WVT;
|
---|
382 | }
|
---|
383 | else if( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
|
---|
384 | {
|
---|
385 | ICOM_THIS(IDirectPlayLobby2AImpl,*ppvObj);
|
---|
386 | ICOM_VTBL(This) = &directPlayLobby2AVT;
|
---|
387 | }
|
---|
388 | else if( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
|
---|
389 | {
|
---|
390 | ICOM_THIS(IDirectPlayLobby3WImpl,*ppvObj);
|
---|
391 | ICOM_VTBL(This) = &directPlayLobby3WVT;
|
---|
392 | }
|
---|
393 | else if( IsEqualGUID( &IID_IDirectPlayLobby3A, riid ) )
|
---|
394 | {
|
---|
395 | ICOM_THIS(IDirectPlayLobby3AImpl,*ppvObj);
|
---|
396 | ICOM_VTBL(This) = &directPlayLobby3AVT;
|
---|
397 | }
|
---|
398 | else
|
---|
399 | {
|
---|
400 | /* Unsupported interface */
|
---|
401 | HeapFree( GetProcessHeap(), 0, *ppvObj );
|
---|
402 | *ppvObj = NULL;
|
---|
403 |
|
---|
404 | return E_NOINTERFACE;
|
---|
405 | }
|
---|
406 |
|
---|
407 | IDirectPlayLobby_AddRef( (LPDIRECTPLAYLOBBY)*ppvObj );
|
---|
408 |
|
---|
409 | return S_OK;
|
---|
410 | }
|
---|
411 |
|
---|
412 | /*
|
---|
413 | * Simple procedure. Just increment the reference count to this
|
---|
414 | * structure and return the new reference count.
|
---|
415 | */
|
---|
416 | static ULONG WINAPI DPL_AddRef
|
---|
417 | ( LPDIRECTPLAYLOBBY iface )
|
---|
418 | {
|
---|
419 | ULONG ulInterfaceRefCount, ulObjRefCount;
|
---|
420 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
421 |
|
---|
422 | ulObjRefCount = InterlockedIncrement( (LPLONG)&This->unk->ulObjRef );
|
---|
423 | ulInterfaceRefCount = InterlockedIncrement( (LPLONG)&This->ulInterfaceRef );
|
---|
424 |
|
---|
425 | TRACE( "ref count incremented to %lu:%lu for %p\n",
|
---|
426 | ulInterfaceRefCount, ulObjRefCount, This );
|
---|
427 |
|
---|
428 | return ulObjRefCount;
|
---|
429 | }
|
---|
430 |
|
---|
431 | /*
|
---|
432 | * Simple COM procedure. Decrease the reference count to this object.
|
---|
433 | * If the object no longer has any reference counts, free up the associated
|
---|
434 | * memory.
|
---|
435 | */
|
---|
436 | static ULONG WINAPI DPL_Release
|
---|
437 | ( LPDIRECTPLAYLOBBYA iface )
|
---|
438 | {
|
---|
439 | ULONG ulInterfaceRefCount, ulObjRefCount;
|
---|
440 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
441 |
|
---|
442 | ulObjRefCount = InterlockedDecrement( (LPLONG)&This->unk->ulObjRef );
|
---|
443 | ulInterfaceRefCount = InterlockedDecrement( (LPLONG)&This->ulInterfaceRef );
|
---|
444 |
|
---|
445 | TRACE( "ref count decremented to %lu:%lu for %p\n",
|
---|
446 | ulInterfaceRefCount, ulObjRefCount, This );
|
---|
447 |
|
---|
448 | /* Deallocate if this is the last reference to the object */
|
---|
449 | if( ulObjRefCount == 0 )
|
---|
450 | {
|
---|
451 | DPL_DestroyLobby3( This );
|
---|
452 | DPL_DestroyLobby2( This );
|
---|
453 | DPL_DestroyLobby1( This );
|
---|
454 | DPL_DestroyIUnknown( This );
|
---|
455 | }
|
---|
456 |
|
---|
457 | if( ulInterfaceRefCount == 0 )
|
---|
458 | {
|
---|
459 | HeapFree( GetProcessHeap(), 0, This );
|
---|
460 | }
|
---|
461 |
|
---|
462 | return ulInterfaceRefCount;
|
---|
463 | }
|
---|
464 |
|
---|
465 |
|
---|
466 | /********************************************************************
|
---|
467 | *
|
---|
468 | * Connects an application to the session specified by the DPLCONNECTION
|
---|
469 | * structure currently stored with the DirectPlayLobby object.
|
---|
470 | *
|
---|
471 | * Returns a IDirectPlay interface.
|
---|
472 | *
|
---|
473 | */
|
---|
474 | static HRESULT WINAPI DPL_ConnectEx
|
---|
475 | ( IDirectPlayLobbyAImpl* This,
|
---|
476 | DWORD dwFlags,
|
---|
477 | REFIID riid,
|
---|
478 | LPVOID* lplpDP,
|
---|
479 | IUnknown* pUnk)
|
---|
480 | {
|
---|
481 | HRESULT hr;
|
---|
482 | DWORD dwOpenFlags = 0;
|
---|
483 | DWORD dwConnSize = 0;
|
---|
484 | LPDPLCONNECTION lpConn;
|
---|
485 |
|
---|
486 | FIXME("(%p)->(0x%08lx,%p,%p): semi stub\n", This, dwFlags, lplpDP, pUnk );
|
---|
487 |
|
---|
488 | if( pUnk )
|
---|
489 | {
|
---|
490 | return DPERR_INVALIDPARAMS;
|
---|
491 | }
|
---|
492 |
|
---|
493 | /* Backwards compatibility */
|
---|
494 | if( dwFlags == 0 )
|
---|
495 | {
|
---|
496 | dwFlags = DPCONNECT_RETURNSTATUS;
|
---|
497 | }
|
---|
498 |
|
---|
499 | /* Create the DirectPlay interface */
|
---|
500 | if( ( hr = DP_CreateInterface( riid, lplpDP ) ) != DP_OK )
|
---|
501 | {
|
---|
502 | ERR( "error creating interface for %s:%s.\n",
|
---|
503 | debugstr_guid( riid ), DPLAYX_HresultToString( hr ) );
|
---|
504 | return hr;
|
---|
505 | }
|
---|
506 |
|
---|
507 | /* FIXME: Is it safe/correct to use appID of 0? */
|
---|
508 | hr = IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY)This,
|
---|
509 | 0, NULL, &dwConnSize );
|
---|
510 | if( hr != DPERR_BUFFERTOOSMALL )
|
---|
511 | {
|
---|
512 | return hr;
|
---|
513 | }
|
---|
514 |
|
---|
515 | lpConn = (LPDPLCONNECTION)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwConnSize );
|
---|
516 |
|
---|
517 | if( lpConn == NULL )
|
---|
518 | {
|
---|
519 | return DPERR_NOMEMORY;
|
---|
520 | }
|
---|
521 |
|
---|
522 | /* FIXME: Is it safe/correct to use appID of 0? */
|
---|
523 | hr = IDirectPlayLobby_GetConnectionSettings( (LPDIRECTPLAYLOBBY)This,
|
---|
524 | 0, lpConn, &dwConnSize );
|
---|
525 | if( FAILED( hr ) )
|
---|
526 | {
|
---|
527 | return hr;
|
---|
528 | }
|
---|
529 |
|
---|
530 | #if 0
|
---|
531 | /* - Need to call IDirectPlay::EnumConnections with the service provider to get that good information
|
---|
532 | * - Need to call CreateAddress to create the lpConnection param for IDirectPlay::InitializeConnection
|
---|
533 | * - Call IDirectPlay::InitializeConnection
|
---|
534 | */
|
---|
535 |
|
---|
536 | /* Now initialize the Service Provider */
|
---|
537 | hr = IDirectPlayX_InitializeConnection( (*(LPDIRECTPLAY2*)lplpDP),
|
---|
538 | #endif
|
---|
539 |
|
---|
540 |
|
---|
541 | /* Setup flags to pass into DirectPlay::Open */
|
---|
542 | if( dwFlags & DPCONNECT_RETURNSTATUS )
|
---|
543 | {
|
---|
544 | dwOpenFlags |= DPOPEN_RETURNSTATUS;
|
---|
545 | }
|
---|
546 | dwOpenFlags |= lpConn->dwFlags;
|
---|
547 |
|
---|
548 | hr = IDirectPlayX_Open( (*(LPDIRECTPLAY2*)lplpDP), lpConn->lpSessionDesc,
|
---|
549 | dwOpenFlags );
|
---|
550 |
|
---|
551 | HeapFree( GetProcessHeap(), 0, lpConn );
|
---|
552 |
|
---|
553 | return hr;
|
---|
554 | }
|
---|
555 |
|
---|
556 | static HRESULT WINAPI IDirectPlayLobbyAImpl_Connect
|
---|
557 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
558 | DWORD dwFlags,
|
---|
559 | LPDIRECTPLAY2A* lplpDP,
|
---|
560 | IUnknown* pUnk)
|
---|
561 | {
|
---|
562 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
563 | return DPL_ConnectEx( This, dwFlags, &IID_IDirectPlay2A,
|
---|
564 | (LPVOID*)lplpDP, pUnk );
|
---|
565 | }
|
---|
566 |
|
---|
567 | static HRESULT WINAPI IDirectPlayLobbyWImpl_Connect
|
---|
568 | ( LPDIRECTPLAYLOBBY iface,
|
---|
569 | DWORD dwFlags,
|
---|
570 | LPDIRECTPLAY2* lplpDP,
|
---|
571 | IUnknown* pUnk)
|
---|
572 | {
|
---|
573 | ICOM_THIS(IDirectPlayLobbyAImpl,iface); /* Yes cast to A */
|
---|
574 | return DPL_ConnectEx( This, dwFlags, &IID_IDirectPlay2,
|
---|
575 | (LPVOID*)lplpDP, pUnk );
|
---|
576 | }
|
---|
577 |
|
---|
578 | /********************************************************************
|
---|
579 | *
|
---|
580 | * Creates a DirectPlay Address, given a service provider-specific network
|
---|
581 | * address.
|
---|
582 | * Returns an address contains the globally unique identifier
|
---|
583 | * (GUID) of the service provider and data that the service provider can
|
---|
584 | * interpret as a network address.
|
---|
585 | *
|
---|
586 | * NOTE: It appears that this method is supposed to be really really stupid
|
---|
587 | * with no error checking on the contents.
|
---|
588 | */
|
---|
589 | static HRESULT WINAPI IDirectPlayLobbyAImpl_CreateAddress
|
---|
590 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
591 | REFGUID guidSP,
|
---|
592 | REFGUID guidDataType,
|
---|
593 | LPCVOID lpData,
|
---|
594 | DWORD dwDataSize,
|
---|
595 | LPVOID lpAddress,
|
---|
596 | LPDWORD lpdwAddressSize )
|
---|
597 | {
|
---|
598 | return DPL_CreateAddress( guidSP, guidDataType, lpData, dwDataSize,
|
---|
599 | lpAddress, lpdwAddressSize, TRUE );
|
---|
600 | }
|
---|
601 |
|
---|
602 | static HRESULT WINAPI IDirectPlayLobbyWImpl_CreateAddress
|
---|
603 | ( LPDIRECTPLAYLOBBY iface,
|
---|
604 | REFGUID guidSP,
|
---|
605 | REFGUID guidDataType,
|
---|
606 | LPCVOID lpData,
|
---|
607 | DWORD dwDataSize,
|
---|
608 | LPVOID lpAddress,
|
---|
609 | LPDWORD lpdwAddressSize )
|
---|
610 | {
|
---|
611 | return DPL_CreateAddress( guidSP, guidDataType, lpData, dwDataSize,
|
---|
612 | lpAddress, lpdwAddressSize, FALSE );
|
---|
613 | }
|
---|
614 |
|
---|
615 | HRESULT DPL_CreateAddress(
|
---|
616 | REFGUID guidSP,
|
---|
617 | REFGUID guidDataType,
|
---|
618 | LPCVOID lpData,
|
---|
619 | DWORD dwDataSize,
|
---|
620 | LPVOID lpAddress,
|
---|
621 | LPDWORD lpdwAddressSize,
|
---|
622 | BOOL bAnsiInterface )
|
---|
623 | {
|
---|
624 | const DWORD dwNumAddElements = 2; /* Service Provide & address data type */
|
---|
625 | DPCOMPOUNDADDRESSELEMENT addressElements[ 2 /* dwNumAddElements */ ];
|
---|
626 |
|
---|
627 | TRACE( "(%p)->(%p,%p,0x%08lx,%p,%p,%d)\n", guidSP, guidDataType, lpData, dwDataSize,
|
---|
628 | lpAddress, lpdwAddressSize, bAnsiInterface );
|
---|
629 |
|
---|
630 | addressElements[ 0 ].guidDataType = DPAID_ServiceProvider;
|
---|
631 | addressElements[ 0 ].dwDataSize = sizeof( GUID );
|
---|
632 | addressElements[ 0 ].lpData = (LPVOID)guidSP;
|
---|
633 |
|
---|
634 | addressElements[ 1 ].guidDataType = *guidDataType;
|
---|
635 | addressElements[ 1 ].dwDataSize = dwDataSize;
|
---|
636 | addressElements[ 1 ].lpData = (LPVOID)lpData;
|
---|
637 |
|
---|
638 | /* Call CreateCompoundAddress to cut down on code.
|
---|
639 | NOTE: We can do this because we don't support DPL 1 interfaces! */
|
---|
640 | return DPL_CreateCompoundAddress( addressElements, dwNumAddElements,
|
---|
641 | lpAddress, lpdwAddressSize, bAnsiInterface );
|
---|
642 | }
|
---|
643 |
|
---|
644 |
|
---|
645 |
|
---|
646 | /********************************************************************
|
---|
647 | *
|
---|
648 | * Parses out chunks from the DirectPlay Address buffer by calling the
|
---|
649 | * given callback function, with lpContext, for each of the chunks.
|
---|
650 | *
|
---|
651 | */
|
---|
652 | static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddress
|
---|
653 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
654 | LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
|
---|
655 | LPCVOID lpAddress,
|
---|
656 | DWORD dwAddressSize,
|
---|
657 | LPVOID lpContext )
|
---|
658 | {
|
---|
659 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
660 |
|
---|
661 | TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This, lpEnumAddressCallback, lpAddress,
|
---|
662 | dwAddressSize, lpContext );
|
---|
663 |
|
---|
664 | return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
|
---|
665 | }
|
---|
666 |
|
---|
667 | static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddress
|
---|
668 | ( LPDIRECTPLAYLOBBY iface,
|
---|
669 | LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
|
---|
670 | LPCVOID lpAddress,
|
---|
671 | DWORD dwAddressSize,
|
---|
672 | LPVOID lpContext )
|
---|
673 | {
|
---|
674 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
675 |
|
---|
676 | TRACE("(%p)->(%p,%p,0x%08lx,%p)\n", This, lpEnumAddressCallback, lpAddress,
|
---|
677 | dwAddressSize, lpContext );
|
---|
678 |
|
---|
679 | return DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
|
---|
680 | }
|
---|
681 |
|
---|
682 | extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, LPCVOID lpAddress,
|
---|
683 | DWORD dwAddressSize, LPVOID lpContext )
|
---|
684 | {
|
---|
685 | DWORD dwTotalSizeEnumerated = 0;
|
---|
686 |
|
---|
687 | /* FIXME: First chunk is always the total size chunk - Should we report it? */
|
---|
688 |
|
---|
689 | while ( dwTotalSizeEnumerated < dwAddressSize )
|
---|
690 | {
|
---|
691 | LPDPADDRESS lpElements = (LPDPADDRESS)lpAddress;
|
---|
692 | DWORD dwSizeThisEnumeration;
|
---|
693 |
|
---|
694 | /* Invoke the enum method. If false is returned, stop enumeration */
|
---|
695 | if ( !lpEnumAddressCallback( &lpElements->guidDataType,
|
---|
696 | lpElements->dwDataSize,
|
---|
697 | (BYTE*)lpElements + sizeof( DPADDRESS ),
|
---|
698 | lpContext ) )
|
---|
699 | {
|
---|
700 | break;
|
---|
701 | }
|
---|
702 |
|
---|
703 | dwSizeThisEnumeration = sizeof( DPADDRESS ) + lpElements->dwDataSize;
|
---|
704 | lpAddress = (BYTE*) lpAddress + dwSizeThisEnumeration;
|
---|
705 | dwTotalSizeEnumerated += dwSizeThisEnumeration;
|
---|
706 | }
|
---|
707 |
|
---|
708 | return DP_OK;
|
---|
709 | }
|
---|
710 |
|
---|
711 | /********************************************************************
|
---|
712 | *
|
---|
713 | * Enumerates all the address types that a given service provider needs to
|
---|
714 | * build the DirectPlay Address.
|
---|
715 | *
|
---|
716 | */
|
---|
717 | static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumAddressTypes
|
---|
718 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
719 | LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback,
|
---|
720 | REFGUID guidSP,
|
---|
721 | LPVOID lpContext,
|
---|
722 | DWORD dwFlags )
|
---|
723 | {
|
---|
724 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
725 |
|
---|
726 | HKEY hkResult;
|
---|
727 | LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
|
---|
728 | DWORD dwIndex, sizeOfSubKeyName=50;
|
---|
729 | char subKeyName[51];
|
---|
730 | FILETIME filetime;
|
---|
731 |
|
---|
732 | TRACE(" (%p)->(%p,%p,%p,0x%08lx)\n", This, lpEnumAddressTypeCallback, guidSP, lpContext, dwFlags );
|
---|
733 |
|
---|
734 | if( dwFlags != 0 )
|
---|
735 | {
|
---|
736 | return DPERR_INVALIDPARAMS;
|
---|
737 | }
|
---|
738 |
|
---|
739 | if( !(void*)lpEnumAddressTypeCallback || !*(int*)lpEnumAddressTypeCallback )
|
---|
740 | {
|
---|
741 | return DPERR_INVALIDPARAMS;
|
---|
742 | }
|
---|
743 |
|
---|
744 | if( guidSP == NULL )
|
---|
745 | {
|
---|
746 | return DPERR_INVALIDOBJECT;
|
---|
747 | }
|
---|
748 |
|
---|
749 | /* Need to loop over the service providers in the registry */
|
---|
750 | if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
|
---|
751 | 0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
|
---|
752 | {
|
---|
753 | /* Hmmm. Does this mean that there are no service providers? */
|
---|
754 | ERR(": no service providers?\n");
|
---|
755 | return DP_OK;
|
---|
756 | }
|
---|
757 |
|
---|
758 | /* Traverse all the service providers we have available */
|
---|
759 | for( dwIndex=0;
|
---|
760 | RegEnumKeyExA( hkResult, dwIndex, subKeyName, &sizeOfSubKeyName,
|
---|
761 | NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
|
---|
762 | ++dwIndex, sizeOfSubKeyName=50 )
|
---|
763 | {
|
---|
764 |
|
---|
765 | HKEY hkServiceProvider, hkServiceProviderAt;
|
---|
766 | GUID serviceProviderGUID;
|
---|
767 | DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
|
---|
768 | char atSubKey[51];
|
---|
769 | char returnBuffer[51];
|
---|
770 | WCHAR buff[51];
|
---|
771 | DWORD dwAtIndex;
|
---|
772 | LPSTR atKey = "Address Types";
|
---|
773 | LPSTR guidDataSubKey = "Guid";
|
---|
774 | FILETIME filetime;
|
---|
775 |
|
---|
776 |
|
---|
777 | TRACE(" this time through: %s\n", subKeyName );
|
---|
778 |
|
---|
779 | /* Get a handle for this particular service provider */
|
---|
780 | if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_READ,
|
---|
781 | &hkServiceProvider ) != ERROR_SUCCESS )
|
---|
782 | {
|
---|
783 | ERR(": what the heck is going on?\n" );
|
---|
784 | continue;
|
---|
785 | }
|
---|
786 |
|
---|
787 | if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
|
---|
788 | NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
|
---|
789 | &sizeOfReturnBuffer ) != ERROR_SUCCESS )
|
---|
790 | {
|
---|
791 | ERR(": missing GUID registry data members\n" );
|
---|
792 | continue;
|
---|
793 | }
|
---|
794 |
|
---|
795 | /* FIXME: Check return types to ensure we're interpreting data right */
|
---|
796 | MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
|
---|
797 | CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
|
---|
798 | /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
|
---|
799 |
|
---|
800 | /* Determine if this is the Service Provider that the user asked for */
|
---|
801 | if( !IsEqualGUID( &serviceProviderGUID, guidSP ) )
|
---|
802 | {
|
---|
803 | continue;
|
---|
804 | }
|
---|
805 |
|
---|
806 | /* Get a handle for this particular service provider */
|
---|
807 | if( RegOpenKeyExA( hkServiceProvider, atKey, 0, KEY_READ,
|
---|
808 | &hkServiceProviderAt ) != ERROR_SUCCESS )
|
---|
809 | {
|
---|
810 | TRACE(": No Address Types registry data sub key/members\n" );
|
---|
811 | break;
|
---|
812 | }
|
---|
813 |
|
---|
814 | /* Traverse all the address type we have available */
|
---|
815 | for( dwAtIndex=0;
|
---|
816 | RegEnumKeyExA( hkServiceProviderAt, dwAtIndex, atSubKey, &sizeOfSubKeyName,
|
---|
817 | NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
|
---|
818 | ++dwAtIndex, sizeOfSubKeyName=50 )
|
---|
819 | {
|
---|
820 | TRACE( "Found Address Type GUID %s\n", atSubKey );
|
---|
821 |
|
---|
822 | /* FIXME: Check return types to ensure we're interpreting data right */
|
---|
823 | MultiByteToWideChar( CP_ACP, 0, atSubKey, -1, buff, sizeof(buff)/sizeof(WCHAR) );
|
---|
824 | CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
|
---|
825 | /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
|
---|
826 |
|
---|
827 | /* The enumeration will return FALSE if we are not to continue */
|
---|
828 | if( !lpEnumAddressTypeCallback( &serviceProviderGUID, lpContext, 0 ) )
|
---|
829 | {
|
---|
830 | WARN("lpEnumCallback returning FALSE\n" );
|
---|
831 | break; /* FIXME: This most likely has to break from the procedure...*/
|
---|
832 | }
|
---|
833 |
|
---|
834 | }
|
---|
835 |
|
---|
836 | /* We only enumerate address types for 1 GUID. We've found it, so quit looking */
|
---|
837 | break;
|
---|
838 | }
|
---|
839 |
|
---|
840 | return DP_OK;
|
---|
841 | }
|
---|
842 |
|
---|
843 | static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumAddressTypes
|
---|
844 | ( LPDIRECTPLAYLOBBY iface,
|
---|
845 | LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback,
|
---|
846 | REFGUID guidSP,
|
---|
847 | LPVOID lpContext,
|
---|
848 | DWORD dwFlags )
|
---|
849 | {
|
---|
850 | FIXME(":stub\n");
|
---|
851 | return DPERR_OUTOFMEMORY;
|
---|
852 | }
|
---|
853 |
|
---|
854 | /********************************************************************
|
---|
855 | *
|
---|
856 | * Enumerates what applications are registered with DirectPlay by
|
---|
857 | * invoking the callback function with lpContext.
|
---|
858 | *
|
---|
859 | */
|
---|
860 | static HRESULT WINAPI IDirectPlayLobbyWImpl_EnumLocalApplications
|
---|
861 | ( LPDIRECTPLAYLOBBY iface,
|
---|
862 | LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback,
|
---|
863 | LPVOID lpContext,
|
---|
864 | DWORD dwFlags )
|
---|
865 | {
|
---|
866 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
867 |
|
---|
868 | FIXME("(%p)->(%p,%p,0x%08lx):stub\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
|
---|
869 |
|
---|
870 | return DPERR_OUTOFMEMORY;
|
---|
871 | }
|
---|
872 |
|
---|
873 | static HRESULT WINAPI IDirectPlayLobbyAImpl_EnumLocalApplications
|
---|
874 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
875 | LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback,
|
---|
876 | LPVOID lpContext,
|
---|
877 | DWORD dwFlags )
|
---|
878 | {
|
---|
879 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
880 |
|
---|
881 | HKEY hkResult;
|
---|
882 | LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Applications";
|
---|
883 | LPSTR guidDataSubKey = "Guid";
|
---|
884 | DWORD dwIndex, sizeOfSubKeyName=50;
|
---|
885 | char subKeyName[51];
|
---|
886 | FILETIME filetime;
|
---|
887 |
|
---|
888 | TRACE("(%p)->(%p,%p,0x%08lx)\n", This, lpEnumLocalAppCallback, lpContext, dwFlags );
|
---|
889 |
|
---|
890 | if( dwFlags != 0 )
|
---|
891 | {
|
---|
892 | return DPERR_INVALIDPARAMS;
|
---|
893 | }
|
---|
894 |
|
---|
895 | if( !(void*)lpEnumLocalAppCallback || !*(int*)lpEnumLocalAppCallback )
|
---|
896 | {
|
---|
897 | return DPERR_INVALIDPARAMS;
|
---|
898 | }
|
---|
899 |
|
---|
900 | /* Need to loop over the service providers in the registry */
|
---|
901 | if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
|
---|
902 | 0, KEY_READ, &hkResult ) != ERROR_SUCCESS )
|
---|
903 | {
|
---|
904 | /* Hmmm. Does this mean that there are no service providers? */
|
---|
905 | ERR(": no service providers?\n");
|
---|
906 | return DP_OK;
|
---|
907 | }
|
---|
908 |
|
---|
909 | /* Traverse all registered applications */
|
---|
910 | for( dwIndex=0;
|
---|
911 | RegEnumKeyExA( hkResult, dwIndex, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, &filetime ) != ERROR_NO_MORE_ITEMS;
|
---|
912 | ++dwIndex, sizeOfSubKeyName=50 )
|
---|
913 | {
|
---|
914 |
|
---|
915 | HKEY hkServiceProvider;
|
---|
916 | GUID serviceProviderGUID;
|
---|
917 | DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
|
---|
918 | char returnBuffer[51];
|
---|
919 | WCHAR buff[51];
|
---|
920 | DPLAPPINFO dplAppInfo;
|
---|
921 |
|
---|
922 | TRACE(" this time through: %s\n", subKeyName );
|
---|
923 |
|
---|
924 | /* Get a handle for this particular service provider */
|
---|
925 | if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_READ,
|
---|
926 | &hkServiceProvider ) != ERROR_SUCCESS )
|
---|
927 | {
|
---|
928 | ERR(": what the heck is going on?\n" );
|
---|
929 | continue;
|
---|
930 | }
|
---|
931 |
|
---|
932 | if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
|
---|
933 | NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
|
---|
934 | &sizeOfReturnBuffer ) != ERROR_SUCCESS )
|
---|
935 | {
|
---|
936 | ERR(": missing GUID registry data members\n" );
|
---|
937 | continue;
|
---|
938 | }
|
---|
939 |
|
---|
940 | /* FIXME: Check return types to ensure we're interpreting data right */
|
---|
941 | MultiByteToWideChar( CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR) );
|
---|
942 | CLSIDFromString( (LPCOLESTR)buff, &serviceProviderGUID );
|
---|
943 | /* FIXME: Have I got a memory leak on the serviceProviderGUID? */
|
---|
944 |
|
---|
945 | dplAppInfo.dwSize = sizeof( dplAppInfo );
|
---|
946 | dplAppInfo.guidApplication = serviceProviderGUID;
|
---|
947 | dplAppInfo.lpszAppNameA = subKeyName;
|
---|
948 |
|
---|
949 | EnterCriticalSection( &This->unk->DPL_lock );
|
---|
950 |
|
---|
951 | memcpy( &This->dpl->hkCallbackKeyHack, &hkServiceProvider, sizeof( hkServiceProvider ) );
|
---|
952 |
|
---|
953 | if( !lpEnumLocalAppCallback( &dplAppInfo, lpContext, dwFlags ) )
|
---|
954 | {
|
---|
955 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
956 | break;
|
---|
957 | }
|
---|
958 |
|
---|
959 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
960 | }
|
---|
961 |
|
---|
962 | return DP_OK;
|
---|
963 | }
|
---|
964 |
|
---|
965 | /********************************************************************
|
---|
966 | *
|
---|
967 | * Retrieves the DPLCONNECTION structure that contains all the information
|
---|
968 | * needed to start and connect an application. This was generated using
|
---|
969 | * either the RunApplication or SetConnectionSettings methods.
|
---|
970 | *
|
---|
971 | * NOTES: If lpData is NULL then just return lpdwDataSize. This allows
|
---|
972 | * the data structure to be allocated by our caller which can then
|
---|
973 | * call this procedure/method again with a valid data pointer.
|
---|
974 | */
|
---|
975 | static HRESULT WINAPI IDirectPlayLobbyAImpl_GetConnectionSettings
|
---|
976 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
977 | DWORD dwAppID,
|
---|
978 | LPVOID lpData,
|
---|
979 | LPDWORD lpdwDataSize )
|
---|
980 | {
|
---|
981 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
982 | HRESULT hr;
|
---|
983 |
|
---|
984 | TRACE("(%p)->(0x%08lx,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
|
---|
985 |
|
---|
986 | EnterCriticalSection( &This->unk->DPL_lock );
|
---|
987 |
|
---|
988 | hr = DPLAYX_GetConnectionSettingsA( dwAppID,
|
---|
989 | lpData,
|
---|
990 | lpdwDataSize
|
---|
991 | );
|
---|
992 |
|
---|
993 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
994 |
|
---|
995 | return hr;
|
---|
996 | }
|
---|
997 |
|
---|
998 | static HRESULT WINAPI IDirectPlayLobbyWImpl_GetConnectionSettings
|
---|
999 | ( LPDIRECTPLAYLOBBY iface,
|
---|
1000 | DWORD dwAppID,
|
---|
1001 | LPVOID lpData,
|
---|
1002 | LPDWORD lpdwDataSize )
|
---|
1003 | {
|
---|
1004 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
1005 | HRESULT hr;
|
---|
1006 |
|
---|
1007 | TRACE("(%p)->(0x%08lx,%p,%p)\n", This, dwAppID, lpData, lpdwDataSize );
|
---|
1008 |
|
---|
1009 | EnterCriticalSection( &This->unk->DPL_lock );
|
---|
1010 |
|
---|
1011 | hr = DPLAYX_GetConnectionSettingsW( dwAppID,
|
---|
1012 | lpData,
|
---|
1013 | lpdwDataSize
|
---|
1014 | );
|
---|
1015 |
|
---|
1016 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
1017 |
|
---|
1018 | return hr;
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | /********************************************************************
|
---|
1022 | *
|
---|
1023 | * Retrieves the message sent between a lobby client and a DirectPlay
|
---|
1024 | * application. All messages are queued until received.
|
---|
1025 | *
|
---|
1026 | */
|
---|
1027 | static HRESULT WINAPI IDirectPlayLobbyAImpl_ReceiveLobbyMessage
|
---|
1028 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
1029 | DWORD dwFlags,
|
---|
1030 | DWORD dwAppID,
|
---|
1031 | LPDWORD lpdwMessageFlags,
|
---|
1032 | LPVOID lpData,
|
---|
1033 | LPDWORD lpdwDataSize )
|
---|
1034 | {
|
---|
1035 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
1036 | FIXME(":stub %p %08lx %08lx %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
|
---|
1037 | lpdwDataSize );
|
---|
1038 | return DPERR_OUTOFMEMORY;
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | static HRESULT WINAPI IDirectPlayLobbyWImpl_ReceiveLobbyMessage
|
---|
1042 | ( LPDIRECTPLAYLOBBY iface,
|
---|
1043 | DWORD dwFlags,
|
---|
1044 | DWORD dwAppID,
|
---|
1045 | LPDWORD lpdwMessageFlags,
|
---|
1046 | LPVOID lpData,
|
---|
1047 | LPDWORD lpdwDataSize )
|
---|
1048 | {
|
---|
1049 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
1050 | FIXME(":stub %p %08lx %08lx %p %p %p\n", This, dwFlags, dwAppID, lpdwMessageFlags, lpData,
|
---|
1051 | lpdwDataSize );
|
---|
1052 | return DPERR_OUTOFMEMORY;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | typedef struct tagRunApplicationEnumStruct
|
---|
1056 | {
|
---|
1057 | IDirectPlayLobbyAImpl* This;
|
---|
1058 |
|
---|
1059 | GUID appGUID;
|
---|
1060 | LPSTR lpszPath;
|
---|
1061 | LPSTR lpszFileName;
|
---|
1062 | LPSTR lpszCommandLine;
|
---|
1063 | LPSTR lpszCurrentDirectory;
|
---|
1064 | } RunApplicationEnumStruct, *lpRunApplicationEnumStruct;
|
---|
1065 |
|
---|
1066 | /* To be called by RunApplication to find how to invoke the function */
|
---|
1067 | static BOOL CALLBACK RunApplicationA_EnumLocalApplications
|
---|
1068 | ( LPCDPLAPPINFO lpAppInfo,
|
---|
1069 | LPVOID lpContext,
|
---|
1070 | DWORD dwFlags )
|
---|
1071 | {
|
---|
1072 | lpRunApplicationEnumStruct lpData = (lpRunApplicationEnumStruct)lpContext;
|
---|
1073 |
|
---|
1074 | if( IsEqualGUID( &lpAppInfo->guidApplication, &lpData->appGUID ) )
|
---|
1075 | {
|
---|
1076 | char returnBuffer[200];
|
---|
1077 | DWORD returnType, sizeOfReturnBuffer;
|
---|
1078 | LPSTR clSubKey = "CommandLine";
|
---|
1079 | LPSTR cdSubKey = "CurrentDirectory";
|
---|
1080 | LPSTR fileSubKey = "File";
|
---|
1081 | LPSTR pathSubKey = "Path";
|
---|
1082 |
|
---|
1083 | /* FIXME: Lazy man hack - dplay struct has the present reg key saved */
|
---|
1084 |
|
---|
1085 | sizeOfReturnBuffer = 200;
|
---|
1086 |
|
---|
1087 | /* Get all the appropriate data from the registry */
|
---|
1088 | if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, clSubKey,
|
---|
1089 | NULL, &returnType, (LPBYTE)returnBuffer,
|
---|
1090 | &sizeOfReturnBuffer ) != ERROR_SUCCESS )
|
---|
1091 | {
|
---|
1092 | ERR( ": missing CommandLine registry data member\n" );
|
---|
1093 | }
|
---|
1094 | else
|
---|
1095 | {
|
---|
1096 | if ((lpData->lpszCommandLine = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
|
---|
1097 | strcpy( lpData->lpszCommandLine, returnBuffer );
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | sizeOfReturnBuffer = 200;
|
---|
1101 |
|
---|
1102 | if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, cdSubKey,
|
---|
1103 | NULL, &returnType, (LPBYTE)returnBuffer,
|
---|
1104 | &sizeOfReturnBuffer ) != ERROR_SUCCESS )
|
---|
1105 | {
|
---|
1106 | ERR( ": missing CurrentDirectory registry data member\n" );
|
---|
1107 | }
|
---|
1108 | else
|
---|
1109 | {
|
---|
1110 | if ((lpData->lpszCurrentDirectory = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
|
---|
1111 | strcpy( lpData->lpszCurrentDirectory, returnBuffer );
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | sizeOfReturnBuffer = 200;
|
---|
1115 |
|
---|
1116 | if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, fileSubKey,
|
---|
1117 | NULL, &returnType, (LPBYTE)returnBuffer,
|
---|
1118 | &sizeOfReturnBuffer ) != ERROR_SUCCESS )
|
---|
1119 | {
|
---|
1120 | ERR( ": missing File registry data member\n" );
|
---|
1121 | }
|
---|
1122 | else
|
---|
1123 | {
|
---|
1124 | if ((lpData->lpszFileName = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
|
---|
1125 | strcpy( lpData->lpszFileName, returnBuffer );
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | sizeOfReturnBuffer = 200;
|
---|
1129 |
|
---|
1130 | if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, pathSubKey,
|
---|
1131 | NULL, &returnType, (LPBYTE)returnBuffer,
|
---|
1132 | &sizeOfReturnBuffer ) != ERROR_SUCCESS )
|
---|
1133 | {
|
---|
1134 | ERR( ": missing Path registry data member\n" );
|
---|
1135 | }
|
---|
1136 | else
|
---|
1137 | {
|
---|
1138 | if ((lpData->lpszPath = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
|
---|
1139 | strcpy( lpData->lpszPath, returnBuffer );
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 | return FALSE; /* No need to keep going as we found what we wanted */
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | return TRUE; /* Keep enumerating, haven't found the application yet */
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | BOOL DPL_CreateAndSetLobbyHandles( DWORD dwDestProcessId, HANDLE hDestProcess,
|
---|
1149 | LPHANDLE lphStart, LPHANDLE lphDeath,
|
---|
1150 | LPHANDLE lphRead )
|
---|
1151 | {
|
---|
1152 | /* These are the handles for the created process */
|
---|
1153 | HANDLE hAppStart, hAppDeath, hAppRead, hTemp;
|
---|
1154 | SECURITY_ATTRIBUTES s_attrib;
|
---|
1155 |
|
---|
1156 | s_attrib.nLength = sizeof( s_attrib );
|
---|
1157 | s_attrib.lpSecurityDescriptor = NULL;
|
---|
1158 | s_attrib.bInheritHandle = TRUE;
|
---|
1159 |
|
---|
1160 | /* FIXME: Is there a handle leak here? */
|
---|
1161 | hTemp = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
|
---|
1162 | *lphStart = ConvertToGlobalHandle( hTemp );
|
---|
1163 |
|
---|
1164 | hTemp = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
|
---|
1165 | *lphDeath = ConvertToGlobalHandle( hTemp );
|
---|
1166 |
|
---|
1167 | hTemp = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
|
---|
1168 | *lphRead = ConvertToGlobalHandle( hTemp );
|
---|
1169 |
|
---|
1170 | if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart,
|
---|
1171 | hDestProcess, &hAppStart,
|
---|
1172 | 0, FALSE, DUPLICATE_SAME_ACCESS ) ) ||
|
---|
1173 | ( !DuplicateHandle( GetCurrentProcess(), *lphDeath,
|
---|
1174 | hDestProcess, &hAppDeath,
|
---|
1175 | 0, FALSE, DUPLICATE_SAME_ACCESS ) ) ||
|
---|
1176 | ( !DuplicateHandle( GetCurrentProcess(), *lphRead,
|
---|
1177 | hDestProcess, &hAppRead,
|
---|
1178 | 0, FALSE, DUPLICATE_SAME_ACCESS ) )
|
---|
1179 | )
|
---|
1180 | {
|
---|
1181 | /* FIXME: Handle leak... */
|
---|
1182 | ERR( "Unable to dup handles\n" );
|
---|
1183 | return FALSE;
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 | if( !DPLAYX_SetLobbyHandles( dwDestProcessId,
|
---|
1187 | hAppStart, hAppDeath, hAppRead ) )
|
---|
1188 | {
|
---|
1189 | return FALSE;
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | return TRUE;
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 |
|
---|
1196 | /********************************************************************
|
---|
1197 | *
|
---|
1198 | * Starts an application and passes to it all the information to
|
---|
1199 | * connect to a session.
|
---|
1200 | *
|
---|
1201 | */
|
---|
1202 | static HRESULT WINAPI IDirectPlayLobbyAImpl_RunApplication
|
---|
1203 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
1204 | DWORD dwFlags,
|
---|
1205 | LPDWORD lpdwAppID,
|
---|
1206 | LPDPLCONNECTION lpConn,
|
---|
1207 | HANDLE hReceiveEvent )
|
---|
1208 | {
|
---|
1209 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
1210 | HRESULT hr;
|
---|
1211 | RunApplicationEnumStruct enumData;
|
---|
1212 | char temp[200];
|
---|
1213 | STARTUPINFOA startupInfo;
|
---|
1214 | PROCESS_INFORMATION newProcessInfo;
|
---|
1215 | LPSTR appName;
|
---|
1216 | DWORD dwSuspendCount;
|
---|
1217 | HANDLE hStart, hDeath, hSettingRead;
|
---|
1218 |
|
---|
1219 | TRACE( "(%p)->(0x%08lx,%p,%p,%x)\n",
|
---|
1220 | This, dwFlags, lpdwAppID, lpConn, hReceiveEvent );
|
---|
1221 |
|
---|
1222 | if( dwFlags != 0 )
|
---|
1223 | {
|
---|
1224 | return DPERR_INVALIDPARAMS;
|
---|
1225 | }
|
---|
1226 |
|
---|
1227 | if( DPLAYX_AnyLobbiesWaitingForConnSettings() )
|
---|
1228 | {
|
---|
1229 | FIXME( "Waiting lobby not being handled correctly\n" );
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | EnterCriticalSection( &This->unk->DPL_lock );
|
---|
1233 |
|
---|
1234 | ZeroMemory( &enumData, sizeof( enumData ) );
|
---|
1235 | enumData.This = This;
|
---|
1236 | enumData.appGUID = lpConn->lpSessionDesc->guidApplication;
|
---|
1237 |
|
---|
1238 | /* Our callback function will fill up the enumData structure with all the information
|
---|
1239 | required to start a new process */
|
---|
1240 | IDirectPlayLobby_EnumLocalApplications( iface, RunApplicationA_EnumLocalApplications,
|
---|
1241 | (LPVOID)(&enumData), 0 );
|
---|
1242 |
|
---|
1243 | /* First the application name */
|
---|
1244 | strcpy( temp, enumData.lpszPath );
|
---|
1245 | strcat( temp, "\\" );
|
---|
1246 | strcat( temp, enumData.lpszFileName );
|
---|
1247 | HeapFree( GetProcessHeap(), 0, enumData.lpszPath );
|
---|
1248 | HeapFree( GetProcessHeap(), 0, enumData.lpszFileName );
|
---|
1249 | if ((appName = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) strcpy( appName, temp );
|
---|
1250 |
|
---|
1251 | /* Now the command line */
|
---|
1252 | strcat( temp, " " );
|
---|
1253 | strcat( temp, enumData.lpszCommandLine );
|
---|
1254 | HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
|
---|
1255 | if ((enumData.lpszCommandLine = (LPSTR)HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 )))
|
---|
1256 | strcpy( enumData.lpszCommandLine, temp );
|
---|
1257 |
|
---|
1258 | ZeroMemory( &startupInfo, sizeof( startupInfo ) );
|
---|
1259 | startupInfo.cb = sizeof( startupInfo );
|
---|
1260 | /* FIXME: Should any fields be filled in? */
|
---|
1261 |
|
---|
1262 | ZeroMemory( &newProcessInfo, sizeof( newProcessInfo ) );
|
---|
1263 |
|
---|
1264 | if( !CreateProcessA( appName,
|
---|
1265 | enumData.lpszCommandLine,
|
---|
1266 | NULL,
|
---|
1267 | NULL,
|
---|
1268 | FALSE,
|
---|
1269 | CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_SUSPENDED, /* Creation Flags */
|
---|
1270 | NULL,
|
---|
1271 | enumData.lpszCurrentDirectory,
|
---|
1272 | &startupInfo,
|
---|
1273 | &newProcessInfo
|
---|
1274 | )
|
---|
1275 | )
|
---|
1276 | {
|
---|
1277 | ERR( "Failed to create process for app %s\n", appName );
|
---|
1278 |
|
---|
1279 | HeapFree( GetProcessHeap(), 0, appName );
|
---|
1280 | HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
|
---|
1281 | HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
|
---|
1282 |
|
---|
1283 | return DPERR_CANTCREATEPROCESS;
|
---|
1284 | }
|
---|
1285 |
|
---|
1286 | HeapFree( GetProcessHeap(), 0, appName );
|
---|
1287 | HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
|
---|
1288 | HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
|
---|
1289 |
|
---|
1290 | /* Reserve this global application id! */
|
---|
1291 | if( !DPLAYX_CreateLobbyApplication( newProcessInfo.dwProcessId ) )
|
---|
1292 | {
|
---|
1293 | ERR( "Unable to create global application data for 0x%08lx\n",
|
---|
1294 | newProcessInfo.dwProcessId );
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 | hr = IDirectPlayLobby_SetConnectionSettings( iface, 0, newProcessInfo.dwProcessId, lpConn );
|
---|
1298 |
|
---|
1299 | if( hr != DP_OK )
|
---|
1300 | {
|
---|
1301 | ERR( "SetConnectionSettings failure %s\n", DPLAYX_HresultToString( hr ) );
|
---|
1302 | return hr;
|
---|
1303 | }
|
---|
1304 |
|
---|
1305 | /* Setup the handles for application notification */
|
---|
1306 | DPL_CreateAndSetLobbyHandles( newProcessInfo.dwProcessId,
|
---|
1307 | newProcessInfo.hProcess,
|
---|
1308 | &hStart, &hDeath, &hSettingRead );
|
---|
1309 |
|
---|
1310 | /* Setup the message thread ID */
|
---|
1311 | This->dpl->dwMsgThread =
|
---|
1312 | CreateLobbyMessageReceptionThread( hReceiveEvent, hStart, hDeath, hSettingRead );
|
---|
1313 |
|
---|
1314 | DPLAYX_SetLobbyMsgThreadId( newProcessInfo.dwProcessId, This->dpl->dwMsgThread );
|
---|
1315 |
|
---|
1316 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
1317 |
|
---|
1318 | /* Everything seems to have been set correctly, update the dwAppID */
|
---|
1319 | *lpdwAppID = newProcessInfo.dwProcessId;
|
---|
1320 |
|
---|
1321 | /* Unsuspend the process - should return the prev suspension count */
|
---|
1322 | if( ( dwSuspendCount = ResumeThread( newProcessInfo.hThread ) ) != 1 )
|
---|
1323 | {
|
---|
1324 | ERR( "ResumeThread failed with 0x%08lx\n", dwSuspendCount );
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | return DP_OK;
|
---|
1328 | }
|
---|
1329 |
|
---|
1330 | static HRESULT WINAPI IDirectPlayLobbyWImpl_RunApplication
|
---|
1331 | ( LPDIRECTPLAYLOBBY iface,
|
---|
1332 | DWORD dwFlags,
|
---|
1333 | LPDWORD lpdwAppID,
|
---|
1334 | LPDPLCONNECTION lpConn,
|
---|
1335 | HANDLE hReceiveEvent )
|
---|
1336 | {
|
---|
1337 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
1338 | FIXME( "(%p)->(0x%08lx,%p,%p,%p):stub\n", This, dwFlags, lpdwAppID, lpConn, (void *)hReceiveEvent );
|
---|
1339 | return DPERR_OUTOFMEMORY;
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 | /********************************************************************
|
---|
1343 | *
|
---|
1344 | * Sends a message between the application and the lobby client.
|
---|
1345 | * All messages are queued until received.
|
---|
1346 | *
|
---|
1347 | */
|
---|
1348 | static HRESULT WINAPI IDirectPlayLobbyAImpl_SendLobbyMessage
|
---|
1349 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
1350 | DWORD dwFlags,
|
---|
1351 | DWORD dwAppID,
|
---|
1352 | LPVOID lpData,
|
---|
1353 | DWORD dwDataSize )
|
---|
1354 | {
|
---|
1355 | FIXME(":stub\n");
|
---|
1356 | return DPERR_OUTOFMEMORY;
|
---|
1357 | }
|
---|
1358 |
|
---|
1359 | static HRESULT WINAPI IDirectPlayLobbyWImpl_SendLobbyMessage
|
---|
1360 | ( LPDIRECTPLAYLOBBY iface,
|
---|
1361 | DWORD dwFlags,
|
---|
1362 | DWORD dwAppID,
|
---|
1363 | LPVOID lpData,
|
---|
1364 | DWORD dwDataSize )
|
---|
1365 | {
|
---|
1366 | FIXME(":stub\n");
|
---|
1367 | return DPERR_OUTOFMEMORY;
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | /********************************************************************
|
---|
1371 | *
|
---|
1372 | * Modifies the DPLCONNECTION structure to contain all information
|
---|
1373 | * needed to start and connect an application.
|
---|
1374 | *
|
---|
1375 | */
|
---|
1376 | static HRESULT WINAPI IDirectPlayLobbyWImpl_SetConnectionSettings
|
---|
1377 | ( LPDIRECTPLAYLOBBY iface,
|
---|
1378 | DWORD dwFlags,
|
---|
1379 | DWORD dwAppID,
|
---|
1380 | LPDPLCONNECTION lpConn )
|
---|
1381 | {
|
---|
1382 | ICOM_THIS(IDirectPlayLobbyWImpl,iface);
|
---|
1383 | HRESULT hr;
|
---|
1384 |
|
---|
1385 | TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This, dwFlags, dwAppID, lpConn );
|
---|
1386 |
|
---|
1387 | EnterCriticalSection( &This->unk->DPL_lock );
|
---|
1388 |
|
---|
1389 | hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
|
---|
1390 |
|
---|
1391 | /* FIXME: Don't think that this is supposed to fail, but the docuementation
|
---|
1392 | is somewhat sketchy. I'll try creating a lobby application
|
---|
1393 | for this... */
|
---|
1394 | if( hr == DPERR_NOTLOBBIED )
|
---|
1395 | {
|
---|
1396 | FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
|
---|
1397 | if( dwAppID == 0 )
|
---|
1398 | {
|
---|
1399 | dwAppID = GetCurrentProcessId();
|
---|
1400 | }
|
---|
1401 | DPLAYX_CreateLobbyApplication( dwAppID );
|
---|
1402 | hr = DPLAYX_SetConnectionSettingsW( dwFlags, dwAppID, lpConn );
|
---|
1403 | }
|
---|
1404 |
|
---|
1405 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
1406 |
|
---|
1407 | return hr;
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 | static HRESULT WINAPI IDirectPlayLobbyAImpl_SetConnectionSettings
|
---|
1411 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
1412 | DWORD dwFlags,
|
---|
1413 | DWORD dwAppID,
|
---|
1414 | LPDPLCONNECTION lpConn )
|
---|
1415 | {
|
---|
1416 | ICOM_THIS(IDirectPlayLobbyAImpl,iface);
|
---|
1417 | HRESULT hr;
|
---|
1418 |
|
---|
1419 | TRACE("(%p)->(0x%08lx,0x%08lx,%p)\n", This, dwFlags, dwAppID, lpConn );
|
---|
1420 |
|
---|
1421 | EnterCriticalSection( &This->unk->DPL_lock );
|
---|
1422 |
|
---|
1423 | hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
|
---|
1424 |
|
---|
1425 | /* FIXME: Don't think that this is supposed to fail, but the docuementation
|
---|
1426 | is somewhat sketchy. I'll try creating a lobby application
|
---|
1427 | for this... */
|
---|
1428 | if( hr == DPERR_NOTLOBBIED )
|
---|
1429 | {
|
---|
1430 | FIXME( "Unlobbied app setting connections. Is this correct behavior?\n" );
|
---|
1431 | dwAppID = GetCurrentProcessId();
|
---|
1432 | DPLAYX_CreateLobbyApplication( dwAppID );
|
---|
1433 | hr = DPLAYX_SetConnectionSettingsA( dwFlags, dwAppID, lpConn );
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | LeaveCriticalSection( &This->unk->DPL_lock );
|
---|
1437 |
|
---|
1438 | return hr;
|
---|
1439 | }
|
---|
1440 |
|
---|
1441 | /********************************************************************
|
---|
1442 | *
|
---|
1443 | * Registers an event that will be set when a lobby message is received.
|
---|
1444 | *
|
---|
1445 | */
|
---|
1446 | static HRESULT WINAPI IDirectPlayLobbyAImpl_SetLobbyMessageEvent
|
---|
1447 | ( LPDIRECTPLAYLOBBYA iface,
|
---|
1448 | DWORD dwFlags,
|
---|
1449 | DWORD dwAppID,
|
---|
1450 | HANDLE hReceiveEvent )
|
---|
1451 | {
|
---|
1452 | FIXME(":stub\n");
|
---|
1453 | return DPERR_OUTOFMEMORY;
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | static HRESULT WINAPI IDirectPlayLobbyWImpl_SetLobbyMessageEvent
|
---|
1457 | ( LPDIRECTPLAYLOBBY iface,
|
---|
1458 | DWORD dwFlags,
|
---|
1459 | DWORD dwAppID,
|
---|
1460 | HANDLE hReceiveEvent )
|
---|
1461 | {
|
---|
1462 | FIXME(":stub\n");
|
---|
1463 | return DPERR_OUTOFMEMORY;
|
---|
1464 | }
|
---|
1465 |
|
---|
1466 |
|
---|
1467 | /* DPL 2 methods */
|
---|
1468 | static HRESULT WINAPI IDirectPlayLobby2WImpl_CreateCompoundAddress
|
---|
1469 | ( LPDIRECTPLAYLOBBY2 iface,
|
---|
1470 | LPCDPCOMPOUNDADDRESSELEMENT lpElements,
|
---|
1471 | DWORD dwElementCount,
|
---|
1472 | LPVOID lpAddress,
|
---|
1473 | LPDWORD lpdwAddressSize )
|
---|
1474 | {
|
---|
1475 | return DPL_CreateCompoundAddress( lpElements, dwElementCount, lpAddress, lpdwAddressSize, FALSE );
|
---|
1476 | }
|
---|
1477 |
|
---|
1478 | static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress
|
---|
1479 | ( LPDIRECTPLAYLOBBY2A iface,
|
---|
1480 | LPCDPCOMPOUNDADDRESSELEMENT lpElements,
|
---|
1481 | DWORD dwElementCount,
|
---|
1482 | LPVOID lpAddress,
|
---|
1483 | LPDWORD lpdwAddressSize )
|
---|
1484 | {
|
---|
1485 | return DPL_CreateCompoundAddress( lpElements, dwElementCount, lpAddress, lpdwAddressSize, TRUE );
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | HRESULT DPL_CreateCompoundAddress
|
---|
1489 | ( LPCDPCOMPOUNDADDRESSELEMENT lpElements,
|
---|
1490 | DWORD dwElementCount,
|
---|
1491 | LPVOID lpAddress,
|
---|
1492 | LPDWORD lpdwAddressSize,
|
---|
1493 | BOOL bAnsiInterface )
|
---|
1494 | {
|
---|
1495 | DWORD dwSizeRequired = 0;
|
---|
1496 | DWORD dwElements;
|
---|
1497 | LPCDPCOMPOUNDADDRESSELEMENT lpOrigElements = lpElements;
|
---|
1498 |
|
---|
1499 | TRACE("(%p,0x%08lx,%p,%p)\n", lpElements, dwElementCount, lpAddress, lpdwAddressSize );
|
---|
1500 |
|
---|
1501 | /* Parameter check */
|
---|
1502 | if( ( lpElements == NULL ) ||
|
---|
1503 | ( dwElementCount == 0 ) /* FIXME: Not sure if this is a failure case */
|
---|
1504 | )
|
---|
1505 | {
|
---|
1506 | return DPERR_INVALIDPARAMS;
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | /* Add the total size chunk */
|
---|
1510 | dwSizeRequired += sizeof( DPADDRESS ) + sizeof( DWORD );
|
---|
1511 |
|
---|
1512 | /* Calculate the size of the buffer required */
|
---|
1513 | for ( dwElements = dwElementCount; dwElements > 0; --dwElements, ++lpElements )
|
---|
1514 | {
|
---|
1515 | if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ServiceProvider ) ) ||
|
---|
1516 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
|
---|
1517 | )
|
---|
1518 | {
|
---|
1519 | dwSizeRequired += sizeof( DPADDRESS ) + sizeof( GUID );
|
---|
1520 | }
|
---|
1521 | else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Phone ) ) ||
|
---|
1522 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Modem ) ) ||
|
---|
1523 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
|
---|
1524 | )
|
---|
1525 | {
|
---|
1526 | if( !bAnsiInterface )
|
---|
1527 | {
|
---|
1528 | ERR( "Ansi GUIDs used for unicode interface\n" );
|
---|
1529 | return DPERR_INVALIDFLAGS;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | dwSizeRequired += sizeof( DPADDRESS ) + lpElements->dwDataSize;
|
---|
1533 | }
|
---|
1534 | else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
|
---|
1535 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ModemW ) ) ||
|
---|
1536 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
|
---|
1537 | )
|
---|
1538 | {
|
---|
1539 | if( bAnsiInterface )
|
---|
1540 | {
|
---|
1541 | ERR( "Unicode GUIDs used for ansi interface\n" );
|
---|
1542 | return DPERR_INVALIDFLAGS;
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 | FIXME( "Right size for unicode interface?\n" );
|
---|
1546 | dwSizeRequired += sizeof( DPADDRESS ) + lpElements->dwDataSize * sizeof( WCHAR );
|
---|
1547 | }
|
---|
1548 | else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
|
---|
1549 | {
|
---|
1550 | dwSizeRequired += sizeof( DPADDRESS ) + sizeof( WORD );
|
---|
1551 | }
|
---|
1552 | else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
|
---|
1553 | {
|
---|
1554 | FIXME( "Right size for unicode interface?\n" );
|
---|
1555 | dwSizeRequired += sizeof( DPADDRESS ) + sizeof( DPCOMPORTADDRESS ); /* FIXME: Right size? */
|
---|
1556 | }
|
---|
1557 | else
|
---|
1558 | {
|
---|
1559 | ERR( "Unknown GUID %s\n", debugstr_guid(&lpElements->guidDataType) );
|
---|
1560 | return DPERR_INVALIDFLAGS;
|
---|
1561 | }
|
---|
1562 | }
|
---|
1563 |
|
---|
1564 | /* The user wants to know how big a buffer to allocate for us */
|
---|
1565 | if( ( lpAddress == NULL ) ||
|
---|
1566 | ( *lpdwAddressSize < dwSizeRequired )
|
---|
1567 | )
|
---|
1568 | {
|
---|
1569 | *lpdwAddressSize = dwSizeRequired;
|
---|
1570 | return DPERR_BUFFERTOOSMALL;
|
---|
1571 | }
|
---|
1572 |
|
---|
1573 | /* Add the total size chunk */
|
---|
1574 | {
|
---|
1575 | LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
|
---|
1576 |
|
---|
1577 | CopyMemory( &lpdpAddress->guidDataType, &DPAID_TotalSize, sizeof( GUID ) );
|
---|
1578 | lpdpAddress->dwDataSize = sizeof( DWORD );
|
---|
1579 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1580 |
|
---|
1581 | *(LPDWORD)lpAddress = dwSizeRequired;
|
---|
1582 | lpAddress = (char *) lpAddress + sizeof( DWORD );
|
---|
1583 | }
|
---|
1584 |
|
---|
1585 | /* Calculate the size of the buffer required */
|
---|
1586 | for( dwElements = dwElementCount, lpElements = lpOrigElements;
|
---|
1587 | dwElements > 0;
|
---|
1588 | --dwElements, ++lpElements )
|
---|
1589 | {
|
---|
1590 | if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ServiceProvider ) ) ||
|
---|
1591 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_LobbyProvider ) )
|
---|
1592 | )
|
---|
1593 | {
|
---|
1594 | LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
|
---|
1595 |
|
---|
1596 | CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
|
---|
1597 | sizeof( GUID ) );
|
---|
1598 | lpdpAddress->dwDataSize = sizeof( GUID );
|
---|
1599 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1600 |
|
---|
1601 | CopyMemory( lpAddress, lpElements->lpData, sizeof( GUID ) );
|
---|
1602 | lpAddress = (char *) lpAddress + sizeof( GUID );
|
---|
1603 | }
|
---|
1604 | else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Phone ) ) ||
|
---|
1605 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_Modem ) ) ||
|
---|
1606 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INet ) )
|
---|
1607 | )
|
---|
1608 | {
|
---|
1609 | LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
|
---|
1610 |
|
---|
1611 | CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
|
---|
1612 | sizeof( GUID ) );
|
---|
1613 | lpdpAddress->dwDataSize = lpElements->dwDataSize;
|
---|
1614 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1615 |
|
---|
1616 | lstrcpynA( (LPSTR)lpAddress,
|
---|
1617 | (LPCSTR)lpElements->lpData,
|
---|
1618 | lpElements->dwDataSize );
|
---|
1619 | lpAddress = (char *) lpAddress + lpElements->dwDataSize;
|
---|
1620 | }
|
---|
1621 | else if ( ( IsEqualGUID( &lpElements->guidDataType, &DPAID_PhoneW ) ) ||
|
---|
1622 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ModemW ) ) ||
|
---|
1623 | ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetW ) )
|
---|
1624 | )
|
---|
1625 | {
|
---|
1626 | LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
|
---|
1627 |
|
---|
1628 | CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
|
---|
1629 | sizeof( GUID ) );
|
---|
1630 | lpdpAddress->dwDataSize = lpElements->dwDataSize;
|
---|
1631 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1632 |
|
---|
1633 | lstrcpynW( (LPWSTR)lpAddress,
|
---|
1634 | (LPCWSTR)lpElements->lpData,
|
---|
1635 | lpElements->dwDataSize );
|
---|
1636 | lpAddress = (char *) lpAddress + lpElements->dwDataSize * sizeof( WCHAR );
|
---|
1637 | }
|
---|
1638 | else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_INetPort ) )
|
---|
1639 | {
|
---|
1640 | LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
|
---|
1641 |
|
---|
1642 | CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
|
---|
1643 | sizeof( GUID ) );
|
---|
1644 | lpdpAddress->dwDataSize = lpElements->dwDataSize;
|
---|
1645 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1646 |
|
---|
1647 | *((LPWORD)lpAddress) = *((LPWORD)lpElements->lpData);
|
---|
1648 | lpAddress = (char *) lpAddress + sizeof( WORD );
|
---|
1649 | }
|
---|
1650 | else if ( IsEqualGUID( &lpElements->guidDataType, &DPAID_ComPort ) )
|
---|
1651 | {
|
---|
1652 | LPDPADDRESS lpdpAddress = (LPDPADDRESS)lpAddress;
|
---|
1653 |
|
---|
1654 | CopyMemory( &lpdpAddress->guidDataType, &lpElements->guidDataType,
|
---|
1655 | sizeof( GUID ) );
|
---|
1656 | lpdpAddress->dwDataSize = lpElements->dwDataSize;
|
---|
1657 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1658 |
|
---|
1659 | CopyMemory( lpAddress, lpElements->lpData, sizeof( DPADDRESS ) );
|
---|
1660 | lpAddress = (char *) lpAddress + sizeof( DPADDRESS );
|
---|
1661 | }
|
---|
1662 | }
|
---|
1663 |
|
---|
1664 | return DP_OK;
|
---|
1665 | }
|
---|
1666 |
|
---|
1667 | /* DPL 3 methods */
|
---|
1668 |
|
---|
1669 | static HRESULT WINAPI IDirectPlayLobby3WImpl_ConnectEx
|
---|
1670 | ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, REFIID riid,
|
---|
1671 | LPVOID* lplpDP, IUnknown* pUnk )
|
---|
1672 | {
|
---|
1673 | ICOM_THIS( IDirectPlayLobbyAImpl, iface );
|
---|
1674 | return DPL_ConnectEx( This, dwFlags, riid, lplpDP, pUnk );
|
---|
1675 | }
|
---|
1676 |
|
---|
1677 | static HRESULT WINAPI IDirectPlayLobby3AImpl_ConnectEx
|
---|
1678 | ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, REFIID riid,
|
---|
1679 | LPVOID* lplpDP, IUnknown* pUnk )
|
---|
1680 | {
|
---|
1681 | ICOM_THIS( IDirectPlayLobbyAImpl, iface );
|
---|
1682 | return DPL_ConnectEx( This, dwFlags, riid, lplpDP, pUnk );
|
---|
1683 | }
|
---|
1684 |
|
---|
1685 | static HRESULT WINAPI IDirectPlayLobby3WImpl_RegisterApplication
|
---|
1686 | ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, LPDPAPPLICATIONDESC lpAppDesc )
|
---|
1687 | {
|
---|
1688 | FIXME(":stub\n");
|
---|
1689 | return DP_OK;
|
---|
1690 | }
|
---|
1691 |
|
---|
1692 | static HRESULT WINAPI IDirectPlayLobby3AImpl_RegisterApplication
|
---|
1693 | ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, LPDPAPPLICATIONDESC lpAppDesc )
|
---|
1694 | {
|
---|
1695 | FIXME(":stub\n");
|
---|
1696 | return DP_OK;
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 | static HRESULT WINAPI IDirectPlayLobby3WImpl_UnregisterApplication
|
---|
1700 | ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags, REFGUID lpAppDesc )
|
---|
1701 | {
|
---|
1702 | FIXME(":stub\n");
|
---|
1703 | return DP_OK;
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 | static HRESULT WINAPI IDirectPlayLobby3AImpl_UnregisterApplication
|
---|
1707 | ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags, REFGUID lpAppDesc )
|
---|
1708 | {
|
---|
1709 | FIXME(":stub\n");
|
---|
1710 | return DP_OK;
|
---|
1711 | }
|
---|
1712 |
|
---|
1713 | static HRESULT WINAPI IDirectPlayLobby3WImpl_WaitForConnectionSettings
|
---|
1714 | ( LPDIRECTPLAYLOBBY3 iface, DWORD dwFlags )
|
---|
1715 | {
|
---|
1716 | HRESULT hr = DP_OK;
|
---|
1717 | BOOL bStartWait = (dwFlags & DPLWAIT_CANCEL) ? FALSE : TRUE;
|
---|
1718 |
|
---|
1719 | TRACE( "(%p)->(0x%08lx)\n", iface, dwFlags );
|
---|
1720 |
|
---|
1721 | if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
|
---|
1722 | {
|
---|
1723 | /* FIXME: What is the correct error return code? */
|
---|
1724 | hr = DPERR_NOTLOBBIED;
|
---|
1725 | }
|
---|
1726 |
|
---|
1727 | return hr;
|
---|
1728 | }
|
---|
1729 |
|
---|
1730 | static HRESULT WINAPI IDirectPlayLobby3AImpl_WaitForConnectionSettings
|
---|
1731 | ( LPDIRECTPLAYLOBBY3A iface, DWORD dwFlags )
|
---|
1732 | {
|
---|
1733 | HRESULT hr = DP_OK;
|
---|
1734 | BOOL bStartWait = (dwFlags & DPLWAIT_CANCEL) ? FALSE : TRUE;
|
---|
1735 |
|
---|
1736 | TRACE( "(%p)->(0x%08lx)\n", iface, dwFlags );
|
---|
1737 |
|
---|
1738 | if( DPLAYX_WaitForConnectionSettings( bStartWait ) )
|
---|
1739 | {
|
---|
1740 | /* FIXME: What is the correct error return code? */
|
---|
1741 | hr = DPERR_NOTLOBBIED;
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 | return hr;
|
---|
1745 | }
|
---|
1746 |
|
---|
1747 |
|
---|
1748 | /* Virtual Table definitions for DPL{1,2,3}{A,W} */
|
---|
1749 |
|
---|
1750 | /* Direct Play Lobby 1 (ascii) Virtual Table for methods */
|
---|
1751 | /* All lobby 1 methods are exactly the same except QueryInterface */
|
---|
1752 | struct ICOM_VTABLE(IDirectPlayLobby) directPlayLobbyAVT =
|
---|
1753 | {
|
---|
1754 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1755 |
|
---|
1756 | (HRESULT(*CALLBACK)(IDirectPlayLobby*,const IID*const,LPVOID*))DPL_QueryInterface,
|
---|
1757 | (ULONG(*CALLBACK)(IDirectPlayLobby*))DPL_AddRef,
|
---|
1758 | (ULONG(*CALLBACK)(IDirectPlayLobby*))DPL_Release,
|
---|
1759 |
|
---|
1760 | IDirectPlayLobbyAImpl_Connect,
|
---|
1761 | IDirectPlayLobbyAImpl_CreateAddress,
|
---|
1762 | IDirectPlayLobbyAImpl_EnumAddress,
|
---|
1763 | IDirectPlayLobbyAImpl_EnumAddressTypes,
|
---|
1764 | IDirectPlayLobbyAImpl_EnumLocalApplications,
|
---|
1765 | IDirectPlayLobbyAImpl_GetConnectionSettings,
|
---|
1766 | IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
|
---|
1767 | IDirectPlayLobbyAImpl_RunApplication,
|
---|
1768 | IDirectPlayLobbyAImpl_SendLobbyMessage,
|
---|
1769 | IDirectPlayLobbyAImpl_SetConnectionSettings,
|
---|
1770 | IDirectPlayLobbyAImpl_SetLobbyMessageEvent
|
---|
1771 | };
|
---|
1772 |
|
---|
1773 | /* Direct Play Lobby 1 (unicode) Virtual Table for methods */
|
---|
1774 | struct ICOM_VTABLE(IDirectPlayLobby) directPlayLobbyWVT =
|
---|
1775 | {
|
---|
1776 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1777 |
|
---|
1778 | (HRESULT(*CALLBACK)(IDirectPlayLobby*,const IID*const,LPVOID*))DPL_QueryInterface,
|
---|
1779 | (ULONG(*CALLBACK)(IDirectPlayLobby*))DPL_AddRef,
|
---|
1780 | (ULONG(*CALLBACK)(IDirectPlayLobby*))DPL_Release,
|
---|
1781 |
|
---|
1782 | IDirectPlayLobbyWImpl_Connect,
|
---|
1783 | IDirectPlayLobbyWImpl_CreateAddress,
|
---|
1784 | IDirectPlayLobbyWImpl_EnumAddress,
|
---|
1785 | IDirectPlayLobbyWImpl_EnumAddressTypes,
|
---|
1786 | IDirectPlayLobbyWImpl_EnumLocalApplications,
|
---|
1787 | IDirectPlayLobbyWImpl_GetConnectionSettings,
|
---|
1788 | IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
|
---|
1789 | IDirectPlayLobbyWImpl_RunApplication,
|
---|
1790 | IDirectPlayLobbyWImpl_SendLobbyMessage,
|
---|
1791 | IDirectPlayLobbyWImpl_SetConnectionSettings,
|
---|
1792 | IDirectPlayLobbyWImpl_SetLobbyMessageEvent
|
---|
1793 | };
|
---|
1794 |
|
---|
1795 | # define XCAST(fun) (void*)
|
---|
1796 |
|
---|
1797 | /* Direct Play Lobby 2 (ascii) Virtual Table for methods */
|
---|
1798 | struct ICOM_VTABLE(IDirectPlayLobby2) directPlayLobby2AVT =
|
---|
1799 | {
|
---|
1800 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1801 |
|
---|
1802 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,const IID*const,LPVOID*))DPL_QueryInterface,
|
---|
1803 | (ULONG(*CALLBACK)(IDirectPlayLobby2*))DPL_AddRef,
|
---|
1804 | (ULONG(*CALLBACK)(IDirectPlayLobby2*))DPL_Release,
|
---|
1805 |
|
---|
1806 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,LPDIRECTPLAY2*,IUnknown*))IDirectPlayLobbyAImpl_Connect,
|
---|
1807 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,const GUID*const,const GUID*const,LPCVOID,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyAImpl_CreateAddress,
|
---|
1808 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,LPDPENUMADDRESSCALLBACK,LPCVOID,DWORD,LPVOID))IDirectPlayLobbyAImpl_EnumAddress,
|
---|
1809 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,LPDPLENUMADDRESSTYPESCALLBACK,const GUID*const,LPVOID,DWORD))IDirectPlayLobbyAImpl_EnumAddressTypes,
|
---|
1810 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,LPDPLENUMLOCALAPPLICATIONSCALLBACK,LPVOID,DWORD))IDirectPlayLobbyAImpl_EnumLocalApplications,
|
---|
1811 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyAImpl_GetConnectionSettings,
|
---|
1812 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,LPDWORD,LPVOID,LPDWORD))IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
|
---|
1813 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,LPDWORD,LPDPLCONNECTION,HANDLE))IDirectPlayLobbyAImpl_RunApplication,
|
---|
1814 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,LPVOID,DWORD))IDirectPlayLobbyAImpl_SendLobbyMessage,
|
---|
1815 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,LPDPLCONNECTION))IDirectPlayLobbyAImpl_SetConnectionSettings,
|
---|
1816 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,HANDLE))IDirectPlayLobbyAImpl_SetLobbyMessageEvent,
|
---|
1817 |
|
---|
1818 | IDirectPlayLobby2AImpl_CreateCompoundAddress
|
---|
1819 | };
|
---|
1820 |
|
---|
1821 | /* Direct Play Lobby 2 (unicode) Virtual Table for methods */
|
---|
1822 | struct ICOM_VTABLE(IDirectPlayLobby2) directPlayLobby2WVT =
|
---|
1823 | {
|
---|
1824 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1825 |
|
---|
1826 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,const IID*const,LPVOID*))DPL_QueryInterface,
|
---|
1827 | (ULONG(*CALLBACK)(IDirectPlayLobby2*))DPL_AddRef,
|
---|
1828 | (ULONG(*CALLBACK)(IDirectPlayLobby2*))DPL_Release,
|
---|
1829 |
|
---|
1830 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,LPDIRECTPLAY2*,IUnknown*))IDirectPlayLobbyWImpl_Connect,
|
---|
1831 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,const GUID*const,const GUID*const,LPCVOID,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyWImpl_CreateAddress,
|
---|
1832 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,LPDPENUMADDRESSCALLBACK,LPCVOID,DWORD,LPVOID))IDirectPlayLobbyWImpl_EnumAddress,
|
---|
1833 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,LPDPLENUMADDRESSTYPESCALLBACK,const GUID*const,LPVOID,DWORD))IDirectPlayLobbyWImpl_EnumAddressTypes,
|
---|
1834 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,LPDPLENUMLOCALAPPLICATIONSCALLBACK,LPVOID,DWORD))IDirectPlayLobbyWImpl_EnumLocalApplications,
|
---|
1835 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyWImpl_GetConnectionSettings,
|
---|
1836 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,LPDWORD,LPVOID,LPDWORD))IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
|
---|
1837 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,LPDWORD,LPDPLCONNECTION,HANDLE))IDirectPlayLobbyWImpl_RunApplication,
|
---|
1838 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,LPVOID,DWORD))IDirectPlayLobbyWImpl_SendLobbyMessage,
|
---|
1839 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,LPDPLCONNECTION))IDirectPlayLobbyWImpl_SetConnectionSettings,
|
---|
1840 | (HRESULT(*CALLBACK)(IDirectPlayLobby2*,DWORD,DWORD,HANDLE))IDirectPlayLobbyWImpl_SetLobbyMessageEvent,
|
---|
1841 |
|
---|
1842 | IDirectPlayLobby2WImpl_CreateCompoundAddress
|
---|
1843 | };
|
---|
1844 |
|
---|
1845 | struct ICOM_VTABLE(IDirectPlayLobby3) directPlayLobby3AVT =
|
---|
1846 | {
|
---|
1847 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1848 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,const IID*const,LPVOID*))DPL_QueryInterface,
|
---|
1849 | (ULONG(*CALLBACK)(IDirectPlayLobby3*))DPL_AddRef,
|
---|
1850 | (ULONG(*CALLBACK)(IDirectPlayLobby3*))DPL_Release,
|
---|
1851 |
|
---|
1852 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,LPDIRECTPLAY2*,IUnknown*))IDirectPlayLobbyAImpl_Connect,
|
---|
1853 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,const GUID*const,const GUID*const,LPCVOID,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyAImpl_CreateAddress,
|
---|
1854 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPDPENUMADDRESSCALLBACK,LPCVOID,DWORD,LPVOID))IDirectPlayLobbyAImpl_EnumAddress,
|
---|
1855 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPDPLENUMADDRESSTYPESCALLBACK,const GUID*const,LPVOID,DWORD))IDirectPlayLobbyAImpl_EnumAddressTypes,
|
---|
1856 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPDPLENUMLOCALAPPLICATIONSCALLBACK,LPVOID,DWORD))IDirectPlayLobbyAImpl_EnumLocalApplications,
|
---|
1857 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyAImpl_GetConnectionSettings,
|
---|
1858 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,LPDWORD,LPVOID,LPDWORD))IDirectPlayLobbyAImpl_ReceiveLobbyMessage,
|
---|
1859 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,LPDWORD,LPDPLCONNECTION,HANDLE))IDirectPlayLobbyAImpl_RunApplication,
|
---|
1860 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,LPVOID,DWORD))IDirectPlayLobbyAImpl_SendLobbyMessage,
|
---|
1861 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,LPDPLCONNECTION))IDirectPlayLobbyAImpl_SetConnectionSettings,
|
---|
1862 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,HANDLE))IDirectPlayLobbyAImpl_SetLobbyMessageEvent,
|
---|
1863 |
|
---|
1864 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPCDPCOMPOUNDADDRESSELEMENT,DWORD,LPVOID,LPDWORD))IDirectPlayLobby2AImpl_CreateCompoundAddress,
|
---|
1865 |
|
---|
1866 | IDirectPlayLobby3AImpl_ConnectEx,
|
---|
1867 | IDirectPlayLobby3AImpl_RegisterApplication,
|
---|
1868 | IDirectPlayLobby3AImpl_UnregisterApplication,
|
---|
1869 | IDirectPlayLobby3AImpl_WaitForConnectionSettings
|
---|
1870 | };
|
---|
1871 |
|
---|
1872 | /* Direct Play Lobby 3 (unicode) Virtual Table for methods */
|
---|
1873 |
|
---|
1874 | struct ICOM_VTABLE(IDirectPlayLobby3) directPlayLobby3WVT =
|
---|
1875 | {
|
---|
1876 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1877 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,const IID*const,LPVOID*))DPL_QueryInterface,
|
---|
1878 | (ULONG(*CALLBACK)(IDirectPlayLobby3*))DPL_AddRef,
|
---|
1879 | (ULONG(*CALLBACK)(IDirectPlayLobby3*))DPL_Release,
|
---|
1880 |
|
---|
1881 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,LPDIRECTPLAY2*,IUnknown*))IDirectPlayLobbyWImpl_Connect,
|
---|
1882 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,const GUID*const,const GUID*const,LPCVOID,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyWImpl_CreateAddress,
|
---|
1883 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPDPENUMADDRESSCALLBACK,LPCVOID,DWORD,LPVOID))IDirectPlayLobbyWImpl_EnumAddress,
|
---|
1884 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPDPLENUMADDRESSTYPESCALLBACK,const GUID*const,LPVOID,DWORD))IDirectPlayLobbyWImpl_EnumAddressTypes,
|
---|
1885 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPDPLENUMLOCALAPPLICATIONSCALLBACK,LPVOID,DWORD))IDirectPlayLobbyWImpl_EnumLocalApplications,
|
---|
1886 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,LPVOID,LPDWORD))IDirectPlayLobbyWImpl_GetConnectionSettings,
|
---|
1887 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,LPDWORD,LPVOID,LPDWORD))IDirectPlayLobbyWImpl_ReceiveLobbyMessage,
|
---|
1888 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,LPDWORD,LPDPLCONNECTION,HANDLE))IDirectPlayLobbyWImpl_RunApplication,
|
---|
1889 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,LPVOID,DWORD))IDirectPlayLobbyWImpl_SendLobbyMessage,
|
---|
1890 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,LPDPLCONNECTION))IDirectPlayLobbyWImpl_SetConnectionSettings,
|
---|
1891 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,DWORD,DWORD,HANDLE))IDirectPlayLobbyWImpl_SetLobbyMessageEvent,
|
---|
1892 |
|
---|
1893 | (HRESULT(*CALLBACK)(IDirectPlayLobby3*,LPCDPCOMPOUNDADDRESSELEMENT,DWORD,LPVOID,LPDWORD))IDirectPlayLobby2WImpl_CreateCompoundAddress,
|
---|
1894 |
|
---|
1895 | IDirectPlayLobby3WImpl_ConnectEx,
|
---|
1896 | IDirectPlayLobby3WImpl_RegisterApplication,
|
---|
1897 | IDirectPlayLobby3WImpl_UnregisterApplication,
|
---|
1898 | IDirectPlayLobby3WImpl_WaitForConnectionSettings
|
---|
1899 | };
|
---|
1900 |
|
---|
1901 |
|
---|
1902 | /*********************************************************
|
---|
1903 | *
|
---|
1904 | * Direct Play Lobby Interface Implementation
|
---|
1905 | *
|
---|
1906 | *********************************************************/
|
---|
1907 |
|
---|
1908 | /***************************************************************************
|
---|
1909 | * DirectPlayLobbyCreateA (DPLAYX.4)
|
---|
1910 | *
|
---|
1911 | */
|
---|
1912 | HRESULT WINAPI DirectPlayLobbyCreateA( LPGUID lpGUIDDSP,
|
---|
1913 | LPDIRECTPLAYLOBBYA *lplpDPL,
|
---|
1914 | IUnknown *lpUnk,
|
---|
1915 | LPVOID lpData,
|
---|
1916 | DWORD dwDataSize )
|
---|
1917 | {
|
---|
1918 | TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
|
---|
1919 | lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
|
---|
1920 |
|
---|
1921 | /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
|
---|
1922 | * equal 0. These fields are mostly for future expansion.
|
---|
1923 | */
|
---|
1924 | if ( lpGUIDDSP || lpData || dwDataSize )
|
---|
1925 | {
|
---|
1926 | *lplpDPL = NULL;
|
---|
1927 | return DPERR_INVALIDPARAMS;
|
---|
1928 | }
|
---|
1929 |
|
---|
1930 | if( lpUnk )
|
---|
1931 | {
|
---|
1932 | *lplpDPL = NULL;
|
---|
1933 | ERR("Bad parameters!\n" );
|
---|
1934 | return CLASS_E_NOAGGREGATION;
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | return DPL_CreateInterface( &IID_IDirectPlayLobbyA, (void**)lplpDPL );
|
---|
1938 | }
|
---|
1939 |
|
---|
1940 | /***************************************************************************
|
---|
1941 | * DirectPlayLobbyCreateW (DPLAYX.5)
|
---|
1942 | *
|
---|
1943 | */
|
---|
1944 | HRESULT WINAPI DirectPlayLobbyCreateW( LPGUID lpGUIDDSP,
|
---|
1945 | LPDIRECTPLAYLOBBY *lplpDPL,
|
---|
1946 | IUnknown *lpUnk,
|
---|
1947 | LPVOID lpData,
|
---|
1948 | DWORD dwDataSize )
|
---|
1949 | {
|
---|
1950 | TRACE("lpGUIDDSP=%p lplpDPL=%p lpUnk=%p lpData=%p dwDataSize=%08lx\n",
|
---|
1951 | lpGUIDDSP,lplpDPL,lpUnk,lpData,dwDataSize);
|
---|
1952 |
|
---|
1953 | /* Parameter Check: lpGUIDSP, lpUnk & lpData must be NULL. dwDataSize must
|
---|
1954 | * equal 0. These fields are mostly for future expansion.
|
---|
1955 | */
|
---|
1956 | if ( lpGUIDDSP || lpData || dwDataSize )
|
---|
1957 | {
|
---|
1958 | *lplpDPL = NULL;
|
---|
1959 | ERR("Bad parameters!\n" );
|
---|
1960 | return DPERR_INVALIDPARAMS;
|
---|
1961 | }
|
---|
1962 |
|
---|
1963 | if( lpUnk )
|
---|
1964 | {
|
---|
1965 | *lplpDPL = NULL;
|
---|
1966 | ERR("Bad parameters!\n" );
|
---|
1967 | return CLASS_E_NOAGGREGATION;
|
---|
1968 | }
|
---|
1969 |
|
---|
1970 | return DPL_CreateInterface( &IID_IDirectPlayLobby, (void**)lplpDPL );
|
---|
1971 | }
|
---|