ReactOS 0.4.16-dev-178-g8ba6102
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 void load_fusion_dlls (MSIPACKAGE *package)
 
static BOOL 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)
 
WCHARmsi_get_assembly_path (MSIPACKAGE *package, const WCHAR *displayname)
 
IAssemblyEnummsi_create_assembly_enum (MSIPACKAGE *package, const WCHAR *displayname)
 
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 542 of file assembly.c.

543{
544 MSICOMPONENT *comp;
545
546 if (package->script == SCRIPT_NONE)
547 return msi_schedule_action(package, SCRIPT_INSTALL, L"MsiPublishAssemblies");
548
550 {
551 LONG res;
552 HKEY hkey;
553 GUID guid;
554 DWORD size;
555 WCHAR buffer[43];
556 MSIRECORD *uirow;
558 BOOL win32;
559
560 if (!assembly || !comp->ComponentId) continue;
561
562 comp->Action = msi_get_component_action( package, comp );
563 if (comp->Action != INSTALLSTATE_LOCAL)
564 {
565 TRACE("component not scheduled for installation %s\n", debugstr_w(comp->Component));
566 continue;
567 }
568 TRACE("publishing %s\n", debugstr_w(comp->Component));
569
570 CLSIDFromString( package->ProductCode, &guid );
572 buffer[20] = '>';
575 buffer[42] = 0;
576
577 win32 = assembly->attributes & msidbAssemblyAttributesWin32;
578 if (assembly->application)
579 {
580 MSIFILE *file = msi_get_loaded_file( package, assembly->application );
581 if (!file)
582 {
583 WARN("no matching file %s for local assembly\n", debugstr_w(assembly->application));
584 continue;
585 }
586 if ((res = open_local_assembly_key( package->Context, win32, file->TargetPath, &hkey )))
587 {
588 WARN( "failed to open local assembly key %ld\n", res );
590 }
591 }
592 else
593 {
594 if ((res = open_global_assembly_key( package->Context, win32, &hkey )))
595 {
596 WARN( "failed to open global assembly key %ld\n", res );
598 }
599 }
600 size = sizeof(buffer);
601 if ((res = RegSetValueExW( hkey, assembly->display_name, 0, REG_MULTI_SZ, (const BYTE *)buffer, size )))
602 {
603 WARN( "failed to set assembly value %ld\n", res );
604 }
605 RegCloseKey( hkey );
606
607 uirow = MSI_CreateRecord( 2 );
608 MSI_RecordSetStringW( uirow, 2, assembly->display_name );
610 msiobj_release( &uirow->hdr );
611 }
612 return ERROR_SUCCESS;
613}
#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:609
MSIFILE * msi_get_loaded_file(MSIPACKAGE *package, const WCHAR *key)
Definition: action.c:572
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:482
static LONG open_global_assembly_key(UINT context, BOOL win32, HKEY *hkey)
Definition: assembly.c:522
@ INSTALLMESSAGE_ACTIONDATA
Definition: msi.h:103
@ INSTALLSTATE_LOCAL
Definition: msi.h:46
@ msidbAssemblyAttributesWin32
Definition: msidefs.h:216
BOOL encode_base85_guid(GUID *, LPWSTR)
Definition: registry.c:165
@ SCRIPT_INSTALL
Definition: msipriv.h:385
@ SCRIPT_NONE
Definition: msipriv.h:384
INT MSI_ProcessMessage(MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD *)
Definition: package.c:1909
UINT MSI_RecordSetStringW(MSIRECORD *, UINT, LPCWSTR)
Definition: record.c:597
MSIRECORD * MSI_CreateRecord(UINT)
Definition: record.c:76
#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:524
INSTALLSTATE Action
Definition: msipriv.h:532
LPWSTR ComponentId
Definition: msipriv.h:525
MSIASSEMBLY * assembly
Definition: msipriv.h:540
struct list components
Definition: msipriv.h:401
LPWSTR ProductCode
Definition: msipriv.h:448
enum script script
Definition: msipriv.h:432
MSIINSTALLCONTEXT Context
Definition: msipriv.h:459
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 615 of file assembly.c.

