[MSCOREE]
[reactos.git] / reactos / dll / win32 / mscoree / metadata.c
1 /*
2 * IMetaDataDispenserEx - dynamic creation/editing of assemblies
3 *
4 * Copyright 2010 Vincent Povirk for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "mscoree_private.h"
22
23 typedef struct MetaDataDispenser
24 {
25 IMetaDataDispenserEx IMetaDataDispenserEx_iface;
26 LONG ref;
27 } MetaDataDispenser;
28
29 static inline MetaDataDispenser *impl_from_IMetaDataDispenserEx(IMetaDataDispenserEx *iface)
30 {
31 return CONTAINING_RECORD(iface, MetaDataDispenser, IMetaDataDispenserEx_iface);
32 }
33
34 static HRESULT WINAPI MetaDataDispenser_QueryInterface(IMetaDataDispenserEx* iface,
35 REFIID riid, void **ppvObject)
36 {
37 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
38
39 if (IsEqualGUID(riid, &IID_IMetaDataDispenserEx) ||
40 IsEqualGUID(riid, &IID_IMetaDataDispenser) ||
41 IsEqualGUID(riid, &IID_IUnknown))
42 {
43 *ppvObject = iface;
44 }
45 else
46 {
47 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
48 return E_NOINTERFACE;
49 }
50
51 IMetaDataDispenserEx_AddRef( iface );
52
53 return S_OK;
54 }
55
56 static ULONG WINAPI MetaDataDispenser_AddRef(IMetaDataDispenserEx* iface)
57 {
58 MetaDataDispenser *This = impl_from_IMetaDataDispenserEx(iface);
59 ULONG ref = InterlockedIncrement(&This->ref);
60
61 TRACE("%p ref=%u\n", This, ref);
62
63 return ref;
64 }
65
66 static ULONG WINAPI MetaDataDispenser_Release(IMetaDataDispenserEx* iface)
67 {
68 MetaDataDispenser *This = impl_from_IMetaDataDispenserEx(iface);
69 ULONG ref = InterlockedDecrement(&This->ref);
70
71 TRACE("%p ref=%u\n", This, ref);
72
73 if (ref == 0)
74 {
75 HeapFree(GetProcessHeap(), 0, This);
76 }
77
78 return ref;
79 }
80
81 static HRESULT WINAPI MetaDataDispenser_DefineScope(IMetaDataDispenserEx* iface,
82 REFCLSID rclsid, DWORD dwCreateFlags, REFIID riid, IUnknown **ppIUnk)
83 {
84 FIXME("%p %s %x %s %p\n", iface, debugstr_guid(rclsid), dwCreateFlags,
85 debugstr_guid(riid), ppIUnk);
86 return E_NOTIMPL;
87 }
88
89 static HRESULT WINAPI MetaDataDispenser_OpenScope(IMetaDataDispenserEx* iface,
90 LPCWSTR szScope, DWORD dwOpenFlags, REFIID riid, IUnknown **ppIUnk)
91 {
92 FIXME("%p %s %x %s %p\n", iface, debugstr_w(szScope), dwOpenFlags,
93 debugstr_guid(riid), ppIUnk);
94 return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI MetaDataDispenser_OpenScopeOnMemory(IMetaDataDispenserEx* iface,
98 const void *pData, ULONG cbData, DWORD dwOpenFlags, REFIID riid, IUnknown **ppIUnk)
99 {
100 FIXME("%p %p %u %x %s %p\n", iface, pData, cbData, dwOpenFlags,
101 debugstr_guid(riid), ppIUnk);
102 return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI MetaDataDispenser_SetOption(IMetaDataDispenserEx* iface,
106 REFGUID optionid, const VARIANT *value)
107 {
108 FIXME("%p %s\n", iface, debugstr_guid(optionid));
109 return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI MetaDataDispenser_GetOption(IMetaDataDispenserEx* iface,
113 REFGUID optionid, VARIANT *pvalue)
114 {
115 FIXME("%p %s\n", iface, debugstr_guid(optionid));
116 return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI MetaDataDispenser_OpenScopeOnITypeInfo(IMetaDataDispenserEx* iface,
120 ITypeInfo *pITI, DWORD dwOpenFlags, REFIID riid, IUnknown **ppIUnk)
121 {
122 FIXME("%p %p %u %s %p\n", iface, pITI, dwOpenFlags, debugstr_guid(riid), ppIUnk);
123 return E_NOTIMPL;
124 }
125
126 static HRESULT WINAPI MetaDataDispenser_GetCORSystemDirectory(IMetaDataDispenserEx* iface,
127 LPWSTR szBuffer, DWORD cchBuffer, DWORD *pchBuffer)
128 {
129 FIXME("%p %p %u %p\n", iface, szBuffer, cchBuffer, pchBuffer);
130 return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI MetaDataDispenser_FindAssembly(IMetaDataDispenserEx* iface,
134 LPCWSTR szAppBase, LPCWSTR szPrivateBin, LPCWSTR szGlobalBin, LPCWSTR szAssemblyName,
135 LPWSTR szName, ULONG cchName, ULONG *pcName)
136 {
137 FIXME("%p %s %s %s %s %p %u %p\n", iface, debugstr_w(szAppBase),
138 debugstr_w(szPrivateBin), debugstr_w(szGlobalBin),
139 debugstr_w(szAssemblyName), szName, cchName, pcName);
140 return E_NOTIMPL;
141 }
142
143 static HRESULT WINAPI MetaDataDispenser_FindAssemblyModule(IMetaDataDispenserEx* iface,
144 LPCWSTR szAppBase, LPCWSTR szPrivateBin, LPCWSTR szGlobalBin, LPCWSTR szAssemblyName,
145 LPCWSTR szModuleName, LPWSTR szName, ULONG cchName, ULONG *pcName)
146 {
147 FIXME("%p %s %s %s %s %s %p %u %p\n", iface, debugstr_w(szAppBase),
148 debugstr_w(szPrivateBin), debugstr_w(szGlobalBin), debugstr_w(szAssemblyName),
149 debugstr_w(szModuleName), szName, cchName, pcName);
150 return E_NOTIMPL;
151 }
152
153 static const struct IMetaDataDispenserExVtbl MetaDataDispenserVtbl =
154 {
155 MetaDataDispenser_QueryInterface,
156 MetaDataDispenser_AddRef,
157 MetaDataDispenser_Release,
158 MetaDataDispenser_DefineScope,
159 MetaDataDispenser_OpenScope,
160 MetaDataDispenser_OpenScopeOnMemory,
161 MetaDataDispenser_SetOption,
162 MetaDataDispenser_GetOption,
163 MetaDataDispenser_OpenScopeOnITypeInfo,
164 MetaDataDispenser_GetCORSystemDirectory,
165 MetaDataDispenser_FindAssembly,
166 MetaDataDispenser_FindAssemblyModule
167 };
168
169 HRESULT MetaDataDispenser_CreateInstance(IUnknown **ppUnk)
170 {
171 MetaDataDispenser *This;
172
173 This = HeapAlloc(GetProcessHeap(), 0, sizeof(MetaDataDispenser));
174
175 if (!This)
176 return E_OUTOFMEMORY;
177
178 This->IMetaDataDispenserEx_iface.lpVtbl = &MetaDataDispenserVtbl;
179 This->ref = 1;
180
181 *ppUnk = (IUnknown*)This;
182
183 return S_OK;
184 }