devenum: Use separate factories for CLSID_SystemDeviceEnum and CLSID_CDeviceMoniker.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-06-26 09:05:30 -05:00 committed by Alexandre Julliard
parent b371cc5130
commit 47921c19e0
1 changed files with 24 additions and 22 deletions

View File

@ -56,6 +56,17 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
return TRUE;
}
struct class_factory
{
IClassFactory IClassFactory_iface;
IUnknown *obj;
};
static inline struct class_factory *impl_from_IClassFactory( IClassFactory *iface )
{
return CONTAINING_RECORD( iface, struct class_factory, IClassFactory_iface );
}
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID iid, void **obj)
{
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(iid), obj);
@ -87,24 +98,15 @@ static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
IUnknown *outer, REFIID iid, void **obj)
{
struct class_factory *This = impl_from_IClassFactory( iface );
TRACE("(%p, %s, %p)\n", outer, debugstr_guid(iid), obj);
if (!obj) return E_POINTER;
if (outer) return CLASS_E_NOAGGREGATION;
if (IsEqualGUID(&IID_ICreateDevEnum, iid))
{
*obj = &DEVENUM_CreateDevEnum;
return S_OK;
}
if (IsEqualGUID(&IID_IParseDisplayName, iid))
{
*obj = &DEVENUM_ParseDisplayName;
return S_OK;
}
return CLASS_E_CLASSNOTAVAILABLE;
return IUnknown_QueryInterface(This->obj, iid, obj);
}
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock)
@ -124,24 +126,24 @@ static const IClassFactoryVtbl ClassFactory_vtbl = {
ClassFactory_LockServer
};
static IClassFactory devenum_cf = { &ClassFactory_vtbl };
static struct class_factory create_devenum_cf = { { &ClassFactory_vtbl }, (IUnknown *)&DEVENUM_CreateDevEnum };
static struct class_factory device_moniker_cf = { { &ClassFactory_vtbl }, (IUnknown *)&DEVENUM_ParseDisplayName };
/***********************************************************************
* DllGetClassObject (DEVENUM.@)
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **obj)
{
TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
*ppv = NULL;
*obj = NULL;
/* FIXME: we should really have two class factories.
* Oh well - works just fine as it is */
if (IsEqualGUID(rclsid, &CLSID_SystemDeviceEnum) ||
IsEqualGUID(rclsid, &CLSID_CDeviceMoniker))
return IClassFactory_QueryInterface(&devenum_cf, iid, ppv);
if (IsEqualGUID(clsid, &CLSID_SystemDeviceEnum))
return IClassFactory_QueryInterface(&create_devenum_cf.IClassFactory_iface, iid, obj);
else if (IsEqualGUID(clsid, &CLSID_CDeviceMoniker))
return IClassFactory_QueryInterface(&device_moniker_cf.IClassFactory_iface, iid, obj);
FIXME("CLSID: %s, IID: %s\n", debugstr_guid(rclsid), debugstr_guid(iid));
FIXME("class %s not available\n", debugstr_guid(clsid));
return CLASS_E_CLASSNOTAVAILABLE;
}