Skip to content

Connecting to a catalog reference returns E_INVALIDARG on Windows 10 1903 due to AppCapability::CreateWithProcessIdForUser not accepting a null user when called from an unpackaged app #5378

@Fulgen301

Description

@Fulgen301

Brief description of your issue

https://github.com/microsoft/winget-cli/blob/1b74fd4d7ded2874254e1e8da3a3605ef20b3530/src/Microsoft.Management.Deployment/Helpers.cpp#L81C72-L81C134

EnsureProcessHasCapability calls AppCapability::CreateWithProcessIdForUser and passes nullptr as the user (which is not something the documentation for that method allows, but it wouldn't be the first underdocumented method...). When that call happens in a program without package identity on Windows 10 1903, this fails with E_INVALIDARG, which makes PackageCatalogReference::Connect fail.

Steps to reproduce

  1. Get a PackageCatalogReference object.
  2. Call Connect on Windows 10 1903.
  3. The extended error code will be E_INVALIDARG.

Reproducer

Expected behavior

Connecting to a package catalog succeeds.

Actual behavior

Connecting to a package catalog fails with E_INVALIDARG.

onecore\base\devices\cam\winrt\lib\appcapabilityaccessfactory.cpp(32)\CapabilityAccessManagerClient.dll!6F6ADE82: (caller: 7027946E) ReturnHr(1) tid(181c) 80070057 The parameter is incorrect.
WindowsPackageManager.dll!70279491: LogHr(1) tid(181c) 80070057 The parameter is incorrect.
(b6c.181c): Windows Runtime Originate Error - code 40080201 (first chance)
EXCEPTION:  WinRTOriginateError
hr = 0x80070057
Message:  The parameter is incorrect.

Environment

Microsoft.WindowsPackageManager.InProcCom.1.10.340 from NuGet

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIt either shouldn't be doing this or needs an investigation.

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions