ReactOS 0.4.15-dev-8422-g6219a1a
assembly.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wine/debug.h"
#include "msipriv.h"
Include dependency graph for assembly.c:

Go to the source code of this file.

Classes

struct  assembly_name
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msi)
 
static BOOL load_fusion_dlls (MSIPACKAGE *package)
 
BOOL msi_init_assembly_caches (MSIPACKAGE *package)
 
void msi_destroy_assembly_caches (MSIPACKAGE *package)
 
static MSIRECORDget_assembly_record (MSIPACKAGE *package, const WCHAR *comp)
 
static UINT get_assembly_name_attribute (MSIRECORD *rec, LPVOID param)
 
static WCHARget_assembly_display_name (MSIDATABASE *db, const WCHAR *comp, MSIASSEMBLY *assembly)
 
static BOOL is_assembly_installed (IAssemblyCache *cache, const WCHAR *display_name)
 
WCHARmsi_get_assembly_path (MSIPACKAGE *package, const WCHAR *displayname)
 
IAssemblyEnummsi_create_assembly_enum (MSIPACKAGE *package, const WCHAR *displayname)
 
static const WCHARget_clr_version_str (enum clr_version version)
 
MSIASSEMBLYmsi_load_assembly (MSIPACKAGE *package, MSICOMPONENT *comp)
 
static enum clr_version get_clr_version (MSIPACKAGE *package, const WCHAR *filename)
 
UINT msi_install_assembly (MSIPACKAGE *package, MSICOMPONENT *comp)
 
UINT msi_uninstall_assembly (MSIPACKAGE *package, MSICOMPONENT *comp)
 
static WCHARbuild_local_assembly_path (const WCHAR *filename)
 
static LONG open_assemblies_key (UINT context, BOOL win32, HKEY *hkey)
 
static LONG open_local_assembly_key (UINT context, BOOL win32, const WCHAR *filename, HKEY *hkey)
 
static LONG delete_local_assembly_key (UINT context, BOOL win32, const WCHAR *filename)
 
static LONG open_global_assembly_key (UINT context, BOOL win32, HKEY *hkey)
 
UINT ACTION_MsiPublishAssemblies (MSIPACKAGE *package)
 
UINT ACTION_MsiUnpublishAssemblies (MSIPACKAGE *package)
 

Variables

static const WCHARclr_version []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file assembly.c.

Function Documentation

◆ ACTION_MsiPublishAssemblies()

UINT ACTION_MsiPublishAssemblies ( MSIPACKAGE package)

Definition at line 595 of file assembly.c.

