Skip to content

Commit 0c22def

Browse files
authored
Merge pull request #110 from david-risney/user/peiche/63-cmdline
#63: Include WebView2 browser process command line in host apps tab & report
2 parents 0870951 + 0126720 commit 0c22def

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

wv2util/HostAppList.cs

+34-15
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class HostAppEntry : IEquatable<HostAppEntry>, IComparable<HostAppEntry>
4444
public HostAppEntry(
4545
string kind, // 'host', or the Edge browser kind 'browser', 'renderer', and so on.
4646
string exePath, // Path to the host app executable
47+
string commandLine, // Command line of the process
4748
int pid, // PID of the host app process
4849
int parentPid, // PID of the parent process
4950
string sdkPath, // Path to a WebView2 SDK DLL
@@ -54,6 +55,7 @@ public HostAppEntry(
5455
{
5556
Kind = kind;
5657
ExecutablePath = exePath == null ? "Unknown" : exePath;
58+
CommandLine = commandLine;
5759
PID = pid;
5860
ParentPID = parentPid;
5961
SdkInfo = new SdkFileInfo(sdkPath, interestingLoadedDllPaths);
@@ -87,6 +89,7 @@ public string DisplayLabel
8789
public string ExecutablePath { get; private set; }
8890
public string ExecutableName => Path.GetFileName(ExecutablePath);
8991
public string ExecutablePathDirectory => Path.GetDirectoryName(ExecutablePath);
92+
public string CommandLine { get; private set; }
9093
public int PID { get; private set; } = 0;
9194
public int ParentPID { get; private set; } = 0;
9295
public string PIDAndStatus =>
@@ -395,6 +398,7 @@ private static IEnumerable<HostAppEntry> AddRuntimeProcessInfoToHostAppEntriesBy
395398
pidToRuntimeHostAppEntry[pid] = currentProcessEntry = new HostAppEntry(
396399
userDataPathAndProcessType.Item2,
397400
msedgewebview2Process.MainModule.FileName,
401+
userDataPathAndProcessType.Item3,
398402
msedgewebview2Process.Id,
399403
parentProcess.Id,
400404
null,
@@ -420,6 +424,7 @@ private static IEnumerable<HostAppEntry> AddRuntimeProcessInfoToHostAppEntriesBy
420424
HostAppEntry newHostAppEntry = new HostAppEntry(
421425
"host",
422426
hostAppEntry.ExecutablePath,
427+
"",
423428
hostAppEntry.PID,
424429
0,
425430
hostAppEntry.SdkInfo.Path,
@@ -458,19 +463,27 @@ private static IEnumerable<HostAppEntry> GetHostAppEntriesFromMachineByProcessMo
458463
List<HostAppEntry> results = new List<HostAppEntry>();
459464
foreach (Process process in Process.GetProcesses())
460465
{
461-
var interestingDllPaths = ProcessUtil.GetInterestingDllsUsedByPid(process.Id);
462-
if (interestingDllPaths.Item1 != null || interestingDllPaths.Item2 != null)
466+
try
463467
{
464-
results.Add(new HostAppEntry(
465-
"host",
466-
process.MainModule.FileName,
467-
process.Id,
468-
0,
469-
interestingDllPaths.Item2,
470-
ClientDllPathToRuntimePath(interestingDllPaths.Item1),
471-
null,
472-
interestingDllPaths.Item3,
473-
0));
468+
var interestingDllPaths = ProcessUtil.GetInterestingDllsUsedByPid(process.Id);
469+
if (interestingDllPaths.Item1 != null || interestingDllPaths.Item2 != null)
470+
{
471+
results.Add(new HostAppEntry(
472+
"host",
473+
process.MainModule.FileName,
474+
"",
475+
process.Id,
476+
0,
477+
interestingDllPaths.Item2,
478+
ClientDllPathToRuntimePath(interestingDllPaths.Item1),
479+
null,
480+
interestingDllPaths.Item3,
481+
0));
482+
}
483+
}
484+
catch (Exception e)
485+
{
486+
Debug.WriteLine("Unable to get app entry (" + process.Id + ") from machine by process module: " + e.Message);
474487
}
475488
}
476489
return results;
@@ -525,6 +538,7 @@ public static IEnumerable<HostAppEntry> GetHostAppEntriesFromMachineByPipeEnumer
525538
hostAppEntries.Add(new HostAppEntry(
526539
"host",
527540
process.MainModule.FileName,
541+
"",
528542
process.Id,
529543
0,
530544
sdkDllPath,
@@ -605,6 +619,7 @@ private static IEnumerable<HostAppEntry> AddRuntimeProcessInfoToHostAppEntriesBy
605619
var runtimeEntry = new HostAppEntry(
606620
"host",
607621
hostAppEntry.ExecutablePath,
622+
"",
608623
hostAppEntry.PID,
609624
0,
610625
hostAppEntry.SdkInfo.Path,
@@ -616,6 +631,7 @@ private static IEnumerable<HostAppEntry> AddRuntimeProcessInfoToHostAppEntriesBy
616631
runtimeEntry.Children.Add(new HostAppEntry(
617632
userDataPathAndProcessType.Item2,
618633
runtimeProcess.MainModule.FileName,
634+
userDataPathAndProcessType.Item3,
619635
runtimeProcess.Id,
620636
runtimeEntry.PID,
621637
null,
@@ -706,6 +722,7 @@ private static IEnumerable<HostAppEntry> AddRuntimeProcessInfoToHostAppEntriesBy
706722
var runtimeEntry = new HostAppEntry(
707723
"host",
708724
hostAppEntry.ExecutablePath,
725+
"",
709726
hostAppEntry.PID,
710727
0,
711728
hostAppEntry.SdkInfo.Path,
@@ -716,6 +733,7 @@ private static IEnumerable<HostAppEntry> AddRuntimeProcessInfoToHostAppEntriesBy
716733
runtimeEntry.Children.Add(new HostAppEntry(
717734
userDataPathAndProcessType.Item2,
718735
runtimeProcess.MainModule.FileName,
736+
userDataPathAndProcessType.Item3,
719737
runtimeProcess.Id,
720738
runtimeEntry.PID,
721739
null,
@@ -775,9 +793,10 @@ private static string ClientDllPathToRuntimePath(string clientDllPath)
775793
return null;
776794
}
777795

778-
public static Tuple<string, string> GetUserDataPathAndProcessTypeFromProcessViaCommandLine(Process process)
796+
public static Tuple<string, string, string> GetUserDataPathAndProcessTypeFromProcessViaCommandLine(Process process)
779797
{
780-
CommandLineUtil.CommandLine commandLine = new CommandLineUtil.CommandLine(process.GetCommandLine());
798+
string commandLineAsString = process.GetCommandLine();
799+
CommandLineUtil.CommandLine commandLine = new CommandLineUtil.CommandLine(commandLineAsString);
781800
string processType = commandLine.GetKeyValue("--type");
782801
string userDataPath = commandLine.GetKeyValue("--user-data-dir");
783802

@@ -795,7 +814,7 @@ public static Tuple<string, string> GetUserDataPathAndProcessTypeFromProcessViaC
795814
processType = "browser";
796815
}
797816

798-
return new Tuple<string, string>(userDataPath, processType);
817+
return new Tuple<string, string, string>(userDataPath, processType, commandLineAsString);
799818
}
800819
}
801820
}

wv2util/Pages/HostAppsPage.xaml

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100

101101
<Label Grid.Row="3" Grid.Column="0" Content="IL" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="{Binding ElementName=HostAppTreeView,Path=SelectedItem,Converter={StaticResource NullToBooleanConverter}}"/>
102102
<TextBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" IsReadOnly="true" ToolTip="The integrity level of the host app process." Text="{Binding ElementName=HostAppTreeView,Path=SelectedValue.IntegrityLevel, Mode=OneWay}" MaxLines="1" VerticalContentAlignment="Center" IsEnabled="{Binding ElementName=HostAppTreeView,Path=SelectedItem,Converter={StaticResource NullToBooleanConverter}}"/>
103+
104+
<Label Grid.Row="4" Grid.Column="0" Content="Command Line" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="{Binding ElementName=HostAppTreeView,Path=SelectedItem,Converter={StaticResource NullToBooleanConverter}}"/>
105+
<TextBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" IsReadOnly="true" ToolTip="The command line of the host app process." Text="{Binding ElementName=HostAppTreeView,Path=SelectedValue.CommandLine, Mode=OneWay}" MaxLines="1" VerticalContentAlignment="Center" IsEnabled="{Binding ElementName=HostAppTreeView,Path=SelectedItem,Converter={StaticResource NullToBooleanConverter}}"/>
103106
</Grid>
104107
</GroupBox>
105108

wv2utilTests/ReportCreatorTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ReportCreatorTests
1818
ReportCreator CreateReportCreatorForTest()
1919
{
2020
return new ReportCreator(
21-
new HostAppEntry("host", "example.exe", 1, 0, "C:\\windows\\system32\\actxprxy.dll", "C:\\windows\\system32", "C:\\windows\\system32", new string[] { }, 2),
21+
new HostAppEntry("host", "example.exe", "C:\\msedgewebview2.exe --embedded-browser-webview=1", 1, 0, "C:\\windows\\system32\\actxprxy.dll", "C:\\windows\\system32", "C:\\windows\\system32", new string[] { }, 2),
2222
new List<AppOverrideEntry>(),
2323
new List<RuntimeEntry>());
2424
}

0 commit comments

Comments
 (0)