Compare commits
9 Commits
c3fa3ed29a
...
master
Author | SHA1 | Date | |
---|---|---|---|
6926504339 | |||
c9f79574a5 | |||
121dfa381d | |||
80b2df1121 | |||
1137495368 | |||
4be5de8177 | |||
131a169676 | |||
ad1dae18a9 | |||
ff8304a149 |
@@ -1,12 +0,0 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = crlf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,9 +0,0 @@
|
||||
desktop.ini
|
||||
*/bin/*
|
||||
*/Debug/*
|
||||
*.dll
|
||||
*.pbk
|
||||
.vs/
|
||||
*/obj/*
|
||||
*/desktop.ini
|
||||
NetWork/Properties/PublishProfiles/
|
25
NetWork.sln
25
NetWork.sln
@@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31612.314
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetWork", "NetWork\NetWork.csproj", "{A1D13A5A-C5C4-4559-BD8D-FB293DAA9034}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A1D13A5A-C5C4-4559-BD8D-FB293DAA9034}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A1D13A5A-C5C4-4559-BD8D-FB293DAA9034}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A1D13A5A-C5C4-4559-BD8D-FB293DAA9034}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A1D13A5A-C5C4-4559-BD8D-FB293DAA9034}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BCD0CEDC-F7E6-4311-A924-55D96D536E8D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
6
NetWork/.gitignore
vendored
6
NetWork/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
bin/
|
||||
net6.0*/
|
||||
Publish/
|
||||
NetWork/Publish/*/*
|
||||
*.exe
|
||||
NetWork/Properties/
|
@@ -1,8 +0,0 @@
|
||||
|
||||
namespace NetWork
|
||||
{
|
||||
class DialUp
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
namespace NetWork
|
||||
{
|
||||
class IgnoreFile
|
||||
{
|
||||
public static void M()
|
||||
{
|
||||
var ahkk = AutoHotkey.Interop.AutoHotkeyEngine.Instance;
|
||||
ahkk.GetVar("shut");
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
M();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NetWork
|
||||
{
|
||||
interface Ip
|
||||
{
|
||||
[DllImport("IPHLPAPI.DLL")]
|
||||
public static extern int ipconfig();
|
||||
public static void Ma()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ApplicationIcon />
|
||||
<StartupObject>NetWork.Program</StartupObject>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<StartWorkingDirectory>.</StartWorkingDirectory>
|
||||
|
||||
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
|
||||
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
|
||||
<UseWPF>True</UseWPF>
|
||||
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
|
||||
<SignAssembly>False</SignAssembly>
|
||||
|
||||
<FileVersion>1.0.0.1</FileVersion>
|
||||
|
||||
<AssemblyVersion>0.1.1</AssemblyVersion>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DocumentationFile>.\NetWork.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AudioControl.x64" Version="1.0.1" />
|
||||
<PackageReference Include="AutoHotkey.Interop" Version="1.0.0.1" />
|
||||
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NETCore.Windows.ApiSets-x64" Version="1.0.0" />
|
||||
<PackageReference Include="NAudio" Version="2.0.1" />
|
||||
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NLog" Version="4.7.15" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
|
||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="SimpleWifi.netstandard" Version="2.0.0" />
|
||||
<PackageReference Include="System.Management" Version="6.0.0" />
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
<PackageReference Include="VPNConnector" Version="1.0.0" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<EmbeddedResource Include="Other\ek.pbk" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Other\Windows.Common.dll" />
|
||||
<EmbeddedResource Include="Other\Windows.Common.pdb" />
|
||||
<EmbeddedResource Include="Other\earphones.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Other\*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Update="Other\Data.ini">
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
||||
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<_LastSelectedProfileId>C:\Users\Saret\Programming\C#\NetWork\NetWork\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||
</PropertyGroup>
|
||||
</Project>
|
1471
NetWork/NetWork.xml
1471
NetWork/NetWork.xml
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
RunNetwork
|
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
|
||||
[
|
||||
""
|
||||
]
|
@@ -1,65 +0,0 @@
|
||||
[
|
||||
[{
|
||||
"GoogleDriveFS": "rep",
|
||||
"qbittorrent": "C:\\Program Files\\qBittorrent\\qbittorrent.exe",
|
||||
"Surfshark": "C:\\Program Files (x86)\\Surfshark\\Surfshark.exe",
|
||||
"cmd": "C:\\Windows\\System32\\cmd.exe",
|
||||
"teamviewer": "C:\\Program Files (x86)\\TeamViewer\\TeamViewer.exe",
|
||||
"tv": "C:\\Program Files (x86)\\TeamViewer\\TeamViewer_Service.exe"
|
||||
}, {
|
||||
"rep": "GoogleDriveFS.exe",
|
||||
"C:\\Program Files\\qBittorrent\\qbittorrent.exe": "qbittorrent.exe",
|
||||
"C:\\Program Files (x86)\\Surfshark\\Surfshark.exe": "Surfshark",
|
||||
"C:\\Windows\\System32\\cmd.exe": "cmd",
|
||||
"C:\\Program Files (x86)\\TeamViewer\\TeamViewer.exe": "teamviewer",
|
||||
"C:\\Program Files (x86)\\TeamViewer\\TeamViewer_Service.exe": "tv"
|
||||
}
|
||||
|
||||
],
|
||||
{
|
||||
"vpn": {
|
||||
"programs_to_run": ["GoogleDriveFS", "qbittorrent", "Surfshark"],
|
||||
"programs_to_stop": ["rdp", "tv", "teamviewer"],
|
||||
"services_to_stop": ["Surf"],
|
||||
"services_to_start": ["teamviewer"],
|
||||
"mute": false
|
||||
},
|
||||
"ek": {
|
||||
"programs_to_run": ["rdp", "GoogleDriveFS"],
|
||||
"programs_to_stop": ["qbittorrent", "Surfshrk"],
|
||||
"services_to_stop": ["Surf"],
|
||||
"services_to_start": [],
|
||||
"mute": false
|
||||
},
|
||||
"good_lan": {
|
||||
"programs_to_run": ["GoogleDriveFS", "qbittorrent", "Surfshark"],
|
||||
"services_to_start": ["Surf"],
|
||||
"services_to_stop": [],
|
||||
"programs_to_stop": ["rdp"],
|
||||
"mute": false
|
||||
},
|
||||
"lan": {
|
||||
"programs_to_run": ["GoogleDriveFS", "rdp"],
|
||||
"services_to_start": [],
|
||||
"services_to_stop": ["Surf"],
|
||||
"programs_to_stop": ["qbittorrent", "Surfshark"],
|
||||
"mute": false,
|
||||
"macs": ["00-E0-4C-68-13-F8"]
|
||||
},
|
||||
"good_wifi": {
|
||||
"programs_to_run": ["GoogleDriveFS", "qbittorrent", "Surfshark"],
|
||||
"services_to_start": ["Surf"],
|
||||
"services_to_stop": [],
|
||||
"programs_to_stop": ["rdp"],
|
||||
"mute": false
|
||||
},
|
||||
"bad_wifi": {
|
||||
"programs_to_run": ["GoogleDriveFS"],
|
||||
"services_to_start": ["Surf"],
|
||||
"services_to_stop": [],
|
||||
"programs_to_stop": ["rdp", "qbittorrent", "Surfshark"],
|
||||
"mute": true
|
||||
|
||||
}
|
||||
}
|
||||
]
|
@@ -1,4 +0,0 @@
|
||||
[
|
||||
"Mi True Wire",
|
||||
"realme"
|
||||
]
|
@@ -1,290 +0,0 @@
|
||||
[ek]
|
||||
Encoding=1
|
||||
PBVersion=8
|
||||
Type=5
|
||||
AutoLogon=0
|
||||
UseRasCredentials=0
|
||||
LowDateTime=1563825568
|
||||
HighDateTime=30902417
|
||||
DialParamsUID=549312
|
||||
Guid=8E5B41957D8C954CBC98BCA8DD84D124
|
||||
VpnStrategy=0
|
||||
ExcludedProtocols=0
|
||||
LcpExtensions=1
|
||||
DataEncryption=8
|
||||
SwCompression=0
|
||||
NegotiateMultilinkAlways=0
|
||||
SkipDoubleDialDialog=0
|
||||
DialMode=0
|
||||
OverridePref=15
|
||||
RedialAttempts=3
|
||||
RedialSeconds=60
|
||||
IdleDisconnectSeconds=0
|
||||
RedialOnLinkFailure=1
|
||||
CallbackMode=0
|
||||
CustomDialDll=
|
||||
CustomDialFunc=
|
||||
CustomRasDialDll=
|
||||
ForceSecureCompartment=0
|
||||
DisableIKENameEkuCheck=0
|
||||
AuthenticateServer=0
|
||||
ShareMsFilePrint=0
|
||||
BindMsNetClient=0
|
||||
SharedPhoneNumbers=0
|
||||
GlobalDeviceSettings=0
|
||||
PrerequisiteEntry=
|
||||
PrerequisitePbk=
|
||||
PreferredPort=PPPoE5-0
|
||||
PreferredDevice=WAN Miniport (PPPOE)
|
||||
PreferredBps=0
|
||||
PreferredHwFlow=0
|
||||
PreferredProtocol=0
|
||||
PreferredCompression=0
|
||||
PreferredSpeaker=0
|
||||
PreferredMdmProtocol=0
|
||||
PreviewUserPw=1
|
||||
PreviewDomain=0
|
||||
PreviewPhoneNumber=0
|
||||
ShowDialingProgress=1
|
||||
ShowMonitorIconInTaskBar=1
|
||||
CustomAuthKey=0
|
||||
AuthRestrictions=552
|
||||
IpPrioritizeRemote=1
|
||||
IpInterfaceMetric=0
|
||||
IpHeaderCompression=0
|
||||
IpAddress=0.0.0.0
|
||||
IpDnsAddress=0.0.0.0
|
||||
IpDns2Address=0.0.0.0
|
||||
IpWinsAddress=0.0.0.0
|
||||
IpWins2Address=0.0.0.0
|
||||
IpAssign=1
|
||||
IpNameAssign=1
|
||||
IpDnsFlags=0
|
||||
IpNBTFlags=0
|
||||
TcpWindowSize=0
|
||||
UseFlags=3
|
||||
IpSecFlags=0
|
||||
IpDnsSuffix=
|
||||
Ipv6Assign=1
|
||||
Ipv6Address=::
|
||||
Ipv6PrefixLength=0
|
||||
Ipv6PrioritizeRemote=1
|
||||
Ipv6InterfaceMetric=0
|
||||
Ipv6NameAssign=1
|
||||
Ipv6DnsAddress=::
|
||||
Ipv6Dns2Address=::
|
||||
Ipv6Prefix=0000000000000000
|
||||
Ipv6InterfaceId=0000000000000000
|
||||
DisableClassBasedDefaultRoute=0
|
||||
DisableMobility=0
|
||||
NetworkOutageTime=0
|
||||
IDI=
|
||||
IDR=
|
||||
ImsConfig=0
|
||||
IdiType=0
|
||||
IdrType=0
|
||||
ProvisionType=0
|
||||
PreSharedKey=
|
||||
CacheCredentials=1
|
||||
NumCustomPolicy=0
|
||||
NumEku=0
|
||||
UseMachineRootCert=0
|
||||
Disable_IKEv2_Fragmentation=0
|
||||
PlumbIKEv2TSAsRoutes=0
|
||||
NumServers=0
|
||||
RouteVersion=1
|
||||
NumRoutes=0
|
||||
NumNrptRules=0
|
||||
AutoTiggerCapable=0
|
||||
NumAppIds=0
|
||||
NumClassicAppIds=0
|
||||
SecurityDescriptor=
|
||||
ApnInfoProviderId=
|
||||
ApnInfoUsername=
|
||||
ApnInfoPassword=
|
||||
ApnInfoAccessPoint=
|
||||
ApnInfoAuthentication=1
|
||||
ApnInfoCompression=0
|
||||
DeviceComplianceEnabled=0
|
||||
DeviceComplianceSsoEnabled=0
|
||||
DeviceComplianceSsoEku=
|
||||
DeviceComplianceSsoIssuer=
|
||||
FlagsSet=0
|
||||
Options=0
|
||||
DisableDefaultDnsSuffixes=0
|
||||
NumTrustedNetworks=0
|
||||
NumDnsSearchSuffixes=0
|
||||
PowershellCreatedProfile=0
|
||||
ProxyFlags=0
|
||||
ProxySettingsModified=0
|
||||
ProvisioningAuthority=
|
||||
AuthTypeOTP=0
|
||||
GREKeyDefined=0
|
||||
NumPerAppTrafficFilters=0
|
||||
AlwaysOnCapable=0
|
||||
DeviceTunnel=0
|
||||
PrivateNetwork=0
|
||||
ManagementApp=
|
||||
|
||||
NETCOMPONENTS=
|
||||
ms_msclient=0
|
||||
ms_server=0
|
||||
|
||||
MEDIA=rastapi
|
||||
Port=PPPoE5-0
|
||||
Device=WAN Miniport (PPPOE)
|
||||
|
||||
DEVICE=PPPoE
|
||||
LastSelectedPhone=0
|
||||
PromoteAlternates=0
|
||||
TryNextAlternateOnFail=1
|
||||
|
||||
[IKEv2-Surfshark Connection]
|
||||
Encoding=1
|
||||
PBVersion=8
|
||||
Type=2
|
||||
AutoLogon=0
|
||||
UseRasCredentials=1
|
||||
LowDateTime=740216224
|
||||
HighDateTime=30902506
|
||||
DialParamsUID=38687218
|
||||
Guid=02AE12A41D5B0B428374D51329305900
|
||||
VpnStrategy=7
|
||||
ExcludedProtocols=8
|
||||
LcpExtensions=1
|
||||
DataEncryption=512
|
||||
SwCompression=0
|
||||
NegotiateMultilinkAlways=0
|
||||
SkipDoubleDialDialog=0
|
||||
DialMode=0
|
||||
OverridePref=15
|
||||
RedialAttempts=3
|
||||
RedialSeconds=5
|
||||
IdleDisconnectSeconds=43200
|
||||
RedialOnLinkFailure=1
|
||||
CallbackMode=0
|
||||
CustomDialDll=
|
||||
CustomDialFunc=
|
||||
CustomRasDialDll=
|
||||
ForceSecureCompartment=0
|
||||
DisableIKENameEkuCheck=0
|
||||
AuthenticateServer=0
|
||||
ShareMsFilePrint=1
|
||||
BindMsNetClient=1
|
||||
SharedPhoneNumbers=0
|
||||
GlobalDeviceSettings=0
|
||||
PrerequisiteEntry=
|
||||
PrerequisitePbk=
|
||||
PreferredPort=VPN2-0
|
||||
PreferredDevice=WAN Miniport (IKEv2)
|
||||
PreferredBps=0
|
||||
PreferredHwFlow=0
|
||||
PreferredProtocol=0
|
||||
PreferredCompression=0
|
||||
PreferredSpeaker=0
|
||||
PreferredMdmProtocol=0
|
||||
PreviewUserPw=1
|
||||
PreviewDomain=1
|
||||
PreviewPhoneNumber=0
|
||||
ShowDialingProgress=1
|
||||
ShowMonitorIconInTaskBar=1
|
||||
CustomAuthKey=0
|
||||
AuthRestrictions=128
|
||||
IpPrioritizeRemote=1
|
||||
IpInterfaceMetric=0
|
||||
IpHeaderCompression=0
|
||||
IpAddress=0.0.0.0
|
||||
IpDnsAddress=0.0.0.0
|
||||
IpDns2Address=0.0.0.0
|
||||
IpWinsAddress=0.0.0.0
|
||||
IpWins2Address=0.0.0.0
|
||||
IpAssign=1
|
||||
IpNameAssign=1
|
||||
IpDnsFlags=0
|
||||
IpNBTFlags=1
|
||||
TcpWindowSize=0
|
||||
UseFlags=2
|
||||
IpSecFlags=0
|
||||
IpDnsSuffix=
|
||||
Ipv6Assign=1
|
||||
Ipv6Address=::
|
||||
Ipv6PrefixLength=0
|
||||
Ipv6PrioritizeRemote=0
|
||||
Ipv6InterfaceMetric=0
|
||||
Ipv6NameAssign=1
|
||||
Ipv6DnsAddress=::
|
||||
Ipv6Dns2Address=::
|
||||
Ipv6Prefix=0000000000000000
|
||||
Ipv6InterfaceId=0000000000000000
|
||||
DisableClassBasedDefaultRoute=0
|
||||
DisableMobility=0
|
||||
NetworkOutageTime=720
|
||||
IDI=
|
||||
IDR=
|
||||
ImsConfig=0
|
||||
IdiType=0
|
||||
IdrType=0
|
||||
ProvisionType=0
|
||||
PreSharedKey=
|
||||
CacheCredentials=0
|
||||
NumCustomPolicy=1
|
||||
CustomIPSecPolicies=030000000400000005000000050000000200000000000000
|
||||
NumEku=0
|
||||
UseMachineRootCert=0
|
||||
Disable_IKEv2_Fragmentation=0
|
||||
PlumbIKEv2TSAsRoutes=0
|
||||
NumServers=0
|
||||
RouteVersion=1
|
||||
NumRoutes=0
|
||||
NumNrptRules=0
|
||||
AutoTiggerCapable=0
|
||||
NumAppIds=0
|
||||
NumClassicAppIds=0
|
||||
SecurityDescriptor=
|
||||
ApnInfoProviderId=
|
||||
ApnInfoUsername=
|
||||
ApnInfoPassword=
|
||||
ApnInfoAccessPoint=
|
||||
ApnInfoAuthentication=1
|
||||
ApnInfoCompression=0
|
||||
DeviceComplianceEnabled=0
|
||||
DeviceComplianceSsoEnabled=0
|
||||
DeviceComplianceSsoEku=
|
||||
DeviceComplianceSsoIssuer=
|
||||
FlagsSet=0
|
||||
Options=0
|
||||
DisableDefaultDnsSuffixes=0
|
||||
NumTrustedNetworks=0
|
||||
NumDnsSearchSuffixes=0
|
||||
PowershellCreatedProfile=0
|
||||
ProxyFlags=0
|
||||
ProxySettingsModified=0
|
||||
ProvisioningAuthority=
|
||||
AuthTypeOTP=0
|
||||
GREKeyDefined=0
|
||||
NumPerAppTrafficFilters=0
|
||||
AlwaysOnCapable=0
|
||||
DeviceTunnel=0
|
||||
PrivateNetwork=0
|
||||
ManagementApp=
|
||||
|
||||
NETCOMPONENTS=
|
||||
ms_msclient=1
|
||||
ms_server=1
|
||||
|
||||
MEDIA=rastapi
|
||||
Port=VPN2-0
|
||||
Device=WAN Miniport (IKEv2)
|
||||
|
||||
DEVICE=vpn
|
||||
PhoneNumber=il-tlv.prod.surfshark.com
|
||||
AreaCode=
|
||||
CountryCode=0
|
||||
CountryID=0
|
||||
UseDialingRules=0
|
||||
Comment=
|
||||
FriendlyName=
|
||||
LastSelectedPhone=0
|
||||
PromoteAlternates=0
|
||||
TryNextAlternateOnFail=1
|
||||
|
@@ -1,457 +0,0 @@
|
||||
using System.IO;
|
||||
using DotRas;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
using NAudio.CoreAudioApi;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.ServiceProcess;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Serilog.Core;
|
||||
using Serilog.Sinks.File;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace NetWork
|
||||
{
|
||||
class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// this function gets an array of service names, and start or stop command, and it runs on the array and
|
||||
/// </summary>
|
||||
/// <param name="service"></param>
|
||||
/// <param name="stop"></param>
|
||||
public static void Servicer(string[] service, bool stop = true) {
|
||||
foreach (string s in service) {
|
||||
Servicer(s, stop);
|
||||
}
|
||||
}
|
||||
private static ServiceController[] GetServices(string service) {
|
||||
Regex regex = new(service, RegexOptions.IgnoreCase);
|
||||
|
||||
|
||||
List<ServiceController> ServiceList = new List<ServiceController>();
|
||||
foreach (var services in ServiceController.GetServices()) {
|
||||
if (regex.IsMatch(services.DisplayName)) {
|
||||
ServiceList.Add(services);
|
||||
}
|
||||
}
|
||||
|
||||
return ServiceList.ToArray();
|
||||
}
|
||||
public static void Servicer(string service, bool stop = true) {
|
||||
|
||||
var Services = GetServices(service);
|
||||
if (stop) {
|
||||
foreach (var ser in Services) {
|
||||
try {
|
||||
ser.Stop();
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (var ser in Services) {
|
||||
try {
|
||||
|
||||
ser.Start();
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static bool Earphones() {
|
||||
string data = System.IO.File.ReadAllText($"{AppDomain.CurrentDomain.BaseDirectory}\\Other\\earphones.json");
|
||||
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
dynamic array = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(data, typeof(JArray));
|
||||
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
var device = new MMDeviceEnumerator();
|
||||
var Devices = device.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
|
||||
foreach (var Device in Devices) {
|
||||
foreach (string ob in array!) {
|
||||
if (Device.FriendlyName.Contains(ob)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String of paths
|
||||
/// </summary>
|
||||
public static string[] StringsOfPaths = System.IO.Directory.GetFiles(@"C:\Program Files\Google\Drive File Stream\", "GoogleDriveFS.exe", System.IO.SearchOption.AllDirectories);
|
||||
public static Dictionary<string, string> progs = new() { { "GoogleDriveFS", StringsOfPaths[^1] }, { "qbittorrent", @"C:\Program Files\qBittorrent\qbittorrent.exe" }, { "Surfshark", @"C:\Program Files (x86)\Surfshark\Surfshark.exe" }, { "cmd", @"C:\Windows\System32\cmd.exe" }, { "teamviewer", @"C:\Program Files (x86)\TeamViewer\TeamViewer.exe" }, { "tv", @"C:\Program Files (x86)\TeamViewer\TeamViewer_Service.exe" } };
|
||||
public static Dictionary<string, string> paths = new() { { StringsOfPaths[^1], "GoogleDriveFS.exe" }, { @"C:\Program Files\qBittorrent\qbittorrent.exe", "qbittorrent.exe" }, { @"C:\Program Files (x86)\Surfshark\Surfshark.exe", "Surfshark" }, { @"C:\Windows\System32\cmd.exe", "cmd" }, { @"C:\Program Files (x86)\TeamViewer\TeamViewer.exe", "teamviewer" }, { @"C:\Program Files (x86)\TeamViewer\TeamViewer_Service.exe", "tv" } };
|
||||
//public static string[,] progs = new string[2,5] { { "GoogleDriveFS.exe", "googledrivesync.exe", "qbittorrent.exe", "Surfshark.exe", "mstsc.exe" },{ StringsOfPaths[StringsOfPaths.Length-1], "C:\\Program Files\\Google\\Drive\\googledrivesync.exe", "C:\\Program Files\\qBittorrent\\qbittorrent.exe", "C:\\Program Files (x86)\\Surfshark\\Surfshark.exe" , "mstsc.exe" } };
|
||||
/// <summary>
|
||||
/// This Function Stops the RDP connection to the office computer. it takes 'stop' parameter. if it is true, it stops the rdp. otherwise, it starts it.
|
||||
/// </summary>
|
||||
/// <param name="stop">A bool parameter. it swiches between stopping (default) and starting rdp session.</param>
|
||||
public static void StopRDP(bool stop = true) {
|
||||
|
||||
if (stop) {
|
||||
Process[] ids = Process.GetProcessesByName("mstsc");
|
||||
foreach (var id in ids) {
|
||||
//using (ILogger log=Logger)
|
||||
//{
|
||||
// log.Debug(id.MainWindowTitle);
|
||||
//}
|
||||
Regex rdp = new("(משרדוש.rdp|161.2)");
|
||||
if (rdp.IsMatch(id.MainWindowTitle) || id.MainWindowTitle.Equals("חיבור לשולחן עבודה מרוחק")) {
|
||||
id.Kill();
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
} else {
|
||||
Process[] ids = Process.GetProcessesByName("mstsc");
|
||||
if (ids.Length < 1) {
|
||||
StartProgram("rdp");
|
||||
} else {
|
||||
bool started = false;
|
||||
foreach (var id in ids) {
|
||||
Regex rdp = new("(משרדוש.rdp|161.2)");
|
||||
|
||||
if (rdp.IsMatch(id.MainWindowTitle) || id.MainWindowTitle.Equals("חיבור לשולחן עבודה מרוחק")) {
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
if (!started) {
|
||||
StartProgram("rdp");
|
||||
}
|
||||
|
||||
Console.WriteLine("");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="connect"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Dial(bool connect = true) {
|
||||
if (connect) {
|
||||
RasDialer rasDialer = new();
|
||||
rasDialer.AllowUseStoredCredentials = true;
|
||||
rasDialer.PhoneBookPath = @"Other\ek.pbk";
|
||||
rasDialer.PhoneNumber = "ek";
|
||||
rasDialer.EntryName = "ek";
|
||||
rasDialer.DialAsync();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// GetProgram switches between the name and the path of the file. if the name is given, it returns the path. if the path is given, it returns the name.
|
||||
/// </summary>
|
||||
/// <param name="NameOrPath">file or path of the program</param>
|
||||
/// <returns>path if name has given, name if path has given. empty string if found nothing.</returns>
|
||||
public static string GetProgram(string NameOrPath) {
|
||||
/*
|
||||
this function decides if the program is a name, or a location.
|
||||
if it is a location, it returns the name of the program
|
||||
if it is a name, it returns the location
|
||||
otherwise, it returns empty string
|
||||
*/
|
||||
|
||||
if (progs.ContainsKey(NameOrPath)) {
|
||||
return progs[NameOrPath];
|
||||
}
|
||||
if (paths.ContainsKey(NameOrPath)) {
|
||||
return paths[NameOrPath];
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
public static void StopSurfshark() {
|
||||
Process.GetProcesses()
|
||||
.Where(x => x.ProcessName.StartsWith("surf", StringComparison.OrdinalIgnoreCase))
|
||||
.ToList()
|
||||
.ForEach(x => x.Kill());
|
||||
|
||||
}
|
||||
public static void StopProgram(string[] Name, bool mute = true) {
|
||||
foreach (string name in Name) {
|
||||
try {
|
||||
System.Text.RegularExpressions.Regex vpnRegEx = new(@"[Ss][Uu][Rr][Ff][Ss][Hh][Aa][Rr][Kk]");
|
||||
if (vpnRegEx.IsMatch(name)) {
|
||||
StopSurfshark();
|
||||
} else if (progs.ContainsKey(name)) {
|
||||
Process[] p = Process.GetProcessesByName(name);
|
||||
foreach (Process proc in p) {
|
||||
proc.Kill(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (name.Contains("mstsc") || name.Contains("rdp")) {
|
||||
StopRDP();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
MuteSystem(mute);
|
||||
}
|
||||
public static void StartProgram(string[] Name, bool mute = false) {
|
||||
Thread trd;
|
||||
|
||||
foreach (var process_name in Name) {
|
||||
if (process_name.Contains("rdp") || process_name.Contains("mstsc")) {
|
||||
StopRDP(false);
|
||||
continue;
|
||||
} else if (Process.GetProcessesByName(process_name).Length < 1) {
|
||||
string process;
|
||||
if (progs.ContainsKey(process_name)) {
|
||||
process = progs[process_name];
|
||||
} else if (paths.ContainsKey(process_name)) {
|
||||
process = process_name;
|
||||
} else {
|
||||
process = @"C:\Windows\System32\rundll32.exe";
|
||||
}
|
||||
trd = new(new ThreadStart(() => Process.Start(process)));
|
||||
trd.Start();
|
||||
;
|
||||
}
|
||||
}
|
||||
MuteSystem(mute);
|
||||
}
|
||||
public static string GetWifiNetwork() {
|
||||
SimpleWifi.Win32.WlanClient wlan = new();
|
||||
string wifiname;
|
||||
try {
|
||||
wifiname = wlan.Interfaces[0].CurrentConnection.profileName;
|
||||
|
||||
}
|
||||
catch {
|
||||
wifiname = "";
|
||||
}
|
||||
return wifiname;
|
||||
|
||||
}
|
||||
public static bool? IsItGoodWifi(string currentWifi) {
|
||||
Regex regex = new(currentWifi);
|
||||
bool? goodWifi;
|
||||
goodWifi = regex.IsMatch("Oliver Oliver5 Oliver x018_497622 TNCAPE5A34D MSBR Azrieli_Modiin_WIFI lu shalmata mickey Mickey Network 192.168.1. Silmarill wintunshark0 saret Saret huji-meonot") ? true : (regex.IsMatch("HUJI-netX eduroam HUJI-guest 132.64") ? false : null);
|
||||
|
||||
return goodWifi;
|
||||
}
|
||||
static bool LanEthernet(System.Net.NetworkInformation.NetworkInterface networkAdapter) {
|
||||
if ((networkAdapter.Name.Contains("Ethernet") || (networkAdapter.NetworkInterfaceType.ToString().Contains("Ethernet"))) && (networkAdapter.OperationalStatus == OperationalStatus.Up)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool IgnoreLan(System.Net.NetworkInformation.NetworkInterface networkAdapter) {
|
||||
if (!(networkAdapter.Name.Contains("Bluetooth")) && (!(networkAdapter.Description.Contains("TAP"))) && (!(networkAdapter.Description.Contains("Hyper-V")))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static string? GetLan(System.Net.NetworkInformation.NetworkInterface networkAdapter) {
|
||||
if (LanEthernet(networkAdapter) && IgnoreLan(networkAdapter)) {
|
||||
return networkAdapter.GetPhysicalAddress().ToString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static bool GetVpn(System.Net.NetworkInformation.NetworkInterface net) {
|
||||
if (net.Name.Contains("Surfshark") || net.Name.Contains("shark") || net.Description.Contains("TAP")) {
|
||||
return net.OperationalStatus.ToString().Equals("Up");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static Dictionary<string, dynamic> GetNetwork() {
|
||||
Dictionary<string, dynamic> net_dict = new() { { "vpn", false }, { "lan", false }, { "good_lan", false }, { "ek", false } };
|
||||
System.Net.NetworkInformation.NetworkInterface[] nets = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
|
||||
string getlan = "";
|
||||
string? lannull;
|
||||
bool getgoodland = false;
|
||||
string? getwifi;
|
||||
getwifi = GetWifiNetwork();
|
||||
foreach (var net in nets) {
|
||||
if (net.Name == "ek") {
|
||||
net_dict["ek"] |= true;
|
||||
}
|
||||
|
||||
net_dict["vpn"] |= GetVpn(net);
|
||||
lannull = GetLan(net);
|
||||
if (lannull is not null) {
|
||||
getlan = lannull;
|
||||
}
|
||||
if (AllowedMac(net.GetPhysicalAddress().ToString())) {
|
||||
getgoodland |= true;
|
||||
}
|
||||
|
||||
}
|
||||
net_dict.Add("Wi-Fi", IsItGoodWifi(getwifi)!);
|
||||
net_dict["good_lan"] = getgoodland;
|
||||
if (getlan.Length > 0) {
|
||||
net_dict["lan"] = true;
|
||||
}
|
||||
|
||||
//net_dict.Add("good_lan", AllowedMac());
|
||||
return net_dict;
|
||||
}
|
||||
private static string HirarcyNetworks(Dictionary<string, dynamic> network_dictionary) {
|
||||
if (network_dictionary["vpn"]) {
|
||||
return "vpn";
|
||||
} else if (network_dictionary["ek"]) {
|
||||
return "ek";
|
||||
} else if (network_dictionary["good_lan"]) {
|
||||
return "good_lan";
|
||||
} else if (network_dictionary["lan"]) {
|
||||
return "lan";
|
||||
}
|
||||
return "Wi-Fi";
|
||||
|
||||
}
|
||||
public static bool AllowedMac(string mac, string?[] those_are_the_AllowedMacs = null) {
|
||||
string[] AllowedMac_adresses;
|
||||
if (!(those_are_the_AllowedMacs is null)) {
|
||||
AllowedMac_adresses = those_are_the_AllowedMacs!;
|
||||
} else {
|
||||
AllowedMac_adresses = new string[] { "00E04C6813E4" };
|
||||
}
|
||||
foreach (var mac_address in AllowedMac_adresses) {
|
||||
if (mac_address.Equals(mac)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
public static bool AllowedMac(string[] mac, string?[] those_are_the_AllowedMacs = null) {
|
||||
foreach (var single_mac in mac) {
|
||||
if (AllowedMac(single_mac, those_are_the_AllowedMacs)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static void StartProgram(string process_name) {
|
||||
if (process_name.Contains("rdp") || process_name.Contains("mstsc")) {
|
||||
Process.Start("mstsc.exe", $"{Environment.ExpandEnvironmentVariables("%USERPROFILE%")}/Documents/משרדוש.rdp");
|
||||
} else if (Process.GetProcessesByName(process_name).Length < 1) {
|
||||
string process;
|
||||
if (progs.ContainsKey(process_name)) {
|
||||
process = progs[process_name];
|
||||
} else if (paths.ContainsKey(process_name)) {
|
||||
process = process_name;
|
||||
} else {
|
||||
process = @"C:\Windows\System32\rundll32.exe";
|
||||
}
|
||||
Process.Start(process);
|
||||
}
|
||||
}
|
||||
public static void MuteSystem(bool mute = true) {
|
||||
MMDeviceEnumerator mMDeviceEnumerator = new();
|
||||
mMDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia).AudioEndpointVolume.Mute = mute;
|
||||
}
|
||||
public static void DoTheSchtik(bool Run) {
|
||||
//using StreamReader read = File.ReadAllText("Other/def.json");
|
||||
//var networkAutomation = JObject()
|
||||
if (Run) {
|
||||
var network_connection = GetNetwork();
|
||||
string[] programs_to_run;
|
||||
string[] programs_to_stop;
|
||||
string[]? services_to_stop;
|
||||
string[]? services_to_start;
|
||||
bool mute;
|
||||
switch (HirarcyNetworks(network_connection)) {
|
||||
case "vpn":
|
||||
programs_to_run = new string[] { "GoogleDriveFS", "qbittorrent", "Surfshark" };
|
||||
programs_to_stop = new string[] { "rdp", "tv", "teamviewer" };
|
||||
services_to_start = new string[] { "Surf" };
|
||||
services_to_stop = new string[] { "teamviewer" };
|
||||
mute = false;
|
||||
break;
|
||||
case "ek":
|
||||
programs_to_run = new string[] { "rdp", "GoogleDriveFS" };
|
||||
programs_to_stop = new string[] { "qbittorrent", "Surfshark" };
|
||||
services_to_stop = new string[] { "Surf" };
|
||||
services_to_start = null;
|
||||
mute = false;
|
||||
break;
|
||||
case "good_lan":
|
||||
programs_to_run = new string[] { "GoogleDriveFS", "qbittorrent", "Surfshark" };
|
||||
services_to_start = new string[] { "Surf" };
|
||||
programs_to_stop = new string[] { "rdp" };
|
||||
services_to_stop = null;
|
||||
mute = false;
|
||||
break;
|
||||
case "lan":
|
||||
programs_to_run = new string[] { "rdp", "GoogleDriveFS" };
|
||||
programs_to_stop = new string[] { "qbittorrent", "Surfshark" };
|
||||
services_to_stop = new string[] { "Surf" };
|
||||
services_to_start = null;
|
||||
mute = false;
|
||||
Dial(true);
|
||||
break;
|
||||
default:
|
||||
if (network_connection["Wi-Fi"]) {
|
||||
programs_to_run = new string[] { "GoogleDriveFS", "qbittorrent", "Surfshark" };
|
||||
services_to_start = new string[] { "Surf" };
|
||||
programs_to_stop = new string[] { "rdp" };
|
||||
services_to_stop = null;
|
||||
mute = false;
|
||||
break;
|
||||
} else {
|
||||
programs_to_run = new string[] { "GoogleDriveFS" };
|
||||
programs_to_stop = new string[] { "qbittorrent", "Surfshark", "rdp" };
|
||||
services_to_stop = new string[] { "Surf" };
|
||||
services_to_start = null;
|
||||
mute = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (Earphones()) {
|
||||
mute = false;
|
||||
}
|
||||
|
||||
|
||||
if (programs_to_run is not null) {
|
||||
StartProgram(programs_to_run, mute);
|
||||
MuteSystem(mute);
|
||||
}
|
||||
if (programs_to_stop is not null) {
|
||||
StopProgram(programs_to_stop, mute);
|
||||
MuteSystem(mute);
|
||||
}
|
||||
|
||||
if (services_to_start is not null) {
|
||||
Servicer(services_to_start, false);
|
||||
}
|
||||
if (services_to_stop is not null) {
|
||||
Servicer(services_to_stop);
|
||||
}
|
||||
}
|
||||
StartTask();
|
||||
System.Windows.Forms.Application.Exit();
|
||||
}
|
||||
private static void StartTask() {
|
||||
TaskService task = new();
|
||||
task.FindTask("StartUp and Run").Run();
|
||||
}
|
||||
public static bool IniData() {
|
||||
return System.IO.File.ReadAllText("Other\\Data.ini").Equals("RunNetwork");
|
||||
}
|
||||
static void Main(string[] args) {
|
||||
Log.Logger = new LoggerConfiguration().WriteTo.File("Logs/NetworkLog.log", LogEventLevel.Debug,
|
||||
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}[{Level: u3}] {Message:lj}{NewLine}",
|
||||
rollingInterval: RollingInterval.Minute).CreateLogger();
|
||||
|
||||
//IgnoreFile.M();
|
||||
DoTheSchtik(IniData());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
73
NetWork/Properties/Resources.Designer.cs
generated
73
NetWork/Properties/Resources.Designer.cs
generated
@@ -1,73 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NetWork.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NetWork.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] ek {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ek", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ek" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Other\ek.pbk;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
@@ -1,211 +0,0 @@
|
||||
from typing import Sequence, Union
|
||||
import wmi
|
||||
import subprocess
|
||||
import glob
|
||||
import re
|
||||
import pywinauto
|
||||
import pywin
|
||||
import psutil
|
||||
import keyboard
|
||||
processes = [p for p in wmi.WMI().Win32_Process() if p.Name in ["GoogleDriveFS.exe",
|
||||
"googledrivesync.exe", "qbittorrent.exe", "Surfshark.exe", "mstsc.exe"]]
|
||||
|
||||
def rdp(start_rdp_software: bool = True):
|
||||
'''rdp detects if the rdp software is running on the computer. if the start_rdp_software is true at calling, the function will start the rdp if there is no program that runs.
|
||||
elsewise, it will close it
|
||||
|
||||
:param start_rdp_software: switch. it can be called to run(true) or stop(false) the rdp software, defaults to True
|
||||
:type start_rdp_software: bool, optional
|
||||
'''
|
||||
if start_rdp_software:
|
||||
running = False
|
||||
for process in processes:
|
||||
if process.CommandLine == '"mstsc.exe" "D:\\Drive\\מסמכים\\vms\\משרדוש.rdp"' or process.CommandLine == '"C:\\Windows\\System32\\mstsc.exe" /v:"132.64.161.2"':
|
||||
running = True
|
||||
if not running:
|
||||
subprocess.Popen('"mstsc.exe" "D:\\Drive\\מסמכים\\vms\\משרדוש.rdp"',
|
||||
creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE, shell=True)
|
||||
else:
|
||||
for process in processes:
|
||||
if process.CommandLine == '"mstsc.exe" "D:\\Drive\\מסמכים\\vms\\משרדוש.rdp"' or process.CommandLine == '"C:\\Windows\\System32\\mstsc.exe" /v:"132.64.161.2"':
|
||||
try:
|
||||
process.Terminate()
|
||||
except:
|
||||
continue
|
||||
|
||||
def allowd_macs(mac_address: Union[dict, tuple, str]):
|
||||
allowed = ['00-E0-4C-68-13-E4']
|
||||
if isinstance(mac_address, str):
|
||||
if mac_address in allowed:
|
||||
return True
|
||||
for allowed_elements in allowed:
|
||||
if allowed_elements in mac_address:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def start_process(process_list: list):
|
||||
start = {
|
||||
"Surfshark.exe": 'C:/Program Files (x86)/Surfshark/Surfshark.exe',
|
||||
'qbittorrent.exe': "C:/Program Files/qBittorrent/qbittorrent.exe", "GoogleDriveFS.exe": glob.glob(
|
||||
'C:/Program Files/Google/Drive File Stream/*/GoogleDriveFS.exe', recursive=True)[0],
|
||||
"googledrivesync.exe": 'C:/Program Files/Google/Drive/googledrivesync.exe'
|
||||
}
|
||||
for p in process_list:
|
||||
start_this_process = False
|
||||
for k in processes:
|
||||
if p == k.Name:
|
||||
start_this_process = True
|
||||
if not start_this_process:
|
||||
subprocess.Popen(start[p], shell=True, creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE)
|
||||
|
||||
|
||||
def stop_process(process_list: list):
|
||||
for proc in process_list:
|
||||
for k in processes:
|
||||
if proc == k.Name:
|
||||
try:
|
||||
k.Terminate()
|
||||
except:
|
||||
continue
|
||||
|
||||
|
||||
def disallow(process_list: list = ["GoogleDriveFS.exe", "googledrivesync.exe"],
|
||||
mute: bool = True, run_process: list = None):
|
||||
stop_process(process_list)
|
||||
if run_process:
|
||||
start_process(run_process)
|
||||
if mute:
|
||||
subprocess.run(["powershell", "-command", "Set-AudioDevice -PlaybackMute $true"],
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
else:
|
||||
subprocess.run(["powershell", "-command", "Set-AudioDevice -PlaybackMute $false"],
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
|
||||
|
||||
def allow(process_list: list = ["Surfshark.exe", 'qbittorrent.exe'], unmute: bool = True):
|
||||
start_process(process_list)
|
||||
if unmute:
|
||||
subprocess.run(["powershell", "-command", "Set-AudioDevice -PlaybackMute $false"],
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
else:
|
||||
subprocess.run(["powershell", "-command", "Set-AudioDevice -PlaybackMute $true"],
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
|
||||
|
||||
def _actiavte_rasdial():
|
||||
pywinauto.findwindows.find_window()
|
||||
|
||||
|
||||
def dial_connect(connection: str = 'Connected to\nek\nCommand completed successfully.\n'):
|
||||
connected = False if connection == 'Connected to\nek\nCommand completed successfully.\n' else True
|
||||
if connected:
|
||||
subprocess.Popen(
|
||||
'rasphone ek',
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE)
|
||||
# _actiavte_rasdial()
|
||||
# keyboard.press_and_release('alt')
|
||||
keyboard.press_and_release('enter')
|
||||
# _actiavte_rasdial()
|
||||
keyboard.press_and_release('enter')
|
||||
subprocess.Popen(["powershell", "-command", "Set-AudioDevice -PlaybackMute $false"],
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE)
|
||||
|
||||
def _hiercy(network_status: dict):
|
||||
if network_status["ek"]:
|
||||
return "ek"
|
||||
elif network_status["good_lan"]:
|
||||
return 'good_lan'
|
||||
elif network_status["lan"]:
|
||||
return "lan"
|
||||
return "Wi-Fi"
|
||||
|
||||
|
||||
def get_net_status(supreme_mac: Union[str, list, tuple, set] = '00-E0-4C-68-13-F8'):
|
||||
|
||||
nets, stats = psutil.net_if_addrs(), psutil.net_if_stats()
|
||||
networks = subprocess.Popen('pwsh -executionPolicy bypass -command "Get-NetConnectionProfile"',
|
||||
shell=True, stdout=subprocess.PIPE).communicate()[0].decode()
|
||||
macs = {nets[key][0][1]: key.strip('\u200f') for key in nets if stats[key][0]}
|
||||
lan_mac = get_lan(supreme_mac, macs)
|
||||
profiles = [Net[19:].strip('\u200f') for net in networks.split('\r\n\r\n')
|
||||
for Net in net.split('\r\n') if 'InterfaceAlias :' in Net]
|
||||
wifi = [net[15:].split('\r\n')[0] for net in networks.split('Name') if 'Wi-Fi' in net]
|
||||
wifi = wifi[0] if wifi else None
|
||||
vpn = [key.strip('\u200f') for key in nets if stats[key][0] and re.search(r'(surf|shark)', key)]
|
||||
return {"Wi-Fi": wifi, "lan": (lan_mac), "ek": ("ek" in profiles), "vpn": vpn, "good_lan": allowd_macs(macs)} if vpn else {"Wi-Fi": wifi, "lan": (lan_mac), "ek": ("ek" in profiles), "good_lan": allowd_macs(macs)}
|
||||
|
||||
|
||||
def get_lan(macs: Union[str, list, tuple, set] = '00-E0-4C-68-13-F8', dict_of_macs: dict = None):
|
||||
SMAC = ['00-E0-4C-68-13-F8', "00-FF-33-C8-0F-88"]
|
||||
if isinstance(macs, str) and macs in dict_of_macs:
|
||||
return True
|
||||
elif not isinstance(macs, str):
|
||||
for m in macs:
|
||||
if m in SMAC:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_status(supreme_mac: Union[str, list, tuple, set] = '00-E0-4C-68-13-F8'):
|
||||
wifi = {
|
||||
"allowed":
|
||||
["Oliver", "Oliver5", "Oliver", "x018_497622", "TNCAPE5A34D", "MSBR", "Azrieli_Modiin_WIFI", "lu shalmata",
|
||||
"mickey", "Mickey", "Network", "192.168.1.", "Silmarill", "wintunshark0", "saret", "Saret", "huji-meonot"],
|
||||
"disallowed": ["HUJI-netX", "eduroam", "HUJI-guest", "132.64"]}
|
||||
network_status = get_net_status(supreme_mac)
|
||||
hierarchy = _hiercy(network_status)
|
||||
if hierarchy == "Wi-Fi":
|
||||
current_network = network_status["Wi-Fi"].split(' ')[0]
|
||||
w = 0 if re.search(current_network, " ".join(wifi["disallowed"])) else 1
|
||||
return {"Wi-Fi": w, "vpn": network_status["vpn"]} if network_status.get("vpn") else {"Wi-Fi": w}
|
||||
elif hierarchy == 'good_lan':
|
||||
return {'good_lan': True}
|
||||
elif hierarchy == "lan":
|
||||
return {"lan": network_status["lan"], "vpn": network_status["vpn"]} if network_status.get("vpn") else {"lan": network_status["lan"]}
|
||||
return {"ek": network_status["ek"], "vpn": network_status["vpn"]} if network_status.get("vpn") else {"ek": network_status["ek"]}
|
||||
|
||||
|
||||
def do_the_schtik(supreme_mac: str = '00-E0-4C-68-13-F8', discontinue: str = None):
|
||||
network_status = get_status(supreme_mac)
|
||||
if network_status.get("vpn"):
|
||||
allow(["qbittorrent.exe", "GoogleDriveFS.exe", "googledrivesync.exe", "Surfshark.exe"])
|
||||
rdp(False)
|
||||
if network_status.get("lan"):
|
||||
dial_connect(discontinue)
|
||||
elif network_status.get('Wi-Fi') and network_status['Wi-Fi'] == 0:
|
||||
allow(["qbittorrent.exe", "GoogleDriveFS.exe", "googledrivesync.exe", "Surfshark.exe"], False)
|
||||
elif network_status.get('Wi-Fi') and network_status['Wi-Fi'] == 1:
|
||||
allow(["qbittorrent.exe", "GoogleDriveFS.exe", "googledrivesync.exe", "Surfshark.exe"])
|
||||
rdp(False)
|
||||
elif network_status.get("good_lan") and network_status["good_lan"]:
|
||||
allow(["qbittorrent.exe", "GoogleDriveFS.exe", "googledrivesync.exe", "Surfshark.exe"])
|
||||
rdp(False)
|
||||
else:
|
||||
if network_status.get("lan"):
|
||||
dial_connect(discontinue)
|
||||
disallow(["Surfshark.exe", 'qbittorrent.exe'], False,
|
||||
run_process=["GoogleDriveFS.exe", "googledrivesync.exe"])
|
||||
rdp()
|
||||
elif network_status.get("ek"):
|
||||
disallow(["Surfshark.exe", 'qbittorrent.exe'], False,
|
||||
run_process=["GoogleDriveFS.exe", "googledrivesync.exe"])
|
||||
rdp()
|
||||
else:
|
||||
disallow(["Surfshark.exe", 'qbittorrent.exe'], run_process=["GoogleDriveFS.exe", "googledrivesync.exe"])
|
||||
|
||||
|
||||
def main():
|
||||
discontinue = subprocess.Popen(
|
||||
'rasdial',
|
||||
shell=True, creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE).communicate()[0].decode().split(
|
||||
"\r\n")[0]
|
||||
do_the_schtik(discontinue=discontinue)
|
||||
|
||||
exit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
main()
|
||||
# get_net_status()
|
Binary file not shown.
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Windows.Common.ManagedWifi")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Windows.Common.ManagedWifi")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ddfe602d-a0b5-4429-8b5c-e99155b6777a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
File diff suppressed because it is too large
Load Diff
@@ -1,800 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
|
||||
namespace Windows.Common.Wifi
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a client to the Zeroconf (Native Wifi) service.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is the entrypoint to Native Wifi management. To manage WiFi settings, create an instance
|
||||
/// of this class.
|
||||
/// </remarks>
|
||||
public class WlanClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Wifi network interface.
|
||||
/// </summary>
|
||||
public class WlanInterface
|
||||
{
|
||||
private WlanClient client;
|
||||
private Wlan.WlanInterfaceInfo info;
|
||||
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Represents a method that will handle <see cref="WlanNotification"/> events.
|
||||
/// </summary>
|
||||
/// <param name="notifyData">The notification data.</param>
|
||||
public delegate void WlanNotificationEventHandler(Wlan.WlanNotificationData notifyData);
|
||||
|
||||
/// <summary>
|
||||
/// Represents a method that will handle <see cref="WlanConnectionNotification"/> events.
|
||||
/// </summary>
|
||||
/// <param name="notifyData">The notification data.</param>
|
||||
/// <param name="connNotifyData">The notification data.</param>
|
||||
public delegate void WlanConnectionNotificationEventHandler(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData);
|
||||
|
||||
/// <summary>
|
||||
/// Represents a method that will handle <see cref="WlanReasonNotification"/> events.
|
||||
/// </summary>
|
||||
/// <param name="notifyData">The notification data.</param>
|
||||
/// <param name="reasonCode">The reason code.</param>
|
||||
public delegate void WlanReasonNotificationEventHandler(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when an event of any kind occurs on a WLAN interface.
|
||||
/// </summary>
|
||||
public event WlanNotificationEventHandler WlanNotification;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a WLAN interface changes connection state.
|
||||
/// </summary>
|
||||
public event WlanConnectionNotificationEventHandler WlanConnectionNotification;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a WLAN operation fails due to some reason.
|
||||
/// </summary>
|
||||
public event WlanReasonNotificationEventHandler WlanReasonNotification;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event queue
|
||||
private bool queueEvents;
|
||||
private AutoResetEvent eventQueueFilled = new AutoResetEvent(false);
|
||||
private Queue<object> eventQueue = new Queue<object>();
|
||||
|
||||
private struct WlanConnectionNotificationEventData
|
||||
{
|
||||
public Wlan.WlanNotificationData notifyData;
|
||||
public Wlan.WlanConnectionNotificationData connNotifyData;
|
||||
}
|
||||
private struct WlanReasonNotificationData
|
||||
{
|
||||
public Wlan.WlanNotificationData notifyData;
|
||||
public Wlan.WlanReasonCode reasonCode;
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal WlanInterface(WlanClient client, Wlan.WlanInterfaceInfo info)
|
||||
{
|
||||
this.client = client;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a parameter of the interface whose data type is <see cref="int"/>.
|
||||
/// </summary>
|
||||
/// <param name="opCode">The opcode of the parameter.</param>
|
||||
/// <param name="value">The value to set.</param>
|
||||
private void SetInterfaceInt(Wlan.WlanIntfOpcode opCode, int value)
|
||||
{
|
||||
IntPtr valuePtr = Marshal.AllocHGlobal(sizeof(int));
|
||||
Marshal.WriteInt32(valuePtr, value);
|
||||
try
|
||||
{
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanSetInterface(client.clientHandle, info.interfaceGuid, opCode, sizeof(int), valuePtr, IntPtr.Zero));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(valuePtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a parameter of the interface whose data type is <see cref="int"/>.
|
||||
/// </summary>
|
||||
/// <param name="opCode">The opcode of the parameter.</param>
|
||||
/// <returns>The integer value.</returns>
|
||||
private int GetInterfaceInt(Wlan.WlanIntfOpcode opCode)
|
||||
{
|
||||
IntPtr valuePtr;
|
||||
int valueSize;
|
||||
Wlan.WlanOpcodeValueType opcodeValueType;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanQueryInterface(client.clientHandle, info.interfaceGuid, opCode, IntPtr.Zero, out valueSize, out valuePtr, out opcodeValueType));
|
||||
try
|
||||
{
|
||||
return Marshal.ReadInt32(valuePtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(valuePtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="WlanInterface"/> is automatically configured.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if "autoconf" is enabled; otherwise, <c>false</c>.</value>
|
||||
public bool Autoconf
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetInterfaceInt(Wlan.WlanIntfOpcode.AutoconfEnabled) != 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetInterfaceInt(Wlan.WlanIntfOpcode.AutoconfEnabled, value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the BSS type for the indicated interface.
|
||||
/// </summary>
|
||||
/// <value>The type of the BSS.</value>
|
||||
public Wlan.Dot11BssType BssType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Wlan.Dot11BssType) GetInterfaceInt(Wlan.WlanIntfOpcode.BssType);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetInterfaceInt(Wlan.WlanIntfOpcode.BssType, (int)value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state of the interface.
|
||||
/// </summary>
|
||||
/// <value>The state of the interface.</value>
|
||||
public Wlan.WlanInterfaceState InterfaceState
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Wlan.WlanInterfaceState)GetInterfaceInt(Wlan.WlanIntfOpcode.InterfaceState);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel.
|
||||
/// </summary>
|
||||
/// <value>The channel.</value>
|
||||
/// <remarks>Not supported on Windows XP SP2.</remarks>
|
||||
public int Channel
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetInterfaceInt(Wlan.WlanIntfOpcode.ChannelNumber);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the RSSI.
|
||||
/// </summary>
|
||||
/// <value>The RSSI.</value>
|
||||
/// <remarks>Not supported on Windows XP SP2.</remarks>
|
||||
public int RSSI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetInterfaceInt(Wlan.WlanIntfOpcode.RSSI);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current operation mode.
|
||||
/// </summary>
|
||||
/// <value>The current operation mode.</value>
|
||||
/// <remarks>Not supported on Windows XP SP2.</remarks>
|
||||
public Wlan.Dot11OperationMode CurrentOperationMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Wlan.Dot11OperationMode) GetInterfaceInt(Wlan.WlanIntfOpcode.CurrentOperationMode);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attributes of the current connection.
|
||||
/// </summary>
|
||||
/// <value>The current connection attributes.</value>
|
||||
/// <exception cref="Win32Exception">An exception with code 0x0000139F (The group or resource is not in the correct state to perform the requested operation.) will be thrown if the interface is not connected to a network.</exception>
|
||||
public Wlan.WlanConnectionAttributes CurrentConnection
|
||||
{
|
||||
get
|
||||
{
|
||||
int valueSize;
|
||||
IntPtr valuePtr;
|
||||
Wlan.WlanOpcodeValueType opcodeValueType;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanQueryInterface(client.clientHandle, info.interfaceGuid, Wlan.WlanIntfOpcode.CurrentConnection, IntPtr.Zero, out valueSize, out valuePtr, out opcodeValueType));
|
||||
try
|
||||
{
|
||||
return (Wlan.WlanConnectionAttributes)Marshal.PtrToStructure(valuePtr, typeof(Wlan.WlanConnectionAttributes));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(valuePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests a scan for available networks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The method returns immediately. Progress is reported through the <see cref="WlanNotification"/> event.
|
||||
/// </remarks>
|
||||
public void Scan()
|
||||
{
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanScan(client.clientHandle, info.interfaceGuid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a pointer to a available networks list (header + entries) to an array of available network entries.
|
||||
/// </summary>
|
||||
/// <param name="bssListPtr">A pointer to an available networks list's header.</param>
|
||||
/// <returns>An array of available network entries.</returns>
|
||||
private Wlan.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
|
||||
{
|
||||
Wlan.WlanAvailableNetworkListHeader availNetListHeader = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(Wlan.WlanAvailableNetworkListHeader));
|
||||
long availNetListIt = availNetListPtr.ToInt64() + Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));
|
||||
Wlan.WlanAvailableNetwork[] availNets = new Wlan.WlanAvailableNetwork[availNetListHeader.numberOfItems];
|
||||
for (int i = 0; i < availNetListHeader.numberOfItems; ++i)
|
||||
{
|
||||
availNets[i] = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(availNetListIt), typeof(Wlan.WlanAvailableNetwork));
|
||||
availNetListIt += Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
|
||||
}
|
||||
return availNets;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the list of available networks.
|
||||
/// </summary>
|
||||
/// <param name="flags">Controls the type of networks returned.</param>
|
||||
/// <returns>A list of the available networks.</returns>
|
||||
public Wlan.WlanAvailableNetwork[] GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags flags)
|
||||
{
|
||||
IntPtr availNetListPtr;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanGetAvailableNetworkList(client.clientHandle, info.interfaceGuid, flags, IntPtr.Zero, out availNetListPtr));
|
||||
try
|
||||
{
|
||||
return ConvertAvailableNetworkListPtr(availNetListPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(availNetListPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a pointer to a BSS list (header + entries) to an array of BSS entries.
|
||||
/// </summary>
|
||||
/// <param name="bssListPtr">A pointer to a BSS list's header.</param>
|
||||
/// <returns>An array of BSS entries.</returns>
|
||||
private Wlan.WlanBssEntry[] ConvertBssListPtr(IntPtr bssListPtr)
|
||||
{
|
||||
Wlan.WlanBssListHeader bssListHeader = (Wlan.WlanBssListHeader)Marshal.PtrToStructure(bssListPtr, typeof(Wlan.WlanBssListHeader));
|
||||
long bssListIt = bssListPtr.ToInt64() + Marshal.SizeOf(typeof(Wlan.WlanBssListHeader));
|
||||
Wlan.WlanBssEntry[] bssEntries = new Wlan.WlanBssEntry[bssListHeader.numberOfItems];
|
||||
for (int i=0; i<bssListHeader.numberOfItems; ++i)
|
||||
{
|
||||
bssEntries[i] = (Wlan.WlanBssEntry)Marshal.PtrToStructure(new IntPtr(bssListIt), typeof(Wlan.WlanBssEntry));
|
||||
bssListIt += Marshal.SizeOf(typeof(Wlan.WlanBssEntry));
|
||||
}
|
||||
return bssEntries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the basic service sets (BSS) list of all available networks.
|
||||
/// </summary>
|
||||
public Wlan.WlanBssEntry[] GetNetworkBssList()
|
||||
{
|
||||
IntPtr bssListPtr;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, IntPtr.Zero, Wlan.Dot11BssType.Any, false, IntPtr.Zero, out bssListPtr));
|
||||
try
|
||||
{
|
||||
return ConvertBssListPtr(bssListPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(bssListPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the basic service sets (BSS) list of the specified network.
|
||||
/// </summary>
|
||||
/// <param name="ssid">Specifies the SSID of the network from which the BSS list is requested.</param>
|
||||
/// <param name="bssType">Indicates the BSS type of the network.</param>
|
||||
/// <param name="securityEnabled">Indicates whether security is enabled on the network.</param>
|
||||
public Wlan.WlanBssEntry[] GetNetworkBssList(Wlan.Dot11Ssid ssid, Wlan.Dot11BssType bssType, bool securityEnabled)
|
||||
{
|
||||
IntPtr ssidPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ssid));
|
||||
Marshal.StructureToPtr(ssid, ssidPtr, false);
|
||||
try
|
||||
{
|
||||
IntPtr bssListPtr;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, ssidPtr, bssType, securityEnabled, IntPtr.Zero, out bssListPtr));
|
||||
try
|
||||
{
|
||||
return ConvertBssListPtr(bssListPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(bssListPtr);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(ssidPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects to a network defined by a connection parameters structure.
|
||||
/// </summary>
|
||||
/// <param name="connectionParams">The connection paramters.</param>
|
||||
protected void Connect(Wlan.WlanConnectionParameters connectionParams)
|
||||
{
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanConnect(client.clientHandle, info.interfaceGuid, ref connectionParams, IntPtr.Zero));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests a connection (association) to the specified wireless network.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The method returns immediately. Progress is reported through the <see cref="WlanNotification"/> event.
|
||||
/// </remarks>
|
||||
public void Connect(Wlan.WlanConnectionMode connectionMode, Wlan.Dot11BssType bssType, string profile)
|
||||
{
|
||||
Wlan.WlanConnectionParameters connectionParams = new Wlan.WlanConnectionParameters();
|
||||
connectionParams.wlanConnectionMode = connectionMode;
|
||||
connectionParams.profile = profile;
|
||||
connectionParams.dot11BssType = bssType;
|
||||
connectionParams.flags = 0;
|
||||
Connect(connectionParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects (associates) to the specified wireless network, returning either on a success to connect
|
||||
/// or a failure.
|
||||
/// </summary>
|
||||
/// <param name="connectionMode"></param>
|
||||
/// <param name="bssType"></param>
|
||||
/// <param name="profile"></param>
|
||||
/// <param name="connectTimeout"></param>
|
||||
/// <returns></returns>
|
||||
public bool ConnectSynchronously(Wlan.WlanConnectionMode connectionMode, Wlan.Dot11BssType bssType, string profile, int connectTimeout)
|
||||
{
|
||||
queueEvents = true;
|
||||
try
|
||||
{
|
||||
Connect(connectionMode, bssType, profile);
|
||||
while (queueEvents && eventQueueFilled.WaitOne(connectTimeout, true))
|
||||
{
|
||||
lock (eventQueue)
|
||||
{
|
||||
while (eventQueue.Count != 0)
|
||||
{
|
||||
object e = eventQueue.Dequeue();
|
||||
if (e is WlanConnectionNotificationEventData)
|
||||
{
|
||||
WlanConnectionNotificationEventData wlanConnectionData = (WlanConnectionNotificationEventData)e;
|
||||
// Check if the conditions are good to indicate either success or failure.
|
||||
if (wlanConnectionData.notifyData.notificationSource == Wlan.WlanNotificationSource.ACM)
|
||||
{
|
||||
switch ((Wlan.WlanNotificationCodeAcm)wlanConnectionData.notifyData.notificationCode)
|
||||
{
|
||||
case Wlan.WlanNotificationCodeAcm.ConnectionComplete:
|
||||
if (wlanConnectionData.connNotifyData.profileName == profile)
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
queueEvents = false;
|
||||
eventQueue.Clear();
|
||||
}
|
||||
return false; // timeout expired and no "connection complete"
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the specified wireless network.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The method returns immediately. Progress is reported through the <see cref="WlanNotification"/> event.
|
||||
/// </remarks>
|
||||
public void Connect(Wlan.WlanConnectionMode connectionMode, Wlan.Dot11BssType bssType, Wlan.Dot11Ssid ssid, Wlan.WlanConnectionFlags flags)
|
||||
{
|
||||
Wlan.WlanConnectionParameters connectionParams = new Wlan.WlanConnectionParameters();
|
||||
connectionParams.wlanConnectionMode = connectionMode;
|
||||
connectionParams.dot11SsidPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ssid));
|
||||
Marshal.StructureToPtr(ssid, connectionParams.dot11SsidPtr, false);
|
||||
connectionParams.dot11BssType = bssType;
|
||||
connectionParams.flags = flags;
|
||||
Connect(connectionParams);
|
||||
Marshal.DestroyStructure(connectionParams.dot11SsidPtr, ssid.GetType());
|
||||
Marshal.FreeHGlobal(connectionParams.dot11SsidPtr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a profile.
|
||||
/// </summary>
|
||||
/// <param name="profileName">
|
||||
/// The name of the profile to be deleted. Profile names are case-sensitive.
|
||||
/// On Windows XP SP2, the supplied name must match the profile name derived automatically from the SSID of the network. For an infrastructure network profile, the SSID must be supplied for the profile name. For an ad hoc network profile, the supplied name must be the SSID of the ad hoc network followed by <c>-adhoc</c>.
|
||||
/// </param>
|
||||
public void DeleteProfile(string profileName)
|
||||
{
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanDeleteProfile(client.clientHandle, info.interfaceGuid, profileName, IntPtr.Zero));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the profile.
|
||||
/// </summary>
|
||||
/// <param name="flags">The flags to set on the profile.</param>
|
||||
/// <param name="profileXml">The XML representation of the profile. On Windows XP SP 2, special care should be taken to adhere to its limitations.</param>
|
||||
/// <param name="overwrite">If a profile by the given name already exists, then specifies whether to overwrite it (if <c>true</c>) or return an error (if <c>false</c>).</param>
|
||||
/// <returns>The resulting code indicating a success or the reason why the profile wasn't valid.</returns>
|
||||
public Wlan.WlanReasonCode SetProfile(Wlan.WlanProfileFlags flags, string profileXml, bool overwrite)
|
||||
{
|
||||
Wlan.WlanReasonCode reasonCode;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanSetProfile(client.clientHandle, info.interfaceGuid, flags, profileXml, null, overwrite, IntPtr.Zero, out reasonCode));
|
||||
return reasonCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile's XML specification.
|
||||
/// </summary>
|
||||
/// <param name="profileName">The name of the profile.</param>
|
||||
/// <returns>The XML document.</returns>
|
||||
public string GetProfileXml(string profileName)
|
||||
{
|
||||
IntPtr profileXmlPtr;
|
||||
Wlan.WlanProfileFlags flags;
|
||||
Wlan.WlanAccess access;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanGetProfile(client.clientHandle, info.interfaceGuid, profileName, IntPtr.Zero, out profileXmlPtr, out flags,
|
||||
out access));
|
||||
try
|
||||
{
|
||||
return Marshal.PtrToStringUni(profileXmlPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(profileXmlPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the information of all profiles on this interface.
|
||||
/// </summary>
|
||||
/// <returns>The profiles information.</returns>
|
||||
public Wlan.WlanProfileInfo[] GetProfiles()
|
||||
{
|
||||
IntPtr profileListPtr;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanGetProfileList(client.clientHandle, info.interfaceGuid, IntPtr.Zero, out profileListPtr));
|
||||
try
|
||||
{
|
||||
Wlan.WlanProfileInfoListHeader header = (Wlan.WlanProfileInfoListHeader) Marshal.PtrToStructure(profileListPtr, typeof(Wlan.WlanProfileInfoListHeader));
|
||||
Wlan.WlanProfileInfo[] profileInfos = new Wlan.WlanProfileInfo[header.numberOfItems];
|
||||
long profileListIterator = profileListPtr.ToInt64() + Marshal.SizeOf(header);
|
||||
for (int i=0; i<header.numberOfItems; ++i)
|
||||
{
|
||||
Wlan.WlanProfileInfo profileInfo = (Wlan.WlanProfileInfo) Marshal.PtrToStructure(new IntPtr(profileListIterator), typeof(Wlan.WlanProfileInfo));
|
||||
profileInfos[i] = profileInfo;
|
||||
profileListIterator += Marshal.SizeOf(profileInfo);
|
||||
}
|
||||
return profileInfos;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(profileListPtr);
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnWlanConnection(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
|
||||
{
|
||||
if (WlanConnectionNotification != null)
|
||||
WlanConnectionNotification(notifyData, connNotifyData);
|
||||
|
||||
if (queueEvents)
|
||||
{
|
||||
WlanConnectionNotificationEventData queuedEvent = new WlanConnectionNotificationEventData();
|
||||
queuedEvent.notifyData = notifyData;
|
||||
queuedEvent.connNotifyData = connNotifyData;
|
||||
EnqueueEvent(queuedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnWlanReason(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode)
|
||||
{
|
||||
if (WlanReasonNotification != null)
|
||||
WlanReasonNotification(notifyData, reasonCode);
|
||||
if (queueEvents)
|
||||
{
|
||||
WlanReasonNotificationData queuedEvent = new WlanReasonNotificationData();
|
||||
queuedEvent.notifyData = notifyData;
|
||||
queuedEvent.reasonCode = reasonCode;
|
||||
EnqueueEvent(queuedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnWlanNotification(Wlan.WlanNotificationData notifyData)
|
||||
{
|
||||
if (WlanNotification != null)
|
||||
WlanNotification(notifyData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enqueues a notification event to be processed serially.
|
||||
/// </summary>
|
||||
private void EnqueueEvent(object queuedEvent)
|
||||
{
|
||||
lock (eventQueue)
|
||||
eventQueue.Enqueue(queuedEvent);
|
||||
eventQueueFilled.Set();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the network interface of this wireless interface.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The network interface allows querying of generic network properties such as the interface's IP address.
|
||||
/// </remarks>
|
||||
public NetworkInterface NetworkInterface
|
||||
{
|
||||
get
|
||||
{
|
||||
// Do not cache the NetworkInterface; We need it fresh
|
||||
// each time cause otherwise it caches the IP information.
|
||||
foreach (NetworkInterface netIface in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
Guid netIfaceGuid = new Guid(netIface.Id);
|
||||
if (netIfaceGuid.Equals(info.interfaceGuid))
|
||||
{
|
||||
return netIface;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The GUID of the interface (same content as the <see cref="System.Net.NetworkInformation.NetworkInterface.Id"/> value).
|
||||
/// </summary>
|
||||
public Guid InterfaceGuid
|
||||
{
|
||||
get { return info.interfaceGuid; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The description of the interface.
|
||||
/// This is a user-immutable string containing the vendor and model name of the adapter.
|
||||
/// </summary>
|
||||
public string InterfaceDescription
|
||||
{
|
||||
get { return info.interfaceDescription; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The friendly name given to the interface by the user (e.g. "Local Area Network Connection").
|
||||
/// </summary>
|
||||
public string InterfaceName
|
||||
{
|
||||
get { return NetworkInterface.Name; }
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr clientHandle;
|
||||
private uint negotiatedVersion;
|
||||
private Wlan.WlanNotificationCallbackDelegate wlanNotificationCallback;
|
||||
|
||||
private Dictionary<Guid,WlanInterface> ifaces = new Dictionary<Guid,WlanInterface>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of a Native Wifi service client.
|
||||
/// </summary>
|
||||
public WlanClient()
|
||||
{
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanOpenHandle(Wlan.WLAN_CLIENT_VERSION_XP_SP2, IntPtr.Zero, out negotiatedVersion, out clientHandle));
|
||||
try
|
||||
{
|
||||
Wlan.WlanNotificationSource prevSrc;
|
||||
wlanNotificationCallback = new Wlan.WlanNotificationCallbackDelegate(OnWlanNotification);
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanRegisterNotification(clientHandle, Wlan.WlanNotificationSource.All, false, wlanNotificationCallback, IntPtr.Zero, IntPtr.Zero, out prevSrc));
|
||||
}
|
||||
catch
|
||||
{
|
||||
Wlan.WlanCloseHandle(clientHandle, IntPtr.Zero);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
~WlanClient()
|
||||
{
|
||||
Wlan.WlanCloseHandle(clientHandle, IntPtr.Zero);
|
||||
}
|
||||
|
||||
private Wlan.WlanConnectionNotificationData? ParseWlanConnectionNotification(ref Wlan.WlanNotificationData notifyData)
|
||||
{
|
||||
int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanConnectionNotificationData));
|
||||
if (notifyData.dataSize < expectedSize)
|
||||
return null;
|
||||
|
||||
Wlan.WlanConnectionNotificationData connNotifyData =
|
||||
(Wlan.WlanConnectionNotificationData)
|
||||
Marshal.PtrToStructure(notifyData.dataPtr, typeof(Wlan.WlanConnectionNotificationData));
|
||||
if (connNotifyData.wlanReasonCode == Wlan.WlanReasonCode.Success)
|
||||
{
|
||||
IntPtr profileXmlPtr = new IntPtr(
|
||||
notifyData.dataPtr.ToInt64() +
|
||||
Marshal.OffsetOf(typeof(Wlan.WlanConnectionNotificationData), "profileXml").ToInt64());
|
||||
connNotifyData.profileXml = Marshal.PtrToStringUni(profileXmlPtr);
|
||||
}
|
||||
return connNotifyData;
|
||||
}
|
||||
|
||||
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context)
|
||||
{
|
||||
WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null;
|
||||
|
||||
switch(notifyData.notificationSource)
|
||||
{
|
||||
case Wlan.WlanNotificationSource.ACM:
|
||||
switch((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode)
|
||||
{
|
||||
case Wlan.WlanNotificationCodeAcm.ConnectionStart:
|
||||
case Wlan.WlanNotificationCodeAcm.ConnectionComplete:
|
||||
case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail:
|
||||
case Wlan.WlanNotificationCodeAcm.Disconnecting:
|
||||
case Wlan.WlanNotificationCodeAcm.Disconnected:
|
||||
Wlan.WlanConnectionNotificationData? connNotifyData = ParseWlanConnectionNotification(ref notifyData);
|
||||
if (connNotifyData.HasValue)
|
||||
if (wlanIface != null)
|
||||
wlanIface.OnWlanConnection(notifyData, connNotifyData.Value);
|
||||
break;
|
||||
case Wlan.WlanNotificationCodeAcm.ScanFail:
|
||||
{
|
||||
int expectedSize = Marshal.SizeOf(typeof (Wlan.WlanReasonCode));
|
||||
if (notifyData.dataSize >= expectedSize)
|
||||
{
|
||||
Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode) Marshal.ReadInt32(notifyData.dataPtr);
|
||||
if (wlanIface != null)
|
||||
wlanIface.OnWlanReason(notifyData, reasonCode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Wlan.WlanNotificationSource.MSM:
|
||||
switch((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode)
|
||||
{
|
||||
case Wlan.WlanNotificationCodeMsm.Associating:
|
||||
case Wlan.WlanNotificationCodeMsm.Associated:
|
||||
case Wlan.WlanNotificationCodeMsm.Authenticating:
|
||||
case Wlan.WlanNotificationCodeMsm.Connected:
|
||||
case Wlan.WlanNotificationCodeMsm.RoamingStart:
|
||||
case Wlan.WlanNotificationCodeMsm.RoamingEnd:
|
||||
case Wlan.WlanNotificationCodeMsm.Disassociating:
|
||||
case Wlan.WlanNotificationCodeMsm.Disconnected:
|
||||
case Wlan.WlanNotificationCodeMsm.PeerJoin:
|
||||
case Wlan.WlanNotificationCodeMsm.PeerLeave:
|
||||
case Wlan.WlanNotificationCodeMsm.AdapterRemoval:
|
||||
Wlan.WlanConnectionNotificationData? connNotifyData = ParseWlanConnectionNotification(ref notifyData);
|
||||
if (connNotifyData.HasValue)
|
||||
if (wlanIface != null)
|
||||
wlanIface.OnWlanConnection(notifyData, connNotifyData.Value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (wlanIface != null)
|
||||
wlanIface.OnWlanNotification(notifyData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the WLAN interfaces.
|
||||
/// </summary>
|
||||
/// <value>The WLAN interfaces.</value>
|
||||
public WlanInterface[] Interfaces
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr ifaceList;
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanEnumInterfaces(clientHandle, IntPtr.Zero, out ifaceList));
|
||||
try
|
||||
{
|
||||
Wlan.WlanInterfaceInfoListHeader header =
|
||||
(Wlan.WlanInterfaceInfoListHeader) Marshal.PtrToStructure(ifaceList, typeof (Wlan.WlanInterfaceInfoListHeader));
|
||||
Int64 listIterator = ifaceList.ToInt64() + Marshal.SizeOf(header);
|
||||
WlanInterface[] interfaces = new WlanInterface[header.numberOfItems];
|
||||
List<Guid> currentIfaceGuids = new List<Guid>();
|
||||
for (int i = 0; i < header.numberOfItems; ++i)
|
||||
{
|
||||
Wlan.WlanInterfaceInfo info =
|
||||
(Wlan.WlanInterfaceInfo) Marshal.PtrToStructure(new IntPtr(listIterator), typeof (Wlan.WlanInterfaceInfo));
|
||||
listIterator += Marshal.SizeOf(info);
|
||||
WlanInterface wlanIface;
|
||||
currentIfaceGuids.Add(info.interfaceGuid);
|
||||
if (ifaces.ContainsKey(info.interfaceGuid))
|
||||
wlanIface = ifaces[info.interfaceGuid];
|
||||
else
|
||||
wlanIface = new WlanInterface(this, info);
|
||||
interfaces[i] = wlanIface;
|
||||
ifaces[info.interfaceGuid] = wlanIface;
|
||||
}
|
||||
|
||||
// Remove stale interfaces
|
||||
Queue<Guid> deadIfacesGuids = new Queue<Guid>();
|
||||
foreach (Guid ifaceGuid in ifaces.Keys)
|
||||
{
|
||||
if (!currentIfaceGuids.Contains(ifaceGuid))
|
||||
deadIfacesGuids.Enqueue(ifaceGuid);
|
||||
}
|
||||
while(deadIfacesGuids.Count != 0)
|
||||
{
|
||||
Guid deadIfaceGuid = deadIfacesGuids.Dequeue();
|
||||
ifaces.Remove(deadIfaceGuid);
|
||||
}
|
||||
|
||||
return interfaces;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Wlan.WlanFreeMemory(ifaceList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string that describes a specified reason code.
|
||||
/// </summary>
|
||||
/// <param name="reasonCode">The reason code.</param>
|
||||
/// <returns>The string.</returns>
|
||||
public string GetStringForReasonCode(Wlan.WlanReasonCode reasonCode)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(1024); // the 1024 size here is arbitrary; the WlanReasonCodeToString docs fail to specify a recommended size
|
||||
Wlan.ThrowIfError(
|
||||
Wlan.WlanReasonCodeToString(reasonCode, sb.Capacity, sb, IntPtr.Zero));
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DDFE602D-A0B5-4429-8B5C-E99155B6777A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Windows.Common</RootNamespace>
|
||||
<AssemblyName>Windows.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Wifi\Interop.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Wifi\WlanApi.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -1,4 +0,0 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
|
Binary file not shown.
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
|
Binary file not shown.
154
Network.cs
Normal file
154
Network.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
class Program
|
||||
{
|
||||
[DllImport("iphlpapi.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int GetAdaptersInfo(IntPtr pAdapterInfo, ref int pOutBufLen);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct IP_ADAPTER_INFO
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string AdapterName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public string Description;
|
||||
public uint AddressLength;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] Address;
|
||||
public int Index;
|
||||
public uint Type;
|
||||
public uint DhcpEnabled;
|
||||
public IntPtr CurrentIpAddress;
|
||||
public IP_ADDR_STRING IpAddressList;
|
||||
public IP_ADDR_STRING GatewayList;
|
||||
public IP_ADDR_STRING DhcpServer;
|
||||
public bool HaveWins;
|
||||
public IP_ADDR_STRING PrimaryWinsServer;
|
||||
public IP_ADDR_STRING SecondaryWinsServer;
|
||||
public uint LeaseObtained;
|
||||
public uint LeaseExpires;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct IP_ADDR_STRING
|
||||
{
|
||||
public IntPtr Next;
|
||||
public IP_ADDRESS_STRING IpAddress;
|
||||
public IP_ADDRESS_STRING IpMask;
|
||||
public int Context;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct IP_ADDRESS_STRING
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string Address;
|
||||
}
|
||||
|
||||
[DllImport("iphlpapi.dll")]
|
||||
public static extern int SendARP(uint destIp, uint srcIp, byte[] macAddress, ref uint physicalAddrLen);
|
||||
|
||||
public static string GetIP()
|
||||
{
|
||||
string hostName = Dns.GetHostName();
|
||||
IPAddress[] addresses = Dns.GetHostAddresses(hostName);
|
||||
IPAddress ipv4 = addresses.FirstOrDefault(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
|
||||
return ipv4?.ToString();
|
||||
}
|
||||
|
||||
public static string GetSSID()
|
||||
{
|
||||
string ssid = "";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
Process process = new Process();
|
||||
process.StartInfo.FileName = "netsh";
|
||||
process.StartInfo.Arguments = "wlan show interfaces";
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
|
||||
process.Start();
|
||||
string output = process.StandardOutput.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
|
||||
int ssidIndex = output.IndexOf("SSID", StringComparison.OrdinalIgnoreCase);
|
||||
if (ssidIndex >= 0)
|
||||
{
|
||||
int startIndex = output.IndexOf(':', ssidIndex) + 1;
|
||||
int endIndex = output.IndexOf('\n', startIndex);
|
||||
ssid = output.Substring(startIndex, endIndex - startIndex).Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return ssid;
|
||||
}
|
||||
|
||||
public static string GetMAC()
|
||||
{
|
||||
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
|
||||
foreach (NetworkInterface networkInterface in networkInterfaces)
|
||||
{
|
||||
if (networkInterface.OperationalStatus == OperationalStatus.Up && networkInterface.NetworkInterfaceType != NetworkInterfaceType.Loopback)
|
||||
{
|
||||
PhysicalAddress macAddress = networkInterface.GetPhysicalAddress();
|
||||
byte[] bytes = macAddress.GetAddressBytes();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
sb.AppendFormat("{0}", bytes[i].ToString("X2"));
|
||||
if (i != bytes.Length - 1)
|
||||
sb.Append(":");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void StopPrograms()
|
||||
{
|
||||
// Add code to stop programs here
|
||||
Console.WriteLine("Stopping programs...");
|
||||
}
|
||||
|
||||
public static void StartPrograms()
|
||||
{
|
||||
// Add code to start programs here
|
||||
Console.WriteLine("Starting programs...");
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
string ip = GetIP();
|
||||
Console.WriteLine("IP Address: " + ip);
|
||||
|
||||
string ssid = GetSSID();
|
||||
Console.WriteLine("SSID: " + ssid);
|
||||
|
||||
string mac = GetMAC();
|
||||
Console.WriteLine("Ethernet MAC Address: " + mac);
|
||||
|
||||
Console.WriteLine("Enter 'stop' to stop programs or 'start' to start programs:");
|
||||
string input = Console.ReadLine();
|
||||
|
||||
switch (input.ToLower())
|
||||
{
|
||||
case "stop":
|
||||
StopPrograms();
|
||||
break;
|
||||
case "start":
|
||||
StartPrograms();
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid input");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
28
mute.cs
Normal file
28
mute.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CoreAudioApi;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// Mute the computer
|
||||
MuteComputer();
|
||||
|
||||
// Wait for user input to exit
|
||||
Console.WriteLine("Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
static void MuteComputer()
|
||||
{
|
||||
// Create an instance of the MMDeviceEnumerator
|
||||
var enumerator = new MMDeviceEnumerator();
|
||||
|
||||
// Get the default audio render device (speaker)
|
||||
var device = enumerator.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
|
||||
|
||||
// Mute the audio
|
||||
device.AudioEndpointVolume.Mute = true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user