Skip to content

Commit

Permalink
[WLANWIZ] Show either a network without stored profile or with one
Browse files Browse the repository at this point in the history
No more duplicates. Unless you have multiple profiles for this particular network.
  • Loading branch information
SigmaTel71 committed Sep 30, 2024
1 parent a2eb980 commit 8d47103
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions dll/shellext/wlanwiz/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ LRESULT CWlanWizard::OnScanNetworks(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO

for (;
this->lstWlanNetworks->dwIndex <= this->lstWlanNetworks->dwNumberOfItems - 1;
this->lstWlanNetworks->dwIndex++)
++this->lstWlanNetworks->dwIndex)
{
ATL::CSimpleArray<UINT> csaIndexAndQuality;
WLAN_AVAILABLE_NETWORK wlanNetwork = this->lstWlanNetworks->Network[this->lstWlanNetworks->dwIndex];

csaIndexAndQuality.Add(wlanNetwork.wlanSignalQuality);
csaIndexAndQuality.Add(this->lstWlanNetworks->dwIndex);

Expand All @@ -106,7 +107,22 @@ LRESULT CWlanWizard::OnScanNetworks(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
while (posIAQ != NULL)
{
auto csaIAQ = calIndexToSignalQuality.GetNext(posIAQ);
DOT11_SSID ssid = this->lstWlanNetworks->Network[csaIAQ[1]].dot11Ssid;
WLAN_AVAILABLE_NETWORK wlanNetwork = this->lstWlanNetworks->Network[csaIAQ[1]];

/* Omit duplicates by keeping networks that have profile if there is the same entry without one */
if (posIAQ > 0)
{
auto csaIAQPrev = calIndexToSignalQuality.GetPrev(posIAQ);
calIndexToSignalQuality.GetNext(posIAQ);

WLAN_AVAILABLE_NETWORK wlanPrevNetwork = this->lstWlanNetworks->Network[csaIAQPrev[1]];
if ( (wlanPrevNetwork.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE) != 0
&& (wlanNetwork.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE) == 0
&& memcmp(wlanNetwork.dot11Ssid.ucSSID, wlanPrevNetwork.dot11Ssid.ucSSID, wlanPrevNetwork.dot11Ssid.uSSIDLength) == 0)
continue;
}

DOT11_SSID ssid = wlanNetwork.dot11Ssid;

int iSSIDLengthWide = MultiByteToWideChar(CP_UTF8, 0, reinterpret_cast<LPCSTR>(ssid.ucSSID), ssid.uSSIDLength, NULL, 0);
ATL::CStringW cswWlanNetworkName = ATL::CStringW(L"", iSSIDLengthWide);
Expand Down

0 comments on commit 8d47103

Please sign in to comment.