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
33 #include "wine/debug.h"
36 #include "dpnet_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
40 static HINSTANCE instance
;
42 static BOOL winsock_loaded
= FALSE
;
44 static BOOL WINAPI
winsock_startup(INIT_ONCE
*once
, void *param
, void **context
)
49 res
= WSAStartup(MAKEWORD(1,1), &wsa_data
);
50 if(res
== ERROR_SUCCESS
)
51 winsock_loaded
= TRUE
;
53 ERR("WSAStartup failed: %u\n", res
);
57 void init_winsock(void)
59 static INIT_ONCE init_once
= INIT_ONCE_STATIC_INIT
;
60 InitOnceExecuteOnce(&init_once
, winsock_startup
, NULL
, NULL
);
63 /* At process attach */
64 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
66 TRACE("%p,%x,%p\n", hInstDLL
, fdwReason
, lpvReserved
);
70 case DLL_PROCESS_ATTACH
:
72 DisableThreadLibraryCalls(hInstDLL
);
75 case DLL_PROCESS_DETACH
:
76 if (lpvReserved
) break;
84 /***********************************************************************
85 * DirectPlay8Create (DPNET.@)
87 HRESULT WINAPI
DirectPlay8Create(REFGUID lpGUID
, LPVOID
*ppvInt
, LPUNKNOWN punkOuter
)
89 TRACE("(%s, %p, %p): stub\n", debugstr_guid(lpGUID
), ppvInt
, punkOuter
);
93 /*******************************************************************************
94 * DirectPlay ClassFactory
99 IClassFactory IClassFactory_iface
;
102 HRESULT (*pfnCreateInstanceFactory
)(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
);
105 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
107 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
110 static HRESULT WINAPI
DICF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
111 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
113 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
114 return E_NOINTERFACE
;
117 static ULONG WINAPI
DICF_AddRef(LPCLASSFACTORY iface
) {
118 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
119 return InterlockedIncrement(&This
->ref
);
122 static ULONG WINAPI
DICF_Release(LPCLASSFACTORY iface
) {
123 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
124 /* static class, won't be freed */
125 return InterlockedDecrement(&This
->ref
);
128 static HRESULT WINAPI
DICF_CreateInstance(LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
) {
129 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
131 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
132 return This
->pfnCreateInstanceFactory(iface
, pOuter
, riid
, ppobj
);
135 static HRESULT WINAPI
DICF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
136 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
137 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
141 static const IClassFactoryVtbl DICF_Vtbl
= {
149 static IClassFactoryImpl DPNET_CFS
[] = {
150 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Client
, DPNET_CreateDirectPlay8Client
},
151 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Server
, DPNET_CreateDirectPlay8Server
},
152 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Peer
, DPNET_CreateDirectPlay8Peer
},
153 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Address
, DPNET_CreateDirectPlay8Address
},
154 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8LobbiedApplication
, DPNET_CreateDirectPlay8LobbiedApp
},
155 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8LobbyClient
, DPNET_CreateDirectPlay8LobbyClient
},
156 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8ThreadPool
, DPNET_CreateDirectPlay8ThreadPool
},
157 { { NULL
}, 0, NULL
, NULL
}
160 /***********************************************************************
161 * DllCanUnloadNow (DPNET.@)
163 HRESULT WINAPI
DllCanUnloadNow(void)
168 /***********************************************************************
169 * DllGetClassObject (DPNET.@)
171 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
175 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
177 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
178 *ppv = (LPVOID)&DPNET_CF;
179 IClassFactory_AddRef((IClassFactory*)*ppv);
183 while (NULL
!= DPNET_CFS
[i
].rclsid
) {
184 if (IsEqualGUID(rclsid
, DPNET_CFS
[i
].rclsid
)) {
185 DICF_AddRef(&DPNET_CFS
[i
].IClassFactory_iface
);
186 *ppv
= &DPNET_CFS
[i
];
192 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
193 return CLASS_E_CLASSNOTAVAILABLE
;
196 /***********************************************************************
197 * DllRegisterServer (DPNET.@)
199 HRESULT WINAPI
DllRegisterServer(void)
201 return __wine_register_resources( instance
);
204 /***********************************************************************
205 * DllUnregisterServer (DPNET.@)
207 HRESULT WINAPI
DllUnregisterServer(void)
209 return __wine_unregister_resources( instance
);