Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/combase/tests/wine.combase.test.c
4395 views
1
/*
2
* Copyright 2022 Rémi Bernon for CodeWeavers
3
*
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.
8
*
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.
13
*
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
17
*/
18
19
#if 0
20
#pragma makedep testdll
21
#endif
22
23
#include <stdarg.h>
24
#include <stddef.h>
25
26
#define COBJMACROS
27
#include "windef.h"
28
#include "winbase.h"
29
30
#include "initguid.h"
31
#include "inspectable.h"
32
#include "roapi.h"
33
#include "winstring.h"
34
35
#include "wine/debug.h"
36
37
WINE_DEFAULT_DEBUG_CHANNEL(combase);
38
39
struct factory
40
{
41
IActivationFactory IActivationFactory_iface;
42
LONG ref;
43
BOOL trusted;
44
};
45
46
static inline struct factory *impl_from_IActivationFactory(IActivationFactory *iface)
47
{
48
return CONTAINING_RECORD(iface, struct factory, IActivationFactory_iface);
49
}
50
51
static HRESULT WINAPI factory_QueryInterface(IActivationFactory *iface, REFIID iid, void **out)
52
{
53
struct factory *impl = impl_from_IActivationFactory(iface);
54
55
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
56
57
if (IsEqualGUID(iid, &IID_IUnknown)
58
|| IsEqualGUID(iid, &IID_IInspectable)
59
|| IsEqualGUID(iid, &IID_IAgileObject)
60
|| IsEqualGUID(iid, &IID_IActivationFactory))
61
{
62
IInspectable_AddRef((*out = &impl->IActivationFactory_iface));
63
return S_OK;
64
}
65
66
FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
67
*out = NULL;
68
return E_NOINTERFACE;
69
}
70
71
static ULONG WINAPI factory_AddRef(IActivationFactory *iface)
72
{
73
struct factory *impl = impl_from_IActivationFactory(iface);
74
ULONG ref = InterlockedIncrement(&impl->ref);
75
TRACE("iface %p increasing refcount to %lu.\n", iface, ref);
76
return ref;
77
}
78
79
static ULONG WINAPI factory_Release(IActivationFactory *iface)
80
{
81
struct factory *impl = impl_from_IActivationFactory(iface);
82
ULONG ref = InterlockedDecrement(&impl->ref);
83
TRACE("iface %p decreasing refcount to %lu.\n", iface, ref);
84
return ref;
85
}
86
87
static HRESULT WINAPI factory_GetIids(IActivationFactory *iface, ULONG *iid_count, IID **iids)
88
{
89
FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
90
return E_NOTIMPL;
91
}
92
93
static HRESULT WINAPI factory_GetRuntimeClassName(IActivationFactory *iface, HSTRING *class_name)
94
{
95
FIXME("iface %p, class_name %p stub!\n", iface, class_name);
96
return E_NOTIMPL;
97
}
98
99
static HRESULT WINAPI factory_GetTrustLevel(IActivationFactory *iface, TrustLevel *trust_level)
100
{
101
struct factory *impl = impl_from_IActivationFactory(iface);
102
103
TRACE("iface %p, trust_level %p.\n", iface, trust_level);
104
105
if (!impl->trusted) return E_NOTIMPL;
106
107
*trust_level = BaseTrust;
108
return S_OK;
109
}
110
111
static HRESULT WINAPI factory_ActivateInstance(IActivationFactory *iface, IInspectable **instance)
112
{
113
FIXME("iface %p, instance %p stub!\n", iface, instance);
114
return E_NOTIMPL;
115
}
116
117
static const struct IActivationFactoryVtbl factory_vtbl =
118
{
119
factory_QueryInterface,
120
factory_AddRef,
121
factory_Release,
122
/* IInspectable methods */
123
factory_GetIids,
124
factory_GetRuntimeClassName,
125
factory_GetTrustLevel,
126
/* IActivationFactory methods */
127
factory_ActivateInstance,
128
};
129
130
static struct factory class_factory = {{&factory_vtbl}, 0};
131
static struct factory trusted_factory = {{&factory_vtbl}, 0, TRUE};
132
133
HRESULT WINAPI DllCanUnloadNow(void)
134
{
135
return S_OK;
136
}
137
138
HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory)
139
{
140
const WCHAR *buffer = WindowsGetStringRawBuffer(classid, NULL);
141
142
TRACE("class %s, factory %p.\n", debugstr_w(buffer), factory);
143
144
if (!wcscmp(buffer, L"Wine.Test.Class"))
145
{
146
IActivationFactory_AddRef((*factory = &class_factory.IActivationFactory_iface));
147
return S_OK;
148
}
149
if (!wcscmp(buffer, L"Wine.Test.Trusted"))
150
{
151
IActivationFactory_AddRef((*factory = &trusted_factory.IActivationFactory_iface));
152
return S_OK;
153
}
154
155
return REGDB_E_CLASSNOTREG;
156
}
157
158
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out)
159
{
160
FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out);
161
return CLASS_E_CLASSNOTAVAILABLE;
162
}
163
164