2008-09-10 08:47:30 +00:00
|
|
|
/*
|
|
|
|
* Implementation of the Fusion API
|
|
|
|
*
|
|
|
|
* Copyright 2008 James Hawkins
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2018-03-09 12:07:30 +00:00
|
|
|
#include <stdarg.h>
|
2019-10-26 21:56:11 +00:00
|
|
|
#ifdef __REACTOS__
|
|
|
|
#include <wchar.h>
|
|
|
|
#endif
|
2018-03-09 12:07:30 +00:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "fusion.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(fusion);
|
|
|
|
|
2013-05-04 20:21:39 +00:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* InitializeFusion (FUSION.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI InitializeFusion(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
2018-01-18 23:10:53 +00:00
|
|
|
return S_OK;
|
2013-05-04 20:21:39 +00:00
|
|
|
}
|
|
|
|
|
2008-09-10 08:47:30 +00:00
|
|
|
/******************************************************************
|
|
|
|
* ClearDownloadCache (FUSION.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ClearDownloadCache(void)
|
|
|
|
{
|
|
|
|
FIXME("stub!\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2016-03-02 10:11:41 +00:00
|
|
|
/******************************************************************
|
|
|
|
* CopyPDBs (FUSION.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CopyPDBs(void *unknown)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub!\n", unknown);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-10 08:47:30 +00:00
|
|
|
/******************************************************************
|
|
|
|
* CreateInstallReferenceEnum (FUSION.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateInstallReferenceEnum(IInstallReferenceEnum **ppRefEnum,
|
|
|
|
IAssemblyName *pName, DWORD dwFlags,
|
|
|
|
LPVOID pvReserved)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %08x, %p) stub!\n", ppRefEnum, pName, dwFlags, pvReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-03-21 19:19:12 +00:00
|
|
|
/******************************************************************
|
|
|
|
* CreateApplicationContext (FUSION.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateApplicationContext(IAssemblyName *name, void *ctx)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p\n", name, ctx);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-10 08:47:30 +00:00
|
|
|
static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
|
|
|
|
DWORD *dwLength);
|
|
|
|
|
|
|
|
static HRESULT get_corversion(LPWSTR version, DWORD size)
|
|
|
|
{
|
|
|
|
HMODULE hmscoree;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
hmscoree = LoadLibraryA("mscoree.dll");
|
|
|
|
if (!hmscoree)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
|
|
|
|
if (!pGetCORVersion)
|
2013-05-04 20:21:39 +00:00
|
|
|
hr = E_FAIL;
|
|
|
|
else
|
|
|
|
hr = pGetCORVersion(version, size, &len);
|
2008-09-10 08:47:30 +00:00
|
|
|
|
|
|
|
FreeLibrary(hmscoree);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetCachePath (FUSION.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath,
|
|
|
|
PDWORD pcchPath)
|
|
|
|
{
|
2013-05-04 20:21:39 +00:00
|
|
|
static const WCHAR assembly[] = {'\\','a','s','s','e','m','b','l','y',0};
|
|
|
|
static const WCHAR gac[] = {'\\','G','A','C',0};
|
|
|
|
static const WCHAR nativeimg[] = {'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
|
|
|
|
static const WCHAR dotnet[] = {'\\','M','i','c','r','o','s','o','f','t','.','N','E','T',0};
|
2009-05-20 14:43:24 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0};
|
|
|
|
#else
|
|
|
|
static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0};
|
|
|
|
#endif
|
2013-05-04 20:21:39 +00:00
|
|
|
WCHAR path[MAX_PATH], windir[MAX_PATH], version[MAX_PATH];
|
|
|
|
DWORD len;
|
|
|
|
HRESULT hr = S_OK;
|
2008-09-10 08:47:30 +00:00
|
|
|
|
|
|
|
TRACE("(%08x, %p, %p)\n", dwCacheFlags, pwzCachePath, pcchPath);
|
|
|
|
|
|
|
|
if (!pcchPath)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-05-04 20:21:39 +00:00
|
|
|
len = GetWindowsDirectoryW(windir, MAX_PATH);
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(path, windir);
|
2008-09-10 08:47:30 +00:00
|
|
|
|
|
|
|
switch (dwCacheFlags)
|
|
|
|
{
|
|
|
|
case ASM_CACHE_ZAP:
|
|
|
|
{
|
|
|
|
hr = get_corversion(version, MAX_PATH);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-10-26 21:56:11 +00:00
|
|
|
len = swprintf(path, zapfmt, windir, assembly + 1, nativeimg, version);
|
2008-09-10 08:47:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ASM_CACHE_GAC:
|
|
|
|
{
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(path + len, assembly);
|
2018-10-01 11:49:44 +00:00
|
|
|
len += ARRAY_SIZE(assembly) - 1;
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(path + len, gac);
|
2018-10-01 11:49:44 +00:00
|
|
|
len += ARRAY_SIZE(gac) - 1;
|
2008-09-10 08:47:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ASM_CACHE_DOWNLOAD:
|
|
|
|
{
|
|
|
|
FIXME("Download cache not implemented\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
case ASM_CACHE_ROOT:
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(path + len, assembly);
|
2018-10-01 11:49:44 +00:00
|
|
|
len += ARRAY_SIZE(assembly) - 1;
|
2013-05-04 20:21:39 +00:00
|
|
|
break;
|
|
|
|
case ASM_CACHE_ROOT_EX:
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(path + len, dotnet);
|
2018-10-01 11:49:44 +00:00
|
|
|
len += ARRAY_SIZE(dotnet) - 1;
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(path + len, assembly);
|
2018-10-01 11:49:44 +00:00
|
|
|
len += ARRAY_SIZE(assembly) - 1;
|
2013-05-04 20:21:39 +00:00
|
|
|
break;
|
2008-09-10 08:47:30 +00:00
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2013-05-04 20:21:39 +00:00
|
|
|
len++;
|
2008-09-10 08:47:30 +00:00
|
|
|
if (*pcchPath <= len || !pwzCachePath)
|
2015-03-21 12:21:40 +00:00
|
|
|
hr = E_NOT_SUFFICIENT_BUFFER;
|
2008-09-10 08:47:30 +00:00
|
|
|
else if (pwzCachePath)
|
2019-10-26 21:56:11 +00:00
|
|
|
lstrcpyW(pwzCachePath, path);
|
2008-09-10 08:47:30 +00:00
|
|
|
|
|
|
|
*pcchPath = len;
|
|
|
|
return hr;
|
|
|
|
}
|