4 * Copyright 2004 Raphael Junqueira
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
34 #include "wine/debug.h"
37 #include "dpnet_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
41 static HINSTANCE instance
;
43 static BOOL winsock_loaded
= FALSE
;
45 static BOOL WINAPI
winsock_startup(INIT_ONCE
*once
, void *param
, void **context
)
50 res
= WSAStartup(MAKEWORD(1,1), &wsa_data
);
51 if(res
== ERROR_SUCCESS
)
52 winsock_loaded
= TRUE
;
54 ERR("WSAStartup failed: %u\n", res
);
58 void init_winsock(void)
60 static INIT_ONCE init_once
= INIT_ONCE_STATIC_INIT
;
61 InitOnceExecuteOnce(&init_once
, winsock_startup
, NULL
, NULL
);
64 /* At process attach */
65 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
67 TRACE("%p,%x,%p\n", hInstDLL
, fdwReason
, lpvReserved
);
71 case DLL_PROCESS_ATTACH
:
73 DisableThreadLibraryCalls(hInstDLL
);
76 case DLL_PROCESS_DETACH
:
77 if (lpvReserved
) break;
85 /***********************************************************************
86 * DirectPlay8Create (DPNET.@)
88 HRESULT WINAPI
DirectPlay8Create(REFGUID lpGUID
, LPVOID
*ppvInt
, LPUNKNOWN punkOuter
)
90 TRACE("(%s, %p, %p): stub\n", debugstr_guid(lpGUID
), ppvInt
, punkOuter
);
94 /*******************************************************************************
95 * DirectPlay ClassFactory
100 IClassFactory IClassFactory_iface
;
103 HRESULT (*pfnCreateInstanceFactory
)(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
);
106 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
108 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
111 static HRESULT WINAPI
DICF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
112 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
114 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
115 return E_NOINTERFACE
;
118 static ULONG WINAPI
DICF_AddRef(LPCLASSFACTORY iface
) {
119 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
120 return InterlockedIncrement(&This
->ref
);
123 static ULONG WINAPI
DICF_Release(LPCLASSFACTORY iface
) {
124 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
125 /* static class, won't be freed */
126 return InterlockedDecrement(&This
->ref
);
129 static HRESULT WINAPI
DICF_CreateInstance(LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
) {
130 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
132 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
133 return This
->pfnCreateInstanceFactory(iface
, pOuter
, riid
, ppobj
);
136 static HRESULT WINAPI
DICF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
137 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
138 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
142 static const IClassFactoryVtbl DICF_Vtbl
= {
150 static IClassFactoryImpl DPNET_CFS
[] = {
151 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Client
, DPNET_CreateDirectPlay8Client
},
152 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Server
, DPNET_CreateDirectPlay8Server
},
153 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Peer
, DPNET_CreateDirectPlay8Peer
},
154 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Address
, DPNET_CreateDirectPlay8Address
},
155 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8LobbiedApplication
, DPNET_CreateDirectPlay8LobbiedApp
},
156 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8LobbyClient
, DPNET_CreateDirectPlay8LobbyClient
},
157 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8ThreadPool
, DPNET_CreateDirectPlay8ThreadPool
},
158 { { NULL
}, 0, NULL
, NULL
}
161 /***********************************************************************
162 * DllCanUnloadNow (DPNET.@)
164 HRESULT WINAPI
DllCanUnloadNow(void)
169 /***********************************************************************
170 * DllGetClassObject (DPNET.@)
172 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
176 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
178 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
179 *ppv = (LPVOID)&DPNET_CF;
180 IClassFactory_AddRef((IClassFactory*)*ppv);
184 while (NULL
!= DPNET_CFS
[i
].rclsid
) {
185 if (IsEqualGUID(rclsid
, DPNET_CFS
[i
].rclsid
)) {
186 DICF_AddRef(&DPNET_CFS
[i
].IClassFactory_iface
);
187 *ppv
= &DPNET_CFS
[i
];
193 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
194 return CLASS_E_CLASSNOTAVAILABLE
;
197 /***********************************************************************
198 * DllRegisterServer (DPNET.@)
200 HRESULT WINAPI
DllRegisterServer(void)
202 return __wine_register_resources( instance
);
205 /***********************************************************************
206 * DllUnregisterServer (DPNET.@)
208 HRESULT WINAPI
DllUnregisterServer(void)
210 return __wine_unregister_resources( instance
);