ReactOS 0.4.17-dev-966-gf06eace
cache.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "winsxs.h"
#include "msxml2.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "sxs_private.h"
Include dependency graph for cache.c:

Go to the source code of this file.

Classes

struct  cache
 
struct  file
 
struct  assembly
 

Macros

#define COBJMACROS
 
#define INITGUID
 
#define ASSEMBLYINFO_FLAG_INSTALLED   1
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (sxs)
 
static struct cache * impl_from_IAssemblyCache (IAssemblyCache *iface)
 
static HRESULT WINAPI cache_QueryInterface (IAssemblyCache *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI cache_AddRef (IAssemblyCache *iface)
 
static ULONG WINAPI cache_Release (IAssemblyCache *iface)
 
static unsigned int build_sxs_path (WCHAR *path)
 
static WCHAR * build_assembly_name (const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version, unsigned int *len)
 
static WCHAR * build_dll_path (const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
 
static WCHAR * build_policy_name (const WCHAR *arch, const WCHAR *name, const WCHAR *token, unsigned int *len)
 
static WCHAR * build_policy_path (const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
 
static void cache_lock (struct cache *cache)
 
static void cache_unlock (struct cache *cache)
 
static HRESULT WINAPI cache_QueryAssemblyInfo (IAssemblyCache *iface, DWORD flags, LPCWSTR assembly_name, ASSEMBLY_INFO *info)
 
static HRESULT WINAPI cache_CreateAssemblyCacheItem (IAssemblyCache *iface, DWORD flags, PVOID reserved, IAssemblyCacheItem **item, LPCWSTR name)
 
static HRESULT WINAPI cache_Reserved (IAssemblyCache *iface, IUnknown **reserved)
 
static BSTR get_attribute_value (IXMLDOMNamedNodeMap *map, const WCHAR *value_name)
 
static void free_assembly (struct assembly *assembly)
 
static HRESULT parse_files (IXMLDOMDocument *doc, struct assembly *assembly)
 
static HRESULT parse_assembly (IXMLDOMDocument *doc, struct assembly **assembly)
 
static WCHAR * build_policy_filename (const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
 
static HRESULT install_policy (const WCHAR *manifest, struct assembly *assembly)
 
static WCHAR * build_source_filename (const WCHAR *manifest, struct file *file)
 
static WCHAR * build_manifest_filename (const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
 
static HRESULT load_manifest (IXMLDOMDocument *doc, const WCHAR *filename)
 
static HRESULT install_assembly (const WCHAR *manifest, struct assembly *assembly)
 
static HRESULT WINAPI cache_InstallAssembly (IAssemblyCache *iface, DWORD flags, LPCWSTR path, LPCFUSION_INSTALL_REFERENCE ref)
 
static HRESULT uninstall_assembly (struct assembly *assembly)
 
static HRESULT WINAPI cache_UninstallAssembly (IAssemblyCache *iface, DWORD flags, LPCWSTR assembly_name, LPCFUSION_INSTALL_REFERENCE ref, ULONG *disp)
 
HRESULT WINAPI CreateAssemblyCache (IAssemblyCache **obj, DWORD reserved)
 

Variables

static const WCHAR cache_mutex_nameW [] = L"__WINE_SXS_CACHE_MUTEX__"
 
static const IAssemblyCacheVtbl cache_vtbl
 

Macro Definition Documentation

◆ ASSEMBLYINFO_FLAG_INSTALLED

#define ASSEMBLYINFO_FLAG_INSTALLED   1

Definition at line 103 of file fusion.idl.

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file cache.c.

◆ INITGUID

#define INITGUID

Definition at line 24 of file cache.c.

Function Documentation

◆ build_assembly_name()

static WCHAR * build_assembly_name ( const WCHAR *  arch,
const WCHAR *  name,
const WCHAR *  token,
const WCHAR *  version,
unsigned int *  len 
)
static

Definition at line 101 of file cache.c.

103{
104 static const WCHAR fmtW[] = L"%s_%s_%s_%s_none_deadbeef";
105 unsigned int buflen = ARRAY_SIZE(fmtW);
106 WCHAR *ret;
107
108 buflen += lstrlenW( arch );
109 buflen += lstrlenW( name );
110 buflen += lstrlenW( token );
111 buflen += lstrlenW( version );
112 if (!(ret = malloc( buflen * sizeof(WCHAR) ))) return NULL;
113 *len = swprintf( ret, buflen, fmtW, arch, name, token, version );
114 return wcslwr( ret );
115}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define lstrlenW
Definition: compat.h:750
static const WCHAR version[]
Definition: asmname.c:66
static wchar_t * wcslwr(wchar_t *str)
Definition: string.h:96
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
short WCHAR
Definition: pedump.c:58
Definition: name.c:39

Referenced by build_dll_path(), build_manifest_filename(), install_assembly(), and uninstall_assembly().

◆ build_dll_path()

static WCHAR * build_dll_path ( const WCHAR *  arch,
const WCHAR *  name,
const WCHAR *  token,
const WCHAR *  version 
)
static

Definition at line 117 of file cache.c.

119{
120 WCHAR *path = NULL, *ret, sxsdir[MAX_PATH];
121 unsigned int len;
122
123 if (!(path = build_assembly_name( arch, name, token, version, &len ))) return NULL;
124 len += build_sxs_path( sxsdir ) + 2;
125 if (!(ret = malloc( len * sizeof(WCHAR) )))
126 {
127 free( path );
128 return NULL;
129 }
130 lstrcpyW( ret, sxsdir );
131 lstrcatW( ret, path );
132 lstrcatW( ret, L"\\" );
133 free( path );
134 return ret;
135}
#define free
Definition: debug_ros.c:5
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
static unsigned int build_sxs_path(WCHAR *path)
Definition: cache.c:92
static WCHAR * build_assembly_name(const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version, unsigned int *len)
Definition: cache.c:101
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by cache_QueryAssemblyInfo().

◆ build_manifest_filename()

static WCHAR * build_manifest_filename ( const WCHAR *  arch,
const WCHAR *  name,
const WCHAR *  token,
const WCHAR *  version 
)
static

Definition at line 542 of file cache.c.

544{
545 static const WCHAR manifestsW[] = L"manifests\\";
546 static const WCHAR suffixW[] = L".manifest";
547 WCHAR sxsdir[MAX_PATH], *ret, *fullname;
548 unsigned int len;
549
550 if (!(fullname = build_assembly_name( arch, name, token, version, &len ))) return NULL;
551 len += build_sxs_path( sxsdir );
552 len += ARRAY_SIZE(manifestsW) - 1;
553 len += ARRAY_SIZE(suffixW) - 1;
554 if (!(ret = malloc( (len + 1) * sizeof(WCHAR) )))
555 {
556 free( fullname );
557 return NULL;
558 }
559 lstrcpyW( ret, sxsdir );
560 lstrcatW( ret, manifestsW );
562 lstrcatW( ret, suffixW );
563
564 free( fullname );
565 return ret;
566}
const char * fullname
Definition: shader.c:1979

Referenced by cache_UninstallAssembly(), and install_assembly().

◆ build_policy_filename()

static WCHAR * build_policy_filename ( const WCHAR *  arch,
const WCHAR *  name,
const WCHAR *  token,
const WCHAR *  version 
)
static

Definition at line 471 of file cache.c.

473{
474 static const WCHAR policiesW[] = L"policies\\";
475 static const WCHAR suffixW[] = L".policy";
476 WCHAR sxsdir[MAX_PATH], *ret, *fullname;
477 unsigned int len;
478
479 if (!(fullname = build_policy_name( arch, name, token, &len ))) return NULL;
480 len += build_sxs_path( sxsdir );
481 len += ARRAY_SIZE(policiesW) - 1;
482 len += lstrlenW( version );
483 len += ARRAY_SIZE(suffixW) - 1;
484 if (!(ret = malloc( (len + 1) * sizeof(WCHAR) )))
485 {
486 free( fullname );
487 return NULL;
488 }
489 lstrcpyW( ret, sxsdir );
490 lstrcatW( ret, policiesW );
492 lstrcatW( ret, name );
494 lstrcatW( ret, L"\\" );
495 lstrcatW( ret, version );
496 lstrcatW( ret, suffixW );
497
498 free( fullname );
499 return ret;
500}
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
static WCHAR * build_policy_name(const WCHAR *arch, const WCHAR *name, const WCHAR *token, unsigned int *len)
Definition: cache.c:137

Referenced by cache_UninstallAssembly(), and install_policy().

◆ build_policy_name()

static WCHAR * build_policy_name ( const WCHAR *  arch,
const WCHAR *  name,
const WCHAR *  token,
unsigned int *  len 
)
static

Definition at line 137 of file cache.c.

139{
140 static const WCHAR fmtW[] = L"%s_%s_%s_none_deadbeef";
141 unsigned int buflen = ARRAY_SIZE(fmtW);
142 WCHAR *ret;
143
144 buflen += lstrlenW( arch );
145 buflen += lstrlenW( name );
146 buflen += lstrlenW( token );
147 if (!(ret = malloc( buflen * sizeof(WCHAR) ))) return NULL;
148 *len = swprintf( ret, buflen, fmtW, arch, name, token );
149 return wcslwr( ret );
150}

Referenced by build_policy_filename(), and build_policy_path().

◆ build_policy_path()

static WCHAR * build_policy_path ( const WCHAR *  arch,
const WCHAR *  name,
const WCHAR *  token,
const WCHAR *  version 
)
static

Definition at line 152 of file cache.c.

154{
155 static const WCHAR fmtW[] = L"%spolicies\\%s\\%s.policy";
156 WCHAR *path = NULL, *ret, sxsdir[MAX_PATH];
157 unsigned int len;
158
159 if (!(path = build_policy_name( arch, name, token, &len ))) return NULL;
160 len += ARRAY_SIZE(fmtW);
161 len += build_sxs_path( sxsdir );
162 len += lstrlenW( version );
163 if (!(ret = malloc( len * sizeof(WCHAR) )))
164 {
165 free( path );
166 return NULL;
167 }
168 swprintf( ret, len, fmtW, sxsdir, path, version );
169 free( path );
170 return ret;
171}

Referenced by cache_QueryAssemblyInfo().

◆ build_source_filename()

static WCHAR * build_source_filename ( const WCHAR *  manifest,
struct file *  file 
)
static

Definition at line 523 of file cache.c.

524{
525 WCHAR *src;
526 const WCHAR *p;
527 int len;
528
529 p = wcsrchr( manifest, '\\' );
530 if (!p) p = wcsrchr( manifest, '/' );
531 if (!p) return wcsdup( manifest );
532
533 len = p - manifest + 1;
534 if (!(src = malloc( (len + lstrlenW( file->name ) + 1) * sizeof(WCHAR) )))
535 return NULL;
536
537 memcpy( src, manifest, len * sizeof(WCHAR) );
538 lstrcpyW( src + len, file->name );
539 return src;
540}
#define wcsrchr
Definition: compat.h:16
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
GLenum src
Definition: glext.h:6340
GLfloat GLfloat p
Definition: glext.h:8902
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: fci.c:123
char name[1]
Definition: fci.c:131
static const CHAR manifest[]
Definition: v6util.h:41

Referenced by install_assembly().

◆ build_sxs_path()

static unsigned int build_sxs_path ( WCHAR *  path)
static

Definition at line 92 of file cache.c.

93{
94 static const WCHAR winsxsW[] = L"\\winsxs\\";
95 unsigned int len = GetWindowsDirectoryW( path, MAX_PATH );
96
97 memcpy( path + len, winsxsW, sizeof(winsxsW) );
98 return len + ARRAY_SIZE(winsxsW) - 1;
99}
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2370

Referenced by build_dll_path(), build_manifest_filename(), build_policy_filename(), build_policy_path(), install_assembly(), and uninstall_assembly().

◆ cache_AddRef()

static ULONG WINAPI cache_AddRef ( IAssemblyCache *  iface)
static

Definition at line 72 of file cache.c.

73{
74 struct cache *cache = impl_from_IAssemblyCache(iface);
76}
#define InterlockedIncrement
Definition: armddk.h:53
static struct cache * impl_from_IAssemblyCache(IAssemblyCache *iface)
Definition: cache.c:47
Definition: cache.c:41
LONG refs
Definition: cache.c:43

◆ cache_CreateAssemblyCacheItem()

static HRESULT WINAPI cache_CreateAssemblyCacheItem ( IAssemblyCache *  iface,
DWORD  flags,
PVOID  reserved,
IAssemblyCacheItem **  item,
LPCWSTR  name 
)
static

Definition at line 260 of file cache.c.

266{
267 FIXME("%p, 0x%08lx, %p, %p, %s\n", iface, flags, reserved, item, debugstr_w(name));
268 return E_NOTIMPL;
269}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99
r reserved
Definition: btrfs.c:3006
GLbitfield flags
Definition: glext.h:7161
#define debugstr_w
Definition: kernel32.h:32

◆ cache_InstallAssembly()

static HRESULT WINAPI cache_InstallAssembly ( IAssemblyCache *  iface,
DWORD  flags,
LPCWSTR  path,
LPCFUSION_INSTALL_REFERENCE  ref 
)
static

Definition at line 657 of file cache.c.

662{
663 struct cache *cache = impl_from_IAssemblyCache( iface );
664 HRESULT hr, init;
665 IXMLDOMDocument *doc = NULL;
666 struct assembly *assembly = NULL;
667
668 TRACE("%p, 0x%08lx, %s, %p\n", iface, flags, debugstr_w(path), ref);
669
670 cache_lock( cache );
672
673 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&doc );
674 if (hr != S_OK)
675 goto done;
676
677 if ((hr = load_manifest( doc, path )) != S_OK) goto done;
678 if ((hr = parse_assembly( doc, &assembly )) != S_OK) goto done;
679
680 /* FIXME: verify name attributes */
681
682 if (!wcscmp( assembly->type, L"win32-policy" ))
684 else
686
687done:
689 if (doc) IXMLDOMDocument_Release( doc );
692 return hr;
693}
HRESULT hr
Definition: delayimp.cpp:582
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
static HRESULT load_manifest(IXMLDOMDocument *doc, const WCHAR *filename)
Definition: cache.c:568
static void cache_unlock(struct cache *cache)
Definition: cache.c:178
static HRESULT install_assembly(const WCHAR *manifest, struct assembly *assembly)
Definition: cache.c:590
static void free_assembly(struct assembly *assembly)
Definition: cache.c:319
static HRESULT install_policy(const WCHAR *manifest, struct assembly *assembly)
Definition: cache.c:502
static HRESULT parse_assembly(IXMLDOMDocument *doc, struct assembly **assembly)
Definition: cache.c:408
static SRWLOCK cache_lock
Definition: session.c:1973
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const struct _GUID CLSID_DOMDocument
#define TRACE(s)
Definition: solgame.cpp:4
BSTR type
Definition: cache.c:311
Definition: send.c:48
static int init
Definition: wintirpc.c:33

◆ cache_lock()

static void cache_lock ( struct cache *  cache)
static

Definition at line 173 of file cache.c.

174{
176}
#define INFINITE
Definition: serial.h:102
HANDLE lock
Definition: cache.c:44
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

◆ cache_QueryAssemblyInfo()

static HRESULT WINAPI cache_QueryAssemblyInfo ( IAssemblyCache *  iface,
DWORD  flags,
LPCWSTR  assembly_name,
ASSEMBLY_INFO *  info 
)
static

Definition at line 185 of file cache.c.

190{
191 struct cache *cache = impl_from_IAssemblyCache( iface );
192 IAssemblyName *name_obj;
193 const WCHAR *arch, *name, *token, *type, *version;
194 WCHAR *path = NULL;
195 unsigned int len;
196 HRESULT hr;
197
198 TRACE("%p, 0x%08lx, %s, %p\n", iface, flags, debugstr_w(assembly_name), info);
199
200 if (flags || (info && info->cbAssemblyInfo != sizeof(*info)))
201 return E_INVALIDARG;
202
204 if (FAILED( hr ))
205 return hr;
206
207 arch = get_name_attribute( name_obj, NAME_ATTR_ID_ARCH );
212 if (!arch || !name || !token || !type || !version)
213 {
214 IAssemblyName_Release( name_obj );
216 }
217 if (!info)
218 {
219 IAssemblyName_Release( name_obj );
220 return S_OK;
221 }
222 cache_lock( cache );
223
224 if (!wcscmp( type, L"win32" )) path = build_dll_path( arch, name, token, version );
225 else if (!wcscmp( type, L"win32-policy" )) path = build_policy_path( arch, name, token, version );
226 else
227 {
229 goto done;
230 }
231 if (!path)
232 {
234 goto done;
235 }
236 hr = S_OK;
237 if (GetFileAttributesW( path ) != INVALID_FILE_ATTRIBUTES) /* FIXME: better check */
238 {
239 info->dwAssemblyFlags = ASSEMBLYINFO_FLAG_INSTALLED;
240 TRACE("assembly is installed\n");
241 }
242 len = lstrlenW( path ) + 1;
243 if (info->pszCurrentAssemblyPathBuf)
244 {
245 if (info->cchBuf < len)
246 {
247 info->cchBuf = len;
249 }
250 else lstrcpyW( info->pszCurrentAssemblyPathBuf, path );
251 }
252
253done:
254 free( path );
255 IAssemblyName_Release( name_obj );
257 return hr;
258}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj, LPCWSTR szAssemblyName, DWORD dwFlags, LPVOID pvReserved)
Definition: asmname.c:795
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
static WCHAR * build_policy_path(const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
Definition: cache.c:152
#define ASSEMBLYINFO_FLAG_INSTALLED
Definition: fusion.idl:103
static WCHAR * build_dll_path(const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
Definition: cache.c:117
const WCHAR * get_name_attribute(IAssemblyName *iface, enum name_attr_id id)
Definition: name.c:177
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
@ NAME_ATTR_ID_VERSION
Definition: sxs_private.h:27
@ NAME_ATTR_ID_NAME
Definition: sxs_private.h:23
@ NAME_ATTR_ID_TYPE
Definition: sxs_private.h:26
@ NAME_ATTR_ID_ARCH
Definition: sxs_private.h:24
@ NAME_ATTR_ID_TOKEN
Definition: sxs_private.h:25
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE
Definition: winerror.h:3173
#define ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE
Definition: winerror.h:3184
@ CANOF_PARSE_DISPLAY_NAME
Definition: winsxs.idl:193

◆ cache_QueryInterface()

static HRESULT WINAPI cache_QueryInterface ( IAssemblyCache *  iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 52 of file cache.c.

56{
57 TRACE("%p, %s, %p\n", iface, debugstr_guid(riid), ret_iface);
58
59 *ret_iface = NULL;
60
62 IsEqualIID(riid, &IID_IAssemblyCache))
63 {
64 IAssemblyCache_AddRef( iface );
65 *ret_iface = iface;
66 return S_OK;
67 }
68
69 return E_NOINTERFACE;
70}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ cache_Release()

static ULONG WINAPI cache_Release ( IAssemblyCache *  iface)
static

Definition at line 78 of file cache.c.

79{
80 struct cache *cache = impl_from_IAssemblyCache(iface);
82
83 if (!refs)
84 {
85 TRACE("destroying %p\n", cache);
87 free( cache );
88 }
89 return refs;
90}
#define InterlockedDecrement
Definition: armddk.h:52
#define CloseHandle
Definition: compat.h:739
LONG refs
Definition: port.c:62
uint32_t ULONG
Definition: typedefs.h:59

◆ cache_Reserved()

static HRESULT WINAPI cache_Reserved ( IAssemblyCache *  iface,
IUnknown **  reserved 
)
static

Definition at line 271 of file cache.c.

274{
275 FIXME("%p\n", reserved);
276 return E_NOTIMPL;
277}

◆ cache_UninstallAssembly()

static HRESULT WINAPI cache_UninstallAssembly ( IAssemblyCache *  iface,
DWORD  flags,
LPCWSTR  assembly_name,
LPCFUSION_INSTALL_REFERENCE  ref,
ULONG *  disp 
)
static

Definition at line 730 of file cache.c.

736{
737 struct cache *cache = impl_from_IAssemblyCache( iface );
738 HRESULT hr, init;
739 IXMLDOMDocument *doc = NULL;
740 struct assembly *assembly = NULL;
741 IAssemblyName *name_obj = NULL;
742 const WCHAR *arch, *name, *token, *type, *version;
743 WCHAR *p, *path = NULL;
744
745 TRACE("%p, 0x%08lx, %s, %p, %p\n", iface, flags, debugstr_w(assembly_name), ref, disp);
746
747 if (ref)
748 {
749 FIXME("application reference not supported\n");
750 return E_NOTIMPL;
751 }
752 cache_lock( cache );
754
756 if (FAILED( hr ))
757 goto done;
758
764 if (!arch || !name || !token || !type || !version)
765 {
767 goto done;
768 }
769 if (!wcscmp( type, L"win32" )) path = build_manifest_filename( arch, name, token, version );
770 else if (!wcscmp( type, L"win32-policy" )) path = build_policy_filename( arch, name, token, version );
771 else
772 {
774 goto done;
775 }
776
777 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&doc );
778 if (hr != S_OK)
779 goto done;
780
781 if ((hr = load_manifest( doc, path )) != S_OK) goto done;
782 if ((hr = parse_assembly( doc, &assembly )) != S_OK) goto done;
783
784 if (!DeleteFileW( path )) WARN( "unable to remove manifest file %lu\n", GetLastError() );
785 else if ((p = wcsrchr( path, '\\' )))
786 {
787 *p = 0;
789 }
790 if (!wcscmp( assembly->type, L"win32" )) hr = uninstall_assembly( assembly );
791
792done:
793 if (name_obj) IAssemblyName_Release( name_obj );
794 free( path );
796 if (doc) IXMLDOMDocument_Release( doc );
799 return hr;
800}
#define WARN(fmt,...)
Definition: precomp.h:61
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:700
static HRESULT uninstall_assembly(struct assembly *assembly)
Definition: cache.c:695
static WCHAR * build_manifest_filename(const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
Definition: cache.c:542
static WCHAR * build_policy_filename(const WCHAR *arch, const WCHAR *name, const WCHAR *token, const WCHAR *version)
Definition: cache.c:471
BSTR name
Definition: cache.c:312
BSTR arch
Definition: cache.c:314
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ cache_unlock()

static void cache_unlock ( struct cache *  cache)
static

Definition at line 178 of file cache.c.

179{
181}
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:554

Referenced by cache_InstallAssembly(), cache_QueryAssemblyInfo(), and cache_UninstallAssembly().

◆ CreateAssemblyCache()

HRESULT WINAPI CreateAssemblyCache ( IAssemblyCache **  obj,
DWORD  reserved 
)

Definition at line 817 of file cache.c.

818{
819 struct cache *cache;
820
821 TRACE("%p, %lu\n", obj, reserved);
822
823 if (!obj)
824 return E_INVALIDARG;
825
826 *obj = NULL;
827
828 cache = malloc( sizeof(*cache) );
829 if (!cache)
830 return E_OUTOFMEMORY;
831
833 cache->refs = 1;
835 if (!cache->lock)
836 {
837 free( cache );
839 }
841 return S_OK;
842}
#define FALSE
Definition: types.h:117
static const IAssemblyCacheVtbl cache_vtbl
Definition: cache.c:802
static const WCHAR cache_mutex_nameW[]
Definition: cache.c:38
IAssemblyCache IAssemblyCache_iface
Definition: cache.c:42
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:525

Referenced by test_QueryAssemblyInfo().

◆ free_assembly()

static void free_assembly ( struct assembly *  assembly)
static

Definition at line 319 of file cache.c.

320{
321 struct list *item, *cursor;
322
323 if (!assembly) return;
330 {
331 struct file *file = LIST_ENTRY( item, struct file, entry );
334 free( file );
335 }
336 free( assembly );
337}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
Definition: list.h:39
const char cursor[]
Definition: icontest.c:13
uint32_t entry
Definition: isohybrid.c:63
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:230
BSTR version
Definition: cache.c:313
BSTR token
Definition: cache.c:315
struct list files
Definition: cache.c:316
struct list entry
Definition: fci.c:124
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by cache_InstallAssembly(), cache_UninstallAssembly(), and parse_assembly().

◆ get_attribute_value()

static BSTR get_attribute_value ( IXMLDOMNamedNodeMap *  map,
const WCHAR *  value_name 
)
static

Definition at line 279 of file cache.c.

280{
281 HRESULT hr;
283 VARIANT var;
284 BSTR str;
285
286 str = SysAllocString( value_name );
287 hr = IXMLDOMNamedNodeMap_getNamedItem( map, str, &attr );
289 if (hr != S_OK) return NULL;
290
291 hr = IXMLDOMNode_get_nodeValue( attr, &var );
292 IXMLDOMNode_Release( attr );
293 if (hr != S_OK) return NULL;
294 if (V_VT(&var) != VT_BSTR)
295 {
296 VariantClear( &var );
297 return NULL;
298 }
299 TRACE("%s=%s\n", debugstr_w(value_name), debugstr_w(V_BSTR( &var )));
300 return V_BSTR( &var );
301}
Definition: _map.h:48
OLECHAR * BSTR
Definition: compat.h:2293
@ VT_BSTR
Definition: compat.h:2303
const char * var
Definition: shader.c:5879
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:240
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
const WCHAR * str
Definition: cookie.c:202
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:626

Referenced by parse_assembly(), and parse_files().

◆ impl_from_IAssemblyCache()

static struct cache * impl_from_IAssemblyCache ( IAssemblyCache *  iface)
inlinestatic

Definition at line 47 of file cache.c.

48{
49 return CONTAINING_RECORD(iface, struct cache, IAssemblyCache_iface);
50}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by cache_AddRef(), cache_InstallAssembly(), cache_QueryAssemblyInfo(), cache_Release(), and cache_UninstallAssembly().

◆ install_assembly()

static HRESULT install_assembly ( const WCHAR *  manifest,
struct assembly *  assembly 
)
static

Definition at line 590 of file cache.c.

591{
592 WCHAR sxsdir[MAX_PATH], *p, *name, *dst, *src;
593 unsigned int len, len_name, len_sxsdir = build_sxs_path( sxsdir );
594 struct file *file;
596 BOOL ret;
597
599 if (!dst) return E_OUTOFMEMORY;
600
602 {
603 free( dst );
604 TRACE("manifest exists, skipping install\n");
605 return S_OK;
606 }
607
609 free( dst );
610 if (!ret)
611 {
613 WARN("failed to copy manifest file 0x%08lx\n", hr);
614 return hr;
615 }
616
618 &len_name );
619 if (!name) return E_OUTOFMEMORY;
620
621 /* FIXME: this should be a transaction */
623 {
624 if (!(src = build_source_filename( manifest, file ))) goto done;
625
626 len = len_sxsdir + len_name + lstrlenW( file->name );
627 if (!(dst = malloc( (len + 2) * sizeof(WCHAR) )))
628 {
629 free( src );
630 goto done;
631 }
632 lstrcpyW( dst, sxsdir );
633 lstrcatW( dst, name );
635
636 lstrcatW( dst, L"\\" );
637 lstrcatW( dst, file->name );
638 for (p = dst; *p; p++) *p = towlower( *p );
639
640 ret = CopyFileW( src, dst, FALSE );
641 free( src );
642 free( dst );
643 if (!ret)
644 {
646 WARN("failed to copy file 0x%08lx\n", hr);
647 goto done;
648 }
649 }
650 hr = S_OK;
651
652done:
653 free( name );
654 return hr;
655}
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:367
static WCHAR * build_source_filename(const WCHAR *manifest, struct file *file)
Definition: cache.c:523
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLenum dst
Definition: glext.h:6340
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
#define towlower(c)
Definition: wctype.h:97

Referenced by cache_InstallAssembly().

◆ install_policy()

static HRESULT install_policy ( const WCHAR *  manifest,
struct assembly *  assembly 
)
static

Definition at line 502 of file cache.c.

503{
504 WCHAR *dst;
505 BOOL ret;
506
507 /* FIXME: handle catalog file */
508
510 if (!dst) return E_OUTOFMEMORY;
511
513 free( dst );
514 if (!ret)
515 {
517 WARN("failed to copy policy manifest file 0x%08lx\n", hr);
518 return hr;
519 }
520 return S_OK;
521}

Referenced by cache_InstallAssembly().

◆ load_manifest()

static HRESULT load_manifest ( IXMLDOMDocument *  doc,
const WCHAR *  filename 
)
static

Definition at line 568 of file cache.c.

569{
570 HRESULT hr;
571 VARIANT var;
573 BSTR str;
574
576 VariantInit( &var );
577 V_VT( &var ) = VT_BSTR;
578 V_BSTR( &var ) = str;
579 hr = IXMLDOMDocument_load( doc, var, &b );
581 if (hr != S_OK) return hr;
582 if (!b)
583 {
584 WARN("failed to load manifest\n");
585 return S_FALSE;
586 }
587 return S_OK;
588}
short VARIANT_BOOL
Definition: compat.h:2290
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
const char * filename
Definition: ioapi.h:137
#define b
Definition: ke_i.h:79
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:547
#define S_FALSE
Definition: winerror.h:3451

Referenced by cache_InstallAssembly(), and cache_UninstallAssembly().

◆ parse_assembly()

static HRESULT parse_assembly ( IXMLDOMDocument *  doc,
struct assembly **  assembly 
)
static

Definition at line 408 of file cache.c.

409{
412 IXMLDOMNamedNodeMap *attrs = NULL;
413 struct assembly *a = NULL;
414 BSTR str;
415 HRESULT hr;
416 LONG len;
417
418 str = SysAllocString( L"assemblyIdentity" );
419 hr = IXMLDOMDocument_getElementsByTagName( doc, str, &list );
421 if (hr != S_OK) goto done;
422
423 hr = IXMLDOMNodeList_get_length( list, &len );
424 if (hr != S_OK) goto done;
425 if (!len)
426 {
428 goto done;
429 }
430 hr = IXMLDOMNodeList_nextNode( list, &node );
431 if (hr != S_OK) goto done;
432 if (!node)
433 {
435 goto done;
436 }
437 if (!(a = calloc(1, sizeof(*a) )))
438 {
440 goto done;
441 }
442 list_init( &a->files );
443
444 hr = IXMLDOMNode_get_attributes( node, &attrs );
445 if (hr != S_OK) goto done;
446
447 a->type = get_attribute_value( attrs, L"type" );
448 a->name = get_attribute_value( attrs, L"name" );
449 a->version = get_attribute_value( attrs, L"version" );
450 a->arch = get_attribute_value( attrs, L"processorArchitecture" );
451 a->token = get_attribute_value( attrs, L"publicKeyToken" );
452
453 if (!a->type || (wcscmp( a->type, L"win32" ) && wcscmp( a->type, L"win32-policy" )) ||
454 !a->name || !a->version || !a->arch || !a->token)
455 {
456 WARN("invalid win32 assembly\n");
458 goto done;
459 }
460 if (!wcscmp( a->type, L"win32" )) hr = parse_files( doc, a );
461
462done:
463 if (attrs) IXMLDOMNamedNodeMap_Release( attrs );
464 if (node) IXMLDOMNode_Release( node );
465 if (list) IXMLDOMNodeList_Release( list );
466 if (hr == S_OK) *assembly = a;
467 else free_assembly( a );
468 return hr;
469}
static void list_init(struct list_entry *head)
Definition: list.h:51
static BSTR get_attribute_value(IXMLDOMNamedNodeMap *map, const WCHAR *value_name)
Definition: cache.c:279
static HRESULT parse_files(IXMLDOMDocument *doc, struct assembly *assembly)
Definition: cache.c:339
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
long LONG
Definition: pedump.c:60
#define calloc
Definition: rosglue.h:14
Definition: dlist.c:348
#define ERROR_SXS_MANIFEST_FORMAT_ERROR
Definition: winerror.h:3098

Referenced by cache_InstallAssembly(), and cache_UninstallAssembly().

◆ parse_files()

static HRESULT parse_files ( IXMLDOMDocument *  doc,
struct assembly *  assembly 
)
static

Definition at line 339 of file cache.c.

340{
341 IXMLDOMNamedNodeMap *attrs;
344 struct file *f;
345 BSTR str;
346 HRESULT hr;
347 LONG len;
348
349 str = SysAllocString( L"file" );
350 hr = IXMLDOMDocument_getElementsByTagName( doc, str, &list );
352 if (hr != S_OK) return hr;
353
354 hr = IXMLDOMNodeList_get_length( list, &len );
355 if (hr != S_OK) goto done;
356 TRACE("found %ld files\n", len);
357 if (!len)
358 {
360 goto done;
361 }
362
363 for (;;)
364 {
365 hr = IXMLDOMNodeList_nextNode( list, &node );
366 if (hr != S_OK || !node)
367 {
368 hr = S_OK;
369 break;
370 }
371
372 /* FIXME: validate node type */
373
374 hr = IXMLDOMNode_get_attributes( node, &attrs );
375 IXMLDOMNode_Release( node );
376 if (hr != S_OK)
377 goto done;
378
379 if (!(f = malloc( sizeof(*f) )))
380 {
381 IXMLDOMNamedNodeMap_Release( attrs );
383 goto done;
384 }
385
386 f->name = get_attribute_value( attrs, L"name" );
387 IXMLDOMNamedNodeMap_Release( attrs );
388 if (!f->name)
389 {
390 free( f );
392 goto done;
393 }
394 list_add_tail( &assembly->files, &f->entry );
395 }
396
397 if (list_empty( &assembly->files ))
398 {
399 WARN("no files found\n");
401 }
402
403done:
404 IXMLDOMNodeList_Release( list );
405 return hr;
406}
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
#define list
Definition: rosglue.h:35
char * name
Definition: wpp.c:52

Referenced by parse_assembly().

◆ uninstall_assembly()

static HRESULT uninstall_assembly ( struct assembly *  assembly)
static

Definition at line 695 of file cache.c.

696{
697 WCHAR sxsdir[MAX_PATH], *name, *dirname, *filename;
698 unsigned int len, len_name, len_sxsdir = build_sxs_path( sxsdir );
700 struct file *file;
701
703 &len_name );
704 if (!name) return E_OUTOFMEMORY;
705 if (!(dirname = malloc( (len_sxsdir + len_name + 1) * sizeof(WCHAR) )))
706 goto done;
707 lstrcpyW( dirname, sxsdir );
708 lstrcpyW( dirname + len_sxsdir, name );
709
711 {
712 len = len_sxsdir + len_name + 1 + lstrlenW( file->name );
713 if (!(filename = malloc( (len + 1) * sizeof(WCHAR) ))) goto done;
715 lstrcatW( filename, L"\\" );
717
718 if (!DeleteFileW( filename )) WARN( "failed to delete file %lu\n", GetLastError() );
719 free( filename );
720 }
722 hr = S_OK;
723
724done:
725 free( dirname );
726 free( name );
727 return hr;
728}
__cdecl __MINGW_NOTHROW char * dirname(char *)

Referenced by cache_UninstallAssembly().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( sxs  )

Variable Documentation

◆ cache_mutex_nameW

const WCHAR cache_mutex_nameW[] = L"__WINE_SXS_CACHE_MUTEX__"
static

Definition at line 38 of file cache.c.

Referenced by CreateAssemblyCache().

◆ cache_vtbl

const IAssemblyCacheVtbl cache_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI cache_UninstallAssembly(IAssemblyCache *iface, DWORD flags, LPCWSTR assembly_name, LPCFUSION_INSTALL_REFERENCE ref, ULONG *disp)
Definition: cache.c:730
static ULONG WINAPI cache_AddRef(IAssemblyCache *iface)
Definition: cache.c:72
static HRESULT WINAPI cache_QueryInterface(IAssemblyCache *iface, REFIID riid, void **ret_iface)
Definition: cache.c:52
static HRESULT WINAPI cache_Reserved(IAssemblyCache *iface, IUnknown **reserved)
Definition: cache.c:271
static HRESULT WINAPI cache_CreateAssemblyCacheItem(IAssemblyCache *iface, DWORD flags, PVOID reserved, IAssemblyCacheItem **item, LPCWSTR name)
Definition: cache.c:260
static HRESULT WINAPI cache_InstallAssembly(IAssemblyCache *iface, DWORD flags, LPCWSTR path, LPCFUSION_INSTALL_REFERENCE ref)
Definition: cache.c:657
static HRESULT WINAPI cache_QueryAssemblyInfo(IAssemblyCache *iface, DWORD flags, LPCWSTR assembly_name, ASSEMBLY_INFO *info)
Definition: cache.c:185
static ULONG WINAPI cache_Release(IAssemblyCache *iface)
Definition: cache.c:78

Definition at line 802 of file cache.c.

Referenced by CreateAssemblyCache().