Skip to content

Fix GetFullNameFromFamilyName for non-elevated context - #2922

Merged
yao-msft merged 2 commits into
microsoft:masterfrom
yao-msft:fixfindpackagenonelevated
Feb 6, 2023
Merged

yao-msft merged 2 commits into
microsoft:masterfrom
yao-msft:fixfindpackagenonelevated

Conversation

@yao-msft

@yao-msft yao-msft commented Feb 4, 2023 •

Copy link
Copy Markdown
Contributor

PackageManager.FindPackages requires elevated context, the fix will be to revert to use previous FindPackagesByPackageFamily

Microsoft Reviewers: Open in CodeFlow

@yao-msft
yao-msft requested a review from a team as a code owner February 4, 2023 01:05

std::wstring pfn = Utility::ConvertToUTF16(familyName);
auto packages = packageManager.FindPackages(pfn);
if (Runtime::IsRunningAsAdmin())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we add a comment about why this check is needed?

{
// More than 1 package found. Don't directly error, let caller deal with it.
// Don't directly error, let caller deal with it
AICLI_LOG(Core, Error, << "Multiple packages found for family name: " << fullNameCount);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we also log something like this in the other case?

@yao-msft
yao-msft merged commit 665ddd9 into microsoft:master Feb 6, 2023
@yao-msft
yao-msft deleted the fixfindpackagenonelevated branch February 6, 2023 19:53
@yao-msft yao-msft linked an issue Feb 6, 2023 that may be closed by this pull request
JohnMcPMS pushed a commit that referenced this pull request Sep 3, 2026
## 📖 Description

The initial sizing call to `FindPackagesByPackageFamily` returns
`ERROR_INSUFFICIENT_BUFFER` when matching packages exist, but can
validly return `ERROR_SUCCESS` with a count of zero when no package is
registered for the current identity.

The current code passes that success result to a failure-only WIL macro,
causing the calling process to CRASH through FAIL_FAST instead of
receiving a normal HRESULT. This change accepts the valid empty result
and lets the existing control flow return
`ERROR_PACKAGE_NOT_REGISTERED_FOR_USER` instead.

The registered-package path and propagation of other Win32 errors remain
unchanged. This is consistent with the handling established in #2922.

For the SYSTEM scenario in #4944, this prevents the direct CRASH caused
by FAIL_FAST, but does not add OutOfProc COM support, enumerate packages
registered to other users, or use staged packages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to uninstall a provisioned MSIX package non-elevated

3 participants