Skip to content

Commit 8a21141

Browse files
committed
[WLANWIZ] Abort scanning if the adapter was disabled
1 parent 33207ed commit 8a21141

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

dll/shellext/wlanwiz/scan.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,49 @@
1212
LRESULT CWlanWizard::OnScanNetworks(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
1313
{
1414
MSG msg;
15+
GUID gCurAdapter;
16+
PWLAN_RADIO_STATE pWRSCurAdapter = NULL;
17+
WLAN_OPCODE_VALUE_TYPE wovtCurrAdapter = wlan_opcode_value_type_invalid;
18+
DWORD dwWRSsize = sizeof(WLAN_RADIO_STATE);
1519

1620
this->uScanStatus = STATUS_SCANNING;
1721
this->bScanTimeout = FALSE;
1822
this->dwSelectedItemID = -1;
1923

20-
m_SidebarButtonAS.EnableWindow(FALSE);
21-
m_SidebarButtonSN.EnableWindow(FALSE);
2224
m_ConnectButton.EnableWindow(FALSE);
2325
m_ListboxWLAN.EnableWindow(FALSE);
2426

2527
/* Clear listbox from previously discovered networks */
2628
m_ListboxWLAN.SendMessageW(LB_RESETCONTENT, NULL, NULL);
2729
m_ListboxWLAN.Invalidate();
2830

31+
/* Check if the adapter is enabled, both hardware and software */
32+
IIDFromString(this->m_sGUID, &gCurAdapter);
33+
WlanQueryInterface(this->hWlanClient,
34+
&gCurAdapter,
35+
wlan_intf_opcode_radio_state,
36+
NULL,
37+
&dwWRSsize,
38+
reinterpret_cast<PVOID*>(&pWRSCurAdapter),
39+
&wovtCurrAdapter);
40+
41+
if (!( pWRSCurAdapter->PhyRadioState[0].dot11SoftwareRadioState == dot11_radio_state_on
42+
&& pWRSCurAdapter->PhyRadioState[0].dot11HardwareRadioState == dot11_radio_state_on))
43+
{
44+
this->uScanStatus = STATUS_SCAN_COMPLETE;
45+
this->bScanTimeout = TRUE;
46+
47+
if (this->lstWlanNetworks != NULL)
48+
{
49+
WlanFreeMemory(this->lstWlanNetworks);
50+
RtlSecureZeroMemory(&this->lstWlanNetworks, sizeof(this->lstWlanNetworks));
51+
}
52+
return FALSE;
53+
}
54+
55+
m_SidebarButtonAS.EnableWindow(FALSE);
56+
m_SidebarButtonSN.EnableWindow(FALSE);
57+
2958
SetTimer(IDT_SCANNING_NETWORKS, 5000);
3059

3160
HCURSOR hOldCursor = SetCursor(LoadCursorW(NULL, IDC_APPSTARTING));

0 commit comments

Comments
 (0)