Synchronize with trunk r58528.
[reactos.git] / 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 #define WIN32_NO_STATUS
22 #define _INC_WINDOWS
23 #define COM_NO_WINDOWS_H
24
25 //#include <stdio.h>
26 #include <stdarg.h>
27 //#include <assert.h>
28
29 #define COBJMACROS
30
31 //#include "wine/library.h"
32 #include <windef.h>
33 #include <winbase.h>
34 //#include "winreg.h"
35 #include <ole2.h>
36 #include <cor.h>
37 //#include "mscoree.h"
38 //#include "corhdr.h"
39 //#include "cordebug.h"
40 //#include "metahost.h"
41 //#include "wine/list.h"
42 //#include "mscoree_private.h"
43
44 #include <wine/debug.h>
45
46 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
47
48 typedef struct MetaDataDispenser
49 {
50 IMetaDataDispenserEx IMetaDataDispenserEx_iface;
51 LONG ref;
52 } MetaDataDispenser;
53
54 static inline MetaDataDispenser *impl_from_IMetaDataDispenserEx(IMetaDataDispenserEx *iface)
55 {
56 return CONTAINING_RECORD(iface, MetaDataDispenser, IMetaDataDispenserEx_iface);
57 }
58
59 static HRESULT WINAPI MetaDataDispenser_QueryInterface(IMetaDataDispenserEx* iface,
60 REFIID riid, void **ppvObject)
61 {
62 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
63
64 if (IsEqualGUID(riid, &IID_IMetaDataDispenserEx) ||
65 IsEqualGUID(riid, &IID_IMetaDataDispenser) ||
66 IsEqualGUID(riid, &IID_IUnknown))
67 {
68 *ppvObject = iface;
69 }
70 else
71 {
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
73 return E_NOINTERFACE;
74 }
75
76 IMetaDataDispenserEx_AddRef( iface );
77
78 return S_OK;
79 }
80
81 static ULONG WINAPI MetaDataDispenser_AddRef(IMetaDataDispenserEx* iface)
82 {
83 MetaDataDispenser *This = impl_from_IMetaDataDispenserEx(iface);
84 ULONG ref = InterlockedIncrement(&This->ref);
85
86 TRACE("%p ref=%u\n", This, ref);
87
88 return ref;
89 }
90
91 static ULONG WINAPI MetaDataDispenser_Release(IMetaDataDispenserEx* iface)
92 {
93 MetaDataDispenser *This = impl_from_IMetaDataDispenserEx(iface);
94 ULONG ref = InterlockedDecrement(&This->ref);
95
96 TRACE("%p ref=%u\n", This, ref);
97
98 if (ref == 0)
99 {
100 HeapFree(GetProcessHeap(), 0, This);
101 }
102
103 return ref;
104 }
105
106 static HRESULT WINAPI MetaDataDispenser_DefineScope(IMetaDataDispenserEx* iface,
107 REFCLSID rclsid, DWORD dwCreateFlags, REFIID riid, IUnknown **ppIUnk)
108 {
109 FIXME("%p %s %x %s %p\n", iface, debugstr_guid(rclsid), dwCreateFlags,
110 debugstr_guid(riid), ppIUnk);
111 return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI MetaDataDispenser_OpenScope(IMetaDataDispenserEx* iface,
115 LPCWSTR szScope, DWORD dwOpenFlags, REFIID riid, IUnknown **ppIUnk)
116 {
117 FIXME("%p %s %x %s %p\n", iface, debugstr_w(szScope), dwOpenFlags,
118 debugstr_guid(riid), ppIUnk);
119 return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI MetaDataDispenser_OpenScopeOnMemory(IMetaDataDispenserEx* iface,
123 const void *pData, ULONG cbData, DWORD dwOpenFlags, REFIID riid, IUnknown **ppIUnk)
124 {
125 FIXME("%p %p %u %x %s %p\n", iface, pData, cbData, dwOpenFlags,
126 debugstr_guid(riid), ppIUnk);
127 return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI MetaDataDispenser_SetOption(IMetaDataDispenserEx* iface,
131 REFGUID optionid, const VARIANT *value)
132 {
133 FIXME("%p %s\n", iface, debugstr_guid(optionid));
134 return E_NOTIMPL;
135 }
136
137 static HRESULT WINAPI MetaDataDispenser_GetOption(IMetaDataDispenserEx* iface,
138 REFGUID optionid, VARIANT *pvalue)
139 {
140 FIXME("%p %s\n", iface, debugstr_guid(optionid));
141 return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI MetaDataDispenser_OpenScopeOnITypeInfo(IMetaDataDispenserEx* iface,
145 ITypeInfo *pITI, DWORD dwOpenFlags, REFIID riid, IUnknown **ppIUnk)
146 {
147 FIXME("%p %p %u %s %p\n", iface, pITI, dwOpenFlags, debugstr_guid(riid), ppIUnk);
148 return E_NOTIMPL;
149 }
150
151 static HRESULT WINAPI MetaDataDispenser_GetCORSystemDirectory(IMetaDataDispenserEx* iface,
152 LPWSTR szBuffer, DWORD cchBuffer, DWORD *pchBuffer)
153 {
154 FIXME("%p %p %u %p\n", iface, szBuffer, cchBuffer, pchBuffer);
155 return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI MetaDataDispenser_FindAssembly(IMetaDataDispenserEx* iface,
159 LPCWSTR szAppBase, LPCWSTR szPrivateBin, LPCWSTR szGlobalBin, LPCWSTR szAssemblyName,
160 LPWSTR szName, ULONG cchName, ULONG *pcName)
161 {
162 FIXME("%p %s %s %s %s %p %u %p\n", iface, debugstr_w(szAppBase),
163 debugstr_w(szPrivateBin), debugstr_w(szGlobalBin),
164 debugstr_w(szAssemblyName), szName, cchName, pcName);
165 return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI MetaDataDispenser_FindAssemblyModule(IMetaDataDispenserEx* iface,
169 LPCWSTR szAppBase, LPCWSTR szPrivateBin, LPCWSTR szGlobalBin, LPCWSTR szAssemblyName,
170 LPCWSTR szModuleName, LPWSTR szName, ULONG cchName, ULONG *pcName)
171 {
172 FIXME("%p %s %s %s %s %s %p %u %p\n", iface, debugstr_w(szAppBase),
173 debugstr_w(szPrivateBin), debugstr_w(szGlobalBin), debugstr_w(szAssemblyName),
174 debugstr_w(szModuleName), szName, cchName, pcName);
175 return E_NOTIMPL;
176 }
177
178 static const struct IMetaDataDispenserExVtbl MetaDataDispenserVtbl =
179 {
180 MetaDataDispenser_QueryInterface,
181 MetaDataDispenser_AddRef,
182 MetaDataDispenser_Release,
183 MetaDataDispenser_DefineScope,
184 MetaDataDispenser_OpenScope,
185 MetaDataDispenser_OpenScopeOnMemory,
186 MetaDataDispenser_SetOption,
187 MetaDataDispenser_GetOption,
188 MetaDataDispenser_OpenScopeOnITypeInfo,
189 MetaDataDispenser_GetCORSystemDirectory,
190 MetaDataDispenser_FindAssembly,
191 MetaDataDispenser_FindAssemblyModule
192 };
193
194 HRESULT MetaDataDispenser_CreateInstance(IUnknown **ppUnk)
195 {
196 MetaDataDispenser *This;
197
198 This = HeapAlloc(GetProcessHeap(), 0, sizeof(MetaDataDispenser));
199
200 if (!This)
201 return E_OUTOFMEMORY;
202
203 This->IMetaDataDispenserEx_iface.lpVtbl = &MetaDataDispenserVtbl;
204 This->ref = 1;
205
206 *ppUnk = (IUnknown*)This;
207
208 return S_OK;
209 }