596{
597 MSICOMPONENT *comp;
598
599 if (package->script == SCRIPT_NONE)
600 return msi_schedule_action(package, SCRIPT_INSTALL, L"MsiPublishAssemblies");
601
603 {
604 LONG res;
605 HKEY hkey;
606 GUID guid;
607 DWORD size;
608 WCHAR buffer[43];
609 MSIRECORD *uirow;
611 BOOL win32;
612
613 if (!assembly || !comp->ComponentId) continue;
614
615 comp->Action = msi_get_component_action( package, comp );
616 if (comp->Action != INSTALLSTATE_LOCAL)
617 {
618 TRACE("component not scheduled for installation %s\n", debugstr_w(comp->Component));
619 continue;
620 }
621 TRACE("publishing %s\n", debugstr_w(comp->Component));
622
623 CLSIDFromString( package->ProductCode, &guid );
625 buffer[20] = '>';
628 buffer[42] = 0;
629
630 win32 = assembly->attributes & msidbAssemblyAttributesWin32;
631 if (assembly->application)
632 {
633 MSIFILE *file = msi_get_loaded_file( package, assembly->application );
634 if (!file)
635 {
636 WARN("no matching file %s for local assembly\n", debugstr_w(assembly->application));
637 continue;
638 }
639 if ((res = open_local_assembly_key( package->Context, win32, file->TargetPath, &hkey )))
640 {
641 WARN( "failed to open local assembly key %ld\n", res );
643 }
644 }
645 else
646 {
647 if ((res = open_global_assembly_key( package->Context, win32, &hkey )))
648 {
649 WARN( "failed to open global assembly key %ld\n", res );
651 }
652 }
653 size = sizeof(buffer);
654 if ((res = RegSetValueExW( hkey, assembly->display_name, 0, REG_MULTI_SZ, (const BYTE *)buffer, size )))
655 {
656 WARN( "failed to set assembly value %ld\n", res );
657 }
658 RegCloseKey( hkey );
659
660 uirow = MSI_CreateRecord( 2 );
661 MSI_RecordSetStringW( uirow, 2, assembly->display_name );
663 msiobj_release( &uirow->hdr );
664 }
665 return ERROR_SUCCESS;
666}
#define WARN(fmt,...)
Definition: precomp.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
INSTALLSTATE msi_get_component_action(MSIPACKAGE *package, MSICOMPONENT *comp)
Definition: action.c:611
MSIFILE * msi_get_loaded_file(MSIPACKAGE *package, const WCHAR *key)
Definition: action.c:574
UINT msi_schedule_action(MSIPACKAGE *package, UINT script, const WCHAR *action)
Definition: custom.c:90
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:241
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_w
Definition: kernel32.h:32
const GUID * guid
static LONG open_local_assembly_key(UINT context, BOOL win32, const WCHAR *filename, HKEY *hkey)
Definition: assembly.c:535
static LONG open_global_assembly_key(UINT context, BOOL win32, HKEY *hkey)
Definition: assembly.c:575
@ INSTALLMESSAGE_ACTIONDATA
Definition: msi.h:103
@ INSTALLSTATE_LOCAL
Definition: msi.h:46
@ msidbAssemblyAttributesWin32
Definition: msidefs.h:216
@ SCRIPT_INSTALL
Definition: msipriv.h:385
@ SCRIPT_NONE
Definition: msipriv.h:384
INT MSI_ProcessMessage(MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD *) DECLSPEC_HIDDEN
Definition: package.c:1914
MSIRECORD * MSI_CreateRecord(UINT) DECLSPEC_HIDDEN
Definition: record.c:76
UINT MSI_RecordSetStringW(MSIRECORD *, UINT, LPCWSTR) DECLSPEC_HIDDEN
Definition: record.c:597
BOOL encode_base85_guid(GUID *, LPWSTR) DECLSPEC_HIDDEN
Definition: registry.c:165
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
Definition: fci.c:127
LPWSTR Component
Definition: msipriv.h:525
INSTALLSTATE Action
Definition: msipriv.h:533
LPWSTR ComponentId
Definition: msipriv.h:526
MSIASSEMBLY * assembly
Definition: msipriv.h:540
struct list components
Definition: msipriv.h:401
LPWSTR ProductCode
Definition: msipriv.h:448
UINT Context
Definition: msipriv.h:459
enum script script
Definition: msipriv.h:432
MSIOBJECTHDR hdr
Definition: msipriv.h:151
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

◆ ACTION_MsiUnpublishAssemblies()

UINT ACTION_MsiUnpublishAssemblies ( MSIPACKAGE package)

Definition at line 668 of file assembly.c.

669{
670 MSICOMPONENT *comp;
671
672 if (package->script == SCRIPT_NONE)
673 return msi_schedule_action(package, SCRIPT_INSTALL, L"MsiUnpublishAssemblies");
674
676 {
677 LONG res;
678 MSIRECORD *uirow;
680 BOOL win32;
681
682 if (!assembly || !comp->ComponentId) continue;
683
684 comp->Action = msi_get_component_action( package, comp );
685 if (comp->Action != INSTALLSTATE_ABSENT)
686 {
687 TRACE("component not scheduled for removal %s\n", debugstr_w(comp->Component));
688 continue;
689 }
690 TRACE("unpublishing %s\n", debugstr_w(comp->Component));
691
692 win32 = assembly->attributes & msidbAssemblyAttributesWin32;
693 if (assembly->application)
694 {
695 MSIFILE *file = msi_get_loaded_file( package, assembly->application );
696 if (!file)
697 {
698 WARN("no matching file %s for local assembly\n", debugstr_w(assembly->application));
699 continue;
700 }
701 if ((res = delete_local_assembly_key( package->Context, win32, file->TargetPath )))
702 WARN( "failed to delete local assembly key %ld\n", res );
703 }
704 else
705 {
706 HKEY hkey;
707 if ((res = open_global_assembly_key( package->Context, win32, &hkey )))
708 WARN( "failed to delete global assembly key %ld\n", res );
709 else
710 {
711 if ((res = RegDeleteValueW( hkey, assembly->display_name )))
712 WARN( "failed to delete global assembly value %ld\n", res );
713 RegCloseKey( hkey );
714 }
715 }
716
717 uirow = MSI_CreateRecord( 2 );
718 MSI_RecordSetStringW( uirow, 2, assembly->display_name );
720 msiobj_release( &uirow->hdr );
721 }
722 return ERROR_SUCCESS;
723}
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
static LONG delete_local_assembly_key(UINT context, BOOL win32, const WCHAR *filename)
Definition: assembly.c:555
@ INSTALLSTATE_ABSENT
Definition: msi.h:45

