0

For a couple of days, I have puzzled about how to do this in the best way possible. I created a form application like so:

enter image description here

I gave the name "WiFi Hacker" for giggles. But my question is, why does Visual Studio give me this error after a couple minutes using the program?

    Additional information: Type 'NativeWifi.Wlan+WlanReasonCode' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.

I am using NativeWifi for my program, and the code for logging networks is as follows:

    WlanClient client = new WlanClient();
    private void wifilister()
    {
        foreach (WlanClient.WlanInterface wI in client.Interfaces)
        {
            foreach (Wlan.WlanAvailableNetwork network in wI.GetAvailableNetworkList(0))
            {
                Wlan.Dot11Ssid ssid = network.dot11Ssid;
                string networkName = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);
                if (wifis.Contains(networkName) == false)
                {
                    //Name
                    ListViewItem item = new ListViewItem(networkName);
                    wifis.Add(networkName);
                    listBox1.Items.Add(networkName);
                    //Encryption Type
                    item.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString());
                    wifis.Add(network.dot11DefaultCipherAlgorithm.ToString());
                    //Signal
                    item.SubItems.Add(network.wlanSignalQuality + "%");
                    wifis.Add(network.wlanSignalQuality + "%");
                    //Logged Time
                    item.SubItems.Add(DateTime.Now.ToString("T"));
                    wifis.Add(DateTime.Now.ToString("T"));
                    listView1.Items.Add(item);
                    label2.Text = "Networks: " + (wifis.Count / 4).ToString();
                }
                if (checkBox2.Checked)
                {
                    label1.Text = track;
                    if (Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength) == track)
                    {
                        label1.Text += " " + network.wlanSignalQuality + "%";
                    }
                }
            }
        }

I got most of this off a tutorial from YouTube, but after it logs more than about 40 different networks in the List, it seems to give that weird error about

'NativeWifi.Wlan+WlanReasonCode'.

This annoyed me, is there a way around it?

mason
  • 31,774
  • 10
  • 77
  • 121
Alex
  • 35
  • 5
  • Wifi Hacker is the name of a computer on one of the networks. So the application has to try each of the 40 networks and ping Wifi Hacker on each network. So if the app is waiting 5 seconds for the ping response then you are wait 200 seconds before the program does not find Wifi Hacker. The program is probably waiting only 3 seconds for each ping response which is 40 x 3 = 120 seconds. – jdweng May 23 '18 at 00:38
  • Possible duplicate of [Issues with using Managed WiFi (NativeWiFi API)](https://stackoverflow.com/questions/42371871/issues-with-using-managed-wifi-nativewifi-api) – Bagus Tesa May 23 '18 at 01:24
  • The Program's name is Wifi Hacker, but I don't understand how that "pings Wifi Hacker on each network?" I have a timer set for 1 second to run the "wifilister()" void, and maybe it is doing it too fast? Let me know if this seems to be a possible issue, or how I can fix this. I do not know a lot about the NativeWifi module. – Alex May 23 '18 at 01:56
  • So far, it seems to do everything it can to crash on me. This is what I did, I know it sounds stupid. I had my program close every 10 seconds, and re-open to find new networks. However, it continues to crash after finding several networks again? How can this be! Is there some kind of background pinging going on that needs to be stopped/restarted? – Alex May 23 '18 at 15:59

0 Answers0