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
26 #include "dpwsockx_dll.h"
27 #include "wine/debug.h"
29 #include "wine/dplaysp.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(dplay
);
34 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
36 TRACE("(0x%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
40 case DLL_WINE_PREATTACH
:
41 return FALSE
; /* prefer native version */
42 case DLL_PROCESS_ATTACH
:
43 /* TODO: Initialization */
44 DisableThreadLibraryCalls(hinstDLL
);
52 static HRESULT WINAPI
DPWSCB_EnumSessions( LPDPSP_ENUMSESSIONSDATA data
)
54 FIXME( "(%p,%d,%p,%u) stub\n",
55 data
->lpMessage
, data
->dwMessageSize
,
56 data
->lpISP
, data
->bReturnStatus
);
57 return DPERR_UNSUPPORTED
;
60 static HRESULT WINAPI
DPWSCB_Reply( LPDPSP_REPLYDATA data
)
62 FIXME( "(%p,%p,%d,%d,%p) stub\n",
63 data
->lpSPMessageHeader
, data
->lpMessage
, data
->dwMessageSize
,
64 data
->idNameServer
, data
->lpISP
);
65 return DPERR_UNSUPPORTED
;
68 static HRESULT WINAPI
DPWSCB_Send( LPDPSP_SENDDATA data
)
70 FIXME( "(0x%08x,%d,%d,%p,%d,%u,%p) stub\n",
71 data
->dwFlags
, data
->idPlayerTo
, data
->idPlayerFrom
,
72 data
->lpMessage
, data
->dwMessageSize
,
73 data
->bSystemMessage
, data
->lpISP
);
74 return DPERR_UNSUPPORTED
;
77 static HRESULT WINAPI
DPWSCB_CreatePlayer( LPDPSP_CREATEPLAYERDATA data
)
79 FIXME( "(%d,0x%08x,%p,%p) stub\n",
80 data
->idPlayer
, data
->dwFlags
,
81 data
->lpSPMessageHeader
, data
->lpISP
);
82 return DPERR_UNSUPPORTED
;
85 static HRESULT WINAPI
DPWSCB_DeletePlayer( LPDPSP_DELETEPLAYERDATA data
)
87 FIXME( "(%d,0x%08x,%p) stub\n",
88 data
->idPlayer
, data
->dwFlags
, data
->lpISP
);
89 return DPERR_UNSUPPORTED
;
92 static HRESULT WINAPI
DPWSCB_GetAddress( LPDPSP_GETADDRESSDATA data
)
94 FIXME( "(%d,0x%08x,%p,%p,%p) stub\n",
95 data
->idPlayer
, data
->dwFlags
, data
->lpAddress
,
96 data
->lpdwAddressSize
, data
->lpISP
);
97 return DPERR_UNSUPPORTED
;
100 static HRESULT WINAPI
DPWSCB_GetCaps( LPDPSP_GETCAPSDATA data
)
102 TRACE( "(%d,%p,0x%08x,%p)\n",
103 data
->idPlayer
, data
->lpCaps
, data
->dwFlags
, data
->lpISP
);
105 data
->lpCaps
->dwFlags
= ( DPCAPS_ASYNCSUPPORTED
|
106 DPCAPS_GUARANTEEDOPTIMIZED
|
107 DPCAPS_GUARANTEEDSUPPORTED
);
109 data
->lpCaps
->dwMaxQueueSize
= DPWS_MAXQUEUESIZE
;
110 data
->lpCaps
->dwHundredBaud
= DPWS_HUNDREDBAUD
;
111 data
->lpCaps
->dwLatency
= DPWS_LATENCY
;
112 data
->lpCaps
->dwMaxLocalPlayers
= DPWS_MAXLOCALPLAYERS
;
113 data
->lpCaps
->dwHeaderLength
= sizeof(DPSP_MSG_HEADER
);
114 data
->lpCaps
->dwTimeout
= DPWS_TIMEOUT
;
116 if ( data
->dwFlags
& DPGETCAPS_GUARANTEED
)
118 data
->lpCaps
->dwMaxBufferSize
= DPWS_GUARANTEED_MAXBUFFERSIZE
;
119 data
->lpCaps
->dwMaxPlayers
= DPWS_GUARANTEED_MAXPLAYERS
;
123 data
->lpCaps
->dwMaxBufferSize
= DPWS_MAXBUFFERSIZE
;
124 data
->lpCaps
->dwMaxPlayers
= DPWS_MAXPLAYERS
;
130 static HRESULT WINAPI
DPWSCB_Open( LPDPSP_OPENDATA data
)
132 FIXME( "(%u,%p,%p,%u,0x%08x,0x%08x) stub\n",
133 data
->bCreate
, data
->lpSPMessageHeader
, data
->lpISP
,
134 data
->bReturnStatus
, data
->dwOpenFlags
, data
->dwSessionFlags
);
135 return DPERR_UNSUPPORTED
;
138 static HRESULT WINAPI
DPWSCB_CloseEx( LPDPSP_CLOSEDATA data
)
140 FIXME( "(%p) stub\n", data
->lpISP
);
141 return DPERR_UNSUPPORTED
;
144 static HRESULT WINAPI
DPWSCB_ShutdownEx( LPDPSP_SHUTDOWNDATA data
)
146 FIXME( "(%p) stub\n", data
->lpISP
);
147 return DPERR_UNSUPPORTED
;
150 static HRESULT WINAPI
DPWSCB_GetAddressChoices( LPDPSP_GETADDRESSCHOICESDATA data
)
152 FIXME( "(%p,%p,%p) stub\n",
153 data
->lpAddress
, data
->lpdwAddressSize
, data
->lpISP
);
154 return DPERR_UNSUPPORTED
;
157 static HRESULT WINAPI
DPWSCB_SendEx( LPDPSP_SENDEXDATA data
)
159 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p,%u) stub\n",
160 data
->lpISP
, data
->dwFlags
, data
->idPlayerTo
, data
->idPlayerFrom
,
161 data
->lpSendBuffers
, data
->cBuffers
, data
->dwMessageSize
,
162 data
->dwPriority
, data
->dwTimeout
, data
->lpDPContext
,
163 data
->lpdwSPMsgID
, data
->bSystemMessage
);
164 return DPERR_UNSUPPORTED
;
167 static HRESULT WINAPI
DPWSCB_SendToGroupEx( LPDPSP_SENDTOGROUPEXDATA data
)
169 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p) stub\n",
170 data
->lpISP
, data
->dwFlags
, data
->idGroupTo
, data
->idPlayerFrom
,
171 data
->lpSendBuffers
, data
->cBuffers
, data
->dwMessageSize
,
172 data
->dwPriority
, data
->dwTimeout
, data
->lpDPContext
,
174 return DPERR_UNSUPPORTED
;
177 static HRESULT WINAPI
DPWSCB_Cancel( LPDPSP_CANCELDATA data
)
179 FIXME( "(%p,0x%08x,%p,%d,0x%08x,0x%08x) stub\n",
180 data
->lpISP
, data
->dwFlags
, data
->lprglpvSPMsgID
, data
->cSPMsgID
,
181 data
->dwMinPriority
, data
->dwMaxPriority
);
182 return DPERR_UNSUPPORTED
;
185 static HRESULT WINAPI
DPWSCB_GetMessageQueue( LPDPSP_GETMESSAGEQUEUEDATA data
)
187 FIXME( "(%p,0x%08x,%d,%d,%p,%p) stub\n",
188 data
->lpISP
, data
->dwFlags
, data
->idFrom
, data
->idTo
,
189 data
->lpdwNumMsgs
, data
->lpdwNumBytes
);
190 return DPERR_UNSUPPORTED
;
193 static void setup_callbacks( LPDPSP_SPCALLBACKS lpCB
)
195 lpCB
->EnumSessions
= DPWSCB_EnumSessions
;
196 lpCB
->Reply
= DPWSCB_Reply
;
197 lpCB
->Send
= DPWSCB_Send
;
198 lpCB
->CreatePlayer
= DPWSCB_CreatePlayer
;
199 lpCB
->DeletePlayer
= DPWSCB_DeletePlayer
;
200 lpCB
->GetAddress
= DPWSCB_GetAddress
;
201 lpCB
->GetCaps
= DPWSCB_GetCaps
;
202 lpCB
->Open
= DPWSCB_Open
;
203 lpCB
->CloseEx
= DPWSCB_CloseEx
;
204 lpCB
->ShutdownEx
= DPWSCB_ShutdownEx
;
205 lpCB
->GetAddressChoices
= DPWSCB_GetAddressChoices
;
206 lpCB
->SendEx
= DPWSCB_SendEx
;
207 lpCB
->SendToGroupEx
= DPWSCB_SendToGroupEx
;
208 lpCB
->Cancel
= DPWSCB_Cancel
;
209 lpCB
->GetMessageQueue
= DPWSCB_GetMessageQueue
;
211 lpCB
->AddPlayerToGroup
= NULL
;
213 lpCB
->CreateGroup
= NULL
;
214 lpCB
->DeleteGroup
= NULL
;
215 lpCB
->RemovePlayerFromGroup
= NULL
;
216 lpCB
->SendToGroup
= NULL
;
217 lpCB
->Shutdown
= NULL
;
222 /******************************************************************
223 * SPInit (DPWSOCKX.1)
225 HRESULT WINAPI
SPInit( LPSPINITDATA lpspData
)
230 TRACE( "Initializing library for %s (%s)\n",
231 wine_dbgstr_guid(lpspData
->lpGuid
), debugstr_w(lpspData
->lpszName
) );
233 /* We only support TCP/IP service */
234 if ( !IsEqualGUID(lpspData
->lpGuid
, &DPSPGUID_TCPIP
) )
236 return DPERR_UNAVAILABLE
;
239 /* Assign callback functions */
240 setup_callbacks( lpspData
->lpCB
);
242 /* Load Winsock 2.0 DLL */
243 if ( WSAStartup( MAKEWORD(2, 0), &wsaData
) != 0 )
245 ERR( "WSAStartup() failed\n" );
246 return DPERR_UNAVAILABLE
;
249 /* Initialize internal data */
250 memset( &dpwsData
, 0, sizeof(DPWS_DATA
) );
251 dpwsData
.lpISP
= lpspData
->lpISP
;
252 IDirectPlaySP_SetSPData( lpspData
->lpISP
, &dpwsData
, sizeof(DPWS_DATA
),
255 /* dplay needs to know the size of the header */
256 lpspData
->dwSPHeaderSize
= sizeof(DPSP_MSG_HEADER
);