summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-06-19 20:04:26 +0100
committersr55 <[email protected]>2020-06-19 20:04:26 +0100
commit0dc75f3ec8a6724a5c0315003948d1957dffe0f2 (patch)
tree3b4693f5441ae51ed6b6a444f0328e233caa72fc /win/CS/HandBrakeWPF
parentd8d6db8a08e6e3086bf6ba1c2a5894df940965bf (diff)
WinGui: Prevent Process isolation feature from being enabled on Windows 7 or Windows 8. We are only going to support this on 10 or later. Fixes #2940
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/Instance/RemoteInstance.cs154
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.Designer.cs9
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.resx3
-rw-r--r--win/CS/HandBrakeWPF/Services/UserSettingService.cs7
-rw-r--r--win/CS/HandBrakeWPF/Views/OptionsView.xaml8
5 files changed, 110 insertions, 71 deletions
diff --git a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
index ce9df2fc9..01a91c948 100644
--- a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
+++ b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
@@ -76,29 +76,6 @@ namespace HandBrakeWPF.Instance
thread1.Start();
}
- private void RunEncodeInitProcess(JsonEncodeObject jobToStart)
- {
- InitCommand initCommand = new InitCommand
- {
- EnableDiskLogging = false,
- AllowDisconnectedWorker = false,
- DisableLibDvdNav = !this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
- EnableHardwareAcceleration = true,
- LogDirectory = DirectoryUtilities.GetLogDirectory(),
- LogVerbosity = this.userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity)
- };
-
- initCommand.LogFile = Path.Combine(initCommand.LogDirectory, string.Format("activity_log.worker.{0}.txt", GeneralUtilities.ProcessId));
-
- JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
-
- string job = JsonConvert.SerializeObject(new EncodeCommand { InitialiseCommand = initCommand, EncodeJob = jobToStart }, Formatting.None, settings);
-
- var task = Task.Run(async () => await this.MakeHttpJsonPostRequest("StartEncode", job));
- task.Wait();
- this.MonitorEncodeProgress();
- }
-
public async void StopEncode()
{
await this.MakeHttpGetRequest("StopEncode");
@@ -122,54 +99,64 @@ namespace HandBrakeWPF.Instance
public void Initialize(int verbosityLvl, bool noHardwareMode)
{
- if (this.workerProcess == null || this.workerProcess.HasExited)
+ try
{
- var plainTextBytes = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());
- this.base64Token = Convert.ToBase64String(plainTextBytes);
- this.port = this.portService.GetOpenPort(userSettingService.GetUserSetting<int>(UserSettingConstants.ProcessIsolationPort));
- this.serverUrl = string.Format("http://127.0.0.1:{0}/", this.port);
-
- workerProcess = new Process
+ if (this.workerProcess == null || this.workerProcess.HasExited)
{
- StartInfo =
- {
- FileName = "HandBrake.Worker.exe",
- Arguments = string.Format(" --port={0} --token={1}", port, this.base64Token),
- UseShellExecute = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = true
- }
- };
- workerProcess.Exited += this.WorkerProcess_Exited;
- workerProcess.OutputDataReceived += this.WorkerProcess_OutputDataReceived;
- workerProcess.ErrorDataReceived += this.WorkerProcess_OutputDataReceived;
-
- workerProcess.Start();
- workerProcess.BeginOutputReadLine();
- workerProcess.BeginErrorReadLine();
+ var plainTextBytes = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());
+ this.base64Token = Convert.ToBase64String(plainTextBytes);
+ this.port = this.portService.GetOpenPort(userSettingService.GetUserSetting<int>(UserSettingConstants.ProcessIsolationPort));
+ this.serverUrl = string.Format("http://127.0.0.1:{0}/", this.port);
- // Set Process Priority
- switch ((ProcessPriority)this.userSettingService.GetUserSetting<int>(UserSettingConstants.ProcessPriorityInt))
- {
- case ProcessPriority.High:
- workerProcess.PriorityClass = ProcessPriorityClass.High;
- break;
- case ProcessPriority.AboveNormal:
- workerProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
- break;
- case ProcessPriority.Normal:
- workerProcess.PriorityClass = ProcessPriorityClass.Normal;
- break;
- case ProcessPriority.Low:
- workerProcess.PriorityClass = ProcessPriorityClass.Idle;
- break;
- default:
- workerProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
- break;
+ workerProcess = new Process
+ {
+ StartInfo =
+ {
+ FileName = "HandBrake.Worker.exe",
+ Arguments =
+ string.Format(" --port={0} --token={1}", port, this.base64Token),
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ CreateNoWindow = true
+ }
+ };
+ workerProcess.Exited += this.WorkerProcess_Exited;
+ workerProcess.OutputDataReceived += this.WorkerProcess_OutputDataReceived;
+ workerProcess.ErrorDataReceived += this.WorkerProcess_OutputDataReceived;
+
+ workerProcess.Start();
+ workerProcess.BeginOutputReadLine();
+ workerProcess.BeginErrorReadLine();
+
+ // Set Process Priority
+ switch ((ProcessPriority)this.userSettingService.GetUserSetting<int>(
+ UserSettingConstants.ProcessPriorityInt))
+ {
+ case ProcessPriority.High:
+ workerProcess.PriorityClass = ProcessPriorityClass.High;
+ break;
+ case ProcessPriority.AboveNormal:
+ workerProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
+ break;
+ case ProcessPriority.Normal:
+ workerProcess.PriorityClass = ProcessPriorityClass.Normal;
+ break;
+ case ProcessPriority.Low:
+ workerProcess.PriorityClass = ProcessPriorityClass.Idle;
+ break;
+ default:
+ workerProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
+ break;
+ }
+
+ this.logService.LogMessage(string.Format("Remote Process started with Process ID: {0} and port: {1}", this.workerProcess.Id, port));
}
-
- this.logService.LogMessage(string.Format("Worker Process started with Process ID: {0} and port: {1}", this.workerProcess.Id, port));
+ }
+ catch (Exception e)
+ {
+ this.logService.LogMessage("Unable to start worker process.");
+ this.logService.LogMessage(e.ToString());
}
}
@@ -204,7 +191,15 @@ namespace HandBrakeWPF.Instance
private void StopPollingProgress()
{
- this.PollEncodeProgress(); // Get the last progress state.
+ try
+ {
+ this.PollEncodeProgress(); // Get the last progress state.
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc);
+ }
+
this.encodePollTimer?.Stop();
}
@@ -290,5 +285,28 @@ namespace HandBrakeWPF.Instance
this.portService.FreePort(this.port);
}
}
+
+ private void RunEncodeInitProcess(JsonEncodeObject jobToStart)
+ {
+ InitCommand initCommand = new InitCommand
+ {
+ EnableDiskLogging = false,
+ AllowDisconnectedWorker = false,
+ DisableLibDvdNav = !this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
+ EnableHardwareAcceleration = true,
+ LogDirectory = DirectoryUtilities.GetLogDirectory(),
+ LogVerbosity = this.userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity)
+ };
+
+ initCommand.LogFile = Path.Combine(initCommand.LogDirectory, string.Format("activity_log.worker.{0}.txt", GeneralUtilities.ProcessId));
+
+ JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
+
+ string job = JsonConvert.SerializeObject(new EncodeCommand { InitialiseCommand = initCommand, EncodeJob = jobToStart }, Formatting.None, settings);
+
+ var task = Task.Run(async () => await this.MakeHttpJsonPostRequest("StartEncode", job));
+ task.Wait();
+ this.MonitorEncodeProgress();
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
index 249f7d5f5..f56f22cd0 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
@@ -3664,6 +3664,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to ( Windows 10 Only! ).
+ /// </summary>
+ public static string OptionsView_Win10Only {
+ get {
+ return ResourceManager.GetString("OptionsView_Win10Only", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Default network port for worker:.
/// </summary>
public static string OptionsView_WorkerDefaultPort {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx
index eaf8f446b..e9561f778 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.resx
+++ b/win/CS/HandBrakeWPF/Properties/Resources.resx
@@ -2268,4 +2268,7 @@ Please choose a different preset.</value>
<data name="PictureSettingsView_RotateAndCrop" xml:space="preserve">
<value>Rotate and Crop</value>
</data>
+ <data name="OptionsView_Win10Only" xml:space="preserve">
+ <value>( Windows 10 Only! )</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/UserSettingService.cs b/win/CS/HandBrakeWPF/Services/UserSettingService.cs
index 2e29811ba..a28ed12cb 100644
--- a/win/CS/HandBrakeWPF/Services/UserSettingService.cs
+++ b/win/CS/HandBrakeWPF/Services/UserSettingService.cs
@@ -28,6 +28,7 @@ namespace HandBrakeWPF.Services
using GeneralApplicationException = Exceptions.GeneralApplicationException;
using SettingChangedEventArgs = EventArgs.SettingChangedEventArgs;
+ using SystemInfo = HandBrakeWPF.Utilities.SystemInfo;
/// <summary>
/// The User Setting Service
@@ -219,6 +220,10 @@ namespace HandBrakeWPF.Services
// Legacy Settings forced Reset.
this.userSettings[UserSettingConstants.ScalingMode] = VideoScaler.Lanczos;
+ if (!SystemInfo.IsWindows10())
+ {
+ this.userSettings[UserSettingConstants.ProcessIsolationEnabled] = false;
+ }
}
catch (Exception exc)
{
@@ -317,7 +322,7 @@ namespace HandBrakeWPF.Services
defaults.Add(UserSettingConstants.DefaultPlayer, false);
// Experimental
- defaults.Add(UserSettingConstants.ProcessIsolationEnabled, true);
+ defaults.Add(UserSettingConstants.ProcessIsolationEnabled, SystemInfo.IsWindows10() ? true : false);
defaults.Add(UserSettingConstants.ProcessIsolationPort, 8037);
defaults.Add(UserSettingConstants.SimultaneousEncodes, 1);
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
index 1135c6311..d5ad61f31 100644
--- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
@@ -420,9 +420,13 @@
</StackPanel>
</StackPanel>
- <StackPanel Orientation="Vertical" Visibility="{Binding IsProcessIsolationAllowed, Converter={StaticResource boolToVisConverter}}">
+ <StackPanel Orientation="Vertical" Visibility="{Binding IsProcessIsolationAllowed, Converter={StaticResource boolToVisConverter}}" IsEnabled="{Binding IsWindows10}">
- <TextBlock Text="{x:Static Properties:Resources.OptionsView_ProcessIsolation}" FontSize="14" Margin="0,10,0,10"/>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{x:Static Properties:Resources.OptionsView_ProcessIsolation}" FontSize="14" Margin="0,10,0,10"/>
+ <TextBlock Text="{x:Static Properties:Resources.OptionsView_Win10Only}" Margin="15,10,0,10" Visibility="{Binding IsWindows10, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
+ </StackPanel>
+
<TextBlock Text="{x:Static Properties:Resources.OptionsView_ProcessIsolation_Warning1}" Margin="10,0,0,0" TextWrapping="Wrap" FontStyle="Italic" />
<TextBlock Text="{x:Static Properties:Resources.OptionsView_ProcessIsolation_Warning2}" Margin="10,0,0,0" TextWrapping="Wrap" FontStyle="Italic" />