From fd1eab7f226550cc8bf6f0de5a2b31202dfecbc7 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 21 May 2012 11:26:07 +0200 Subject: [PATCH] fusion: Add support for installing version 4.0 assemblies. --- dlls/fusion/asmcache.c | 45 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/dlls/fusion/asmcache.c b/dlls/fusion/asmcache.c index fdf8ab5a23..93047d4ec7 100644 --- a/dlls/fusion/asmcache.c +++ b/dlls/fusion/asmcache.c @@ -94,39 +94,48 @@ static BOOL create_full_path(LPCWSTR path) return ret; } -static BOOL get_assembly_directory(LPWSTR dir, DWORD size, PEKIND architecture) +static BOOL get_assembly_directory(LPWSTR dir, DWORD size, const char *version, PEKIND architecture) { + static const WCHAR dotnet[] = {'\\','M','i','c','r','o','s','o','f','t','.','N','E','T','\\',0}; static const WCHAR gac[] = {'\\','a','s','s','e','m','b','l','y','\\','G','A','C',0}; - static const WCHAR msil[] = {'_','M','S','I','L',0}; static const WCHAR x86[] = {'_','3','2',0}; static const WCHAR amd64[] = {'_','6','4',0}; + DWORD len = GetWindowsDirectoryW(dir, size); - GetWindowsDirectoryW(dir, size); - strcatW(dir, gac); - + if (!strcmp(version, "v4.0.30319")) + { + strcpyW(dir + len, dotnet); + len += sizeof(dotnet)/sizeof(WCHAR) -1; + strcpyW(dir + len, gac + 1); + len += sizeof(gac)/sizeof(WCHAR) - 2; + } + else + { + strcpyW(dir + len, gac); + len += sizeof(gac)/sizeof(WCHAR) - 1; + } switch (architecture) { case peNone: break; case peMSIL: - strcatW(dir, msil); + strcpyW(dir + len, msil); break; case peI386: - strcatW(dir, x86); + strcpyW(dir + len, x86); break; case peAMD64: - strcatW(dir, amd64); + strcpyW(dir + len, amd64); break; default: WARN("unhandled architecture %u\n", architecture); return FALSE; } - return TRUE; } @@ -371,15 +380,11 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, static const WCHAR ext_dll[] = {'.','d','l','l',0}; IAssemblyCacheImpl *cache = impl_from_IAssemblyCache(iface); ASSEMBLY *assembly; - LPWSTR filename; - LPWSTR name = NULL; - LPWSTR token = NULL; - LPWSTR version = NULL; - LPWSTR asmpath = NULL; - WCHAR path[MAX_PATH]; - WCHAR asmdir[MAX_PATH]; - LPWSTR ext; + WCHAR *filename, *ext; + WCHAR *name = NULL, *token = NULL, *version = NULL, *asmpath = NULL; + WCHAR path[MAX_PATH], asmdir[MAX_PATH]; PEKIND architecture; + char *clr_version; HRESULT hr; TRACE("(%p, %d, %s, %p)\n", iface, dwFlags, @@ -416,10 +421,14 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, if (FAILED(hr)) goto done; + hr = assembly_get_runtime_version(assembly, &clr_version); + if (FAILED(hr)) + goto done; + cache_lock( cache ); architecture = assembly_get_architecture(assembly); - get_assembly_directory(asmdir, MAX_PATH, architecture); + get_assembly_directory(asmdir, MAX_PATH, clr_version, architecture); sprintfW(path, format, asmdir, name, version, token);