msi: Improve tracing.

This commit is contained in:
Hans Leidekker 2015-03-16 10:55:21 +01:00 committed by Alexandre Julliard
parent f1d22c0ebd
commit 7a4d8f57c7
6 changed files with 79 additions and 67 deletions

View File

@ -2070,7 +2070,6 @@ DWORD msi_get_disk_file_size( LPCWSTR filename )
return INVALID_FILE_SIZE; return INVALID_FILE_SIZE;
size = GetFileSize( file, NULL ); size = GetFileSize( file, NULL );
TRACE("size is %u\n", size);
CloseHandle( file ); CloseHandle( file );
return size; return size;
} }
@ -2081,7 +2080,7 @@ BOOL msi_file_hash_matches( MSIFILE *file )
MSIFILEHASHINFO hash; MSIFILEHASHINFO hash;
hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO); hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
r = MsiGetFileHashW( file->TargetPath, 0, &hash ); r = msi_get_filehash( file->TargetPath, &hash );
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
return FALSE; return FALSE;
@ -2154,8 +2153,6 @@ static void set_target_path( MSIPACKAGE *package, MSIFILE *file )
{ {
MSIASSEMBLY *assembly = file->Component->assembly; MSIASSEMBLY *assembly = file->Component->assembly;
TRACE("file %s is named %s\n", debugstr_w(file->File), debugstr_w(file->FileName));
msi_free( file->TargetPath ); msi_free( file->TargetPath );
if (assembly && !assembly->application) if (assembly && !assembly->application)
{ {
@ -2169,7 +2166,7 @@ static void set_target_path( MSIPACKAGE *package, MSIFILE *file )
file->TargetPath = msi_build_directory_name( 2, dir, file->FileName ); file->TargetPath = msi_build_directory_name( 2, dir, file->FileName );
} }
TRACE("resolves to %s\n", debugstr_w(file->TargetPath)); TRACE("file %s resolves to %s\n", debugstr_w(file->File), debugstr_w(file->TargetPath));
} }
static UINT calculate_file_cost( MSIPACKAGE *package ) static UINT calculate_file_cost( MSIPACKAGE *package )
@ -2197,6 +2194,7 @@ static UINT calculate_file_cost( MSIPACKAGE *package )
continue; continue;
} }
file_size = msi_get_disk_file_size( file->TargetPath ); file_size = msi_get_disk_file_size( file->TargetPath );
TRACE("%s (size %u)\n", debugstr_w(file->TargetPath), file_size);
if (file->Version) if (file->Version)
{ {

View File

@ -69,34 +69,38 @@ static msi_file_state calculate_install_state( MSIPACKAGE *package, MSIFILE *fil
VS_FIXEDFILEINFO *file_version; VS_FIXEDFILEINFO *file_version;
WCHAR *font_version; WCHAR *font_version;
msi_file_state state; msi_file_state state;
DWORD size;
comp->Action = msi_get_component_action( package, comp ); comp->Action = msi_get_component_action( package, comp );
if (comp->Action != INSTALLSTATE_LOCAL || (comp->assembly && comp->assembly->installed)) if (comp->Action != INSTALLSTATE_LOCAL || (comp->assembly && comp->assembly->installed))
{ {
TRACE("file %s is not scheduled for install\n", debugstr_w(file->File)); TRACE("skipping %s (not scheduled for install)\n", debugstr_w(file->File));
return msifs_skipped; return msifs_skipped;
} }
if ((comp->assembly && !comp->assembly->application && !comp->assembly->installed) || if ((comp->assembly && !comp->assembly->application && !comp->assembly->installed) ||
GetFileAttributesW( file->TargetPath ) == INVALID_FILE_ATTRIBUTES) GetFileAttributesW( file->TargetPath ) == INVALID_FILE_ATTRIBUTES)
{ {
TRACE("file %s is missing\n", debugstr_w(file->File)); TRACE("installing %s (missing)\n", debugstr_w(file->File));
return msifs_missing; return msifs_missing;
} }
if (file->Version) if (file->Version)
{ {
if ((file_version = msi_get_disk_file_version( file->TargetPath ))) if ((file_version = msi_get_disk_file_version( file->TargetPath )))
{ {
TRACE("new %s old %u.%u.%u.%u\n", debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS),
LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS),
LOWORD(file_version->dwFileVersionLS));
if (msi_compare_file_versions( file_version, file->Version ) < 0) if (msi_compare_file_versions( file_version, file->Version ) < 0)
{
TRACE("overwriting %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_overwrite; state = msifs_overwrite;
}
else else
{ {
TRACE("destination file version equal or greater, not overwriting\n"); TRACE("keeping %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_present; state = msifs_present;
} }
msi_free( file_version ); msi_free( file_version );
@ -104,37 +108,46 @@ static msi_file_state calculate_install_state( MSIPACKAGE *package, MSIFILE *fil
} }
else if ((font_version = msi_font_version_from_file( file->TargetPath ))) else if ((font_version = msi_font_version_from_file( file->TargetPath )))
{ {
TRACE("new %s old %s\n", debugstr_w(file->Version), debugstr_w(font_version));
if (msi_compare_font_versions( font_version, file->Version ) < 0) if (msi_compare_font_versions( font_version, file->Version ) < 0)
{
TRACE("overwriting %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_overwrite; state = msifs_overwrite;
}
else else
{ {
TRACE("destination file version equal or greater, not overwriting\n"); TRACE("keeping %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_present; state = msifs_present;
} }
msi_free( font_version ); msi_free( font_version );
return state; return state;
} }
} }
if (msi_get_disk_file_size( file->TargetPath ) != file->FileSize) if ((size = msi_get_disk_file_size( file->TargetPath )) != file->FileSize)
{ {
TRACE("overwriting %s (old size %u new size %u)\n", debugstr_w(file->File), size, file->FileSize);
return msifs_overwrite; return msifs_overwrite;
} }
if (file->hash.dwFileHashInfoSize) if (file->hash.dwFileHashInfoSize)
{ {
if (msi_file_hash_matches( file )) if (msi_file_hash_matches( file ))
{ {
TRACE("file hashes match, not overwriting\n"); TRACE("keeping %s (hash match)\n", debugstr_w(file->File));
return msifs_hashmatch; return msifs_hashmatch;
} }
else else
{ {
TRACE("file hashes do not match, overwriting\n"); TRACE("overwriting %s (hash mismatch)\n", debugstr_w(file->File));
return msifs_overwrite; return msifs_overwrite;
} }
} }
/* assume present */ /* assume present */
TRACE("keeping %s\n", debugstr_w(file->File));
return msifs_present; return msifs_present;
} }

View File

@ -172,7 +172,6 @@ static WCHAR *load_ttf_name_id( const WCHAR *filename, DWORD id )
end: end:
CloseHandle(handle); CloseHandle(handle);
TRACE("Returning %s\n", debugstr_w(ret));
return ret; return ret;
} }

View File

@ -4013,17 +4013,55 @@ extern VOID WINAPI MD5Init( MD5_CTX *);
extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int ); extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
extern VOID WINAPI MD5Final( MD5_CTX *); extern VOID WINAPI MD5Final( MD5_CTX *);
/*********************************************************************** UINT msi_get_filehash( const WCHAR *path, MSIFILEHASHINFO *hash )
* MsiGetFileHashW [MSI.@]
*/
UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
PMSIFILEHASHINFO pHash )
{ {
HANDLE handle, mapping; HANDLE handle, mapping;
void *p; void *p;
DWORD length; DWORD length;
UINT r = ERROR_FUNCTION_FAILED; UINT r = ERROR_FUNCTION_FAILED;
handle = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
if (handle == INVALID_HANDLE_VALUE)
{
WARN("can't open file %u\n", GetLastError());
return ERROR_FILE_NOT_FOUND;
}
if ((length = GetFileSize( handle, NULL )))
{
if ((mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL )))
{
if ((p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length )))
{
MD5_CTX ctx;
MD5Init( &ctx );
MD5Update( &ctx, p, length );
MD5Final( &ctx );
UnmapViewOfFile( p );
memcpy( hash->dwData, ctx.digest, sizeof(hash->dwData) );
r = ERROR_SUCCESS;
}
CloseHandle( mapping );
}
}
else
{
/* Empty file -> set hash to 0 */
memset( hash->dwData, 0, sizeof(hash->dwData) );
r = ERROR_SUCCESS;
}
CloseHandle( handle );
return r;
}
/***********************************************************************
* MsiGetFileHashW [MSI.@]
*/
UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
PMSIFILEHASHINFO pHash )
{
TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash ); TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
if (!szFilePath) if (!szFilePath)
@ -4039,46 +4077,7 @@ UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
if (pHash->dwFileHashInfoSize < sizeof *pHash) if (pHash->dwFileHashInfoSize < sizeof *pHash)
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
handle = CreateFileW( szFilePath, GENERIC_READ, return msi_get_filehash( szFilePath, pHash );
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
if (handle == INVALID_HANDLE_VALUE)
{
WARN("can't open file %u\n", GetLastError());
return ERROR_FILE_NOT_FOUND;
}
length = GetFileSize( handle, NULL );
if (length)
{
mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL );
if (mapping)
{
p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length );
if (p)
{
MD5_CTX ctx;
MD5Init( &ctx );
MD5Update( &ctx, p, length );
MD5Final( &ctx );
UnmapViewOfFile( p );
memcpy( pHash->dwData, ctx.digest, sizeof pHash->dwData );
r = ERROR_SUCCESS;
}
CloseHandle( mapping );
}
}
else
{
/* Empty file -> set hash to 0 */
memset( pHash->dwData, 0, sizeof pHash->dwData );
r = ERROR_SUCCESS;
}
CloseHandle( handle );
return r;
} }
/*********************************************************************** /***********************************************************************

View File

@ -937,6 +937,7 @@ extern int msi_compare_file_versions(VS_FIXEDFILEINFO *, const WCHAR *) DECLSPEC
extern int msi_compare_font_versions(const WCHAR *, const WCHAR *) DECLSPEC_HIDDEN; extern int msi_compare_font_versions(const WCHAR *, const WCHAR *) DECLSPEC_HIDDEN;
extern DWORD msi_get_disk_file_size(LPCWSTR) DECLSPEC_HIDDEN; extern DWORD msi_get_disk_file_size(LPCWSTR) DECLSPEC_HIDDEN;
extern BOOL msi_file_hash_matches(MSIFILE *) DECLSPEC_HIDDEN; extern BOOL msi_file_hash_matches(MSIFILE *) DECLSPEC_HIDDEN;
extern UINT msi_get_filehash(const WCHAR *, MSIFILEHASHINFO *) DECLSPEC_HIDDEN;
extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value ) DECLSPEC_HIDDEN; extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value ) DECLSPEC_HIDDEN;
extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value ) DECLSPEC_HIDDEN; extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value ) DECLSPEC_HIDDEN;

View File

@ -888,7 +888,7 @@ static UINT msi_apply_patch_package( MSIPACKAGE *package, const WCHAR *file )
MSIPATCHINFO *patch = NULL; MSIPATCHINFO *patch = NULL;
UINT r = ERROR_SUCCESS; UINT r = ERROR_SUCCESS;
TRACE("%p %s\n", package, debugstr_w(file)); TRACE("%p, %s\n", package, debugstr_w(file));
r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &patch_db ); r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &patch_db );
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
@ -1003,6 +1003,8 @@ UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code )
MSIPATCHINFO *patch_info; MSIPATCHINFO *patch_info;
MSISUMMARYINFO *si; MSISUMMARYINFO *si;
TRACE("%p, %s\n", package, debugstr_w(patch_code));
len = sizeof(patch_file) / sizeof(WCHAR); len = sizeof(patch_file) / sizeof(WCHAR);
r = MsiGetPatchInfoExW( patch_code, package->ProductCode, NULL, package->Context, r = MsiGetPatchInfoExW( patch_code, package->ProductCode, NULL, package->Context,
INSTALLPROPERTY_LOCALPACKAGEW, patch_file, &len ); INSTALLPROPERTY_LOCALPACKAGEW, patch_file, &len );