1 /* Internet TCP/IP and IPX Connection For DirectPlay
3 * Copyright 2008 Ismael Barros Barros
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "dpwsockx_dll.h"
28 #include "wine/debug.h"
30 #include "wine/dplaysp.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
37 TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 /* TODO: Initialization */
45 DisableThreadLibraryCalls(hinstDLL);
53 static HRESULT WINAPI DPWSCB_EnumSessions( LPDPSP_ENUMSESSIONSDATA data )
55 FIXME( "(%p,%d,%p,%u) stub\n",
56 data->lpMessage, data->dwMessageSize,
57 data->lpISP, data->bReturnStatus );
58 return DPERR_UNSUPPORTED;
61 static HRESULT WINAPI DPWSCB_Reply( LPDPSP_REPLYDATA data )
63 FIXME( "(%p,%p,%d,%d,%p) stub\n",
64 data->lpSPMessageHeader, data->lpMessage, data->dwMessageSize,
65 data->idNameServer, data->lpISP );
66 return DPERR_UNSUPPORTED;
69 static HRESULT WINAPI DPWSCB_Send( LPDPSP_SENDDATA data )
71 FIXME( "(0x%08x,%d,%d,%p,%d,%u,%p) stub\n",
72 data->dwFlags, data->idPlayerTo, data->idPlayerFrom,
73 data->lpMessage, data->dwMessageSize,
74 data->bSystemMessage, data->lpISP );
75 return DPERR_UNSUPPORTED;
78 static HRESULT WINAPI DPWSCB_CreatePlayer( LPDPSP_CREATEPLAYERDATA data )
80 FIXME( "(%d,0x%08x,%p,%p) stub\n",
81 data->idPlayer, data->dwFlags,
82 data->lpSPMessageHeader, data->lpISP );
83 return DPERR_UNSUPPORTED;
86 static HRESULT WINAPI DPWSCB_DeletePlayer( LPDPSP_DELETEPLAYERDATA data )
88 FIXME( "(%d,0x%08x,%p) stub\n",
89 data->idPlayer, data->dwFlags, data->lpISP );
90 return DPERR_UNSUPPORTED;
93 static HRESULT WINAPI DPWSCB_GetAddress( LPDPSP_GETADDRESSDATA data )
95 FIXME( "(%d,0x%08x,%p,%p,%p) stub\n",
96 data->idPlayer, data->dwFlags, data->lpAddress,
97 data->lpdwAddressSize, data->lpISP );
98 return DPERR_UNSUPPORTED;
101 static HRESULT WINAPI DPWSCB_GetCaps( LPDPSP_GETCAPSDATA data )
103 FIXME( "(%d,%p,0x%08x,%p)\n",
104 data->idPlayer, data->lpCaps, data->dwFlags, data->lpISP );
105 return DPERR_UNSUPPORTED;
108 static HRESULT WINAPI DPWSCB_Open( LPDPSP_OPENDATA data )
110 FIXME( "(%u,%p,%p,%u,0x%08x,0x%08x) stub\n",
111 data->bCreate, data->lpSPMessageHeader, data->lpISP,
112 data->bReturnStatus, data->dwOpenFlags, data->dwSessionFlags );
113 return DPERR_UNSUPPORTED;
116 static HRESULT WINAPI DPWSCB_CloseEx( LPDPSP_CLOSEDATA data )
118 FIXME( "(%p) stub\n", data->lpISP );
119 return DPERR_UNSUPPORTED;
122 static HRESULT WINAPI DPWSCB_ShutdownEx( LPDPSP_SHUTDOWNDATA data )
124 FIXME( "(%p) stub\n", data->lpISP );
125 return DPERR_UNSUPPORTED;
128 static HRESULT WINAPI DPWSCB_GetAddressChoices( LPDPSP_GETADDRESSCHOICESDATA data )
130 FIXME( "(%p,%p,%p) stub\n",
131 data->lpAddress, data->lpdwAddressSize, data->lpISP );
132 return DPERR_UNSUPPORTED;
135 static HRESULT WINAPI DPWSCB_SendEx( LPDPSP_SENDEXDATA data )
137 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p,%u) stub\n",
138 data->lpISP, data->dwFlags, data->idPlayerTo, data->idPlayerFrom,
139 data->lpSendBuffers, data->cBuffers, data->dwMessageSize,
140 data->dwPriority, data->dwTimeout, data->lpDPContext,
141 data->lpdwSPMsgID, data->bSystemMessage );
142 return DPERR_UNSUPPORTED;
145 static HRESULT WINAPI DPWSCB_SendToGroupEx( LPDPSP_SENDTOGROUPEXDATA data )
147 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p) stub\n",
148 data->lpISP, data->dwFlags, data->idGroupTo, data->idPlayerFrom,
149 data->lpSendBuffers, data->cBuffers, data->dwMessageSize,
150 data->dwPriority, data->dwTimeout, data->lpDPContext,
152 return DPERR_UNSUPPORTED;
155 static HRESULT WINAPI DPWSCB_Cancel( LPDPSP_CANCELDATA data )
157 FIXME( "(%p,0x%08x,%p,%d,0x%08x,0x%08x) stub\n",
158 data->lpISP, data->dwFlags, data->lprglpvSPMsgID, data->cSPMsgID,
159 data->dwMinPriority, data->dwMaxPriority );
160 return DPERR_UNSUPPORTED;
163 static HRESULT WINAPI DPWSCB_GetMessageQueue( LPDPSP_GETMESSAGEQUEUEDATA data )
165 FIXME( "(%p,0x%08x,%d,%d,%p,%p) stub\n",
166 data->lpISP, data->dwFlags, data->idFrom, data->idTo,
167 data->lpdwNumMsgs, data->lpdwNumBytes );
168 return DPERR_UNSUPPORTED;
171 static void setup_callbacks( LPDPSP_SPCALLBACKS lpCB )
173 lpCB->EnumSessions = DPWSCB_EnumSessions;
174 lpCB->Reply = DPWSCB_Reply;
175 lpCB->Send = DPWSCB_Send;
176 lpCB->CreatePlayer = DPWSCB_CreatePlayer;
177 lpCB->DeletePlayer = DPWSCB_DeletePlayer;
178 lpCB->GetAddress = DPWSCB_GetAddress;
179 lpCB->GetCaps = DPWSCB_GetCaps;
180 lpCB->Open = DPWSCB_Open;
181 lpCB->CloseEx = DPWSCB_CloseEx;
182 lpCB->ShutdownEx = DPWSCB_ShutdownEx;
183 lpCB->GetAddressChoices = DPWSCB_GetAddressChoices;
184 lpCB->SendEx = DPWSCB_SendEx;
185 lpCB->SendToGroupEx = DPWSCB_SendToGroupEx;
186 lpCB->Cancel = DPWSCB_Cancel;
187 lpCB->GetMessageQueue = DPWSCB_GetMessageQueue;
189 lpCB->AddPlayerToGroup = NULL;
191 lpCB->CreateGroup = NULL;
192 lpCB->DeleteGroup = NULL;
193 lpCB->RemovePlayerFromGroup = NULL;
194 lpCB->SendToGroup = NULL;
195 lpCB->Shutdown = NULL;
200 /******************************************************************
201 * SPInit (DPWSOCKX.1)
203 HRESULT WINAPI SPInit( LPSPINITDATA lpspData )
208 TRACE( "Initializing library for %s (%s)\n",
209 wine_dbgstr_guid(lpspData->lpGuid), debugstr_w(lpspData->lpszName) );
211 /* We only support TCP/IP service */
212 if ( !IsEqualGUID(lpspData->lpGuid, &DPSPGUID_TCPIP) )
214 return DPERR_UNAVAILABLE;
217 /* Assign callback functions */
218 setup_callbacks( lpspData->lpCB );
220 /* Load Winsock 2.0 DLL */
221 if ( WSAStartup( MAKEWORD(2, 0), &wsaData ) != 0 )
223 ERR( "WSAStartup() failed\n" );
224 return DPERR_UNAVAILABLE;
227 /* Initialize internal data */
228 memset( &dpwsData, 0, sizeof(DPWS_DATA) );
229 dpwsData.lpISP = lpspData->lpISP;
230 IDirectPlaySP_SetSPData( lpspData->lpISP, &dpwsData, sizeof(DPWS_DATA),
233 /* dplay needs to know the size of the header */
234 lpspData->dwSPHeaderSize = sizeof(DPSP_MSG_HEADER);