msi: Reimplement MsiGetComponentPath.
This commit is contained in:
parent
ced84f5b53
commit
383a8a5b92
@ -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 )
|
||||
return INSTALLSTATE_INVALIDARG;
|
||||
if( lpPathBuf->str.w && !pcchBuf )
|
||||
if (!szProduct || !szComponent)
|
||||
return INSTALLSTATE_INVALIDARG;
|
||||
|
||||
if (!squash_guid( szProduct, squished_pc ) ||
|
||||
!squash_guid( szComponent, squished_comp ))
|
||||
if (lpPathBuf->str.w && !pcchBuf)
|
||||
return INSTALLSTATE_INVALIDARG;
|
||||
|
||||
rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
|
||||
if( rc != ERROR_SUCCESS )
|
||||
return INSTALLSTATE_UNKNOWN;
|
||||
if (!squash_guid(szProduct, squished_pc) ||
|
||||
!squash_guid(szComponent, squished_comp))
|
||||
return INSTALLSTATE_INVALIDARG;
|
||||
|
||||
RegCloseKey(hkey);
|
||||
state = INSTALLSTATE_UNKNOWN;
|
||||
|
||||
rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
|
||||
if( rc != ERROR_SUCCESS )
|
||||
return INSTALLSTATE_UNKNOWN;
|
||||
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);
|
||||
|
||||
path = msi_reg_get_val_str( hkey, squished_pc );
|
||||
RegCloseKey(hkey);
|
||||
state = INSTALLSTATE_ABSENT;
|
||||
|
||||
TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
|
||||
debugstr_w(szProduct), debugstr_w(path));
|
||||
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);
|
||||
|
||||
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;
|
||||
if (state == INSTALLSTATE_LOCAL && !*path)
|
||||
state = INSTALLSTATE_NOTUSED;
|
||||
|
||||
msi_strcpy_to_awstring( path, lpPathBuf, pcchBuf );
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user