1 /* 2 * 3 * Copyright 2009 Austin English 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 */ 19 20 #include <stdarg.h> 21 22 #define COBJMACROS 23 24 #include "windef.h" 25 #include "winbase.h" 26 #include "objbase.h" 27 #include "wbemcli.h" 28 #include "wbemprov.h" 29 #include "rpcproxy.h" 30 31 #include "wbemprox_private.h" 32 #include "wine/debug.h" 33 34 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox); 35 36 static HINSTANCE instance; 37 38 typedef HRESULT (*fnCreateInstance)( LPVOID *ppObj ); 39 40 typedef struct 41 { 42 IClassFactory IClassFactory_iface; 43 fnCreateInstance pfnCreateInstance; 44 } wbemprox_cf; 45 46 static inline wbemprox_cf *impl_from_IClassFactory( IClassFactory *iface ) 47 { 48 return CONTAINING_RECORD(iface, wbemprox_cf, IClassFactory_iface); 49 } 50 51 static HRESULT WINAPI wbemprox_cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj ) 52 { 53 if (IsEqualGUID(riid, &IID_IUnknown) || 54 IsEqualGUID(riid, &IID_IClassFactory)) 55 { 56 IClassFactory_AddRef( iface ); 57 *ppobj = iface; 58 return S_OK; 59 } 60 FIXME("interface %s not implemented\n", debugstr_guid(riid)); 61 return E_NOINTERFACE; 62 } 63 64 static ULONG WINAPI wbemprox_cf_AddRef( IClassFactory *iface ) 65 { 66 return 2; 67 } 68 69 static ULONG WINAPI wbemprox_cf_Release( IClassFactory *iface ) 70 { 71 return 1; 72 } 73 74 static HRESULT WINAPI wbemprox_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter, 75 REFIID riid, LPVOID *ppobj ) 76 { 77 wbemprox_cf *This = impl_from_IClassFactory( iface ); 78 HRESULT r; 79 IUnknown *punk; 80 81 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj); 82 83 *ppobj = NULL; 84 85 if (pOuter) 86 return CLASS_E_NOAGGREGATION; 87 88 r = This->pfnCreateInstance( (LPVOID *)&punk ); 89 if (FAILED(r)) 90 return r; 91 92 r = IUnknown_QueryInterface( punk, riid, ppobj ); 93 IUnknown_Release( punk ); 94 return r; 95 } 96 97 static HRESULT WINAPI wbemprox_cf_LockServer( IClassFactory *iface, BOOL dolock ) 98 { 99 FIXME("(%p)->(%d)\n", iface, dolock); 100 return S_OK; 101 } 102 103 static const struct IClassFactoryVtbl wbemprox_cf_vtbl = 104 { 105 wbemprox_cf_QueryInterface, 106 wbemprox_cf_AddRef, 107 wbemprox_cf_Release, 108 wbemprox_cf_CreateInstance, 109 wbemprox_cf_LockServer 110 }; 111 112 static wbemprox_cf wbem_locator_cf = { { &wbemprox_cf_vtbl }, WbemLocator_create }; 113 114 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 115 { 116 117 switch (fdwReason) 118 { 119 case DLL_PROCESS_ATTACH: 120 instance = hinstDLL; 121 DisableThreadLibraryCalls(hinstDLL); 122 init_table_list(); 123 break; 124 } 125 126 return TRUE; 127 } 128 129 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv ) 130 { 131 IClassFactory *cf = NULL; 132 133 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv); 134 135 if (IsEqualGUID( rclsid, &CLSID_WbemLocator ) || 136 IsEqualGUID( rclsid, &CLSID_WbemAdministrativeLocator )) 137 { 138 cf = &wbem_locator_cf.IClassFactory_iface; 139 } 140 if (!cf) return CLASS_E_CLASSNOTAVAILABLE; 141 return IClassFactory_QueryInterface( cf, iid, ppv ); 142 } 143 144 /*********************************************************************** 145 * DllCanUnloadNow (WBEMPROX.@) 146 */ 147 HRESULT WINAPI DllCanUnloadNow( void ) 148 { 149 return S_FALSE; 150 } 151 152 /*********************************************************************** 153 * DllRegisterServer (WBEMPROX.@) 154 */ 155 HRESULT WINAPI DllRegisterServer(void) 156 { 157 return __wine_register_resources( instance ); 158 } 159 160 /*********************************************************************** 161 * DllUnregisterServer (WBEMPROX.@) 162 */ 163 HRESULT WINAPI DllUnregisterServer(void) 164 { 165 return __wine_unregister_resources( instance ); 166 } 167