2010-11-03 15:09:08 +01:00
|
|
|
/*
|
|
|
|
* IAssemblyCache implementation
|
|
|
|
*
|
|
|
|
* Copyright 2010 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define INITGUID
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "winsxs.h"
|
2010-11-05 11:36:49 +01:00
|
|
|
#include "msxml2.h"
|
|
|
|
|
2010-11-03 15:09:08 +01:00
|
|
|
#include "wine/debug.h"
|
2010-11-05 11:36:49 +01:00
|
|
|
#include "wine/list.h"
|
2012-03-30 10:21:11 +02:00
|
|
|
#include "sxs_private.h"
|
2010-11-03 15:09:08 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(sxs);
|
|
|
|
|
2012-04-30 09:35:10 +02:00
|
|
|
static const WCHAR cache_mutex_nameW[] =
|
|
|
|
{'_','_','W','I','N','E','_','S','X','S','_','C','A','C','H','E','_','M','U','T','E','X','_','_',0};
|
|
|
|
|
2012-03-30 10:21:11 +02:00
|
|
|
static const WCHAR win32W[] = {'w','i','n','3','2',0};
|
|
|
|
static const WCHAR win32_policyW[] = {'w','i','n','3','2','-','p','o','l','i','c','y',0};
|
2012-04-30 09:34:30 +02:00
|
|
|
static const WCHAR backslashW[] = {'\\',0};
|
2010-11-05 11:36:49 +01:00
|
|
|
|
2010-11-03 15:09:08 +01:00
|
|
|
struct cache
|
|
|
|
{
|
2011-01-14 00:39:39 +01:00
|
|
|
IAssemblyCache IAssemblyCache_iface;
|
2010-11-03 15:09:08 +01:00
|
|
|
LONG refs;
|
2012-04-30 09:35:10 +02:00
|
|
|
HANDLE lock;
|
2010-11-03 15:09:08 +01:00
|
|
|
};
|
|
|
|
|
2011-01-14 00:39:39 +01:00
|
|
|
static inline struct cache *impl_from_IAssemblyCache(IAssemblyCache *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct cache, IAssemblyCache_iface);
|
|
|
|
}
|
|
|
|
|
2010-11-03 15:09:08 +01:00
|
|
|
static HRESULT WINAPI cache_QueryInterface(
|
|
|
|
IAssemblyCache *iface,
|
|
|
|
REFIID riid,
|
2021-09-15 20:31:47 +02:00
|
|
|
void **ret_iface )
|
2010-11-03 15:09:08 +01:00
|
|
|
{
|
2021-09-15 20:31:47 +02:00
|
|
|
TRACE("%p, %s, %p\n", iface, debugstr_guid(riid), ret_iface);
|
2010-11-03 15:09:08 +01:00
|
|
|
|
2021-09-15 20:31:47 +02:00
|
|
|
*ret_iface = NULL;
|
2010-11-03 15:09:08 +01:00
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IAssemblyCache))
|
|
|
|
{
|
2012-07-31 12:25:08 +02:00
|
|
|
IAssemblyCache_AddRef( iface );
|
2021-09-15 20:31:47 +02:00
|
|
|
*ret_iface = iface;
|
2010-11-03 15:09:08 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI cache_AddRef( IAssemblyCache *iface )
|
|
|
|
{
|
2011-01-14 00:39:39 +01:00
|
|
|
struct cache *cache = impl_from_IAssemblyCache(iface);
|
2010-11-03 15:09:08 +01:00
|
|
|
return InterlockedIncrement( &cache->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI cache_Release( IAssemblyCache *iface )
|
|
|
|
{
|
2011-01-14 00:39:39 +01:00
|
|
|
struct cache *cache = impl_from_IAssemblyCache(iface);
|
2010-11-03 15:09:08 +01:00
|
|
|
ULONG refs = InterlockedDecrement( &cache->refs );
|
|
|
|
|
|
|
|
if (!refs)
|
|
|
|
{
|
|
|
|
TRACE("destroying %p\n", cache);
|
2012-04-30 09:35:10 +02:00
|
|
|
CloseHandle( cache->lock );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( cache );
|
2010-11-03 15:09:08 +01:00
|
|
|
}
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
static unsigned int build_sxs_path( WCHAR *path )
|
2012-03-30 10:21:11 +02:00
|
|
|
{
|
|
|
|
static const WCHAR winsxsW[] = {'\\','w','i','n','s','x','s','\\',0};
|
2012-04-30 09:34:30 +02:00
|
|
|
unsigned int len = GetWindowsDirectoryW( path, MAX_PATH );
|
|
|
|
|
|
|
|
memcpy( path + len, winsxsW, sizeof(winsxsW) );
|
2018-07-18 23:01:33 +02:00
|
|
|
return len + ARRAY_SIZE(winsxsW) - 1;
|
2012-03-30 10:21:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *build_assembly_name( const WCHAR *arch, const WCHAR *name, const WCHAR *token,
|
2012-04-30 09:34:30 +02:00
|
|
|
const WCHAR *version, unsigned int *len )
|
2012-03-30 10:21:11 +02:00
|
|
|
{
|
|
|
|
static const WCHAR fmtW[] =
|
|
|
|
{'%','s','_','%','s','_','%','s','_','%','s','_','n','o','n','e','_','d','e','a','d','b','e','e','f',0};
|
2018-07-18 23:01:33 +02:00
|
|
|
unsigned int buflen = ARRAY_SIZE(fmtW);
|
2019-06-21 08:50:39 +02:00
|
|
|
WCHAR *ret;
|
2012-03-30 10:21:11 +02:00
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
buflen += lstrlenW( arch );
|
|
|
|
buflen += lstrlenW( name );
|
|
|
|
buflen += lstrlenW( token );
|
|
|
|
buflen += lstrlenW( version );
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(ret = malloc( buflen * sizeof(WCHAR) ))) return NULL;
|
2019-06-21 08:50:39 +02:00
|
|
|
*len = swprintf( ret, buflen, fmtW, arch, name, token, version );
|
|
|
|
return wcslwr( ret );
|
2012-03-30 10:21:11 +02:00
|
|
|
}
|
|
|
|
|
2020-09-18 11:58:33 +02:00
|
|
|
static WCHAR *build_dll_path( const WCHAR *arch, const WCHAR *name, const WCHAR *token,
|
|
|
|
const WCHAR *version )
|
2012-04-30 09:34:30 +02:00
|
|
|
{
|
|
|
|
WCHAR *path = NULL, *ret, sxsdir[MAX_PATH];
|
|
|
|
unsigned int len;
|
|
|
|
|
|
|
|
if (!(path = build_assembly_name( arch, name, token, version, &len ))) return NULL;
|
2020-10-03 09:57:13 +02:00
|
|
|
len += build_sxs_path( sxsdir ) + 2;
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(ret = malloc( len * sizeof(WCHAR) )))
|
2012-04-30 09:34:30 +02:00
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( path );
|
2012-04-30 09:34:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2020-09-18 11:58:33 +02:00
|
|
|
lstrcpyW( ret, sxsdir );
|
|
|
|
lstrcatW( ret, path );
|
|
|
|
lstrcatW( ret, L"\\" );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( path );
|
2012-04-30 09:34:30 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *build_policy_name( const WCHAR *arch, const WCHAR *name, const WCHAR *token,
|
|
|
|
unsigned int *len )
|
2012-03-30 10:21:11 +02:00
|
|
|
{
|
|
|
|
static const WCHAR fmtW[] =
|
|
|
|
{'%','s','_','%','s','_','%','s','_','n','o','n','e','_','d','e','a','d','b','e','e','f',0};
|
2018-07-18 23:01:33 +02:00
|
|
|
unsigned int buflen = ARRAY_SIZE(fmtW);
|
2019-06-21 08:50:39 +02:00
|
|
|
WCHAR *ret;
|
2012-03-30 10:21:11 +02:00
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
buflen += lstrlenW( arch );
|
|
|
|
buflen += lstrlenW( name );
|
|
|
|
buflen += lstrlenW( token );
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(ret = malloc( buflen * sizeof(WCHAR) ))) return NULL;
|
2019-06-21 08:50:39 +02:00
|
|
|
*len = swprintf( ret, buflen, fmtW, arch, name, token );
|
|
|
|
return wcslwr( ret );
|
2012-03-30 10:21:11 +02:00
|
|
|
}
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
static WCHAR *build_policy_path( const WCHAR *arch, const WCHAR *name, const WCHAR *token,
|
|
|
|
const WCHAR *version )
|
|
|
|
{
|
|
|
|
static const WCHAR fmtW[] =
|
|
|
|
{'%','s','p','o','l','i','c','i','e','s','\\','%','s','\\','%','s','.','p','o','l','i','c','y',0};
|
|
|
|
WCHAR *path = NULL, *ret, sxsdir[MAX_PATH];
|
|
|
|
unsigned int len;
|
|
|
|
|
|
|
|
if (!(path = build_policy_name( arch, name, token, &len ))) return NULL;
|
2018-07-18 23:01:33 +02:00
|
|
|
len += ARRAY_SIZE(fmtW);
|
2012-04-30 09:34:30 +02:00
|
|
|
len += build_sxs_path( sxsdir );
|
2019-06-21 08:50:39 +02:00
|
|
|
len += lstrlenW( version );
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(ret = malloc( len * sizeof(WCHAR) )))
|
2012-04-30 09:34:30 +02:00
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( path );
|
2012-04-30 09:34:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
swprintf( ret, len, fmtW, sxsdir, path, version );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( path );
|
2012-04-30 09:34:30 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-30 09:35:10 +02:00
|
|
|
static void cache_lock( struct cache *cache )
|
|
|
|
{
|
|
|
|
WaitForSingleObject( cache->lock, INFINITE );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cache_unlock( struct cache *cache )
|
|
|
|
{
|
|
|
|
ReleaseMutex( cache->lock );
|
|
|
|
}
|
|
|
|
|
2012-03-30 10:21:11 +02:00
|
|
|
#define ASSEMBLYINFO_FLAG_INSTALLED 1
|
|
|
|
|
2010-11-03 15:09:08 +01:00
|
|
|
static HRESULT WINAPI cache_QueryAssemblyInfo(
|
|
|
|
IAssemblyCache *iface,
|
|
|
|
DWORD flags,
|
2012-03-30 10:21:11 +02:00
|
|
|
LPCWSTR assembly_name,
|
2010-11-03 15:09:08 +01:00
|
|
|
ASSEMBLY_INFO *info )
|
|
|
|
{
|
2012-04-30 09:35:10 +02:00
|
|
|
struct cache *cache = impl_from_IAssemblyCache( iface );
|
2012-04-30 09:34:30 +02:00
|
|
|
IAssemblyName *name_obj;
|
2012-03-30 10:21:11 +02:00
|
|
|
const WCHAR *arch, *name, *token, *type, *version;
|
2020-09-18 11:58:33 +02:00
|
|
|
WCHAR *path = NULL;
|
2012-04-30 09:34:30 +02:00
|
|
|
unsigned int len;
|
2012-03-30 10:21:11 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-18 09:17:10 +01:00
|
|
|
TRACE("%p, 0x%08lx, %s, %p\n", iface, flags, debugstr_w(assembly_name), info);
|
2012-03-30 10:21:11 +02:00
|
|
|
|
|
|
|
if (flags || (info && info->cbAssemblyInfo != sizeof(*info)))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = CreateAssemblyNameObject( &name_obj, assembly_name, CANOF_PARSE_DISPLAY_NAME, 0 );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
arch = get_name_attribute( name_obj, NAME_ATTR_ID_ARCH );
|
|
|
|
name = get_name_attribute( name_obj, NAME_ATTR_ID_NAME );
|
|
|
|
token = get_name_attribute( name_obj, NAME_ATTR_ID_TOKEN );
|
|
|
|
type = get_name_attribute( name_obj, NAME_ATTR_ID_TYPE );
|
|
|
|
version = get_name_attribute( name_obj, NAME_ATTR_ID_VERSION );
|
|
|
|
if (!arch || !name || !token || !type || !version)
|
|
|
|
{
|
2012-04-30 09:34:30 +02:00
|
|
|
IAssemblyName_Release( name_obj );
|
2012-03-30 10:21:11 +02:00
|
|
|
return HRESULT_FROM_WIN32( ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE );
|
|
|
|
}
|
|
|
|
if (!info)
|
|
|
|
{
|
|
|
|
IAssemblyName_Release( name_obj );
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-04-30 09:35:10 +02:00
|
|
|
cache_lock( cache );
|
|
|
|
|
2020-09-18 11:58:33 +02:00
|
|
|
if (!wcscmp( type, win32W )) path = build_dll_path( arch, name, token, version );
|
2019-06-21 08:50:39 +02:00
|
|
|
else if (!wcscmp( type, win32_policyW )) path = build_policy_path( arch, name, token, version );
|
2012-03-30 10:21:11 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = HRESULT_FROM_WIN32( ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE );
|
|
|
|
goto done;
|
|
|
|
}
|
2012-04-30 09:34:30 +02:00
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
2012-03-30 10:21:11 +02:00
|
|
|
hr = S_OK;
|
2012-04-30 09:34:30 +02:00
|
|
|
if (GetFileAttributesW( path ) != INVALID_FILE_ATTRIBUTES) /* FIXME: better check */
|
2012-03-30 10:21:11 +02:00
|
|
|
{
|
|
|
|
info->dwAssemblyFlags = ASSEMBLYINFO_FLAG_INSTALLED;
|
|
|
|
TRACE("assembly is installed\n");
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
len = lstrlenW( path ) + 1;
|
2012-03-30 10:21:11 +02:00
|
|
|
if (info->pszCurrentAssemblyPathBuf)
|
|
|
|
{
|
|
|
|
if (info->cchBuf < len)
|
|
|
|
{
|
|
|
|
info->cchBuf = len;
|
|
|
|
hr = HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER );
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
else lstrcpyW( info->pszCurrentAssemblyPathBuf, path );
|
2012-03-30 10:21:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2022-03-30 08:48:15 +02:00
|
|
|
free( path );
|
2012-03-30 10:21:11 +02:00
|
|
|
IAssemblyName_Release( name_obj );
|
2012-04-30 09:35:10 +02:00
|
|
|
cache_unlock( cache );
|
2012-03-30 10:21:11 +02:00
|
|
|
return hr;
|
2010-11-03 15:09:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI cache_CreateAssemblyCacheItem(
|
|
|
|
IAssemblyCache *iface,
|
|
|
|
DWORD flags,
|
|
|
|
PVOID reserved,
|
|
|
|
IAssemblyCacheItem **item,
|
|
|
|
LPCWSTR name )
|
|
|
|
{
|
2022-02-18 09:17:10 +01:00
|
|
|
FIXME("%p, 0x%08lx, %p, %p, %s\n", iface, flags, reserved, item, debugstr_w(name));
|
2010-11-03 15:09:08 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI cache_Reserved(
|
|
|
|
IAssemblyCache *iface,
|
|
|
|
IUnknown **reserved)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", reserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-05 11:36:49 +01:00
|
|
|
static BSTR get_attribute_value( IXMLDOMNamedNodeMap *map, const WCHAR *value_name )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IXMLDOMNode *attr;
|
|
|
|
VARIANT var;
|
|
|
|
BSTR str;
|
|
|
|
|
|
|
|
str = SysAllocString( value_name );
|
|
|
|
hr = IXMLDOMNamedNodeMap_getNamedItem( map, str, &attr );
|
|
|
|
SysFreeString( str );
|
|
|
|
if (hr != S_OK) return NULL;
|
|
|
|
|
|
|
|
hr = IXMLDOMNode_get_nodeValue( attr, &var );
|
|
|
|
IXMLDOMNode_Release( attr );
|
|
|
|
if (hr != S_OK) return NULL;
|
|
|
|
if (V_VT(&var) != VT_BSTR)
|
|
|
|
{
|
|
|
|
VariantClear( &var );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
TRACE("%s=%s\n", debugstr_w(value_name), debugstr_w(V_BSTR( &var )));
|
|
|
|
return V_BSTR( &var );
|
|
|
|
}
|
|
|
|
|
|
|
|
struct file
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
BSTR name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct assembly
|
|
|
|
{
|
|
|
|
BSTR type;
|
|
|
|
BSTR name;
|
|
|
|
BSTR version;
|
|
|
|
BSTR arch;
|
|
|
|
BSTR token;
|
|
|
|
struct list files;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void free_assembly( struct assembly *assembly )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
|
|
|
|
|
|
|
if (!assembly) return;
|
|
|
|
SysFreeString( assembly->type );
|
|
|
|
SysFreeString( assembly->name );
|
|
|
|
SysFreeString( assembly->version );
|
|
|
|
SysFreeString( assembly->arch );
|
|
|
|
SysFreeString( assembly->token );
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &assembly->files )
|
|
|
|
{
|
|
|
|
struct file *file = LIST_ENTRY( item, struct file, entry );
|
|
|
|
list_remove( &file->entry );
|
|
|
|
SysFreeString( file->name );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( file );
|
2010-11-05 11:36:49 +01:00
|
|
|
}
|
2022-03-30 08:48:15 +02:00
|
|
|
free( assembly );
|
2010-11-05 11:36:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_files( IXMLDOMDocument *doc, struct assembly *assembly )
|
|
|
|
{
|
|
|
|
static const WCHAR fileW[] = {'f','i','l','e',0};
|
|
|
|
static const WCHAR nameW[] = {'n','a','m','e',0};
|
|
|
|
IXMLDOMNamedNodeMap *attrs;
|
|
|
|
IXMLDOMNodeList *list;
|
|
|
|
IXMLDOMNode *node;
|
|
|
|
struct file *f;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hr;
|
|
|
|
LONG len;
|
|
|
|
|
|
|
|
str = SysAllocString( fileW );
|
|
|
|
hr = IXMLDOMDocument_getElementsByTagName( doc, str, &list );
|
|
|
|
SysFreeString( str );
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = IXMLDOMNodeList_get_length( list, &len );
|
|
|
|
if (hr != S_OK) goto done;
|
2022-02-18 09:17:10 +01:00
|
|
|
TRACE("found %ld files\n", len);
|
2010-11-05 11:36:49 +01:00
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMNodeList_nextNode( list, &node );
|
|
|
|
if (hr != S_OK || !node)
|
|
|
|
{
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: validate node type */
|
|
|
|
|
|
|
|
hr = IXMLDOMNode_get_attributes( node, &attrs );
|
|
|
|
IXMLDOMNode_Release( node );
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto done;
|
|
|
|
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(f = malloc( sizeof(*f) )))
|
2010-11-05 11:36:49 +01:00
|
|
|
{
|
|
|
|
IXMLDOMNamedNodeMap_Release( attrs );
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
f->name = get_attribute_value( attrs, nameW );
|
|
|
|
IXMLDOMNamedNodeMap_Release( attrs );
|
|
|
|
if (!f->name)
|
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( f );
|
2010-11-05 11:36:49 +01:00
|
|
|
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
list_add_tail( &assembly->files, &f->entry );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list_empty( &assembly->files ))
|
|
|
|
{
|
|
|
|
WARN("no files found\n");
|
|
|
|
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
IXMLDOMNodeList_Release( list );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT parse_assembly( IXMLDOMDocument *doc, struct assembly **assembly )
|
|
|
|
{
|
|
|
|
static const WCHAR identityW[] = {'a','s','s','e','m','b','l','y','I','d','e','n','t','i','t','y',0};
|
|
|
|
static const WCHAR typeW[] = {'t','y','p','e',0};
|
|
|
|
static const WCHAR nameW[] = {'n','a','m','e',0};
|
|
|
|
static const WCHAR versionW[] = {'v','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR architectureW[] = {'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e',0};
|
|
|
|
static const WCHAR tokenW[] = {'p','u','b','l','i','c','K','e','y','T','o','k','e','n',0};
|
|
|
|
IXMLDOMNodeList *list = NULL;
|
|
|
|
IXMLDOMNode *node = NULL;
|
|
|
|
IXMLDOMNamedNodeMap *attrs = NULL;
|
|
|
|
struct assembly *a = NULL;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hr;
|
|
|
|
LONG len;
|
|
|
|
|
|
|
|
str = SysAllocString( identityW );
|
|
|
|
hr = IXMLDOMDocument_getElementsByTagName( doc, str, &list );
|
|
|
|
SysFreeString( str );
|
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
|
|
|
|
hr = IXMLDOMNodeList_get_length( list, &len );
|
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
hr = IXMLDOMNodeList_nextNode( list, &node );
|
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
if (!node)
|
|
|
|
{
|
|
|
|
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(a = calloc(1, sizeof(*a) )))
|
2010-11-05 11:36:49 +01:00
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
list_init( &a->files );
|
|
|
|
|
|
|
|
hr = IXMLDOMNode_get_attributes( node, &attrs );
|
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
|
2010-12-10 12:53:50 +01:00
|
|
|
a->type = get_attribute_value( attrs, typeW );
|
2010-11-05 11:36:49 +01:00
|
|
|
a->name = get_attribute_value( attrs, nameW );
|
|
|
|
a->version = get_attribute_value( attrs, versionW );
|
|
|
|
a->arch = get_attribute_value( attrs, architectureW );
|
|
|
|
a->token = get_attribute_value( attrs, tokenW );
|
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
if (!a->type || (wcscmp( a->type, win32W ) && wcscmp( a->type, win32_policyW )) ||
|
2010-12-10 12:53:50 +01:00
|
|
|
!a->name || !a->version || !a->arch || !a->token)
|
2010-11-05 11:36:49 +01:00
|
|
|
{
|
|
|
|
WARN("invalid win32 assembly\n");
|
|
|
|
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
if (!wcscmp( a->type, win32W )) hr = parse_files( doc, a );
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (attrs) IXMLDOMNamedNodeMap_Release( attrs );
|
|
|
|
if (node) IXMLDOMNode_Release( node );
|
|
|
|
if (list) IXMLDOMNodeList_Release( list );
|
|
|
|
if (hr == S_OK) *assembly = a;
|
|
|
|
else free_assembly( a );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
static WCHAR *build_policy_filename( const WCHAR *arch, const WCHAR *name, const WCHAR *token,
|
|
|
|
const WCHAR *version )
|
2010-12-10 12:53:50 +01:00
|
|
|
{
|
|
|
|
static const WCHAR policiesW[] = {'p','o','l','i','c','i','e','s','\\',0};
|
|
|
|
static const WCHAR suffixW[] = {'.','p','o','l','i','c','y',0};
|
2012-04-30 09:34:30 +02:00
|
|
|
WCHAR sxsdir[MAX_PATH], *ret, *fullname;
|
|
|
|
unsigned int len;
|
|
|
|
|
|
|
|
if (!(fullname = build_policy_name( arch, name, token, &len ))) return NULL;
|
|
|
|
len += build_sxs_path( sxsdir );
|
2018-07-18 23:01:33 +02:00
|
|
|
len += ARRAY_SIZE(policiesW) - 1;
|
2019-06-21 08:50:39 +02:00
|
|
|
len += lstrlenW( version );
|
2018-07-18 23:01:33 +02:00
|
|
|
len += ARRAY_SIZE(suffixW) - 1;
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(ret = malloc( (len + 1) * sizeof(WCHAR) )))
|
2012-04-30 09:34:30 +02:00
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( fullname );
|
2012-04-30 09:34:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcpyW( ret, sxsdir );
|
|
|
|
lstrcatW( ret, policiesW );
|
2012-04-30 09:34:30 +02:00
|
|
|
CreateDirectoryW( ret, NULL );
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcatW( ret, name );
|
2012-04-30 09:34:30 +02:00
|
|
|
CreateDirectoryW( ret, NULL );
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcatW( ret, backslashW );
|
|
|
|
lstrcatW( ret, version );
|
|
|
|
lstrcatW( ret, suffixW );
|
2012-04-30 09:34:30 +02:00
|
|
|
|
2022-03-30 08:48:15 +02:00
|
|
|
free( fullname );
|
2012-04-30 09:34:30 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT install_policy( const WCHAR *manifest, struct assembly *assembly )
|
|
|
|
{
|
|
|
|
WCHAR *dst;
|
2010-12-10 12:53:50 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* FIXME: handle catalog file */
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
dst = build_policy_filename( assembly->arch, assembly->name, assembly->token, assembly->version );
|
|
|
|
if (!dst) return E_OUTOFMEMORY;
|
2010-12-10 12:53:50 +01:00
|
|
|
|
|
|
|
ret = CopyFileW( manifest, dst, FALSE );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( dst );
|
2010-12-10 12:53:50 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
2012-04-30 09:34:30 +02:00
|
|
|
HRESULT hr = HRESULT_FROM_WIN32( GetLastError() );
|
2022-02-18 09:17:10 +01:00
|
|
|
WARN("failed to copy policy manifest file 0x%08lx\n", hr);
|
2012-04-30 09:34:30 +02:00
|
|
|
return hr;
|
2010-12-10 12:53:50 +01:00
|
|
|
}
|
2012-04-30 09:34:30 +02:00
|
|
|
return S_OK;
|
2010-12-10 12:53:50 +01:00
|
|
|
}
|
|
|
|
|
2010-11-05 11:36:49 +01:00
|
|
|
static WCHAR *build_source_filename( const WCHAR *manifest, struct file *file )
|
|
|
|
{
|
|
|
|
WCHAR *src;
|
|
|
|
const WCHAR *p;
|
|
|
|
int len;
|
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
p = wcsrchr( manifest, '\\' );
|
|
|
|
if (!p) p = wcsrchr( manifest, '/' );
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!p) return wcsdup( manifest );
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
len = p - manifest + 1;
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(src = malloc( (len + lstrlenW( file->name ) + 1) * sizeof(WCHAR) )))
|
2010-11-05 11:36:49 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memcpy( src, manifest, len * sizeof(WCHAR) );
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcpyW( src + len, file->name );
|
2010-11-05 11:36:49 +01:00
|
|
|
return src;
|
|
|
|
}
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
static WCHAR *build_manifest_filename( const WCHAR *arch, const WCHAR *name, const WCHAR *token,
|
|
|
|
const WCHAR *version )
|
2010-11-05 11:36:49 +01:00
|
|
|
{
|
|
|
|
static const WCHAR manifestsW[] = {'m','a','n','i','f','e','s','t','s','\\',0};
|
|
|
|
static const WCHAR suffixW[] = {'.','m','a','n','i','f','e','s','t',0};
|
2012-04-30 09:34:30 +02:00
|
|
|
WCHAR sxsdir[MAX_PATH], *ret, *fullname;
|
|
|
|
unsigned int len;
|
|
|
|
|
|
|
|
if (!(fullname = build_assembly_name( arch, name, token, version, &len ))) return NULL;
|
|
|
|
len += build_sxs_path( sxsdir );
|
2018-07-18 23:01:33 +02:00
|
|
|
len += ARRAY_SIZE(manifestsW) - 1;
|
|
|
|
len += ARRAY_SIZE(suffixW) - 1;
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(ret = malloc( (len + 1) * sizeof(WCHAR) )))
|
2012-04-30 09:34:30 +02:00
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( fullname );
|
2012-04-30 09:34:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcpyW( ret, sxsdir );
|
|
|
|
lstrcatW( ret, manifestsW );
|
|
|
|
lstrcatW( ret, fullname );
|
|
|
|
lstrcatW( ret, suffixW );
|
2012-04-30 09:34:30 +02:00
|
|
|
|
2022-03-30 08:48:15 +02:00
|
|
|
free( fullname );
|
2012-04-30 09:34:30 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT load_manifest( IXMLDOMDocument *doc, const WCHAR *filename )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANT var;
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
BSTR str;
|
|
|
|
|
|
|
|
str = SysAllocString( filename );
|
|
|
|
VariantInit( &var );
|
|
|
|
V_VT( &var ) = VT_BSTR;
|
|
|
|
V_BSTR( &var ) = str;
|
|
|
|
hr = IXMLDOMDocument_load( doc, var, &b );
|
|
|
|
SysFreeString( str );
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
if (!b)
|
|
|
|
{
|
|
|
|
WARN("failed to load manifest\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembly )
|
|
|
|
{
|
2012-03-30 10:21:11 +02:00
|
|
|
WCHAR sxsdir[MAX_PATH], *p, *name, *dst, *src;
|
2012-04-30 09:34:30 +02:00
|
|
|
unsigned int len, len_name, len_sxsdir = build_sxs_path( sxsdir );
|
2010-11-05 11:36:49 +01:00
|
|
|
struct file *file;
|
2010-12-10 12:53:50 +01:00
|
|
|
HRESULT hr = E_OUTOFMEMORY;
|
2010-11-05 11:36:49 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
dst = build_manifest_filename( assembly->arch, assembly->name, assembly->token, assembly->version );
|
|
|
|
if (!dst) return E_OUTOFMEMORY;
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
ret = CopyFileW( manifest, dst, FALSE );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( dst );
|
2010-11-05 11:36:49 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
hr = HRESULT_FROM_WIN32( GetLastError() );
|
2022-02-18 09:17:10 +01:00
|
|
|
WARN("failed to copy manifest file 0x%08lx\n", hr);
|
2012-04-30 09:34:30 +02:00
|
|
|
return hr;
|
2010-11-05 11:36:49 +01:00
|
|
|
}
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
name = build_assembly_name( assembly->arch, assembly->name, assembly->token, assembly->version,
|
|
|
|
&len_name );
|
|
|
|
if (!name) return E_OUTOFMEMORY;
|
|
|
|
|
2010-11-05 11:36:49 +01:00
|
|
|
/* FIXME: this should be a transaction */
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &assembly->files, struct file, entry )
|
|
|
|
{
|
2012-04-30 09:34:30 +02:00
|
|
|
if (!(src = build_source_filename( manifest, file ))) goto done;
|
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
len = len_sxsdir + len_name + lstrlenW( file->name );
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(dst = malloc( (len + 2) * sizeof(WCHAR) )))
|
2010-11-05 11:36:49 +01:00
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( src );
|
2010-11-05 11:36:49 +01:00
|
|
|
goto done;
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcpyW( dst, sxsdir );
|
|
|
|
lstrcatW( dst, name );
|
2010-11-05 11:36:49 +01:00
|
|
|
CreateDirectoryW( dst, NULL );
|
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcatW( dst, backslashW );
|
|
|
|
lstrcatW( dst, file->name );
|
|
|
|
for (p = dst; *p; p++) *p = towlower( *p );
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
ret = CopyFileW( src, dst, FALSE );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( src );
|
|
|
|
free( dst );
|
2010-11-05 11:36:49 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
hr = HRESULT_FROM_WIN32( GetLastError() );
|
2022-02-18 09:17:10 +01:00
|
|
|
WARN("failed to copy file 0x%08lx\n", hr);
|
2010-11-05 11:36:49 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
2010-12-10 12:53:50 +01:00
|
|
|
hr = S_OK;
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
done:
|
2022-03-30 08:48:15 +02:00
|
|
|
free( name );
|
2010-11-05 11:36:49 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-11-03 15:09:08 +01:00
|
|
|
static HRESULT WINAPI cache_InstallAssembly(
|
|
|
|
IAssemblyCache *iface,
|
|
|
|
DWORD flags,
|
|
|
|
LPCWSTR path,
|
|
|
|
LPCFUSION_INSTALL_REFERENCE ref )
|
|
|
|
{
|
2012-04-30 09:35:10 +02:00
|
|
|
struct cache *cache = impl_from_IAssemblyCache( iface );
|
2010-11-05 11:36:49 +01:00
|
|
|
HRESULT hr, init;
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
struct assembly *assembly = NULL;
|
|
|
|
|
2022-02-18 09:17:10 +01:00
|
|
|
TRACE("%p, 0x%08lx, %s, %p\n", iface, flags, debugstr_w(path), ref);
|
2010-11-05 11:36:49 +01:00
|
|
|
|
2012-04-30 09:35:10 +02:00
|
|
|
cache_lock( cache );
|
2010-11-05 11:36:49 +01:00
|
|
|
init = CoInitialize( NULL );
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&doc );
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto done;
|
|
|
|
|
2012-04-30 09:34:30 +02:00
|
|
|
if ((hr = load_manifest( doc, path )) != S_OK) goto done;
|
|
|
|
if ((hr = parse_assembly( doc, &assembly )) != S_OK) goto done;
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
/* FIXME: verify name attributes */
|
|
|
|
|
2019-06-21 08:50:39 +02:00
|
|
|
if (!wcscmp( assembly->type, win32_policyW ))
|
2010-12-10 12:53:50 +01:00
|
|
|
hr = install_policy( path, assembly );
|
|
|
|
else
|
|
|
|
hr = install_assembly( path, assembly );
|
2010-11-05 11:36:49 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
free_assembly( assembly );
|
|
|
|
if (doc) IXMLDOMDocument_Release( doc );
|
2012-04-30 09:34:30 +02:00
|
|
|
if (SUCCEEDED(init)) CoUninitialize();
|
2012-04-30 09:35:10 +02:00
|
|
|
cache_unlock( cache );
|
2010-11-05 11:36:49 +01:00
|
|
|
return hr;
|
2010-11-03 15:09:08 +01:00
|
|
|
}
|
|
|
|
|
2012-04-30 09:34:52 +02:00
|
|
|
static HRESULT uninstall_assembly( struct assembly *assembly )
|
|
|
|
{
|
|
|
|
WCHAR sxsdir[MAX_PATH], *name, *dirname, *filename;
|
|
|
|
unsigned int len, len_name, len_sxsdir = build_sxs_path( sxsdir );
|
|
|
|
HRESULT hr = E_OUTOFMEMORY;
|
|
|
|
struct file *file;
|
|
|
|
|
|
|
|
name = build_assembly_name( assembly->arch, assembly->name, assembly->token, assembly->version,
|
|
|
|
&len_name );
|
|
|
|
if (!name) return E_OUTOFMEMORY;
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(dirname = malloc( (len_sxsdir + len_name + 1) * sizeof(WCHAR) )))
|
2012-04-30 09:34:52 +02:00
|
|
|
goto done;
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcpyW( dirname, sxsdir );
|
|
|
|
lstrcpyW( dirname + len_sxsdir, name );
|
2012-04-30 09:34:52 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &assembly->files, struct file, entry )
|
|
|
|
{
|
2019-06-21 08:50:39 +02:00
|
|
|
len = len_sxsdir + len_name + 1 + lstrlenW( file->name );
|
2022-03-30 08:48:15 +02:00
|
|
|
if (!(filename = malloc( (len + 1) * sizeof(WCHAR) ))) goto done;
|
2019-06-21 08:50:39 +02:00
|
|
|
lstrcpyW( filename, dirname );
|
|
|
|
lstrcatW( filename, backslashW );
|
|
|
|
lstrcatW( filename, file->name );
|
2012-04-30 09:34:52 +02:00
|
|
|
|
2022-02-18 09:17:10 +01:00
|
|
|
if (!DeleteFileW( filename )) WARN( "failed to delete file %lu\n", GetLastError() );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( filename );
|
2012-04-30 09:34:52 +02:00
|
|
|
}
|
|
|
|
RemoveDirectoryW( dirname );
|
|
|
|
hr = S_OK;
|
|
|
|
|
|
|
|
done:
|
2022-03-30 08:48:15 +02:00
|
|
|
free( dirname );
|
|
|
|
free( name );
|
2012-04-30 09:34:52 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI cache_UninstallAssembly(
|
|
|
|
IAssemblyCache *iface,
|
|
|
|
DWORD flags,
|
|
|
|
LPCWSTR assembly_name,
|
|
|
|
LPCFUSION_INSTALL_REFERENCE ref,
|
|
|
|
ULONG *disp )
|
|
|
|
{
|
2012-04-30 09:35:10 +02:00
|
|
|
struct cache *cache = impl_from_IAssemblyCache( iface );
|
2012-04-30 09:34:52 +02:00
|
|
|
HRESULT hr, init;
|
|
|
|
IXMLDOMDocument *doc = NULL;
|
|
|
|
struct assembly *assembly = NULL;
|
|
|
|
IAssemblyName *name_obj = NULL;
|
|
|
|
const WCHAR *arch, *name, *token, *type, *version;
|
|
|
|
WCHAR *p, *path = NULL;
|
|
|
|
|
2022-02-18 09:17:10 +01:00
|
|
|
TRACE("%p, 0x%08lx, %s, %p, %p\n", iface, flags, debugstr_w(assembly_name), ref, disp);
|
2012-04-30 09:34:52 +02:00
|
|
|
|
|
|
|
if (ref)
|
|
|
|
{
|
|
|
|
FIXME("application reference not supported\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2012-04-30 09:35:10 +02:00
|
|
|
cache_lock( cache );
|
2012-04-30 09:34:52 +02:00
|
|
|
init = CoInitialize( NULL );
|
|
|
|
|
|
|
|
hr = CreateAssemblyNameObject( &name_obj, assembly_name, CANOF_PARSE_DISPLAY_NAME, NULL );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
arch = get_name_attribute( name_obj, NAME_ATTR_ID_ARCH );
|
|
|
|
name = get_name_attribute( name_obj, NAME_ATTR_ID_NAME );
|
|
|
|
token = get_name_attribute( name_obj, NAME_ATTR_ID_TOKEN );
|
|
|
|
type = get_name_attribute( name_obj, NAME_ATTR_ID_TYPE );
|
|
|
|
version = get_name_attribute( name_obj, NAME_ATTR_ID_VERSION );
|
|
|
|
if (!arch || !name || !token || !type || !version)
|
|
|
|
{
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
goto done;
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
if (!wcscmp( type, win32W )) path = build_manifest_filename( arch, name, token, version );
|
|
|
|
else if (!wcscmp( type, win32_policyW )) path = build_policy_filename( arch, name, token, version );
|
2012-04-30 09:34:52 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&doc );
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if ((hr = load_manifest( doc, path )) != S_OK) goto done;
|
|
|
|
if ((hr = parse_assembly( doc, &assembly )) != S_OK) goto done;
|
|
|
|
|
2022-02-18 09:17:10 +01:00
|
|
|
if (!DeleteFileW( path )) WARN( "unable to remove manifest file %lu\n", GetLastError() );
|
2019-06-21 08:50:39 +02:00
|
|
|
else if ((p = wcsrchr( path, '\\' )))
|
2012-04-30 09:34:52 +02:00
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
RemoveDirectoryW( path );
|
|
|
|
}
|
2019-06-21 08:50:39 +02:00
|
|
|
if (!wcscmp( assembly->type, win32W )) hr = uninstall_assembly( assembly );
|
2012-04-30 09:34:52 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (name_obj) IAssemblyName_Release( name_obj );
|
2022-03-30 08:48:15 +02:00
|
|
|
free( path );
|
2012-04-30 09:34:52 +02:00
|
|
|
free_assembly( assembly );
|
|
|
|
if (doc) IXMLDOMDocument_Release( doc );
|
|
|
|
if (SUCCEEDED(init)) CoUninitialize();
|
2012-04-30 09:35:10 +02:00
|
|
|
cache_unlock( cache );
|
2012-04-30 09:34:52 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-11-03 15:09:08 +01:00
|
|
|
static const IAssemblyCacheVtbl cache_vtbl =
|
|
|
|
{
|
|
|
|
cache_QueryInterface,
|
|
|
|
cache_AddRef,
|
|
|
|
cache_Release,
|
|
|
|
cache_UninstallAssembly,
|
|
|
|
cache_QueryAssemblyInfo,
|
|
|
|
cache_CreateAssemblyCacheItem,
|
|
|
|
cache_Reserved,
|
|
|
|
cache_InstallAssembly
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* CreateAssemblyCache (SXS.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateAssemblyCache( IAssemblyCache **obj, DWORD reserved )
|
|
|
|
{
|
|
|
|
struct cache *cache;
|
|
|
|
|
2022-02-18 09:17:10 +01:00
|
|
|
TRACE("%p, %lu\n", obj, reserved);
|
2010-11-03 15:09:08 +01:00
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
2022-03-30 08:48:15 +02:00
|
|
|
cache = malloc( sizeof(*cache) );
|
2010-11-03 15:09:08 +01:00
|
|
|
if (!cache)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-01-14 00:39:39 +01:00
|
|
|
cache->IAssemblyCache_iface.lpVtbl = &cache_vtbl;
|
2010-11-03 15:09:08 +01:00
|
|
|
cache->refs = 1;
|
2012-04-30 09:35:10 +02:00
|
|
|
cache->lock = CreateMutexW( NULL, FALSE, cache_mutex_nameW );
|
|
|
|
if (!cache->lock)
|
|
|
|
{
|
2022-03-30 08:48:15 +02:00
|
|
|
free( cache );
|
2012-04-30 09:35:10 +02:00
|
|
|
return HRESULT_FROM_WIN32( GetLastError() );
|
|
|
|
}
|
2011-01-14 00:39:39 +01:00
|
|
|
*obj = &cache->IAssemblyCache_iface;
|
2010-11-03 15:09:08 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|