616{
617 MSICOMPONENT *comp;
618
619 if (package->script == SCRIPT_NONE)
620 return msi_schedule_action(package, SCRIPT_INSTALL, L"MsiUnpublishAssemblies");
621
623 {
624 LONG res;
625 MSIRECORD *uirow;
627 BOOL win32;
628
629 if (!assembly || !comp->ComponentId) continue;
630
631 comp->Action = msi_get_component_action( package, comp );
632 if (comp->Action != INSTALLSTATE_ABSENT)
633 {
634 TRACE("component not scheduled for removal %s\n", debugstr_w(comp->Component));
635 continue;
636 }
637 TRACE("unpublishing %s\n", debugstr_w(comp->Component));
638
639 win32 = assembly->attributes & msidbAssemblyAttributesWin32;
640 if (assembly->application)
641 {
642 MSIFILE *file = msi_get_loaded_file( package, assembly->application );
643 if (!file)
644 {
645 WARN("no matching file %s for local assembly\n", debugstr_w(assembly->application));
646 continue;
647 }
648 if ((res = delete_local_assembly_key( package->Context, win32, file->TargetPath )))
649 WARN( "failed to delete local assembly key %ld\n", res );
650 }
651 else
652 {
653 HKEY hkey;
654 if ((res = open_global_assembly_key( package->Context, win32, &hkey )))
655 WARN( "failed to delete global assembly key %ld\n", res );
656 else
657 {
658 if ((res = RegDeleteValueW( hkey, assembly->display_name )))
659 WARN( "failed to delete global assembly value %ld\n", res );
660 RegCloseKey( hkey );
661 }
662 }
663
664 uirow = MSI_CreateRecord( 2 );
665 MSI_RecordSetStringW( uirow, 2, assembly->display_name );
667 msiobj_release( &uirow->hdr );
668 }
669 return ERROR_SUCCESS;
670}
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:502
@ INSTALLSTATE_ABSENT
Definition: msi.h:45

◆ build_local_assembly_path()

static WCHAR * build_local_assembly_path ( const WCHAR filename)
static

Definition at line 445 of file assembly.c.

446{
447 UINT i;
448 WCHAR *ret;
449
450 if (!(ret = malloc( (wcslen( filename ) + 1) * sizeof(WCHAR) )))
451 return NULL;
452
453 for (i = 0; filename[i]; i++)
454 {
455 if (filename[i] == '\\' || filename[i] == '/') ret[i] = '|';
456 else ret[i] = filename[i];
457 }
458 ret[i] = 0;
459 return ret;
460}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
const char * filename
Definition: ioapi.h:137
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 502 of file assembly.c.

503{
504 LONG res;
505 HKEY root;
506 WCHAR *path;
507
509 return ERROR_OUTOFMEMORY;
510
511 if ((res = open_assemblies_key( context, win32, &root )))
512 {
513 free( path );
514 return res;
515 }
517 RegCloseKey( root );
518 free( path );
519 return res;
520}
struct _root root
#define free
Definition: debug_ros.c:5
#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:445
static LONG open_assemblies_key(UINT context, BOOL win32, HKEY *hkey)
Definition: assembly.c:462
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 172 of file assembly.c.

173{
174 struct assembly_name name;
175 WCHAR *display_name = NULL;
176 MSIQUERY *view;
177 UINT i, r;
178 int len;
179
180 r = MSI_OpenQuery( db, &view, L"SELECT * FROM `MsiAssemblyName` WHERE `Component_` = '%s'", comp );
181 if (r != ERROR_SUCCESS)
182 return NULL;
183
184 name.count = 0;
185 name.index = 0;
186 name.attrs = NULL;
187 MSI_IterateRecords( view, &name.count, NULL, NULL );
188 if (!name.count) goto done;
189
190 name.attrs = malloc( name.count * sizeof(WCHAR *) );
191 if (!name.attrs) goto done;
192
194
195 len = 0;
196 for (i = 0; i < name.count; i++) len += lstrlenW( name.attrs[i] ) + 1;
197
198 display_name = malloc( (len + 1) * sizeof(WCHAR) );
199 if (display_name)
200 {
201 display_name[0] = 0;
202 for (i = 0; i < name.count; i++)
203 {
204 lstrcatW( display_name, name.attrs[i] );
205 if (i < name.count - 1) lstrcatW( display_name, L"," );
206 }
207 }
208
209done:
210 msiobj_release( &view->hdr );
211 if (name.attrs)
212 {
213 for (i = 0; i < name.count; i++) free( name.attrs[i] );
214 free( name.attrs );
215 }
216 return display_name;
217}
#define lstrlenW
Definition: compat.h:750
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:157
UINT WINAPIV MSI_OpenQuery(MSIDATABASE *, MSIQUERY **, LPCWSTR,...)
Definition: msiquery.c:138
UINT MSI_IterateRecords(MSIQUERY *, LPDWORD, record_func, LPVOID)
Definition: msiquery.c:163
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 157 of file assembly.c.

