2 * Copyright 2013 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
31 #include "wine/debug.h"
32 #include "wbemdisp_private.h"
33 #include "wbemdisp_classes.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
37 static HINSTANCE instance
;
39 static HRESULT WINAPI
WinMGMTS_QueryInterface(IParseDisplayName
*iface
, REFIID riid
, void **ppv
)
41 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
42 TRACE("(IID_IUnknown %p)\n", ppv
);
44 }else if(IsEqualGUID(riid
, &IID_IParseDisplayName
)) {
45 TRACE("(IID_IParseDisplayName %p)\n", ppv
);
48 WARN("Unsupported riid %s\n", debugstr_guid(riid
));
53 IUnknown_AddRef((IUnknown
*)*ppv
);
57 static ULONG WINAPI
WinMGMTS_AddRef(IParseDisplayName
*iface
)
62 static ULONG WINAPI
WinMGMTS_Release(IParseDisplayName
*iface
)
67 static HRESULT WINAPI
WinMGMTS_ParseDisplayName(IParseDisplayName
*iface
, IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
68 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
70 FIXME("(%p %s %p %p)\n", pbc
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
74 static const IParseDisplayNameVtbl WinMGMTSVtbl
= {
75 WinMGMTS_QueryInterface
,
78 WinMGMTS_ParseDisplayName
81 static IParseDisplayName winmgmts
= { &WinMGMTSVtbl
};
83 static HRESULT
WinMGMTS_create(void **ppv
)
91 IClassFactory IClassFactory_iface
;
92 HRESULT (*fnCreateInstance
)( LPVOID
* );
95 static inline struct factory
*impl_from_IClassFactory( IClassFactory
*iface
)
97 return CONTAINING_RECORD( iface
, struct factory
, IClassFactory_iface
);
100 static HRESULT WINAPI
factory_QueryInterface( IClassFactory
*iface
, REFIID riid
, LPVOID
*obj
)
102 if (IsEqualGUID( riid
, &IID_IUnknown
) || IsEqualGUID( riid
, &IID_IClassFactory
))
104 IClassFactory_AddRef( iface
);
108 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
109 return E_NOINTERFACE
;
112 static ULONG WINAPI
factory_AddRef( IClassFactory
*iface
)
117 static ULONG WINAPI
factory_Release( IClassFactory
*iface
)
122 static HRESULT WINAPI
factory_CreateInstance( IClassFactory
*iface
, LPUNKNOWN outer
, REFIID riid
,
125 struct factory
*factory
= impl_from_IClassFactory( iface
);
129 TRACE( "%p, %s, %p\n", outer
, debugstr_guid(riid
), obj
);
132 if (outer
) return CLASS_E_NOAGGREGATION
;
134 hr
= factory
->fnCreateInstance( (LPVOID
*)&unk
);
138 hr
= IUnknown_QueryInterface( unk
, riid
, obj
);
139 IUnknown_Release( unk
);
143 static HRESULT WINAPI
factory_LockServer( IClassFactory
*iface
, BOOL lock
)
145 FIXME( "%p, %d\n", iface
, lock
);
149 static const struct IClassFactoryVtbl factory_vtbl
=
151 factory_QueryInterface
,
154 factory_CreateInstance
,
158 static struct factory swbem_locator_cf
= { { &factory_vtbl
}, SWbemLocator_create
};
159 static struct factory winmgmts_cf
= { { &factory_vtbl
}, WinMGMTS_create
};
161 BOOL WINAPI
DllMain( HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
166 case DLL_WINE_PREATTACH
:
167 return FALSE
; /* prefer native version */
168 case DLL_PROCESS_ATTACH
:
170 DisableThreadLibraryCalls( hinst
);
176 HRESULT WINAPI
DllGetClassObject( REFCLSID rclsid
, REFIID iid
, LPVOID
*obj
)
178 IClassFactory
*cf
= NULL
;
180 TRACE( "%s, %s, %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), obj
);
182 if (IsEqualGUID( rclsid
, &CLSID_SWbemLocator
))
183 cf
= &swbem_locator_cf
.IClassFactory_iface
;
184 else if (IsEqualGUID( rclsid
, &CLSID_WinMGMTS
))
185 cf
= &winmgmts_cf
.IClassFactory_iface
;
187 return CLASS_E_CLASSNOTAVAILABLE
;
189 return IClassFactory_QueryInterface( cf
, iid
, obj
);
192 /***********************************************************************
193 * DllCanUnloadNow (WBEMDISP.@)
195 HRESULT WINAPI
DllCanUnloadNow(void)
200 /***********************************************************************
201 * DllRegisterServer (WBEMDISP.@)
203 HRESULT WINAPI
DllRegisterServer(void)
205 return __wine_register_resources( instance
);
208 /***********************************************************************
209 * DllUnregisterServer (WBEMDISP.@)
211 HRESULT WINAPI
DllUnregisterServer(void)
213 return __wine_unregister_resources( instance
);