Skip to content

Commit c2de789

Browse files
committed
[WLANWIZ] Filter scan results
Eliminate all entries that have profile name different from SSID or not have profile at all in case there is an entry that fully matches SSID w/ profile name.
1 parent 9c51f93 commit c2de789

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

dll/shellext/wlanwiz/scan.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,17 @@ LRESULT CWlanWizard::OnScanNetworks(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
164164
/* Remove networks that do not have profile name exactly matching SSID */
165165
for (const auto& dwKnownAPIdx : setAPsWithProfiles)
166166
{
167-
WLAN_AVAILABLE_NETWORK wlanNetWithProfile = this->lstWlanNetworks->Network[dwKnownAPIdx];
167+
PWLAN_AVAILABLE_NETWORK wlanNetWithProfile = &this->lstWlanNetworks->Network[dwKnownAPIdx];
168168

169169
vecIndexesBySignalQuality.erase(std::remove_if(vecIndexesBySignalQuality.begin(), vecIndexesBySignalQuality.end(), [&](const DWORD& dwAP)
170170
{
171-
bool bSameNetwork = dwKnownAPIdx == dwAP;
172-
bool bProfileNameIsSSID = std::wstring_view(wlanNetWithProfile.strProfileName) == std::wstring_view(APNameToUnicode(&this->lstWlanNetworks->Network[dwAP].dot11Ssid));
171+
if (dwKnownAPIdx == dwAP)
172+
return false;
173173

174-
return !bSameNetwork && !bProfileNameIsSSID;
174+
bool bProfileNameIsSSID = std::wstring_view(wlanNetWithProfile->strProfileName) == std::wstring_view(APNameToUnicode(&this->lstWlanNetworks->Network[dwAP].dot11Ssid));
175+
bool bHasProfile = (this->lstWlanNetworks->Network[dwAP].dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE) != 0;
176+
177+
return bProfileNameIsSSID && !bHasProfile;
175178
}), vecIndexesBySignalQuality.end());
176179
}
177180

@@ -193,11 +196,12 @@ LRESULT CWlanWizard::OnScanNetworks(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
193196
if (dwConnectedTo != MAXDWORD)
194197
{
195198
auto connectedIdx = std::find(vecIndexesBySignalQuality.begin(), vecIndexesBySignalQuality.end(), dwConnectedTo) - vecIndexesBySignalQuality.begin();
196-
auto middle = connectedIdx + 1 <= vecIndexesBySignalQuality.size()
197-
? vecIndexesBySignalQuality.begin() + connectedIdx + 1
198-
: vecIndexesBySignalQuality.end();
199199

200-
std::rotate(vecIndexesBySignalQuality.begin() + connectedIdx, middle, vecIndexesBySignalQuality.end());
200+
if (connectedIdx > 0)
201+
{
202+
auto iter = vecIndexesBySignalQuality.begin();
203+
std::rotate(iter, iter + connectedIdx, iter + connectedIdx + 1);
204+
}
201205
}
202206

203207
for (const auto& dwNetwork : vecIndexesBySignalQuality)

0 commit comments

Comments
 (0)