msi: Open the correct key and return INSTALLSTATE_ADVERTISED if it's missing.
This commit is contained in:
parent
ceb4e6d4ef
commit
1130d5909b
|
@ -1260,9 +1260,9 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
|||
return r;
|
||||
|
||||
/* now check if it's complete or advertised */
|
||||
rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
|
||||
rc = MSIREG_OpenUserDataFeaturesKey(szProduct, &hkey, FALSE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
return INSTALLSTATE_UNKNOWN;
|
||||
return INSTALLSTATE_ADVERTISED;
|
||||
|
||||
components = msi_reg_get_val_str( hkey, szFeature );
|
||||
RegCloseKey(hkey);
|
||||
|
|
|
@ -703,6 +703,7 @@ extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create
|
|||
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenFeatures(HKEY* key);
|
||||
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenComponents(HKEY* key);
|
||||
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
|
||||
|
|
|
@ -60,6 +60,16 @@ static const WCHAR szInstaller_Features[] = {
|
|||
'I','n','s','t','a','l','l','e','r','\\',
|
||||
'F','e','a','t','u','r','e','s',0 };
|
||||
|
||||
static const WCHAR szUserDataFeatures_fmt[] = {
|
||||
'S','o','f','t','w','a','r','e','\\',
|
||||
'M','i','c','r','o','s','o','f','t','\\',
|
||||
'W','i','n','d','o','w','s','\\',
|
||||
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
||||
'I','n','s','t','a','l','l','e','r','\\',
|
||||
'U','s','e','r','D','a','t','a','\\',
|
||||
'%','s','\\','P','r','o','d','u','c','t','s','\\',
|
||||
'%','s','\\','F','e','a','t','u','r','e','s',0};
|
||||
|
||||
static const WCHAR szInstaller_Features_fmt[] = {
|
||||
'S','o','f','t','w','a','r','e','\\',
|
||||
'M','i','c','r','o','s','o','f','t','\\',
|
||||
|
@ -411,6 +421,27 @@ BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val)
|
|||
return r == ERROR_SUCCESS && type == REG_DWORD;
|
||||
}
|
||||
|
||||
static UINT get_user_sid(LPWSTR *usersid)
|
||||
{
|
||||
HANDLE token;
|
||||
BYTE buf[1024];
|
||||
DWORD size;
|
||||
PTOKEN_USER user;
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
size = sizeof(buf);
|
||||
if (!GetTokenInformation(token, TokenUser, (void *)buf, size, &size))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
user = (PTOKEN_USER)buf;
|
||||
if (!ConvertSidToStringSidW(user->User.Sid, usersid))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
|
@ -526,6 +557,35 @@ UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
|||
return rc;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
WCHAR keypath[0x200];
|
||||
LPWSTR usersid;
|
||||
|
||||
TRACE("%s\n", debugstr_w(szProduct));
|
||||
squash_guid(szProduct, squished_pc);
|
||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
||||
|
||||
rc = get_user_sid(&usersid);
|
||||
if (rc != ERROR_SUCCESS || !usersid)
|
||||
{
|
||||
ERR("Failed to retrieve user SID: %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
|
||||
|
||||
if (create)
|
||||
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
else
|
||||
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
|
||||
msi_free(usersid);
|
||||
return rc;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenComponents(HKEY* key)
|
||||
{
|
||||
return RegCreateKeyW(HKEY_LOCAL_MACHINE,szInstaller_Components,key);
|
||||
|
@ -571,27 +631,6 @@ UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static UINT get_user_sid(LPWSTR *usersid)
|
||||
{
|
||||
HANDLE token;
|
||||
BYTE buf[1024];
|
||||
DWORD size;
|
||||
PTOKEN_USER user;
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
size = sizeof(buf);
|
||||
if (!GetTokenInformation(token, TokenUser, (void *)buf, size, &size))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
user = (PTOKEN_USER)buf;
|
||||
if (!ConvertSidToStringSidW(user->User.Sid, usersid))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY *key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
|
|
|
@ -1850,7 +1850,10 @@ static void test_publish(void)
|
|||
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
|
||||
todo_wine
|
||||
|
@ -1905,7 +1908,10 @@ static void test_publish(void)
|
|||
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
|
||||
todo_wine
|
||||
|
@ -1960,7 +1966,10 @@ static void test_publish(void)
|
|||
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
|
||||
todo_wine
|
||||
|
@ -1986,10 +1995,16 @@ static void test_publish(void)
|
|||
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
|
||||
|
@ -2067,10 +2082,16 @@ static void test_publish(void)
|
|||
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
|
||||
|
|
|
@ -573,10 +573,7 @@ static void test_MsiQueryFeatureState(void)
|
|||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
state = MsiQueryFeatureStateA(prodcode, "feature");
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
}
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
|
||||
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
|
||||
lstrcatA(keypath, usersid);
|
||||
|
@ -606,28 +603,19 @@ static void test_MsiQueryFeatureState(void)
|
|||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
state = MsiQueryFeatureStateA(prodcode, "feature");
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
}
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
|
||||
res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
state = MsiQueryFeatureStateA(prodcode, "feature");
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
}
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
|
||||
res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
state = MsiQueryFeatureStateA(prodcode, "feature");
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
}
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
|
||||
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
|
||||
lstrcatA(keypath, usersid);
|
||||
|
@ -638,10 +626,7 @@ static void test_MsiQueryFeatureState(void)
|
|||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
state = MsiQueryFeatureStateA(prodcode, "feature");
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
}
|
||||
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
|
||||
|
||||
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
@ -652,6 +637,15 @@ static void test_MsiQueryFeatureState(void)
|
|||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
state = MsiQueryFeatureStateA(prodcode, "feature");
|
||||
todo_wine
|
||||
{
|
||||
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
|
||||
}
|
||||
|
||||
RegDeleteValueA(compkey, prod_squashed);
|
||||
RegDeleteValueA(compkey, "");
|
||||
RegDeleteValueA(localkey, "feature");
|
||||
|
|
Loading…
Reference in New Issue