You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the wlanapi.h method WlanGetAvailableNetworkList, i receive a WLAN_AVAILABLE_NETWORK_LIST with dwNumberOfItems > 1 (around 8), but when i try to access the availableNetworksList.Network[1] i get a Range error ("only valid value is 0: 1").
Steps to reproduce
import package:win32/win32.dart
call WlanOpenHandle to get the clientHandle
call WlanEnumInterfaces to get the guid of the network interface
call WlanGetAvailableNetworkList, get the WLAN_AVAILABLE_NETWORK_LIST struct, check the dwNumberOfItems and then iterate on the Networks array
Expected behavior
I can use a normal for-i loop until dwNumberOfItems - 1 and receive different WLAN_AVAILABLE_NETWORK items.
Environment
Windows 11, Dell computer
The text was updated successfully, but these errors were encountered:
The reason you're getting a RangeError when accessing elements of the Network array in the WLAN_AVAILABLE_NETWORK_LIST is because the array is annotated with @Array(1):
This annotation tells the compiler that the array contains only a single element, which leads to an out-of-bounds error when trying to access subsequent elements.
This array is actually defined as a variable-length array in C, but Dart doesn't support variable-sized arrays yet. As a result, it's projected as a single-element array. This causes bounds-checking issues when you try to access any element beyond the first.
To access the full list of networks, you can get a pointer to the beginning of the array by calculating the memory address of the array and then iterating over it:
extensiononPointer<WLAN_AVAILABLE_NETWORK_LIST> {
List<WLAN_AVAILABLE_NETWORK> get network {
final networks =<WLAN_AVAILABLE_NETWORK>[];
// Get a pointer to the beginning of the array.final ptr =Pointer<WLAN_AVAILABLE_NETWORK>.fromAddress(
address +sizeOf<Uint32>() +// dwNumberOfItemssizeOf<Uint32>() // dwIndex
);
// Iterate through the networks.for (var i =0; i < ref.dwNumberOfItems; i++) {
final network = (ptr + i).ref;
networks.add(network);
}
return networks;
}
}
You can call this extension method from a pointer to the WLAN_AVAILABLE_NETWORK_LIST struct returned by the WlanGetAvailableNetworkList function. Please let me know if this works.
Description
Using the wlanapi.h method WlanGetAvailableNetworkList, i receive a WLAN_AVAILABLE_NETWORK_LIST with dwNumberOfItems > 1 (around 8), but when i try to access the availableNetworksList.Network[1] i get a Range error ("only valid value is 0: 1").
Steps to reproduce
Expected behavior
I can use a normal for-i loop until dwNumberOfItems - 1 and receive different WLAN_AVAILABLE_NETWORK items.
Environment
Windows 11, Dell computer
The text was updated successfully, but these errors were encountered: