diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/Window.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/Window.cs index aebf9a77fd..1dc43600c2 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/Window.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/Window.cs @@ -324,7 +324,7 @@ internal sealed class Window // Correct the process data if the window belongs to a uwp app hosted by 'ApplicationFrameHost.exe' // (This only works if the window isn't minimized. For minimized windows the required child window isn't assigned.) - if (string.Equals(_handlesToProcessCache[hWindow].Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase)) + if (_handlesToProcessCache[hWindow].IsUwpAppFrameHost) { new Task(() => { diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/WindowProcess.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/WindowProcess.cs index af3730cada..2dfbbcf429 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/WindowProcess.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/WindowProcess.cs @@ -23,7 +23,7 @@ internal sealed class WindowProcess /// /// An indicator if the window belongs to an 'Universal Windows Platform (UWP)' process /// - private readonly bool _isUwpAppFrameHost; + private bool _isUwpAppFrameHost; /// /// Gets the id of the process @@ -126,6 +126,14 @@ internal sealed class WindowProcess get; private set; } + /// + /// Gets the type of the process (UWP app, packaged Win32 app, unpackaged Win32 app, ...). + /// + internal ProcessPackagingInfo ProcessType + { + get; private set; + } + /// /// Initializes a new instance of the class. /// @@ -134,13 +142,10 @@ internal sealed class WindowProcess /// New process name. internal WindowProcess(uint pid, uint tid, string name) { + ProcessType = ProcessPackagingInfo.Empty; UpdateProcessInfo(pid, tid, name); - ProcessType = ProcessPackagingInspector.Inspect((int)pid); - _isUwpAppFrameHost = string.Equals(Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase); } - public ProcessPackagingInfo ProcessType { get; private set; } - /// /// Updates the process information of the instance. /// @@ -156,6 +161,10 @@ internal sealed class WindowProcess // Process can be elevated only if process id is not 0 (Dummy value on error) IsFullAccessDenied = (pid != 0) ? TestProcessAccessUsingAllAccessFlag(pid) : false; + + // Update process type + ProcessType = ProcessPackagingInspector.Inspect((int)pid); + _isUwpAppFrameHost = string.Equals(Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase); } /// diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Helpers/ProcessPackagingInfo.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Helpers/ProcessPackagingInfo.cs index f1d3c5e09d..1a1321a9d6 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Helpers/ProcessPackagingInfo.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Helpers/ProcessPackagingInfo.cs @@ -11,4 +11,13 @@ internal sealed record ProcessPackagingInfo( bool IsAppContainer, string? PackageFullName, int? LastError -); +) +{ + public static ProcessPackagingInfo Empty { get; } = new( + Pid: 0, + Kind: ProcessPackagingKind.Unknown, + HasPackageIdentity: false, + IsAppContainer: false, + PackageFullName: null, + LastError: null); +}