Module: wine Branch: master Commit: 70225a4de3acc2cb15034eae2b7f929078602f72 URL: http://source.winehq.org/git/wine.git/?a=commit;h=70225a4de3acc2cb15034eae2b...
Author: Jérôme Gardou jerome.gardou@reactos.org Date: Wed Apr 30 16:08:43 2014 +0200
msi: Expand REG_EXPAND_SZ keys when resolving AppSearch entries.
---
dlls/msi/appsearch.c | 13 +++++++++++++ dlls/msi/tests/package.c | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+)
diff --git a/dlls/msi/appsearch.c b/dlls/msi/appsearch.c index 0d9c302..ae8c5c8 100644 --- a/dlls/msi/appsearch.c +++ b/dlls/msi/appsearch.c @@ -451,6 +451,19 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue, MSISIGNAT if (sz == 0) goto end;
+ /* expand if needed */ + if (regType == REG_EXPAND_SZ) + { + sz = ExpandEnvironmentStringsW((LPCWSTR)value, NULL, 0); + if (sz) + { + LPWSTR buf = msi_alloc(sz * sizeof(WCHAR)); + ExpandEnvironmentStringsW((LPCWSTR)value, buf, sz); + msi_free(value); + value = (LPBYTE)buf; + } + } + if ((regType == REG_SZ || regType == REG_EXPAND_SZ) && (ptr = strchrW((LPWSTR)value, '"')) && (end = strchrW(++ptr, '"'))) *end = '\0'; diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index a0c0455..043baf9 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -3689,6 +3689,8 @@ static void test_appsearch(void) MSIHANDLE hdb; CHAR prop[MAX_PATH]; DWORD size; + HKEY hkey; + const char reg_expand_value[] = "%systemroot%\system32\notepad.exe";
hdb = create_package_db(); ok ( hdb, "failed to create package database\n" ); @@ -3702,12 +3704,23 @@ static void test_appsearch(void) r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" ); ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
+ r = add_appsearch_entry( hdb, "'REGEXPANDVAL', 'NewSignature3'" ); + ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r ); + r = create_reglocator_table( hdb ); ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\shell\open\command", "", 1 ); ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
+ r = RegCreateKeyExA(HKEY_CURRENT_USER, "Software\Winetest_msi", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL); + ok( r == ERROR_SUCCESS, "Could not create key: %d.\n", r ); + r = RegSetValueExA(hkey, NULL, 0, REG_EXPAND_SZ, (const BYTE*)reg_expand_value, strlen(reg_expand_value) + 1); + ok( r == ERROR_SUCCESS, "Could not set key value: %d.\n", r); + RegCloseKey(hkey); + r = add_reglocator_entry( hdb, "NewSignature3", 1, "Software\Winetest_msi", "", 1 ); + ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r ); + r = create_drlocator_table( hdb ); ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
@@ -3723,6 +3736,9 @@ static void test_appsearch(void) r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" ); ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
+ r = add_signature_entry( hdb, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" ); + ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r ); + r = package_from_db( hdb, &hpkg ); if (r == ERROR_INSTALL_PACKAGE_REJECTED) { @@ -3749,9 +3765,15 @@ static void test_appsearch(void) r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size ); ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
+ size = sizeof(prop); + r = MsiGetPropertyA( hpkg, "REGEXPANDVAL", prop, &size ); + ok( r == ERROR_SUCCESS, "get property failed: %d\n", r); + ok( lstrlenA(prop) != 0, "Expected non-zero length\n"); + done: MsiCloseHandle( hpkg ); DeleteFileA(msifile); + RegDeleteKeyA(HKEY_CURRENT_USER, "Software\Winetest_msi"); }
static void test_appsearch_complocator(void)