crypt32: Add Japanese translation.
[wine] / dlls / mscoree / mscoree_main.c
1 /*
2  * Implementation of mscoree.dll
3  * Microsoft Component Object Runtime Execution Engine
4  *
5  * Copyright 2006 Paul Chitescu
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include <stdarg.h>
23
24 #define COBJMACROS
25 #include "wine/unicode.h"
26 #include "wine/library.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "winreg.h"
32 #include "ole2.h"
33 #include "ocidl.h"
34 #include "shellapi.h"
35
36 #include "initguid.h"
37 #include "cor.h"
38 #include "corerror.h"
39 #include "mscoree.h"
40 #include "metahost.h"
41 #include "mscoree_private.h"
42
43 #include "wine/debug.h"
44
45 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
46
47 static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path, int* abi_version)
48 {
49     static const WCHAR mono_dll[] = {'\\','b','i','n','\\','m','o','n','o','.','d','l','l',0};
50     static const WCHAR libmono_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','.','d','l','l',0};
51     DWORD attributes;
52
53     strcpyW(dll_path, path);
54     strcatW(dll_path, mono_dll);
55     attributes = GetFileAttributesW(dll_path);
56
57     if (attributes == INVALID_FILE_ATTRIBUTES)
58     {
59         strcpyW(dll_path, path);
60         strcatW(dll_path, libmono_dll);
61         attributes = GetFileAttributesW(dll_path);
62     }
63
64     if (attributes != INVALID_FILE_ATTRIBUTES)
65     {
66         /* FIXME: Test for appropriate architecture. */
67         *abi_version = 1;
68         return TRUE;
69     }
70
71     return FALSE;
72 }
73
74 static BOOL get_mono_path_from_registry(LPWSTR path)
75 {
76     static const WCHAR mono_key[] = {'S','o','f','t','w','a','r','e','\\','N','o','v','e','l','l','\\','M','o','n','o',0};
77     static const WCHAR defaul_clr[] = {'D','e','f','a','u','l','t','C','L','R',0};
78     static const WCHAR install_root[] = {'S','d','k','I','n','s','t','a','l','l','R','o','o','t',0};
79     static const WCHAR slash[] = {'\\',0};
80
81     WCHAR version[64], version_key[MAX_PATH];
82     DWORD len;
83     HKEY key;
84     WCHAR dll_path[MAX_PATH];
85     int abi_version;
86
87     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, mono_key, 0, KEY_READ, &key))
88         return FALSE;
89
90     len = sizeof(version);
91     if (RegQueryValueExW(key, defaul_clr, 0, NULL, (LPBYTE)version, &len))
92     {
93         RegCloseKey(key);
94         return FALSE;
95     }
96     RegCloseKey(key);
97
98     lstrcpyW(version_key, mono_key);
99     lstrcatW(version_key, slash);
100     lstrcatW(version_key, version);
101
102     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, version_key, 0, KEY_READ, &key))
103         return FALSE;
104
105     len = sizeof(WCHAR) * MAX_PATH;
106     if (RegQueryValueExW(key, install_root, 0, NULL, (LPBYTE)path, &len))
107     {
108         RegCloseKey(key);
109         return FALSE;
110     }
111     RegCloseKey(key);
112
113     return find_mono_dll(path, dll_path, &abi_version);
114 }
115
116 static BOOL get_mono_path_from_folder(LPCWSTR folder, LPWSTR mono_path)
117 {
118     static const WCHAR mono_one_dot_zero[] = {'\\','m','o','n','o','-','1','.','0', 0};
119     WCHAR mono_dll_path[MAX_PATH];
120     int abi_version;
121     BOOL found = FALSE;
122
123     strcpyW(mono_path, folder);
124     strcatW(mono_path, mono_one_dot_zero);
125
126     found = find_mono_dll(mono_path, mono_dll_path, &abi_version);
127
128     if (found && abi_version != 1)
129     {
130         ERR("found wrong ABI in %s\n", debugstr_w(mono_path));
131         found = FALSE;
132     }
133
134     return found;
135 }
136
137 static BOOL get_mono_path(LPWSTR path)
138 {
139     static const WCHAR subdir_mono[] = {'\\','m','o','n','o',0};
140     static const WCHAR sibling_mono[] = {'\\','.','.','\\','m','o','n','o',0};
141     WCHAR base_path[MAX_PATH];
142     const char *unix_data_dir;
143     WCHAR *dos_data_dir;
144     int build_tree=0;
145     static WCHAR* (CDECL *wine_get_dos_file_name)(const char*);
146
147     /* First try c:\windows\mono */
148     GetWindowsDirectoryW(base_path, MAX_PATH);
149     strcatW(base_path, subdir_mono);
150
151     if (get_mono_path_from_folder(base_path, path))
152         return TRUE;
153
154     /* Next: /usr/share/wine/mono */
155     unix_data_dir = wine_get_data_dir();
156
157     if (!unix_data_dir)
158     {
159         unix_data_dir = wine_get_build_dir();
160         build_tree = 1;
161     }
162
163     if (unix_data_dir)
164     {
165         if (!wine_get_dos_file_name)
166             wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleA("kernel32"), "wine_get_dos_file_name");
167
168         if (wine_get_dos_file_name)
169         {
170             dos_data_dir = wine_get_dos_file_name(unix_data_dir);
171
172             if (dos_data_dir)
173             {
174                 strcpyW(base_path, dos_data_dir);
175                 strcatW(base_path, build_tree ? sibling_mono : subdir_mono);
176
177                 HeapFree(GetProcessHeap(), 0, dos_data_dir);
178
179                 if (get_mono_path_from_folder(base_path, path))
180                     return TRUE;
181             }
182         }
183     }
184
185     /* Last: the registry */
186     return get_mono_path_from_registry(path);
187 }
188
189 static BOOL get_install_root(LPWSTR install_dir)
190 {
191     const WCHAR dotnet_key[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\','.','N','E','T','F','r','a','m','e','w','o','r','k','\\',0};
192     const WCHAR install_root[] = {'I','n','s','t','a','l','l','R','o','o','t',0};
193
194     DWORD len;
195     HKEY key;
196
197     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, dotnet_key, 0, KEY_READ, &key))
198         return FALSE;
199
200     len = MAX_PATH;
201     if (RegQueryValueExW(key, install_root, 0, NULL, (LPBYTE)install_dir, &len))
202     {
203         RegCloseKey(key);
204         return FALSE;
205     }
206     RegCloseKey(key);
207
208     return TRUE;
209 }
210
211 static CRITICAL_SECTION mono_lib_cs;
212 static CRITICAL_SECTION_DEBUG mono_lib_cs_debug =
213 {
214     0, 0, &mono_lib_cs,
215     { &mono_lib_cs_debug.ProcessLocksList,
216       &mono_lib_cs_debug.ProcessLocksList },
217       0, 0, { (DWORD_PTR)(__FILE__ ": mono_lib_cs") }
218 };
219 static CRITICAL_SECTION mono_lib_cs = { &mono_lib_cs_debug, -1, 0, 0, 0, 0 };
220
221 HMODULE mono_handle;
222
223 void (*mono_config_parse)(const char *filename);
224 MonoAssembly* (*mono_domain_assembly_open) (MonoDomain *domain, const char *name);
225 void (*mono_jit_cleanup)(MonoDomain *domain);
226 int (*mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
227 MonoDomain* (*mono_jit_init)(const char *file);
228 int (*mono_jit_set_trace_options)(const char* options);
229 void (*mono_set_dirs)(const char *assembly_dir, const char *config_dir);
230
231 static void set_environment(LPCWSTR bin_path)
232 {
233     WCHAR path_env[MAX_PATH];
234     int len;
235
236     static const WCHAR pathW[] = {'P','A','T','H',0};
237
238     /* We have to modify PATH as Mono loads other DLLs from this directory. */
239     GetEnvironmentVariableW(pathW, path_env, sizeof(path_env)/sizeof(WCHAR));
240     len = strlenW(path_env);
241     path_env[len++] = ';';
242     strcpyW(path_env+len, bin_path);
243     SetEnvironmentVariableW(pathW, path_env);
244 }
245
246 static HMODULE load_mono(void)
247 {
248     static const WCHAR bin[] = {'\\','b','i','n',0};
249     static const WCHAR lib[] = {'\\','l','i','b',0};
250     static const WCHAR etc[] = {'\\','e','t','c',0};
251     HMODULE result;
252     WCHAR mono_path[MAX_PATH], mono_dll_path[MAX_PATH+16], mono_bin_path[MAX_PATH+4];
253     WCHAR mono_lib_path[MAX_PATH+4], mono_etc_path[MAX_PATH+4];
254     char mono_lib_path_a[MAX_PATH], mono_etc_path_a[MAX_PATH];
255     int abi_version;
256
257     EnterCriticalSection(&mono_lib_cs);
258
259     if (!mono_handle)
260     {
261         if (!get_mono_path(mono_path)) goto end;
262
263         strcpyW(mono_bin_path, mono_path);
264         strcatW(mono_bin_path, bin);
265         set_environment(mono_bin_path);
266
267         strcpyW(mono_lib_path, mono_path);
268         strcatW(mono_lib_path, lib);
269         WideCharToMultiByte(CP_UTF8, 0, mono_lib_path, -1, mono_lib_path_a, MAX_PATH, NULL, NULL);
270
271         strcpyW(mono_etc_path, mono_path);
272         strcatW(mono_etc_path, etc);
273         WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL);
274
275         if (!find_mono_dll(mono_path, mono_dll_path, &abi_version)) goto end;
276
277         if (abi_version != 1) goto end;
278
279         mono_handle = LoadLibraryW(mono_dll_path);
280
281         if (!mono_handle) goto end;
282
283 #define LOAD_MONO_FUNCTION(x) do { \
284     x = (void*)GetProcAddress(mono_handle, #x); \
285     if (!x) { \
286         mono_handle = NULL; \
287         goto end; \
288     } \
289 } while (0);
290
291         LOAD_MONO_FUNCTION(mono_config_parse);
292         LOAD_MONO_FUNCTION(mono_domain_assembly_open);
293         LOAD_MONO_FUNCTION(mono_jit_cleanup);
294         LOAD_MONO_FUNCTION(mono_jit_exec);
295         LOAD_MONO_FUNCTION(mono_jit_init);
296         LOAD_MONO_FUNCTION(mono_jit_set_trace_options);
297         LOAD_MONO_FUNCTION(mono_set_dirs);
298
299 #undef LOAD_MONO_FUNCTION
300
301         mono_set_dirs(mono_lib_path_a, mono_etc_path_a);
302
303         mono_config_parse(NULL);
304     }
305
306 end:
307     result = mono_handle;
308
309     LeaveCriticalSection(&mono_lib_cs);
310
311     if (!result)
312         MESSAGE("wine: Install the Windows version of Mono to run .NET executables\n");
313
314     return result;
315 }
316
317 HRESULT WINAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor,
318                                     LPCWSTR pwszHostConfigFile, VOID *pReserved,
319                                     DWORD startupFlags, REFCLSID rclsid,
320                                     REFIID riid, LPVOID *ppv)
321 {
322     FIXME("(%s, %s, %s, %p, %d, %s, %s, %p): semi-stub!\n", debugstr_w(pwszVersion),
323           debugstr_w(pwszBuildFlavor), debugstr_w(pwszHostConfigFile), pReserved,
324           startupFlags, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
325
326     if (!get_mono_path(NULL))
327     {
328         MESSAGE("wine: Install the Windows version of Mono to run .NET executables\n");
329         return E_FAIL;
330     }
331
332     return S_OK;
333 }
334
335 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
336 {
337     TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
338
339     switch (fdwReason)
340     {
341     case DLL_WINE_PREATTACH:
342         return FALSE;  /* prefer native version */
343     case DLL_PROCESS_ATTACH:
344         DisableThreadLibraryCalls(hinstDLL);
345         break;
346     case DLL_PROCESS_DETACH:
347         unload_all_runtimes();
348         break;
349     }
350     return TRUE;
351 }
352
353 BOOL WINAPI _CorDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
354 {
355     FIXME("(%p, %d, %p): stub\n", hinstDLL, fdwReason, lpvReserved);
356
357     switch (fdwReason)
358     {
359     case DLL_PROCESS_ATTACH:
360         DisableThreadLibraryCalls(hinstDLL);
361         break;
362     case DLL_PROCESS_DETACH:
363         break;
364     }
365     return TRUE;
366 }
367
368 static void get_utf8_args(int *argc, char ***argv)
369 {
370     WCHAR **argvw;
371     int size=0, i;
372     char *current_arg;
373
374     argvw = CommandLineToArgvW(GetCommandLineW(), argc);
375
376     for (i=0; i<*argc; i++)
377     {
378         size += sizeof(char*);
379         size += WideCharToMultiByte(CP_UTF8, 0, argvw[i], -1, NULL, 0, NULL, NULL);
380     }
381     size += sizeof(char*);
382
383     *argv = HeapAlloc(GetProcessHeap(), 0, size);
384     current_arg = (char*)(*argv + *argc + 1);
385
386     for (i=0; i<*argc; i++)
387     {
388         (*argv)[i] = current_arg;
389         current_arg += WideCharToMultiByte(CP_UTF8, 0, argvw[i], -1, current_arg, size, NULL, NULL);
390     }
391
392     (*argv)[*argc] = NULL;
393
394     HeapFree(GetProcessHeap(), 0, argvw);
395 }
396
397 __int32 WINAPI _CorExeMain(void)
398 {
399     int exit_code;
400     int trace_size;
401     char trace_setting[256];
402     int argc;
403     char **argv;
404     MonoDomain *domain;
405     MonoAssembly *assembly;
406     char filename[MAX_PATH];
407
408     if (!load_mono())
409     {
410         return -1;
411     }
412
413     get_utf8_args(&argc, &argv);
414
415     trace_size = GetEnvironmentVariableA("WINE_MONO_TRACE", trace_setting, sizeof(trace_setting));
416
417     if (trace_size)
418     {
419         mono_jit_set_trace_options(trace_setting);
420     }
421
422     GetModuleFileNameA(NULL, filename, MAX_PATH);
423
424     domain = mono_jit_init(filename);
425
426     assembly = mono_domain_assembly_open(domain, filename);
427
428     exit_code = mono_jit_exec(domain, assembly, argc, argv);
429
430     mono_jit_cleanup(domain);
431
432     HeapFree(GetProcessHeap(), 0, argv);
433
434     return exit_code;
435 }
436
437 __int32 WINAPI _CorExeMain2(PBYTE ptrMemory, DWORD cntMemory, LPWSTR imageName, LPWSTR loaderName, LPWSTR cmdLine)
438 {
439     TRACE("(%p, %u, %s, %s, %s)\n", ptrMemory, cntMemory, debugstr_w(imageName), debugstr_w(loaderName), debugstr_w(cmdLine));
440     FIXME("Directly running .NET applications not supported.\n");
441     return -1;
442 }
443
444 void WINAPI CorExitProcess(int exitCode)
445 {
446     FIXME("(%x) stub\n", exitCode);
447     ExitProcess(exitCode);
448 }
449
450 VOID WINAPI _CorImageUnloading(PVOID imageBase)
451 {
452     TRACE("(%p): stub\n", imageBase);
453 }
454
455 HRESULT WINAPI _CorValidateImage(PVOID* imageBase, LPCWSTR imageName)
456 {
457     TRACE("(%p, %s): stub\n", imageBase, debugstr_w(imageName));
458     return E_FAIL;
459 }
460
461 HRESULT WINAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
462 {
463     static const WCHAR slash[] = {'\\',0};
464     WCHAR system_dir[MAX_PATH];
465     WCHAR version[MAX_PATH];
466
467     FIXME("(%p, %d, %p): semi-stub!\n", pbuffer, cchBuffer, dwLength);
468
469     if (!dwLength)
470         return E_POINTER;
471
472     if (!pbuffer)
473         return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
474
475     if (!get_install_root(system_dir))
476     {
477         ERR("error reading registry key for installroot, returning empty path\n");
478         *dwLength = 0;
479     }
480     else
481     {
482         GetCORVersion(version, MAX_PATH, dwLength);
483         lstrcatW(system_dir, version);
484         lstrcatW(system_dir, slash);
485         *dwLength = lstrlenW(system_dir) + 1;
486
487         if (cchBuffer < *dwLength)
488             return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
489
490         lstrcpyW(pbuffer, system_dir);
491     }
492
493     return S_OK;
494 }
495
496 HRESULT WINAPI GetCORVersion(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
497 {
498     static const WCHAR version[] = {'v','2','.','0','.','5','0','7','2','7',0};
499
500     FIXME("(%p, %d, %p): semi-stub!\n", pbuffer, cchBuffer, dwLength);
501
502     if (!dwLength || !pbuffer)
503         return E_POINTER;
504
505     *dwLength = lstrlenW(version) + 1;
506
507     if (cchBuffer < *dwLength)
508         return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
509
510     lstrcpyW(pbuffer, version);
511
512     return S_OK;
513 }
514
515 HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile,
516     DWORD startupFlags, DWORD runtimeInfoFlags, LPWSTR pDirectory, DWORD dwDirectory, DWORD *dwDirectoryLength,
517     LPWSTR pVersion, DWORD cchBuffer, DWORD *dwlength)
518 {
519     HRESULT ret;
520     ICLRRuntimeInfo *info;
521     DWORD length_dummy;
522
523     TRACE("(%s, %s, %s, 0x%08x, 0x%08x, %p, 0x%08x, %p, %p, 0x%08x, %p)\n", debugstr_w(pExe),
524           debugstr_w(pwszVersion), debugstr_w(pConfigurationFile), startupFlags, runtimeInfoFlags, pDirectory,
525           dwDirectory, dwDirectoryLength, pVersion, cchBuffer, dwlength);
526
527     if (!dwDirectoryLength) dwDirectoryLength = &length_dummy;
528
529     if (!dwlength) dwlength = &length_dummy;
530
531     ret = get_runtime_info(pExe, pwszVersion, pConfigurationFile, startupFlags, runtimeInfoFlags, TRUE, &info);
532
533     if (SUCCEEDED(ret))
534     {
535         *dwlength = cchBuffer;
536         ret = ICLRRuntimeInfo_GetVersionString(info, pVersion, dwlength);
537
538         if (SUCCEEDED(ret))
539         {
540             *dwDirectoryLength = dwDirectory;
541             ret = ICLRRuntimeInfo_GetRuntimeDirectory(info, pDirectory, dwDirectoryLength);
542         }
543
544         ICLRRuntimeInfo_Release(info);
545     }
546
547     return ret;
548 }
549
550 HRESULT WINAPI LoadLibraryShim( LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE * phModDll)
551 {
552     FIXME("(%p %s, %p, %p, %p): semi-stub\n", szDllName, debugstr_w(szDllName), szVersion, pvReserved, phModDll);
553
554     if (phModDll) *phModDll = LoadLibraryW(szDllName);
555     return S_OK;
556 }
557
558 HRESULT WINAPI LockClrVersion(FLockClrVersionCallback hostCallback, FLockClrVersionCallback *pBeginHostSetup, FLockClrVersionCallback *pEndHostSetup)
559 {
560     FIXME("(%p %p %p): stub\n", hostCallback, pBeginHostSetup, pEndHostSetup);
561     return S_OK;
562 }
563
564 HRESULT WINAPI CoInitializeCor(DWORD fFlags)
565 {
566     FIXME("(0x%08x): stub\n", fFlags);
567     return S_OK;
568 }
569
570 HRESULT WINAPI GetAssemblyMDImport(LPCWSTR szFileName, REFIID riid, IUnknown **ppIUnk)
571 {
572     FIXME("(%p %s, %s, %p): stub\n", szFileName, debugstr_w(szFileName), debugstr_guid(riid), *ppIUnk);
573     return ERROR_CALL_NOT_IMPLEMENTED;
574 }
575
576 HRESULT WINAPI GetVersionFromProcess(HANDLE hProcess, LPWSTR pVersion, DWORD cchBuffer, DWORD *dwLength)
577 {
578     FIXME("(%p, %p, %d, %p): stub\n", hProcess, pVersion, cchBuffer, dwLength);
579     return E_NOTIMPL;
580 }
581
582 HRESULT WINAPI LoadStringRCEx(LCID culture, UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet, int* pBufLen)
583 {
584     HRESULT res = S_OK;
585     if ((iBufLen <= 0) || !pBuffer)
586         return E_INVALIDARG;
587     pBuffer[0] = 0;
588     if (resId) {
589         FIXME("(%d, %x, %p, %d, %d, %p): semi-stub\n", culture, resId, pBuffer, iBufLen, bQuiet, pBufLen);
590         res = E_NOTIMPL;
591     }
592     else
593         res = E_FAIL;
594     if (pBufLen)
595         *pBufLen = lstrlenW(pBuffer);
596     return res;
597 }
598
599 HRESULT WINAPI LoadStringRC(UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet)
600 {
601     return LoadStringRCEx(-1, resId, pBuffer, iBufLen, bQuiet, NULL);
602 }
603
604 HRESULT WINAPI CorBindToRuntimeEx(LPWSTR szVersion, LPWSTR szBuildFlavor, DWORD nflags, REFCLSID rslsid,
605                                   REFIID riid, LPVOID *ppv)
606 {
607     FIXME("%s %s %d %s %s %p\n", debugstr_w(szVersion), debugstr_w(szBuildFlavor), nflags, debugstr_guid( rslsid ),
608           debugstr_guid( riid ), ppv);
609
610     if(IsEqualGUID( riid, &IID_ICorRuntimeHost ))
611     {
612         *ppv = create_corruntimehost();
613         return S_OK;
614     }
615     *ppv = NULL;
616     return E_NOTIMPL;
617 }
618
619 HRESULT WINAPI CorBindToCurrentRuntime(LPCWSTR filename, REFCLSID rclsid, REFIID riid, LPVOID *ppv)
620 {
621     FIXME("(%s, %s, %s, %p): stub\n", debugstr_w(filename), debugstr_guid(rclsid), debugstr_guid(riid), ppv);
622     return E_NOTIMPL;
623 }
624
625 STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void **ppObject)
626 {
627     FIXME("(%s,%s,%p)\n", debugstr_w(pTypeName), debugstr_guid(riid), ppObject);
628     return E_NOTIMPL;
629 }
630
631 BOOL WINAPI StrongNameSignatureVerification(LPCWSTR filename, DWORD inFlags, DWORD* pOutFlags)
632 {
633     FIXME("(%s, 0x%X, %p): stub\n", debugstr_w(filename), inFlags, pOutFlags);
634     return FALSE;
635 }
636
637 BOOL WINAPI StrongNameSignatureVerificationEx(LPCWSTR filename, BOOL forceVerification, BOOL* pVerified)
638 {
639     FIXME("(%s, %u, %p): stub\n", debugstr_w(filename), forceVerification, pVerified);
640     return FALSE;
641 }
642
643 HRESULT WINAPI CLRCreateInstance(REFCLSID clsid, REFIID riid, LPVOID *ppInterface)
644 {
645     TRACE("(%s,%s,%p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppInterface);
646
647     if (IsEqualGUID(clsid, &CLSID_CLRMetaHost))
648         return CLRMetaHost_CreateInstance(riid, ppInterface);
649
650     FIXME("not implemented for class %s\n", debugstr_guid(clsid));
651
652     return CLASS_E_CLASSNOTAVAILABLE;
653 }
654
655 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
656 {
657     FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
658     if(!ppv)
659         return E_INVALIDARG;
660
661     return E_NOTIMPL;
662 }
663
664 HRESULT WINAPI DllRegisterServer(void)
665 {
666     FIXME("\n");
667     return S_OK;
668 }
669
670 HRESULT WINAPI DllUnregisterServer(void)
671 {
672     FIXME("\n");
673     return S_OK;
674 }
675
676 HRESULT WINAPI DllCanUnloadNow(VOID)
677 {
678     return S_OK;
679 }
680
681 INT WINAPI ND_RU1( const void *ptr, INT offset )
682 {
683     return *((const BYTE *)ptr + offset);
684 }
685
686 INT WINAPI ND_RI2( const void *ptr, INT offset )
687 {
688     return *(const SHORT *)((const BYTE *)ptr + offset);
689 }
690
691 INT WINAPI ND_RI4( const void *ptr, INT offset )
692 {
693     return *(const INT *)((const BYTE *)ptr + offset);
694 }
695
696 INT64 WINAPI ND_RI8( const void *ptr, INT offset )
697 {
698     return *(const INT64 *)((const BYTE *)ptr + offset);
699 }
700
701 void WINAPI ND_WU1( void *ptr, INT offset, BYTE val )
702 {
703     *((BYTE *)ptr + offset) = val;
704 }
705
706 void WINAPI ND_WI2( void *ptr, INT offset, SHORT val )
707 {
708     *(SHORT *)((BYTE *)ptr + offset) = val;
709 }
710
711 void WINAPI ND_WI4( void *ptr, INT offset, INT val )
712 {
713     *(INT *)((BYTE *)ptr + offset) = val;
714 }
715
716 void WINAPI ND_WI8( void *ptr, INT offset, INT64 val )
717 {
718     *(INT64 *)((BYTE *)ptr + offset) = val;
719 }
720
721 void WINAPI ND_CopyObjDst( const void *src, void *dst, INT offset, INT size )
722 {
723     memcpy( (BYTE *)dst + offset, src, size );
724 }
725
726 void WINAPI ND_CopyObjSrc( const void *src, INT offset, void *dst, INT size )
727 {
728     memcpy( dst, (const BYTE *)src + offset, size );
729 }