mshtml: Added support for partial reads in read_stream_data.
[wine] / dlls / mscoree / corruntimehost.c
1 /*
2  *
3  * Copyright 2008 Alistair Leslie-Hughes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #define COBJMACROS
21
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
29
30 #include "cor.h"
31 #include "mscoree.h"
32
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
36
37 typedef struct _corruntimehost
38 {
39     const struct ICorRuntimeHostVtbl *lpVtbl;
40     LONG ref;
41 } corruntimehost;
42
43 static inline corruntimehost *impl_from_ICorRuntimeHost( ICorRuntimeHost *iface )
44 {
45     return (corruntimehost *)((char*)iface - FIELD_OFFSET(corruntimehost, lpVtbl));
46 }
47
48 /*** IUnknown methods ***/
49 static HRESULT WINAPI corruntimehost_QueryInterface(ICorRuntimeHost* iface,
50         REFIID riid,
51         void **ppvObject)
52 {
53     corruntimehost *This = impl_from_ICorRuntimeHost( iface );
54     TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
55
56     if ( IsEqualGUID( riid, &IID_ICorRuntimeHost ) ||
57          IsEqualGUID( riid, &IID_IUnknown ) )
58     {
59         *ppvObject = iface;
60     }
61     else
62     {
63         FIXME("Unsupported interface %s\n", debugstr_guid(riid));
64         return E_NOINTERFACE;
65     }
66
67     ICorRuntimeHost_AddRef( iface );
68
69     return S_OK;
70 }
71
72 static ULONG WINAPI corruntimehost_AddRef(ICorRuntimeHost* iface)
73 {
74     corruntimehost *This = impl_from_ICorRuntimeHost( iface );
75     return InterlockedIncrement( &This->ref );
76 }
77
78 static ULONG WINAPI corruntimehost_Release(ICorRuntimeHost* iface)
79 {
80     corruntimehost *This = impl_from_ICorRuntimeHost( iface );
81     ULONG ref;
82
83     ref = InterlockedDecrement( &This->ref );
84     if ( ref == 0 )
85     {
86         HeapFree( GetProcessHeap(), 0, This );
87     }
88
89     return ref;
90 }
91
92 /*** ICorRuntimeHost methods ***/
93 static HRESULT WINAPI corruntimehost_CreateLogicalThreadState(
94                     ICorRuntimeHost* iface)
95 {
96     FIXME("stub %p\n", iface);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI corruntimehost_DeleteLogicalThreadState(
101                     ICorRuntimeHost* iface)
102 {
103     FIXME("stub %p\n", iface);
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI corruntimehost_SwitchInLogicalThreadState(
108                     ICorRuntimeHost* iface,
109                     DWORD *fiberCookie)
110 {
111     FIXME("stub %p\n", iface);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI corruntimehost_SwitchOutLogicalThreadState(
116                     ICorRuntimeHost* iface,
117                     DWORD **fiberCookie)
118 {
119     FIXME("stub %p\n", iface);
120     return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI corruntimehost_LocksHeldByLogicalThread(
124                     ICorRuntimeHost* iface,
125                     DWORD *pCount)
126 {
127     FIXME("stub %p\n", iface);
128     return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI corruntimehost_MapFile(
132     ICorRuntimeHost* iface,
133     HANDLE hFile,
134     HMODULE *mapAddress)
135 {
136     FIXME("stub %p\n", iface);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI corruntimehost_GetConfiguration(
141     ICorRuntimeHost* iface,
142     ICorConfiguration **pConfiguration)
143 {
144     FIXME("stub %p\n", iface);
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI corruntimehost_Start(
149     ICorRuntimeHost* iface)
150 {
151     FIXME("stub %p\n", iface);
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI corruntimehost_Stop(
156     ICorRuntimeHost* iface)
157 {
158     FIXME("stub %p\n", iface);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI corruntimehost_CreateDomain(
163     ICorRuntimeHost* iface,
164     LPCWSTR friendlyName,
165     IUnknown *identityArray,
166     IUnknown **appDomain)
167 {
168     FIXME("stub %p\n", iface);
169     return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI corruntimehost_GetDefaultDomain(
173     ICorRuntimeHost* iface,
174     IUnknown **pAppDomain)
175 {
176     FIXME("stub %p\n", iface);
177     return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI corruntimehost_EnumDomains(
181     ICorRuntimeHost* iface,
182     HDOMAINENUM *hEnum)
183 {
184     FIXME("stub %p\n", iface);
185     return E_NOTIMPL;
186 }
187
188 static HRESULT WINAPI corruntimehost_NextDomain(
189     ICorRuntimeHost* iface,
190     HDOMAINENUM hEnum,
191     IUnknown **appDomain)
192 {
193     FIXME("stub %p\n", iface);
194     return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI corruntimehost_CloseEnum(
198     ICorRuntimeHost* iface,
199     HDOMAINENUM hEnum)
200 {
201     FIXME("stub %p\n", iface);
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI corruntimehost_CreateDomainEx(
206     ICorRuntimeHost* iface,
207     LPCWSTR friendlyName,
208     IUnknown *setup,
209     IUnknown *evidence,
210     IUnknown **appDomain)
211 {
212     FIXME("stub %p\n", iface);
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI corruntimehost_CreateDomainSetup(
217     ICorRuntimeHost* iface,
218     IUnknown **appDomainSetup)
219 {
220     FIXME("stub %p\n", iface);
221     return E_NOTIMPL;
222 }
223
224 static HRESULT WINAPI corruntimehost_CreateEvidence(
225     ICorRuntimeHost* iface,
226     IUnknown **evidence)
227 {
228     FIXME("stub %p\n", iface);
229     return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI corruntimehost_UnloadDomain(
233     ICorRuntimeHost* iface,
234     IUnknown *appDomain)
235 {
236     FIXME("stub %p\n", iface);
237     return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI corruntimehost_CurrentDomain(
241     ICorRuntimeHost* iface,
242     IUnknown **appDomain)
243 {
244     FIXME("stub %p\n", iface);
245     return E_NOTIMPL;
246 }
247
248 static const struct ICorRuntimeHostVtbl corruntimehost_vtbl =
249 {
250     corruntimehost_QueryInterface,
251     corruntimehost_AddRef,
252     corruntimehost_Release,
253     corruntimehost_CreateLogicalThreadState,
254     corruntimehost_DeleteLogicalThreadState,
255     corruntimehost_SwitchInLogicalThreadState,
256     corruntimehost_SwitchOutLogicalThreadState,
257     corruntimehost_LocksHeldByLogicalThread,
258     corruntimehost_MapFile,
259     corruntimehost_GetConfiguration,
260     corruntimehost_Start,
261     corruntimehost_Stop,
262     corruntimehost_CreateDomain,
263     corruntimehost_GetDefaultDomain,
264     corruntimehost_EnumDomains,
265     corruntimehost_NextDomain,
266     corruntimehost_CloseEnum,
267     corruntimehost_CreateDomainEx,
268     corruntimehost_CreateDomainSetup,
269     corruntimehost_CreateEvidence,
270     corruntimehost_UnloadDomain,
271     corruntimehost_CurrentDomain
272 };
273
274 IUnknown* create_corruntimehost(void)
275 {
276     corruntimehost *This;
277
278     This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
279     if ( !This )
280         return NULL;
281
282     This->lpVtbl = &corruntimehost_vtbl;
283     This->ref = 1;
284
285     FIXME("return iface %p\n", This);
286
287     return (IUnknown*) &This->lpVtbl;
288 }