◆ build_local_assembly_path()

static WCHAR * build_local_assembly_path ( const WCHAR filename)
static

Definition at line 498 of file assembly.c.

499{
500 UINT i;
501 WCHAR *ret;
502
503 if (!(ret = msi_alloc( (lstrlenW( filename ) + 1) * sizeof(WCHAR) )))
504 return NULL;
505
506 for (i = 0; filename[i]; i++)
507 {
508 if (filename[i] == '\\' || filename[i] == '/') ret[i] = '|';
509 else ret[i] = filename[i];
510 }
511 ret[i] = 0;
512 return ret;
513}
#define NULL
Definition: types.h:112
#define lstrlenW
Definition: compat.h:750
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const char * filename
Definition: ioapi.h:137
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1142
unsigned int UINT
Definition: ndis.h:50
int ret

Referenced by delete_local_assembly_key(), and open_local_assembly_key().

◆ delete_local_assembly_key()

static LONG delete_local_assembly_key ( UINT  context,
BOOL  win32,
const WCHAR filename 
)
static

Definition at line 555 of file assembly.c.

556{
557 LONG res;
558 HKEY root;
559 WCHAR *path;
560
562 return ERROR_OUTOFMEMORY;
563
564 if ((res = open_assemblies_key( context, win32, &root )))
565 {
566 msi_free( path );
567 return res;
568 }
570 RegCloseKey( root );
571 msi_free( path );
572 return res;
573}
struct _root root
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
static WCHAR * build_local_assembly_path(const WCHAR *filename)
Definition: assembly.c:498
static LONG open_assemblies_key(UINT context, BOOL win32, HKEY *hkey)
Definition: assembly.c:515
static void msi_free(void *mem)
Definition: msipriv.h:1159
Definition: http.c:7252

Referenced by ACTION_MsiUnpublishAssemblies().

◆ get_assembly_display_name()

static WCHAR * get_assembly_display_name ( MSIDATABASE db,
const WCHAR comp,
MSIASSEMBLY assembly 
)
static

Definition at line 175 of file assembly.c.

176{
177 struct assembly_name name;
178 WCHAR *display_name = NULL;
179 MSIQUERY *view;
180 UINT i, r;
181 int len;
182
183 r = MSI_OpenQuery( db, &view, L"SELECT * FROM `MsiAssemblyName` WHERE `Component_` = '%s'", comp );
184 if (r != ERROR_SUCCESS)
185 return NULL;
186
187 name.count = 0;
188 name.index = 0;
189 name.attrs = NULL;
190 MSI_IterateRecords( view, &name.count, NULL, NULL );
191 if (!name.count) goto done;
192
193 name.attrs = msi_alloc( name.count * sizeof(WCHAR *) );
194 if (!name.attrs) goto done;
195
197
198 len = 0;
199 for (i = 0; i < name.count; i++) len += lstrlenW( name.attrs[i] ) + 1;
200
201 display_name = msi_alloc( (len + 1) * sizeof(WCHAR) );
202 if (display_name)
203 {
204 display_name[0] = 0;
205 for (i = 0; i < name.count; i++)
206 {
207 lstrcatW( display_name, name.attrs[i] );
208 if (i < name.count - 1) lstrcatW( display_name, L"," );
209 }
210 }
211
212done:
213 msiobj_release( &view->hdr );
214 if (name.attrs)
215 {
216 for (i = 0; i < name.count; i++) msi_free( name.attrs[i] );
217 msi_free( name.attrs );
218 }
219 return display_name;
220}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLsizei len
Definition: glext.h:6722
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static UINT get_assembly_name_attribute(MSIRECORD *rec, LPVOID param)
Definition: assembly.c:160
UINT MSI_IterateRecords(MSIQUERY *, LPDWORD, record_func, LPVOID) DECLSPEC_HIDDEN
Definition: msiquery.c:163
UINT WINAPIV MSI_OpenQuery(MSIDATABASE *, MSIQUERY **, LPCWSTR,...) DECLSPEC_HIDDEN
Definition: msiquery.c:138
Definition: name.c:39

Referenced by msi_load_assembly().

◆ get_assembly_name_attribute()

