2004-04-07 22:39:00 +02:00
|
|
|
/*
|
|
|
|
* DirectPlay
|
|
|
|
*
|
|
|
|
* Copyright 2004 Raphael Junqueira
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-07 22:39:00 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "objbase.h"
|
2010-12-07 13:02:38 +01:00
|
|
|
#include "oleauto.h"
|
|
|
|
#include "oleidl.h"
|
|
|
|
#include "rpcproxy.h"
|
2004-04-07 22:39:00 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2010-12-07 13:02:38 +01:00
|
|
|
#include "initguid.h"
|
2004-04-07 22:39:00 +02:00
|
|
|
#include "dpnet_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
|
|
|
|
|
2016-11-02 10:13:49 +01:00
|
|
|
static BOOL winsock_loaded = FALSE;
|
|
|
|
|
|
|
|
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **context)
|
|
|
|
{
|
|
|
|
WSADATA wsa_data;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
res = WSAStartup(MAKEWORD(1,1), &wsa_data);
|
|
|
|
if(res == ERROR_SUCCESS)
|
|
|
|
winsock_loaded = TRUE;
|
|
|
|
else
|
2022-02-02 10:40:06 +01:00
|
|
|
ERR("WSAStartup failed: %lu\n", res);
|
2016-11-02 10:13:49 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_winsock(void)
|
|
|
|
{
|
|
|
|
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
|
|
|
InitOnceExecuteOnce(&init_once, winsock_startup, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2004-04-07 22:39:00 +02:00
|
|
|
/* At process attach */
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("%p,%lx,%p\n", hInstDLL, fdwReason, lpvReserved);
|
2016-11-02 10:13:49 +01:00
|
|
|
|
|
|
|
switch(fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hInstDLL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
if (lpvReserved) break;
|
|
|
|
if(winsock_loaded)
|
|
|
|
WSACleanup();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DirectPlay8Create (DPNET.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DirectPlay8Create(REFGUID lpGUID, LPVOID *ppvInt, LPUNKNOWN punkOuter)
|
|
|
|
{
|
|
|
|
TRACE("(%s, %p, %p): stub\n", debugstr_guid(lpGUID), ppvInt, punkOuter);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* DirectPlay ClassFactory
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
2010-12-05 15:15:50 +01:00
|
|
|
IClassFactory IClassFactory_iface;
|
|
|
|
LONG ref;
|
|
|
|
REFCLSID rclsid;
|
|
|
|
HRESULT (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
|
2004-04-07 22:39:00 +02:00
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2010-12-05 15:15:50 +01:00
|
|
|
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2004-04-07 22:39:00 +02:00
|
|
|
static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
2010-12-05 15:15:50 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
|
|
|
|
2004-04-07 22:39:00 +02:00
|
|
|
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
|
2010-12-05 15:15:50 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-09-28 21:19:27 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
|
2010-12-05 15:15:50 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-04-07 22:39:00 +02:00
|
|
|
/* static class, won't be freed */
|
2004-09-28 21:19:27 +02:00
|
|
|
return InterlockedDecrement(&This->ref);
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DICF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
|
2010-12-05 15:15:50 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
|
|
|
|
2004-04-07 22:39:00 +02:00
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
return This->pfnCreateInstanceFactory(iface, pOuter, riid, ppobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
2010-12-05 15:15:50 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-04-07 22:39:00 +02:00
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IClassFactoryVtbl DICF_Vtbl = {
|
2004-04-07 22:39:00 +02:00
|
|
|
DICF_QueryInterface,
|
|
|
|
DICF_AddRef,
|
|
|
|
DICF_Release,
|
|
|
|
DICF_CreateInstance,
|
|
|
|
DICF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static IClassFactoryImpl DPNET_CFS[] = {
|
2010-12-05 15:15:50 +01:00
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Client, DPNET_CreateDirectPlay8Client },
|
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Server, DPNET_CreateDirectPlay8Server },
|
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Peer, DPNET_CreateDirectPlay8Peer },
|
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Address, DPNET_CreateDirectPlay8Address },
|
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8LobbiedApplication, DPNET_CreateDirectPlay8LobbiedApp },
|
2014-05-12 07:19:03 +02:00
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8LobbyClient, DPNET_CreateDirectPlay8LobbyClient },
|
2010-12-05 15:15:50 +01:00
|
|
|
{ { &DICF_Vtbl }, 1, &CLSID_DirectPlay8ThreadPool, DPNET_CreateDirectPlay8ThreadPool},
|
|
|
|
{ { NULL }, 0, NULL, NULL }
|
2004-04-07 22:39:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (DPNET.@)
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
2004-04-07 22:39:00 +02:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2012-03-21 23:35:02 +01:00
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
2004-04-07 22:39:00 +02:00
|
|
|
/*
|
|
|
|
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
|
|
|
|
*ppv = (LPVOID)&DPNET_CF;
|
|
|
|
IClassFactory_AddRef((IClassFactory*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
while (NULL != DPNET_CFS[i].rclsid) {
|
|
|
|
if (IsEqualGUID(rclsid, DPNET_CFS[i].rclsid)) {
|
2010-12-05 15:15:50 +01:00
|
|
|
DICF_AddRef(&DPNET_CFS[i].IClassFactory_iface);
|
2004-04-07 22:39:00 +02:00
|
|
|
*ppv = &DPNET_CFS[i];
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2012-03-21 23:35:02 +01:00
|
|
|
FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
2004-04-07 22:39:00 +02:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|