158{
159 struct assembly_name *name = param;
160 const WCHAR *attr = MSI_RecordGetString( rec, 2 );
161 const WCHAR *value = MSI_RecordGetString( rec, 3 );
162 int len = lstrlenW( L"%s=\"%s\"" ) + lstrlenW( attr ) + lstrlenW( value );
163
164 if (!(name->attrs[name->index] = malloc( len * sizeof(WCHAR) )))
165 return ERROR_OUTOFMEMORY;
166
167 if (!wcsicmp( attr, L"name" )) lstrcpyW( name->attrs[name->index++], value );
168 else swprintf( name->attrs[name->index++], len, L"%s=\"%s\"", attr, value );
169 return ERROR_SUCCESS;
170}
#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)
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 121 of file assembly.c.

122{
123 MSIQUERY *view;
124 MSIRECORD *rec;
125 UINT r;
126
127 r = MSI_OpenQuery( package->db, &view, L"SELECT * FROM `MsiAssembly` WHERE `Component_` = '%s'", comp );
128 if (r != ERROR_SUCCESS)
129 return NULL;
130
132 if (r != ERROR_SUCCESS)
133 {
134 msiobj_release( &view->hdr );
135 return NULL;
136 }
137 r = MSI_ViewFetch( view, &rec );
138 if (r != ERROR_SUCCESS)
139 {
140 msiobj_release( &view->hdr );
141 return NULL;
142 }
143 if (!MSI_RecordGetString( rec, 4 ))
144 TRACE("component is a global assembly\n");
145
146 msiobj_release( &view->hdr );
147 return rec;
148}
UINT MSI_ViewExecute(MSIQUERY *, MSIRECORD *)
Definition: msiquery.c:502
UINT MSI_ViewFetch(MSIQUERY *, MSIRECORD **)
Definition: msiquery.c:377
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 331 of file assembly.c.

332{
333 DWORD len;
334 HRESULT hr;
336 WCHAR *strW;
337
338 if (!package->pGetFileVersion) return CLR_VERSION_V10;
339
340 hr = package->pGetFileVersion( filename, NULL, 0, &len );
342 if ((strW = malloc( len * sizeof(WCHAR) )))
343 {
344 hr = package->pGetFileVersion( filename, strW, len, &len );
345 if (hr == S_OK)
346 {
347 UINT i;
348 for (i = 0; i < CLR_VERSION_MAX; i++)
349 if (!wcscmp( strW, clr_version[i] )) version = i;
350 }
351 free( strW );
352 }
353 return version;
354}
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().

◆ init_assembly_caches()

static BOOL init_assembly_caches ( MSIPACKAGE package)
static

Definition at line 54 of file assembly.c.

55{
56 HRESULT (WINAPI *pCreateAssemblyCache)( IAssemblyCache **, DWORD );
57
58 if (!package->cache_sxs && CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE;
59
60 load_fusion_dlls( package );
61 package->pGetFileVersion = (void *)GetProcAddress( package->hmscoree, "GetFileVersion" ); /* missing from v1.0.3705 */
62
63 if (package->hfusion10 && !package->cache_net[CLR_VERSION_V10])
64 {
65 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion10, "CreateAssemblyCache" );
66 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V10], 0 );
67 }
68 if (package->hfusion11 && !package->cache_net[CLR_VERSION_V11])
69 {
70 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion11, "CreateAssemblyCache" );
71 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V11], 0 );
72 }
73 if (package->hfusion20 && !package->cache_net[CLR_VERSION_V20])
74 {
75 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion20, "CreateAssemblyCache" );
76 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V20], 0 );
77 }
78 if (package->hfusion40 && !package->cache_net[CLR_VERSION_V40])
79 {
80 pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyCache" );
81 pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V40], 0 );
82 package->pCreateAssemblyNameObject = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyNameObject" );
83 package->pCreateAssemblyEnum = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyEnum" );
84 }
85
86 return TRUE;
87}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved)
Definition: asmcache.c:555
static void load_fusion_dlls(MSIPACKAGE *package)
Definition: assembly.c:33
@ CLR_VERSION_V20
Definition: msipriv.h:377
@ CLR_VERSION_V40
Definition: msipriv.h:378
#define DWORD
Definition: nt_native.h:44
WCHAR DWORD const WCHAR void IUnknown IAssemblyName void *IAssemblyCache * cache_net[CLR_VERSION_MAX]
Definition: msipriv.h:423
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
IAssemblyCache * cache_sxs
Definition: msipriv.h:424
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6