static UINT get_assembly_name_attribute ( MSIRECORD rec,
LPVOID  param 
)
static

Definition at line 160 of file assembly.c.

161{
162 struct assembly_name *name = param;
163 const WCHAR *attr = MSI_RecordGetString( rec, 2 );
164 const WCHAR *value = MSI_RecordGetString( rec, 3 );
165 int len = lstrlenW( L"%s=\"%s\"" ) + lstrlenW( attr ) + lstrlenW( value );
166
167 if (!(name->attrs[name->index] = msi_alloc( len * sizeof(WCHAR) )))
168 return ERROR_OUTOFMEMORY;
169
170 if (!wcsicmp( attr, L"name" )) lstrcpyW( name->attrs[name->index++], value );
171 else swprintf( name->attrs[name->index++], len, L"%s=\"%s\"", attr, value );
172 return ERROR_SUCCESS;
173}
#define lstrcpyW
Definition: compat.h:749
#define wcsicmp
Definition: compat.h:15
#define swprintf
Definition: precomp.h:40
GLfloat param
Definition: glext.h:5796
const WCHAR * MSI_RecordGetString(const MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:433
Definition: cookie.c:202
Definition: pdh_main.c:94

Referenced by get_assembly_display_name().

◆ get_assembly_record()

static MSIRECORD * get_assembly_record ( MSIPACKAGE package,
const WCHAR comp 
)
static

Definition at line 124 of file assembly.c.

125{
126 MSIQUERY *view;
127 MSIRECORD *rec;
128 UINT r;
129
130 r = MSI_OpenQuery( package->db, &view, L"SELECT * FROM `MsiAssembly` WHERE `Component_` = '%s'", comp );
131 if (r != ERROR_SUCCESS)
132 return NULL;
133
135 if (r != ERROR_SUCCESS)
136 {
137 msiobj_release( &view->hdr );
138 return NULL;
139 }
140 r = MSI_ViewFetch( view, &rec );
141 if (r != ERROR_SUCCESS)
142 {
143 msiobj_release( &view->hdr );
144 return NULL;
145 }
146 if (!MSI_RecordGetString( rec, 4 ))
147 TRACE("component is a global assembly\n");
148
149 msiobj_release( &view->hdr );
150 return rec;
151}
UINT MSI_ViewFetch(MSIQUERY *, MSIRECORD **) DECLSPEC_HIDDEN
Definition: msiquery.c:377
UINT MSI_ViewExecute(MSIQUERY *, MSIRECORD *) DECLSPEC_HIDDEN
Definition: msiquery.c:502
MSIDATABASE * db
Definition: msipriv.h:394

Referenced by msi_load_assembly().

◆ get_clr_version()

static enum clr_version get_clr_version ( MSIPACKAGE package,
const WCHAR filename 
)
static

Definition at line 386 of file assembly.c.

387{
388 DWORD len;
389 HRESULT hr;
391 WCHAR *strW;
392
393 if (!package->pGetFileVersion) return CLR_VERSION_V10;
394
395 hr = package->pGetFileVersion( filename, NULL, 0, &len );
397 if ((strW = msi_alloc( len * sizeof(WCHAR) )))
398 {
399 hr = package->pGetFileVersion( filename, strW, len, &len );
400 if (hr == S_OK)
401 {
402 UINT i;
403 for (i = 0; i < CLR_VERSION_MAX; i++)
404 if (!wcscmp( strW, clr_version[i] )) version = i;
405 }
406 msi_free( strW );
407 }
408 return version;
409}
static const WCHAR version[]
Definition: asmname.c:66
#define S_OK
Definition: intsafe.h:52
WCHAR strW[12]
Definition: clipboard.c:2029
clr_version
Definition: msipriv.h:374
@ CLR_VERSION_MAX
Definition: msipriv.h:379
@ CLR_VERSION_V11
Definition: msipriv.h:376
@ CLR_VERSION_V10
Definition: msipriv.h:375
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HRESULT hr
Definition: shlfolder.c:183
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345

Referenced by msi_install_assembly().

◆ get_clr_version_str()

static const WCHAR * get_clr_version_str ( enum clr_version  version)
static

Definition at line 312 of file assembly.c.

313{
314 if (version >= ARRAY_SIZE( clr_version )) return L"unknown";
315 return clr_version[version];
316}
#define ARRAY_SIZE(A)
Definition: main.h:33

Referenced by msi_load_assembly().

◆ is_assembly_installed()

static BOOL is_assembly_installed ( IAssemblyCache cache,
const WCHAR display_name 
)
static

Definition at line 222 of file assembly.c.

223{
224 HRESULT hr;
226
227 if (!cache) return FALSE;
228
229 memset( &info, 0, sizeof(info) );
230 info.cbAssemblyInfo = sizeof(info);
231 hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, display_name, &info );
232 if (hr == S_OK /* sxs version */ || hr == E_NOT_SUFFICIENT_BUFFER)
233 {
234 return (info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED);
235 }
236 TRACE( "QueryAssemblyInfo returned %#lx\n", hr );
237 return FALSE;
238}
#define FALSE
Definition: types.h:117
#define ASSEMBLYINFO_FLAG_INSTALLED
Definition: fusion.idl:103
#define memset(x, y, z)
Definition: compat.h:39
Definition: cache.c:49

