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 BOOL winsock_loaded
= FALSE
;
42 static BOOL WINAPI
winsock_startup(INIT_ONCE
*once
, void *param
, void **context
)
47 res
= WSAStartup(MAKEWORD(1,1), &wsa_data
);
48 if(res
== ERROR_SUCCESS
)
49 winsock_loaded
= TRUE
;
51 ERR("WSAStartup failed: %lu\n", res
);
55 void init_winsock(void)
57 static INIT_ONCE init_once
= INIT_ONCE_STATIC_INIT
;
58 InitOnceExecuteOnce(&init_once
, winsock_startup
, NULL
, NULL
);
61 /* At process attach */
62 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
64 TRACE("%p,%lx,%p\n", hInstDLL
, fdwReason
, lpvReserved
);
68 case DLL_PROCESS_ATTACH
:
69 DisableThreadLibraryCalls(hInstDLL
);
72 case DLL_PROCESS_DETACH
:
73 if (lpvReserved
) break;
81 /***********************************************************************
82 * DirectPlay8Create (DPNET.@)
84 HRESULT WINAPI
DirectPlay8Create(REFGUID lpGUID
, LPVOID
*ppvInt
, LPUNKNOWN punkOuter
)
86 TRACE("(%s, %p, %p): stub\n", debugstr_guid(lpGUID
), ppvInt
, punkOuter
);
90 /*******************************************************************************
91 * DirectPlay ClassFactory
96 IClassFactory IClassFactory_iface
;
99 HRESULT (*pfnCreateInstanceFactory
)(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
);
102 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
104 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
107 static HRESULT WINAPI
DICF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
108 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
110 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
111 return E_NOINTERFACE
;
114 static ULONG WINAPI
DICF_AddRef(LPCLASSFACTORY iface
) {
115 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
116 return InterlockedIncrement(&This
->ref
);
119 static ULONG WINAPI
DICF_Release(LPCLASSFACTORY iface
) {
120 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
121 /* static class, won't be freed */
122 return InterlockedDecrement(&This
->ref
);
125 static HRESULT WINAPI
DICF_CreateInstance(LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
) {
126 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
128 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
129 return This
->pfnCreateInstanceFactory(iface
, pOuter
, riid
, ppobj
);
132 static HRESULT WINAPI
DICF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
133 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
134 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
138 static const IClassFactoryVtbl DICF_Vtbl
= {
146 static IClassFactoryImpl DPNET_CFS
[] = {
147 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Client
, DPNET_CreateDirectPlay8Client
},
148 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Server
, DPNET_CreateDirectPlay8Server
},
149 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Peer
, DPNET_CreateDirectPlay8Peer
},
150 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8Address
, DPNET_CreateDirectPlay8Address
},
151 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8LobbiedApplication
, DPNET_CreateDirectPlay8LobbiedApp
},
152 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8LobbyClient
, DPNET_CreateDirectPlay8LobbyClient
},
153 { { &DICF_Vtbl
}, 1, &CLSID_DirectPlay8ThreadPool
, DPNET_CreateDirectPlay8ThreadPool
},
154 { { NULL
}, 0, NULL
, NULL
}
157 /***********************************************************************
158 * DllGetClassObject (DPNET.@)
160 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
164 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
166 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
167 *ppv = (LPVOID)&DPNET_CF;
168 IClassFactory_AddRef((IClassFactory*)*ppv);
172 while (NULL
!= DPNET_CFS
[i
].rclsid
) {
173 if (IsEqualGUID(rclsid
, DPNET_CFS
[i
].rclsid
)) {
174 DICF_AddRef(&DPNET_CFS
[i
].IClassFactory_iface
);
175 *ppv
= &DPNET_CFS
[i
];
181 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
182 return CLASS_E_CLASSNOTAVAILABLE
;