#include <stdarg.h>
#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
#include "wine/debug.h"
#include "msipriv.h"
#include "winuser.h"
-#include "winreg.h"
-#include "shlwapi.h"
#include "wine/unicode.h"
#include "msidefs.h"
const WCHAR cszSOURCEDIR[] = {'S','O','U','R','C','E','D','I','R',0};
const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
const WCHAR cszbs[]={'\\',0};
+const WCHAR szLocalSid[] = {'S','-','1','-','5','-','1','8',0};
LPWSTR build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name )
{
return NULL;
}
+void msi_reset_folders( MSIPACKAGE *package, BOOL source )
+{
+ MSIFOLDER *folder;
+
+ LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
+ {
+ if ( source )
+ {
+ msi_free( folder->ResolvedSource );
+ folder->ResolvedSource = NULL;
+ }
+ else
+ {
+ msi_free( folder->ResolvedTarget );
+ folder->ResolvedTarget = NULL;
+ }
+ }
+}
+
static LPWSTR get_source_root( MSIPACKAGE *package )
{
LPWSTR path, p;
}
}
+LPWSTR resolve_file_source(MSIPACKAGE *package, MSIFILE *file)
+{
+ LPWSTR p, path;
+
+ TRACE("Working to resolve source of file %s\n", debugstr_w(file->File));
+
+ if (file->IsCompressed)
+ return NULL;
+
+ p = resolve_folder(package, file->Component->Directory,
+ TRUE, FALSE, TRUE, NULL);
+ path = build_directory_name(2, p, file->ShortName);
+
+ if (file->LongName &&
+ GetFileAttributesW(path) == INVALID_FILE_ATTRIBUTES)
+ {
+ msi_free(path);
+ path = build_directory_name(2, p, file->LongName);
+ }
+
+ msi_free(p);
+
+ TRACE("file %s source resolves to %s\n", debugstr_w(file->File),
+ debugstr_w(path));
+
+ return path;
+}
+
LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
BOOL set_prop, BOOL load_prop, MSIFOLDER **folder)
{
}
else
{
- /* source may be in a few different places ... check each of them */
path = NULL;
- /* try the long path directory */
- if (f->SourceLongPath)
- {
- path = build_directory_name( 3, p, f->SourceLongPath, NULL );
- if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
- {
- msi_free( path );
- path = NULL;
- }
- }
-
- /* try the short path directory */
- if (!path && f->SourceShortPath)
- {
- path = build_directory_name( 3, p, f->SourceShortPath, NULL );
- if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
- {
- msi_free( path );
- path = NULL;
- }
- }
-
- /* try the root of the install */
- if (!path)
+ if (package->WordCount & msidbSumInfoSourceTypeCompressed)
path = get_source_root( package );
+ else if (package->WordCount & msidbSumInfoSourceTypeSFN)
+ path = build_directory_name( 3, p, f->SourceShortPath, NULL );
+ else
+ path = build_directory_name( 3, p, f->SourceLongPath, NULL );
TRACE("source -> %s\n", debugstr_w(path));
f->ResolvedSource = strdupW( path );
void msi_free_action_script(MSIPACKAGE *package, UINT script)
{
- int i;
+ UINT i;
for (i = 0; i < package->script->ActionCount[script]; i++)
msi_free(package->script->Actions[script][i]);
msi_free( file->LongName );
msi_free( file->Version );
msi_free( file->Language );
- msi_free( file->SourcePath );
msi_free( file->TargetPath );
msi_free( file );
}
msi_free(package->script);
}
+ if (package->patch)
+ {
+ msi_free(package->patch->patchcode);
+ msi_free(package->patch->transforms);
+ msi_free(package->patch);
+ }
+
msi_free(package->BaseURL);
msi_free(package->PackagePath);
msi_free(package->ProductCode);
if (!comp)
return FALSE;
- if (comp->Installed == check)
- return FALSE;
-
if (comp->ActionRequest == check)
return TRUE;
else
memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
}
-void reduce_to_shortfilename(WCHAR* filename)
-{
- LPWSTR p = strchrW(filename,'|');
- if (p)
- *p = 0;
-}
-
LPWSTR create_component_advertise_string(MSIPACKAGE* package,
MSICOMPONENT* component, LPCWSTR feature)
{
continue;
if (newstate == INSTALLSTATE_LOCAL)
- msi_component_set_state( component, INSTALLSTATE_LOCAL );
+ msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
else
{
ComponentList *clist;
component->hasLocalFeature = FALSE;
- msi_component_set_state( component, newstate );
+ msi_component_set_state(package, component, newstate);
/*if any other feature wants is local we need to set it local*/
LIST_FOR_EACH_ENTRY( f, &package->features, MSIFEATURE, entry )
if (component->Attributes & msidbComponentAttributesOptional)
{
if (f->Attributes & msidbFeatureAttributesFavorSource)
- msi_component_set_state( component, INSTALLSTATE_SOURCE );
+ msi_component_set_state(package, component, INSTALLSTATE_SOURCE);
else
- msi_component_set_state( component, INSTALLSTATE_LOCAL );
+ msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
}
else if (component->Attributes & msidbComponentAttributesSourceOnly)
- msi_component_set_state( component, INSTALLSTATE_SOURCE );
+ msi_component_set_state(package, component, INSTALLSTATE_SOURCE);
else
- msi_component_set_state( component, INSTALLSTATE_LOCAL );
+ msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
}
}
}
BOOL check_unique_action(const MSIPACKAGE *package, LPCWSTR action)
{
- INT i;
+ UINT i;
if (!package->script)
return FALSE;
msiobj_release( &rec->hdr );
return data;
}
-
-void msi_ui_error( DWORD msg_id, DWORD type )
-{
- WCHAR text[2048];
-
- static const WCHAR title[] = {
- 'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
- };
-
- if (!MsiLoadStringW( -1, msg_id, text, sizeof(text) / sizeof(text[0]),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ))
- return;
-
- MessageBoxW( NULL, text, title, type );
-}
-
-typedef struct
-{
- MSIPACKAGE *package;
- MSIMEDIAINFO *mi;
- MSIFILE *file;
- LPWSTR destination;
-} CabData;
-
-static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
-{
- TRACE("(%d)\n", fdint);
-
- switch (fdint)
- {
- case fdintNEXT_CABINET:
- {
- ERR("continuous cabinets not handled\n");
- return 0;
- }
-
- case fdintCOPY_FILE:
- {
- CabData *data = (CabData*) pfdin->pv;
- LPWSTR file, path;
- DWORD attrs, size;
- HANDLE handle;
- MSIFILE *f;
-
- file = strdupAtoW(pfdin->psz1);
- f = get_loaded_file(data->package, file);
- msi_free(file);
-
- if (!f)
- {
- WARN("unknown file in cabinet (%s)\n",debugstr_a(pfdin->psz1));
- return 0;
- }
-
- if (lstrcmpW(f->File, data->file->File))
- return 0;
-
- size = lstrlenW(data->destination) + lstrlenW(data->file->FileName) + 2;
- path = msi_alloc(size * sizeof(WCHAR));
- lstrcpyW(path, data->destination);
- PathAddBackslashW(path);
- lstrcatW(path, data->file->FileName);
-
- TRACE("extracting %s\n", debugstr_w(path));
-
- attrs = f->Attributes & (FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
- if (!attrs) attrs = FILE_ATTRIBUTE_NORMAL;
-
- handle = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0,
- NULL, CREATE_ALWAYS, attrs, NULL);
- if (handle == INVALID_HANDLE_VALUE)
- {
- if (GetFileAttributesW(path) == INVALID_FILE_ATTRIBUTES)
- ERR("failed to create %s (error %d)\n",
- debugstr_w(path), GetLastError());
-
- msi_free(path);
- return 0;
- }
-
- msi_free(path);
- return (INT_PTR)handle;
- }
-
- case fdintCLOSE_FILE_INFO:
- {
- FILETIME ft;
- FILETIME ftLocal;
- HANDLE handle = (HANDLE)pfdin->hf;
-
- if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft))
- return -1;
- if (!LocalFileTimeToFileTime(&ft, &ftLocal))
- return -1;
- if (!SetFileTime(handle, &ftLocal, 0, &ftLocal))
- return -1;
- CloseHandle(handle);
- return 1;
- }
-
- default:
- return 0;
- }
-}
-
-UINT msi_extract_file(MSIPACKAGE *package, MSIFILE *file, LPWSTR destdir)
-{
- MSIMEDIAINFO *mi;
- CabData data;
- UINT r;
-
- mi = msi_alloc_zero(sizeof(MSIMEDIAINFO));
- if (!mi)
- return ERROR_OUTOFMEMORY;
-
- r = msi_load_media_info(package, file, mi);
- if (r != ERROR_SUCCESS)
- goto done;
-
- if (GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES)
- {
- r = find_published_source(package, mi);
- if (r != ERROR_SUCCESS)
- {
- ERR("Cabinet not found: %s\n", debugstr_w(mi->source));
- return ERROR_INSTALL_FAILURE;
- }
- }
-
- data.package = package;
- data.mi = mi;
- data.file = file;
- data.destination = destdir;
-
- if (!msi_cabextract(package, mi, cabinet_notify, &data))
- {
- ERR("Failed to extract cabinet file\n");
- r = ERROR_FUNCTION_FAILED;
- }
-
-done:
- msi_free_media_info(mi);
- return r;
-}