Referenced by msi_load_assembly().

◆ load_fusion_dlls()

static BOOL load_fusion_dlls ( MSIPACKAGE package)
static

Definition at line 33 of file assembly.c.

34{
35 HRESULT (WINAPI *pLoadLibraryShim)( const WCHAR *, const WCHAR *, void *, HMODULE * );
38
39 lstrcpyW( path + len, L"\\mscoree.dll" );
40 if (package->hmscoree || !(package->hmscoree = LoadLibraryW( path ))) return TRUE;
41 if (!(pLoadLibraryShim = (void *)GetProcAddress( package->hmscoree, "LoadLibraryShim" )))
42 {
43 FreeLibrary( package->hmscoree );
44 package->hmscoree = NULL;
45 return TRUE;
46 }
47
48 pLoadLibraryShim( L"fusion.dll", L"v1.0.3705", NULL, &package->hfusion10 );
49 pLoadLibraryShim( L"fusion.dll", L"v1.1.4322", NULL, &package->hfusion11 );
50 pLoadLibraryShim( L"fusion.dll", L"v2.0.50727", NULL, &package->hfusion20 );
51 pLoadLibraryShim( L"fusion.dll", L"v4.0.30319", NULL, &package->hfusion40 );
52
53 return TRUE;
54}
#define TRUE
Definition: types.h:120
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
HMODULE hfusion20
Definition: msipriv.h:417
HMODULE hfusion11
Definition: msipriv.h:416
HMODULE hfusion10
Definition: msipriv.h:415
HMODULE hmscoree
Definition: msipriv.h:419
HMODULE hfusion40
Definition: msipriv.h:418
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6

Referenced by msi_init_assembly_caches().

◆ msi_create_assembly_enum()

IAssemblyEnum * msi_create_assembly_enum ( MSIPACKAGE package,
const WCHAR displayname 
)

Definition at line 265 of file assembly.c.

266{
267 HRESULT hr;
270 WCHAR *str;
271 DWORD len = 0;
272
273 if (!package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum) return NULL;
274
275 hr = package->pCreateAssemblyNameObject( &name, displayname, CANOF_PARSE_DISPLAY_NAME, NULL );
276 if (FAILED( hr )) return NULL;
277
278 hr = IAssemblyName_GetName( name, &len, NULL );
279 if (hr != E_NOT_SUFFICIENT_BUFFER || !(str = msi_alloc( len * sizeof(WCHAR) )))
280 {
281 IAssemblyName_Release( name );
282 return NULL;
283 }
284
285 hr = IAssemblyName_GetName( name, &len, str );
286 IAssemblyName_Release( name );
287 if (FAILED( hr ))
288 {
289 msi_free( str );
290 return NULL;
291 }
292
293 hr = package->pCreateAssemblyNameObject( &name, str, 0, NULL );
294 msi_free( str );
295 if (FAILED( hr )) return NULL;
296
297 hr = package->pCreateAssemblyEnum( &ret, NULL, name, ASM_CACHE_GAC, NULL );
298 IAssemblyName_Release( name );
299 if (FAILED( hr )) return NULL;
300
301 return ret;
302}
@ ASM_CACHE_GAC
Definition: fusion.idl:29
#define FAILED(hr)
Definition: intsafe.h:51
const WCHAR * str
@ CANOF_PARSE_DISPLAY_NAME
Definition: winsxs.idl:193

Referenced by patch_assembly().

◆ msi_destroy_assembly_caches()

void msi_destroy_assembly_caches ( MSIPACKAGE package)

Definition at line 92 of file assembly.c.

