From 692650433976f3b8969920e5b00111c5b2ad5fce Mon Sep 17 00:00:00 2001 From: 1kamma Date: Sat, 1 Jul 2023 00:40:55 +0300 Subject: [PATCH] retry eveything --- .editorconfig | 12 - .gitignore | 10 - NetWork.sln | 25 - NetWork.sln.DotSettings.user | 4 - NetWork/.gitignore | 6 - NetWork/DialUp.cs | 8 - NetWork/IgnoreFile.cs | 15 - NetWork/Ip.cs | 19 - NetWork/Logs/NetworkLog202305272351.log | 1 - NetWork/Logs/NetworkLog202305272353.log | 1 - NetWork/Logs/NetworkLog202305272354.log | 1 - NetWork/NetWork.csproj | 120 -- NetWork/NetWork.csproj.user | 6 - NetWork/NetWork.xml | 1471 --------------- NetWork/Other/Data.ini | 1 - NetWork/Other/Windows.Common.pdb | Bin 38400 -> 0 bytes NetWork/Other/bluetooth.json | 4 - NetWork/Other/data.db | Bin 57344 -> 0 bytes NetWork/Other/def.json | 65 - NetWork/Other/earphones.json | 4 - NetWork/Other/ek.pbk | 290 --- NetWork/Program.cs | 461 ----- NetWork/Properties/Resources.Designer.cs | 73 - NetWork/Properties/Resources.resx | 124 -- NetWork/Properties/launchSettings.json | 7 - NetWork/RegistarRegistry.cs | 64 - NetWork/Torrent And Sync.py | 211 --- NetWork/UpgradeLog.htm | Bin 32672 -> 0 bytes .../Windows.Common/Properties/AssemblyInfo.cs | 36 - NetWork/Windows.Common/Wifi/Interop.cs | 1606 ----------------- NetWork/Windows.Common/Wifi/WlanApi.cs | 800 -------- NetWork/Windows.Common/Windows.Common.csproj | 55 - ...amework,Version=v4.6.AssemblyAttributes.cs | 4 - ...gnTimeResolveAssemblyReferencesInput.cache | Bin 6658 -> 0 bytes ...dows.Common.csproj.AssemblyReference.cache | Bin 3982 -> 0 bytes ...amework,Version=v4.6.AssemblyAttributes.cs | 4 - ...dows.Common.csproj.AssemblyReference.cache | Bin 11 -> 0 bytes Network.cs | 154 ++ mute.cs | 28 + 39 files changed, 182 insertions(+), 5508 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .gitignore delete mode 100644 NetWork.sln delete mode 100644 NetWork.sln.DotSettings.user delete mode 100644 NetWork/.gitignore delete mode 100644 NetWork/DialUp.cs delete mode 100644 NetWork/IgnoreFile.cs delete mode 100644 NetWork/Ip.cs delete mode 100644 NetWork/Logs/NetworkLog202305272351.log delete mode 100644 NetWork/Logs/NetworkLog202305272353.log delete mode 100644 NetWork/Logs/NetworkLog202305272354.log delete mode 100644 NetWork/NetWork.csproj delete mode 100644 NetWork/NetWork.csproj.user delete mode 100644 NetWork/NetWork.xml delete mode 100644 NetWork/Other/Data.ini delete mode 100644 NetWork/Other/Windows.Common.pdb delete mode 100644 NetWork/Other/bluetooth.json delete mode 100644 NetWork/Other/data.db delete mode 100644 NetWork/Other/def.json delete mode 100644 NetWork/Other/earphones.json delete mode 100644 NetWork/Other/ek.pbk delete mode 100644 NetWork/Program.cs delete mode 100644 NetWork/Properties/Resources.Designer.cs delete mode 100644 NetWork/Properties/Resources.resx delete mode 100644 NetWork/Properties/launchSettings.json delete mode 100644 NetWork/RegistarRegistry.cs delete mode 100644 NetWork/Torrent And Sync.py delete mode 100644 NetWork/UpgradeLog.htm delete mode 100644 NetWork/Windows.Common/Properties/AssemblyInfo.cs delete mode 100644 NetWork/Windows.Common/Wifi/Interop.cs delete mode 100644 NetWork/Windows.Common/Wifi/WlanApi.cs delete mode 100644 NetWork/Windows.Common/Windows.Common.csproj delete mode 100644 NetWork/Windows.Common/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs delete mode 100644 NetWork/Windows.Common/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache delete mode 100644 NetWork/Windows.Common/obj/Debug/Windows.Common.csproj.AssemblyReference.cache delete mode 100644 NetWork/Windows.Common/obj/Release/.NETFramework,Version=v4.6.AssemblyAttributes.cs delete mode 100644 NetWork/Windows.Common/obj/Release/Windows.Common.csproj.AssemblyReference.cache create mode 100644 Network.cs create mode 100644 mute.cs diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index b9c127d..0000000 --- a/.editorconfig +++ /dev/null @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f76a265..0000000 --- a/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -desktop.ini -*/bin/* -*/Debug/* -*.dll -*.pbk -.vs/ -*/obj/* -*/desktop.ini -NetWork/Properties/PublishProfiles/ -Publish/ diff --git a/NetWork.sln b/NetWork.sln deleted file mode 100644 index acb59d8..0000000 --- a/NetWork.sln +++ /dev/null @@ -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 diff --git a/NetWork.sln.DotSettings.user b/NetWork.sln.DotSettings.user deleted file mode 100644 index 01f3d08..0000000 --- a/NetWork.sln.DotSettings.user +++ /dev/null @@ -1,4 +0,0 @@ - - <AssemblyExplorer> - <Assembly Path="C:\Users\Saret\.nuget\packages\dotras.for.win8\1.3.0\lib\net40\DotRas.dll" /> -</AssemblyExplorer> \ No newline at end of file diff --git a/NetWork/.gitignore b/NetWork/.gitignore deleted file mode 100644 index 2cd892b..0000000 --- a/NetWork/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -bin/ -net6.0*/ -Publish/ -NetWork/Publish/*/* -*.exe -NetWork/Properties/ \ No newline at end of file diff --git a/NetWork/DialUp.cs b/NetWork/DialUp.cs deleted file mode 100644 index 276175d..0000000 --- a/NetWork/DialUp.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace NetWork -{ - class DialUp - { - - } -} diff --git a/NetWork/IgnoreFile.cs b/NetWork/IgnoreFile.cs deleted file mode 100644 index 6a1a603..0000000 --- a/NetWork/IgnoreFile.cs +++ /dev/null @@ -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(); - } - } -} diff --git a/NetWork/Ip.cs b/NetWork/Ip.cs deleted file mode 100644 index 9e5ddf2..0000000 --- a/NetWork/Ip.cs +++ /dev/null @@ -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() - { - - } - } -} diff --git a/NetWork/Logs/NetworkLog202305272351.log b/NetWork/Logs/NetworkLog202305272351.log deleted file mode 100644 index 0e24fdd..0000000 --- a/NetWork/Logs/NetworkLog202305272351.log +++ /dev/null @@ -1 +0,0 @@ -2023-05-27 23:51:29.776 +03:00[Information] null diff --git a/NetWork/Logs/NetworkLog202305272353.log b/NetWork/Logs/NetworkLog202305272353.log deleted file mode 100644 index c3c188b..0000000 --- a/NetWork/Logs/NetworkLog202305272353.log +++ /dev/null @@ -1 +0,0 @@ -2023-05-27 23:53:49.024 +03:00[Information] null diff --git a/NetWork/Logs/NetworkLog202305272354.log b/NetWork/Logs/NetworkLog202305272354.log deleted file mode 100644 index 7bab3c7..0000000 --- a/NetWork/Logs/NetworkLog202305272354.log +++ /dev/null @@ -1 +0,0 @@ -2023-05-27 23:54:44.555 +03:00[Information] null diff --git a/NetWork/NetWork.csproj b/NetWork/NetWork.csproj deleted file mode 100644 index b4b8826..0000000 --- a/NetWork/NetWork.csproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - WinExe - net6.0-windows - - NetWork.Program - False - enable - true - true - <_SuppressWpfTrimError>true - . - <_SuppressWinFormsTrimError>true - 7.0 - Size - True - true - True - - False - - False - - 1.0.0.1 - true - 0.1.1 - false - false - false - - - - embedded - true - x64 - True - <_SuppressWinFormsTrimError>true - - - embedded - true - x64 - .\NetWork.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - - - - - - - - PreserveNewest - - - - - - - - - - - - - false - false - True - - - - Never - - - diff --git a/NetWork/NetWork.csproj.user b/NetWork/NetWork.csproj.user deleted file mode 100644 index 42fe998..0000000 --- a/NetWork/NetWork.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - <_LastSelectedProfileId>C:\Users\Saret\Programming\C#\NetWork\NetWork\Properties\PublishProfiles\FolderProfile.pubxml - - \ No newline at end of file diff --git a/NetWork/NetWork.xml b/NetWork/NetWork.xml deleted file mode 100644 index c4062d9..0000000 --- a/NetWork/NetWork.xml +++ /dev/null @@ -1,1471 +0,0 @@ - - - - NetWork - - - - - this function gets an array of service names, and start or stop command, and it runs on the array and - - - - - - - String of paths - - - - - 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. - - A bool parameter. it swiches between stopping (default) and starting rdp session. - - - - - - - - - - - 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. - - file or path of the program - path if name has given, name if path has given. empty string if found nothing. - - - - A strongly-typed resource class, for looking up localized strings, etc. - - - - - Returns the cached ResourceManager instance used by this class. - - - - - Overrides the current thread's CurrentUICulture property for all - resource lookups using this strongly typed resource class. - - - - - Looks up a localized resource of type System.Byte[]. - - - - - Defines the Native Wifi API through P/Invoke interop. - - - This class is intended for internal use. Use the class instead. - - - - - Defines various opcodes used to set and query parameters for an interface. - - - Corresponds to the native WLAN_INTF_OPCODE type. - - - - - Opcode used to set or query whether auto config is enabled. - - - - - Opcode used to set or query whether background scan is enabled. - - - - - Opcode used to set or query the media streaming mode of the driver. - - - - - Opcode used to set or query the radio state. - - - - - Opcode used to set or query the BSS type of the interface. - - - - - Opcode used to query the state of the interface. - - - - - Opcode used to query information about the current connection of the interface. - - - - - Opcose used to query the current channel on which the wireless interface is operating. - - - - - Opcode used to query the supported auth/cipher pairs for infrastructure mode. - - - - - Opcode used to query the supported auth/cipher pairs for ad hoc mode. - - - - - Opcode used to query the list of supported country or region strings. - - - - - Opcode used to set or query the current operation mode of the wireless interface. - - - - - Opcode used to query driver statistics. - - - - - Opcode used to query the received signal strength. - - - - - Specifies the origin of automatic configuration (auto config) settings. - - - Corresponds to the native WLAN_OPCODE_VALUE_TYPE type. - - - - - The auto config settings were queried, but the origin of the settings was not determined. - - - - - The auto config settings were set by group policy. - - - - - The auto config settings were set by the user. - - - - - The auto config settings are invalid. - - - - Not supported on Windows XP SP2: must be a null reference. - Not supported on Windows XP SP2: must be a null reference. - - - - Defines flags passed to . - - - - - Include all ad-hoc network profiles in the available network list, including profiles that are not visible. - - - - - Include all hidden network profiles in the available network list, including profiles that are not visible. - - - - - The header of an array of information about available networks. - - - - - Contains the number of items following the header. - - - - - The index of the current item. The index of the first item is 0. - - - - - Contains various flags for the network. - - - - - This network is currently connected. - - - - - There is a profile for this network. - - - - - Contains information about an available wireless network. - - - - - Contains the profile name associated with the network. - If the network doesn't have a profile, this member will be empty. - If multiple profiles are associated with the network, there will be multiple entries with the same SSID in the visible network list. Profile names are case-sensitive. - - - - - Contains the SSID of the visible wireless network. - - - - - Specifies whether the network is infrastructure or ad hoc. - - - - - Indicates the number of BSSIDs in the network. - - - - - Indicates whether the network is connectable or not. - - - - - Indicates why a network cannot be connected to. This member is only valid when is false. - - - - - The number of PHY types supported on available networks. - The maximum value of this field is 8. If more than 8 PHY types are supported, must be set to true. - - - - - Contains an array of values that represent the PHY types supported by the available networks. - When is greater than 8, this array contains only the first 8 PHY types. - - - - - Gets the values that represent the PHY types supported by the available networks. - - - - - Specifies if there are more than 8 PHY types supported. - When this member is set to true, an application must call to get the complete list of PHY types. - contains the PHY type for an entry. - - - - - A percentage value that represents the signal quality of the network. - This field contains a value between 0 and 100. - A value of 0 implies an actual RSSI signal strength of -100 dbm. - A value of 100 implies an actual RSSI signal strength of -50 dbm. - You can calculate the RSSI signal strength value for values between 1 and 99 using linear interpolation. - - - - - Indicates whether security is enabled on the network. - - - - - Indicates the default authentication algorithm used to join this network for the first time. - - - - - Indicates the default cipher algorithm to be used when joining this network. - - - - - Contains various flags for the network. - - - - - Reserved for future use. Must be set to NULL. - - - - - The only option available on Windows XP SP2. - - - - - Defines the access mask of an all-user profile. - - - - - The user can view profile permissions. - - - - - The user has read access, and the user can also connect to and disconnect from a network using the profile. - - - - - The user has execute access and the user can also modify and delete permissions associated with a profile. - - - - Not supported on Windows XP SP2: must be a null reference. - - - - Specifies where the notification comes from. - - - - - All notifications, including those generated by the 802.1X module. - - - - - Notifications generated by the auto configuration module. - - - - - Notifications generated by MSM. - - - - - Notifications generated by the security module. - - - - - Notifications generated by independent hardware vendors (IHV). - - - - - Indicates the type of an ACM () notification. - - - The enumeration identifiers correspond to the native wlan_notification_acm_ identifiers. - On Windows XP SP2, only the ConnectionComplete and Disconnected notifications are available. - - - - - Indicates the type of an MSM () notification. - - - The enumeration identifiers correspond to the native wlan_notification_msm_ identifiers. - - - - - Contains information provided when registering for notifications. - - - Corresponds to the native WLAN_NOTIFICATION_DATA type. - - - - - Specifies where the notification comes from. - - - On Windows XP SP2, this field must be set to , or . - - - - - Indicates the type of notification. The value of this field indicates what type of associated data will be present in . - - - - - Indicates which interface the notification is for. - - - - - Specifies the size of , in bytes. - - - - - Pointer to additional data needed for the notification, as indicated by . - - - - - Gets the notification code (in the correct enumeration type) according to the notification source. - - - - - Defines the callback function which accepts WLAN notifications. - - - - - Defines connection parameter flags. - - - - - Connect to the destination network even if the destination is a hidden network. A hidden network does not broadcast its SSID. Do not use this flag if the destination network is an ad-hoc network. - If the profile specified by is not null, then this flag is ignored and the nonBroadcast profile element determines whether to connect to a hidden network. - - - - - Do not form an ad-hoc network. Only join an ad-hoc network if the network already exists. Do not use this flag if the destination network is an infrastructure network. - - - - - Ignore the privacy bit when connecting to the network. Ignoring the privacy bit has the effect of ignoring whether packets are encryption and ignoring the method of encryption used. Only use this flag when connecting to an infrastructure network using a temporary profile. - - - - - Exempt EAPOL traffic from encryption and decryption. This flag is used when an application must send EAPOL traffic over an infrastructure network that uses Open authentication and WEP encryption. This flag must not be used to connect to networks that require 802.1X authentication. This flag is only valid when is set to . Avoid using this flag whenever possible. - - - - - Specifies the parameters used when using the function. - - - Corresponds to the native WLAN_CONNECTION_PARAMETERS type. - - - - - Specifies the mode of connection. - - - - - Specifies the profile being used for the connection. - The contents of the field depend on the : - - - Value of - Contents of the profile string - - - - The name of the profile used for the connection. - - - - The XML representation of the profile used for the connection. - - - , or - null - - - - - - - Pointer to a structure that specifies the SSID of the network to connect to. - This field is optional. When set to null, all SSIDs in the profile will be tried. - This field must not be null if is set to or . - - - - - Pointer to a structure that contains the list of basic service set (BSS) identifiers desired for the connection. - - - On Windows XP SP2, must be set to null. - - - - - A value that indicates the BSS type of the network. If a profile is provided, this BSS type must be the same as the one in the profile. - - - - - Specifies ocnnection parameters. - - - On Windows XP SP2, must be set to 0. - - - - - The connection state of an ad hoc network. - - - - - The ad hoc network has been formed, but no client or host is connected to the network. - - - - - A client or host is connected to the ad hoc network. - - - - - Contains information about a basic service set (BSS). - - - - - Contains the SSID of the access point (AP) associated with the BSS. - - - - - The identifier of the PHY on which the AP is operating. - - - - - Contains the BSS identifier. - - - - - Specifies whether the network is infrastructure or ad hoc. - - - - - The received signal strength in dBm. - - - - - The link quality reported by the driver. Ranges from 0-100. - - - - - If 802.11d is not implemented, the network interface card (NIC) must set this field to TRUE. If 802.11d is implemented (but not necessarily enabled), the NIC must set this field to TRUE if the BSS operation complies with the configured regulatory domain. - - - - - Contains the beacon interval value from the beacon packet or probe response. - - - - - The timestamp from the beacon packet or probe response. - - - - - The host timestamp value when the beacon or probe response is received. - - - - - The capability value from the beacon packet or probe response. - - - - - The frequency of the center channel, in kHz. - - - - - Contains the set of data transfer rates supported by the BSS. - - - - - Offset of the information element (IE) data blob. - - - - - Size of the IE data blob, in bytes. - - - - - Contains the set of supported data rates. - - - - - The length, in bytes, of . - - - - - An array of supported data transfer rates. - If the rate is a basic rate, the first bit of the rate value is set to 1. - A basic rate is the data transfer rate that all stations in a basic service set (BSS) can use to receive frames from the wireless medium. - - - - - CalculateS the data transfer rate in Mbps for an arbitrary supported rate. - - - - - - - Represents an error occuring during WLAN operations which indicate their failure via a . - - - - - Gets the WLAN reason code. - - The WLAN reason code. - - - - Gets a message that describes the reason code. - - - The error message that explains the reason for the exception, or an empty string(""). - - - - Specifies reasons for a failure of a WLAN operation. - - - To get the WLAN API native reason code identifiers, prefix the identifiers with WLAN_REASON_CODE_. - - - - - Contains information about connection related notifications. - - - Corresponds to the native WLAN_CONNECTION_NOTIFICATION_DATA type. - - - - - On Windows XP SP 2, only is supported. - - - - - The name of the profile used for the connection. Profile names are case-sensitive. - - - - - The SSID of the association. - - - - - The BSS network type. - - - - - Indicates whether security is enabled for this connection. - - - - - Indicates the reason for an operation failure. - This field has a value of for all connection-related notifications except . - If the connection fails, this field indicates the reason for the failure. - - - - - This field contains the XML presentation of the profile used for discovery, if the connection succeeds. - - - - - Indicates the state of an interface. - - - Corresponds to the native WLAN_INTERFACE_STATE type. - - - - - The interface is not ready to operate. - - - - - The interface is connected to a network. - - - - - The interface is the first node in an ad hoc network. No peer has connected. - - - - - The interface is disconnecting from the current network. - - - - - The interface is not connected to any network. - - - - - The interface is attempting to associate with a network. - - - - - Auto configuration is discovering the settings for the network. - - - - - The interface is in the process of authenticating. - - - - - Contains the SSID of an interface. - - - - - The length, in bytes, of the array. - - - - - The SSID. - - - - - Defines an 802.11 PHY and media type. - - - Corresponds to the native DOT11_PHY_TYPE type. - - - - - Specifies an unknown or uninitialized PHY type. - - - - - Specifies any PHY type. - - - - - Specifies a frequency-hopping spread-spectrum (FHSS) PHY. Bluetooth devices can use FHSS or an adaptation of FHSS. - - - - - Specifies a direct sequence spread spectrum (DSSS) PHY. - - - - - Specifies an infrared (IR) baseband PHY. - - - - - Specifies an orthogonal frequency division multiplexing (OFDM) PHY. 802.11a devices can use OFDM. - - - - - Specifies a high-rate DSSS (HRDSSS) PHY. - - - - - Specifies an extended rate PHY (ERP). 802.11g devices can use ERP. - - - - - Specifies the start of the range that is used to define PHY types that are developed by an independent hardware vendor (IHV). - - - - - Specifies the end of the range that is used to define PHY types that are developed by an independent hardware vendor (IHV). - - - - - Defines a basic service set (BSS) network type. - - - Corresponds to the native DOT11_BSS_TYPE type. - - - - - Specifies an infrastructure BSS network. - - - - - Specifies an independent BSS (IBSS) network. - - - - - Specifies either infrastructure or IBSS network. - - - - - Contains association attributes for a connection - - - Corresponds to the native WLAN_ASSOCIATION_ATTRIBUTES type. - - - - - The SSID of the association. - - - - - Specifies whether the network is infrastructure or ad hoc. - - - - - The BSSID of the association. - - - - - The physical type of the association. - - - - - The position of the value in the structure containing the list of PHY types. - - - - - A percentage value that represents the signal quality of the network. - This field contains a value between 0 and 100. - A value of 0 implies an actual RSSI signal strength of -100 dbm. - A value of 100 implies an actual RSSI signal strength of -50 dbm. - You can calculate the RSSI signal strength value for values between 1 and 99 using linear interpolation. - - - - - The receiving rate of the association. - - - - - The transmission rate of the association. - - - - - Gets the BSSID of the associated access point. - - The BSSID. - - - - Defines the mode of connection. - - - Corresponds to the native WLAN_CONNECTION_MODE type. - - - - - A profile will be used to make the connection. - - - - - A temporary profile will be used to make the connection. - - - - - Secure discovery will be used to make the connection. - - - - - Unsecure discovery will be used to make the connection. - - - - - A connection will be made automatically, generally using a persistent profile. - - - - - Not used. - - - - - Defines a wireless LAN authentication algorithm. - - - Corresponds to the native DOT11_AUTH_ALGORITHM type. - - - - - Specifies an IEEE 802.11 Open System authentication algorithm. - - - - - Specifies an 802.11 Shared Key authentication algorithm that requires the use of a pre-shared Wired Equivalent Privacy (WEP) key for the 802.11 authentication. - - - - - Specifies a Wi-Fi Protected Access (WPA) algorithm. IEEE 802.1X port authentication is performed by the supplicant, authenticator, and authentication server. Cipher keys are dynamically derived through the authentication process. - This algorithm is valid only for BSS types of . - When the WPA algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 1 (802.1X) within the WPA information element (IE). - - - - - Specifies a WPA algorithm that uses preshared keys (PSK). IEEE 802.1X port authentication is performed by the supplicant and authenticator. Cipher keys are dynamically derived through a preshared key that is used on both the supplicant and authenticator. - This algorithm is valid only for BSS types of . - When the WPA PSK algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 2 (preshared key) within the WPA IE. - - - - - This value is not supported. - - - - - Specifies an 802.11i Robust Security Network Association (RSNA) algorithm. WPA2 is one such algorithm. IEEE 802.1X port authentication is performed by the supplicant, authenticator, and authentication server. Cipher keys are dynamically derived through the authentication process. - This algorithm is valid only for BSS types of . - When the RSNA algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 1 (802.1X) within the RSN IE. - - - - - Specifies an 802.11i RSNA algorithm that uses PSK. IEEE 802.1X port authentication is performed by the supplicant and authenticator. Cipher keys are dynamically derived through a preshared key that is used on both the supplicant and authenticator. - This algorithm is valid only for BSS types of . - When the RSNA PSK algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 2(preshared key) within the RSN IE. - - - - - Indicates the start of the range that specifies proprietary authentication algorithms that are developed by an IHV. - - - This enumerator is valid only when the miniport driver is operating in Extensible Station (ExtSTA) mode. - - - - - Indicates the end of the range that specifies proprietary authentication algorithms that are developed by an IHV. - - - This enumerator is valid only when the miniport driver is operating in Extensible Station (ExtSTA) mode. - - - - - Defines a cipher algorithm for data encryption and decryption. - - - Corresponds to the native DOT11_CIPHER_ALGORITHM type. - - - - - Specifies that no cipher algorithm is enabled or supported. - - - - - Specifies a Wired Equivalent Privacy (WEP) algorithm, which is the RC4-based algorithm that is specified in the 802.11-1999 standard. This enumerator specifies the WEP cipher algorithm with a 40-bit cipher key. - - - - - Specifies a Temporal Key Integrity Protocol (TKIP) algorithm, which is the RC4-based cipher suite that is based on the algorithms that are defined in the WPA specification and IEEE 802.11i-2004 standard. This cipher also uses the Michael Message Integrity Code (MIC) algorithm for forgery protection. - - - - - Specifies an AES-CCMP algorithm, as specified in the IEEE 802.11i-2004 standard and RFC 3610. Advanced Encryption Standard (AES) is the encryption algorithm defined in FIPS PUB 197. - - - - - Specifies a WEP cipher algorithm with a 104-bit cipher key. - - - - - Specifies a Robust Security Network (RSN) Use Group Key cipher suite. For more information about the Use Group Key cipher suite, refer to Clause 7.3.2.9.1 of the IEEE 802.11i-2004 standard. - - - - - Specifies a Wifi Protected Access (WPA) Use Group Key cipher suite. For more information about the Use Group Key cipher suite, refer to Clause 7.3.2.9.1 of the IEEE 802.11i-2004 standard. - - - - - Specifies a WEP cipher algorithm with a cipher key of any length. - - - - - Specifies the start of the range that is used to define proprietary cipher algorithms that are developed by an independent hardware vendor (IHV). - - - - - Specifies the end of the range that is used to define proprietary cipher algorithms that are developed by an IHV. - - - - - Defines the security attributes for a wireless connection. - - - Corresponds to the native WLAN_SECURITY_ATTRIBUTES type. - - - - - Indicates whether security is enabled for this connection. - - - - - The authentication algorithm. - - - - - The cipher algorithm. - - - - - Defines the attributes of a wireless connection. - - - Corresponds to the native WLAN_CONNECTION_ATTRIBUTES type. - - - - - The state of the interface. - - - - - The mode of the connection. - - - - - The name of the profile used for the connection. Profile names are case-sensitive. - - - - - The attributes of the association. - - - - - The security attributes of the connection. - - - - - Contains information about a LAN interface. - - - - - The GUID of the interface. - - - - - The description of the interface. - - - - - The current state of the interface. - - - - - The header of the list returned by . - - - - - The header of the list returned by . - - - - - Contains basic information about a profile. - - - - - The name of the profile. This value may be the name of a domain if the profile is for provisioning. Profile names are case-sensitive. - - - - - Profile flags. - - - - - Flags that specifiy the miniport driver's current operation mode. - - - - - Specifies that the miniport driver supports the Extensible Station (ExtSTA) operation mode. - - - - - Specifies that the miniport driver supports the Network Monitor (NetMon) operation mode. - - - - - Helper method to wrap calls to Native WiFi API methods. - If the method falls, throws an exception containing the error code. - - The error code. - - - - Represents a client to the Zeroconf (Native Wifi) service. - - - This class is the entrypoint to Native Wifi management. To manage WiFi settings, create an instance - of this class. - - - - - Represents a Wifi network interface. - - - - - Represents a method that will handle events. - - The notification data. - - - - Represents a method that will handle events. - - The notification data. - The notification data. - - - - Represents a method that will handle events. - - The notification data. - The reason code. - - - - Occurs when an event of any kind occurs on a WLAN interface. - - - - - Occurs when a WLAN interface changes connection state. - - - - - Occurs when a WLAN operation fails due to some reason. - - - - - Sets a parameter of the interface whose data type is . - - The opcode of the parameter. - The value to set. - - - - Gets a parameter of the interface whose data type is . - - The opcode of the parameter. - The integer value. - - - - Gets or sets a value indicating whether this is automatically configured. - - true if "autoconf" is enabled; otherwise, false. - - - - Gets or sets the BSS type for the indicated interface. - - The type of the BSS. - - - - Gets the state of the interface. - - The state of the interface. - - - - Gets the channel. - - The channel. - Not supported on Windows XP SP2. - - - - Gets the RSSI. - - The RSSI. - Not supported on Windows XP SP2. - - - - Gets the current operation mode. - - The current operation mode. - Not supported on Windows XP SP2. - - - - Gets the attributes of the current connection. - - The current connection attributes. - 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. - - - - Requests a scan for available networks. - - - The method returns immediately. Progress is reported through the event. - - - - - Converts a pointer to a available networks list (header + entries) to an array of available network entries. - - A pointer to an available networks list's header. - An array of available network entries. - - - - Retrieves the list of available networks. - - Controls the type of networks returned. - A list of the available networks. - - - - Converts a pointer to a BSS list (header + entries) to an array of BSS entries. - - A pointer to a BSS list's header. - An array of BSS entries. - - - - Retrieves the basic service sets (BSS) list of all available networks. - - - - - Retrieves the basic service sets (BSS) list of the specified network. - - Specifies the SSID of the network from which the BSS list is requested. - Indicates the BSS type of the network. - Indicates whether security is enabled on the network. - - - - Connects to a network defined by a connection parameters structure. - - The connection paramters. - - - - Requests a connection (association) to the specified wireless network. - - - The method returns immediately. Progress is reported through the event. - - - - - Connects (associates) to the specified wireless network, returning either on a success to connect - or a failure. - - - - - - - - - - Connects to the specified wireless network. - - - The method returns immediately. Progress is reported through the event. - - - - - Deletes a profile. - - - 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 -adhoc. - - - - - Sets the profile. - - The flags to set on the profile. - The XML representation of the profile. On Windows XP SP 2, special care should be taken to adhere to its limitations. - If a profile by the given name already exists, then specifies whether to overwrite it (if true) or return an error (if false). - The resulting code indicating a success or the reason why the profile wasn't valid. - - - - Gets the profile's XML specification. - - The name of the profile. - The XML document. - - - - Gets the information of all profiles on this interface. - - The profiles information. - - - - Enqueues a notification event to be processed serially. - - - - - Gets the network interface of this wireless interface. - - - The network interface allows querying of generic network properties such as the interface's IP address. - - - - - The GUID of the interface (same content as the value). - - - - - The description of the interface. - This is a user-immutable string containing the vendor and model name of the adapter. - - - - - The friendly name given to the interface by the user (e.g. "Local Area Network Connection"). - - - - - Creates a new instance of a Native Wifi service client. - - - - - Gets the WLAN interfaces. - - The WLAN interfaces. - - - - Gets a string that describes a specified reason code. - - The reason code. - The string. - - - diff --git a/NetWork/Other/Data.ini b/NetWork/Other/Data.ini deleted file mode 100644 index 5797f66..0000000 --- a/NetWork/Other/Data.ini +++ /dev/null @@ -1 +0,0 @@ -RunNetwork \ No newline at end of file diff --git a/NetWork/Other/Windows.Common.pdb b/NetWork/Other/Windows.Common.pdb deleted file mode 100644 index 82abb07ee9798e26bd5efebb3e2445606e734627..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 38400 zcmeI53w%|@z3^@KQi9_(sbn*+6VaFbS`g)`W*rwMr{i zJw@yLV_QA7ryj-nDCf3%wHNQT)wZ_k{b;Y++S+Qpw5O++qxbup$I99}I||X$R$<`3 ze`_B9ng9G}=0CG$&01MlTiw{u)UdL-aMq+*@U44~AC-ir5A>xYh;T!L_uk6^-+Ql% z@gMp58-1MJ3_OFZ^`5mUh3tadPzob4OR)b@QdkzWw%X^hp)x zmVQ1ccyY;;%%CXl$i>G;1KGyEX2ZDsmtQr?#E(xck4V~)29C6UN18c2!vC^j$*E6t zeYW4us$lOKw;q23IeB^xJu=_4l~xvh(|`e74`Cf@)G!$aba zs{I$g^v+!`jr;u42kVy%`EB0z;~O6Mb(iNSK7RX!7f#>0_>60M9Uj{J_|@{GYX4!! zZr)mI!J<_n~K*ibbUHb3?19mUJ;K0gHzj6HfkDq1^FNu5gw)ORRc-8*! zt?j#Sz5AAKPV#4fS|e z)-Ic0-<)b}SX)%x6a+OVE~|H(E7Lh$4n@_LbAvc*+c*!c$aCtF^%ZMtRpgQ7!jwP<=#MN?C1&5F8B z70u0!wJX*&r6%1EY_anSWxOe3Wln`=`|%e=Jn>sK}$ zlALSX^6=8sx;*;PasHVu^iFI)=)^1os+q8RUHI$ZX{6V((6e=OaYx{9sez+^RUGEf z1U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|0009ILKmY**5I_I{1Q0*~0R#|0009KH61Xm3hd;`Vf#2n~!gbkQ_+H-4|0$(l zMegTT_9N@ge^47FHVAuFx5B(}x7DTJjb$ z&>3<|0&B>BNL&TB3vD;*jyi*H`(S@Zjg=1AZqOaMHadgv_{IlXjk`*7ogsI9NZ1N- zO$K4!ZlrJkehpazXZ7D6Jr@0UBiJL~ z24`}W+?ibDlKnpW>9TjabEjOpkv{+5&RY6&qtsrv-6;*!YwfG2FC4Ia&QgdjIhb>) z*hi^|SOgG2009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q7T~0eft5>-qow z`~RVy3hashCClEs#Q!ckWf^>ZAb^}nqPcV}j?N`%tZ!Yw(;ET$vjO_p|MH6dG5{L_ z2q1s}0tg_000IagfB*srAb - /// this function gets an array of service names, and start or stop command, and it runs on the array and - /// - /// - /// - 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 ServiceList = new List(); - 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; - } - - /// - /// String of paths - /// - public static string[] StringsOfPaths = System.IO.Directory.GetFiles(@"C:\Program Files\Google\Drive File Stream\", "GoogleDriveFS.exe", System.IO.SearchOption.AllDirectories); - public static Dictionary 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 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" } }; - /// - /// 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. - /// - /// A bool parameter. it swiches between stopping (default) and starting rdp session. - 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(""); - - } - } - } - /// - /// - /// - /// - /// - 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; - } - /// - /// 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. - /// - /// file or path of the program - /// path if name has given, name if path has given. empty string if found nothing. - 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 GetNetwork() { - Dictionary 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 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() { - var toRunOrNotToRun = Registry.GetValue(@"HKEY_CURRENT_USER\Software\SaretNetwork", "Run", 1); - return toRunOrNotToRun is null? true: toRunOrNotToRun.Equals(1)?true:false; - } - 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()); - - } - } -} \ No newline at end of file diff --git a/NetWork/Properties/Resources.Designer.cs b/NetWork/Properties/Resources.Designer.cs deleted file mode 100644 index e05f63a..0000000 --- a/NetWork/Properties/Resources.Designer.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -namespace NetWork.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // 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() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [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; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] ek { - get { - object obj = ResourceManager.GetObject("ek", resourceCulture); - return ((byte[])(obj)); - } - } - } -} diff --git a/NetWork/Properties/Resources.resx b/NetWork/Properties/Resources.resx deleted file mode 100644 index 4801d1e..0000000 --- a/NetWork/Properties/Resources.resx +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Other\ek.pbk;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/NetWork/Properties/launchSettings.json b/NetWork/Properties/launchSettings.json deleted file mode 100644 index 5ed5ab7..0000000 --- a/NetWork/Properties/launchSettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "profiles": { - "NetWork": { - "commandName": "Project" - } - } -} \ No newline at end of file diff --git a/NetWork/RegistarRegistry.cs b/NetWork/RegistarRegistry.cs deleted file mode 100644 index 4a7e1b1..0000000 --- a/NetWork/RegistarRegistry.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using Microsoft.Win32; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace NetWork -{ - internal class RegistarRegistry - { - - public static bool IniData() - { - var toRunOrNotToRun = Registry.GetValue(@"HKEY_CURRENT_USER\Software\SaretNetwork", "Run", 1); - return toRunOrNotToRun is null ? true : toRunOrNotToRun.Equals(1) ? true : false; - } - } - internal class NetworkInterface - { - public string Name { get; set; } - public ListOfPrograms ListOfProgramsToStart { get; set; } - public ListOfPrograms ListOfProgramsToStop { get; set; } - public string[] ServicesToStart { get; set; } - public string[] ServicesToStop { get;set; } - public bool Mute { get; set; }=true; - public NetworkInterface(string name, string url) - { - Name = name; - } - } - internal class ListOfPrograms - { - public string[] ProgramName { get; private set; } - public string[] ProgramPath { get; private set; } - public ListOfPrograms(string url) { - WebClient webClient = new(); - string[] data = Regex.Split(Regex.Replace(webClient.DownloadString(url),@"[\{\}]",""),","); - ProgramName = new string[data.Length]; - ProgramPath = new string[data.Length]; - for(int i = 0; i < data.Length; i++) - { - ProgramName[i] = Regex.Match(data[i], @"(?<="").+(?="":)").Value; - ProgramPath[i] = Regex.Match(data[i], @"(?<=:\s?"")[^""]+").Value; - } - //string d = Regex.Replace(webClient.DownloadString(url), @"[\{\}]", ""); - //ProgramName = Regex.Matches(d,@"(?<=\"")\w+(?=\"":)").Select(x => x.Value).ToArray(); - } - public ListOfPrograms(string registryHive, string registryName) - { - string location = Regex.IsMatch(registryHive, @"HKEY_") ? Regex.Replace(registryHive, @"^[^\\]+", "")[1..] : registryHive; - RegistryKey key = Registry.CurrentUser.OpenSubKey($"{location}\\{registryName}") ; - ProgramName = key.GetValueNames(); - ProgramPath = new string[ProgramName.Length]; - for (int i = 0; i < ProgramName.Length; i++) - { - ProgramPath[i] = Registry.GetValue($"HKEY_CURRENT_USER\\{location}\\{registryName}", ProgramName[i], "").ToString(); - } - } - } - -} diff --git a/NetWork/Torrent And Sync.py b/NetWork/Torrent And Sync.py deleted file mode 100644 index 204055a..0000000 --- a/NetWork/Torrent And Sync.py +++ /dev/null @@ -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() diff --git a/NetWork/UpgradeLog.htm b/NetWork/UpgradeLog.htm deleted file mode 100644 index 455e6fcde453ee67aaf260b1398d1a01fc5d6315..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32672 zcmeI5S#Mj(a>vh$9}*znf!E3%YogIY$=2ezo&iNsvaH40EZG_jE+kPqwOFLqnVavJ zhad@%1PBlyxnCm5@86~NSx6o7P>bgx0zsa0da16is;;W8?$i9=|M^4kyI?GM9~6V7 z;8QRcl!9Ea8`Ofspc4EL{7vxJfl74q$pzJ5Jva}xf-?8p!D(!Cr90b&FC*{MM);Xa+k6bl+MoxOA-^(avk`sytU6mDh>q{??2=-oUEuh%!VYr%8cQY%~3DZBeahsQdYsH|b9-#3)q;<=ml zs@xkTYQYI9Tft{i_vpV$6=U_fgK1zN1v`{j=XcB1?QPnYsB%fWyt{w{xvANMJs>gdQAT(;eOa7aaS$xx&AHibi&;!wfbn= z^DIaG_-BS1JCs|eq}9y@(b|%ucnxvB*OfMm#G@+DR}Q})DBY+|5{7^74gQWAqu^Qw zf+W>L`i`e<*M}Twl7bvxaeEJZ^;9Nz6Dmt8l%4}tZ>H8I>uNU(#=m4L?fba_g*Sr( zM{A9*Bielp#vQ?UFmUsI8GPRsY>frU#OV#hJi5TX<849|-9^!EII!-FF3_((Fv%>k4<6jnOGWmZC1=I)8Ay2#UQ6Qb>b+@=2jtAi@T$K`P zh^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&l3`S!=B5sA^ z^pIZFJW~Bl+KITuyWKm8motqXV&d(gdK9I2T$@@yLJv6EXWzqit!gVgk7E={KwN7i zt;%imREu%_6W3GT0={lI(-RfrwFS*A`VTj|0{qNn5$QQ|a&PBHZ8;06bq~d8>|{kd zomA(B=?t`FOu=SA+7T&_K`Yo{ZFz>0?qp0x@~K&r{BK1_#9wPqmfC9vrR|biU)#!R zPrJ%{XtM5_1KK%E;{27*!!iDvUtz@e};U z7%$&Ae%-ErbX(lcQ$YWHC#zLYhh)5=daD+Yk83*ByyUEMlcrOn=kCi2id&%_(_Spo z82V3CvoN>o-`gas70nyx(QjGvYOPuNNtBD8pec>v63%d`LD`)|*3!M{HH_h_>HqmmrT$Dx(XG42 z?Z_ItM-|CB0D}`C#&f-uxj#MhBu~j1ho^BnmOQE5q!)C`g`Mta5_FrSwa!y{681mA z%|?0LM~jckdOPG-N0Pm0Ut2_@A9uAw9=rd)cF0rUVeL?IHkh1S#Whl>-EHm@&y`HK zGAD}Hiuy)>Ni(8$ZE8ECq~1@{`9kp#UcGsLLE|@0VeNM^pUQNS{DOKPrl+A7<5x+d e*Tx=AQj&BIgDj - /// Defines the Native Wifi API through P/Invoke interop. - /// - /// - /// This class is intended for internal use. Use the class instead. - /// - public static class Wlan - { - #region P/Invoke API - /// - /// Defines various opcodes used to set and query parameters for an interface. - /// - /// - /// Corresponds to the native WLAN_INTF_OPCODE type. - /// - public enum WlanIntfOpcode - { - /// - /// Opcode used to set or query whether auto config is enabled. - /// - AutoconfEnabled = 1, - /// - /// Opcode used to set or query whether background scan is enabled. - /// - BackgroundScanEnabled, - /// - /// Opcode used to set or query the media streaming mode of the driver. - /// - MediaStreamingMode, - /// - /// Opcode used to set or query the radio state. - /// - RadioState, - /// - /// Opcode used to set or query the BSS type of the interface. - /// - BssType, - /// - /// Opcode used to query the state of the interface. - /// - InterfaceState, - /// - /// Opcode used to query information about the current connection of the interface. - /// - CurrentConnection, - /// - /// Opcose used to query the current channel on which the wireless interface is operating. - /// - ChannelNumber, - /// - /// Opcode used to query the supported auth/cipher pairs for infrastructure mode. - /// - SupportedInfrastructureAuthCipherPairs, - /// - /// Opcode used to query the supported auth/cipher pairs for ad hoc mode. - /// - SupportedAdhocAuthCipherPairs, - /// - /// Opcode used to query the list of supported country or region strings. - /// - SupportedCountryOrRegionStringList, - /// - /// Opcode used to set or query the current operation mode of the wireless interface. - /// - CurrentOperationMode, - /// - /// Opcode used to query driver statistics. - /// - Statistics = 0x10000101, - /// - /// Opcode used to query the received signal strength. - /// - RSSI, - SecurityStart = 0x20010000, - SecurityEnd = 0x2fffffff, - IhvStart = 0x30000000, - IhvEnd = 0x3fffffff - } - - /// - /// Specifies the origin of automatic configuration (auto config) settings. - /// - /// - /// Corresponds to the native WLAN_OPCODE_VALUE_TYPE type. - /// - public enum WlanOpcodeValueType - { - /// - /// The auto config settings were queried, but the origin of the settings was not determined. - /// - QueryOnly = 0, - /// - /// The auto config settings were set by group policy. - /// - SetByGroupPolicy = 1, - /// - /// The auto config settings were set by the user. - /// - SetByUser = 2, - /// - /// The auto config settings are invalid. - /// - Invalid = 3 - } - - public const uint WLAN_CLIENT_VERSION_XP_SP2 = 1; - public const uint WLAN_CLIENT_VERSION_LONGHORN = 2; - - [DllImport("wlanapi.dll")] - public static extern int WlanOpenHandle( - [In] UInt32 clientVersion, - [In, Out] IntPtr pReserved, - [Out] out UInt32 negotiatedVersion, - [Out] out IntPtr clientHandle); - - [DllImport("wlanapi.dll")] - public static extern int WlanCloseHandle( - [In] IntPtr clientHandle, - [In, Out] IntPtr pReserved); - - [DllImport("wlanapi.dll")] - public static extern int WlanEnumInterfaces( - [In] IntPtr clientHandle, - [In, Out] IntPtr pReserved, - [Out] out IntPtr ppInterfaceList); - - [DllImport("wlanapi.dll")] - public static extern int WlanQueryInterface( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] WlanIntfOpcode opCode, - [In, Out] IntPtr pReserved, - [Out] out int dataSize, - [Out] out IntPtr ppData, - [Out] out WlanOpcodeValueType wlanOpcodeValueType); - - [DllImport("wlanapi.dll")] - public static extern int WlanSetInterface( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] WlanIntfOpcode opCode, - [In] uint dataSize, - [In] IntPtr pData, - [In, Out] IntPtr pReserved); - - /// Not supported on Windows XP SP2: must be a null reference. - /// Not supported on Windows XP SP2: must be a null reference. - [DllImport("wlanapi.dll")] - public static extern int WlanScan( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] IntPtr pDot11Ssid, - [In] IntPtr pIeData, - [In, Out] IntPtr pReserved); - - /// - /// Defines flags passed to . - /// - [Flags] - public enum WlanGetAvailableNetworkFlags - { - /// - /// Include all ad-hoc network profiles in the available network list, including profiles that are not visible. - /// - IncludeAllAdhocProfiles = 0x00000001, - /// - /// Include all hidden network profiles in the available network list, including profiles that are not visible. - /// - IncludeAllManualHiddenProfiles = 0x00000002 - } - - /// - /// The header of an array of information about available networks. - /// - [StructLayout(LayoutKind.Sequential)] - internal struct WlanAvailableNetworkListHeader - { - /// - /// Contains the number of items following the header. - /// - public uint numberOfItems; - /// - /// The index of the current item. The index of the first item is 0. - /// - public uint index; - } - - /// - /// Contains various flags for the network. - /// - [Flags] - public enum WlanAvailableNetworkFlags - { - /// - /// This network is currently connected. - /// - Connected = 0x00000001, - /// - /// There is a profile for this network. - /// - HasProfile = 0x00000002 - } - - /// - /// Contains information about an available wireless network. - /// - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - public struct WlanAvailableNetwork - { - /// - /// Contains the profile name associated with the network. - /// If the network doesn't have a profile, this member will be empty. - /// If multiple profiles are associated with the network, there will be multiple entries with the same SSID in the visible network list. Profile names are case-sensitive. - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string profileName; - /// - /// Contains the SSID of the visible wireless network. - /// - public Dot11Ssid dot11Ssid; - /// - /// Specifies whether the network is infrastructure or ad hoc. - /// - public Dot11BssType dot11BssType; - /// - /// Indicates the number of BSSIDs in the network. - /// - public uint numberOfBssids; - /// - /// Indicates whether the network is connectable or not. - /// - public bool networkConnectable; - /// - /// Indicates why a network cannot be connected to. This member is only valid when is false. - /// - public WlanReasonCode wlanNotConnectableReason; - /// - /// The number of PHY types supported on available networks. - /// The maximum value of this field is 8. If more than 8 PHY types are supported, must be set to true. - /// - private uint numberOfPhyTypes; - /// - /// Contains an array of values that represent the PHY types supported by the available networks. - /// When is greater than 8, this array contains only the first 8 PHY types. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - private Dot11PhyType[] dot11PhyTypes; - /// - /// Gets the values that represent the PHY types supported by the available networks. - /// - public Dot11PhyType[] Dot11PhyTypes - { - get - { - Dot11PhyType[] ret = new Dot11PhyType[numberOfPhyTypes]; - Array.Copy(dot11PhyTypes, ret, numberOfPhyTypes); - return ret; - } - } - /// - /// Specifies if there are more than 8 PHY types supported. - /// When this member is set to true, an application must call to get the complete list of PHY types. - /// contains the PHY type for an entry. - /// - public bool morePhyTypes; - /// - /// A percentage value that represents the signal quality of the network. - /// This field contains a value between 0 and 100. - /// A value of 0 implies an actual RSSI signal strength of -100 dbm. - /// A value of 100 implies an actual RSSI signal strength of -50 dbm. - /// You can calculate the RSSI signal strength value for values between 1 and 99 using linear interpolation. - /// - public uint wlanSignalQuality; - /// - /// Indicates whether security is enabled on the network. - /// - public bool securityEnabled; - /// - /// Indicates the default authentication algorithm used to join this network for the first time. - /// - public Dot11AuthAlgorithm dot11DefaultAuthAlgorithm; - /// - /// Indicates the default cipher algorithm to be used when joining this network. - /// - public Dot11CipherAlgorithm dot11DefaultCipherAlgorithm; - /// - /// Contains various flags for the network. - /// - public WlanAvailableNetworkFlags flags; - /// - /// Reserved for future use. Must be set to NULL. - /// - uint reserved; - } - - [DllImport("wlanapi.dll")] - public static extern int WlanGetAvailableNetworkList( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] WlanGetAvailableNetworkFlags flags, - [In, Out] IntPtr reservedPtr, - [Out] out IntPtr availableNetworkListPtr); - - [Flags] - public enum WlanProfileFlags - { - /// - /// The only option available on Windows XP SP2. - /// - AllUser = 0, - GroupPolicy = 1, - User = 2 - } - - [DllImport("wlanapi.dll")] - public static extern int WlanSetProfile( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] WlanProfileFlags flags, - [In, MarshalAs(UnmanagedType.LPWStr)] string profileXml, - [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string allUserProfileSecurity, - [In] bool overwrite, - [In] IntPtr pReserved, - [Out] out WlanReasonCode reasonCode); - - /// - /// Defines the access mask of an all-user profile. - /// - [Flags] - public enum WlanAccess - { - /// - /// The user can view profile permissions. - /// - ReadAccess = 0x00020000 | 0x0001, - /// - /// The user has read access, and the user can also connect to and disconnect from a network using the profile. - /// - ExecuteAccess = ReadAccess | 0x0020, - /// - /// The user has execute access and the user can also modify and delete permissions associated with a profile. - /// - WriteAccess = ReadAccess | ExecuteAccess | 0x0002 | 0x00010000 | 0x00040000 - } - - /// Not supported on Windows XP SP2: must be a null reference. - [DllImport("wlanapi.dll")] - public static extern int WlanGetProfile( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In, MarshalAs(UnmanagedType.LPWStr)] string profileName, - [In] IntPtr pReserved, - [Out] out IntPtr profileXml, - [Out, Optional] out WlanProfileFlags flags, - [Out, Optional] out WlanAccess grantedAccess); - - [DllImport("wlanapi.dll")] - public static extern int WlanGetProfileList( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] IntPtr pReserved, - [Out] out IntPtr profileList - ); - - [DllImport("wlanapi.dll")] - public static extern void WlanFreeMemory(IntPtr pMemory); - - [DllImport("wlanapi.dll")] - public static extern int WlanReasonCodeToString( - [In] WlanReasonCode reasonCode, - [In] int bufferSize, - [In, Out] StringBuilder stringBuffer, - IntPtr pReserved - ); - - /// - /// Specifies where the notification comes from. - /// - [Flags] - public enum WlanNotificationSource - { - None = 0, - /// - /// All notifications, including those generated by the 802.1X module. - /// - All = 0X0000FFFF, - /// - /// Notifications generated by the auto configuration module. - /// - ACM = 0X00000008, - /// - /// Notifications generated by MSM. - /// - MSM = 0X00000010, - /// - /// Notifications generated by the security module. - /// - Security = 0X00000020, - /// - /// Notifications generated by independent hardware vendors (IHV). - /// - IHV = 0X00000040 - } - - /// - /// Indicates the type of an ACM () notification. - /// - /// - /// The enumeration identifiers correspond to the native wlan_notification_acm_ identifiers. - /// On Windows XP SP2, only the ConnectionComplete and Disconnected notifications are available. - /// - public enum WlanNotificationCodeAcm - { - AutoconfEnabled = 1, - AutoconfDisabled, - BackgroundScanEnabled, - BackgroundScanDisabled, - BssTypeChange, - PowerSettingChange, - ScanComplete, - ScanFail, - ConnectionStart, - ConnectionComplete, - ConnectionAttemptFail, - FilterListChange, - InterfaceArrival, - InterfaceRemoval, - ProfileChange, - ProfileNameChange, - ProfilesExhausted, - NetworkNotAvailable, - NetworkAvailable, - Disconnecting, - Disconnected, - AdhocNetworkStateChange - } - - /// - /// Indicates the type of an MSM () notification. - /// - /// - /// The enumeration identifiers correspond to the native wlan_notification_msm_ identifiers. - /// - public enum WlanNotificationCodeMsm - { - Associating = 1, - Associated, - Authenticating, - Connected, - RoamingStart, - RoamingEnd, - RadioStateChange, - SignalQualityChange, - Disassociating, - Disconnected, - PeerJoin, - PeerLeave, - AdapterRemoval, - AdapterOperationModeChange - } - - /// - /// Contains information provided when registering for notifications. - /// - /// - /// Corresponds to the native WLAN_NOTIFICATION_DATA type. - /// - [StructLayout(LayoutKind.Sequential)] - public struct WlanNotificationData - { - /// - /// Specifies where the notification comes from. - /// - /// - /// On Windows XP SP2, this field must be set to , or . - /// - public WlanNotificationSource notificationSource; - /// - /// Indicates the type of notification. The value of this field indicates what type of associated data will be present in . - /// - public int notificationCode; - /// - /// Indicates which interface the notification is for. - /// - public Guid interfaceGuid; - /// - /// Specifies the size of , in bytes. - /// - public int dataSize; - /// - /// Pointer to additional data needed for the notification, as indicated by . - /// - public IntPtr dataPtr; - - /// - /// Gets the notification code (in the correct enumeration type) according to the notification source. - /// - public object NotificationCode - { - get - { - if (notificationSource == WlanNotificationSource.MSM) - return (WlanNotificationCodeMsm)notificationCode; - else if (notificationSource == WlanNotificationSource.ACM) - return (WlanNotificationCodeAcm)notificationCode; - else - return notificationCode; - } - - } - } - - /// - /// Defines the callback function which accepts WLAN notifications. - /// - public delegate void WlanNotificationCallbackDelegate(ref WlanNotificationData notificationData, IntPtr context); - - [DllImport("wlanapi.dll")] - public static extern int WlanRegisterNotification( - [In] IntPtr clientHandle, - [In] WlanNotificationSource notifSource, - [In] bool ignoreDuplicate, - [In] WlanNotificationCallbackDelegate funcCallback, - [In] IntPtr callbackContext, - [In] IntPtr reserved, - [Out] out WlanNotificationSource prevNotifSource); - - /// - /// Defines connection parameter flags. - /// - [Flags] - public enum WlanConnectionFlags - { - /// - /// Connect to the destination network even if the destination is a hidden network. A hidden network does not broadcast its SSID. Do not use this flag if the destination network is an ad-hoc network. - /// If the profile specified by is not null, then this flag is ignored and the nonBroadcast profile element determines whether to connect to a hidden network. - /// - HiddenNetwork = 0x00000001, - /// - /// Do not form an ad-hoc network. Only join an ad-hoc network if the network already exists. Do not use this flag if the destination network is an infrastructure network. - /// - AdhocJoinOnly = 0x00000002, - /// - /// Ignore the privacy bit when connecting to the network. Ignoring the privacy bit has the effect of ignoring whether packets are encryption and ignoring the method of encryption used. Only use this flag when connecting to an infrastructure network using a temporary profile. - /// - IgnorePrivacyBit = 0x00000004, - /// - /// Exempt EAPOL traffic from encryption and decryption. This flag is used when an application must send EAPOL traffic over an infrastructure network that uses Open authentication and WEP encryption. This flag must not be used to connect to networks that require 802.1X authentication. This flag is only valid when is set to . Avoid using this flag whenever possible. - /// - EapolPassthrough = 0x00000008 - } - - /// - /// Specifies the parameters used when using the function. - /// - /// - /// Corresponds to the native WLAN_CONNECTION_PARAMETERS type. - /// - [StructLayout(LayoutKind.Sequential)] - public struct WlanConnectionParameters - { - /// - /// Specifies the mode of connection. - /// - public WlanConnectionMode wlanConnectionMode; - /// - /// Specifies the profile being used for the connection. - /// The contents of the field depend on the : - /// - /// - /// Value of - /// Contents of the profile string - /// - /// - /// - /// The name of the profile used for the connection. - /// - /// - /// - /// The XML representation of the profile used for the connection. - /// - /// - /// , or - /// null - /// - /// - /// - [MarshalAs(UnmanagedType.LPWStr)] - public string profile; - /// - /// Pointer to a structure that specifies the SSID of the network to connect to. - /// This field is optional. When set to null, all SSIDs in the profile will be tried. - /// This field must not be null if is set to or . - /// - public IntPtr dot11SsidPtr; - /// - /// Pointer to a structure that contains the list of basic service set (BSS) identifiers desired for the connection. - /// - /// - /// On Windows XP SP2, must be set to null. - /// - public IntPtr desiredBssidListPtr; - /// - /// A value that indicates the BSS type of the network. If a profile is provided, this BSS type must be the same as the one in the profile. - /// - public Dot11BssType dot11BssType; - /// - /// Specifies ocnnection parameters. - /// - /// - /// On Windows XP SP2, must be set to 0. - /// - public WlanConnectionFlags flags; - } - - /// - /// The connection state of an ad hoc network. - /// - public enum WlanAdhocNetworkState - { - /// - /// The ad hoc network has been formed, but no client or host is connected to the network. - /// - Formed = 0, - /// - /// A client or host is connected to the ad hoc network. - /// - Connected = 1 - } - - [DllImport("wlanapi.dll")] - public static extern int WlanConnect( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] ref WlanConnectionParameters connectionParameters, - IntPtr pReserved); - - [DllImport("wlanapi.dll")] - public static extern int WlanDeleteProfile( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In, MarshalAs(UnmanagedType.LPWStr)] string profileName, - IntPtr reservedPtr - ); - - [DllImport("wlanapi.dll")] - public static extern int WlanGetNetworkBssList( - [In] IntPtr clientHandle, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, - [In] IntPtr dot11SsidInt, - [In] Dot11BssType dot11BssType, - [In] bool securityEnabled, - IntPtr reservedPtr, - [Out] out IntPtr wlanBssList - ); - - [StructLayout(LayoutKind.Sequential)] - internal struct WlanBssListHeader - { - internal uint totalSize; - internal uint numberOfItems; - } - - /// - /// Contains information about a basic service set (BSS). - /// - [StructLayout(LayoutKind.Sequential)] - public struct WlanBssEntry - { - /// - /// Contains the SSID of the access point (AP) associated with the BSS. - /// - public Dot11Ssid dot11Ssid; - /// - /// The identifier of the PHY on which the AP is operating. - /// - public uint phyId; - /// - /// Contains the BSS identifier. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public byte[] dot11Bssid; - /// - /// Specifies whether the network is infrastructure or ad hoc. - /// - public Dot11BssType dot11BssType; - public Dot11PhyType dot11BssPhyType; - /// - /// The received signal strength in dBm. - /// - public int rssi; - /// - /// The link quality reported by the driver. Ranges from 0-100. - /// - public uint linkQuality; - /// - /// If 802.11d is not implemented, the network interface card (NIC) must set this field to TRUE. If 802.11d is implemented (but not necessarily enabled), the NIC must set this field to TRUE if the BSS operation complies with the configured regulatory domain. - /// - public bool inRegDomain; - /// - /// Contains the beacon interval value from the beacon packet or probe response. - /// - public ushort beaconPeriod; - /// - /// The timestamp from the beacon packet or probe response. - /// - public ulong timestamp; - /// - /// The host timestamp value when the beacon or probe response is received. - /// - public ulong hostTimestamp; - /// - /// The capability value from the beacon packet or probe response. - /// - public ushort capabilityInformation; - /// - /// The frequency of the center channel, in kHz. - /// - public uint chCenterFrequency; - /// - /// Contains the set of data transfer rates supported by the BSS. - /// - public WlanRateSet wlanRateSet; - /// - /// Offset of the information element (IE) data blob. - /// - public uint ieOffset; - /// - /// Size of the IE data blob, in bytes. - /// - public uint ieSize; - } - - /// - /// Contains the set of supported data rates. - /// - [StructLayout(LayoutKind.Sequential)] - public struct WlanRateSet - { - /// - /// The length, in bytes, of . - /// - private uint rateSetLength; - /// - /// An array of supported data transfer rates. - /// If the rate is a basic rate, the first bit of the rate value is set to 1. - /// A basic rate is the data transfer rate that all stations in a basic service set (BSS) can use to receive frames from the wireless medium. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 126)] - private ushort[] rateSet; - - public ushort[] Rates - { - get - { - ushort[] rates = new ushort[rateSetLength / sizeof(ushort)]; - Array.Copy(rateSet, rates, rates.Length); - return rates; - } - } - - /// - /// CalculateS the data transfer rate in Mbps for an arbitrary supported rate. - /// - /// - /// - public double GetRateInMbps(int rate) - { - return (rateSet[rate] & 0x7FFF) * 0.5; - } - } - - /// - /// Represents an error occuring during WLAN operations which indicate their failure via a . - /// - public class WlanException : Exception - { - private WlanReasonCode reasonCode; - - WlanException(WlanReasonCode reasonCode) - { - this.reasonCode = reasonCode; - } - - /// - /// Gets the WLAN reason code. - /// - /// The WLAN reason code. - public WlanReasonCode ReasonCode - { - get { return reasonCode; } - } - - /// - /// Gets a message that describes the reason code. - /// - /// - /// The error message that explains the reason for the exception, or an empty string(""). - public override string Message - { - get - { - StringBuilder sb = new StringBuilder(1024); - if (WlanReasonCodeToString(reasonCode, sb.Capacity, sb, IntPtr.Zero) == 0) - return sb.ToString(); - else - return string.Empty; - } - } - } - - // TODO: .NET-ify the WlanReasonCode enum (naming convention + docs). - - /// - /// Specifies reasons for a failure of a WLAN operation. - /// - /// - /// To get the WLAN API native reason code identifiers, prefix the identifiers with WLAN_REASON_CODE_. - /// - public enum WlanReasonCode - { - Success = 0, - // general codes - UNKNOWN = 0x10000 + 1, - - RANGE_SIZE = 0x10000, - BASE = 0x10000 + RANGE_SIZE, - - // range for Auto Config - // - AC_BASE = 0x10000 + RANGE_SIZE, - AC_CONNECT_BASE = (AC_BASE + RANGE_SIZE / 2), - AC_END = (AC_BASE + RANGE_SIZE - 1), - - // range for profile manager - // it has profile adding failure reason codes, but may not have - // connection reason codes - // - PROFILE_BASE = 0x10000 + (7 * RANGE_SIZE), - PROFILE_CONNECT_BASE = (PROFILE_BASE + RANGE_SIZE / 2), - PROFILE_END = (PROFILE_BASE + RANGE_SIZE - 1), - - // range for MSM - // - MSM_BASE = 0x10000 + (2 * RANGE_SIZE), - MSM_CONNECT_BASE = (MSM_BASE + RANGE_SIZE / 2), - MSM_END = (MSM_BASE + RANGE_SIZE - 1), - - // range for MSMSEC - // - MSMSEC_BASE = 0x10000 + (3 * RANGE_SIZE), - MSMSEC_CONNECT_BASE = (MSMSEC_BASE + RANGE_SIZE / 2), - MSMSEC_END = (MSMSEC_BASE + RANGE_SIZE - 1), - - // AC network incompatible reason codes - // - NETWORK_NOT_COMPATIBLE = (AC_BASE + 1), - PROFILE_NOT_COMPATIBLE = (AC_BASE + 2), - - // AC connect reason code - // - NO_AUTO_CONNECTION = (AC_CONNECT_BASE + 1), - NOT_VISIBLE = (AC_CONNECT_BASE + 2), - GP_DENIED = (AC_CONNECT_BASE + 3), - USER_DENIED = (AC_CONNECT_BASE + 4), - BSS_TYPE_NOT_ALLOWED = (AC_CONNECT_BASE + 5), - IN_FAILED_LIST = (AC_CONNECT_BASE + 6), - IN_BLOCKED_LIST = (AC_CONNECT_BASE + 7), - SSID_LIST_TOO_LONG = (AC_CONNECT_BASE + 8), - CONNECT_CALL_FAIL = (AC_CONNECT_BASE + 9), - SCAN_CALL_FAIL = (AC_CONNECT_BASE + 10), - NETWORK_NOT_AVAILABLE = (AC_CONNECT_BASE + 11), - PROFILE_CHANGED_OR_DELETED = (AC_CONNECT_BASE + 12), - KEY_MISMATCH = (AC_CONNECT_BASE + 13), - USER_NOT_RESPOND = (AC_CONNECT_BASE + 14), - - // Profile validation errors - // - INVALID_PROFILE_SCHEMA = (PROFILE_BASE + 1), - PROFILE_MISSING = (PROFILE_BASE + 2), - INVALID_PROFILE_NAME = (PROFILE_BASE + 3), - INVALID_PROFILE_TYPE = (PROFILE_BASE + 4), - INVALID_PHY_TYPE = (PROFILE_BASE + 5), - MSM_SECURITY_MISSING = (PROFILE_BASE + 6), - IHV_SECURITY_NOT_SUPPORTED = (PROFILE_BASE + 7), - IHV_OUI_MISMATCH = (PROFILE_BASE + 8), - // IHV OUI not present but there is IHV settings in profile - IHV_OUI_MISSING = (PROFILE_BASE + 9), - // IHV OUI is present but there is no IHV settings in profile - IHV_SETTINGS_MISSING = (PROFILE_BASE + 10), - // both/conflict MSMSec and IHV security settings exist in profile - CONFLICT_SECURITY = (PROFILE_BASE + 11), - // no IHV or MSMSec security settings in profile - SECURITY_MISSING = (PROFILE_BASE + 12), - INVALID_BSS_TYPE = (PROFILE_BASE + 13), - INVALID_ADHOC_CONNECTION_MODE = (PROFILE_BASE + 14), - NON_BROADCAST_SET_FOR_ADHOC = (PROFILE_BASE + 15), - AUTO_SWITCH_SET_FOR_ADHOC = (PROFILE_BASE + 16), - AUTO_SWITCH_SET_FOR_MANUAL_CONNECTION = (PROFILE_BASE + 17), - IHV_SECURITY_ONEX_MISSING = (PROFILE_BASE + 18), - PROFILE_SSID_INVALID = (PROFILE_BASE + 19), - TOO_MANY_SSID = (PROFILE_BASE + 20), - - // MSM network incompatible reasons - // - UNSUPPORTED_SECURITY_SET_BY_OS = (MSM_BASE + 1), - UNSUPPORTED_SECURITY_SET = (MSM_BASE + 2), - BSS_TYPE_UNMATCH = (MSM_BASE + 3), - PHY_TYPE_UNMATCH = (MSM_BASE + 4), - DATARATE_UNMATCH = (MSM_BASE + 5), - - // MSM connection failure reasons, to be defined - // failure reason codes - // - // user called to disconnect - USER_CANCELLED = (MSM_CONNECT_BASE + 1), - // got disconnect while associating - ASSOCIATION_FAILURE = (MSM_CONNECT_BASE + 2), - // timeout for association - ASSOCIATION_TIMEOUT = (MSM_CONNECT_BASE + 3), - // pre-association security completed with failure - PRE_SECURITY_FAILURE = (MSM_CONNECT_BASE + 4), - // fail to start post-association security - START_SECURITY_FAILURE = (MSM_CONNECT_BASE + 5), - // post-association security completed with failure - SECURITY_FAILURE = (MSM_CONNECT_BASE + 6), - // security watchdog timeout - SECURITY_TIMEOUT = (MSM_CONNECT_BASE + 7), - // got disconnect from driver when roaming - ROAMING_FAILURE = (MSM_CONNECT_BASE + 8), - // failed to start security for roaming - ROAMING_SECURITY_FAILURE = (MSM_CONNECT_BASE + 9), - // failed to start security for adhoc-join - ADHOC_SECURITY_FAILURE = (MSM_CONNECT_BASE + 10), - // got disconnection from driver - DRIVER_DISCONNECTED = (MSM_CONNECT_BASE + 11), - // driver operation failed - DRIVER_OPERATION_FAILURE = (MSM_CONNECT_BASE + 12), - // Ihv service is not available - IHV_NOT_AVAILABLE = (MSM_CONNECT_BASE + 13), - // Response from ihv timed out - IHV_NOT_RESPONDING = (MSM_CONNECT_BASE + 14), - // Timed out waiting for driver to disconnect - DISCONNECT_TIMEOUT = (MSM_CONNECT_BASE + 15), - // An internal error prevented the operation from being completed. - INTERNAL_FAILURE = (MSM_CONNECT_BASE + 16), - // UI Request timed out. - UI_REQUEST_TIMEOUT = (MSM_CONNECT_BASE + 17), - // Roaming too often, post security is not completed after 5 times. - TOO_MANY_SECURITY_ATTEMPTS = (MSM_CONNECT_BASE + 18), - - // MSMSEC reason codes - // - - MSMSEC_MIN = MSMSEC_BASE, - - // Key index specified is not valid - MSMSEC_PROFILE_INVALID_KEY_INDEX = (MSMSEC_BASE + 1), - // Key required, PSK present - MSMSEC_PROFILE_PSK_PRESENT = (MSMSEC_BASE + 2), - // Invalid key length - MSMSEC_PROFILE_KEY_LENGTH = (MSMSEC_BASE + 3), - // Invalid PSK length - MSMSEC_PROFILE_PSK_LENGTH = (MSMSEC_BASE + 4), - // No auth/cipher specified - MSMSEC_PROFILE_NO_AUTH_CIPHER_SPECIFIED = (MSMSEC_BASE + 5), - // Too many auth/cipher specified - MSMSEC_PROFILE_TOO_MANY_AUTH_CIPHER_SPECIFIED = (MSMSEC_BASE + 6), - // Profile contains duplicate auth/cipher - MSMSEC_PROFILE_DUPLICATE_AUTH_CIPHER = (MSMSEC_BASE + 7), - // Profile raw data is invalid (1x or key data) - MSMSEC_PROFILE_RAWDATA_INVALID = (MSMSEC_BASE + 8), - // Invalid auth/cipher combination - MSMSEC_PROFILE_INVALID_AUTH_CIPHER = (MSMSEC_BASE + 9), - // 802.1x disabled when it's required to be enabled - MSMSEC_PROFILE_ONEX_DISABLED = (MSMSEC_BASE + 10), - // 802.1x enabled when it's required to be disabled - MSMSEC_PROFILE_ONEX_ENABLED = (MSMSEC_BASE + 11), - MSMSEC_PROFILE_INVALID_PMKCACHE_MODE = (MSMSEC_BASE + 12), - MSMSEC_PROFILE_INVALID_PMKCACHE_SIZE = (MSMSEC_BASE + 13), - MSMSEC_PROFILE_INVALID_PMKCACHE_TTL = (MSMSEC_BASE + 14), - MSMSEC_PROFILE_INVALID_PREAUTH_MODE = (MSMSEC_BASE + 15), - MSMSEC_PROFILE_INVALID_PREAUTH_THROTTLE = (MSMSEC_BASE + 16), - // PreAuth enabled when PMK cache is disabled - MSMSEC_PROFILE_PREAUTH_ONLY_ENABLED = (MSMSEC_BASE + 17), - // Capability matching failed at network - MSMSEC_CAPABILITY_NETWORK = (MSMSEC_BASE + 18), - // Capability matching failed at NIC - MSMSEC_CAPABILITY_NIC = (MSMSEC_BASE + 19), - // Capability matching failed at profile - MSMSEC_CAPABILITY_PROFILE = (MSMSEC_BASE + 20), - // Network does not support specified discovery type - MSMSEC_CAPABILITY_DISCOVERY = (MSMSEC_BASE + 21), - // Passphrase contains invalid character - MSMSEC_PROFILE_PASSPHRASE_CHAR = (MSMSEC_BASE + 22), - // Key material contains invalid character - MSMSEC_PROFILE_KEYMATERIAL_CHAR = (MSMSEC_BASE + 23), - // Wrong key type specified for the auth/cipher pair - MSMSEC_PROFILE_WRONG_KEYTYPE = (MSMSEC_BASE + 24), - // "Mixed cell" suspected (AP not beaconing privacy, we have privacy enabled profile) - MSMSEC_MIXED_CELL = (MSMSEC_BASE + 25), - // Auth timers or number of timeouts in profile is incorrect - MSMSEC_PROFILE_AUTH_TIMERS_INVALID = (MSMSEC_BASE + 26), - // Group key update interval in profile is incorrect - MSMSEC_PROFILE_INVALID_GKEY_INTV = (MSMSEC_BASE + 27), - // "Transition network" suspected, trying legacy 802.11 security - MSMSEC_TRANSITION_NETWORK = (MSMSEC_BASE + 28), - // Key contains characters which do not map to ASCII - MSMSEC_PROFILE_KEY_UNMAPPED_CHAR = (MSMSEC_BASE + 29), - // Capability matching failed at profile (auth not found) - MSMSEC_CAPABILITY_PROFILE_AUTH = (MSMSEC_BASE + 30), - // Capability matching failed at profile (cipher not found) - MSMSEC_CAPABILITY_PROFILE_CIPHER = (MSMSEC_BASE + 31), - - // Failed to queue UI request - MSMSEC_UI_REQUEST_FAILURE = (MSMSEC_CONNECT_BASE + 1), - // 802.1x authentication did not start within configured time - MSMSEC_AUTH_START_TIMEOUT = (MSMSEC_CONNECT_BASE + 2), - // 802.1x authentication did not complete within configured time - MSMSEC_AUTH_SUCCESS_TIMEOUT = (MSMSEC_CONNECT_BASE + 3), - // Dynamic key exchange did not start within configured time - MSMSEC_KEY_START_TIMEOUT = (MSMSEC_CONNECT_BASE + 4), - // Dynamic key exchange did not succeed within configured time - MSMSEC_KEY_SUCCESS_TIMEOUT = (MSMSEC_CONNECT_BASE + 5), - // Message 3 of 4 way handshake has no key data (RSN/WPA) - MSMSEC_M3_MISSING_KEY_DATA = (MSMSEC_CONNECT_BASE + 6), - // Message 3 of 4 way handshake has no IE (RSN/WPA) - MSMSEC_M3_MISSING_IE = (MSMSEC_CONNECT_BASE + 7), - // Message 3 of 4 way handshake has no Group Key (RSN) - MSMSEC_M3_MISSING_GRP_KEY = (MSMSEC_CONNECT_BASE + 8), - // Matching security capabilities of IE in M3 failed (RSN/WPA) - MSMSEC_PR_IE_MATCHING = (MSMSEC_CONNECT_BASE + 9), - // Matching security capabilities of Secondary IE in M3 failed (RSN) - MSMSEC_SEC_IE_MATCHING = (MSMSEC_CONNECT_BASE + 10), - // Required a pairwise key but AP configured only group keys - MSMSEC_NO_PAIRWISE_KEY = (MSMSEC_CONNECT_BASE + 11), - // Message 1 of group key handshake has no key data (RSN/WPA) - MSMSEC_G1_MISSING_KEY_DATA = (MSMSEC_CONNECT_BASE + 12), - // Message 1 of group key handshake has no group key - MSMSEC_G1_MISSING_GRP_KEY = (MSMSEC_CONNECT_BASE + 13), - // AP reset secure bit after connection was secured - MSMSEC_PEER_INDICATED_INSECURE = (MSMSEC_CONNECT_BASE + 14), - // 802.1x indicated there is no authenticator but profile requires 802.1x - MSMSEC_NO_AUTHENTICATOR = (MSMSEC_CONNECT_BASE + 15), - // Plumbing settings to NIC failed - MSMSEC_NIC_FAILURE = (MSMSEC_CONNECT_BASE + 16), - // Operation was cancelled by caller - MSMSEC_CANCELLED = (MSMSEC_CONNECT_BASE + 17), - // Key was in incorrect format - MSMSEC_KEY_FORMAT = (MSMSEC_CONNECT_BASE + 18), - // Security downgrade detected - MSMSEC_DOWNGRADE_DETECTED = (MSMSEC_CONNECT_BASE + 19), - // PSK mismatch suspected - MSMSEC_PSK_MISMATCH_SUSPECTED = (MSMSEC_CONNECT_BASE + 20), - // Forced failure because connection method was not secure - MSMSEC_FORCED_FAILURE = (MSMSEC_CONNECT_BASE + 21), - // ui request couldn't be queued or user pressed cancel - MSMSEC_SECURITY_UI_FAILURE = (MSMSEC_CONNECT_BASE + 22), - - MSMSEC_MAX = MSMSEC_END - } - - /// - /// Contains information about connection related notifications. - /// - /// - /// Corresponds to the native WLAN_CONNECTION_NOTIFICATION_DATA type. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct WlanConnectionNotificationData - { - /// - /// On Windows XP SP 2, only is supported. - /// - public WlanConnectionMode wlanConnectionMode; - /// - /// The name of the profile used for the connection. Profile names are case-sensitive. - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] - public string profileName; - /// - /// The SSID of the association. - /// - public Dot11Ssid dot11Ssid; - /// - /// The BSS network type. - /// - public Dot11BssType dot11BssType; - /// - /// Indicates whether security is enabled for this connection. - /// - public bool securityEnabled; - /// - /// Indicates the reason for an operation failure. - /// This field has a value of for all connection-related notifications except . - /// If the connection fails, this field indicates the reason for the failure. - /// - public WlanReasonCode wlanReasonCode; - /// - /// This field contains the XML presentation of the profile used for discovery, if the connection succeeds. - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] - public string profileXml; - } - - /// - /// Indicates the state of an interface. - /// - /// - /// Corresponds to the native WLAN_INTERFACE_STATE type. - /// - public enum WlanInterfaceState - { - /// - /// The interface is not ready to operate. - /// - NotReady = 0, - /// - /// The interface is connected to a network. - /// - Connected = 1, - /// - /// The interface is the first node in an ad hoc network. No peer has connected. - /// - AdHocNetworkFormed = 2, - /// - /// The interface is disconnecting from the current network. - /// - Disconnecting = 3, - /// - /// The interface is not connected to any network. - /// - Disconnected = 4, - /// - /// The interface is attempting to associate with a network. - /// - Associating = 5, - /// - /// Auto configuration is discovering the settings for the network. - /// - Discovering = 6, - /// - /// The interface is in the process of authenticating. - /// - Authenticating = 7 - } - - /// - /// Contains the SSID of an interface. - /// - public struct Dot11Ssid - { - /// - /// The length, in bytes, of the array. - /// - public uint SSIDLength; - /// - /// The SSID. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public byte[] SSID; - } - - /// - /// Defines an 802.11 PHY and media type. - /// - /// - /// Corresponds to the native DOT11_PHY_TYPE type. - /// - public enum Dot11PhyType : uint - { - /// - /// Specifies an unknown or uninitialized PHY type. - /// - Unknown = 0, - /// - /// Specifies any PHY type. - /// - Any = Unknown, - /// - /// Specifies a frequency-hopping spread-spectrum (FHSS) PHY. Bluetooth devices can use FHSS or an adaptation of FHSS. - /// - FHSS = 1, - /// - /// Specifies a direct sequence spread spectrum (DSSS) PHY. - /// - DSSS = 2, - /// - /// Specifies an infrared (IR) baseband PHY. - /// - IrBaseband = 3, - /// - /// Specifies an orthogonal frequency division multiplexing (OFDM) PHY. 802.11a devices can use OFDM. - /// - OFDM = 4, - /// - /// Specifies a high-rate DSSS (HRDSSS) PHY. - /// - HRDSSS = 5, - /// - /// Specifies an extended rate PHY (ERP). 802.11g devices can use ERP. - /// - ERP = 6, - /// - /// Specifies the start of the range that is used to define PHY types that are developed by an independent hardware vendor (IHV). - /// - IHV_Start = 0x80000000, - /// - /// Specifies the end of the range that is used to define PHY types that are developed by an independent hardware vendor (IHV). - /// - IHV_End = 0xffffffff - } - - /// - /// Defines a basic service set (BSS) network type. - /// - /// - /// Corresponds to the native DOT11_BSS_TYPE type. - /// - public enum Dot11BssType - { - /// - /// Specifies an infrastructure BSS network. - /// - Infrastructure = 1, - /// - /// Specifies an independent BSS (IBSS) network. - /// - Independent = 2, - /// - /// Specifies either infrastructure or IBSS network. - /// - Any = 3 - } - - /// - /// Contains association attributes for a connection - /// - /// - /// Corresponds to the native WLAN_ASSOCIATION_ATTRIBUTES type. - /// - [StructLayout(LayoutKind.Sequential)] - public struct WlanAssociationAttributes - { - /// - /// The SSID of the association. - /// - public Dot11Ssid dot11Ssid; - /// - /// Specifies whether the network is infrastructure or ad hoc. - /// - public Dot11BssType dot11BssType; - /// - /// The BSSID of the association. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public byte[] dot11Bssid; - /// - /// The physical type of the association. - /// - public Dot11PhyType dot11PhyType; - /// - /// The position of the value in the structure containing the list of PHY types. - /// - public uint dot11PhyIndex; - /// - /// A percentage value that represents the signal quality of the network. - /// This field contains a value between 0 and 100. - /// A value of 0 implies an actual RSSI signal strength of -100 dbm. - /// A value of 100 implies an actual RSSI signal strength of -50 dbm. - /// You can calculate the RSSI signal strength value for values between 1 and 99 using linear interpolation. - /// - public uint wlanSignalQuality; - /// - /// The receiving rate of the association. - /// - public uint rxRate; - /// - /// The transmission rate of the association. - /// - public uint txRate; - - /// - /// Gets the BSSID of the associated access point. - /// - /// The BSSID. - public PhysicalAddress Dot11Bssid - { - get { return new PhysicalAddress(dot11Bssid); } - } - } - - /// - /// Defines the mode of connection. - /// - /// - /// Corresponds to the native WLAN_CONNECTION_MODE type. - /// - public enum WlanConnectionMode - { - /// - /// A profile will be used to make the connection. - /// - Profile = 0, - /// - /// A temporary profile will be used to make the connection. - /// - TemporaryProfile, - /// - /// Secure discovery will be used to make the connection. - /// - DiscoverySecure, - /// - /// Unsecure discovery will be used to make the connection. - /// - DiscoveryUnsecure, - /// - /// A connection will be made automatically, generally using a persistent profile. - /// - Auto, - /// - /// Not used. - /// - Invalid - } - - /// - /// Defines a wireless LAN authentication algorithm. - /// - /// - /// Corresponds to the native DOT11_AUTH_ALGORITHM type. - /// - public enum Dot11AuthAlgorithm : uint - { - /// - /// Specifies an IEEE 802.11 Open System authentication algorithm. - /// - IEEE80211_Open = 1, - /// - /// Specifies an 802.11 Shared Key authentication algorithm that requires the use of a pre-shared Wired Equivalent Privacy (WEP) key for the 802.11 authentication. - /// - IEEE80211_SharedKey = 2, - /// - /// Specifies a Wi-Fi Protected Access (WPA) algorithm. IEEE 802.1X port authentication is performed by the supplicant, authenticator, and authentication server. Cipher keys are dynamically derived through the authentication process. - /// This algorithm is valid only for BSS types of . - /// When the WPA algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 1 (802.1X) within the WPA information element (IE). - /// - WPA = 3, - /// - /// Specifies a WPA algorithm that uses preshared keys (PSK). IEEE 802.1X port authentication is performed by the supplicant and authenticator. Cipher keys are dynamically derived through a preshared key that is used on both the supplicant and authenticator. - /// This algorithm is valid only for BSS types of . - /// When the WPA PSK algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 2 (preshared key) within the WPA IE. - /// - WPA_PSK = 4, - /// - /// This value is not supported. - /// - WPA_None = 5, - /// - /// Specifies an 802.11i Robust Security Network Association (RSNA) algorithm. WPA2 is one such algorithm. IEEE 802.1X port authentication is performed by the supplicant, authenticator, and authentication server. Cipher keys are dynamically derived through the authentication process. - /// This algorithm is valid only for BSS types of . - /// When the RSNA algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 1 (802.1X) within the RSN IE. - /// - RSNA = 6, - /// - /// Specifies an 802.11i RSNA algorithm that uses PSK. IEEE 802.1X port authentication is performed by the supplicant and authenticator. Cipher keys are dynamically derived through a preshared key that is used on both the supplicant and authenticator. - /// This algorithm is valid only for BSS types of . - /// When the RSNA PSK algorithm is enabled, the 802.11 station will associate only with an access point whose beacon or probe responses contain the authentication suite of type 2(preshared key) within the RSN IE. - /// - RSNA_PSK = 7, - /// - /// Indicates the start of the range that specifies proprietary authentication algorithms that are developed by an IHV. - /// - /// - /// This enumerator is valid only when the miniport driver is operating in Extensible Station (ExtSTA) mode. - /// - IHV_Start = 0x80000000, - /// - /// Indicates the end of the range that specifies proprietary authentication algorithms that are developed by an IHV. - /// - /// - /// This enumerator is valid only when the miniport driver is operating in Extensible Station (ExtSTA) mode. - /// - IHV_End = 0xffffffff - } - - /// - /// Defines a cipher algorithm for data encryption and decryption. - /// - /// - /// Corresponds to the native DOT11_CIPHER_ALGORITHM type. - /// - public enum Dot11CipherAlgorithm : uint - { - /// - /// Specifies that no cipher algorithm is enabled or supported. - /// - None = 0x00, - /// - /// Specifies a Wired Equivalent Privacy (WEP) algorithm, which is the RC4-based algorithm that is specified in the 802.11-1999 standard. This enumerator specifies the WEP cipher algorithm with a 40-bit cipher key. - /// - WEP40 = 0x01, - /// - /// Specifies a Temporal Key Integrity Protocol (TKIP) algorithm, which is the RC4-based cipher suite that is based on the algorithms that are defined in the WPA specification and IEEE 802.11i-2004 standard. This cipher also uses the Michael Message Integrity Code (MIC) algorithm for forgery protection. - /// - TKIP = 0x02, - /// - /// Specifies an AES-CCMP algorithm, as specified in the IEEE 802.11i-2004 standard and RFC 3610. Advanced Encryption Standard (AES) is the encryption algorithm defined in FIPS PUB 197. - /// - CCMP = 0x04, - /// - /// Specifies a WEP cipher algorithm with a 104-bit cipher key. - /// - WEP104 = 0x05, - /// - /// Specifies a Robust Security Network (RSN) Use Group Key cipher suite. For more information about the Use Group Key cipher suite, refer to Clause 7.3.2.9.1 of the IEEE 802.11i-2004 standard. - /// - WPA_UseGroup = 0x100, - /// - /// Specifies a Wifi Protected Access (WPA) Use Group Key cipher suite. For more information about the Use Group Key cipher suite, refer to Clause 7.3.2.9.1 of the IEEE 802.11i-2004 standard. - /// - RSN_UseGroup = 0x100, - /// - /// Specifies a WEP cipher algorithm with a cipher key of any length. - /// - WEP = 0x101, - /// - /// Specifies the start of the range that is used to define proprietary cipher algorithms that are developed by an independent hardware vendor (IHV). - /// - IHV_Start = 0x80000000, - /// - /// Specifies the end of the range that is used to define proprietary cipher algorithms that are developed by an IHV. - /// - IHV_End = 0xffffffff - } - - /// - /// Defines the security attributes for a wireless connection. - /// - /// - /// Corresponds to the native WLAN_SECURITY_ATTRIBUTES type. - /// - [StructLayout(LayoutKind.Sequential)] - public struct WlanSecurityAttributes - { - /// - /// Indicates whether security is enabled for this connection. - /// - [MarshalAs(UnmanagedType.Bool)] - public bool securityEnabled; - [MarshalAs(UnmanagedType.Bool)] - public bool oneXEnabled; - /// - /// The authentication algorithm. - /// - public Dot11AuthAlgorithm dot11AuthAlgorithm; - /// - /// The cipher algorithm. - /// - public Dot11CipherAlgorithm dot11CipherAlgorithm; - } - - /// - /// Defines the attributes of a wireless connection. - /// - /// - /// Corresponds to the native WLAN_CONNECTION_ATTRIBUTES type. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct WlanConnectionAttributes - { - /// - /// The state of the interface. - /// - public WlanInterfaceState isState; - /// - /// The mode of the connection. - /// - public WlanConnectionMode wlanConnectionMode; - /// - /// The name of the profile used for the connection. Profile names are case-sensitive. - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string profileName; - /// - /// The attributes of the association. - /// - public WlanAssociationAttributes wlanAssociationAttributes; - /// - /// The security attributes of the connection. - /// - public WlanSecurityAttributes wlanSecurityAttributes; - } - - /// - /// Contains information about a LAN interface. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct WlanInterfaceInfo - { - /// - /// The GUID of the interface. - /// - public Guid interfaceGuid; - /// - /// The description of the interface. - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string interfaceDescription; - /// - /// The current state of the interface. - /// - public WlanInterfaceState isState; - } - - /// - /// The header of the list returned by . - /// - [StructLayout(LayoutKind.Sequential)] - internal struct WlanInterfaceInfoListHeader - { - public uint numberOfItems; - public uint index; - } - - /// - /// The header of the list returned by . - /// - [StructLayout(LayoutKind.Sequential)] - internal struct WlanProfileInfoListHeader - { - public uint numberOfItems; - public uint index; - } - - /// - /// Contains basic information about a profile. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct WlanProfileInfo - { - /// - /// The name of the profile. This value may be the name of a domain if the profile is for provisioning. Profile names are case-sensitive. - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string profileName; - /// - /// Profile flags. - /// - public WlanProfileFlags profileFlags; - } - - /// - /// Flags that specifiy the miniport driver's current operation mode. - /// - [Flags] - public enum Dot11OperationMode : uint - { - Unknown = 0x00000000, - Station = 0x00000001, - AP = 0x00000002, - /// - /// Specifies that the miniport driver supports the Extensible Station (ExtSTA) operation mode. - /// - ExtensibleStation = 0x00000004, - /// - /// Specifies that the miniport driver supports the Network Monitor (NetMon) operation mode. - /// - NetworkMonitor = 0x80000000 - } - #endregion - - /// - /// Helper method to wrap calls to Native WiFi API methods. - /// If the method falls, throws an exception containing the error code. - /// - /// The error code. - [DebuggerStepThrough] - internal static void ThrowIfError(int win32ErrorCode) - { - if (win32ErrorCode != 0) - throw new Win32Exception(win32ErrorCode); - } - } -} diff --git a/NetWork/Windows.Common/Wifi/WlanApi.cs b/NetWork/Windows.Common/Wifi/WlanApi.cs deleted file mode 100644 index fc3bbfd..0000000 --- a/NetWork/Windows.Common/Wifi/WlanApi.cs +++ /dev/null @@ -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 -{ - /// - /// Represents a client to the Zeroconf (Native Wifi) service. - /// - /// - /// This class is the entrypoint to Native Wifi management. To manage WiFi settings, create an instance - /// of this class. - /// - public class WlanClient - { - /// - /// Represents a Wifi network interface. - /// - public class WlanInterface - { - private WlanClient client; - private Wlan.WlanInterfaceInfo info; - - #region Events - /// - /// Represents a method that will handle events. - /// - /// The notification data. - public delegate void WlanNotificationEventHandler(Wlan.WlanNotificationData notifyData); - - /// - /// Represents a method that will handle events. - /// - /// The notification data. - /// The notification data. - public delegate void WlanConnectionNotificationEventHandler(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData); - - /// - /// Represents a method that will handle events. - /// - /// The notification data. - /// The reason code. - public delegate void WlanReasonNotificationEventHandler(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode); - - /// - /// Occurs when an event of any kind occurs on a WLAN interface. - /// - public event WlanNotificationEventHandler WlanNotification; - - /// - /// Occurs when a WLAN interface changes connection state. - /// - public event WlanConnectionNotificationEventHandler WlanConnectionNotification; - - /// - /// Occurs when a WLAN operation fails due to some reason. - /// - public event WlanReasonNotificationEventHandler WlanReasonNotification; - - #endregion - - #region Event queue - private bool queueEvents; - private AutoResetEvent eventQueueFilled = new AutoResetEvent(false); - private Queue eventQueue = new Queue(); - - 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; - } - - /// - /// Sets a parameter of the interface whose data type is . - /// - /// The opcode of the parameter. - /// The value to set. - 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); - } - } - - /// - /// Gets a parameter of the interface whose data type is . - /// - /// The opcode of the parameter. - /// The integer value. - 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); - } - } - - /// - /// Gets or sets a value indicating whether this is automatically configured. - /// - /// true if "autoconf" is enabled; otherwise, false. - public bool Autoconf - { - get - { - return GetInterfaceInt(Wlan.WlanIntfOpcode.AutoconfEnabled) != 0; - } - set - { - SetInterfaceInt(Wlan.WlanIntfOpcode.AutoconfEnabled, value ? 1 : 0); - } - } - - /// - /// Gets or sets the BSS type for the indicated interface. - /// - /// The type of the BSS. - public Wlan.Dot11BssType BssType - { - get - { - return (Wlan.Dot11BssType) GetInterfaceInt(Wlan.WlanIntfOpcode.BssType); - } - set - { - SetInterfaceInt(Wlan.WlanIntfOpcode.BssType, (int)value); - } - } - - /// - /// Gets the state of the interface. - /// - /// The state of the interface. - public Wlan.WlanInterfaceState InterfaceState - { - get - { - return (Wlan.WlanInterfaceState)GetInterfaceInt(Wlan.WlanIntfOpcode.InterfaceState); - } - } - - /// - /// Gets the channel. - /// - /// The channel. - /// Not supported on Windows XP SP2. - public int Channel - { - get - { - return GetInterfaceInt(Wlan.WlanIntfOpcode.ChannelNumber); - } - } - - /// - /// Gets the RSSI. - /// - /// The RSSI. - /// Not supported on Windows XP SP2. - public int RSSI - { - get - { - return GetInterfaceInt(Wlan.WlanIntfOpcode.RSSI); - } - } - - /// - /// Gets the current operation mode. - /// - /// The current operation mode. - /// Not supported on Windows XP SP2. - public Wlan.Dot11OperationMode CurrentOperationMode - { - get - { - return (Wlan.Dot11OperationMode) GetInterfaceInt(Wlan.WlanIntfOpcode.CurrentOperationMode); - } - } - - /// - /// Gets the attributes of the current connection. - /// - /// The current connection attributes. - /// 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. - 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); - } - } - } - - /// - /// Requests a scan for available networks. - /// - /// - /// The method returns immediately. Progress is reported through the event. - /// - public void Scan() - { - Wlan.ThrowIfError( - Wlan.WlanScan(client.clientHandle, info.interfaceGuid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)); - } - - /// - /// Converts a pointer to a available networks list (header + entries) to an array of available network entries. - /// - /// A pointer to an available networks list's header. - /// An array of available network entries. - 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; - } - - /// - /// Retrieves the list of available networks. - /// - /// Controls the type of networks returned. - /// A list of the available networks. - 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); - } - } - - /// - /// Converts a pointer to a BSS list (header + entries) to an array of BSS entries. - /// - /// A pointer to a BSS list's header. - /// An array of BSS entries. - 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 - /// Retrieves the basic service sets (BSS) list of all available networks. - /// - 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); - } - } - - /// - /// Retrieves the basic service sets (BSS) list of the specified network. - /// - /// Specifies the SSID of the network from which the BSS list is requested. - /// Indicates the BSS type of the network. - /// Indicates whether security is enabled on the network. - 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); - } - } - - /// - /// Connects to a network defined by a connection parameters structure. - /// - /// The connection paramters. - protected void Connect(Wlan.WlanConnectionParameters connectionParams) - { - Wlan.ThrowIfError( - Wlan.WlanConnect(client.clientHandle, info.interfaceGuid, ref connectionParams, IntPtr.Zero)); - } - - /// - /// Requests a connection (association) to the specified wireless network. - /// - /// - /// The method returns immediately. Progress is reported through the event. - /// - 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); - } - - /// - /// Connects (associates) to the specified wireless network, returning either on a success to connect - /// or a failure. - /// - /// - /// - /// - /// - /// - 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" - } - - /// - /// Connects to the specified wireless network. - /// - /// - /// The method returns immediately. Progress is reported through the event. - /// - 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); - } - - /// - /// Deletes a profile. - /// - /// - /// 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 -adhoc. - /// - public void DeleteProfile(string profileName) - { - Wlan.ThrowIfError( - Wlan.WlanDeleteProfile(client.clientHandle, info.interfaceGuid, profileName, IntPtr.Zero)); - } - - /// - /// Sets the profile. - /// - /// The flags to set on the profile. - /// The XML representation of the profile. On Windows XP SP 2, special care should be taken to adhere to its limitations. - /// If a profile by the given name already exists, then specifies whether to overwrite it (if true) or return an error (if false). - /// The resulting code indicating a success or the reason why the profile wasn't valid. - 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; - } - - /// - /// Gets the profile's XML specification. - /// - /// The name of the profile. - /// The XML document. - 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); - } - } - - /// - /// Gets the information of all profiles on this interface. - /// - /// The profiles information. - 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 - /// Enqueues a notification event to be processed serially. - /// - private void EnqueueEvent(object queuedEvent) - { - lock (eventQueue) - eventQueue.Enqueue(queuedEvent); - eventQueueFilled.Set(); - } - - /// - /// Gets the network interface of this wireless interface. - /// - /// - /// The network interface allows querying of generic network properties such as the interface's IP address. - /// - 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; - } - } - - /// - /// The GUID of the interface (same content as the value). - /// - public Guid InterfaceGuid - { - get { return info.interfaceGuid; } - } - - /// - /// The description of the interface. - /// This is a user-immutable string containing the vendor and model name of the adapter. - /// - public string InterfaceDescription - { - get { return info.interfaceDescription; } - } - - /// - /// The friendly name given to the interface by the user (e.g. "Local Area Network Connection"). - /// - public string InterfaceName - { - get { return NetworkInterface.Name; } - } - } - - private IntPtr clientHandle; - private uint negotiatedVersion; - private Wlan.WlanNotificationCallbackDelegate wlanNotificationCallback; - - private Dictionary ifaces = new Dictionary(); - - /// - /// Creates a new instance of a Native Wifi service client. - /// - 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); - } - - /// - /// Gets the WLAN interfaces. - /// - /// The WLAN interfaces. - 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 currentIfaceGuids = new List(); - 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 deadIfacesGuids = new Queue(); - 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); - } - } - } - - /// - /// Gets a string that describes a specified reason code. - /// - /// The reason code. - /// The string. - 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(); - } - } -} diff --git a/NetWork/Windows.Common/Windows.Common.csproj b/NetWork/Windows.Common/Windows.Common.csproj deleted file mode 100644 index f23343a..0000000 --- a/NetWork/Windows.Common/Windows.Common.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Debug - AnyCPU - {DDFE602D-A0B5-4429-8B5C-E99155B6777A} - Library - Properties - Windows.Common - Windows.Common - v4.6 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/NetWork/Windows.Common/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs b/NetWork/Windows.Common/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs deleted file mode 100644 index a216cb0..0000000 --- a/NetWork/Windows.Common/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs +++ /dev/null @@ -1,4 +0,0 @@ -// -using System; -using System.Reflection; -[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] diff --git a/NetWork/Windows.Common/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/NetWork/Windows.Common/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index b8b02409d5d76e52f3c452975d4dbcbb26fd6b6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6658 zcmeHMZBH9V5VpZwFoYD-ln`jrOB=OG>YnVHcZm;)jT6)aA=@IAutnB)W3%C2+}%Bl zi})@51yz4yJ9D6)a>AE|H!g|L|;YqKd zjD0SBW|x(3anHzmj^nvIh3&My4?=R!-O8>S8TzF4yl*RCz?KWX63kBPdw$*K=5Nrc zc*o#w)ib%qN@J~&%~~rNmSYnHx&9fXS3b8b!rO5b2(R^CuvQC%QDS1pZTU(*#K8}l zZF_C7UP=j0-R^9kDsagwIfK3Pp4;HfBDZ1QWUj?6rl8-Gv~sE8+jdbf2il%E?l)Cf z9oz1I(pL0r3+MZolockLpu%Bgzb--Tq7nI&H(gIa0U8WLvExdG{tdkA8h&wer>?nf z*9ZK16OXRwFOJe}oTpTm+$?Ybrt$;_Ioq-n6J=n+JlbRGNX|AdDW+S(YhZ+ER&xTH zTq@BS3`pX{6i^5k(a^)b!4C`7wwm*Q*O$wrtiRz{>-BiMG@oxF62w+HQgtmJ+irddam6=JJrHw zb+=2Y^=?zO&0WiD%j)~?Z;zH&z52&$0qTAer9_%pK`K-N>DebC?;Y?S!(`?WB)=ke zXHhJE>QSHGlV@5A+vliV4_($tKZp86(Bo^mb0oL5`*=5nx{Q&_2E!zldOm5rFl%TmZ6!AoU19LaHes!1)$&RCG86rkFvZ z3~KPk6(B!~c7_2mrORW)sYN$Kg7^+08qq=Qf->GH)y+N~u~>9izdLrYI!~gV62ZLX z?jMAepwn{nj2}JYhx#@FH_kPfkm;K+$X$^V4O!;@}V3tRq4gy-tjxBSs7JQegl zTWyFU?}xqkLw=z-s7+2LzsFOrf2D{kQi)Uh0Yy22<2^-0G(dQYH;Ez^C*wp)1EzY> zl{m4~E7}y%R=QF|UCCSRM-&TZ`D?4C=h{!$I(PPlyNc>#R5;tgt#htDL;d1e<@!=! z=UjV^?ZaThFVN1+S&6lY3R0=?T>BYSxi2Qjb?){Ea*B8_F?=nJB8tV)enG)NDe|qep)Bpeg diff --git a/NetWork/Windows.Common/obj/Debug/Windows.Common.csproj.AssemblyReference.cache b/NetWork/Windows.Common/obj/Debug/Windows.Common.csproj.AssemblyReference.cache deleted file mode 100644 index 59a348fa6e1f86963741a833c9a6e610d21c0a68..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3982 zcmd5;O>fgc5cPo7y#x4!ER9Rk2%^~u7t+zYx&Agd|cf-I3xbJx$9QoVf2Pr0!roBCu zpz6JtzutNo4lzcFJi^{vr7#^O3{`l*A}N%Jb+~7~$FD*jhh)${{I@#YBwJysA|Vqt zBI6_hFsFFE$>s0)kB*lu;I4V|fD4(jF{gwl(^b3Radho@Y@f4_czm2~6pL&Jy5^*H zva!DL>Wv4VTL>apD2-`F2zM-P0G%RASg{dS{NOx)nMLhE$1E?-!jEg4zrJNV2IX0P zj4yc1CNoJj6TBAU_no8j$3MH<1!6Zx{FElOaF%ao(Uv)m+vC_=mFzQqQbD#&6=!6- zp$6c2PVsQYHA|5MC>c%IS$*-ANe8(17rB9O0IOFiC9wfeIRkWi8L&$=CH5~s-JfgZ z%9Mes$Ol_%&hnvP${yT+sar1Fqy^co8UgWxFH}z3R_Yej1;E3+z;+j$rYx$JIm>Qc zuCY-IVini5HCFD(wktWSC>J`pa_Oge+=r5KMI+l-RV}UlH|Iw=;9!;-!;hMQxo`Z1 zoB5)V?*pvmarU`JIh9PIX>g}3!g>+kl -using System; -using System.Reflection; -//[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] diff --git a/NetWork/Windows.Common/obj/Release/Windows.Common.csproj.AssemblyReference.cache b/NetWork/Windows.Common/obj/Release/Windows.Common.csproj.AssemblyReference.cache deleted file mode 100644 index f5e894aea93a73e58fa9d4feab241bc197ee1a40..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11 QcmeZu3JP{+WMlvW01Ze1dH?_b diff --git a/Network.cs b/Network.cs new file mode 100644 index 0000000..1b77e7a --- /dev/null +++ b/Network.cs @@ -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; + } + } +} diff --git a/mute.cs b/mute.cs new file mode 100644 index 0000000..7629afe --- /dev/null +++ b/mute.cs @@ -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; + } +}