Fix GetTokenAppContainerFolderPath for desktop bridge packages
@@ -2526,6 +2526,7 @@ VOID PhpRemoveAttributeNode(
PhpDestroyAttributeNode(Node);
}
+_Success_(return)
BOOLEAN PhpGetSelectedAttributeTreeNodes(
_Inout_ PATTRIBUTE_TREE_CONTEXT Context,
_Out_ PATTRIBUTE_NODE **Nodes,
@@ -3453,11 +3454,22 @@ PPH_STRING PhpGetTokenRegistryPath(
PPH_STRING PhpGetTokenAppContainerFolderPath(
_In_ HANDLE TokenHandle,
- _In_ PSID TokenAppContainerSid
+ _In_opt_ PSID TokenAppContainerSid
)
+{
+ if (PhIsTokenFullTrustAppPackage(TokenHandle))
+ {
+ return PhGetKnownFolderPathEx(
+ &FOLDERID_LocalAppData,
+ PH_KF_FLAG_FORCE_APP_DATA_REDIRECTION,
+ TokenHandle,
+ NULL
+ );
+ }
+ else if (TokenAppContainerSid)
{
PPH_STRING appContainerFolderPath = NULL;
- PPH_STRING appContainerSid = NULL;
+ PPH_STRING appContainerSid;
PWSTR folderPath = NULL;
appContainerSid = PhSidToStringSid(TokenAppContainerSid);
@@ -3519,6 +3531,11 @@ PPH_STRING PhpGetTokenAppContainerFolderPath(
return appContainerFolderPath;
}
+ else
+ {
+ return NULL;
+ }
+}
PPH_STRING PhpGetTokenAppContainerRegistryPath(
_In_ HANDLE TokenHandle
@@ -3772,14 +3789,14 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
PPH_STRING appContainerRegistryPath = NULL;
if (NT_SUCCESS(PhQueryTokenVariableSize(tokenHandle, TokenAppContainerSid, &appContainerInfo)))
- {
- if (appContainerInfo->TokenAppContainer)
{
appContainerFolderPath = PhpGetTokenAppContainerFolderPath(tokenHandle, appContainerInfo->TokenAppContainer);
- }
-
PhFree(appContainerInfo);
}
+ else
+ {
+ appContainerFolderPath = PhpGetTokenAppContainerFolderPath(tokenHandle, NULL);
+ }
if (appContainerFolderPath)
{