93{
94 UINT i;
95
96 if (package->cache_sxs)
97 {
98 IAssemblyCache_Release( package->cache_sxs );
99 package->cache_sxs = NULL;
100 }
101 for (i = 0; i < CLR_VERSION_MAX; i++)
102 {
103 if (package->cache_net[i])
104 {
105 IAssemblyCache_Release( package->cache_net[i] );
106 package->cache_net[i] = NULL;
107 }
108 }
109 package->pGetFileVersion = NULL;
110 package->pCreateAssemblyNameObject = NULL;
111 package->pCreateAssemblyEnum = NULL;
112 FreeLibrary( package->hfusion10 );
113 FreeLibrary( package->hfusion11 );
114 FreeLibrary( package->hfusion20 );
115 FreeLibrary( package->hfusion40 );
116 FreeLibrary( package->hmscoree );
117 package->hfusion10 = NULL;
118 package->hfusion11 = NULL;
119 package->hfusion20 = NULL;
120 package->hfusion40 = NULL;
121 package->hmscoree = NULL;
122}
WCHAR DWORD const WCHAR void IUnknown IAssemblyName void *IAssemblyCache * cache_net[CLR_VERSION_MAX]
Definition: msipriv.h:423
IAssemblyCache * cache_sxs
Definition: msipriv.h:424

Referenced by MSI_FreePackage().

◆ msi_get_assembly_path()

WCHAR * msi_get_assembly_path ( MSIPACKAGE package,
const WCHAR displayname 
)

Definition at line 240 of file assembly.c.

241{
242 HRESULT hr;
245
246 if (!cache) return NULL;
247
248 memset( &info, 0, sizeof(info) );
249 info.cbAssemblyInfo = sizeof(info);
250 hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
251 if (hr != E_NOT_SUFFICIENT_BUFFER) return NULL;
252
253 if (!(info.pszCurrentAssemblyPathBuf = msi_alloc( info.cchBuf * sizeof(WCHAR) ))) return NULL;
254
255 hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
256 if (FAILED( hr ))
257 {
258 msi_free( info.pszCurrentAssemblyPathBuf );
259 return NULL;
260 }
261 TRACE("returning %s\n", debugstr_w(info.pszCurrentAssemblyPathBuf));
262 return info.pszCurrentAssemblyPathBuf;
263}
@ CLR_VERSION_V40
Definition: msipriv.h:378

Referenced by patch_assembly().

◆ msi_init_assembly_caches()

BOOL msi_init_assembly_caches ( MSIPACKAGE package)

Definition at line 56 of file assembly.c.

57{
58 HRESULT (WINAPI *pCreateAssemblyCache)( IAssemblyCache **, DWORD );
59
60 if (package->cache_sxs) return TRUE;
61 if (CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE;
62
63 if (!load_fusion_dlls( package )) return FALSE;
64 package->pGetFileVersion = (void *)GetProcAddress( package->hmscoree, "GetFileVersion" ); /* missing from v1.0.3705 */
65
66 if (package->hfusion10)
67 {
68 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion10, "CreateAssemblyCache" );
69 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V10], 0 );
70 }
71 if (package->hfusion11)
72 {
73 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion11, "CreateAssemblyCache" );
74 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V11], 0 );
75 }
76 if (package->hfusion20)
77 {
78 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion20, "CreateAssemblyCache" );
79 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V20], 0 );
80 }
81 if (package->hfusion40)
82 {
83 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyCache" );
84 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V40], 0 );
85 package->pCreateAssemblyNameObject = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyNameObject" );
86 package->pCreateAssemblyEnum = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyEnum" );
87 }
88
89 return TRUE;
90}
HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved)
Definition: asmcache.c:555
static BOOL load_fusion_dlls(MSIPACKAGE *package)
Definition: assembly.c:33
@ CLR_VERSION_V20
Definition: msipriv.h:377
#define DWORD
Definition: nt_native.h:44

Referenced by MSI_OpenPackageW().

◆ msi_install_assembly()

UINT msi_install_assembly ( MSIPACKAGE package,
MSICOMPONENT comp 
)

Definition at line 411 of file assembly.c.

