Ejemplo n.º 1
0
        private static bool TurnInterfaceRadio(Guid interfaceId, DOT11_RADIO_STATE radioState)
        {
            using (var client = new Base.WlanClient())
            {
                var phyRadioState = new WLAN_PHY_RADIO_STATE {
                    dot11SoftwareRadioState = radioState,
                };

                return(Base.SetPhyRadioState(client.Handle, interfaceId, phyRadioState));
            }
        }
Ejemplo n.º 2
0
        internal static bool TurnInterfaceRadio(Base.WlanClient client, Guid interfaceId, DOT11_RADIO_STATE radioState)
        {
            if (interfaceId == Guid.Empty)
            {
                throw new ArgumentException(nameof(interfaceId));
            }

            using (var container = new DisposableContainer <Base.WlanClient>(client))
            {
                var phyRadioState = new WLAN_PHY_RADIO_STATE {
                    dot11SoftwareRadioState = radioState,
                };

                return(Base.SetPhyRadioState(container.Content.Handle, interfaceId, phyRadioState));
            }
        }
Ejemplo n.º 3
0
        public static bool SetPhyRadioState(SafeClientHandle clientHandle, Guid interfaceId, WLAN_PHY_RADIO_STATE state)
        {
            var size = Marshal.SizeOf(state);

            IntPtr setData = IntPtr.Zero;

            try
            {
                setData = Marshal.AllocHGlobal(size);
                Marshal.StructureToPtr(state, setData, false);

                var result = WlanSetInterface(
                    clientHandle,
                    interfaceId,
                    WLAN_INTF_OPCODE.wlan_intf_opcode_radio_state,
                    (uint)size,
                    setData,
                    IntPtr.Zero);

                // ERROR_ACCESS_DENIED will be thrown if the caller does not have sufficient permissions.
                // By default, only a user who is logged on as a member of the Administrators group or
                // the Network Configuration Operators group can set the operation mode of the interface.
                // ERROR_GEN_FAILURE will be thrown if the OpCode is not supported by the driver or NIC.
                return(CheckResult(nameof(WlanSetInterface), result, false));
            }
            finally
            {
                Marshal.FreeHGlobal(setData);
            }
        }