microsoft / microsoft/winget-cli

Access denied (0xc0000005) when running under Windows 10 version 17763

Open
#4,574 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

When running winget --list with scope machine on a Windows 10x86 build 17763, it crashes.

The reason is because PopulateIndexFromMSIX (https://github.com/microsoft/winget-cli/blob/6c54251308f91125f8fc8044f70fac69459295fe/src/AppInstallerRepositoryCore/Microsoft/PredefinedInstalledSourceFactory.cpp#L61) calls FindProvisionedPackages. This however seems to return a null value which is not catch by the catch hresult and is therefore a nullptr.

Looking at documentation, it does seem the minimum build would be 19041, not 17763, as stated in docs.

Windows 10, version 2004 (introduced in 10.0.19041.0)

https://learn.microsoft.com/en-us/uwp/api/windows.management.deployment.packagemanager.findprovisionedpackages?view=winrt-22621

MGdF9HpWoF

void PopulateIndexFromMSIX(SQLiteIndex& index, Manifest::ScopeEnum scope, SQLiteIndex* cacheData = nullptr)
{  
    //....
    AICLI_LOG(Repo, Verbose, << "Examining MSIX entries for " << ScopeToString(scope));

    IIterable<Package> packages;
    PackageManager packageManager;
    if (scope == Manifest::ScopeEnum::Machine)
    {
        packages = packageManager.FindProvisionedPackages();
    }

// --------------
template <typename D> auto consume_Windows_Management_Deployment_IPackageManager9<D>::FindProvisionedPackages() const
{
    void* packageCollection{};
    check_hresult(WINRT_IMPL_SHIM(winrt::Windows::Management::Deployment::IPackageManager9)->FindProvisionedPackages(&packageCollection));
    return winrt::Windows::Foundation::Collections::IVector<winrt::Windows::ApplicationModel::Package>{ packageCollection, take_ownership_from_abi };
}

// -------------- 
int32_t __stdcall FindProvisionedPackages(void** packageCollection) noexcept final try
{
    clear_abi(packageCollection);
    typename D::abi_guard guard(this->shim());
    *packageCollection = detach_from<winrt::Windows::Foundation::Collections::IVector<winrt::Windows::ApplicationModel::Package>>(this->shim().FindProvisionedPackages());
    return 0;
}
catch (...) { return to_hresult(); }
Steps to reproduce

Run winget --list with scope machine

Expected behavior

Not crash, return the base products. Since that specific os didnt have MSStore, it should be empty.

Actual behavior

Crash

Environment
Compiled release-v1.7.11261


Machine:

![UEMi2ND62J](https://github.com/microsoft/winget-cli/assets/24320606/25a5fd83-cc93-42bf-8557-0d01a4d07b17)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at PopulateIndexFromMSIX in src/AppInstallerRepositoryCore/Microsoft/PredefinedInstalledSourceFactory.cpp and run winget --list with machine scope on Windows 10 x86 build 17763. Examine the FindProvisionedPackages path and verify the command no longer crashes; on an OS without Microsoft Store packages, it should return the base products or an empty result.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.