1 /* This contains the implementation of the interface Service
2 * Providers require to communicate with Direct Play
4 * Copyright 2000 Peter Hunnisett <hunnise@nortelnetworks.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 ULONG ulInterfaceRef; \
66 DirectPlaySPIUnknownData* unk; \
69 struct IDirectPlaySPImpl
71 ICOM_VFIELD(IDirectPlaySP);
75 /* Forward declaration of virtual tables */
76 static ICOM_VTABLE(IDirectPlaySP) 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 ICOM_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 ICOM_THIS(IDirectPlaySPImpl,lpSP);
139 This->unk = (DirectPlaySPIUnknownData*)HeapAlloc( GetProcessHeap(),
141 sizeof( *(This->unk) ) );
143 if ( This->unk == NULL )
148 InitializeCriticalSection( &This->unk->DPSP_lock );
153 static BOOL DPSP_DestroyIUnknown( LPVOID lpSP )
155 ICOM_THIS(IDirectPlaySPImpl,lpSP);
157 DeleteCriticalSection( &This->unk->DPSP_lock );
158 HeapFree( GetProcessHeap(), 0, This->unk );
164 static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp )
166 ICOM_THIS(IDirectPlaySPImpl,lpSP);
168 This->sp = (DirectPlaySPData*)HeapAlloc( GetProcessHeap(),
170 sizeof( *(This->sp) ) );
172 if ( This->sp == NULL )
177 This->sp->dplay = dp;
179 /* Normally we should be keeping a reference, but since only the dplay
180 * interface that created us can destroy us, we do not keep a reference
181 * to it (ie we'd be stuck with always having one reference to the dplay
182 * object, and hence us, around).
183 * NOTE: The dp object does reference count us.
185 * FIXME: This is a kludge to get around a problem where a queryinterface
186 * is used to get a new interface and then is closed. We will then
187 * reference garbage. However, with this we will never deallocate
188 * the interface we store. The correct fix is to require all
189 * DP internal interfaces to use the This->dp2 interface which
190 * should be changed to This->dp
192 IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp );
197 static BOOL DPSP_DestroyDirectPlaySP( LPVOID lpSP )
199 ICOM_THIS(IDirectPlaySPImpl,lpSP);
201 /* Normally we should be keeping a reference, but since only the dplay
202 * interface that created us can destroy us, we do not keep a reference
203 * to it (ie we'd be stuck with always having one reference to the dplay
204 * object, and hence us, around).
205 * NOTE: The dp object does reference count us.
207 /*IDirectPlayX_Release( (LPDIRECTPLAY2)This->sp->dplay ); */
209 HeapFree( GetProcessHeap(), 0, This->sp->lpSpRemoteData );
210 HeapFree( GetProcessHeap(), 0, This->sp->lpSpLocalData );
212 /* FIXME: Need to delete player queue */
214 HeapFree( GetProcessHeap(), 0, This->sp );
218 /* Interface implementation */
220 static HRESULT WINAPI DPSP_QueryInterface
221 ( LPDIRECTPLAYSP iface,
225 ICOM_THIS(IDirectPlaySPImpl,iface);
226 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj );
228 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
231 if( *ppvObj == NULL )
233 return DPERR_OUTOFMEMORY;
236 CopyMemory( *ppvObj, This, sizeof( *This ) );
237 (*(IDirectPlaySPImpl**)ppvObj)->ulInterfaceRef = 0;
239 if( IsEqualGUID( &IID_IDirectPlaySP, riid ) )
241 ICOM_THIS(IDirectPlaySPImpl,*ppvObj);
242 This->lpVtbl = &directPlaySPVT;
246 /* Unsupported interface */
247 HeapFree( GetProcessHeap(), 0, *ppvObj );
250 return E_NOINTERFACE;
253 IDirectPlaySP_AddRef( (LPDIRECTPLAYSP)*ppvObj );
258 static ULONG WINAPI DPSP_AddRef
259 ( LPDIRECTPLAYSP iface )
261 ULONG ulInterfaceRefCount, ulObjRefCount;
262 ICOM_THIS(IDirectPlaySPImpl,iface);
264 ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef );
265 ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
267 TRACE( "ref count incremented to %lu:%lu for %p\n",
268 ulInterfaceRefCount, ulObjRefCount, This );
270 return ulObjRefCount;
273 static ULONG WINAPI DPSP_Release
274 ( LPDIRECTPLAYSP iface )
276 ULONG ulInterfaceRefCount, ulObjRefCount;
277 ICOM_THIS(IDirectPlaySPImpl,iface);
279 ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef );
280 ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
282 TRACE( "ref count decremented to %lu:%lu for %p\n",
283 ulInterfaceRefCount, ulObjRefCount, This );
285 /* Deallocate if this is the last reference to the object */
286 if( ulObjRefCount == 0 )
288 DPSP_DestroyDirectPlaySP( This );
289 DPSP_DestroyIUnknown( This );
292 if( ulInterfaceRefCount == 0 )
294 HeapFree( GetProcessHeap(), 0, This );
297 return ulInterfaceRefCount;
300 static HRESULT WINAPI IDirectPlaySPImpl_AddMRUEntry
301 ( LPDIRECTPLAYSP iface,
309 ICOM_THIS(IDirectPlaySPImpl,iface);
311 /* Should be able to call the comctl32 undocumented MRU routines.
312 I suspect that the interface works appropriately */
313 FIXME( "(%p)->(%p,%p%p,0x%08lx,0x%08lx): stub\n",
314 This, lpSection, lpKey, lpData, dwDataSize, dwMaxEntries );
319 static HRESULT WINAPI IDirectPlaySPImpl_CreateAddress
320 ( LPDIRECTPLAYSP iface,
322 REFGUID guidDataType,
326 LPDWORD lpdwAddressSize
329 ICOM_THIS(IDirectPlaySPImpl,iface);
331 FIXME( "(%p)->(%s,%s,%p,0x%08lx,%p,%p): stub\n",
332 This, debugstr_guid(guidSP), debugstr_guid(guidDataType),
333 lpData, dwDataSize, lpAddress, lpdwAddressSize );
338 static HRESULT WINAPI IDirectPlaySPImpl_EnumAddress
339 ( LPDIRECTPLAYSP iface,
340 LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
346 ICOM_THIS(IDirectPlaySPImpl,iface);
348 TRACE( "(%p)->(%p,%p,0x%08lx,%p)\n",
349 This, lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
351 DPL_EnumAddress( lpEnumAddressCallback, lpAddress, dwAddressSize, lpContext );
356 static HRESULT WINAPI IDirectPlaySPImpl_EnumMRUEntries
357 ( LPDIRECTPLAYSP iface,
360 LPENUMMRUCALLBACK lpEnumMRUCallback,
364 ICOM_THIS(IDirectPlaySPImpl,iface);
366 /* Should be able to call the comctl32 undocumented MRU routines.
367 I suspect that the interface works appropriately */
368 FIXME( "(%p)->(%p,%p,%p,%p,): stub\n",
369 This, lpSection, lpKey, lpEnumMRUCallback, lpContext );
374 static HRESULT WINAPI IDirectPlaySPImpl_GetPlayerFlags
375 ( LPDIRECTPLAYSP iface,
377 LPDWORD lpdwPlayerFlags
380 ICOM_THIS(IDirectPlaySPImpl,iface);
382 FIXME( "(%p)->(0x%08lx,%p): stub\n",
383 This, idPlayer, lpdwPlayerFlags );
388 static HRESULT WINAPI IDirectPlaySPImpl_GetSPPlayerData
389 ( LPDIRECTPLAYSP iface,
392 LPDWORD lpdwDataSize,
397 LPDP_SPPLAYERDATA lpPlayerData;
398 ICOM_THIS(IDirectPlaySPImpl,iface);
400 TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx)\n",
401 This, idPlayer, lplpData, lpdwDataSize, dwFlags );
403 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerData );
407 TRACE( "Couldn't get player data: %s\n", DPLAYX_HresultToString(hr) );
408 return DPERR_INVALIDPLAYER;
411 /* What to do in the case where there is nothing set yet? */
412 if( dwFlags == DPSET_LOCAL )
414 if( lpPlayerData->lpPlayerLocalData )
416 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerLocalData );
419 *lplpData = lpPlayerData->lpPlayerLocalData;
420 *lpdwDataSize = lpPlayerData->dwPlayerLocalDataSize;
422 else if( dwFlags == DPSET_REMOTE )
424 if( lpPlayerData->lpPlayerRemoteData )
426 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerRemoteData );
429 *lplpData = lpPlayerData->lpPlayerRemoteData;
430 *lpdwDataSize = lpPlayerData->dwPlayerRemoteDataSize;
433 if( *lplpData == NULL )
441 static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
442 ( LPDIRECTPLAYSP iface,
443 LPVOID lpMessageBody,
444 DWORD dwMessageBodySize,
445 LPVOID lpMessageHeader
448 LPDPMSG_SENDENVELOPE lpMsg = (LPDPMSG_SENDENVELOPE)lpMessageBody;
449 HRESULT hr = DPERR_GENERIC;
454 ICOM_THIS(IDirectPlaySPImpl,iface);
456 FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n",
457 This, lpMessageBody, dwMessageBodySize, lpMessageHeader );
459 wCommandId = lpMsg->wCommandId;
460 wVersion = lpMsg->wVersion;
462 TRACE( "Incomming message has envelope of 0x%08lx, %u, %u\n",
463 lpMsg->dwMagic, wCommandId, wVersion );
465 if( lpMsg->dwMagic != DPMSGMAGIC_DPLAYMSG )
467 ERR( "Unknown magic 0x%08lx!\n", lpMsg->dwMagic );
468 return DPERR_GENERIC;
473 const LPDWORD lpcHeader = (LPDWORD)lpMessageHeader;
475 TRACE( "lpMessageHeader = [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx]\n",
476 lpcHeader[0], lpcHeader[1], lpcHeader[2], lpcHeader[3], lpcHeader[4] );
480 /* Pass everything else to Direct Play */
481 data.lpMessage = NULL;
482 data.dwMessageSize = 0;
484 /* Pass this message to the dplay interface to handle */
485 hr = DP_HandleMessage( This->sp->dplay, lpMessageBody, dwMessageBodySize,
486 lpMessageHeader, wCommandId, wVersion,
487 &data.lpMessage, &data.dwMessageSize );
491 ERR( "Command processing failed %s\n", DPLAYX_HresultToString(hr) );
494 /* Do we want a reply? */
495 if( data.lpMessage != NULL )
497 data.lpSPMessageHeader = lpMessageHeader;
498 data.idNameServer = 0;
501 hr = (This->sp->dplay->dp2->spData.lpCB->Reply)( &data );
505 ERR( "Reply failed %s\n", DPLAYX_HresultToString(hr) );
513 HANDLE hReceiveEvent = 0;
514 /* FIXME: Aquire some sort of interface lock */
515 /* FIXME: Need some sort of context for this callback. Need to determine
516 * how this is actually done with the SP
518 /* FIXME: Who needs to delete the message when done? */
519 switch( lpMsg->dwType )
521 case DPSYS_CREATEPLAYERORGROUP:
523 LPDPMSG_CREATEPLAYERORGROUP msg = (LPDPMSG_CREATEPLAYERORGROUP)lpMsg;
525 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
527 hr = DP_IF_CreatePlayer( This, lpMessageHeader, msg->dpId,
528 &msg->dpnName, 0, msg->lpData,
529 msg->dwDataSize, msg->dwFlags, ... );
531 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
533 /* Group in group situation? */
534 if( msg->dpIdParent == DPID_NOPARENT_GROUP )
536 hr = DP_IF_CreateGroup( This, lpMessageHeader, msg->dpId,
537 &msg->dpnName, 0, msg->lpData,
538 msg->dwDataSize, msg->dwFlags, ... );
540 else /* Group in Group */
542 hr = DP_IF_CreateGroupInGroup( This, lpMessageHeader, msg->dpIdParent,
543 &msg->dpnName, 0, msg->lpData,
544 msg->dwDataSize, msg->dwFlags, ... );
549 ERR( "Corrupt msg->dwPlayerType for DPSYS_CREATEPLAYERORGROUP\n" );
556 case DPSYS_DESTROYPLAYERORGROUP:
558 LPDPMSG_DESTROYPLAYERORGROUP msg = (LPDPMSG_DESTROYPLAYERORGROUP)lpMsg;
560 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
562 hr = DP_IF_DestroyPlayer( This, msg->dpId, ... );
564 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
566 hr = DP_IF_DestroyGroup( This, msg->dpId, ... );
570 ERR( "Corrupt msg->dwPlayerType for DPSYS_DESTROYPLAYERORGROUP\n" );
577 case DPSYS_ADDPLAYERTOGROUP:
579 LPDPMSG_ADDPLAYERTOGROUP msg = (LPDPMSG_ADDPLAYERTOGROUP)lpMsg;
581 hr = DP_IF_AddPlayerToGroup( This, msg->dpIdGroup, msg->dpIdPlayer, ... );
585 case DPSYS_DELETEPLAYERFROMGROUP:
587 LPDPMSG_DELETEPLAYERFROMGROUP msg = (LPDPMSG_DELETEPLAYERFROMGROUP)lpMsg;
589 hr = DP_IF_DeletePlayerFromGroup( This, msg->dpIdGroup, msg->dpIdPlayer,
595 case DPSYS_SESSIONLOST:
597 LPDPMSG_SESSIONLOST msg = (LPDPMSG_SESSIONLOST)lpMsg;
599 FIXME( "DPSYS_SESSIONLOST not handled\n" );
606 LPDPMSG_HOST msg = (LPDPMSG_HOST)lpMsg;
608 FIXME( "DPSYS_HOST not handled\n" );
613 case DPSYS_SETPLAYERORGROUPDATA:
615 LPDPMSG_SETPLAYERORGROUPDATA msg = (LPDPMSG_SETPLAYERORGROUPDATA)lpMsg;
617 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
619 hr = DP_IF_SetPlayerData( This, msg->dpId, msg->lpData, msg->dwDataSize, DPSET_REMOTE, ... );
621 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
623 hr = DP_IF_SetGroupData( This, msg->dpId, msg->lpData, msg->dwDataSize,
628 ERR( "Corrupt msg->dwPlayerType for LPDPMSG_SETPLAYERORGROUPDATA\n" );
635 case DPSYS_SETPLAYERORGROUPNAME:
637 LPDPMSG_SETPLAYERORGROUPNAME msg = (LPDPMSG_SETPLAYERORGROUPNAME)lpMsg;
639 if( msg->dwPlayerType == DPPLAYERTYPE_PLAYER )
641 hr = DP_IF_SetPlayerName( This, msg->dpId, msg->dpnName, ... );
643 else if( msg->dwPlayerType == DPPLAYERTYPE_GROUP )
645 hr = DP_IF_SetGroupName( This, msg->dpId, msg->dpnName, ... );
649 ERR( "Corrupt msg->dwPlayerType for LPDPMSG_SETPLAYERORGROUPDATA\n" );
656 case DPSYS_SETSESSIONDESC;
658 LPDPMSG_SETSESSIONDESC msg = (LPDPMSG_SETSESSIONDESC)lpMsg;
660 hr = DP_IF_SetSessionDesc( This, &msg->dpDesc );
665 case DPSYS_ADDGROUPTOGROUP:
667 LPDPMSG_ADDGROUPTOGROUP msg = (LPDPMSG_ADDGROUPTOGROUP)lpMsg;
669 hr = DP_IF_AddGroupToGroup( This, msg->dpIdParentGroup, msg->dpIdGroup,
675 case DPSYS_DELETEGROUPFROMGROUP:
677 LPDPMSG_DELETEGROUPFROMGROUP msg = (LPDPMSG_DELETEGROUPFROMGROUP)lpMsg;
679 hr = DP_IF_DeleteGroupFromGroup( This, msg->dpIdParentGroup,
680 msg->dpIdGroup, ... );
685 case DPSYS_SECUREMESSAGE:
687 LPDPMSG_SECUREMESSAGE msg = (LPDPMSG_SECUREMESSAGE)lpMsg;
689 FIXME( "DPSYS_SECUREMESSAGE not implemented\n" );
694 case DPSYS_STARTSESSION:
696 LPDPMSG_STARTSESSION msg = (LPDPMSG_STARTSESSION)lpMsg;
698 FIXME( "DPSYS_STARTSESSION not implemented\n" );
705 LPDPMSG_CHAT msg = (LPDPMSG_CHAT)lpMsg;
707 FIXME( "DPSYS_CHAT not implemeneted\n" );
712 case DPSYS_SETGROUPOWNER:
714 LPDPMSG_SETGROUPOWNER msg = (LPDPMSG_SETGROUPOWNER)lpMsg;
716 FIXME( "DPSYS_SETGROUPOWNER not implemented\n" );
721 case DPSYS_SENDCOMPLETE:
723 LPDPMSG_SENDCOMPLETE msg = (LPDPMSG_SENDCOMPLETE)lpMsg;
725 FIXME( "DPSYS_SENDCOMPLETE not implemented\n" );
732 /* NOTE: This should be a user defined type. There is nothing that we
733 * need to do with it except queue it.
735 TRACE( "Received user message type(?) 0x%08lx through SP.\n",
741 FIXME( "Queue message in the receive queue. Need some context data!\n" );
745 ERR( "Unable to perform action for msg type 0x%08lx\n", lpMsg->dwType );
747 /* If a receive event was registered for this player, invoke it */
750 SetEvent( hReceiveEvent );
755 static HRESULT WINAPI IDirectPlaySPImpl_SetSPPlayerData
756 ( LPDIRECTPLAYSP iface,
764 LPDP_SPPLAYERDATA lpPlayerEntry;
767 ICOM_THIS(IDirectPlaySPImpl,iface);
769 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
770 TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx)\n",
771 This, idPlayer, lpData, dwDataSize, dwFlags );
773 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerEntry );
776 /* Player must not exist */
777 return DPERR_INVALIDPLAYER;
780 lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize );
781 CopyMemory( lpPlayerData, lpData, dwDataSize );
783 if( dwFlags == DPSET_LOCAL )
785 lpPlayerEntry->lpPlayerLocalData = lpPlayerData;
786 lpPlayerEntry->dwPlayerLocalDataSize = dwDataSize;
788 else if( dwFlags == DPSET_REMOTE )
790 lpPlayerEntry->lpPlayerRemoteData = lpPlayerData;
791 lpPlayerEntry->dwPlayerRemoteDataSize = dwDataSize;
794 hr = DP_SetSPPlayerData( This->sp->dplay, idPlayer, lpPlayerEntry );
799 static HRESULT WINAPI IDirectPlaySPImpl_CreateCompoundAddress
800 ( LPDIRECTPLAYSP iface,
801 LPCDPCOMPOUNDADDRESSELEMENT lpElements,
802 DWORD dwElementCount,
804 LPDWORD lpdwAddressSize
807 ICOM_THIS(IDirectPlaySPImpl,iface);
809 FIXME( "(%p)->(%p,0x%08lx,%p,%p): stub\n",
810 This, lpElements, dwElementCount, lpAddress, lpdwAddressSize );
815 static HRESULT WINAPI IDirectPlaySPImpl_GetSPData
816 ( LPDIRECTPLAYSP iface,
818 LPDWORD lpdwDataSize,
823 ICOM_THIS(IDirectPlaySPImpl,iface);
825 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
826 TRACE( "(%p)->(%p,%p,0x%08lx)\n",
827 This, lplpData, lpdwDataSize, dwFlags );
830 /* This is what the documentation says... */
831 if( dwFlags != DPSET_REMOTE )
833 return DPERR_INVALIDPARAMS;
836 /* ... but most service providers call this with 1 */
837 /* Guess that this is using a DPSET_LOCAL or DPSET_REMOTE type of
840 if( dwFlags != DPSET_REMOTE )
842 TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
846 /* FIXME: What to do in the case where this isn't initialized yet? */
848 /* Yes, we're supposed to return a pointer to the memory we have stored! */
849 if( dwFlags == DPSET_REMOTE )
851 *lpdwDataSize = This->sp->dwSpRemoteDataSize;
852 *lplpData = This->sp->lpSpRemoteData;
854 if( This->sp->lpSpRemoteData == NULL )
859 else if( dwFlags == DPSET_LOCAL )
861 *lpdwDataSize = This->sp->dwSpLocalDataSize;
862 *lplpData = This->sp->lpSpLocalData;
864 if( This->sp->lpSpLocalData == NULL )
873 static HRESULT WINAPI IDirectPlaySPImpl_SetSPData
874 ( LPDIRECTPLAYSP iface,
882 ICOM_THIS(IDirectPlaySPImpl,iface);
884 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
885 TRACE( "(%p)->(%p,0x%08lx,0x%08lx)\n",
886 This, lpData, dwDataSize, dwFlags );
889 /* This is what the documentation says... */
890 if( dwFlags != DPSET_REMOTE )
892 return DPERR_INVALIDPARAMS;
895 /* ... but most service providers call this with 1 */
896 /* Guess that this is using a DPSET_LOCAL or DPSET_REMOTE type of
899 if( dwFlags != DPSET_REMOTE )
901 TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
905 lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize );
906 CopyMemory( lpSpData, lpData, dwDataSize );
908 /* If we have data already allocated, free it and replace it */
909 if( dwFlags == DPSET_REMOTE )
911 if( This->sp->lpSpRemoteData )
913 HeapFree( GetProcessHeap(), 0, This->sp->lpSpRemoteData );
916 This->sp->dwSpRemoteDataSize = dwDataSize;
917 This->sp->lpSpRemoteData = lpSpData;
919 else if ( dwFlags == DPSET_LOCAL )
921 if( This->sp->lpSpLocalData )
923 HeapFree( GetProcessHeap(), 0, This->sp->lpSpLocalData );
926 This->sp->lpSpLocalData = lpSpData;
927 This->sp->dwSpLocalDataSize = dwDataSize;
933 static VOID WINAPI IDirectPlaySPImpl_SendComplete
934 ( LPDIRECTPLAYSP iface,
939 ICOM_THIS(IDirectPlaySPImpl,iface);
941 FIXME( "(%p)->(%p,0x%08lx): stub\n",
942 This, unknownA, unknownB );
946 static struct ICOM_VTABLE(IDirectPlaySP) directPlaySPVT =
948 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
954 IDirectPlaySPImpl_AddMRUEntry,
955 IDirectPlaySPImpl_CreateAddress,
956 IDirectPlaySPImpl_EnumAddress,
957 IDirectPlaySPImpl_EnumMRUEntries,
958 IDirectPlaySPImpl_GetPlayerFlags,
959 IDirectPlaySPImpl_GetSPPlayerData,
960 IDirectPlaySPImpl_HandleMessage,
961 IDirectPlaySPImpl_SetSPPlayerData,
962 IDirectPlaySPImpl_CreateCompoundAddress,
963 IDirectPlaySPImpl_GetSPData,
964 IDirectPlaySPImpl_SetSPData,
965 IDirectPlaySPImpl_SendComplete
969 /* DP external interfaces to call into DPSP interface */
971 /* Allocate the structure */
972 extern LPVOID DPSP_CreateSPPlayerData(void)
974 TRACE( "Creating SPPlayer data struct\n" );
975 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
976 sizeof( DP_SPPLAYERDATA ) );