Referenced by msi_create_assembly_enum(), msi_get_assembly_path(), msi_install_assembly(), and msi_uninstall_assembly().

◆ load_fusion_dlls()

static void 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;
41 if (!(pLoadLibraryShim = (void *)GetProcAddress( package->hmscoree, "LoadLibraryShim" )))
42 {
43 FreeLibrary( package->hmscoree );
44 package->hmscoree = NULL;
45 return;
46 }
47
48 if (!package->hfusion10) pLoadLibraryShim( L"fusion.dll", L"v1.0.3705", NULL, &package->hfusion10 );
49 if (!package->hfusion11) pLoadLibraryShim( L"fusion.dll", L"v1.1.4322", NULL, &package->hfusion11 );
50 if (!package->hfusion20) pLoadLibraryShim( L"fusion.dll", L"v2.0.50727", NULL, &package->hfusion20 );
51 if (!package->hfusion40) pLoadLibraryShim( L"fusion.dll", L"v4.0.30319", NULL, &package->hfusion40 );
52}
#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

Referenced by init_assembly_caches().

◆ msi_create_assembly_enum()

IAssemblyEnum * msi_create_assembly_enum ( MSIPACKAGE package,
const WCHAR displayname 
)

Definition at line 244 of file assembly.c.

245{
246 HRESULT hr;
249 WCHAR *str;
250 DWORD len = 0;
251
252 if (!init_assembly_caches( package ) || !package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum)
253 return NULL;
254
255 hr = package->pCreateAssemblyNameObject( &name, displayname, CANOF_PARSE_DISPLAY_NAME, NULL );
256 if (FAILED( hr )) return NULL;
257
258 hr = IAssemblyName_GetName( name, &len, NULL );
259 if (hr != E_NOT_SUFFICIENT_BUFFER || !(str = malloc( len * sizeof(WCHAR) )))
260 {
261 IAssemblyName_Release( name );
262 return NULL;
263 }
264
265 hr = IAssemblyName_GetName( name, &len, str );
266 IAssemblyName_Release( name );
267 if (FAILED( hr ))
268 {
269 free( str );
270 return NULL;
271 }
272
273 hr = package->pCreateAssemblyNameObject( &name, str, 0, NULL );
274 free( str );
275 if (FAILED( hr )) return NULL;
276
277 hr = package->pCreateAssemblyEnum( &ret, NULL, name, ASM_CACHE_GAC, NULL );
278 IAssemblyName_Release( name );
279 if (FAILED( hr )) return NULL;
280
281 return ret;
282}
@ ASM_CACHE_GAC
Definition: fusion.idl:29
#define FAILED(hr)
Definition: intsafe.h:51
static BOOL init_assembly_caches(MSIPACKAGE *package)
Definition: assembly.c:54
const WCHAR * str
@ CANOF_PARSE_DISPLAY_NAME
Definition: winsxs.idl:193

Referenced by msi_patch_assembly().

◆ msi_destroy_assembly_caches()

void msi_destroy_assembly_caches ( MSIPACKAGE package)

Definition at line 89 of file assembly.c.

90{
91 UINT i;
92
93 if (package->cache_sxs)
94 {
95 IAssemblyCache_Release( package->cache_sxs );
96 package->cache_sxs = NULL;
97 }
98 for (i = 0; i < CLR_VERSION_MAX; i++)
99 {
100 if (package->cache_net[i])
101 {
102 IAssemblyCache_Release( package->cache_net[i] );
103 package->cache_net[i] = NULL;
104 }
105 }
106 package->pGetFileVersion = NULL;
107 package->pCreateAssemblyNameObject = NULL;
108 package->pCreateAssemblyEnum = NULL;
109 FreeLibrary( package->hfusion10 );
110 FreeLibrary( package->hfusion11 );
111 FreeLibrary( package->hfusion20 );
112 FreeLibrary( package->hfusion40 );
113 FreeLibrary( package->hmscoree );
114 package->hfusion10 = NULL;
115 package->hfusion11 = NULL;
116 package->hfusion20 = NULL;
117 package->hfusion40 = NULL;
118 package->hmscoree = NULL;
119}

