winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

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

Open leberechtreinhold opened this issue 1 year ago • 2 comments

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)

leberechtreinhold avatar Jun 21 '24 18:06 leberechtreinhold

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Jun 21 '24 18:06 github-actions[bot]

^ That crash happens with the package itself being null, here's the FindProvisionedPackages call.

leberechtreinhold avatar Jun 21 '24 19:06 leberechtreinhold