winejoystick: Fix a crash on accessing a CFArray past its end due to an off-by-one...
[wine/multimedia.git] / dlls / netprofm / main.c
blob9808dee083646c22822407cd4484c48ad26ac5ea
1 /*
2 * Copyright 2014 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #define COBJMACROS
24 #include "objbase.h"
25 #include "rpcproxy.h"
26 #include "netlistmgr.h"
28 #include "wine/debug.h"
29 #include "netprofm_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(netprofm);
33 static HINSTANCE instance;
35 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
37 switch (reason)
39 case DLL_WINE_PREATTACH:
40 return FALSE; /* prefer native version */
41 case DLL_PROCESS_ATTACH:
42 instance = hinst;
43 DisableThreadLibraryCalls( hinst );
44 break;
46 return TRUE;
49 struct netprofm_cf
51 IClassFactory IClassFactory_iface;
52 HRESULT (*create_instance)(void **);
55 static inline struct netprofm_cf *impl_from_IClassFactory( IClassFactory *iface )
57 return CONTAINING_RECORD( iface, struct netprofm_cf, IClassFactory_iface );
60 static HRESULT WINAPI netprofm_cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
62 if (IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IClassFactory ))
64 IClassFactory_AddRef( iface );
65 *ppobj = iface;
66 return S_OK;
68 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
69 return E_NOINTERFACE;
72 static ULONG WINAPI netprofm_cf_AddRef( IClassFactory *iface )
74 return 2;
77 static ULONG WINAPI netprofm_cf_Release( IClassFactory *iface )
79 return 1;
82 static HRESULT WINAPI netprofm_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN outer,
83 REFIID riid, LPVOID *obj )
85 struct netprofm_cf *factory = impl_from_IClassFactory( iface );
86 IUnknown *unk;
87 HRESULT r;
89 TRACE( "%p %s %p\n", outer, debugstr_guid(riid), obj );
91 *obj = NULL;
92 if (outer) return CLASS_E_NOAGGREGATION;
94 r = factory->create_instance( (void **)&unk );
95 if (FAILED( r ))
96 return r;
98 r = IUnknown_QueryInterface( unk, riid, obj );
99 IUnknown_Release( unk );
100 return r;
103 static HRESULT WINAPI netprofm_cf_LockServer( IClassFactory *iface, BOOL dolock )
105 FIXME( "%p, %d\n", iface, dolock );
106 return S_OK;
109 static const struct IClassFactoryVtbl netprofm_cf_vtbl =
111 netprofm_cf_QueryInterface,
112 netprofm_cf_AddRef,
113 netprofm_cf_Release,
114 netprofm_cf_CreateInstance,
115 netprofm_cf_LockServer
118 static struct netprofm_cf list_manager_cf = { { &netprofm_cf_vtbl }, list_manager_create };
120 /***********************************************************************
121 * DllGetClassObject (NETPROFM.@)
123 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
125 IClassFactory *cf = NULL;
127 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
129 if (IsEqualGUID( rclsid, &CLSID_NetworkListManager ))
131 cf = &list_manager_cf.IClassFactory_iface;
133 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
134 return IClassFactory_QueryInterface( cf, iid, ppv );
137 /***********************************************************************
138 * DllCanUnloadNow (NETPROFM.@)
140 HRESULT WINAPI DllCanUnloadNow( void )
142 return S_FALSE;
145 /***********************************************************************
146 * DllRegisterServer (NETPROFM.@)
148 HRESULT WINAPI DllRegisterServer( void )
150 return __wine_register_resources( instance );
153 /***********************************************************************
154 * DllUnregisterServer (NETPROFM.@)
156 HRESULT WINAPI DllUnregisterServer( void )
158 return __wine_unregister_resources( instance );