SEBWIN-110: Switched to custom build of SimpleWifi which incorporates the RadioState for Wi-Fi interfaces.
This commit is contained in:
parent
396aa56bd5
commit
00754ee100
5 changed files with 17 additions and 56 deletions
BIN
Libraries/SimpleWifi.dll
Normal file
BIN
Libraries/SimpleWifi.dll
Normal file
Binary file not shown.
|
@ -49,7 +49,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="SimpleWifi, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<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>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
@ -70,8 +71,5 @@
|
||||||
<Name>SafeExamBrowser.Contracts</Name>
|
<Name>SafeExamBrowser.Contracts</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -8,15 +8,13 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Management;
|
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.SystemComponents;
|
using SafeExamBrowser.Contracts.SystemComponents;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||||
using SimpleWifi;
|
using SimpleWifi;
|
||||||
using SimpleWifi.Win32;
|
using SimpleWifi.Win32;
|
||||||
|
using SimpleWifi.Win32.Interop;
|
||||||
|
|
||||||
namespace SafeExamBrowser.SystemComponents
|
namespace SafeExamBrowser.SystemComponents
|
||||||
{
|
{
|
||||||
|
@ -91,61 +89,25 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// See https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx
|
var client = new WlanClient();
|
||||||
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();
|
|
||||||
|
|
||||||
logger.Info("Interface count: " + interfaces.Count);
|
foreach (var @interface in client.Interfaces)
|
||||||
|
|
||||||
foreach (var i in interfaces)
|
|
||||||
{
|
{
|
||||||
logger.Info(i.Description);
|
foreach (var state in @interface.RadioState.PhyRadioState)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
logger.Info($"{property.Name}: {property.Value} ({property.Type})");
|
if (state.dot11SoftwareRadioState == Dot11RadioState.On && state.dot11HardwareRadioState == Dot11RadioState.On)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
Trace.WriteLine($"PhyIndex: {state.dwPhyIndex}");
|
return false;
|
||||||
Trace.WriteLine($"SoftwareRadioState: {state.dot11SoftwareRadioState}");
|
|
||||||
Trace.WriteLine($"HardwareRadioState: {state.dot11HardwareRadioState}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.Error("Fail!", e);
|
logger.Error("Failed to determine the radio state of the wireless adapter(s)! Assuming it is (all are) turned off...", e);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateControl()
|
private void UpdateControl()
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="SimpleWifi" version="1.0.0.0" targetFramework="net452" />
|
|
||||||
</packages>
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26730.16
|
VisualStudioVersion = 15.0.27004.2008
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser", "SafeExamBrowser\SafeExamBrowser.csproj", "{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser", "SafeExamBrowser\SafeExamBrowser.csproj", "{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -30,6 +30,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.SystemCompo
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Classic", "SafeExamBrowser.UserInterface.Classic\SafeExamBrowser.UserInterface.Classic.csproj", "{A502DF54-7169-4647-94BD-18B192924866}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Classic", "SafeExamBrowser.UserInterface.Classic\SafeExamBrowser.UserInterface.Classic.csproj", "{A502DF54-7169-4647-94BD-18B192924866}"
|
||||||
EndProject
|
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
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
Loading…
Reference in a new issue