Path: blob/master/dlls/combase/tests/wine.combase.test.c
4395 views
/*1* Copyright 2022 Rémi Bernon for CodeWeavers2*3* This library is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* This library is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with this library; if not, write to the Free Software15* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA16*/1718#if 019#pragma makedep testdll20#endif2122#include <stdarg.h>23#include <stddef.h>2425#define COBJMACROS26#include "windef.h"27#include "winbase.h"2829#include "initguid.h"30#include "inspectable.h"31#include "roapi.h"32#include "winstring.h"3334#include "wine/debug.h"3536WINE_DEFAULT_DEBUG_CHANNEL(combase);3738struct factory39{40IActivationFactory IActivationFactory_iface;41LONG ref;42BOOL trusted;43};4445static inline struct factory *impl_from_IActivationFactory(IActivationFactory *iface)46{47return CONTAINING_RECORD(iface, struct factory, IActivationFactory_iface);48}4950static HRESULT WINAPI factory_QueryInterface(IActivationFactory *iface, REFIID iid, void **out)51{52struct factory *impl = impl_from_IActivationFactory(iface);5354TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);5556if (IsEqualGUID(iid, &IID_IUnknown)57|| IsEqualGUID(iid, &IID_IInspectable)58|| IsEqualGUID(iid, &IID_IAgileObject)59|| IsEqualGUID(iid, &IID_IActivationFactory))60{61IInspectable_AddRef((*out = &impl->IActivationFactory_iface));62return S_OK;63}6465FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));66*out = NULL;67return E_NOINTERFACE;68}6970static ULONG WINAPI factory_AddRef(IActivationFactory *iface)71{72struct factory *impl = impl_from_IActivationFactory(iface);73ULONG ref = InterlockedIncrement(&impl->ref);74TRACE("iface %p increasing refcount to %lu.\n", iface, ref);75return ref;76}7778static ULONG WINAPI factory_Release(IActivationFactory *iface)79{80struct factory *impl = impl_from_IActivationFactory(iface);81ULONG ref = InterlockedDecrement(&impl->ref);82TRACE("iface %p decreasing refcount to %lu.\n", iface, ref);83return ref;84}8586static HRESULT WINAPI factory_GetIids(IActivationFactory *iface, ULONG *iid_count, IID **iids)87{88FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);89return E_NOTIMPL;90}9192static HRESULT WINAPI factory_GetRuntimeClassName(IActivationFactory *iface, HSTRING *class_name)93{94FIXME("iface %p, class_name %p stub!\n", iface, class_name);95return E_NOTIMPL;96}9798static HRESULT WINAPI factory_GetTrustLevel(IActivationFactory *iface, TrustLevel *trust_level)99{100struct factory *impl = impl_from_IActivationFactory(iface);101102TRACE("iface %p, trust_level %p.\n", iface, trust_level);103104if (!impl->trusted) return E_NOTIMPL;105106*trust_level = BaseTrust;107return S_OK;108}109110static HRESULT WINAPI factory_ActivateInstance(IActivationFactory *iface, IInspectable **instance)111{112FIXME("iface %p, instance %p stub!\n", iface, instance);113return E_NOTIMPL;114}115116static const struct IActivationFactoryVtbl factory_vtbl =117{118factory_QueryInterface,119factory_AddRef,120factory_Release,121/* IInspectable methods */122factory_GetIids,123factory_GetRuntimeClassName,124factory_GetTrustLevel,125/* IActivationFactory methods */126factory_ActivateInstance,127};128129static struct factory class_factory = {{&factory_vtbl}, 0};130static struct factory trusted_factory = {{&factory_vtbl}, 0, TRUE};131132HRESULT WINAPI DllCanUnloadNow(void)133{134return S_OK;135}136137HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory)138{139const WCHAR *buffer = WindowsGetStringRawBuffer(classid, NULL);140141TRACE("class %s, factory %p.\n", debugstr_w(buffer), factory);142143if (!wcscmp(buffer, L"Wine.Test.Class"))144{145IActivationFactory_AddRef((*factory = &class_factory.IActivationFactory_iface));146return S_OK;147}148if (!wcscmp(buffer, L"Wine.Test.Trusted"))149{150IActivationFactory_AddRef((*factory = &trusted_factory.IActivationFactory_iface));151return S_OK;152}153154return REGDB_E_CLASSNOTREG;155}156157HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out)158{159FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out);160return CLASS_E_CLASSNOTAVAILABLE;161}162163164