412{
413 HRESULT hr;
414 const WCHAR *manifest;
418
419 if (comp->assembly->feature)
420 feature = msi_get_loaded_feature( package, comp->assembly->feature );
421
422 if (assembly->application)
423 {
424 if (feature) feature->Action = INSTALLSTATE_LOCAL;
425 return ERROR_SUCCESS;
426 }
427 if (assembly->attributes == msidbAssemblyAttributesWin32)
428 {
429 if (!assembly->manifest)
430 {
431 WARN("no manifest\n");
433 }
435 cache = package->cache_sxs;
436 }
437 else
438 {
439 manifest = msi_get_loaded_file( package, comp->KeyPath )->TargetPath;
440 cache = package->cache_net[get_clr_version( package, manifest )];
441 if (!cache) return ERROR_SUCCESS;
442 }
443 TRACE("installing assembly %s\n", debugstr_w(manifest));
444
445 hr = IAssemblyCache_InstallAssembly( cache, 0, manifest, NULL );
446 if (hr != S_OK)
447 {
448 ERR( "failed to install assembly %s (%#lx)\n", debugstr_w(manifest), hr );
450 }
451 if (feature) feature->Action = INSTALLSTATE_LOCAL;
452 assembly->installed = TRUE;
453 return ERROR_SUCCESS;
454}
#define ERR(fmt,...)
Definition: precomp.h:57
MSIFEATURE * msi_get_loaded_feature(MSIPACKAGE *package, const WCHAR *Feature)
Definition: action.c:563
INTERNETFEATURELIST feature
Definition: misc.c:1719
static enum clr_version get_clr_version(MSIPACKAGE *package, const WCHAR *filename)
Definition: assembly.c:386
struct file_info manifest
Definition: actctx.c:529
LPWSTR feature
Definition: msipriv.h:512
LPWSTR KeyPath
Definition: msipriv.h:530
LPWSTR TargetPath
Definition: msipriv.h:617
static const CHAR manifest[]
Definition: v6util.h:39

Referenced by ACTION_InstallFiles(), and ACTION_PatchFiles().

◆ msi_load_assembly()

MSIASSEMBLY * msi_load_assembly ( MSIPACKAGE package,
MSICOMPONENT comp 
)

Definition at line 319 of file assembly.c.

