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