Commit e16bcda4 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Don't create empty values for special registry entries.

parent c959e386
...@@ -2578,6 +2578,11 @@ static WCHAR *get_keypath( MSIPACKAGE *package, HKEY root, const WCHAR *path ) ...@@ -2578,6 +2578,11 @@ static WCHAR *get_keypath( MSIPACKAGE *package, HKEY root, const WCHAR *path )
return strdupW( path ); return strdupW( path );
} }
static BOOL is_special_entry( const WCHAR *name, const WCHAR *value )
{
return (name && (name[0] == '*' || name[0] == '+') && !name[1] && !value);
}
static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
{ {
MSIPACKAGE *package = param; MSIPACKAGE *package = param;
...@@ -2612,10 +2617,8 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) ...@@ -2612,10 +2617,8 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
/* null values can have special meanings */ /* null values can have special meanings */
if (name[0]=='-' && name[1] == 0) if (name[0]=='-' && name[1] == 0)
return ERROR_SUCCESS; return ERROR_SUCCESS;
else if ((name[0]=='+' && name[1] == 0) || if ((name[0] == '+' || name[0] == '*') && !name[1])
(name[0] == '*' && name[1] == 0)) check_first = TRUE;
name = NULL;
check_first = TRUE;
} }
root = MSI_RecordGetInteger(row,2); root = MSI_RecordGetInteger(row,2);
...@@ -2652,28 +2655,30 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) ...@@ -2652,28 +2655,30 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
} }
deformat_string(package, name, &deformated); deformat_string(package, name, &deformated);
if (!is_special_entry( name , value ))
if (!check_first)
{
TRACE("Setting value %s of %s\n",debugstr_w(deformated),
debugstr_w(uikey));
RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
}
else
{ {
DWORD sz = 0; if (!check_first)
rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz);
if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
{ {
TRACE("value %s of %s checked already exists\n", TRACE("Setting value %s of %s\n", debugstr_w(deformated),
debugstr_w(deformated), debugstr_w(uikey)); debugstr_w(uikey));
RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
} }
else else
{ {
TRACE("Checked and setting value %s of %s\n", DWORD sz = 0;
debugstr_w(deformated), debugstr_w(uikey)); rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz);
if (deformated || size) if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
RegSetValueExW(hkey, deformated, 0, type, (LPBYTE) value_data, size); {
TRACE("value %s of %s checked already exists\n", debugstr_w(deformated),
debugstr_w(uikey));
}
else
{
TRACE("Checked and setting value %s of %s\n", debugstr_w(deformated),
debugstr_w(uikey));
if (deformated || size)
RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
}
} }
} }
RegCloseKey(hkey); RegCloseKey(hkey);
...@@ -2773,7 +2778,7 @@ static UINT ITERATE_RemoveRegistryValuesOnUninstall( MSIRECORD *row, LPVOID para ...@@ -2773,7 +2778,7 @@ static UINT ITERATE_RemoveRegistryValuesOnUninstall( MSIRECORD *row, LPVOID para
{ {
if (name[0] == '+' && !name[1]) if (name[0] == '+' && !name[1])
return ERROR_SUCCESS; return ERROR_SUCCESS;
else if ((name[0] == '-' && !name[1]) || (name[0] == '*' && !name[1])) if ((name[0] == '-' || name[0] == '*') && !name[1])
{ {
delete_key = TRUE; delete_key = TRUE;
name = NULL; name = NULL;
......
...@@ -487,7 +487,10 @@ static const char wrv_registry_dat[] = ...@@ -487,7 +487,10 @@ static const char wrv_registry_dat[] =
"Registry\tRoot\tKey\tName\tValue\tComponent_\n" "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
"s72\ti2\tl255\tL255\tL0\ts72\n" "s72\ti2\tl255\tL255\tL0\ts72\n"
"Registry\tRegistry\n" "Registry\tRegistry\n"
"regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus"; "regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus\n"
"regdata1\t2\tSOFTWARE\\Wine\\msitest\t*\t\taugustus\n"
"regdata2\t2\tSOFTWARE\\Wine\\msitest\t*\t#%\taugustus\n"
"regdata3\t2\tSOFTWARE\\Wine\\msitest\t*\t#x\taugustus\n";
static const char cf_directory_dat[] = static const char cf_directory_dat[] =
"Directory\tDirectory_Parent\tDefaultDir\n" "Directory\tDirectory_Parent\tDefaultDir\n"
...@@ -4572,7 +4575,7 @@ static void test_write_registry_values(void) ...@@ -4572,7 +4575,7 @@ static void test_write_registry_values(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
size = MAX_PATH; size = MAX_PATH;
type = REG_MULTI_SZ; type = 0xdeadbeef;
memset(path, 'a', MAX_PATH); memset(path, 'a', MAX_PATH);
res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size); res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
...@@ -4580,9 +4583,12 @@ static void test_write_registry_values(void) ...@@ -4580,9 +4583,12 @@ static void test_write_registry_values(void)
ok(size == 15, "Expected 15, got %d\n", size); ok(size == 15, "Expected 15, got %d\n", size);
ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type); ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
res = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
RegDeleteValueA(hkey, "Value"); RegDeleteValueA(hkey, "Value");
RegCloseKey(hkey); RegCloseKey(hkey);
RegDeleteKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Wine\\msitest"); RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
error: error:
DeleteFile(msifile); DeleteFile(msifile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment