MsiUseFeature() returning INSTALLSTATE_BROKEN is tolerated in non-elevated process now
This commit is contained in:
parent
a1485a78f6
commit
cf6e3e7c25
@ -47,7 +47,32 @@ static int MsiUseFeature()
|
||||
}
|
||||
|
||||
// Perform the Microsoft Installer's feature completeness check.
|
||||
if (MsiUseFeatureW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) != INSTALLSTATE_LOCAL) {
|
||||
switch (MsiUseFeatureW(_L(PRODUCT_VERSION_GUID), pwcArglist[1])) {
|
||||
case INSTALLSTATE_LOCAL:
|
||||
// All components of the feature were checked and present.
|
||||
break;
|
||||
|
||||
case INSTALLSTATE_BROKEN: {
|
||||
// Some of the components are reported missing.
|
||||
//
|
||||
// Unfortunately, the feature state is falsely reported as broken, when MsiUseFeature() lacks privilege
|
||||
// to check the presence of at least one component installed in an inaccessible folder or registry key.
|
||||
// If our process is not elevated and feature does contain such components, this is the expected result.
|
||||
// However, even when we are "Run as Administrator", this does not guarantee we can access all the
|
||||
// components. Some might be restricted from Administrators group aswell.
|
||||
win_handle token;
|
||||
TOKEN_ELEVATION Elevation; DWORD dwSize;
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) &&
|
||||
GetTokenInformation(token, TokenElevation, &Elevation, sizeof(Elevation), &dwSize) &&
|
||||
!Elevation.TokenIsElevated)
|
||||
{
|
||||
// We are not elevated.
|
||||
OutputDebugStr(_T("The feature is reported broken and the elevation is required for a more reliable test. Silently assuming the feature is complete.\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
OutputDebugStr(_T("The feature is not installed locally.\n"));
|
||||
return 2;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b09610fd5f9168cb70252e7a8227995ba931f268
|
||||
Subproject commit 750f40fada90ce22e8aceb4bf2775be8478bf63b
|
Loading…
x
Reference in New Issue
Block a user