320{
321 MSIRECORD *rec;
322 MSIASSEMBLY *a;
323
324 if (!(rec = get_assembly_record( package, comp->Component ))) return NULL;
325 if (!(a = msi_alloc_zero( sizeof(MSIASSEMBLY) )))
326 {
327 msiobj_release( &rec->hdr );
328 return NULL;
329 }
330 a->feature = strdupW( MSI_RecordGetString( rec, 2 ) );
331 TRACE("feature %s\n", debugstr_w(a->feature));
332
333 a->manifest = strdupW( MSI_RecordGetString( rec, 3 ) );
334 TRACE("manifest %s\n", debugstr_w(a->manifest));
335
336 a->application = strdupW( MSI_RecordGetString( rec, 4 ) );
337 TRACE("application %s\n", debugstr_w(a->application));
338
339 a->attributes = MSI_RecordGetInteger( rec, 5 );
340 TRACE( "attributes %lu\n", a->attributes );
341
342 if (!(a->display_name = get_assembly_display_name( package->db, comp->Component, a )))
343 {
344 WARN("can't get display name\n");
345 msiobj_release( &rec->hdr );
346 msi_free( a->feature );
347 msi_free( a->manifest );
348 msi_free( a->application );
349 msi_free( a );
350 return NULL;
351 }
352 TRACE("display name %s\n", debugstr_w(a->display_name));
353
354 if (a->application)
355 {
356 /* We can't check the manifest here because the target path may still change.
357 So we assume that the assembly is not installed and lean on the InstallFiles
358 action to determine which files need to be installed.
359 */
360 a->installed = FALSE;
361 }
362 else
363 {
364 if (a->attributes == msidbAssemblyAttributesWin32)
365 a->installed = is_assembly_installed( package->cache_sxs, a->display_name );
366 else
367 {
368 UINT i;
369 for (i = 0; i < CLR_VERSION_MAX; i++)
370 {
371 a->clr_version[i] = is_assembly_installed( package->cache_net[i], a->display_name );
372 if (a->clr_version[i])
373 {
374 TRACE("runtime version %s\n", debugstr_w(get_clr_version_str( i )));
375 a->installed = TRUE;
376 break;
377 }
378 }
379 }
380 }
381 TRACE("assembly is %s\n", a->installed ? "installed" : "not installed");
382 msiobj_release( &rec->hdr );
383 return a;
384}
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
static MSIRECORD * get_assembly_record(MSIPACKAGE *package, const WCHAR *comp)
Definition: assembly.c:124
static WCHAR * get_assembly_display_name(MSIDATABASE *db, const WCHAR *comp, MSIASSEMBLY *assembly)
Definition: assembly.c:175
static const WCHAR * get_clr_version_str(enum clr_version version)
Definition: assembly.c:312
static BOOL is_assembly_installed(IAssemblyCache *cache, const WCHAR *display_name)
Definition: assembly.c:222
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1148
int MSI_RecordGetInteger(MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:213

Referenced by load_component().

◆ msi_uninstall_assembly()

UINT msi_uninstall_assembly ( MSIPACKAGE package,
MSICOMPONENT comp 
)

Definition at line 456 of file assembly.c.

457{
458 HRESULT hr;
462
463 if (comp->assembly->feature)
464 feature = msi_get_loaded_feature( package, comp->assembly->feature );
465
466 if (assembly->application)
467 {
468 if (feature) feature->Action = INSTALLSTATE_ABSENT;
469 return ERROR_SUCCESS;
470 }
471 TRACE("removing %s\n", debugstr_w(assembly->display_name));
472
473 if (assembly->attributes == msidbAssemblyAttributesWin32)
474 {
475 cache = package->cache_sxs;
476 hr = IAssemblyCache_UninstallAssembly( cache, 0, assembly->display_name, NULL, NULL );
477 if (FAILED( hr )) WARN( "failed to uninstall assembly %#lx\n", hr );
478 }
479 else
480 {
481 unsigned int i;
482 for (i = 0; i < CLR_VERSION_MAX; i++)
483 {
484 if (!assembly->clr_version[i]) continue;
485 cache = package->cache_net[i];
486 if (cache)
487 {
488 hr = IAssemblyCache_UninstallAssembly( cache, 0, assembly->display_name, NULL, NULL );
489 if (FAILED( hr )) WARN( "failed to uninstall assembly %#lx\n", hr );
490 }
491 }
492 }
493 if (feature) feature->Action = INSTALLSTATE_ABSENT;
494 assembly->installed = FALSE;
495 return ERROR_SUCCESS;
496}

Referenced by ACTION_RemoveFiles().

◆ open_assemblies_key()

static LONG open_assemblies_key ( UINT  context,
BOOL  win32,
HKEY hkey 
)
static

Definition at line 515 of file assembly.c.

516{
517 HKEY root;
518 const WCHAR *path;
519
521 {
523 if (win32) path = L"Installer\\Win32Assemblies\\";
524 else path = L"Installer\\Assemblies\\";
525 }
526 else
527 {
529 if (win32) path = L"Software\\Microsoft\\Installer\\Win32Assemblies\\";
530 else path = L"Software\\Microsoft\\Installer\\Assemblies\\";
531 }
532 return RegCreateKeyW( root, path, hkey );
533}
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
@ MSIINSTALLCONTEXT_MACHINE
Definition: msi.h:200
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by delete_local_assembly_key(), and open_local_assembly_key().

◆ open_global_assembly_key()

static LONG open_global_assembly_key ( UINT  context,
BOOL  win32,
HKEY hkey 
)
static

Definition at line 575 of file assembly.c.

576{
577 HKEY root;
578 const WCHAR *path;
579
581 {
583 if (win32) path = L"Installer\\Win32Assemblies\\Global";
584 else path = L"Installer\\Assemblies\\Global";
585 }
586 else
587 {
589 if (win32) path = L"Software\\Microsoft\\Installer\\Win32Assemblies\\Global";
590 else path = L"Software\\Microsoft\\Installer\\Assemblies\\Global";
591 }
592 return RegCreateKeyW( root, path, hkey );
593}

Referenced by ACTION_MsiPublishAssemblies(), and ACTION_MsiUnpublishAssemblies().

◆ open_local_assembly_key()

static LONG open_local_assembly_key ( UINT  context,
BOOL  win32,
const WCHAR filename,
HKEY hkey 
)
static

Definition at line 535 of file assembly.c.

536{
537 LONG res;
538 HKEY root;
539 WCHAR *path;
540
542 return ERROR_OUTOFMEMORY;
543
544 if ((res = open_assemblies_key( context, win32, &root )))
545 {
546 msi_free( path );
547 return res;
548 }
549 res = RegCreateKeyW( root, path, hkey );
550 RegCloseKey( root );
551 msi_free( path );
552 return res;
553}

Referenced by ACTION_MsiPublishAssemblies().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msi  )

Variable Documentation

◆ clr_version

const WCHAR* clr_version[]
static
Initial value:
=
{
L"v1.0.3705",
L"v1.2.4322",
L"v2.0.50727",
L"v4.0.30319"
}

Definition at line 304 of file assembly.c.