SEBWIN-110: Switched to custom build of SimpleWifi which incorporates the RadioState for Wi-Fi interfaces.

This commit is contained in:
dbuechel 2017-11-14 09:10:06 +01:00
parent 396aa56bd5
commit 00754ee100
5 changed files with 17 additions and 56 deletions

BIN
Libraries/SimpleWifi.dll Normal file

Binary file not shown.

View file

@ -49,7 +49,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="SimpleWifi, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleWifi.1.0.0.0\lib\net40\SimpleWifi.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\SimpleWifi.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
@ -70,8 +71,5 @@
<Name>SafeExamBrowser.Contracts</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -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()

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SimpleWifi" version="1.0.0.0" targetFramework="net452" />
</packages>

View file

@ -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