Improve process AppId column (now shows the real AppUserModelId for all processes)
#include <phapp.h>
#include <proctree.h>
+#include <appresolver.h>
#include <cpysave.h>
#include <emenu.h>
#include <mapimg.h>
@@ -1125,12 +1126,30 @@ static VOID PhpUpdateProcessNodeAppId(
if (!(ProcessNode->ValidMask & PHPN_APPID))
{
ULONG windowFlags;
- PPH_STRING windowTitle;
+ PPH_STRING applicationUserModelId;
PhClearReference(&ProcessNode->AppIdText);
+ if (PhAppResolverGetAppIdForProcess(ProcessNode->ProcessItem->ProcessId, &applicationUserModelId))
+ {
+ ProcessNode->AppIdText = applicationUserModelId;
+ }
+ else
+ {
if (ProcessNode->ProcessItem->QueryHandle)
{
+ if (NT_SUCCESS(PhGetProcessWindowTitle(
+ ProcessNode->ProcessItem->QueryHandle,
+ &windowFlags,
+ &applicationUserModelId
+ )))
+ {
+ if (windowFlags & STARTF_TITLEISAPPID)
+ ProcessNode->AppIdText = applicationUserModelId;
+ else
+ PhDereferenceObject(applicationUserModelId);
+ }
+
//if (WindowsVersion >= WINDOWS_8 && ProcessNode->ProcessItem->IsImmersive)
//{
// HANDLE tokenHandle;
@@ -1178,18 +1197,6 @@ static VOID PhpUpdateProcessNodeAppId(
// NtClose(tokenHandle);
// }
//}
- //else
-
- if (NT_SUCCESS(PhGetProcessWindowTitle(
- ProcessNode->ProcessItem->QueryHandle,
- &windowFlags,
- &windowTitle
- )))
- {
- if (windowFlags & STARTF_TITLEISAPPID)
- ProcessNode->AppIdText = windowTitle;
- else
- PhDereferenceObject(windowTitle);
}
}
