static void test_MsiInstallProduct(void) { UINT r; CHAR path[MAX_PATH]; LONG res; HKEY hkey; DWORD num, size, type; r = MsiInstallProductA(msifile, NULL); todo_wine { ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); } todo_wine { ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n"); ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n"); ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest\\changed", FALSE), "File not installed\n"); ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest\\first", FALSE), "File not installed\n"); ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); } res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey); todo_wine { ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res); } size = MAX_PATH; type = REG_SZ; res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size); todo_wine { ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res); ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path); } size = MAX_PATH; type = REG_SZ; res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size); todo_wine { ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", res); } size = sizeof(num); type = REG_DWORD; res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size); todo_wine { ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", res); ok(num == 314, "Expected 314, got %ld\n", num); } RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest"); }
static void test_simple_patch( void ) { UINT r; DWORD size; char path[MAX_PATH], install_source[MAX_PATH], buffer[32]; const char *query; MSIHANDLE hpackage, hdb, hview, hrec; if (!pMsiApplyPatchA) { win_skip("MsiApplyPatchA is not available\n"); return; } if (is_process_limited()) { skip("process is limited\n"); return; } CreateDirectoryA( "msitest", NULL ); create_file( "msitest\\patch.txt", 1000 ); create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) ); create_patch( mspfile ); MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); r = MsiInstallProductA( msifile, NULL ); if (r != ERROR_SUCCESS) { skip("Product installation failed with error code %u\n", r); goto cleanup; } size = get_pf_file_size( "msitest\\patch.txt" ); ok( size == 1000, "expected 1000, got %u\n", size ); size = sizeof(install_source); r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", "InstallSource", install_source, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); strcpy( path, CURR_DIR ); strcat( path, "\\" ); strcat( path, msifile ); r = MsiOpenPackageA( path, &hpackage ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hpackage ); ok( hdb, "failed to get database handle\n" ); query = "SELECT * FROM `Property` where `Property` = 'PATCHNEWPACKAGECODE'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); query = "SELECT * FROM `Property` WHERE `Property` = 'PATCHNEWSUMMARYSUBJECT' " "AND `Value` = 'Installer Database'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); buffer[0] = 0; size = sizeof(buffer); r = MsiGetProperty( hpackage, "PATCHNEWSUMMARYSUBJECT", buffer, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcmp( buffer, "Installer Database" ), "expected \'Installer Database\', got \'%s\'\n", buffer ); MsiCloseHandle( hdb ); MsiCloseHandle( hpackage ); r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL ); ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */ "expected ERROR_SUCCESS, got %u\n", r ); if (r == ERROR_PATCH_PACKAGE_INVALID) { win_skip("Windows Installer < 3.0 detected\n"); goto uninstall; } size = get_pf_file_size( "msitest\\patch.txt" ); ok( size == 1002, "expected 1002, got %u\n", size ); /* show that MsiOpenPackage applies registered patches */ r = MsiOpenPackageA( path, &hpackage ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hpackage ); ok( hdb, "failed to get database handle\n" ); query = "SELECT * FROM `Property` where `Property` = 'PATCHNEWPACKAGECODE'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); query = "SELECT * FROM `Property` WHERE `Property` = 'PATCHNEWSUMMARYSUBJECT' " "AND `Value` = 'Installation Database'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); buffer[0] = 0; size = sizeof(buffer); r = MsiGetProperty( hpackage, "PATCHNEWSUMMARYSUBJECT", buffer, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcmp( buffer, "Installation Database" ), "expected \'Installation Database\', got \'%s\'\n", buffer ); MsiCloseHandle( hdb ); MsiCloseHandle( hpackage ); /* show that patches are not committed to the local package database */ size = sizeof(path); r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", "LocalPackage", path, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiOpenDatabaseA( path, MSIDBOPEN_READONLY, &hdb ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); MsiCloseHandle( hdb ); uninstall: size = sizeof(path); r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", "InstallSource", path, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcasecmp( path, install_source ), "wrong path %s\n", path ); r = MsiInstallProductA( msifile, "REMOVE=ALL" ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !delete_pf( "msitest\\patch.txt", TRUE ), "file not removed\n" ); ok( !delete_pf( "msitest", FALSE ), "directory not removed\n" ); cleanup: DeleteFileA( msifile ); DeleteFileA( mspfile ); DeleteFileA( "msitest\\patch.txt" ); RemoveDirectoryA( "msitest" ); }
static void test_system_tables( void ) { UINT r; const char *query; MSIHANDLE hproduct, hdb, hview, hrec; if (!pMsiApplyPatchA) { win_skip("MsiApplyPatchA is not available\n"); return; } if (is_process_limited()) { skip("process is limited\n"); return; } CreateDirectoryA( "msitest", NULL ); create_file( "msitest\\patch.txt", 1000 ); create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) ); create_patch( mspfile ); MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); r = MsiInstallProductA( msifile, NULL ); if (r != ERROR_SUCCESS) { skip("Product installation failed with error code %d\n", r); goto cleanup; } r = MsiOpenProductA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &hproduct ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hproduct ); ok( hdb, "failed to get database handle\n" ); r = find_entry( hdb, "_Streams", "\5SummaryInformation" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); query = "SELECT * FROM `_Storages`"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); r = find_entry( hdb, "_Tables", "Directory" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "File" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Component" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Feature" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "FeatureComponents" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "InstallExecuteSequence" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Media" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "_Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); MsiCloseHandle( hdb ); MsiCloseHandle( hproduct ); r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL ); ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */ "expected ERROR_SUCCESS, got %u\n", r ); if (r == ERROR_PATCH_PACKAGE_INVALID) { win_skip("Windows Installer < 3.0 detected\n"); goto uninstall; } r = MsiOpenProductA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &hproduct ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hproduct ); ok( hdb, "failed to get database handle\n" ); r = find_entry( hdb, "_Streams", "\5SummaryInformation" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); query = "SELECT * FROM `_Storages`"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); r = find_entry( hdb, "_Tables", "Directory" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "File" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Component" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Feature" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "FeatureComponents" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "InstallExecuteSequence" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Media" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "_Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "MsiPatchHeaders" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Patch" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "PatchPackage" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); MsiCloseHandle( hdb ); MsiCloseHandle( hproduct ); uninstall: r = MsiInstallProductA( msifile, "REMOVE=ALL" ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); cleanup: DeleteFileA( msifile ); DeleteFileA( mspfile ); DeleteFileA( "msitest\\patch.txt" ); RemoveDirectoryA( "msitest" ); }
static void test_patch_registration( void ) { UINT r, size; char buffer[MAX_PATH], patch_code[39]; if (!pMsiApplyPatchA || !pMsiGetPatchInfoExA || !pMsiEnumPatchesExA) { win_skip("required functions not available\n"); return; } if (is_process_limited()) { skip("process is limited\n"); return; } CreateDirectoryA( "msitest", NULL ); create_file( "msitest\\patch.txt", 1000 ); create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) ); create_patch( mspfile ); MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); r = MsiInstallProductA( msifile, NULL ); if (r != ERROR_SUCCESS) { skip("Product installation failed with error code %d\n", r); goto cleanup; } r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL ); ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */ "expected ERROR_SUCCESS, got %u\n", r ); if (r == ERROR_PATCH_PACKAGE_INVALID) { win_skip("Windows Installer < 3.0 detected\n"); goto uninstall; } buffer[0] = 0; size = sizeof(buffer); r = pMsiGetPatchInfoExA( "{0F96CDC0-4CDF-4304-B283-7B9264889EF7}", "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_LOCALPACKAGE, buffer, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( buffer[0], "buffer empty\n" ); buffer[0] = 0; size = sizeof(buffer); r = pMsiGetPatchInfoExA( "{0F96CDC0-4CDF-4304-B283-7B9264889EF7}", "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_MACHINE, INSTALLPROPERTY_LOCALPACKAGE, buffer, &size ); ok( r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r ); buffer[0] = 0; size = sizeof(buffer); r = pMsiGetPatchInfoExA( "{0F96CDC0-4CDF-4304-B283-7B9264889EF7}", "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_USERMANAGED, INSTALLPROPERTY_LOCALPACKAGE, buffer, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !buffer[0], "got %s\n", buffer ); r = pMsiEnumPatchesExA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_APPLIED, 0, patch_code, NULL, NULL, NULL, NULL ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcmp( patch_code, "{0F96CDC0-4CDF-4304-B283-7B9264889EF7}" ), "wrong patch code\n" ); r = pMsiEnumPatchesExA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_MACHINE, MSIPATCHSTATE_APPLIED, 0, patch_code, NULL, NULL, NULL, NULL ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); r = pMsiEnumPatchesExA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_USERMANAGED, MSIPATCHSTATE_APPLIED, 0, patch_code, NULL, NULL, NULL, NULL ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); uninstall: r = MsiInstallProductA( msifile, "REMOVE=ALL" ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); buffer[0] = 0; size = sizeof(buffer); r = pMsiGetPatchInfoExA( "{0F96CDC0-4CDF-4304-B283-7B9264889EF7}", "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", NULL, MSIINSTALLCONTEXT_USERUNMANAGED, INSTALLPROPERTY_LOCALPACKAGE, buffer, &size ); ok( r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r ); cleanup: DeleteFileA( msifile ); DeleteFileA( mspfile ); DeleteFileA( "msitest\\patch.txt" ); RemoveDirectoryA( "msitest" ); }