diff --git a/.gitignore b/.gitignore
index 57914e2..133759c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,14 @@ bld/
[Bb]in/
[Oo]bj/
+/
+
+# Visual Studio 2015 cache/options directory
+
+.vs/
+
+
+
# Roslyn cache directories
*.ide/
diff --git a/InstallShield 2012 Spring Projects/SafeExamBrowser_2016.ism b/InstallShield 2012 Spring Projects/SafeExamBrowser_2016.ism
index b9efe9f..ab958c3 100644
Binary files a/InstallShield 2012 Spring Projects/SafeExamBrowser_2016.ism and b/InstallShield 2012 Spring Projects/SafeExamBrowser_2016.ism differ
diff --git a/SEBWindowsServiceContracts/Properties/AssemblyInfo.cs b/SEBWindowsServiceContracts/Properties/AssemblyInfo.cs
index 4746d3e..0c1b4d3 100644
--- a/SEBWindowsServiceContracts/Properties/AssemblyInfo.cs
+++ b/SEBWindowsServiceContracts/Properties/AssemblyInfo.cs
@@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SEBWindowsServiceContracts")]
-[assembly: AssemblyCopyright("Copyright © 2016 ETH Zurich")]
+[assembly: AssemblyCopyright("Copyright © 2010-2017 ETH Zurich, Educational Development and Technology (LET)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyInformationalVersion("1.0.0.0")]
+[assembly: AssemblyVersion("2.1.*")]
+[assembly: AssemblyInformationalVersion("2.1.7")]
diff --git a/SEBWindowsServiceContracts/RegistryServiceContract.cs b/SEBWindowsServiceContracts/RegistryServiceContract.cs
index 24e1ec7..320adb0 100644
--- a/SEBWindowsServiceContracts/RegistryServiceContract.cs
+++ b/SEBWindowsServiceContracts/RegistryServiceContract.cs
@@ -3,10 +3,10 @@
namespace SEBWindowsServiceContracts
{
- ///
- /// The contact for the WCF Service
- ///
- [ServiceContract]
+ ///
+ /// The contact for the WCF Service
+ ///
+ [ServiceContract]
public interface IRegistryServiceContract
{
[OperationContract]
@@ -28,6 +28,7 @@ public interface IRegistryServiceContract
/// Don't add a value without creating the corresponding subclass of RegistryEntry
public enum RegistryIdentifiers
{
+ DisableChromeNotifications,
DisableLockWorkstation,
DisableTaskMgr,
DisableChangePassword,
diff --git a/SebRegistryResetter/Properties/AssemblyInfo.cs b/SebRegistryResetter/Properties/AssemblyInfo.cs
index fe7f087..afc1985 100644
--- a/SebRegistryResetter/Properties/AssemblyInfo.cs
+++ b/SebRegistryResetter/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.*")]
-[assembly: AssemblyInformationalVersion("2.1.6")]
+[assembly: AssemblyInformationalVersion("2.1.7")]
diff --git a/SebWindowsClient/SebWindowsClient/ConfigurationUtils/SEBSettings.cs b/SebWindowsClient/SebWindowsClient/ConfigurationUtils/SEBSettings.cs
index 3289c89..2f89975 100644
--- a/SebWindowsClient/SebWindowsClient/ConfigurationUtils/SEBSettings.cs
+++ b/SebWindowsClient/SebWindowsClient/ConfigurationUtils/SEBSettings.cs
@@ -218,7 +218,8 @@ public class SEBSettings
public const String KeyOS = "os";
public const String KeyTitle = "title";
public const String KeyDescription = "description";
- public const String KeyExecutable = "executable";
+ public const String KeyExecutable = "executable";
+ public const String KeyOriginalName = "originalName";
public const String KeyPath = "path";
public const String KeyIdentifier = "identifier";
public const String KeyUser = "user";
@@ -418,6 +419,7 @@ public enum operatingSystems
public static ListObj prohibitedProcessList = new ListObj();
public static DictObj prohibitedProcessData = new DictObj();
public static DictObj prohibitedProcessDataDefault = new DictObj();
+ private static List prohibitedProcessesDefault;
public static int urlFilterRuleIndex;
public static ListObj urlFilterRuleList = new ListObj();
@@ -666,6 +668,7 @@ public static void CreateDefaultAndCurrentSettingsFromScratch()
SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyTitle , "SEB");
SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyDescription, "");
SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyExecutable, SEBClientInfo.XUL_RUNNER);
+ SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyOriginalName, SEBClientInfo.XUL_RUNNER);
SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyPath , "../xulrunner/");
SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyIdentifier , "XULRunner");
SEBSettings.permittedProcessDataXulRunner.Add(SEBSettings.KeyWindowHandlingProcess , "");
@@ -682,7 +685,8 @@ public static void CreateDefaultAndCurrentSettingsFromScratch()
SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyOS, IntWin);
SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyTitle , "");
SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyDescription, "");
- SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyExecutable , "");
+ SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyExecutable, "");
+ SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyOriginalName, "");
SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyPath , "");
SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyIdentifier , "");
SEBSettings.permittedProcessDataDefault.Add(SEBSettings.KeyWindowHandlingProcess , "");
@@ -694,12 +698,15 @@ public static void CreateDefaultAndCurrentSettingsFromScratch()
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyCurrentUser, true);
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyStrongKill , false);
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyOS , IntWin);
- SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyExecutable , "");
+ SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyExecutable, "");
+ SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyOriginalName, "");
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyDescription, "");
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyIdentifier , "");
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyWindowHandlingProcess , "");
SEBSettings.prohibitedProcessDataDefault.Add(SEBSettings.KeyUser , "");
+ SEBSettings.prohibitedProcessesDefault = new List { "Chrome", "Chromium", "Vivaldi", "Opera", "browser", "slimjet", "UCBrowser", "Firefox" };
+
// Default settings for group "Network - Filter"
SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableURLFilter , false);
SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableURLContentFilter, false);
@@ -1415,10 +1422,59 @@ public static void PermitXulRunnerProcess()
//SEBSettings.permittedProcessList.Insert (indexOfProcessXulRunnerExe, SEBSettings.permittedProcessDataXulRunner);
}
+ AddDefaultProhibitedProcesses();
return;
}
+ public static void AddDefaultProhibitedProcesses()
+ {
+ // Get the Prohibited Process list
+ SEBSettings.prohibitedProcessList = (ListObj)SEBSettings.settingsCurrent[SEBSettings.KeyProhibitedProcesses];
+
+ foreach (string defaultProhibitedProcessName in prohibitedProcessesDefault)
+ {
+ // Position of this default prohibited process in Prohibited Process list
+ int indexOfProcess = -1;
+
+ string prohibitedProcessFilenameWithoutExtension = Path.GetFileNameWithoutExtension(defaultProhibitedProcessName);
+
+ // Traverse Prohibited Processes of currently opened file
+ for (int listIndex = 0; listIndex < SEBSettings.prohibitedProcessList.Count; listIndex++)
+ {
+ DictObj prohibitedProcessData = (DictObj)SEBSettings.prohibitedProcessList[listIndex];
+
+ // Check if this prohibited process already is in Prohibited Process list in current settings
+ if (Path.GetFileNameWithoutExtension((string)prohibitedProcessData[SEBSettings.KeyOriginalName]).Equals(prohibitedProcessFilenameWithoutExtension, StringComparison.InvariantCultureIgnoreCase) ||
+ Path.GetFileNameWithoutExtension((string)prohibitedProcessData[SEBSettings.KeyExecutable]).Equals(prohibitedProcessFilenameWithoutExtension, StringComparison.InvariantCultureIgnoreCase))
+ indexOfProcess = listIndex;
+ } // next listIndex
+
+ // If this default prohibited process was not in Prohibited Process list, insert it at the beginning
+ if (indexOfProcess == -1)
+ {
+ SEBSettings.prohibitedProcessList.Insert(0, prohibitetProcessDictForProcess(defaultProhibitedProcessName));
+ }
+ }
+ }
+
+ private static DictObj prohibitetProcessDictForProcess(string processName)
+ {
+ DictObj prohibitedProcessDict = new DictObj();
+
+ prohibitedProcessDict.Add(SEBSettings.KeyActive, true);
+ prohibitedProcessDict.Add(SEBSettings.KeyCurrentUser, true);
+ prohibitedProcessDict.Add(SEBSettings.KeyStrongKill, false);
+ prohibitedProcessDict.Add(SEBSettings.KeyOS, IntWin);
+ prohibitedProcessDict.Add(SEBSettings.KeyExecutable, processName);
+ prohibitedProcessDict.Add(SEBSettings.KeyOriginalName, processName);
+ prohibitedProcessDict.Add(SEBSettings.KeyDescription, "");
+ prohibitedProcessDict.Add(SEBSettings.KeyIdentifier, "");
+ prohibitedProcessDict.Add(SEBSettings.KeyWindowHandlingProcess, "");
+ prohibitedProcessDict.Add(SEBSettings.KeyUser, "");
+
+ return prohibitedProcessDict;
+ }
// **************
// Print settings
diff --git a/SebWindowsClient/SebWindowsClient/ProcessUtils/ExecutableInfo.cs b/SebWindowsClient/SebWindowsClient/ProcessUtils/ExecutableInfo.cs
new file mode 100644
index 0000000..256e0ee
--- /dev/null
+++ b/SebWindowsClient/SebWindowsClient/ProcessUtils/ExecutableInfo.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace SebWindowsClient.ProcessUtils
+{
+ public class ExecutableInfo
+ {
+ public string Name { get; }
+ public string OriginalName { get; }
+
+ public ExecutableInfo(string name, string originalName = null)
+ {
+ Name = name ?? string.Empty;
+ OriginalName = originalName ?? string.Empty;
+ }
+
+ public bool HasName
+ {
+ get { return !String.IsNullOrEmpty(Name); }
+ }
+
+ public bool HasOriginalName
+ {
+ get { return !String.IsNullOrEmpty(OriginalName); }
+ }
+
+ public bool NamesAreEqual
+ {
+ get { return Name.Equals(OriginalName, StringComparison.InvariantCultureIgnoreCase); }
+ }
+ }
+}
diff --git a/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBNotAllowedProcessController.cs b/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBNotAllowedProcessController.cs
index 674eff6..61da4ef 100644
--- a/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBNotAllowedProcessController.cs
+++ b/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBNotAllowedProcessController.cs
@@ -53,187 +53,152 @@ public static string getLocalProcessOwner(int pid)
/// Closes process by process name.
///
///
- public static void CloseProcessByName(string nameToClosse)
+ public static void CloseProcess(Process processToClose)
{
- Process[] processes = System.Diagnostics.Process.GetProcesses();
- foreach (System.Diagnostics.Process processToClosse in processes)
+ try
{
- if (processToClosse.ProcessName == nameToClosse)
+ if (processToClose == null) // && !processToClose.HasExited)
+ {
+ return;
+ }
+ else
{
- try
+ Logger.AddInformation("Closing " + processToClose.ProcessName);
+ if (processToClose.ProcessName.Contains("xulrunner"))
+ {
+ Logger.AddInformation("Closing XulRunner over Socket");
+ SEBXULRunnerWebSocketServer.SendAllowCloseToXulRunner();
+ Thread.Sleep(500);
+ }
+
+ string name = "processHasExitedTrue";
+
+ // Try to close process nicely with CloseMainWindow
+ if (processToClose.HasExited)
+ {
+ return;
+ }
{
- // Display physical memory usage 5 times at intervals of 2 seconds.
- for (int i = 0; i < 5; i++)
+ Logger.AddInformation("Process " + processToClose.ProcessName + " hasnt closed yet, try again");
+ //If the process handles the mainWindow
+ if (processToClose.MainWindowHandle != IntPtr.Zero)
{
- if (!processToClosse.HasExited)
- {
- // Discard cached information about the process.
- processToClosse.Refresh();
- // Print working set to console.
- Console.WriteLine("Physical Memory Usage: "
- + processToClosse.WorkingSet64.ToString());
- // Wait 2 seconds.
- Thread.Sleep(2000);
- }
- else
+ name = processToClose.ProcessName;
+ // Close process by sending a close message to its main window.
+ Logger.AddError("Send CloseMainWindow to process " + name, null, null);
+ processToClose.CloseMainWindow();
+ // Wait max. 5 seconds till the process exits
+ for (int i = 0; i < 5; i++)
{
- break;
+ processToClose.Refresh();
+ // If process still hasn't exited, we wait another second
+ if (processToClose != null && !processToClose.HasExited)
+ {
+ Logger.AddError("Process " + name + " hasn't exited by closing its main window, wait up to one more second and check again.", null, null);
+ //Thread.Sleep(1000);
+ processToClose.WaitForExit(1000);
+ }
+ else
+ {
+ Logger.AddError("Process " + name + " has exited.", null, null);
+ break;
+ }
}
}
-
- // Close process by sending a close message to its main window.
- processToClosse.CloseMainWindow();
- // Free resources associated with process.
- processToClosse.Close();
-
- }
- catch (Exception e)
- {
- Console.WriteLine("The following exception was raised: ");
- Console.WriteLine(e.Message);
}
- }
- }
- }
+ processToClose.Refresh();
- ///
- /// Closes process by process name.
- ///
- ///
- public static void CloseProcess(Process processToClose)
- {
- try
+ // Check if process has exited now and otherwise kill it
+ if (!processToClose.HasExited)
{
- if (processToClose != null) // && !processToClose.HasExited)
+ // If process still hasn't exited, we kill it
+ Logger.AddError("Send Kill to process " + name, null, null);
+ processToClose.Kill();
+ // Wait max. 10 seconds till the process exits
+ for (int i = 0; i < 10; i++)
{
- Logger.AddInformation("Closing " + processToClose.ProcessName);
- if (processToClose.ProcessName.Contains("xulrunner"))
- {
- Logger.AddInformation("Closing XulRunner over Socket");
- SEBXULRunnerWebSocketServer.SendAllowCloseToXulRunner();
- Thread.Sleep(500);
- }
-
- string name = "processHasExitedTrue";
-
- // Try to close process nicely with CloseMainWindow
- if (!processToClose.HasExited)
- {
- Logger.AddInformation("Process " + processToClose.ProcessName + " hasnt closed yet, try again");
- //If the process handles the mainWindow
- if (processToClose.MainWindowHandle != IntPtr.Zero)
- {
- name = processToClose.ProcessName;
- // Close process by sending a close message to its main window.
- Logger.AddError("Send CloseMainWindow to process " + name, null, null);
- processToClose.CloseMainWindow();
- // Wait max. 5 seconds till the process exits
- for (int i = 0; i < 5; i++)
- {
- processToClose.Refresh();
- // If process still hasn't exited, we wait another second
- if (processToClose != null && !processToClose.HasExited)
- {
- Logger.AddError("Process " + name + " hasn't exited by closing its main window, wait up to one more second and check again.", null, null);
- //Thread.Sleep(1000);
- processToClose.WaitForExit(1000);
- }
- else
- {
- Logger.AddError("Process " + name + " has exited.", null, null);
- break;
- }
- }
- }
- }
processToClose.Refresh();
-
- // Check if process has exited now and otherwise kill it
+ // If process still hasn't exited, we wait another second
if (!processToClose.HasExited)
{
- // If process still hasn't exited, we kill it
- Logger.AddError("Send Kill to process " + name, null, null);
- processToClose.Kill();
- // Wait max. 10 seconds till the process exits
- for (int i = 0; i < 10; i++)
+ Logger.AddError("Process " + name + " still hasn't exited, wait up to one more second and check again.", null, null);
+ //Thread.Sleep(1000);
+ try
+ {
+ processToClose.WaitForExit(1000);
+ }
+ catch (Exception ex)
{
- processToClose.Refresh();
- // If process still hasn't exited, we wait another second
- if (!processToClose.HasExited)
- {
- Logger.AddError("Process " + name + " still hasn't exited, wait up to one more second and check again.", null, null);
- //Thread.Sleep(1000);
- try
- {
- processToClose.WaitForExit(1000);
- }
- catch (Exception ex)
- {
- Logger.AddError("Unable to processToClose.WaitForExit(1000)",null,ex);
- }
-
- }
- else
- {
- Logger.AddError("Process " + name + " has exited.", null, null);
- break;
- }
+ Logger.AddError("Unable to processToClose.WaitForExit(1000)", null, ex);
}
+
}
- processToClose.Refresh();
-
- // If process still hasn't exited or wasn't closed, we log this
- if (!processToClose.HasExited)
+ else
{
- //Logger.AddError("Process " + name + " has not exited after trying to close its main window and killing it and waiting in total 20 seconds!", null, null);
- Logger.AddError("Process " + name + " has not exited after killing it and waiting in total 11 seconds!", null, null);
+ Logger.AddError("Process " + name + " has exited.", null, null);
+ break;
}
-
- //// Close the process if it has exited (freeing resources)
- //if (processToClose.HasExited)
- // //if (processToClose.HasExited && processToClose != SEBClientInfo.SebWindowsClientForm.xulRunner)
- // {
- // Logger.AddError("Send Close to process " + name, null, null);
- // processToClose.Close();
-
- // // Wait max. 10 seconds till the process exits
- // for (int i = 0; i < 10; i++)
- // {
- // processToClose.Refresh();
- // // If process still wasn't closed, we wait another second
- // if (processToClose.Handle != IntPtr.Zero)
- // {
- // Logger.AddError("Process " + name + " still wasn't closed, wait up to one more second and check again.", null, null);
- // //Thread.Sleep(1000);
- // processToClose.WaitForExit(1000);
- // }
- // else
- // {
- // Logger.AddError("Process " + name + " was successfully closed.", null, null);
- // break;
- // }
- // }
-
- // // If process still wasn't closed, we log this
- // processToClose.Refresh();
- // if (processToClose.Handle != IntPtr.Zero)
- // {
- // Logger.AddError("Process " + name + " didn't close.", null, null);
- // }
- //}
- //else
- //{
- // Logger.AddError("Although it didn't exit yet, send Close anyways to process " + name, null, null);
- // processToClose.Close();
- //}
}
}
- catch (Exception ex)
+ processToClose.Refresh();
+
+ // If process still hasn't exited or wasn't closed, we log this
+ if (processToClose.HasExited)
+ {
+ return;
+ }
+ else
{
- Logger.AddError("Error when killing process", null, ex);
+ //Logger.AddError("Process " + name + " has not exited after trying to close its main window and killing it and waiting in total 20 seconds!", null, null);
+ Logger.AddError("Process " + name + " has not exited after killing it and waiting in total 11 seconds!", null, null);
}
+
+ //// Close the process if it has exited (freeing resources)
+ //if (processToClose.HasExited)
+ // //if (processToClose.HasExited && processToClose != SEBClientInfo.SebWindowsClientForm.xulRunner)
+ // {
+ // Logger.AddError("Send Close to process " + name, null, null);
+ // processToClose.Close();
+
+ // // Wait max. 10 seconds till the process exits
+ // for (int i = 0; i < 10; i++)
+ // {
+ // processToClose.Refresh();
+ // // If process still wasn't closed, we wait another second
+ // if (processToClose.Handle != IntPtr.Zero)
+ // {
+ // Logger.AddError("Process " + name + " still wasn't closed, wait up to one more second and check again.", null, null);
+ // //Thread.Sleep(1000);
+ // processToClose.WaitForExit(1000);
+ // }
+ // else
+ // {
+ // Logger.AddError("Process " + name + " was successfully closed.", null, null);
+ // break;
+ // }
+ // }
+
+ // // If process still wasn't closed, we log this
+ // processToClose.Refresh();
+ // if (processToClose.Handle != IntPtr.Zero)
+ // {
+ // Logger.AddError("Process " + name + " didn't close.", null, null);
+ // }
+ //}
+ //else
+ //{
+ // Logger.AddError("Although it didn't exit yet, send Close anyways to process " + name, null, null);
+ // processToClose.Close();
+ //}
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.AddError("Error when killing process", null, ex);
+ }
}
+
///
/// Gets all processes.
///
diff --git a/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBProcessHandler.cs b/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBProcessHandler.cs
index 2f46880..babc616 100644
--- a/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBProcessHandler.cs
+++ b/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBProcessHandler.cs
@@ -1,24 +1,20 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
+using System.Management;
using System.Runtime.InteropServices;
-using System.Text;
using System.Threading;
-using System.Threading.Tasks;
using System.Windows.Forms;
-using System.Windows.Forms.VisualStyles;
-using SebWindowsClient.ConfigurationUtils;
using SebWindowsClient.DiagnosticsUtils;
namespace SebWindowsClient.ProcessUtils
{
- ///
- /// Offers methods to handle windows
- ///
- public static class SEBProcessHandler
+ ///
+ /// Offers methods to handle windows
+ ///
+ public static class SEBProcessHandler
{
#region Public Members
@@ -26,7 +22,7 @@ public static class SEBProcessHandler
///
/// A list of not prohibited window executables
///
- public static List ProhibitedExecutables = new List();
+ public static List ProhibitedExecutables = new List();
#endregion
@@ -38,29 +34,6 @@ public static class SEBProcessHandler
#region Public Methods
- ///
- /// Checks if the process is explicitly prohibited to run while SEB is running
- ///
- ///
- ///
- public static bool IsProcessProhibited(string processName)
- {
- if (String.IsNullOrWhiteSpace(processName))
- return false;
-
- processName = processName.ToLower();
-
- //If no prohibited Executables are defined, return false
- if (ProhibitedExecutables.Count == 0)
- return false;
- //If explicitly prohibited, return true
- if (ProhibitedExecutables.Count > 0 && ProhibitedExecutables.Any(ex => ex.Contains(processName) || processName.Contains(ex)))
- return true;
-
- //else return false
- return false;
- }
-
///
/// Starts the explorer shell if not running
/// This task sleeps the Thread for six seconds to make sure the explorer shell starts up completely
@@ -181,17 +154,59 @@ public static string GetExecutableName(this Process process)
.Where(oW => oW.Key.GetProcess().GetExecutableName() == process.GetExecutableName());
}
- #endregion
+ public static bool HasOriginalName(this Process process, out string originalName)
+ {
+ var query = "SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId = " + process.Id;
- #region Private Methods
+ originalName = string.Empty;
-
+ try
+ {
+ using (var searcher = new ManagementObjectSearcher(query))
+ using (var results = searcher.Get())
+ {
+ var processData = results.Cast().FirstOrDefault(p => Convert.ToInt32(p["ProcessId"]) == process.Id);
- #endregion
+ if (processData != null)
+ {
+ var executablePath = processData["ExecutablePath"] as string;
+
+ if (!String.IsNullOrEmpty(executablePath) && File.Exists(executablePath))
+ {
+ var processName = process.GetExecutableName();
+ var executableInfo = FileVersionInfo.GetVersionInfo(executablePath);
- #region Screensaver & Sleep
+ originalName = Path.GetFileNameWithoutExtension(executableInfo.OriginalFilename);
- [FlagsAttribute]
+ if (!String.IsNullOrWhiteSpace(originalName) && !processName.Equals(originalName, StringComparison.InvariantCultureIgnoreCase))
+ {
+ Logger.AddInformation(String.Format("Process '{0}' has been renamed from '{1}' to '{2}'!", executablePath, originalName, processName));
+ }
+
+ return true;
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Logger.AddError(String.Format("Failed to retrieve the original name of process '{0}'!", process.ProcessName ?? ""), null, e, e.Message);
+ }
+
+ return false;
+ }
+
+ #endregion
+
+ #region Private Methods
+
+
+
+ #endregion
+
+ #region Screensaver & Sleep
+
+ [FlagsAttribute]
public enum EXECUTION_STATE : uint
{
ES_SYSTEM_REQUIRED = 0x00000001,
@@ -238,11 +253,25 @@ public void StartWatchDog()
{
if (_processesToWatch.Count == 0)
{
- foreach (var processName in SEBProcessHandler.ProhibitedExecutables)
+ foreach (var executable in SEBProcessHandler.ProhibitedExecutables)
{
- var processToWatch = new ProcessInfo(processName);
- processToWatch.Started += ProcessStarted;
- _processesToWatch.Add(processToWatch);
+ if (executable.HasName)
+ {
+ var processInfo = new ProcessInfo(executable.Name);
+
+ processInfo.Started += ProcessStarted;
+
+ _processesToWatch.Add(processInfo);
+ }
+
+ if (executable.HasOriginalName && !executable.NamesAreEqual)
+ {
+ var processInfo = new ProcessInfo(executable.OriginalName);
+
+ processInfo.Started += ProcessStarted;
+
+ _processesToWatch.Add(processInfo);
+ }
}
}
}
@@ -250,11 +279,10 @@ public void StartWatchDog()
private void ProcessStarted(object sender, EventArgs e)
{
var processName = ((ProcessInfo) sender).ProcessName;
- foreach (var process in Process.GetProcesses().Where(p => processName.Contains(p.ProcessName)))
+
+ foreach (var process in Process.GetProcesses().Where(p => processName.Equals(p.ProcessName, StringComparison.InvariantCultureIgnoreCase)))
{
SEBNotAllowedProcessController.CloseProcess(process);
- //p.CloseMainWindow();
- //p.Close();
}
}
diff --git a/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBWindowHandler.cs b/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBWindowHandler.cs
index 9b7bdc6..f5d1b7b 100644
--- a/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBWindowHandler.cs
+++ b/SebWindowsClient/SebWindowsClient/ProcessUtils/SEBWindowHandler.cs
@@ -1,24 +1,19 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing;
using System.Linq;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
-using System.Threading.Tasks;
using System.Windows.Forms;
-using System.Windows.Forms.VisualStyles;
using SebWindowsClient.DiagnosticsUtils;
-using SebWindowsClient.ServiceUtils;
namespace SebWindowsClient.ProcessUtils
{
- ///
- /// Offers methods to handle windows
- ///
- public static class SEBWindowHandler
+ ///
+ /// Offers methods to handle windows
+ ///
+ public static class SEBWindowHandler
{
#region Public Members
@@ -26,7 +21,7 @@ public static class SEBWindowHandler
///
/// A list of not allowed window titles (the title must not exactly match but only contain the values in here
///
- public static List AllowedExecutables = new List();
+ public static List AllowedExecutables = new List();
///
/// The possible actions for a window defined by ShowWindowAsync()
@@ -56,26 +51,49 @@ enum ShowWindowCommand
#region Public Methods
///
- /// Checks if the process that holds the windowhandle is allowed to show its window
+ /// Checks if the process that holds the window handle is allowed to show its window.
///
- ///
- ///
- public static bool IsWindowAllowedByProcessName(string processName)
+ public static bool IsWindowAllowed(this Process process)
{
- if (String.IsNullOrWhiteSpace(processName))
- return false;
-
- processName = processName.ToLower();
-
- //If no allowed apps are specified, meaning all apps are allowed return true
- if (AllowedExecutables.Count == 0)
- return true;
- //If explicitly allowed return true
- if (AllowedExecutables.Count > 0 && AllowedExecutables.Any(ex => ex.Contains(processName) || processName.Contains(ex)))
- return true;
-
- //else return false
- return false;
+ var processName = process.GetExecutableName();
+
+ if (!String.IsNullOrWhiteSpace(processName))
+ {
+ var processHasOriginalName = process.HasOriginalName(out string originalProcessName);
+
+ foreach (var executable in AllowedExecutables)
+ {
+ var isAllowed = executable.HasName || executable.HasOriginalName;
+
+ if (executable.HasName)
+ {
+ isAllowed &= executable.Name.Equals(processName, StringComparison.InvariantCultureIgnoreCase);
+ }
+
+ if (executable.HasOriginalName && processHasOriginalName)
+ {
+ isAllowed &= executable.OriginalName.Equals(originalProcessName, StringComparison.InvariantCultureIgnoreCase);
+
+ if (!executable.HasName)
+ {
+ isAllowed &= executable.OriginalName.Equals(processName, StringComparison.InvariantCultureIgnoreCase);
+ }
+ }
+ else if (executable.HasOriginalName && !processHasOriginalName)
+ {
+ isAllowed = false;
+ }
+
+ if (isAllowed)
+ {
+ return true;
+ }
+ }
+ }
+
+ Logger.AddInformation(String.Format("Window for process '{0}' is not allowed!", processName ?? ""));
+
+ return false;
}
/// Returns a dictionary that contains the handle and title of all the open windows.
@@ -354,15 +372,6 @@ public static void DisableForegroundWatchDog()
#endregion
- #region Process Extensions
-
- public static bool IsWindowAllowed(this Process process)
- {
- return IsWindowAllowedByProcessName(process.GetExecutableName());
- }
-
- #endregion
-
#region Private Methods
private static void EditAllOpenWindows(ShowWindowCommand action)
diff --git a/SebWindowsClient/SebWindowsClient/Properties/AssemblyInfo.cs b/SebWindowsClient/SebWindowsClient/Properties/AssemblyInfo.cs
index 9ac7771..9282025 100644
--- a/SebWindowsClient/SebWindowsClient/Properties/AssemblyInfo.cs
+++ b/SebWindowsClient/SebWindowsClient/Properties/AssemblyInfo.cs
@@ -32,4 +32,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.1.*")]
-[assembly: AssemblyInformationalVersion("2.1.6")]
+[assembly: AssemblyInformationalVersion("2.1.7")]
diff --git a/SebWindowsClient/SebWindowsClient/SebWindowsClient.csproj b/SebWindowsClient/SebWindowsClient/SebWindowsClient.csproj
index fc4c41f..459a205 100644
--- a/SebWindowsClient/SebWindowsClient/SebWindowsClient.csproj
+++ b/SebWindowsClient/SebWindowsClient/SebWindowsClient.csproj
@@ -85,6 +85,7 @@
+
diff --git a/SebWindowsClient/SebWindowsClient/SebWindowsClientForm.cs b/SebWindowsClient/SebWindowsClient/SebWindowsClientForm.cs
index 0f7de40..eb9f612 100644
--- a/SebWindowsClient/SebWindowsClient/SebWindowsClientForm.cs
+++ b/SebWindowsClient/SebWindowsClient/SebWindowsClientForm.cs
@@ -35,20 +35,20 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Drawing;
+using System.IO;
using System.Linq;
+using System.Net;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
+using SebWindowsClient.BlockShortcutsUtils;
using SebWindowsClient.ConfigurationUtils;
-using SebWindowsClient.DiagnosticsUtils;
using SebWindowsClient.DesktopUtils;
-using System.Net;
-using System.IO;
+using SebWindowsClient.DiagnosticsUtils;
using SebWindowsClient.ProcessUtils;
-using SebWindowsClient.BlockShortcutsUtils;
-using System.Runtime.InteropServices;
-using System.Diagnostics;
using SebWindowsClient.ServiceUtils;
using SebWindowsClient.UI;
using SebWindowsClient.XULRunnerCommunication;
@@ -57,9 +57,9 @@
namespace SebWindowsClient
{
-
- public partial class SebWindowsClientForm : Form
+
+ public partial class SebWindowsClientForm : Form
{
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
@@ -732,6 +732,10 @@ private void addPermittedProcessesToTS()
//SEBClientInfo.SebWindowsClientForm.Activate();
SEBMessageBox.Show(SEBUIStrings.permittedApplicationNotFound, SEBUIStrings.permittedApplicationNotFoundMessage.Replace("%s",title), MessageBoxIcon.Error, MessageBoxButtons.OK);
}
+ } else
+ {
+ // Permitted application is Firefox: Set its call entry to null
+ permittedProcessesCalls.Add(null);
}
}
}
@@ -955,7 +959,8 @@ public string GetPermittedApplicationPath(DictObj permittedProcess)
{
string executable = (string)SEBSettings.valueForDictionaryKey(permittedProcess, SEBSettings.KeyExecutable);
if (executable == null) executable = "";
- string executablePath = (string)SEBSettings.valueForDictionaryKey(permittedProcess, SEBSettings.KeyPath);
+ string originalName = (string) SEBSettings.valueForDictionaryKey(permittedProcess, SEBSettings.KeyOriginalName) ?? string.Empty;
+ string executablePath = (string)SEBSettings.valueForDictionaryKey(permittedProcess, SEBSettings.KeyPath);
if (executablePath == null) executablePath = "";
bool allowChoosingApp = (bool)SEBSettings.valueForDictionaryKey(permittedProcess, SEBSettings.KeyAllowUser);
//if (allowChoosingApp == null) allowChoosingApp = false;
@@ -996,7 +1001,7 @@ public string GetPermittedApplicationPath(DictObj permittedProcess)
{
// Ask the user to locate the application
SEBToForeground();
- return ThreadedDialog.ShowFileDialogForExecutable(executable);
+ return ThreadedDialog.ShowFileDialogForExecutable(executable, originalName);
}
return fullPath;
}
@@ -1355,62 +1360,92 @@ private static bool MyEnumThreadWindowsProc(IntPtr hWnd, IntPtr lParam)
return true;
}
- /// ----------------------------------------------------------------------------------------
- ///
- /// Set registry values and close prohibited processes.
- ///
- /// true if succeed
- /// ----------------------------------------------------------------------------------------
- private bool InitClientRegistryAndKillProcesses()
+ private bool CheckProhibitedProcesses()
{
-
- // Add prohibited processes to the "processes not permitted to run" list
- // which will be dealt with after checking if permitted processes are already running;
- // the user will be asked to quit all those processes him/herself or to let SEB kill them
- // Prohibited processes with the strongKill flag set can be killed without user consent
-
- List