msvcrt: Improve acosf compatibility with native ucrtbase.
[wine.git] / dlls / fusion / fusion.c
blob0787bf0f2ac8071355ccb3d1874d1a53b3cb8b94
1 /*
2 * Implementation of the Fusion API
4 * Copyright 2008 James Hawkins
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "fusion.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(fusion);
35 /******************************************************************
36 * InitializeFusion (FUSION.@)
38 HRESULT WINAPI InitializeFusion(void)
40 FIXME("\n");
41 return S_OK;
44 /******************************************************************
45 * ClearDownloadCache (FUSION.@)
47 HRESULT WINAPI ClearDownloadCache(void)
49 FIXME("stub!\n");
50 return E_NOTIMPL;
53 /******************************************************************
54 * CopyPDBs (FUSION.@)
56 HRESULT WINAPI CopyPDBs(void *unknown)
58 FIXME("(%p) stub!\n", unknown);
59 return E_NOTIMPL;
62 /******************************************************************
63 * CreateInstallReferenceEnum (FUSION.@)
65 HRESULT WINAPI CreateInstallReferenceEnum(IInstallReferenceEnum **ppRefEnum,
66 IAssemblyName *pName, DWORD dwFlags,
67 LPVOID pvReserved)
69 FIXME("(%p, %p, %08x, %p) stub!\n", ppRefEnum, pName, dwFlags, pvReserved);
70 return E_NOTIMPL;
73 /******************************************************************
74 * CreateApplicationContext (FUSION.@)
76 HRESULT WINAPI CreateApplicationContext(IAssemblyName *name, void *ctx)
78 FIXME("%p, %p\n", name, ctx);
79 return E_NOTIMPL;
82 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
83 DWORD *dwLength);
85 static HRESULT get_corversion(LPWSTR version, DWORD size)
87 HMODULE hmscoree;
88 HRESULT hr;
89 DWORD len;
91 hmscoree = LoadLibraryA("mscoree.dll");
92 if (!hmscoree)
93 return E_FAIL;
95 pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
96 if (!pGetCORVersion)
97 hr = E_FAIL;
98 else
99 hr = pGetCORVersion(version, size, &len);
101 FreeLibrary(hmscoree);
102 return hr;
105 /******************************************************************
106 * GetCachePath (FUSION.@)
108 HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath,
109 PDWORD pcchPath)
111 static const WCHAR assembly[] = {'\\','a','s','s','e','m','b','l','y',0};
112 static const WCHAR gac[] = {'\\','G','A','C',0};
113 static const WCHAR nativeimg[] = {'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
114 static const WCHAR dotnet[] = {'\\','M','i','c','r','o','s','o','f','t','.','N','E','T',0};
115 #ifdef _WIN64
116 static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0};
117 #else
118 static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0};
119 #endif
120 WCHAR path[MAX_PATH], windir[MAX_PATH], version[MAX_PATH];
121 DWORD len;
122 HRESULT hr = S_OK;
124 TRACE("(%08x, %p, %p)\n", dwCacheFlags, pwzCachePath, pcchPath);
126 if (!pcchPath)
127 return E_INVALIDARG;
129 len = GetWindowsDirectoryW(windir, MAX_PATH);
130 lstrcpyW(path, windir);
132 switch (dwCacheFlags)
134 case ASM_CACHE_ZAP:
136 hr = get_corversion(version, MAX_PATH);
137 if (FAILED(hr))
138 return hr;
140 len = swprintf(path, ARRAY_SIZE(path), zapfmt, windir, assembly + 1, nativeimg, version);
141 break;
143 case ASM_CACHE_GAC:
145 lstrcpyW(path + len, assembly);
146 len += ARRAY_SIZE(assembly) - 1;
147 lstrcpyW(path + len, gac);
148 len += ARRAY_SIZE(gac) - 1;
149 break;
151 case ASM_CACHE_DOWNLOAD:
153 FIXME("Download cache not implemented\n");
154 return E_FAIL;
156 case ASM_CACHE_ROOT:
157 lstrcpyW(path + len, assembly);
158 len += ARRAY_SIZE(assembly) - 1;
159 break;
160 case ASM_CACHE_ROOT_EX:
161 lstrcpyW(path + len, dotnet);
162 len += ARRAY_SIZE(dotnet) - 1;
163 lstrcpyW(path + len, assembly);
164 len += ARRAY_SIZE(assembly) - 1;
165 break;
166 default:
167 return E_INVALIDARG;
170 len++;
171 if (*pcchPath <= len || !pwzCachePath)
172 hr = E_NOT_SUFFICIENT_BUFFER;
173 else if (pwzCachePath)
174 lstrcpyW(pwzCachePath, path);
176 *pcchPath = len;
177 return hr;