diff --git a/dlls/msi/package.c b/dlls/msi/package.c index 7c537d4b5a6..00a828303e3 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -352,6 +352,7 @@ static void MSI_FreePackage( MSIOBJECTHDR *arg) if (package->delete_on_close) DeleteFileW( package->localfile ); msi_free( package->localfile ); + MSI_ProcessMessage(NULL, INSTALLMESSAGE_TERMINATE, 0); } static UINT create_temp_property_table(MSIPACKAGE *package) @@ -1477,6 +1478,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) TRACE("%s %p\n", debugstr_w(szPackage), pPackage); + MSI_ProcessMessage(NULL, INSTALLMESSAGE_INITIALIZE, 0); + localfile[0] = 0; if( szPackage[0] == '#' ) { @@ -1638,6 +1641,8 @@ UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phP ret = ERROR_NOT_ENOUGH_MEMORY; msiobj_release( &package->hdr ); } + else + MSI_ProcessMessage(NULL, INSTALLMESSAGE_TERMINATE, 0); return ret; } @@ -1787,13 +1792,17 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIREC msi_free(template); } - res = MSI_FormatRecordW(package, record, message, &len); - if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) - return res; - len++; - message = msi_alloc(len * sizeof(WCHAR)); - if (!message) return ERROR_OUTOFMEMORY; - MSI_FormatRecordW(package, record, message, &len); + if (!package || !record) + message = NULL; + else { + res = MSI_FormatRecordW(package, record, message, &len); + if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) + return res; + len++; + message = msi_alloc(len * sizeof(WCHAR)); + if (!message) return ERROR_OUTOFMEMORY; + MSI_FormatRecordW(package, record, message, &len); + } /* convert it to ASCII */ len = WideCharToMultiByte( CP_ACP, 0, message, -1, NULL, 0, NULL, NULL ); @@ -1821,7 +1830,7 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIREC rc = gUIHandlerA( gUIContext, eMessageType, msg ); } - if (!rc && package->log_file != INVALID_HANDLE_VALUE && + if (!rc && package && package->log_file != INVALID_HANDLE_VALUE && (eMessageType & 0xff000000) != INSTALLMESSAGE_PROGRESS) { DWORD written; @@ -1883,6 +1892,10 @@ INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType, MSIPACKAGE *package = NULL; MSIRECORD *record = NULL; + if ((eMessageType & 0xff000000) == INSTALLMESSAGE_INITIALIZE || + (eMessageType & 0xff000000) == INSTALLMESSAGE_TERMINATE) + return -1; + package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE ); if( !package ) { diff --git a/dlls/msi/tests/format.c b/dlls/msi/tests/format.c index b035cfa08bf..d86a252f8dc 100644 --- a/dlls/msi/tests/format.c +++ b/dlls/msi/tests/format.c @@ -2782,6 +2782,9 @@ static void test_processmessage(void) todo_wine ok( r == IDOK, "expected IDOK, got %i\n", r); + r = MsiProcessMessage(package, INSTALLMESSAGE_INITIALIZE, hrec); + ok( r == -1, "expected -1, got %i\n", r); + MsiCloseHandle(hrec); MsiCloseHandle(package); diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 9934c00a29e..a46bb20fdfa 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -9384,7 +9384,7 @@ static void test_externalui_message(void) r = MsiOpenPackageA("nonexistent", &hpkg); ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r); - ok_sequence(openpackage_nonexistent_sequence, "MsiOpenPackage with nonexistent db", TRUE); + ok_sequence(openpackage_nonexistent_sequence, "MsiOpenPackage with nonexistent db", FALSE); r = package_from_db(hdb, &hpkg); if (r == ERROR_INSTALL_PACKAGE_REJECTED) @@ -9408,7 +9408,7 @@ static void test_externalui_message(void) /* close the package */ MsiCloseHandle(hpkg); - ok_sequence(closehandle_sequence, "MsiCloseHandle()", TRUE); + ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE); CoUninitialize(); DeleteFileA(msifile);