diff --git a/Libraries/SimpleWifi.dll b/Libraries/SimpleWifi.dll new file mode 100644 index 00000000..3e28917a Binary files /dev/null and b/Libraries/SimpleWifi.dll differ diff --git a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj index 5ea322a3..4302968c 100644 --- a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj +++ b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj @@ -49,7 +49,8 @@ - ..\packages\SimpleWifi.1.0.0.0\lib\net40\SimpleWifi.dll + False + ..\Libraries\SimpleWifi.dll @@ -70,8 +71,5 @@ SafeExamBrowser.Contracts - - - \ No newline at end of file diff --git a/SafeExamBrowser.SystemComponents/WirelessNetwork.cs b/SafeExamBrowser.SystemComponents/WirelessNetwork.cs index 62544b2a..343f361a 100644 --- a/SafeExamBrowser.SystemComponents/WirelessNetwork.cs +++ b/SafeExamBrowser.SystemComponents/WirelessNetwork.cs @@ -8,15 +8,13 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Management; -using System.Net.NetworkInformation; using System.Timers; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.SystemComponents; using SafeExamBrowser.Contracts.UserInterface.Taskbar; using SimpleWifi; using SimpleWifi.Win32; +using SimpleWifi.Win32.Interop; namespace SafeExamBrowser.SystemComponents { @@ -91,61 +89,25 @@ namespace SafeExamBrowser.SystemComponents { try { - // See https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx - string query = @" - SELECT * - FROM Win32_NetworkAdapter"; - var searcher = new ManagementObjectSearcher(query); - var adapters = searcher.Get(); - var interfaces = NetworkInterface.GetAllNetworkInterfaces().Where(i => i.NetworkInterfaceType == NetworkInterfaceType.Wireless80211).ToList(); + var client = new WlanClient(); - logger.Info("Interface count: " + interfaces.Count); - - foreach (var i in interfaces) + foreach (var @interface in client.Interfaces) { - logger.Info(i.Description); - logger.Info(i.Id); - logger.Info(i.Name); - logger.Info(i.NetworkInterfaceType.ToString()); - logger.Info(i.OperationalStatus.ToString()); - logger.Info("-----"); - } - - foreach (var adapter in adapters) - { - logger.Info("-------"); - - foreach (var property in adapter.Properties) + foreach (var state in @interface.RadioState.PhyRadioState) { - logger.Info($"{property.Name}: {property.Value} ({property.Type})"); - } - } - - logger.Info("Adapter count: " + adapters.Count); - - return true; - - using (var client = new WlanClient()) - { - foreach (var @interface in client.Interfaces) - { - Trace.WriteLine($"[{@interface.InterfaceName}]"); - - foreach (var state in @interface.RadioState.PhyRadioState) + if (state.dot11SoftwareRadioState == Dot11RadioState.On && state.dot11HardwareRadioState == Dot11RadioState.On) { - Trace.WriteLine($"PhyIndex: {state.dwPhyIndex}"); - Trace.WriteLine($"SoftwareRadioState: {state.dot11SoftwareRadioState}"); - Trace.WriteLine($"HardwareRadioState: {state.dot11HardwareRadioState}"); + return false; } } } } catch (Exception e) { - logger.Error("Fail!", e); - - return true; + logger.Error("Failed to determine the radio state of the wireless adapter(s)! Assuming it is (all are) turned off...", e); } + + return true; } private void UpdateControl() diff --git a/SafeExamBrowser.SystemComponents/packages.config b/SafeExamBrowser.SystemComponents/packages.config deleted file mode 100644 index f8a15217..00000000 --- a/SafeExamBrowser.SystemComponents/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/SafeExamBrowser.sln b/SafeExamBrowser.sln index b3db513a..9109ae99 100644 --- a/SafeExamBrowser.sln +++ b/SafeExamBrowser.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.16 +VisualStudioVersion = 15.0.27004.2008 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser", "SafeExamBrowser\SafeExamBrowser.csproj", "{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}" EndProject @@ -30,6 +30,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.SystemCompo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Classic", "SafeExamBrowser.UserInterface.Classic\SafeExamBrowser.UserInterface.Classic.csproj", "{A502DF54-7169-4647-94BD-18B192924866}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{E03B19EC-8E4D-481C-9C1B-5C6C060D3D6B}" + ProjectSection(SolutionItems) = preProject + Libraries\SimpleWifi.dll = Libraries\SimpleWifi.dll + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU