Skip to content

Commit d17844f

Browse files
committed
Fix missing appcontainer names for some service processes
1 parent 4bdcb52 commit d17844f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

phlib/appresolver.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,32 @@ PPH_STRING PhGetAppContainerName(
449449
appContainerName = PhCreateString(packageMonikerName);
450450
AppContainerFreeMemory_I(packageMonikerName);
451451
}
452+
else // Check the local system account appcontainer mappings. (dmex)
453+
{
454+
static PH_STRINGREF appcontainerMappings = PH_STRINGREF_INIT(L"Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppContainer\\Mappings\\");
455+
static PH_STRINGREF appcontainerDefaultMappings = PH_STRINGREF_INIT(L".DEFAULT\\");
456+
HANDLE keyHandle;
457+
PPH_STRING sidString;
458+
PPH_STRING keyPath;
459+
460+
sidString = PhSidToStringSid(AppContainerSid);
461+
keyPath = PhConcatStringRef3(&appcontainerDefaultMappings, &appcontainerMappings, &sidString->sr);
462+
463+
if (NT_SUCCESS(PhOpenKey(
464+
&keyHandle,
465+
KEY_READ,
466+
PH_KEY_USERS,
467+
&keyPath->sr,
468+
0
469+
)))
470+
{
471+
PhMoveReference(&appContainerName, PhQueryRegistryString(keyHandle, L"Moniker"));
472+
NtClose(keyHandle);
473+
}
474+
475+
PhDereferenceObject(keyPath);
476+
PhDereferenceObject(sidString);
477+
}
452478

453479
return appContainerName;
454480
}
@@ -481,6 +507,7 @@ PPH_STRING PhGetAppContainerPackageName(
481507
)
482508
{
483509
static PH_STRINGREF appcontainerMappings = PH_STRINGREF_INIT(L"Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppContainer\\Mappings\\");
510+
static PH_STRINGREF appcontainerDefaultMappings = PH_STRINGREF_INIT(L".DEFAULT\\");
484511
HANDLE keyHandle;
485512
PPH_STRING sidString;
486513
PPH_STRING keyPath;
@@ -509,6 +536,27 @@ PPH_STRING PhGetAppContainerPackageName(
509536
}
510537

511538
PhDereferenceObject(keyPath);
539+
540+
// Check the local system account appcontainer mappings. (dmex)
541+
if (PhIsNullOrEmptyString(packageName))
542+
{
543+
keyPath = PhConcatStringRef3(&appcontainerDefaultMappings, &appcontainerMappings, &sidString->sr);
544+
545+
if (NT_SUCCESS(PhOpenKey(
546+
&keyHandle,
547+
KEY_READ,
548+
PH_KEY_USERS,
549+
&keyPath->sr,
550+
0
551+
)))
552+
{
553+
PhMoveReference(&packageName, PhQueryRegistryString(keyHandle, L"Moniker"));
554+
NtClose(keyHandle);
555+
}
556+
557+
PhDereferenceObject(keyPath);
558+
}
559+
512560
PhDereferenceObject(sidString);
513561

514562
return packageName;

0 commit comments

Comments
 (0)