Referenced by MSI_FreePackage().

◆ msi_get_assembly_path()

WCHAR * msi_get_assembly_path ( MSIPACKAGE package,
const WCHAR displayname 
)

Definition at line 219 of file assembly.c.

220{
221 HRESULT hr;
224
225 if (!init_assembly_caches( package ) || !(cache = package->cache_net[CLR_VERSION_V40])) return NULL;
226
227 memset( &info, 0, sizeof(info) );
228 info.cbAssemblyInfo = sizeof(info);
229 hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
230 if (hr != E_NOT_SUFFICIENT_BUFFER) return NULL;
231
232 if (!(info.pszCurrentAssemblyPathBuf = malloc( info.cchBuf * sizeof(WCHAR) ))) return NULL;
233
234 hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
235 if (FAILED( hr ))
236 {
237 free( info.pszCurrentAssemblyPathBuf );
238 return NULL;
239 }
240 TRACE("returning %s\n", debugstr_w(info.pszCurrentAssemblyPathBuf));
241 return info.pszCurrentAssemblyPathBuf;
242}
#define memset(x, y, z)
Definition: compat.h:39
Definition: cache.c:49

Referenced by msi_patch_assembly().

◆ msi_install_assembly()

UINT msi_install_assembly ( MSIPACKAGE package,
MSICOMPONENT comp 
)

Definition at line 356 of file assembly.c.

357{
358 HRESULT hr;
359 const WCHAR *manifest;
363
364 if (!init_assembly_caches( package )) return ERROR_FUNCTION_FAILED;
365
366 if (comp->assembly->feature)
367 feature = msi_get_loaded_feature( package, comp->assembly->feature );
368
369 if (assembly->application)
370 {
371 if (feature) feature->Action = INSTALLSTATE_LOCAL;
372 return ERROR_SUCCESS;
373 }
374 if (assembly->attributes == msidbAssemblyAttributesWin32)
375 {
376 if (!assembly->manifest)
377 {
378 WARN("no manifest\n");
380 }
382 cache = package->cache_sxs;
383 }
384 else
385 {
386 manifest = msi_get_loaded_file( package, comp->KeyPath )->TargetPath;
387 cache = package->cache_net[get_clr_version( package, manifest )];
388 if (!cache) return ERROR_SUCCESS;
389 }
390 TRACE("installing assembly %s\n", debugstr_w(manifest));
391
392 hr = IAssemblyCache_InstallAssembly( cache, 0, manifest, NULL );
393 if (hr != S_OK)
394 {
395 ERR( "failed to install assembly %s (%#lx)\n", debugstr_w(manifest), hr );
397 }
398 if (feature) feature->Action = INSTALLSTATE_LOCAL;
399 return ERROR_SUCCESS;
400}
#define ERR(fmt,...)
Definition: precomp.h:57
MSIFEATURE * msi_get_loaded_feature(MSIPACKAGE *package, const WCHAR *Feature)
Definition: action.c:561
INTERNETFEATURELIST feature
Definition: misc.c:1719
static enum clr_version get_clr_version(MSIPACKAGE *package, const WCHAR *filename)
Definition: assembly.c:331
struct file_info manifest
Definition: actctx.c:530
LPWSTR feature
Definition: msipriv.h:512
LPWSTR KeyPath
Definition: msipriv.h:529
LPWSTR TargetPath
Definition: msipriv.h:617
static const CHAR manifest[]
Definition: v6util.h:41

Referenced by ACTION_InstallFinalize().

◆ msi_load_assembly()

MSIASSEMBLY * msi_load_assembly ( MSIPACKAGE package,
MSICOMPONENT comp 
)

Definition at line 292 of file assembly.c.

