comctl32/monthcal: Take into account day name width when setting calendar column...
[wine.git] / dlls / mscoree / mscoree_main.c
blob033a121a9e7fcd0c56d38dba0b1d2c9040e334d5
1 /*
2 * Implementation of mscoree.dll
3 * Microsoft Component Object Runtime Execution Engine
5 * Copyright 2006 Paul Chitescu
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.
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.
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
22 #include <stdarg.h>
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"
36 #include "initguid.h"
37 #include "msxml2.h"
38 #include "corerror.h"
39 #include "cor.h"
40 #include "mscoree.h"
41 #include "corhdr.h"
42 #include "cordebug.h"
43 #include "metahost.h"
44 #include "fusion.h"
45 #include "wine/list.h"
46 #include "mscoree_private.h"
47 #include "rpcproxy.h"
49 #include "wine/debug.h"
51 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
53 static HINSTANCE MSCOREE_hInstance;
55 typedef HRESULT (*fnCreateInstance)(REFIID riid, LPVOID *ppObj);
57 char *WtoA(LPCWSTR wstr)
59 int length;
60 char *result;
62 length = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
64 result = HeapAlloc(GetProcessHeap(), 0, length);
66 if (result)
67 WideCharToMultiByte(CP_UTF8, 0, wstr, -1, result, length, NULL, NULL);
69 return result;
72 static BOOL get_install_root(LPWSTR install_dir)
74 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};
75 const WCHAR install_root[] = {'I','n','s','t','a','l','l','R','o','o','t',0};
77 DWORD len;
78 HKEY key;
80 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, dotnet_key, 0, KEY_READ, &key))
81 return FALSE;
83 len = MAX_PATH;
84 if (RegQueryValueExW(key, install_root, 0, NULL, (LPBYTE)install_dir, &len))
86 RegCloseKey(key);
87 return FALSE;
89 RegCloseKey(key);
91 return TRUE;
94 typedef struct mscorecf
96 IClassFactory IClassFactory_iface;
97 LONG ref;
99 fnCreateInstance pfnCreateInstance;
101 CLSID clsid;
102 } mscorecf;
104 static inline mscorecf *impl_from_IClassFactory( IClassFactory *iface )
106 return CONTAINING_RECORD(iface, mscorecf, IClassFactory_iface);
109 static HRESULT WINAPI mscorecf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj )
111 TRACE("%s %p\n", debugstr_guid(riid), ppobj);
113 if (IsEqualGUID(riid, &IID_IUnknown) ||
114 IsEqualGUID(riid, &IID_IClassFactory))
116 IClassFactory_AddRef( iface );
117 *ppobj = iface;
118 return S_OK;
121 ERR("interface %s not implemented\n", debugstr_guid(riid));
122 return E_NOINTERFACE;
125 static ULONG WINAPI mscorecf_AddRef(IClassFactory *iface )
127 mscorecf *This = impl_from_IClassFactory(iface);
128 ULONG ref = InterlockedIncrement(&This->ref);
130 TRACE("%p ref=%u\n", This, ref);
132 return ref;
135 static ULONG WINAPI mscorecf_Release(IClassFactory *iface )
137 mscorecf *This = impl_from_IClassFactory(iface);
138 ULONG ref = InterlockedDecrement(&This->ref);
140 TRACE("%p ref=%u\n", This, ref);
142 if (ref == 0)
144 HeapFree(GetProcessHeap(), 0, This);
147 return ref;
150 static HRESULT WINAPI mscorecf_CreateInstance(IClassFactory *iface,LPUNKNOWN pOuter,
151 REFIID riid, LPVOID *ppobj )
153 mscorecf *This = impl_from_IClassFactory( iface );
154 HRESULT hr;
155 IUnknown *punk;
157 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
159 *ppobj = NULL;
161 if (pOuter)
162 return CLASS_E_NOAGGREGATION;
164 hr = This->pfnCreateInstance( &This->clsid, (LPVOID*) &punk );
165 if (SUCCEEDED(hr))
167 hr = IUnknown_QueryInterface( punk, riid, ppobj );
169 IUnknown_Release( punk );
171 else
173 WARN("Cannot create an instance object. 0x%08x\n", hr);
175 return hr;
178 static HRESULT WINAPI mscorecf_LockServer(IClassFactory *iface, BOOL dolock)
180 FIXME("(%p)->(%d),stub!\n",iface,dolock);
181 return S_OK;
184 static const struct IClassFactoryVtbl mscorecf_vtbl =
186 mscorecf_QueryInterface,
187 mscorecf_AddRef,
188 mscorecf_Release,
189 mscorecf_CreateInstance,
190 mscorecf_LockServer
193 HRESULT WINAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor,
194 LPCWSTR pwszHostConfigFile, VOID *pReserved,
195 DWORD startupFlags, REFCLSID rclsid,
196 REFIID riid, LPVOID *ppv)
198 HRESULT ret;
199 ICLRRuntimeInfo *info;
201 TRACE("(%s, %s, %s, %p, %d, %s, %s, %p)\n", debugstr_w(pwszVersion),
202 debugstr_w(pwszBuildFlavor), debugstr_w(pwszHostConfigFile), pReserved,
203 startupFlags, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
205 *ppv = NULL;
207 ret = get_runtime_info(NULL, pwszVersion, pwszHostConfigFile, startupFlags, 0, TRUE, &info);
209 if (SUCCEEDED(ret))
211 ret = ICLRRuntimeInfo_GetInterface(info, rclsid, riid, ppv);
213 ICLRRuntimeInfo_Release(info);
216 return ret;
219 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
221 TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
223 MSCOREE_hInstance = hinstDLL;
225 switch (fdwReason)
227 case DLL_WINE_PREATTACH:
228 return FALSE; /* prefer native version */
229 case DLL_PROCESS_ATTACH:
230 runtimehost_init();
231 DisableThreadLibraryCalls(hinstDLL);
232 break;
233 case DLL_PROCESS_DETACH:
234 expect_no_runtimes();
235 if (lpvReserved) break; /* process is terminating */
236 runtimehost_uninit();
237 break;
239 return TRUE;
242 __int32 WINAPI _CorExeMain2(PBYTE ptrMemory, DWORD cntMemory, LPWSTR imageName, LPWSTR loaderName, LPWSTR cmdLine)
244 TRACE("(%p, %u, %s, %s, %s)\n", ptrMemory, cntMemory, debugstr_w(imageName), debugstr_w(loaderName), debugstr_w(cmdLine));
245 FIXME("Directly running .NET applications not supported.\n");
246 return -1;
249 void WINAPI CorExitProcess(int exitCode)
251 TRACE("(%x)\n", exitCode);
252 CLRMetaHost_ExitProcess(0, exitCode);
255 VOID WINAPI _CorImageUnloading(PVOID imageBase)
257 TRACE("(%p): stub\n", imageBase);
260 HRESULT WINAPI _CorValidateImage(PVOID* imageBase, LPCWSTR imageName)
262 TRACE("(%p, %s): stub\n", imageBase, debugstr_w(imageName));
263 return E_FAIL;
266 HRESULT WINAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
268 ICLRRuntimeInfo *info;
269 HRESULT ret;
271 TRACE("(%p, %d, %p)!\n", pbuffer, cchBuffer, dwLength);
273 if (!dwLength || !pbuffer)
274 return E_POINTER;
276 ret = get_runtime_info(NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
278 if (SUCCEEDED(ret))
280 *dwLength = cchBuffer;
281 ret = ICLRRuntimeInfo_GetRuntimeDirectory(info, pbuffer, dwLength);
283 ICLRRuntimeInfo_Release(info);
286 return ret;
289 HRESULT WINAPI GetCORVersion(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
291 ICLRRuntimeInfo *info;
292 HRESULT ret;
294 TRACE("(%p, %d, %p)!\n", pbuffer, cchBuffer, dwLength);
296 if (!dwLength || !pbuffer)
297 return E_POINTER;
299 ret = get_runtime_info(NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
301 if (SUCCEEDED(ret))
303 *dwLength = cchBuffer;
304 ret = ICLRRuntimeInfo_GetVersionString(info, pbuffer, dwLength);
306 ICLRRuntimeInfo_Release(info);
309 return ret;
312 HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile,
313 DWORD startupFlags, DWORD runtimeInfoFlags, LPWSTR pDirectory, DWORD dwDirectory, DWORD *dwDirectoryLength,
314 LPWSTR pVersion, DWORD cchBuffer, DWORD *dwlength)
316 HRESULT ret;
317 ICLRRuntimeInfo *info;
318 DWORD length_dummy;
320 TRACE("(%s, %s, %s, 0x%08x, 0x%08x, %p, 0x%08x, %p, %p, 0x%08x, %p)\n", debugstr_w(pExe),
321 debugstr_w(pwszVersion), debugstr_w(pConfigurationFile), startupFlags, runtimeInfoFlags, pDirectory,
322 dwDirectory, dwDirectoryLength, pVersion, cchBuffer, dwlength);
324 if (!dwDirectoryLength) dwDirectoryLength = &length_dummy;
326 if (!dwlength) dwlength = &length_dummy;
328 ret = get_runtime_info(pExe, pwszVersion, pConfigurationFile, startupFlags, runtimeInfoFlags, TRUE, &info);
330 if (SUCCEEDED(ret))
332 *dwlength = cchBuffer;
333 ret = ICLRRuntimeInfo_GetVersionString(info, pVersion, dwlength);
335 if (SUCCEEDED(ret))
337 if(pwszVersion)
338 pVersion[0] = pwszVersion[0];
340 *dwDirectoryLength = dwDirectory;
341 ret = ICLRRuntimeInfo_GetRuntimeDirectory(info, pDirectory, dwDirectoryLength);
344 ICLRRuntimeInfo_Release(info);
347 return ret;
350 HRESULT WINAPI GetRequestedRuntimeVersion(LPWSTR pExe, LPWSTR pVersion, DWORD cchBuffer, DWORD *dwlength)
352 TRACE("(%s, %p, %d, %p)\n", debugstr_w(pExe), pVersion, cchBuffer, dwlength);
354 if(!dwlength)
355 return E_POINTER;
357 return GetRequestedRuntimeInfo(pExe, NULL, NULL, 0, 0, NULL, 0, NULL, pVersion, cchBuffer, dwlength);
360 HRESULT WINAPI GetRealProcAddress(LPCSTR procname, void **ppv)
362 FIXME("(%s, %p)\n", debugstr_a(procname), ppv);
363 return CLR_E_SHIM_RUNTIMEEXPORT;
366 HRESULT WINAPI GetFileVersion(LPCWSTR szFilename, LPWSTR szBuffer, DWORD cchBuffer, DWORD *dwLength)
368 TRACE("(%s, %p, %d, %p)\n", debugstr_w(szFilename), szBuffer, cchBuffer, dwLength);
370 if (!szFilename || !dwLength)
371 return E_POINTER;
373 *dwLength = cchBuffer;
374 return CLRMetaHost_GetVersionFromFile(0, szFilename, szBuffer, dwLength);
377 HRESULT WINAPI LoadLibraryShim( LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE * phModDll)
379 HRESULT ret=S_OK;
380 WCHAR dll_filename[MAX_PATH];
381 WCHAR version[MAX_PATH];
382 static const WCHAR default_version[] = {'v','1','.','1','.','4','3','2','2',0};
383 static const WCHAR slash[] = {'\\',0};
384 DWORD dummy;
386 TRACE("(%p %s, %p, %p, %p)\n", szDllName, debugstr_w(szDllName), szVersion, pvReserved, phModDll);
388 if (!szDllName || !phModDll)
389 return E_POINTER;
391 if (!get_install_root(dll_filename))
393 ERR("error reading registry key for installroot\n");
394 dll_filename[0] = 0;
396 else
398 if (!szVersion)
400 ret = GetCORVersion(version, MAX_PATH, &dummy);
401 if (SUCCEEDED(ret))
402 szVersion = version;
403 else
404 szVersion = default_version;
406 strcatW(dll_filename, szVersion);
407 strcatW(dll_filename, slash);
410 strcatW(dll_filename, szDllName);
412 *phModDll = LoadLibraryW(dll_filename);
414 return *phModDll ? S_OK : E_HANDLE;
417 HRESULT WINAPI LockClrVersion(FLockClrVersionCallback hostCallback, FLockClrVersionCallback *pBeginHostSetup, FLockClrVersionCallback *pEndHostSetup)
419 FIXME("(%p %p %p): stub\n", hostCallback, pBeginHostSetup, pEndHostSetup);
420 return S_OK;
423 HRESULT WINAPI CoInitializeCor(DWORD fFlags)
425 FIXME("(0x%08x): stub\n", fFlags);
426 return S_OK;
429 HRESULT WINAPI GetAssemblyMDImport(LPCWSTR szFileName, REFIID riid, IUnknown **ppIUnk)
431 FIXME("(%p %s, %s, %p): stub\n", szFileName, debugstr_w(szFileName), debugstr_guid(riid), *ppIUnk);
432 return ERROR_CALL_NOT_IMPLEMENTED;
435 HRESULT WINAPI GetVersionFromProcess(HANDLE hProcess, LPWSTR pVersion, DWORD cchBuffer, DWORD *dwLength)
437 FIXME("(%p, %p, %d, %p): stub\n", hProcess, pVersion, cchBuffer, dwLength);
438 return E_NOTIMPL;
441 HRESULT WINAPI LoadStringRCEx(LCID culture, UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet, int* pBufLen)
443 HRESULT res = S_OK;
444 if ((iBufLen <= 0) || !pBuffer)
445 return E_INVALIDARG;
446 pBuffer[0] = 0;
447 if (resId) {
448 FIXME("(%d, %x, %p, %d, %d, %p): semi-stub\n", culture, resId, pBuffer, iBufLen, bQuiet, pBufLen);
449 res = E_NOTIMPL;
451 else
452 res = E_FAIL;
453 if (pBufLen)
454 *pBufLen = lstrlenW(pBuffer);
455 return res;
458 HRESULT WINAPI LoadStringRC(UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet)
460 return LoadStringRCEx(-1, resId, pBuffer, iBufLen, bQuiet, NULL);
463 HRESULT WINAPI CorBindToRuntimeEx(LPWSTR szVersion, LPWSTR szBuildFlavor, DWORD nflags, REFCLSID rslsid,
464 REFIID riid, LPVOID *ppv)
466 HRESULT ret;
467 ICLRRuntimeInfo *info;
469 TRACE("%s %s %d %s %s %p\n", debugstr_w(szVersion), debugstr_w(szBuildFlavor), nflags, debugstr_guid( rslsid ),
470 debugstr_guid( riid ), ppv);
472 *ppv = NULL;
474 ret = get_runtime_info(NULL, szVersion, NULL, nflags, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
476 if (SUCCEEDED(ret))
478 ret = ICLRRuntimeInfo_GetInterface(info, rslsid, riid, ppv);
480 ICLRRuntimeInfo_Release(info);
483 return ret;
486 HRESULT WINAPI CorBindToCurrentRuntime(LPCWSTR filename, REFCLSID rclsid, REFIID riid, LPVOID *ppv)
488 HRESULT ret;
489 ICLRRuntimeInfo *info;
491 TRACE("(%s, %s, %s, %p)\n", debugstr_w(filename), debugstr_guid(rclsid), debugstr_guid(riid), ppv);
493 *ppv = NULL;
495 ret = get_runtime_info(NULL, NULL, filename, 0, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
497 if (SUCCEEDED(ret))
499 ret = ICLRRuntimeInfo_GetInterface(info, rclsid, riid, ppv);
501 ICLRRuntimeInfo_Release(info);
504 return ret;
507 STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void **ppObject)
509 HRESULT ret;
510 ICLRRuntimeInfo *info;
511 RuntimeHost *host;
512 MonoObject *obj;
513 IUnknown *unk;
515 TRACE("(%s,%s,%p)\n", debugstr_w(pTypeName), debugstr_guid(riid), ppObject);
517 /* FIXME: How to determine which runtime version to use? */
518 ret = get_runtime_info(NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, TRUE, &info);
520 if (SUCCEEDED(ret))
522 ret = ICLRRuntimeInfo_GetRuntimeHost(info, &host);
524 ICLRRuntimeInfo_Release(info);
527 if (SUCCEEDED(ret))
528 ret = RuntimeHost_CreateManagedInstance(host, pTypeName, NULL, &obj);
530 if (SUCCEEDED(ret))
531 ret = RuntimeHost_GetIUnknownForObject(host, obj, &unk);
533 if (SUCCEEDED(ret))
535 ret = IUnknown_QueryInterface(unk, riid, ppObject);
536 IUnknown_Release(unk);
539 return ret;
542 BOOL WINAPI StrongNameSignatureVerification(LPCWSTR filename, DWORD inFlags, DWORD* pOutFlags)
544 FIXME("(%s, 0x%X, %p): stub\n", debugstr_w(filename), inFlags, pOutFlags);
545 return FALSE;
548 BOOL WINAPI StrongNameSignatureVerificationEx(LPCWSTR filename, BOOL forceVerification, BOOL* pVerified)
550 FIXME("(%s, %u, %p): stub\n", debugstr_w(filename), forceVerification, pVerified);
551 return FALSE;
554 HRESULT WINAPI CreateConfigStream(LPCWSTR filename, IStream **stream)
556 FIXME("(%s, %p): stub\n", debugstr_w(filename), stream);
557 return E_NOTIMPL;
560 HRESULT WINAPI CreateDebuggingInterfaceFromVersion(int nDebugVersion, LPCWSTR version, IUnknown **ppv)
562 const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
563 HRESULT hr = E_FAIL;
564 ICLRRuntimeInfo *runtimeinfo;
566 if(nDebugVersion < 1 || nDebugVersion > 4)
567 return E_INVALIDARG;
569 TRACE("(%d %s, %p): stub\n", nDebugVersion, debugstr_w(version), ppv);
571 if(!ppv)
572 return E_INVALIDARG;
574 *ppv = NULL;
576 if(strcmpW(version, v2_0) != 0)
578 FIXME("Currently .NET Version '%s' not support.\n", debugstr_w(version));
579 return E_INVALIDARG;
582 if(nDebugVersion != 3)
583 return E_INVALIDARG;
585 hr = CLRMetaHost_GetRuntime(0, version, &IID_ICLRRuntimeInfo, (void**)&runtimeinfo);
586 if(hr == S_OK)
588 hr = ICLRRuntimeInfo_GetInterface(runtimeinfo, &CLSID_CLRDebuggingLegacy, &IID_ICorDebug, (void**)ppv);
590 ICLRRuntimeInfo_Release(runtimeinfo);
593 if(!*ppv)
594 return E_FAIL;
596 return hr;
599 HRESULT WINAPI CLRCreateInstance(REFCLSID clsid, REFIID riid, LPVOID *ppInterface)
601 TRACE("(%s,%s,%p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppInterface);
603 if (IsEqualGUID(clsid, &CLSID_CLRMetaHost))
604 return CLRMetaHost_CreateInstance(riid, ppInterface);
605 if (IsEqualGUID(clsid, &CLSID_CLRMetaHostPolicy))
606 return CLRMetaHostPolicy_CreateInstance(riid, ppInterface);
608 FIXME("not implemented for class %s\n", debugstr_guid(clsid));
610 return CLASS_E_CLASSNOTAVAILABLE;
613 HRESULT WINAPI CreateInterface(REFCLSID clsid, REFIID riid, LPVOID *ppInterface)
615 TRACE("(%s,%s,%p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppInterface);
617 return CLRCreateInstance(clsid, riid, ppInterface);
620 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
622 mscorecf *This;
623 HRESULT hr;
625 TRACE("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
627 if(!ppv)
628 return E_INVALIDARG;
630 This = HeapAlloc(GetProcessHeap(), 0, sizeof(mscorecf));
632 This->IClassFactory_iface.lpVtbl = &mscorecf_vtbl;
633 This->pfnCreateInstance = create_monodata;
634 This->ref = 1;
635 This->clsid = *rclsid;
637 hr = IClassFactory_QueryInterface( &This->IClassFactory_iface, riid, ppv );
638 IClassFactory_Release(&This->IClassFactory_iface);
640 return hr;
643 static void parse_msi_version_string(const char *version, int *parts)
645 const char *minor_start, *build_start;
647 parts[0] = atoi(version);
649 parts[1] = parts[2] = 0;
651 minor_start = strchr(version, '.');
652 if (minor_start)
654 minor_start++;
655 parts[1] = atoi(minor_start);
657 build_start = strchr(minor_start, '.');
658 if (build_start)
659 parts[2] = atoi(build_start+1);
663 static BOOL install_wine_mono(void)
665 BOOL is_wow64 = FALSE;
666 HMODULE hmsi;
667 UINT (WINAPI *pMsiGetProductInfoA)(LPCSTR,LPCSTR,LPSTR,DWORD*);
668 char versionstringbuf[15];
669 UINT res;
670 DWORD buffer_size;
671 PROCESS_INFORMATION pi;
672 STARTUPINFOW si;
673 WCHAR app[MAX_PATH];
674 WCHAR *args;
675 LONG len;
676 BOOL ret;
678 static const char* mono_version = "4.6.2";
679 static const char* mono_product_code = "{E45D8920-A758-4088-B6C6-31DBB276992E}";
681 static const WCHAR controlW[] = {'\\','c','o','n','t','r','o','l','.','e','x','e',0};
682 static const WCHAR argsW[] =
683 {' ','a','p','p','w','i','z','.','c','p','l',' ','i','n','s','t','a','l','l','_','m','o','n','o',0};
685 IsWow64Process(GetCurrentProcess(), &is_wow64);
687 if (is_wow64)
689 TRACE("not installing mono in wow64 process\n");
690 return TRUE;
693 hmsi = LoadLibraryA("msi");
695 if (!hmsi)
697 ERR("couldn't load msi.dll\n");
698 return FALSE;
701 pMsiGetProductInfoA = (void*)GetProcAddress(hmsi, "MsiGetProductInfoA");
703 buffer_size = sizeof(versionstringbuf);
705 res = pMsiGetProductInfoA(mono_product_code, "VersionString", versionstringbuf, &buffer_size);
707 FreeLibrary(hmsi);
709 if (res == ERROR_SUCCESS)
711 int current_version[3], wanted_version[3], i;
713 TRACE("found installed version %s\n", versionstringbuf);
715 parse_msi_version_string(versionstringbuf, current_version);
716 parse_msi_version_string(mono_version, wanted_version);
718 for (i=0; i<3; i++)
720 if (current_version[i] < wanted_version[i])
721 break;
722 else if (current_version[i] > wanted_version[i])
724 TRACE("installed version is newer than %s, quitting\n", mono_version);
725 return TRUE;
729 if (i == 3)
731 TRACE("version %s is already installed, quitting\n", mono_version);
732 return TRUE;
736 len = GetSystemDirectoryW(app, MAX_PATH-sizeof(controlW)/sizeof(WCHAR));
737 memcpy(app+len, controlW, sizeof(controlW));
739 args = HeapAlloc(GetProcessHeap(), 0, (len*sizeof(WCHAR) + sizeof(controlW) + sizeof(argsW)));
740 if(!args)
741 return FALSE;
743 memcpy(args, app, len*sizeof(WCHAR) + sizeof(controlW));
744 memcpy(args + len + sizeof(controlW)/sizeof(WCHAR)-1, argsW, sizeof(argsW));
746 TRACE("starting %s\n", debugstr_w(args));
748 memset(&si, 0, sizeof(si));
749 si.cb = sizeof(si);
750 ret = CreateProcessW(app, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
751 HeapFree(GetProcessHeap(), 0, args);
752 if (ret) {
753 CloseHandle(pi.hThread);
754 WaitForSingleObject(pi.hProcess, INFINITE);
755 CloseHandle(pi.hProcess);
758 return ret;
761 HRESULT WINAPI DllRegisterServer(void)
763 install_wine_mono();
765 return __wine_register_resources( MSCOREE_hInstance );
768 HRESULT WINAPI DllUnregisterServer(void)
770 return __wine_unregister_resources( MSCOREE_hInstance );
773 HRESULT WINAPI DllCanUnloadNow(VOID)
775 return S_FALSE;
778 void WINAPI CoEEShutDownCOM(void)
780 FIXME("stub.\n");
783 INT WINAPI ND_RU1( const void *ptr, INT offset )
785 return *((const BYTE *)ptr + offset);
788 INT WINAPI ND_RI2( const void *ptr, INT offset )
790 return *(const SHORT *)((const BYTE *)ptr + offset);
793 INT WINAPI ND_RI4( const void *ptr, INT offset )
795 return *(const INT *)((const BYTE *)ptr + offset);
798 INT64 WINAPI ND_RI8( const void *ptr, INT offset )
800 return *(const INT64 *)((const BYTE *)ptr + offset);
803 void WINAPI ND_WU1( void *ptr, INT offset, BYTE val )
805 *((BYTE *)ptr + offset) = val;
808 void WINAPI ND_WI2( void *ptr, INT offset, SHORT val )
810 *(SHORT *)((BYTE *)ptr + offset) = val;
813 void WINAPI ND_WI4( void *ptr, INT offset, INT val )
815 *(INT *)((BYTE *)ptr + offset) = val;
818 void WINAPI ND_WI8( void *ptr, INT offset, INT64 val )
820 *(INT64 *)((BYTE *)ptr + offset) = val;
823 void WINAPI ND_CopyObjDst( const void *src, void *dst, INT offset, INT size )
825 memcpy( (BYTE *)dst + offset, src, size );
828 void WINAPI ND_CopyObjSrc( const void *src, INT offset, void *dst, INT size )
830 memcpy( dst, (const BYTE *)src + offset, size );