From f89ab56ef69097d00ff75eb3991dde8c0e8b54ed Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 5 Jul 2019 12:55:54 +0200 Subject: [PATCH] mscoree: Build with msvcrt. Signed-off-by: Alexandre Julliard --- dlls/mscoree/Makefile.in | 2 + dlls/mscoree/assembly.c | 1 - dlls/mscoree/config.c | 12 ++-- dlls/mscoree/corruntimehost.c | 25 ++++--- dlls/mscoree/metadata.c | 1 - dlls/mscoree/metahost.c | 124 ++++++++++++++++++---------------- dlls/mscoree/mscoree_main.c | 14 ++-- 7 files changed, 93 insertions(+), 86 deletions(-) diff --git a/dlls/mscoree/Makefile.in b/dlls/mscoree/Makefile.in index 9ae43df101c..5302e45e1a1 100644 --- a/dlls/mscoree/Makefile.in +++ b/dlls/mscoree/Makefile.in @@ -1,6 +1,8 @@ MODULE = mscoree.dll IMPORTS = dbghelp uuid shell32 advapi32 ole32 oleaut32 shlwapi +EXTRADLLFLAGS = -mno-cygwin + C_SRCS = \ assembly.c \ config.c \ diff --git a/dlls/mscoree/assembly.c b/dlls/mscoree/assembly.c index b6535561ca0..240225a14da 100644 --- a/dlls/mscoree/assembly.c +++ b/dlls/mscoree/assembly.c @@ -37,7 +37,6 @@ #include "mscoree_private.h" #include "wine/debug.h" -#include "wine/unicode.h" typedef struct { diff --git a/dlls/mscoree/config.c b/dlls/mscoree/config.c index 777195d85cf..f2abf107a5f 100644 --- a/dlls/mscoree/config.c +++ b/dlls/mscoree/config.c @@ -426,7 +426,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface, switch (This->states[This->statenum]) { case STATE_ROOT: - if (nLocalName == ARRAY_SIZE(configuration) - 1 && lstrcmpW(pLocalName, configuration) == 0) + if (nLocalName == ARRAY_SIZE(configuration) - 1 && wcscmp(pLocalName, configuration) == 0) { This->states[++This->statenum] = STATE_CONFIGURATION; break; @@ -434,13 +434,13 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface, else goto unknown; case STATE_CONFIGURATION: - if (nLocalName == ARRAY_SIZE(startup) - 1 && lstrcmpW(pLocalName, startup) == 0) + if (nLocalName == ARRAY_SIZE(startup) - 1 && wcscmp(pLocalName, startup) == 0) { hr = parse_startup(This, pAttr); This->states[++This->statenum] = STATE_STARTUP; break; } - else if (nLocalName == ARRAY_SIZE(runtime) - 1 && lstrcmpW(pLocalName, runtime) == 0) + else if (nLocalName == ARRAY_SIZE(runtime) - 1 && wcscmp(pLocalName, runtime) == 0) { This->states[++This->statenum] = STATE_RUNTIME; break; @@ -449,7 +449,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface, goto unknown; case STATE_RUNTIME: if (nLocalName == ARRAY_SIZE(assemblyBinding) - 1 && - lstrcmpW(pLocalName, assemblyBinding) == 0) + wcscmp(pLocalName, assemblyBinding) == 0) { This->states[++This->statenum] = STATE_ASSEMBLY_BINDING; break; @@ -457,7 +457,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface, else goto unknown; case STATE_ASSEMBLY_BINDING: - if (nLocalName == ARRAY_SIZE(probing) - 1 && lstrcmpW(pLocalName, probing) == 0) + if (nLocalName == ARRAY_SIZE(probing) - 1 && wcscmp(pLocalName, probing) == 0) { hr = parse_probing(This, pAttr); This->states[++This->statenum] = STATE_PROBING; @@ -467,7 +467,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface, goto unknown; case STATE_STARTUP: if (nLocalName == ARRAY_SIZE(supportedRuntime) - 1 && - lstrcmpW(pLocalName, supportedRuntime) == 0) + wcscmp(pLocalName, supportedRuntime) == 0) { hr = parse_supported_runtime(This, pAttr); This->states[++This->statenum] = STATE_UNKNOWN; diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c index 13619bdc199..2ccc7bc4f5b 100644 --- a/dlls/mscoree/corruntimehost.c +++ b/dlls/mscoree/corruntimehost.c @@ -40,7 +40,6 @@ #include "mscoree_private.h" #include "wine/debug.h" -#include "wine/unicode.h" #include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL( mscoree ); @@ -1480,8 +1479,8 @@ __int32 WINAPI _CorExeMain(void) WCHAR config_file[MAX_PATH]; static const WCHAR dotconfig[] = {'.','c','o','n','f','i','g',0}; - strcpyW(config_file, filename); - strcatW(config_file, dotconfig); + lstrcpyW(config_file, filename); + lstrcatW(config_file, dotconfig); hr = RuntimeHost_GetDefaultDomain(host, config_file, &domain); } @@ -1686,10 +1685,10 @@ static BOOL try_create_registration_free_com(REFIID clsid, WCHAR *classname, UIN ERR("Buffer is too small\n"); goto end; } - strcpyW(classname, ptr_name); + lstrcpyW(classname, ptr_name); ptr_path_start = assembly_info->lpAssemblyEncodedAssemblyIdentity; - ptr_path_end = strchrW(ptr_path_start, ','); + ptr_path_end = wcschr(ptr_path_start, ','); memcpy(path, ptr_path_start, (char*)ptr_path_end - (char*)ptr_path_start); GetModuleFileNameW(NULL, filename, filename_size); @@ -1702,7 +1701,7 @@ static BOOL try_create_registration_free_com(REFIID clsid, WCHAR *classname, UIN } PathAppendW(filename, path); - strcatW(filename, str_dll); + lstrcatW(filename, str_dll); ret = TRUE; @@ -1766,10 +1765,10 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) if(res == ERROR_SUCCESS) { /* Strip file:/// */ - if(strncmpW(codebase, wszFileSlash, strlenW(wszFileSlash)) == 0) - offset = strlenW(wszFileSlash); + if(wcsncmp(codebase, wszFileSlash, lstrlenW(wszFileSlash)) == 0) + offset = lstrlenW(wszFileSlash); - strcpyW(filename, codebase + offset); + lstrcpyW(filename, codebase + offset); } else { @@ -1808,14 +1807,14 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) WARN("Attempt to load from the application directory.\n"); GetModuleFileNameW(NULL, filename, MAX_PATH); - ns = strrchrW(filename, '\\'); + ns = wcsrchr(filename, '\\'); *(ns+1) = '\0'; - ns = strchrW(assemblyname, ','); + ns = wcschr(assemblyname, ','); *(ns) = '\0'; - strcatW(filename, assemblyname); + lstrcatW(filename, assemblyname); *(ns) = '.'; - strcatW(filename, wszDLL); + lstrcatW(filename, wszDLL); } } } diff --git a/dlls/mscoree/metadata.c b/dlls/mscoree/metadata.c index 457f756a008..4853dd0c6b9 100644 --- a/dlls/mscoree/metadata.c +++ b/dlls/mscoree/metadata.c @@ -24,7 +24,6 @@ #define COBJMACROS -#include "wine/library.h" #include "windef.h" #include "winbase.h" #include "winreg.h" diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c index c7407273cf5..f87737cd839 100644 --- a/dlls/mscoree/metahost.c +++ b/dlls/mscoree/metahost.c @@ -24,8 +24,6 @@ #define COBJMACROS -#include "wine/unicode.h" -#include "wine/library.h" #include "windef.h" #include "winbase.h" #include "winreg.h" @@ -171,12 +169,12 @@ static HRESULT load_mono(LPCWSTR mono_path) if (!mono_handle) { - strcpyW(mono_lib_path, mono_path); - strcatW(mono_lib_path, lib); + lstrcpyW(mono_lib_path, mono_path); + lstrcatW(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); + lstrcpyW(mono_etc_path, mono_path); + lstrcatW(mono_etc_path, etc); WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL); if (!find_mono_dll(mono_path, mono_dll_path)) goto fail; @@ -499,7 +497,7 @@ static HRESULT WINAPI CLRRuntimeInfo_GetRuntimeDirectory(ICLRRuntimeInfo* iface, if (pwzBuffer) { if (buffer_size >= size) - strcpyW(pwzBuffer, system_dir); + lstrcpyW(pwzBuffer, system_dir); else hr = E_NOT_SUFFICIENT_BUFFER; } @@ -644,21 +642,21 @@ static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path) static const WCHAR libmono2_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','.','d','l','l',0}; DWORD attributes=INVALID_FILE_ATTRIBUTES; - strcpyW(dll_path, path); - strcatW(dll_path, libmono2_arch_dll); + lstrcpyW(dll_path, path); + lstrcatW(dll_path, libmono2_arch_dll); attributes = GetFileAttributesW(dll_path); if (attributes == INVALID_FILE_ATTRIBUTES) { - strcpyW(dll_path, path); - strcatW(dll_path, mono2_dll); + lstrcpyW(dll_path, path); + lstrcatW(dll_path, mono2_dll); attributes = GetFileAttributesW(dll_path); } if (attributes == INVALID_FILE_ATTRIBUTES) { - strcpyW(dll_path, path); - strcatW(dll_path, libmono2_dll); + lstrcpyW(dll_path, path); + lstrcatW(dll_path, libmono2_dll); attributes = GetFileAttributesW(dll_path); } @@ -672,11 +670,11 @@ static BOOL get_mono_path_local(LPWSTR path) /* c:\windows\mono\mono-2.0 */ GetWindowsDirectoryW(base_path, MAX_PATH); - strcatW(base_path, subdir_mono); + lstrcatW(base_path, subdir_mono); if (find_mono_dll(base_path, mono_dll_path)) { - strcpyW(path, base_path); + lstrcpyW(path, base_path); return TRUE; } @@ -701,7 +699,7 @@ static BOOL get_mono_path_registry(LPWSTR path) res = RegGetValueW(hkey, NULL, valuename, RRF_RT_REG_SZ, NULL, base_path, &valuesize); if (res == ERROR_SUCCESS && find_mono_dll(base_path, mono_dll_path)) { - strcpyW(path, base_path); + lstrcpyW(path, base_path); ret = TRUE; } @@ -710,12 +708,36 @@ static BOOL get_mono_path_registry(LPWSTR path) return ret; } -static BOOL get_mono_path_unix(const char *unix_dir, LPWSTR path) +static BOOL get_mono_path_dos(const WCHAR *dir, LPWSTR path) { static const WCHAR unix_prefix[] = {'\\','\\','?','\\','u','n','i','x','\\'}; - static WCHAR * (CDECL *p_wine_get_dos_file_name)(const char*); + static const char basedir[] = "\\wine-mono-" WINE_MONO_VERSION; LPWSTR dos_dir; WCHAR mono_dll_path[MAX_PATH]; + DWORD len; + BOOL ret; + + if (memcmp(dir, unix_prefix, sizeof(unix_prefix)) == 0) + return FALSE; /* No drive letter for this directory */ + + len = lstrlenW( dir ) + MultiByteToWideChar( CP_UNIXCP, 0, basedir, -1, NULL, 0 ); + if (!(dos_dir = heap_alloc( len * sizeof(WCHAR) ))) return FALSE; + lstrcpyW( dos_dir, dir ); + MultiByteToWideChar( CP_UNIXCP, 0, basedir, -1, dos_dir + lstrlenW(dos_dir), len - lstrlenW(dos_dir)); + + ret = find_mono_dll(dos_dir, mono_dll_path); + if (ret) + lstrcpyW(path, dos_dir); + + heap_free(dos_dir); + + return ret; +} + +static BOOL get_mono_path_unix(const char *unix_dir, LPWSTR path) +{ + static WCHAR * (CDECL *p_wine_get_dos_file_name)(const char*); + LPWSTR dos_dir; BOOL ret; if (!p_wine_get_dos_file_name) @@ -729,49 +751,37 @@ static BOOL get_mono_path_unix(const char *unix_dir, LPWSTR path) if (!dos_dir) return FALSE; - if (memcmp(dos_dir, unix_prefix, sizeof(unix_prefix)) == 0) - { - /* No drive letter for this directory */ - heap_free(dos_dir); - return FALSE; - } - - ret = find_mono_dll(dos_dir, mono_dll_path); - if (ret) - strcpyW(path, dos_dir); + ret = get_mono_path_dos( dos_dir, path); heap_free(dos_dir); - return ret; } static BOOL get_mono_path_datadir(LPWSTR path) { - const char *data_dir; - char *package_dir; - int len; + static const WCHAR winedatadirW[] = {'W','I','N','E','D','A','T','A','D','I','R',0}; + static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0}; + static const WCHAR unix_prefix[] = {'\\','?','?','\\','u','n','i','x','\\'}; + static const WCHAR monoW[] = {'\\','m','o','n','o',0}; + static const WCHAR dotdotW[] = {'\\','.','.',0}; + const WCHAR *data_dir, *suffix; + WCHAR *package_dir; BOOL ret; - if((data_dir = wine_get_data_dir())) - { - len = strlen(data_dir); - package_dir = heap_alloc(len + sizeof("/mono/wine-mono-" WINE_MONO_VERSION)); - memcpy(package_dir, data_dir, len); - strcpy(package_dir+len, "/mono/wine-mono-" WINE_MONO_VERSION); - } - else if((data_dir = wine_get_build_dir())) - { - len = strlen(data_dir); - package_dir = heap_alloc(len + sizeof("/../wine-mono-" WINE_MONO_VERSION)); - memcpy(package_dir, data_dir, len); - strcpy(package_dir+len, "/../wine-mono-" WINE_MONO_VERSION); - } + if ((data_dir = _wgetenv( winedatadirW ))) + suffix = monoW; + else if ((data_dir = _wgetenv( winebuilddirW ))) + suffix = dotdotW; else - { return FALSE; - } - ret = get_mono_path_unix(package_dir, path); + if (!wcsncmp( data_dir, unix_prefix, wcslen(unix_prefix) )) return FALSE; + data_dir += 4; /* skip \??\ prefix */ + package_dir = heap_alloc( (lstrlenW(data_dir) + lstrlenW(suffix) + 1) * sizeof(WCHAR)); + lstrcpyW( package_dir, data_dir ); + lstrcatW( package_dir, suffix ); + + ret = get_mono_path_dos(package_dir, path); heap_free(package_dir); @@ -783,10 +793,10 @@ BOOL get_mono_path(LPWSTR path, BOOL skip_local) return (!skip_local && get_mono_path_local(path)) || get_mono_path_registry(path) || get_mono_path_datadir(path) || - get_mono_path_unix(INSTALL_DATADIR "/wine/mono/wine-mono-" WINE_MONO_VERSION, path) || + get_mono_path_unix(INSTALL_DATADIR "/wine/mono", path) || (strcmp(INSTALL_DATADIR, "/usr/share") && - get_mono_path_unix("/usr/share/wine/mono/wine-mono-" WINE_MONO_VERSION, path)) || - get_mono_path_unix("/opt/wine/mono/wine-mono-" WINE_MONO_VERSION, path); + get_mono_path_unix("/usr/share/wine/mono", path)) || + get_mono_path_unix("/opt/wine/mono", path); } struct InstalledRuntimeEnum @@ -1485,9 +1495,9 @@ static HKEY get_app_overrides_key(void) { HKEY tmpkey; WCHAR *p, *appname = bufferW; - if ((p = strrchrW( appname, '/' ))) appname = p + 1; - if ((p = strrchrW( appname, '\\' ))) appname = p + 1; - strcatW( appname, subkeyW ); + if ((p = wcsrchr( appname, '/' ))) appname = p + 1; + if ((p = wcsrchr( appname, '\\' ))) appname = p + 1; + lstrcatW( appname, subkeyW ); /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Mono\AsmOverrides */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) { @@ -1683,8 +1693,8 @@ HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, if (exefile && !config_file && !config_stream) { - strcpyW(local_config_file, exefile); - strcatW(local_config_file, dotconfig); + lstrcpyW(local_config_file, exefile); + lstrcatW(local_config_file, dotconfig); config_file = local_config_file; } diff --git a/dlls/mscoree/mscoree_main.c b/dlls/mscoree/mscoree_main.c index 40577de7148..15bbc235207 100644 --- a/dlls/mscoree/mscoree_main.c +++ b/dlls/mscoree/mscoree_main.c @@ -22,8 +22,6 @@ #include #define COBJMACROS -#include "wine/unicode.h" -#include "wine/library.h" #include "windef.h" #include "winbase.h" #include "winuser.h" @@ -414,11 +412,11 @@ HRESULT WINAPI LoadLibraryShim( LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvR else szVersion = default_version; } - strcatW(dll_filename, szVersion); - strcatW(dll_filename, slash); + lstrcatW(dll_filename, szVersion); + lstrcatW(dll_filename, slash); } - strcatW(dll_filename, szDllName); + lstrcatW(dll_filename, szDllName); *phModDll = LoadLibraryW(dll_filename); @@ -578,7 +576,7 @@ HRESULT WINAPI CreateDebuggingInterfaceFromVersion(int nDebugVersion, LPCWSTR ve *ppv = NULL; - if(strcmpW(version, v2_0) != 0) + if(wcscmp(version, v2_0) != 0) { FIXME("Currently .NET Version '%s' not support.\n", debugstr_w(version)); return E_INVALIDARG; @@ -732,8 +730,8 @@ static BOOL get_support_msi(LPCWSTR mono_path, LPWSTR msi_path) hmsi = GetModuleHandleA("msi"); - strcpyW(msi_path, mono_path); - strcatW(msi_path, support_msi_relative); + lstrcpyW(msi_path, mono_path); + lstrcatW(msi_path, support_msi_relative); pMsiOpenPackageW = (void*)GetProcAddress(hmsi, "MsiOpenPackageW");