1 /* This contains the implementation of the interface Service
2 * Providers require to communicate with Direct Play
4 * Copyright 2000 Peter Hunnisett
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/debug.h"
27 #include "dplay_global.h"
28 #include "name_server.h"
29 #include "dplayx_messages.h"
31 #include "dplayx_global.h" /* FIXME: For global hack */
33 /* FIXME: Need to add interface locking inside procedures */
35 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
38 static BOOL DPSP_CreateIUnknown( LPVOID lpSP );
39 static BOOL DPSP_DestroyIUnknown( LPVOID lpSP );
40 static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp );
41 static BOOL DPSP_DestroyDirectPlaySP( LPVOID lpSP );
43 /* Predefine the interface */
44 typedef struct IDirectPlaySPImpl IDirectPlaySPImpl;
46 typedef struct tagDirectPlaySPIUnknownData
49 CRITICAL_SECTION DPSP_lock;
50 } DirectPlaySPIUnknownData;
52 typedef struct tagDirectPlaySPData
54 LPVOID lpSpRemoteData;
55 DWORD dwSpRemoteDataSize; /* Size of data pointed to by lpSpRemoteData */
58 DWORD dwSpLocalDataSize; /* Size of data pointed to by lpSpLocalData */
60 IDirectPlay2Impl* dplay; /* FIXME: This should perhaps be iface not impl */
64 #define DPSP_IMPL_FIELDS \
65 LONG ulInterfaceRef; \
66 DirectPlaySPIUnknownData* unk; \
69 struct IDirectPlaySPImpl
71 const IDirectPlaySPVtbl *lpVtbl;
75 /* Forward declaration of virtual tables */
76 static const IDirectPlaySPVtbl directPlaySPVT;
78 /* This structure is passed to the DP object for safe keeping */
79 typedef struct tagDP_SPPLAYERDATA
81 LPVOID lpPlayerLocalData;
82 DWORD dwPlayerLocalDataSize;
84 LPVOID lpPlayerRemoteData;
85 DWORD dwPlayerRemoteDataSize;
86 } DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA;
88 /* Create the SP interface */
90 HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp )
92 TRACE( " for %s\n", debugstr_guid( riid ) );
94 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
95 sizeof( IDirectPlaySPImpl ) );
99 return DPERR_OUTOFMEMORY;
102 if( IsEqualGUID( &IID_IDirectPlaySP, riid ) )
104 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)*ppvObj;
105 This->lpVtbl = &directPlaySPVT;
109 /* Unsupported interface */
110 HeapFree( GetProcessHeap(), 0, *ppvObj );
113 return E_NOINTERFACE;
117 if( DPSP_CreateIUnknown( *ppvObj ) &&
118 DPSP_CreateDirectPlaySP( *ppvObj, dp )
121 IDirectPlaySP_AddRef( (LPDIRECTPLAYSP)*ppvObj );
125 /* Initialize failed, destroy it */
126 DPSP_DestroyDirectPlaySP( *ppvObj );
127 DPSP_DestroyIUnknown( *ppvObj );
129 HeapFree( GetProcessHeap(), 0, *ppvObj );
132 return DPERR_NOMEMORY;
135 static BOOL DPSP_CreateIUnknown( LPVOID lpSP )
137 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
139 This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
141 if ( This->unk == NULL )
146 InitializeCriticalSection( &This->unk->DPSP_lock );
151 static BOOL DPSP_DestroyIUnknown( LPVOID lpSP )
153 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
155 DeleteCriticalSection( &This->unk->DPSP_lock );
156 HeapFree( GetProcessHeap(), 0, This->unk );
162 static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp )
164 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
166 This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) );
168 if ( This->sp == NULL )
173 This->sp->dplay = dp;
175 /* Normally we should be keeping a reference, but since only the dplay
176 * interface that created us can destroy us, we do not keep a reference
177 * to it (ie we'd be stuck with always having one reference to the dplay
178 * object, and hence us, around).
179 * NOTE: The dp object does reference count us.
181 * FIXME: This is a kludge to get around a problem where a queryinterface
182 * is used to get a new interface and then is closed. We will then
183 * reference garbage. However, with this we will never deallocate
184 * the interface we store. The correct fix is to require all
185 * DP internal interfaces to use the This->dp2 interface which
186 * should be changed to This->dp
188 IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp );
193 static BOOL DPSP_DestroyDirectPlaySP( LPVOID lpSP )
195 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)lpSP;
197 /* Normally we should be keeping a reference, but since only the dplay
198 * interface that created us can destroy us, we do not keep a reference
199 * to it (ie we'd be stuck with always having one reference to the dplay
200 * object, and hence us, around).
201 * NOTE: The dp object does reference count us.
203 /*IDirectPlayX_Release( (LPDIRECTPLAY2)This->sp->dplay ); */
205 HeapFree( GetProcessHeap(), 0, This->sp->lpSpRemoteData );
206 HeapFree( GetProcessHeap(), 0, This->sp->lpSpLocalData );
208 /* FIXME: Need to delete player queue */
210 HeapFree( GetProcessHeap(), 0, This->sp );
214 /* Interface implementation */
216 static HRESULT WINAPI DPSP_QueryInterface
217 ( LPDIRECTPLAYSP iface,
221 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
222 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj );
224 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
227 if( *ppvObj == NULL )
229 return DPERR_OUTOFMEMORY;
232 CopyMemory( *ppvObj, This, sizeof( *This ) );
233 (*(IDirectPlaySPImpl**)ppvObj)->ulInterfaceRef = 0;
235 if( IsEqualGUID( &IID_IDirectPlaySP, riid ) )
237 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)*ppvObj;
238 This->lpVtbl = &directPlaySPVT;
242 /* Unsupported interface */
243 HeapFree( GetProcessHeap(), 0, *ppvObj );
246 return E_NOINTERFACE;
249 IDirectPlaySP_AddRef( (LPDIRECTPLAYSP)*ppvObj );
254 static ULONG WINAPI DPSP_AddRef
255 ( LPDIRECTPLAYSP iface )
257 ULONG ulInterfaceRefCount, ulObjRefCount;
258 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
260 ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
261 ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
263 TRACE( "ref count incremented to %u:%u for %p\n",
264 ulInterfaceRefCount, ulObjRefCount, This );
266 return ulObjRefCount;
269 static ULONG WINAPI DPSP_Release
270 ( LPDIRECTPLAYSP iface )
272 ULONG ulInterfaceRefCount, ulObjRefCount;
273 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
275 ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
276 ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
278 TRACE( "ref count decremented to %u:%u for %p\n",
279 ulInterfaceRefCount, ulObjRefCount, This );
281 /* Deallocate if this is the last reference to the object */
282 if( ulObjRefCount == 0 )
284 DPSP_DestroyDirectPlaySP( This );
285 DPSP_DestroyIUnknown( This );
288 if( ulInterfaceRefCount == 0 )
290 HeapFree( GetProcessHeap(), 0, This );
293 return ulInterfaceRefCount;
296 static HRESULT WINAPI IDirectPlaySPImpl_AddMRUEntry
297 ( LPDIRECTPLAYSP iface,
305 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
307 /* Should be able to call the comctl32 undocumented MRU routines.
308 I suspect that the interface works appropriately */
309 FIXME( "(%p)->(%p,%p%p,0x%08x,0x%08x): stub\n",
310 This, lpSection, lpKey, lpData, dwDataSize, dwMaxEntries );
315 static HRESULT WINAPI IDirectPlaySPImpl_CreateAddress
316 ( LPDIRECTPLAYSP iface,
318 REFGUID guidDataType,
322 LPDWORD lpdwAddressSize
325 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
327 FIXME( "(%p)->(%s,%s,%p,0x%08x,%p,%p): stub\n",
328 This, debugstr_guid(guidSP), debugstr_guid(guidDataType),
329 lpData, dwDataSize, lpAddress, lpdwAddressSize );
334 static HRESULT WINAPI IDirectPlaySPImpl_EnumAddress
335 ( LPDIRECTPLAYSP iface,
336 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
342 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
344 TRACE( "(%p)->(%p,%p,0x%08x,%p)\n",
345 This, lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
347 DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
352 static HRESULT WINAPI IDirectPlaySPImpl_EnumMRUEntries
353 ( LPDIRECTPLAYSP iface,
356 LPENUMMRUCALLBACK lpEnumMRUCallback,
360 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
362 /* Should be able to call the comctl32 undocumented MRU routines.
363 I suspect that the interface works appropriately */
364 FIXME( "(%p)->(%p,%p,%p,%p,): stub\n",
365 This, lpSection, lpKey, lpEnumMRUCallback, lpContext );
370 static HRESULT WINAPI IDirectPlaySPImpl_GetPlayerFlags
371 ( LPDIRECTPLAYSP iface,
373 LPDWORD lpdwPlayerFlags
376 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
378 FIXME( "(%p)->(0x%08x,%p): stub\n",
379 This, idPlayer, lpdwPlayerFlags );
384 static HRESULT WINAPI IDirectPlaySPImpl_GetSPPlayerData
385 ( LPDIRECTPLAYSP iface,
388 LPDWORD lpdwDataSize,
393 LPDP_SPPLAYERDATA lpPlayerData;
394 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
396 TRACE( "(%p)->(0x%08x,%p,%p,0x%08x)\n",
397 This, idPlayer, lplpData, lpdwDataSize, dwFlags );
399 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerData );
403 TRACE( "Couldn't get player data: %s\n", DPLAYX_HresultToString(hr) );
404 return DPERR_INVALIDPLAYER;
407 /* What to do in the case where there is nothing set yet? */
408 if( dwFlags == DPSET_LOCAL )
410 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerLocalData );
411 *lplpData = lpPlayerData->lpPlayerLocalData;
412 *lpdwDataSize = lpPlayerData->dwPlayerLocalDataSize;
414 else if( dwFlags == DPSET_REMOTE )
416 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerRemoteData );
417 *lplpData = lpPlayerData->lpPlayerRemoteData;
418 *lpdwDataSize = lpPlayerData->dwPlayerRemoteDataSize;
421 if( *lplpData == NULL )
429 static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
430 ( LPDIRECTPLAYSP iface,
431 LPVOID lpMessageBody,
432 DWORD dwMessageBodySize,
433 LPVOID lpMessageHeader
436 LPDPMSG_SENDENVELOPE lpMsg = (LPDPMSG_SENDENVELOPE)lpMessageBody;
437 HRESULT hr = DPERR_GENERIC;
442 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
444 FIXME( "(%p)->(%p,0x%08x,%p): mostly stub\n",
445 This, lpMessageBody, dwMessageBodySize, lpMessageHeader );
447 wCommandId = lpMsg->wCommandId;
448 wVersion = lpMsg->wVersion;
450 TRACE( "Incoming message has envelope of 0x%08x, %u, %u\n",
451 lpMsg->dwMagic, wCommandId, wVersion );
453 if( lpMsg->dwMagic != DPMSGMAGIC_DPLAYMSG )
455 ERR( "Unknown magic 0x%08x!\n", lpMsg->dwMagic );
456 return DPERR_GENERIC;
461 const LPDWORD lpcHeader = (LPDWORD)lpMessageHeader;
463 TRACE( "lpMessageHeader = [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx]\n",
464 lpcHeader[0], lpcHeader[1], lpcHeader[2], lpcHeader[3], lpcHeader[4] );
468 /* Pass everything else to Direct Play */
469 data.lpMessage = NULL;
470 data.dwMessageSize = 0;
472 /* Pass this message to the dplay interface to handle */
473 hr = DP_HandleMessage( This->sp->dplay, lpMessageBody, dwMessageBodySize,
474 lpMessageHeader, wCommandId, wVersion,
475 &data.lpMessage, &data.dwMessageSize );
479 ERR( "Command processing failed %s\n", DPLAYX_HresultToString(hr) );
482 /* Do we want a reply? */
483 if( data.lpMessage != NULL )
485 data.lpSPMessageHeader = lpMessageHeader;
486 data.idNameServer = 0;
489 hr = (This->sp->dplay->dp2->spData.lpCB->Reply)( &data );
493 ERR( "Reply failed %s\n", DPLAYX_HresultToString(hr) );
501 HANDLE hReceiveEvent = 0;
502 /* FIXME: Acquire some sort of interface lock */
503 /* FIXME: Need some sort of context for this callback. Need to determine
504 * how this is actually done with the SP
506 /* FIXME: Who needs to delete the message when done? */
507 switch( lpMsg->dwType )
509 case DPSYS_CREATEPLAYERORGROUP:
511 LPDPMSG_CREATEPLAYERORGROUP msg = (LPDPMSG_CREATEPLAYERORGROUP)lpMsg;
513 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
515 hr = DP_IF_CreatePlayer( This, lpMessageHeader, msg->dpId,
516 &msg->dpnName, 0, msg->lpData,
517 msg->dwDataSize, msg->dwFlags, ... );
519 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
521 /* Group in group situation? */
522 if( msg->dpIdParent == DPID_NOPARENT_GROUP )
524 hr = DP_IF_CreateGroup( This, lpMessageHeader, msg->dpId,
525 &msg->dpnName, 0, msg->lpData,
526 msg->dwDataSize, msg->dwFlags, ... );
528 else /* Group in Group */
530 hr = DP_IF_CreateGroupInGroup( This, lpMessageHeader, msg->dpIdParent,
531 &msg->dpnName, 0, msg->lpData,
532 msg->dwDataSize, msg->dwFlags, ... );
537 ERR( "Corrupt msg->dwPlayerType for DPSYS_CREATEPLAYERORGROUP\n" );
544 case DPSYS_DESTROYPLAYERORGROUP:
546 LPDPMSG_DESTROYPLAYERORGROUP msg = (LPDPMSG_DESTROYPLAYERORGROUP)lpMsg;
548 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
550 hr = DP_IF_DestroyPlayer( This, msg->dpId, ... );
552 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
554 hr = DP_IF_DestroyGroup( This, msg->dpId, ... );
558 ERR( "Corrupt msg->dwPlayerType for DPSYS_DESTROYPLAYERORGROUP\n" );
565 case DPSYS_ADDPLAYERTOGROUP:
567 LPDPMSG_ADDPLAYERTOGROUP msg = (LPDPMSG_ADDPLAYERTOGROUP)lpMsg;
569 hr = DP_IF_AddPlayerToGroup( This, msg->dpIdGroup, msg->dpIdPlayer, ... );
573 case DPSYS_DELETEPLAYERFROMGROUP:
575 LPDPMSG_DELETEPLAYERFROMGROUP msg = (LPDPMSG_DELETEPLAYERFROMGROUP)lpMsg;
577 hr = DP_IF_DeletePlayerFromGroup( This, msg->dpIdGroup, msg->dpIdPlayer,
583 case DPSYS_SESSIONLOST:
585 LPDPMSG_SESSIONLOST msg = (LPDPMSG_SESSIONLOST)lpMsg;
587 FIXME( "DPSYS_SESSIONLOST not handled\n" );
594 LPDPMSG_HOST msg = (LPDPMSG_HOST)lpMsg;
596 FIXME( "DPSYS_HOST not handled\n" );
601 case DPSYS_SETPLAYERORGROUPDATA:
603 LPDPMSG_SETPLAYERORGROUPDATA msg = (LPDPMSG_SETPLAYERORGROUPDATA)lpMsg;
605 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
607 hr = DP_IF_SetPlayerData( This, msg->dpId, msg->lpData, msg->dwDataSize, DPSET_REMOTE, ... );
609 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
611 hr = DP_IF_SetGroupData( This, msg->dpId, msg->lpData, msg->dwDataSize,
616 ERR( "Corrupt msg->dwPlayerType for LPDPMSG_SETPLAYERORGROUPDATA\n" );
623 case DPSYS_SETPLAYERORGROUPNAME:
625 LPDPMSG_SETPLAYERORGROUPNAME msg = (LPDPMSG_SETPLAYERORGROUPNAME)lpMsg;
627 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
629 hr = DP_IF_SetPlayerName( This, msg->dpId, msg->dpnName, ... );
631 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
633 hr = DP_IF_SetGroupName( This, msg->dpId, msg->dpnName, ... );
637 ERR( "Corrupt msg->dwPlayerType for LPDPMSG_SETPLAYERORGROUPDATA\n" );
644 case DPSYS_SETSESSIONDESC;
646 LPDPMSG_SETSESSIONDESC msg = (LPDPMSG_SETSESSIONDESC)lpMsg;
648 hr = DP_IF_SetSessionDesc( This, &msg->dpDesc );
653 case DPSYS_ADDGROUPTOGROUP:
655 LPDPMSG_ADDGROUPTOGROUP msg = (LPDPMSG_ADDGROUPTOGROUP)lpMsg;
657 hr = DP_IF_AddGroupToGroup( This, msg->dpIdParentGroup, msg->dpIdGroup,
663 case DPSYS_DELETEGROUPFROMGROUP:
665 LPDPMSG_DELETEGROUPFROMGROUP msg = (LPDPMSG_DELETEGROUPFROMGROUP)lpMsg;
667 hr = DP_IF_DeleteGroupFromGroup( This, msg->dpIdParentGroup,
668 msg->dpIdGroup, ... );
673 case DPSYS_SECUREMESSAGE:
675 LPDPMSG_SECUREMESSAGE msg = (LPDPMSG_SECUREMESSAGE)lpMsg;
677 FIXME( "DPSYS_SECUREMESSAGE not implemented\n" );
682 case DPSYS_STARTSESSION:
684 LPDPMSG_STARTSESSION msg = (LPDPMSG_STARTSESSION)lpMsg;
686 FIXME( "DPSYS_STARTSESSION not implemented\n" );
693 LPDPMSG_CHAT msg = (LPDPMSG_CHAT)lpMsg;
695 FIXME( "DPSYS_CHAT not implemeneted\n" );
700 case DPSYS_SETGROUPOWNER:
702 LPDPMSG_SETGROUPOWNER msg = (LPDPMSG_SETGROUPOWNER)lpMsg;
704 FIXME( "DPSYS_SETGROUPOWNER not implemented\n" );
709 case DPSYS_SENDCOMPLETE:
711 LPDPMSG_SENDCOMPLETE msg = (LPDPMSG_SENDCOMPLETE)lpMsg;
713 FIXME( "DPSYS_SENDCOMPLETE not implemented\n" );
720 /* NOTE: This should be a user defined type. There is nothing that we
721 * need to do with it except queue it.
723 TRACE( "Received user message type(?) 0x%08lx through SP.\n",
729 FIXME( "Queue message in the receive queue. Need some context data!\n" );
733 ERR( "Unable to perform action for msg type 0x%08lx\n", lpMsg->dwType );
735 /* If a receive event was registered for this player, invoke it */
738 SetEvent( hReceiveEvent );
743 static HRESULT WINAPI IDirectPlaySPImpl_SetSPPlayerData
744 ( LPDIRECTPLAYSP iface,
752 LPDP_SPPLAYERDATA lpPlayerEntry;
755 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
757 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
758 TRACE( "(%p)->(0x%08x,%p,0x%08x,0x%08x)\n",
759 This, idPlayer, lpData, dwDataSize, dwFlags );
761 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerEntry );
764 /* Player must not exist */
765 return DPERR_INVALIDPLAYER;
768 lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize );
769 CopyMemory( lpPlayerData, lpData, dwDataSize );
771 if( dwFlags == DPSET_LOCAL )
773 lpPlayerEntry->lpPlayerLocalData = lpPlayerData;
774 lpPlayerEntry->dwPlayerLocalDataSize = dwDataSize;
776 else if( dwFlags == DPSET_REMOTE )
778 lpPlayerEntry->lpPlayerRemoteData = lpPlayerData;
779 lpPlayerEntry->dwPlayerRemoteDataSize = dwDataSize;
782 hr = DP_SetSPPlayerData( This->sp->dplay, idPlayer, lpPlayerEntry );
787 static HRESULT WINAPI IDirectPlaySPImpl_CreateCompoundAddress
788 ( LPDIRECTPLAYSP iface,
789 LPCDPCOMPOUNDADDRESSELEMENT lpElements,
790 DWORD dwElementCount,
792 LPDWORD lpdwAddressSize
795 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
797 FIXME( "(%p)->(%p,0x%08x,%p,%p): stub\n",
798 This, lpElements, dwElementCount, lpAddress, lpdwAddressSize );
803 static HRESULT WINAPI IDirectPlaySPImpl_GetSPData
804 ( LPDIRECTPLAYSP iface,
806 LPDWORD lpdwDataSize,
811 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
813 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
814 TRACE( "(%p)->(%p,%p,0x%08x)\n",
815 This, lplpData, lpdwDataSize, dwFlags );
818 /* This is what the documentation says... */
819 if( dwFlags != DPSET_REMOTE )
821 return DPERR_INVALIDPARAMS;
824 /* ... but most service providers call this with 1 */
825 /* Guess that this is using a DPSET_LOCAL or DPSET_REMOTE type of
828 if( dwFlags != DPSET_REMOTE )
830 TRACE( "Undocumented dwFlags 0x%08x used\n", dwFlags );
834 /* FIXME: What to do in the case where this isn't initialized yet? */
836 /* Yes, we're supposed to return a pointer to the memory we have stored! */
837 if( dwFlags == DPSET_REMOTE )
839 *lpdwDataSize = This->sp->dwSpRemoteDataSize;
840 *lplpData = This->sp->lpSpRemoteData;
842 if( This->sp->lpSpRemoteData == NULL )
847 else if( dwFlags == DPSET_LOCAL )
849 *lpdwDataSize = This->sp->dwSpLocalDataSize;
850 *lplpData = This->sp->lpSpLocalData;
852 if( This->sp->lpSpLocalData == NULL )
861 static HRESULT WINAPI IDirectPlaySPImpl_SetSPData
862 ( LPDIRECTPLAYSP iface,
870 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
872 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
873 TRACE( "(%p)->(%p,0x%08x,0x%08x)\n",
874 This, lpData, dwDataSize, dwFlags );
877 /* This is what the documentation says... */
878 if( dwFlags != DPSET_REMOTE )
880 return DPERR_INVALIDPARAMS;
883 /* ... but most service providers call this with 1 */
884 /* Guess that this is using a DPSET_LOCAL or DPSET_REMOTE type of
887 if( dwFlags != DPSET_REMOTE )
889 TRACE( "Undocumented dwFlags 0x%08x used\n", dwFlags );
893 lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize );
894 CopyMemory( lpSpData, lpData, dwDataSize );
896 /* If we have data already allocated, free it and replace it */
897 if( dwFlags == DPSET_REMOTE )
899 HeapFree( GetProcessHeap(), 0, This->sp->lpSpRemoteData );
900 This->sp->dwSpRemoteDataSize = dwDataSize;
901 This->sp->lpSpRemoteData = lpSpData;
903 else if ( dwFlags == DPSET_LOCAL )
905 HeapFree( GetProcessHeap(), 0, This->sp->lpSpLocalData );
906 This->sp->lpSpLocalData = lpSpData;
907 This->sp->dwSpLocalDataSize = dwDataSize;
913 static VOID WINAPI IDirectPlaySPImpl_SendComplete
914 ( LPDIRECTPLAYSP iface,
919 IDirectPlaySPImpl *This = (IDirectPlaySPImpl *)iface;
921 FIXME( "(%p)->(%p,0x%08x): stub\n",
922 This, unknownA, unknownB );
925 static const IDirectPlaySPVtbl directPlaySPVT =
932 IDirectPlaySPImpl_AddMRUEntry,
933 IDirectPlaySPImpl_CreateAddress,
934 IDirectPlaySPImpl_EnumAddress,
935 IDirectPlaySPImpl_EnumMRUEntries,
936 IDirectPlaySPImpl_GetPlayerFlags,
937 IDirectPlaySPImpl_GetSPPlayerData,
938 IDirectPlaySPImpl_HandleMessage,
939 IDirectPlaySPImpl_SetSPPlayerData,
940 IDirectPlaySPImpl_CreateCompoundAddress,
941 IDirectPlaySPImpl_GetSPData,
942 IDirectPlaySPImpl_SetSPData,
943 IDirectPlaySPImpl_SendComplete
947 /* DP external interfaces to call into DPSP interface */
949 /* Allocate the structure */
950 extern LPVOID DPSP_CreateSPPlayerData(void)
952 TRACE( "Creating SPPlayer data struct\n" );
953 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
954 sizeof( DP_SPPLAYERDATA ) );