293{
294 MSIRECORD *rec;
295 MSIASSEMBLY *a;
296
297 if (!(rec = get_assembly_record( package, comp->Component ))) return NULL;
298 if (!(a = calloc( 1, sizeof(MSIASSEMBLY) )))
299 {
300 msiobj_release( &rec->hdr );
301 return NULL;
302 }
303 a->feature = wcsdup( MSI_RecordGetString( rec, 2 ) );
304 TRACE("feature %s\n", debugstr_w(a->feature));
305
306 a->manifest = wcsdup( MSI_RecordGetString( rec, 3 ) );
307 TRACE("manifest %s\n", debugstr_w(a->manifest));
308
309 a->application = wcsdup( MSI_RecordGetString( rec, 4 ) );
310 TRACE("application %s\n", debugstr_w(a->application));
311
312 a->attributes = MSI_RecordGetInteger( rec, 5 );
313 TRACE( "attributes %lu\n", a->attributes );
314
315 if (!(a->display_name = get_assembly_display_name( package->db, comp->Component, a )))
316 {
317 WARN("can't get display name\n");
318 msiobj_release( &rec->hdr );
319 free( a->feature );
320 free( a->manifest );
321 free( a->application );
322 free( a );
323 return NULL;
324 }
325 TRACE("display name %s\n", debugstr_w(a->display_name));
326
327 msiobj_release( &rec->hdr );
328 return a;
329}
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:121
static WCHAR * get_assembly_display_name(MSIDATABASE *db, const WCHAR *comp, MSIASSEMBLY *assembly)
Definition: assembly.c:172
int MSI_RecordGetInteger(MSIRECORD *, UINT)
Definition: record.c:213
#define calloc
Definition: rosglue.h:14
_Check_return_ _CRTIMP wchar_t *__cdecl wcsdup(_In_z_ const wchar_t *_Str)

Referenced by load_component().

◆ msi_uninstall_assembly()

UINT msi_uninstall_assembly ( MSIPACKAGE package,
MSICOMPONENT comp 
)

Definition at line 402 of file assembly.c.

403{
404 HRESULT hr;
408
409 if (!init_assembly_caches( package )) return ERROR_FUNCTION_FAILED;
410
411 if (comp->assembly->feature)
412 feature = msi_get_loaded_feature( package, comp->assembly->feature );
413
414 if (assembly->application)
415 {
416 if (feature) feature->Action = INSTALLSTATE_ABSENT;
417 return ERROR_SUCCESS;
418 }
419 TRACE("removing %s\n", debugstr_w(assembly->display_name));
420
421 if (assembly->attributes == msidbAssemblyAttributesWin32)
422 {
423 cache = package->cache_sxs;
424 hr = IAssemblyCache_UninstallAssembly( cache, 0, assembly->display_name, NULL, NULL );
425 if (FAILED( hr )) WARN( "failed to uninstall assembly %#lx\n", hr );
426 }
427 else
428 {
429 unsigned int i;
430 for (i = 0; i < CLR_VERSION_MAX; i++)
431 {
432 if (!assembly->clr_version[i]) continue;
433 cache = package->cache_net[i];
434 if (cache)
435 {
436 hr = IAssemblyCache_UninstallAssembly( cache, 0, assembly->display_name, NULL, NULL );
437 if (FAILED( hr )) WARN( "failed to uninstall assembly %#lx\n", hr );
438 }
439 }
440 }
441 if (feature) feature->Action = INSTALLSTATE_ABSENT;
442 return ERROR_SUCCESS;
443}

Referenced by ACTION_RemoveFiles().

◆ open_assemblies_key()

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

Definition at line 462 of file assembly.c.

463{
464 HKEY root;
465 const WCHAR *path;
466
468 {
470 if (win32) path = L"Installer\\Win32Assemblies\\";
471 else path = L"Installer\\Assemblies\\";
472 }
473 else
474 {
476 if (win32) path = L"Software\\Microsoft\\Installer\\Win32Assemblies\\";
477 else path = L"Software\\Microsoft\\Installer\\Assemblies\\";
478 }
479 return RegCreateKeyW( root, path, hkey );
480}
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 522 of file assembly.c.

523{
524 HKEY root;
525 const WCHAR *path;
526
528 {
530 if (win32) path = L"Installer\\Win32Assemblies\\Global";
531 else path = L"Installer\\Assemblies\\Global";
532 }
533 else
534 {
536 if (win32) path = L"Software\\Microsoft\\Installer\\Win32Assemblies\\Global";
537 else path = L"Software\\Microsoft\\Installer\\Assemblies\\Global";
538 }
539 return RegCreateKeyW( root, path, hkey );
540}

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 482 of file assembly.c.

483{
484 LONG res;
485 HKEY root;
486 WCHAR *path;
487
489 return ERROR_OUTOFMEMORY;
490
491 if ((res = open_assemblies_key( context, win32, &root )))
492 {
493 free( path );
494 return res;
495 }
496 res = RegCreateKeyW( root, path, hkey );
497 RegCloseKey( root );
498 free( path );
499 return res;
500}

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 284 of file assembly.c.