2006-10-06 11:21:02 +02:00
|
|
|
/*
|
|
|
|
* Implementation of mscoree.dll
|
|
|
|
* Microsoft Component Object Runtime Execution Engine
|
|
|
|
*
|
|
|
|
* Copyright 2006 Paul Chitescu
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
#include "wine/unicode.h"
|
2010-09-21 20:26:04 +02:00
|
|
|
#include "wine/library.h"
|
2006-10-06 11:21:02 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2006-11-01 21:42:30 +01:00
|
|
|
#include "winuser.h"
|
2010-04-02 22:33:12 +02:00
|
|
|
#include "winnls.h"
|
2006-12-11 22:13:48 +01:00
|
|
|
#include "winreg.h"
|
2006-11-01 21:42:30 +01:00
|
|
|
#include "ole2.h"
|
2010-04-02 22:33:12 +02:00
|
|
|
#include "shellapi.h"
|
2006-10-06 11:21:02 +02:00
|
|
|
|
2008-03-28 11:10:55 +01:00
|
|
|
#include "initguid.h"
|
2007-08-04 03:16:33 +02:00
|
|
|
#include "cor.h"
|
2010-08-26 00:14:41 +02:00
|
|
|
#include "corerror.h"
|
2007-08-04 03:16:33 +02:00
|
|
|
#include "mscoree.h"
|
2008-03-28 11:10:55 +01:00
|
|
|
#include "mscoree_private.h"
|
2007-08-04 03:16:33 +02:00
|
|
|
|
2006-10-06 11:21:02 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
|
|
|
|
|
2010-09-21 20:26:04 +02:00
|
|
|
BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path, int* abi_version)
|
|
|
|
{
|
|
|
|
static const WCHAR mono_dll[] = {'\\','b','i','n','\\','m','o','n','o','.','d','l','l',0};
|
|
|
|
static const WCHAR libmono_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','.','d','l','l',0};
|
|
|
|
DWORD attributes;
|
|
|
|
|
|
|
|
strcpyW(dll_path, path);
|
|
|
|
strcatW(dll_path, mono_dll);
|
|
|
|
attributes = GetFileAttributesW(dll_path);
|
|
|
|
|
|
|
|
if (attributes == INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
strcpyW(dll_path, path);
|
|
|
|
strcatW(dll_path, libmono_dll);
|
|
|
|
attributes = GetFileAttributesW(dll_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attributes != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
/* FIXME: Test for appropriate architecture. */
|
|
|
|
*abi_version = 1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_mono_path_from_registry(LPWSTR path)
|
2006-12-11 22:13:48 +01:00
|
|
|
{
|
|
|
|
static const WCHAR mono_key[] = {'S','o','f','t','w','a','r','e','\\','N','o','v','e','l','l','\\','M','o','n','o',0};
|
|
|
|
static const WCHAR defaul_clr[] = {'D','e','f','a','u','l','t','C','L','R',0};
|
|
|
|
static const WCHAR install_root[] = {'S','d','k','I','n','s','t','a','l','l','R','o','o','t',0};
|
|
|
|
static const WCHAR slash[] = {'\\',0};
|
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
WCHAR version[64], version_key[MAX_PATH];
|
|
|
|
DWORD len;
|
2006-12-11 22:13:48 +01:00
|
|
|
HKEY key;
|
2010-09-21 20:26:04 +02:00
|
|
|
WCHAR dll_path[MAX_PATH];
|
|
|
|
int abi_version;
|
2006-12-11 22:13:48 +01:00
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, mono_key, 0, KEY_READ, &key))
|
2010-04-02 22:33:12 +02:00
|
|
|
return FALSE;
|
2006-12-11 22:13:48 +01:00
|
|
|
|
|
|
|
len = sizeof(version);
|
|
|
|
if (RegQueryValueExW(key, defaul_clr, 0, NULL, (LPBYTE)version, &len))
|
|
|
|
{
|
|
|
|
RegCloseKey(key);
|
2010-04-02 22:33:12 +02:00
|
|
|
return FALSE;
|
2006-12-11 22:13:48 +01:00
|
|
|
}
|
|
|
|
RegCloseKey(key);
|
|
|
|
|
|
|
|
lstrcpyW(version_key, mono_key);
|
|
|
|
lstrcatW(version_key, slash);
|
|
|
|
lstrcatW(version_key, version);
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, version_key, 0, KEY_READ, &key))
|
2010-04-02 22:33:12 +02:00
|
|
|
return FALSE;
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
len = sizeof(WCHAR) * MAX_PATH;
|
|
|
|
if (RegQueryValueExW(key, install_root, 0, NULL, (LPBYTE)path, &len))
|
2006-12-11 22:13:48 +01:00
|
|
|
{
|
|
|
|
RegCloseKey(key);
|
2010-04-02 22:33:12 +02:00
|
|
|
return FALSE;
|
2006-12-11 22:13:48 +01:00
|
|
|
}
|
|
|
|
RegCloseKey(key);
|
|
|
|
|
2010-09-21 20:26:04 +02:00
|
|
|
return find_mono_dll(path, dll_path, &abi_version);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_mono_path_from_folder(LPCWSTR folder, LPWSTR mono_path)
|
|
|
|
{
|
|
|
|
static const WCHAR mono_one_dot_zero[] = {'\\','m','o','n','o','-','1','.','0', 0};
|
|
|
|
WCHAR mono_dll_path[MAX_PATH];
|
|
|
|
int abi_version;
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
|
|
|
strcpyW(mono_path, folder);
|
|
|
|
strcatW(mono_path, mono_one_dot_zero);
|
|
|
|
|
|
|
|
found = find_mono_dll(mono_path, mono_dll_path, &abi_version);
|
|
|
|
|
|
|
|
if (found && abi_version != 1)
|
|
|
|
{
|
|
|
|
ERR("found wrong ABI in %s\n", debugstr_w(mono_path));
|
|
|
|
found = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_mono_path(LPWSTR path)
|
|
|
|
{
|
|
|
|
static const WCHAR subdir_mono[] = {'\\','m','o','n','o',0};
|
|
|
|
static const WCHAR sibling_mono[] = {'\\','.','.','\\','m','o','n','o',0};
|
|
|
|
WCHAR base_path[MAX_PATH];
|
|
|
|
const char *unix_data_dir;
|
|
|
|
WCHAR *dos_data_dir;
|
|
|
|
int build_tree=0;
|
|
|
|
static WCHAR* (CDECL *wine_get_dos_file_name)(const char*);
|
|
|
|
|
|
|
|
/* First try c:\windows\mono */
|
|
|
|
GetWindowsDirectoryW(base_path, MAX_PATH);
|
|
|
|
strcatW(base_path, subdir_mono);
|
|
|
|
|
|
|
|
if (get_mono_path_from_folder(base_path, path))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* Next: /usr/share/wine/mono */
|
|
|
|
unix_data_dir = wine_get_data_dir();
|
|
|
|
|
|
|
|
if (!unix_data_dir)
|
|
|
|
{
|
|
|
|
unix_data_dir = wine_get_build_dir();
|
|
|
|
build_tree = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unix_data_dir)
|
|
|
|
{
|
|
|
|
if (!wine_get_dos_file_name)
|
|
|
|
wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleA("kernel32"), "wine_get_dos_file_name");
|
|
|
|
|
|
|
|
if (wine_get_dos_file_name)
|
|
|
|
{
|
|
|
|
dos_data_dir = wine_get_dos_file_name(unix_data_dir);
|
|
|
|
|
|
|
|
if (dos_data_dir)
|
|
|
|
{
|
|
|
|
strcpyW(base_path, dos_data_dir);
|
|
|
|
strcatW(base_path, build_tree ? sibling_mono : subdir_mono);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, dos_data_dir);
|
|
|
|
|
|
|
|
if (get_mono_path_from_folder(base_path, path))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Last: the registry */
|
|
|
|
return get_mono_path_from_registry(path);
|
2010-04-02 22:33:12 +02:00
|
|
|
}
|
|
|
|
|
2010-08-25 14:53:05 +02:00
|
|
|
static BOOL get_install_root(LPWSTR install_dir)
|
|
|
|
{
|
|
|
|
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};
|
|
|
|
const WCHAR install_root[] = {'I','n','s','t','a','l','l','R','o','o','t',0};
|
|
|
|
|
|
|
|
DWORD len;
|
|
|
|
HKEY key;
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, dotnet_key, 0, KEY_READ, &key))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
len = MAX_PATH;
|
|
|
|
if (RegQueryValueExW(key, install_root, 0, NULL, (LPBYTE)install_dir, &len))
|
|
|
|
{
|
|
|
|
RegCloseKey(key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
RegCloseKey(key);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
static CRITICAL_SECTION mono_lib_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG mono_lib_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &mono_lib_cs,
|
|
|
|
{ &mono_lib_cs_debug.ProcessLocksList,
|
|
|
|
&mono_lib_cs_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": mono_lib_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION mono_lib_cs = { &mono_lib_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
HMODULE mono_handle;
|
|
|
|
|
|
|
|
void (*mono_config_parse)(const char *filename);
|
|
|
|
MonoAssembly* (*mono_domain_assembly_open) (MonoDomain *domain, const char *name);
|
|
|
|
void (*mono_jit_cleanup)(MonoDomain *domain);
|
|
|
|
int (*mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
|
|
|
|
MonoDomain* (*mono_jit_init)(const char *file);
|
|
|
|
int (*mono_jit_set_trace_options)(const char* options);
|
|
|
|
void (*mono_set_dirs)(const char *assembly_dir, const char *config_dir);
|
|
|
|
|
|
|
|
static void set_environment(LPCWSTR bin_path)
|
|
|
|
{
|
|
|
|
WCHAR path_env[MAX_PATH];
|
|
|
|
int len;
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
static const WCHAR pathW[] = {'P','A','T','H',0};
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
/* We have to modify PATH as Mono loads other DLLs from this directory. */
|
|
|
|
GetEnvironmentVariableW(pathW, path_env, sizeof(path_env)/sizeof(WCHAR));
|
|
|
|
len = strlenW(path_env);
|
|
|
|
path_env[len++] = ';';
|
|
|
|
strcpyW(path_env+len, bin_path);
|
|
|
|
SetEnvironmentVariableW(pathW, path_env);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HMODULE load_mono(void)
|
|
|
|
{
|
|
|
|
static const WCHAR bin[] = {'\\','b','i','n',0};
|
|
|
|
static const WCHAR lib[] = {'\\','l','i','b',0};
|
|
|
|
static const WCHAR etc[] = {'\\','e','t','c',0};
|
|
|
|
HMODULE result;
|
|
|
|
WCHAR mono_path[MAX_PATH], mono_dll_path[MAX_PATH+16], mono_bin_path[MAX_PATH+4];
|
|
|
|
WCHAR mono_lib_path[MAX_PATH+4], mono_etc_path[MAX_PATH+4];
|
|
|
|
char mono_lib_path_a[MAX_PATH], mono_etc_path_a[MAX_PATH];
|
2010-09-21 20:26:04 +02:00
|
|
|
int abi_version;
|
2010-04-02 22:33:12 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&mono_lib_cs);
|
|
|
|
|
|
|
|
if (!mono_handle)
|
|
|
|
{
|
|
|
|
if (!get_mono_path(mono_path)) goto end;
|
|
|
|
|
|
|
|
strcpyW(mono_bin_path, mono_path);
|
|
|
|
strcatW(mono_bin_path, bin);
|
|
|
|
set_environment(mono_bin_path);
|
|
|
|
|
|
|
|
strcpyW(mono_lib_path, mono_path);
|
|
|
|
strcatW(mono_lib_path, lib);
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, mono_lib_path, -1, mono_lib_path_a, MAX_PATH, NULL, NULL);
|
|
|
|
|
|
|
|
strcpyW(mono_etc_path, mono_path);
|
|
|
|
strcatW(mono_etc_path, etc);
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL);
|
|
|
|
|
2010-09-21 20:26:04 +02:00
|
|
|
if (!find_mono_dll(mono_path, mono_dll_path, &abi_version)) goto end;
|
2010-04-02 22:33:12 +02:00
|
|
|
|
2010-09-21 20:26:04 +02:00
|
|
|
if (abi_version != 1) goto end;
|
|
|
|
|
|
|
|
mono_handle = LoadLibraryW(mono_dll_path);
|
2010-04-02 22:33:12 +02:00
|
|
|
|
|
|
|
if (!mono_handle) goto end;
|
|
|
|
|
|
|
|
#define LOAD_MONO_FUNCTION(x) do { \
|
|
|
|
x = (void*)GetProcAddress(mono_handle, #x); \
|
|
|
|
if (!x) { \
|
|
|
|
mono_handle = NULL; \
|
|
|
|
goto end; \
|
|
|
|
} \
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
LOAD_MONO_FUNCTION(mono_config_parse);
|
|
|
|
LOAD_MONO_FUNCTION(mono_domain_assembly_open);
|
|
|
|
LOAD_MONO_FUNCTION(mono_jit_cleanup);
|
|
|
|
LOAD_MONO_FUNCTION(mono_jit_exec);
|
|
|
|
LOAD_MONO_FUNCTION(mono_jit_init);
|
|
|
|
LOAD_MONO_FUNCTION(mono_jit_set_trace_options);
|
|
|
|
LOAD_MONO_FUNCTION(mono_set_dirs);
|
|
|
|
|
|
|
|
#undef LOAD_MONO_FUNCTION
|
|
|
|
|
|
|
|
mono_set_dirs(mono_lib_path_a, mono_etc_path_a);
|
|
|
|
|
|
|
|
mono_config_parse(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
result = mono_handle;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&mono_lib_cs);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
MESSAGE("wine: Install the Windows version of Mono to run .NET executables\n");
|
|
|
|
|
|
|
|
return result;
|
2006-12-11 22:13:48 +01:00
|
|
|
}
|
|
|
|
|
2007-08-23 22:22:28 +02:00
|
|
|
HRESULT WINAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor,
|
|
|
|
LPCWSTR pwszHostConfigFile, VOID *pReserved,
|
|
|
|
DWORD startupFlags, REFCLSID rclsid,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2010-03-25 21:26:43 +01:00
|
|
|
FIXME("(%s, %s, %s, %p, %d, %s, %s, %p): semi-stub!\n", debugstr_w(pwszVersion),
|
2007-08-23 22:22:28 +02:00
|
|
|
debugstr_w(pwszBuildFlavor), debugstr_w(pwszHostConfigFile), pReserved,
|
2010-03-25 21:26:43 +01:00
|
|
|
startupFlags, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
2007-08-23 22:22:28 +02:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
if (!get_mono_path(NULL))
|
2007-08-23 22:22:28 +02:00
|
|
|
{
|
|
|
|
MESSAGE("wine: Install the Windows version of Mono to run .NET executables\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI _CorDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %p): stub\n", hinstDLL, fdwReason, lpvReserved);
|
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
static void get_utf8_args(int *argc, char ***argv)
|
2006-10-06 11:21:02 +02:00
|
|
|
{
|
2010-04-02 22:33:12 +02:00
|
|
|
WCHAR **argvw;
|
|
|
|
int size=0, i;
|
|
|
|
char *current_arg;
|
|
|
|
|
|
|
|
argvw = CommandLineToArgvW(GetCommandLineW(), argc);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
for (i=0; i<*argc; i++)
|
2006-12-11 22:13:48 +01:00
|
|
|
{
|
2010-04-02 22:33:12 +02:00
|
|
|
size += sizeof(char*);
|
|
|
|
size += WideCharToMultiByte(CP_UTF8, 0, argvw[i], -1, NULL, 0, NULL, NULL);
|
2006-12-11 22:13:48 +01:00
|
|
|
}
|
2010-04-02 22:33:12 +02:00
|
|
|
size += sizeof(char*);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
*argv = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
current_arg = (char*)(*argv + *argc + 1);
|
2010-03-24 19:35:57 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
for (i=0; i<*argc; i++)
|
|
|
|
{
|
|
|
|
(*argv)[i] = current_arg;
|
|
|
|
current_arg += WideCharToMultiByte(CP_UTF8, 0, argvw[i], -1, current_arg, size, NULL, NULL);
|
|
|
|
}
|
2010-03-24 19:35:57 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
(*argv)[*argc] = NULL;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, argvw);
|
|
|
|
}
|
2010-03-24 19:35:57 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
__int32 WINAPI _CorExeMain(void)
|
|
|
|
{
|
|
|
|
int exit_code;
|
|
|
|
int trace_size;
|
|
|
|
char trace_setting[256];
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
MonoDomain *domain;
|
|
|
|
MonoAssembly *assembly;
|
|
|
|
char filename[MAX_PATH];
|
|
|
|
|
|
|
|
if (!load_mono())
|
2006-12-11 22:13:48 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
get_utf8_args(&argc, &argv);
|
|
|
|
|
|
|
|
trace_size = GetEnvironmentVariableA("WINE_MONO_TRACE", trace_setting, sizeof(trace_setting));
|
2010-03-24 19:35:57 +01:00
|
|
|
|
|
|
|
if (trace_size)
|
|
|
|
{
|
2010-04-02 22:33:12 +02:00
|
|
|
mono_jit_set_trace_options(trace_setting);
|
2010-03-24 19:35:57 +01:00
|
|
|
}
|
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
GetModuleFileNameA(NULL, filename, MAX_PATH);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
domain = mono_jit_init(filename);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
assembly = mono_domain_assembly_open(domain, filename);
|
|
|
|
|
|
|
|
exit_code = mono_jit_exec(domain, assembly, argc, argv);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
mono_jit_cleanup(domain);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, argv);
|
2006-12-11 22:13:48 +01:00
|
|
|
|
2010-04-02 22:33:12 +02:00
|
|
|
return exit_code;
|
2006-10-06 11:21:02 +02:00
|
|
|
}
|
|
|
|
|
2007-08-04 03:16:33 +02:00
|
|
|
__int32 WINAPI _CorExeMain2(PBYTE ptrMemory, DWORD cntMemory, LPWSTR imageName, LPWSTR loaderName, LPWSTR cmdLine)
|
2006-10-06 11:21:02 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %u, %s, %s, %s)\n", ptrMemory, cntMemory, debugstr_w(imageName), debugstr_w(loaderName), debugstr_w(cmdLine));
|
|
|
|
FIXME("Directly running .NET applications not supported.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-11 14:25:39 +01:00
|
|
|
void WINAPI CorExitProcess(int exitCode)
|
|
|
|
{
|
|
|
|
FIXME("(%x) stub\n", exitCode);
|
|
|
|
ExitProcess(exitCode);
|
|
|
|
}
|
|
|
|
|
2007-08-04 03:16:33 +02:00
|
|
|
VOID WINAPI _CorImageUnloading(PVOID imageBase)
|
2006-10-06 11:21:02 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p): stub\n", imageBase);
|
|
|
|
}
|
|
|
|
|
2007-08-04 03:16:33 +02:00
|
|
|
HRESULT WINAPI _CorValidateImage(PVOID* imageBase, LPCWSTR imageName)
|
2006-10-06 11:21:02 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %s): stub\n", imageBase, debugstr_w(imageName));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2006-10-13 23:07:17 +02:00
|
|
|
|
2006-12-18 10:40:13 +01:00
|
|
|
HRESULT WINAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
|
|
|
|
{
|
2010-08-25 14:53:05 +02:00
|
|
|
static const WCHAR slash[] = {'\\',0};
|
|
|
|
WCHAR system_dir[MAX_PATH];
|
|
|
|
WCHAR version[MAX_PATH];
|
|
|
|
|
|
|
|
FIXME("(%p, %d, %p): semi-stub!\n", pbuffer, cchBuffer, dwLength);
|
2006-12-18 10:40:13 +01:00
|
|
|
|
|
|
|
if (!dwLength)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2010-08-25 14:53:05 +02:00
|
|
|
if (!pbuffer)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
|
|
|
|
if (!get_install_root(system_dir))
|
|
|
|
{
|
|
|
|
ERR("error reading registry key for installroot, returning empty path\n");
|
|
|
|
*dwLength = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetCORVersion(version, MAX_PATH, dwLength);
|
|
|
|
lstrcatW(system_dir, version);
|
|
|
|
lstrcatW(system_dir, slash);
|
|
|
|
*dwLength = lstrlenW(system_dir) + 1;
|
|
|
|
|
|
|
|
if (cchBuffer < *dwLength)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
|
|
|
|
lstrcpyW(pbuffer, system_dir);
|
|
|
|
}
|
2006-12-18 10:40:13 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-10-13 23:07:17 +02:00
|
|
|
HRESULT WINAPI GetCORVersion(LPWSTR pbuffer, DWORD cchBuffer, DWORD *dwLength)
|
|
|
|
{
|
2010-08-24 12:51:33 +02:00
|
|
|
static const WCHAR version[] = {'v','2','.','0','.','5','0','7','2','7',0};
|
2006-10-13 23:07:17 +02:00
|
|
|
|
|
|
|
FIXME("(%p, %d, %p): semi-stub!\n", pbuffer, cchBuffer, dwLength);
|
|
|
|
|
2010-08-24 12:51:33 +02:00
|
|
|
if (!dwLength || !pbuffer)
|
2006-10-13 23:07:17 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2010-08-25 14:53:05 +02:00
|
|
|
*dwLength = lstrlenW(version) + 1;
|
2006-10-13 23:07:17 +02:00
|
|
|
|
|
|
|
if (cchBuffer < *dwLength)
|
2010-08-24 12:51:33 +02:00
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
2006-10-13 23:07:17 +02:00
|
|
|
|
2010-08-24 12:51:33 +02:00
|
|
|
lstrcpyW(pbuffer, version);
|
2006-10-13 23:07:17 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-11-01 21:42:30 +01:00
|
|
|
|
2006-12-11 14:25:39 +01:00
|
|
|
HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile,
|
|
|
|
DWORD startupFlags, DWORD runtimeInfoFlags, LPWSTR pDirectory, DWORD dwDirectory, DWORD *dwDirectoryLength,
|
|
|
|
LPWSTR pVersion, DWORD cchBuffer, DWORD *dwlength)
|
|
|
|
{
|
2010-08-26 00:14:41 +02:00
|
|
|
HRESULT ret;
|
|
|
|
DWORD ver_len, dir_len;
|
|
|
|
WCHAR dirW[MAX_PATH], verW[MAX_PATH];
|
|
|
|
|
|
|
|
FIXME("(%s, %s, %s, 0x%08x, 0x%08x, %p, 0x%08x, %p, %p, 0x%08x, %p) semi-stub\n", debugstr_w(pExe),
|
2006-12-11 14:25:39 +01:00
|
|
|
debugstr_w(pwszVersion), debugstr_w(pConfigurationFile), startupFlags, runtimeInfoFlags, pDirectory,
|
|
|
|
dwDirectory, dwDirectoryLength, pVersion, cchBuffer, dwlength);
|
2010-08-26 00:14:41 +02:00
|
|
|
|
|
|
|
if (!pwszVersion && !(runtimeInfoFlags & RUNTIME_INFO_UPGRADE_VERSION))
|
|
|
|
return CLR_E_SHIM_RUNTIME;
|
|
|
|
|
|
|
|
ret = GetCORSystemDirectory(dirW, dwDirectory, &dir_len);
|
|
|
|
|
|
|
|
if (ret == S_OK)
|
|
|
|
{
|
|
|
|
if (dwDirectoryLength)
|
|
|
|
*dwDirectoryLength = dir_len;
|
|
|
|
if (pDirectory)
|
|
|
|
lstrcpyW(pDirectory, dirW);
|
|
|
|
|
|
|
|
ret = GetCORVersion(verW, cchBuffer, &ver_len);
|
|
|
|
|
|
|
|
if (ret == S_OK)
|
|
|
|
{
|
|
|
|
if (dwlength)
|
|
|
|
*dwlength = ver_len;
|
|
|
|
if (pVersion)
|
|
|
|
lstrcpyW(pVersion, verW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
2006-12-11 14:25:39 +01:00
|
|
|
}
|
|
|
|
|
2006-11-01 21:42:30 +01:00
|
|
|
HRESULT WINAPI LoadLibraryShim( LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE * phModDll)
|
|
|
|
{
|
|
|
|
FIXME("(%p %s, %p, %p, %p): semi-stub\n", szDllName, debugstr_w(szDllName), szVersion, pvReserved, phModDll);
|
2006-12-11 14:25:39 +01:00
|
|
|
|
|
|
|
if (phModDll) *phModDll = LoadLibraryW(szDllName);
|
2006-11-01 21:42:30 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-12-20 05:09:28 +01:00
|
|
|
HRESULT WINAPI LockClrVersion(FLockClrVersionCallback hostCallback, FLockClrVersionCallback *pBeginHostSetup, FLockClrVersionCallback *pEndHostSetup)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %p): stub\n", hostCallback, pBeginHostSetup, pEndHostSetup);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-11-01 21:42:30 +01:00
|
|
|
HRESULT WINAPI CoInitializeCor(DWORD fFlags)
|
|
|
|
{
|
|
|
|
FIXME("(0x%08x): stub\n", fFlags);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI GetAssemblyMDImport(LPCWSTR szFileName, REFIID riid, IUnknown **ppIUnk)
|
|
|
|
{
|
2010-03-25 21:26:43 +01:00
|
|
|
FIXME("(%p %s, %s, %p): stub\n", szFileName, debugstr_w(szFileName), debugstr_guid(riid), *ppIUnk);
|
2006-11-01 21:42:30 +01:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
2007-12-18 15:55:17 +01:00
|
|
|
|
|
|
|
HRESULT WINAPI GetVersionFromProcess(HANDLE hProcess, LPWSTR pVersion, DWORD cchBuffer, DWORD *dwLength)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %d, %p): stub\n", hProcess, pVersion, cchBuffer, dwLength);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2008-01-10 05:44:31 +01:00
|
|
|
|
2008-01-21 17:07:43 +01:00
|
|
|
HRESULT WINAPI LoadStringRCEx(LCID culture, UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet, int* pBufLen)
|
|
|
|
{
|
|
|
|
HRESULT res = S_OK;
|
|
|
|
if ((iBufLen <= 0) || !pBuffer)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
pBuffer[0] = 0;
|
|
|
|
if (resId) {
|
|
|
|
FIXME("(%d, %x, %p, %d, %d, %p): semi-stub\n", culture, resId, pBuffer, iBufLen, bQuiet, pBufLen);
|
|
|
|
res = E_NOTIMPL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = E_FAIL;
|
|
|
|
if (pBufLen)
|
|
|
|
*pBufLen = lstrlenW(pBuffer);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI LoadStringRC(UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet)
|
|
|
|
{
|
|
|
|
return LoadStringRCEx(-1, resId, pBuffer, iBufLen, bQuiet, NULL);
|
|
|
|
}
|
|
|
|
|
2008-03-14 11:27:42 +01:00
|
|
|
HRESULT WINAPI CorBindToRuntimeEx(LPWSTR szVersion, LPWSTR szBuildFlavor, DWORD nflags, REFCLSID rslsid,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %d %s %s %p\n", debugstr_w(szVersion), debugstr_w(szBuildFlavor), nflags, debugstr_guid( rslsid ),
|
|
|
|
debugstr_guid( riid ), ppv);
|
|
|
|
|
2008-03-28 11:10:55 +01:00
|
|
|
if(IsEqualGUID( riid, &IID_ICorRuntimeHost ))
|
|
|
|
{
|
|
|
|
*ppv = create_corruntimehost();
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-03-14 11:27:42 +01:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-06-08 22:03:22 +02:00
|
|
|
HRESULT WINAPI CorBindToCurrentRuntime(LPCWSTR filename, REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %s, %s, %p): stub\n", debugstr_w(filename), debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-03-26 22:10:43 +01:00
|
|
|
STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void **ppObject)
|
|
|
|
{
|
|
|
|
FIXME("(%s,%s,%p)\n", debugstr_w(pTypeName), debugstr_guid(riid), ppObject);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-04-29 10:51:07 +02:00
|
|
|
BOOL WINAPI StrongNameSignatureVerification(LPCWSTR filename, DWORD inFlags, DWORD* pOutFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%s, 0x%X, %p): stub\n", debugstr_w(filename), inFlags, pOutFlags);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI StrongNameSignatureVerificationEx(LPCWSTR filename, BOOL forceVerification, BOOL* pVerified)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %u, %p): stub\n", debugstr_w(filename), forceVerification, pVerified);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-10 05:44:31 +01:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
|
|
|
{
|
2010-03-25 21:26:43 +01:00
|
|
|
FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
2008-01-10 05:44:31 +01:00
|
|
|
if(!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-02-08 09:21:23 +01:00
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-01-10 05:44:31 +01:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(VOID)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-03-25 15:21:18 +01:00
|
|
|
|
|
|
|
INT WINAPI ND_RU1( const void *ptr, INT offset )
|
|
|
|
{
|
|
|
|
return *((const BYTE *)ptr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
INT WINAPI ND_RI2( const void *ptr, INT offset )
|
|
|
|
{
|
|
|
|
return *(const SHORT *)((const BYTE *)ptr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
INT WINAPI ND_RI4( const void *ptr, INT offset )
|
|
|
|
{
|
|
|
|
return *(const INT *)((const BYTE *)ptr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
INT64 WINAPI ND_RI8( const void *ptr, INT offset )
|
|
|
|
{
|
|
|
|
return *(const INT64 *)((const BYTE *)ptr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ND_WU1( void *ptr, INT offset, BYTE val )
|
|
|
|
{
|
|
|
|
*((BYTE *)ptr + offset) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ND_WI2( void *ptr, INT offset, SHORT val )
|
|
|
|
{
|
|
|
|
*(SHORT *)((BYTE *)ptr + offset) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ND_WI4( void *ptr, INT offset, INT val )
|
|
|
|
{
|
|
|
|
*(INT *)((BYTE *)ptr + offset) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ND_WI8( void *ptr, INT offset, INT64 val )
|
|
|
|
{
|
|
|
|
*(INT64 *)((BYTE *)ptr + offset) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ND_CopyObjDst( const void *src, void *dst, INT offset, INT size )
|
|
|
|
{
|
|
|
|
memcpy( (BYTE *)dst + offset, src, size );
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI ND_CopyObjSrc( const void *src, INT offset, void *dst, INT size )
|
|
|
|
{
|
|
|
|
memcpy( dst, (const BYTE *)src + offset, size );
|
|
|
|
}
|