From 2a4c7c444b02a70aaf4cc3f53f4af8931b23f86a Mon Sep 17 00:00:00 2001 From: Fabian Maurer Date: Mon, 18 Nov 2024 00:05:03 +0100 Subject: [PATCH 1/2] msi: Add more tests for MsiSummaryInfoPersist --- dlls/msi/tests/suminfo.c | 147 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/dlls/msi/tests/suminfo.c b/dlls/msi/tests/suminfo.c index 59b56a2cbba..753f8bb53e5 100644 --- a/dlls/msi/tests/suminfo.c +++ b/dlls/msi/tests/suminfo.c @@ -278,6 +278,153 @@ static void test_suminfo(void) r = MsiCloseHandle(hsuminfo); ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + /* try persisting on transacted msi */ + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian"); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n"); + + r = MsiSummaryInfoPersist(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_READONLY, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + sz = 0x10; + strcpy(buf,"x"); + r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n"); + ok(!strcmp(buf,"Mike"), "buffer was wrong: %s\n", buf); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + /* try persisting on transacted msi with commit */ + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian"); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n"); + + r = MsiSummaryInfoPersist(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiDatabaseCommit(hdb); + ok(r == ERROR_SUCCESS, "MsiDatabaseCommit wrong error %u\n", r); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_READONLY, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + sz = 0x10; + strcpy(buf,"x"); + r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n"); + ok(!strcmp(buf,"Fabian"), "buffer was wrong: %s\n", buf); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + /* try persisting on direct msi */ + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian2"); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n"); + + r = MsiSummaryInfoPersist(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_READONLY, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + sz = 0x10; + strcpy(buf,"x"); + r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n"); + ok(!strcmp(buf,"Fabian2"), "buffer was wrong: %s\n", buf); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + /* try persisting on indirectly opened msi */ + r = MsiGetSummaryInformationA(0, msifile, 2, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error %u\n", r); + + r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian3"); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n"); + + r = MsiSummaryInfoPersist(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_READONLY, &hdb); + ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n"); + + r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo); + ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n"); + + sz = 0x10; + strcpy(buf,"x"); + r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz); + ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n"); + todo_wine + ok(!strcmp(buf,"Fabian3"), "buffer was wrong: %s\n", buf); + + r = MsiCloseHandle(hsuminfo); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n"); + + /* Cleanup */ r = DeleteFileA(msifile); ok(r, "DeleteFile failed\n"); } From 777c8b864ad3306882cfdda8710c749988dc8b0f Mon Sep 17 00:00:00 2001 From: Fabian Maurer Date: Mon, 18 Nov 2024 00:06:54 +0100 Subject: [PATCH 2/2] msi: Make MsiGetSummaryInformationW open database as direct instead of transacted This fixes MsiSummaryInfoPersist not saving data to disk Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55859 --- dlls/msi/suminfo.c | 2 +- dlls/msi/tests/suminfo.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c index b1934cf41c7..8670904c59b 100644 --- a/dlls/msi/suminfo.c +++ b/dlls/msi/suminfo.c @@ -515,7 +515,7 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, const WCHAR *szDatab if( szDatabase && szDatabase[0] ) { - LPCWSTR persist = uiUpdateCount ? MSIDBOPEN_TRANSACT : MSIDBOPEN_READONLY; + LPCWSTR persist = uiUpdateCount ? MSIDBOPEN_DIRECT : MSIDBOPEN_READONLY; ret = MSI_OpenDatabaseW( szDatabase, persist, &db ); if( ret != ERROR_SUCCESS ) diff --git a/dlls/msi/tests/suminfo.c b/dlls/msi/tests/suminfo.c index 753f8bb53e5..42e68c16d84 100644 --- a/dlls/msi/tests/suminfo.c +++ b/dlls/msi/tests/suminfo.c @@ -415,7 +415,6 @@ static void test_suminfo(void) strcpy(buf,"x"); r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz); ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n"); - todo_wine ok(!strcmp(buf,"Fabian3"), "buffer was wrong: %s\n", buf); r = MsiCloseHandle(hsuminfo);