microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.78k stars 319 forks source link

DeriveAppContainerSidFromAppContainerName doesn't work if container name same as caller package family name #787

Open soumyamahunt opened 3 years ago

soumyamahunt commented 3 years ago

Describe the bug

When DeriveAppContainerSidFromAppContainerName is used get sid for a package family name, if package family name is same as caller package family name the function call succeeds (no error code returned) but sid isn't retrived.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create sample cppwinrt console application.
  2. Create new packaging project and add the above console application project as reference.
  3. Add following snippet to the main function with required headers and namespaces, and deploy the package.
    PSID pSid = NULL;
    check_hresult(DeriveAppContainerSidFromAppContainerName(Package::Current().Id().FamilyName().c_str(), &pSid ));
    if (pSid == NULL)
    {
    printf("Failed to retrieve sid");
    }
  4. When running the console app see output on console.

Expected behavior

Should retrieve sid even if package family name are same.

Version Info

Not applicable.

NuGet package version: Not applicable

Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)

Additional context

This is necessary for sharing named objects between uwp and win32 process packaged together.

soumyamahunt commented 3 years ago

Not sure if this issue is scope of reunion but it sill is an issue with windows api.

andrewleader commented 3 years ago

Hi @soumyamahunt, thanks for reporting this.

I think there might be a different way of using this API, but looking at the docs you referenced, they don't explain much at all, seems like we definitely have to improve our docs.

The main dev that knows this area the best is currently out-of-office till 5/17. Another dev mentioned that this API you're using will drive the SID of a child AppContainer if it's invoked from within an AppContainer - you can NOT use this API to pass in a package family name and get the SID of the (non-child) AppContainer within which you're currently running.

We'll hopefully have a better answer the week of 5/17 for you, I apologize for the delay. I'll work with the team to get the docs updated too!

zrajnai-shapr3d commented 2 years ago

Any updates on this?!