Commit 383a8a5b authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Reimplement MsiGetComponentPath.

parent ced84f5b
......@@ -1240,52 +1240,78 @@ UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
static INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
awstring* lpPathBuf, LPDWORD pcchBuf)
{
WCHAR squished_pc[GUID_SIZE], squished_comp[GUID_SIZE];
UINT rc;
HKEY hkey = 0;
WCHAR squished_pc[GUID_SIZE];
WCHAR squished_comp[GUID_SIZE];
HKEY hkey;
LPWSTR path = NULL;
INSTALLSTATE r;
INSTALLSTATE state;
DWORD version;
static const WCHAR wininstaller[] = {
'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
TRACE("%s %s %p %p\n", debugstr_w(szProduct),
debugstr_w(szComponent), lpPathBuf->str.w, pcchBuf);
if( !szProduct || !szComponent )
if (!szProduct || !szComponent)
return INSTALLSTATE_INVALIDARG;
if( lpPathBuf->str.w && !pcchBuf )
if (lpPathBuf->str.w && !pcchBuf)
return INSTALLSTATE_INVALIDARG;
if (!squash_guid( szProduct, squished_pc ) ||
!squash_guid( szComponent, squished_comp ))
if (!squash_guid(szProduct, squished_pc) ||
!squash_guid(szComponent, squished_comp))
return INSTALLSTATE_INVALIDARG;
rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
if( rc != ERROR_SUCCESS )
return INSTALLSTATE_UNKNOWN;
state = INSTALLSTATE_UNKNOWN;
RegCloseKey(hkey);
if (MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS)
{
path = msi_reg_get_val_str(hkey, squished_pc);
RegCloseKey(hkey);
rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
if( rc != ERROR_SUCCESS )
return INSTALLSTATE_UNKNOWN;
state = INSTALLSTATE_ABSENT;
path = msi_reg_get_val_str( hkey, squished_pc );
RegCloseKey(hkey);
if ((MSIREG_OpenLocalSystemProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenUserDataProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS) &&
msi_reg_get_val_dword(hkey, wininstaller, &version) &&
GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
{
RegCloseKey(hkey);
state = INSTALLSTATE_LOCAL;
}
}
if (state != INSTALLSTATE_LOCAL &&
(MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS))
{
RegCloseKey(hkey);
if (MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS)
{
msi_free(path);
path = msi_reg_get_val_str(hkey, squished_pc);
RegCloseKey(hkey);
TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
debugstr_w(szProduct), debugstr_w(path));
state = INSTALLSTATE_ABSENT;
if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
state = INSTALLSTATE_LOCAL;
}
}
if (!path)
return INSTALLSTATE_UNKNOWN;
if (path[0])
r = INSTALLSTATE_LOCAL;
else
r = INSTALLSTATE_NOTUSED;
msi_strcpy_to_awstring( path, lpPathBuf, pcchBuf );
if (state == INSTALLSTATE_LOCAL && !*path)
state = INSTALLSTATE_NOTUSED;
msi_free( path );
return r;
msi_strcpy_to_awstring(path, lpPathBuf, pcchBuf);
msi_free(path);
return state;
}
/******************************************************************
......
......@@ -1044,12 +1044,9 @@ static void test_MsiGetComponentPath(void)
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
......@@ -1066,24 +1063,18 @@ static void test_MsiGetComponentPath(void)
/* install properties key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(compkey, "");
......@@ -1114,12 +1105,9 @@ static void test_MsiGetComponentPath(void)
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
......@@ -1136,24 +1124,18 @@ static void test_MsiGetComponentPath(void)
/* install properties key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(compkey, "");
......@@ -1199,12 +1181,9 @@ static void test_MsiGetComponentPath(void)
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
......@@ -1221,24 +1200,18 @@ static void test_MsiGetComponentPath(void)
/* install properties key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(prodkey, "");
......@@ -1283,24 +1256,18 @@ static void test_MsiGetComponentPath(void)
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(prodkey, "");
......@@ -1341,24 +1308,18 @@ static void test_MsiGetComponentPath(void)
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(prodkey, "");
......
......@@ -3780,10 +3780,7 @@ static void test_states(void)
action = 0xdeadbee;
r = MsiGetFeatureState(hpkg, "five", &state, &action);
ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
todo_wine
{
ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
}
ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
state = 0xdeadbee;
......
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