Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

586 lines
21 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "ncnetcon.h"
  4. #include "ncperms.h"
  5. #include "ncui.h"
  6. #include "lanui.h"
  7. #include "lanhelp.h"
  8. #include "eapolui.h"
  9. #include "wzcpage.h"
  10. #include "wzcui.h"
  11. #define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
  12. ////////////////////////////////////////////////////////////////////////
  13. // CWZCConfigPage related stuff
  14. //
  15. // g_wszHiddWebK is a string of 26 bullets (0x25cf - the hidden password char) and a NULL
  16. WCHAR g_wszHiddWepK[] = {0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf,
  17. 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x25cf, 0x0000};
  18. //+---------------------------------------------------------------------------
  19. // automatically enable/disable state for all the WepK related controls
  20. DWORD
  21. CWZCConfigPage::EnableWepKControls()
  22. {
  23. BOOL bEnable;
  24. // allow changing the Wep Key settings only if they are needed (i.e. privacy and/or shared auth)
  25. // It is so for several reasons:
  26. // - we allow all the params to change, but the SSID & the infra mode (these are
  27. // the key info for a configuration and determines the position of the configuration
  28. // in the preferred list - messing with these involves a whole work to readjust
  29. // the position of the configuration)
  30. // - for the long term future we could allow any params of a configuration to change
  31. // including the key info. This will involve changing the position of this configuration
  32. // in the preferred list, but we should do it some time.
  33. bEnable = (m_dwFlags & WZCDLG_PROPS_RWWEP);
  34. bEnable = bEnable && ((BST_CHECKED == ::SendMessage(m_hwndUsePW, BM_GETCHECK, 0, 0)) ||
  35. (BST_CHECKED == ::SendMessage(m_hwndChkShared, BM_GETCHECK, 0, 0)));
  36. ::EnableWindow(m_hwndUseHardwarePW, bEnable);
  37. bEnable = bEnable && (BST_UNCHECKED == IsDlgButtonChecked(IDC_USEHARDWAREPW));
  38. ::EnableWindow(m_hwndLblKMat, bEnable);
  39. ::EnableWindow(m_hwndEdKMat, bEnable);
  40. ::EnableWindow(m_hwndLblKMat2, bEnable && m_bKMatTouched);
  41. ::EnableWindow(m_hwndEdKMat2, bEnable && m_bKMatTouched);
  42. ::EnableWindow(m_hwndLblKIdx, bEnable);
  43. ::EnableWindow(m_hwndEdKIdx, bEnable);
  44. return ERROR_SUCCESS;
  45. }
  46. //+---------------------------------------------------------------------------
  47. // initializes WEP controls
  48. DWORD
  49. CWZCConfigPage::InitWepKControls()
  50. {
  51. UINT nWepKLen = 0;
  52. // check whether the key is provided automatically or not
  53. CheckDlgButton(IDC_USEHARDWAREPW,
  54. (m_wzcConfig.dwCtlFlags & WZCCTL_WEPK_PRESENT) ? BST_UNCHECKED : BST_CHECKED);
  55. if (m_wzcConfig.KeyLength == 0)
  56. {
  57. nWepKLen = 0;
  58. m_bKMatTouched = TRUE;
  59. }
  60. //--- when a password is to be displayed as hidden chars, don't put in
  61. //--- its actual length, but just 8 bulled chars.
  62. else
  63. {
  64. nWepKLen = 8;
  65. }
  66. g_wszHiddWepK[nWepKLen] = L'\0';
  67. ::SetWindowText(m_hwndEdKMat, g_wszHiddWepK);
  68. ::SetWindowText(m_hwndEdKMat2, g_wszHiddWepK);
  69. g_wszHiddWepK[nWepKLen] = 0x25cf; // Hidden password char (bullet)
  70. // the index edit control shouldn't accept more than exactly one char
  71. ::SendMessage(m_hwndEdKIdx, EM_LIMITTEXT, 1, 0);
  72. // show the current key index, if valid. Otherwise, default to the min valid value.
  73. if (m_wzcConfig.KeyIndex + 1 >= WZC_WEPKIDX_MIN &&
  74. m_wzcConfig.KeyIndex + 1 <= WZC_WEPKIDX_MAX)
  75. {
  76. CHAR szIdx[WZC_WEPKIDX_NDIGITS];
  77. ::SetWindowTextA(m_hwndEdKIdx, _itoa(m_wzcConfig.KeyIndex + 1, szIdx, 10));
  78. }
  79. else
  80. m_wzcConfig.KeyIndex = 0;
  81. return ERROR_SUCCESS;
  82. }
  83. //+---------------------------------------------------------------------------
  84. // checks the validity of the WEP Key material and selects the
  85. // material from the first invalid char (non hexa in hexa format or longer
  86. // than the specified length
  87. DWORD
  88. CWZCConfigPage::CheckWepKMaterial(LPSTR *ppszKMat, DWORD *pdwKeyFlags)
  89. {
  90. DWORD dwErr = ERROR_SUCCESS;
  91. DWORD dwKeyFlags = 0;
  92. UINT nMatLen = ::GetWindowTextLength(m_hwndEdKMat);
  93. LPSTR pszCrtMat = NULL;
  94. UINT nSelIdx = 0;
  95. switch(nMatLen)
  96. {
  97. case WZC_WEPKMAT_40_ASC: // 5 chars
  98. case WZC_WEPKMAT_104_ASC: // 13 chars
  99. case WZC_WEPKMAT_128_ASC: // 16 chars
  100. break;
  101. case WZC_WEPKMAT_40_HEX: // 10 hexadecimal digits
  102. case WZC_WEPKMAT_104_HEX: // 26 hexadecimal digits
  103. case WZC_WEPKMAT_128_HEX: // 32 hexadecimal digits
  104. dwKeyFlags |= WZCCTL_WEPK_XFORMAT;
  105. break;
  106. default:
  107. dwErr = ERROR_BAD_FORMAT;
  108. }
  109. // allocate space for the current key material
  110. if (dwErr == ERROR_SUCCESS)
  111. {
  112. pszCrtMat = new CHAR[nMatLen + 1];
  113. if (pszCrtMat == NULL)
  114. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  115. }
  116. // get the current key material from the edit control
  117. if (dwErr == ERROR_SUCCESS)
  118. {
  119. if (nMatLen != ::GetWindowTextA(m_hwndEdKMat, pszCrtMat, nMatLen+1))
  120. dwErr = GetLastError();
  121. }
  122. // we have now all the data. We should select the text in the Key material
  123. // edit control from the first one of the two:
  124. // - the nNewLen to the end (if the current content exceeds the specified length)
  125. // - the first non hexa digit to the end (if current format is hexa)
  126. if (dwErr == ERROR_SUCCESS && (dwKeyFlags & WZCCTL_WEPK_XFORMAT))
  127. {
  128. UINT nNonXIdx;
  129. for (nNonXIdx = 0; nNonXIdx < nMatLen; nNonXIdx++)
  130. {
  131. if (!isxdigit(pszCrtMat[nNonXIdx]))
  132. {
  133. dwErr = ERROR_BAD_FORMAT;
  134. break;
  135. }
  136. }
  137. }
  138. if (dwErr != ERROR_SUCCESS)
  139. {
  140. ::SetWindowText(m_hwndEdKMat2, L"");
  141. ::SendMessage(m_hwndEdKMat, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  142. // and set the focus on the key material edit control
  143. ::SetFocus(m_hwndEdKMat);
  144. // clean up whatever memory we allocated since we're not passing it up
  145. if (pszCrtMat != NULL)
  146. delete pszCrtMat;
  147. }
  148. else
  149. {
  150. *ppszKMat = pszCrtMat;
  151. *pdwKeyFlags = dwKeyFlags;
  152. }
  153. return dwErr;
  154. }
  155. //+---------------------------------------------------------------------------
  156. // parses & copies the WEP Key material from the parameter into the m_wzcConfig object
  157. // The length should be already the good one, the format is given by m_wzcConfig.dwCtlFlags
  158. // Since we assume a valid key material it means its length is non-zero and it is fitting in
  159. // the configurations key material buffer, and if the formatting is hexadecimal, it
  160. // contains an even number of hexa digits.
  161. DWORD
  162. CWZCConfigPage::CopyWepKMaterial(LPSTR szKMat)
  163. {
  164. BYTE chFakeKeyMaterial[] = {0x56, 0x09, 0x08, 0x98, 0x4D, 0x08, 0x11, 0x66, 0x42, 0x03, 0x01, 0x67, 0x66};
  165. if (m_wzcConfig.dwCtlFlags & WZCCTL_WEPK_XFORMAT)
  166. {
  167. UINT nKMatIdx = 0;
  168. // we know here we have a valid hexadecimal formatting
  169. // this implies the string has an even number of digits
  170. while(*szKMat != '\0')
  171. {
  172. m_wzcConfig.KeyMaterial[nKMatIdx] = HEX(*szKMat) << 4;
  173. szKMat++;
  174. m_wzcConfig.KeyMaterial[nKMatIdx] |= HEX(*szKMat);
  175. szKMat++;
  176. nKMatIdx++;
  177. }
  178. m_wzcConfig.KeyLength = nKMatIdx;
  179. }
  180. else
  181. {
  182. // the key is not in Hex format, so just copy over the bytes
  183. // we know the length is good so no worries about overwritting the buffer
  184. m_wzcConfig.KeyLength = strlen(szKMat);
  185. memcpy(m_wzcConfig.KeyMaterial, szKMat, m_wzcConfig.KeyLength);
  186. }
  187. return ERROR_SUCCESS;
  188. }
  189. //+---------------------------------------------------------------------------
  190. // sets the EAPOL Locked bit
  191. DWORD
  192. CWZCConfigPage::SetEapolAllowedState()
  193. {
  194. if (m_pEapolConfig != NULL)
  195. {
  196. // EAPOL shouldn't be even allowed on networks not requesting privacy or on
  197. // ad hoc networks.
  198. if (BST_UNCHECKED == ::SendMessage(m_hwndUsePW, BM_GETCHECK, 0, 0) ||
  199. BST_CHECKED == ::SendMessage(m_hwndChkAdhoc, BM_GETCHECK, 0, 0))
  200. {
  201. // lock the Eapol configuration page
  202. m_pEapolConfig->m_dwCtlFlags |= EAPOL_CTL_LOCKED;
  203. }
  204. else // for Infrastructure networks requiring privacy..
  205. {
  206. // unlock the Eapol configuration page (users are allowed to enable / disable 802.1X)
  207. m_pEapolConfig->m_dwCtlFlags &= ~EAPOL_CTL_LOCKED;
  208. // if asked to correlate onex state with the presence of an explicit key, fix this here
  209. if (m_dwFlags & WZCDLG_PROPS_ONEX_CHECK)
  210. {
  211. if (BST_CHECKED == ::SendMessage(m_hwndUseHardwarePW, BM_GETCHECK, 0, 0))
  212. m_pEapolConfig->m_EapolIntfParams.dwEapFlags |= EAPOL_ENABLED;
  213. else
  214. m_pEapolConfig->m_EapolIntfParams.dwEapFlags &= ~EAPOL_ENABLED;
  215. }
  216. }
  217. }
  218. return ERROR_SUCCESS;
  219. }
  220. //+---------------------------------------------------------------------------
  221. // class constructor
  222. CWZCConfigPage::CWZCConfigPage(DWORD dwFlags)
  223. {
  224. m_dwFlags = dwFlags;
  225. m_bKMatTouched = FALSE;
  226. m_pEapolConfig = NULL;
  227. ZeroMemory(&m_wzcConfig, sizeof(WZC_WLAN_CONFIG));
  228. m_wzcConfig.Length = sizeof(WZC_WLAN_CONFIG);
  229. m_wzcConfig.InfrastructureMode = Ndis802_11Infrastructure;
  230. m_wzcConfig.Privacy = 1;
  231. }
  232. //+---------------------------------------------------------------------------
  233. // Uploads the configuration into the dialog's internal data
  234. DWORD
  235. CWZCConfigPage::UploadWzcConfig(CWZCConfig *pwzcConfig)
  236. {
  237. // if the configuration being uploaded is already a preferred one, reset the
  238. // ONEX check flag (don't control the ONEX setting since it has already been
  239. // chosen by the user at the moment the configuration was first created)
  240. if (pwzcConfig->m_dwFlags & WZC_DESCR_PREFRD)
  241. m_dwFlags &= ~WZCDLG_PROPS_ONEX_CHECK;
  242. CopyMemory(&m_wzcConfig, &(pwzcConfig->m_wzcConfig), sizeof(WZC_WLAN_CONFIG));
  243. return ERROR_SUCCESS;
  244. }
  245. //+---------------------------------------------------------------------------
  246. // copy a reference to the EAPOL configuration object
  247. DWORD
  248. CWZCConfigPage::UploadEapolConfig(CEapolConfig *pEapolConfig)
  249. {
  250. // this member is never to be freed in this class
  251. m_pEapolConfig = pEapolConfig;
  252. return ERROR_SUCCESS;
  253. }
  254. //+---------------------------------------------------------------------------
  255. // Sets the dialog flags. Returns the entire current set of flags
  256. DWORD
  257. CWZCConfigPage::SetFlags(DWORD dwMask, DWORD dwNewFlags)
  258. {
  259. m_dwFlags &= ~dwMask;
  260. m_dwFlags |= (dwNewFlags & dwMask);
  261. return m_dwFlags;
  262. }
  263. //+---------------------------------------------------------------------------
  264. // INIT_DIALOG handler
  265. LRESULT
  266. CWZCConfigPage::OnInitDialog (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  267. {
  268. DWORD dwStyle;
  269. HRESULT hr = S_OK;
  270. // get all the controls handles
  271. m_hwndEdSSID = GetDlgItem(IDC_WZC_EDIT_SSID);
  272. m_hwndChkAdhoc = GetDlgItem(IDC_ADHOC);
  273. m_hwndChkShared = GetDlgItem(IDC_SHAREDMODE);
  274. m_hwndUsePW = GetDlgItem(IDC_USEPW);
  275. // wep key related controls
  276. m_hwndUseHardwarePW = GetDlgItem(IDC_USEHARDWAREPW);
  277. m_hwndLblKMat = GetDlgItem(IDC_WZC_LBL_KMat);
  278. m_hwndEdKMat = GetDlgItem(IDC_WZC_EDIT_KMat);
  279. m_hwndLblKMat2 = GetDlgItem(IDC_WZC_LBL_KMat2);
  280. m_hwndEdKMat2 = GetDlgItem(IDC_WZC_EDIT_KMat2);
  281. m_hwndLblKIdx = GetDlgItem(IDC_WZC_LBL_KIdx);
  282. m_hwndEdKIdx = GetDlgItem(IDC_WZC_EDIT_KIdx);
  283. // initialize the SSID field with the SSID, if one is given
  284. if (m_wzcConfig.Ssid.SsidLength != 0)
  285. {
  286. // ugly but this is life. In order to convert the SSID to LPWSTR we need a buffer.
  287. // We know an SSID can't exceed 32 chars (see NDIS_802_11_SSID from ntddndis.h) so
  288. // make room for the null terminator and that's it. We could do mem alloc but I'm
  289. // not sure it worth the effort (at runtime).
  290. WCHAR wszSSID[33];
  291. UINT nLenSSID = 0;
  292. // convert the LPSTR (original SSID format) to LPWSTR (needed in List Ctrl)
  293. nLenSSID = MultiByteToWideChar(
  294. CP_ACP,
  295. 0,
  296. (LPCSTR)m_wzcConfig.Ssid.Ssid,
  297. m_wzcConfig.Ssid.SsidLength,
  298. wszSSID,
  299. celems(wszSSID));
  300. if (nLenSSID != 0)
  301. {
  302. wszSSID[nLenSSID] = L'\0';
  303. ::SetWindowText(m_hwndEdSSID, wszSSID);
  304. }
  305. }
  306. // Check the "this network is adhoc" box if neccessary.
  307. ::SendMessage(m_hwndChkAdhoc, BM_SETCHECK, (m_wzcConfig.InfrastructureMode == Ndis802_11IBSS) ? BST_CHECKED : BST_UNCHECKED, 0);
  308. // Check the "Use the network key to access this network" checkbox if necessary
  309. // Checking this corresponds to "Shared" auth mode. Unchecked corresponds to "Open" (dsheldon)
  310. ::SendMessage(m_hwndChkShared, BM_SETCHECK, m_wzcConfig.AuthenticationMode ? BST_CHECKED : BST_UNCHECKED, 0);
  311. // the SSID can't be under any circumstances larger than 32 chars
  312. ::SendMessage(m_hwndEdSSID, EM_LIMITTEXT, 32, 0);
  313. // create the spin control
  314. CreateUpDownControl(
  315. WS_CHILD|WS_VISIBLE|WS_BORDER|UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
  316. 0, 0, 0, 0,
  317. m_hWnd,
  318. -1,
  319. _Module.GetResourceInstance(),
  320. m_hwndEdKIdx,
  321. WZC_WEPKIDX_MAX,
  322. WZC_WEPKIDX_MIN,
  323. WZC_WEPKIDX_MIN);
  324. ::SendMessage(m_hwndUsePW, BM_SETCHECK, (m_wzcConfig.Privacy == 1) ? BST_CHECKED : BST_UNCHECKED, 0);
  325. // at this point we can say the WEP key is untouched
  326. m_bKMatTouched = FALSE;
  327. // fill in the WepK controls
  328. InitWepKControls();
  329. // enable or disable the controls based on how the dialog is called
  330. ::EnableWindow(m_hwndEdSSID, m_dwFlags & WZCDLG_PROPS_RWSSID);
  331. ::EnableWindow(m_hwndChkAdhoc, m_dwFlags & WZCDLG_PROPS_RWINFR);
  332. ::EnableWindow(m_hwndChkShared, m_dwFlags & WZCDLG_PROPS_RWAUTH);
  333. ::EnableWindow(m_hwndUsePW, m_dwFlags & WZCDLG_PROPS_RWWEP);
  334. // enable or disable all the wep key related controls
  335. EnableWepKControls();
  336. SetEapolAllowedState();
  337. return LresFromHr(hr);
  338. }
  339. //+---------------------------------------------------------------------------
  340. // OK button handler
  341. LRESULT
  342. CWZCConfigPage::OnOK(UINT idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  343. {
  344. UINT nSSIDLen;
  345. CHAR szSSID[33];
  346. DWORD dwKeyFlags = 0;
  347. UINT nKeyIdx;
  348. LPSTR szWepKMat = NULL;
  349. // variables used for prompting the user with warning/error messages
  350. UINT nWarnStringID = 0;
  351. WCHAR wszBuff[48];
  352. m_wzcConfig.Length = sizeof(WZC_WLAN_CONFIG);
  353. // get the basic 802.11 parameters
  354. m_wzcConfig.InfrastructureMode = (BST_CHECKED == ::SendMessage(m_hwndChkAdhoc, BM_GETCHECK, 0, 0)) ? Ndis802_11IBSS : Ndis802_11Infrastructure;
  355. m_wzcConfig.AuthenticationMode = (BST_CHECKED == ::SendMessage(m_hwndChkShared, BM_GETCHECK, 0, 0)) ? Ndis802_11AuthModeShared : Ndis802_11AuthModeOpen;
  356. m_wzcConfig.Privacy = (BYTE) (BST_CHECKED == ::SendMessage(m_hwndUsePW, BM_GETCHECK, 0, 0)) ? 1 : 0;
  357. // get the SSID (max 32 chars)
  358. nSSIDLen = ::GetWindowTextA(
  359. m_hwndEdSSID,
  360. szSSID,
  361. sizeof(szSSID));
  362. m_wzcConfig.Ssid.SsidLength = nSSIDLen;
  363. if (nSSIDLen > 0)
  364. CopyMemory(m_wzcConfig.Ssid.Ssid, szSSID, nSSIDLen);
  365. // mark whether a WEP key is provided (not defaulted) or not (defaulted to whatever the hdw might have)
  366. if (IsDlgButtonChecked(IDC_USEHARDWAREPW))
  367. m_wzcConfig.dwCtlFlags &= ~WZCCTL_WEPK_PRESENT;
  368. else
  369. m_wzcConfig.dwCtlFlags |= WZCCTL_WEPK_PRESENT;
  370. // get the key index in a local variable
  371. wszBuff[0] = L'\0';
  372. ::GetWindowText(m_hwndEdKIdx, wszBuff, sizeof(wszBuff)/sizeof(WCHAR));
  373. nKeyIdx = _wtoi(wszBuff) - 1;
  374. if (nKeyIdx + 1 < WZC_WEPKIDX_MIN || nKeyIdx + 1 > WZC_WEPKIDX_MAX)
  375. {
  376. nWarnStringID = IDS_WZC_KERR_IDX;
  377. nKeyIdx = m_wzcConfig.KeyIndex;
  378. ::SendMessage(m_hwndEdKIdx, EM_SETSEL, 0, -1);
  379. ::SetFocus(m_hwndEdKIdx);
  380. }
  381. // get the key material in a local variable.
  382. // If the key is incorrect, the local storage is not changed.
  383. if (m_bKMatTouched)
  384. {
  385. if (CheckWepKMaterial(&szWepKMat, &dwKeyFlags) != ERROR_SUCCESS)
  386. {
  387. nWarnStringID = IDS_WZC_KERR_MAT;
  388. }
  389. else
  390. {
  391. CHAR szBuff[WZC_WEPKMAT_128_HEX + 1]; // maximum key length
  392. // verify whether the key is confirmed correctly. We do this only if nWarnString is
  393. // 0, which means the key is formatted correctly, hence less than 32 chars.
  394. szBuff[0] = '\0';
  395. ::GetWindowTextA( m_hwndEdKMat2, szBuff, sizeof(szBuff));
  396. if (strcmp(szBuff, szWepKMat) != 0)
  397. {
  398. nWarnStringID = IDS_WZC_KERR_MAT2;
  399. // no wep key to be saved, hence delete whatever was read so far
  400. delete szWepKMat;
  401. szWepKMat = NULL;
  402. ::SetWindowText(m_hwndEdKMat2, L"");
  403. ::SetFocus(m_hwndEdKMat2);
  404. }
  405. }
  406. }
  407. // check whether we actually need the wep key settings entered by the user
  408. if ((m_wzcConfig.AuthenticationMode == Ndis802_11AuthModeOpen && !m_wzcConfig.Privacy) ||
  409. !(m_wzcConfig.dwCtlFlags & WZCCTL_WEPK_PRESENT))
  410. {
  411. // no, we don't actually need the key, so we won't prompt the user if he entered an incorrect
  412. // key material or index. In this case whatever the user entered is simply ignored.
  413. // However, if the user entered a correct index / material, they will be saved.
  414. nWarnStringID = 0;
  415. }
  416. // if there is no error to be prompted, just copy over the key settings (regardless they are needed
  417. // or not).
  418. if (nWarnStringID == 0)
  419. {
  420. m_wzcConfig.KeyIndex = nKeyIdx;
  421. if (szWepKMat != NULL)
  422. {
  423. m_wzcConfig.dwCtlFlags &= ~(WZCCTL_WEPK_XFORMAT);
  424. m_wzcConfig.dwCtlFlags |= dwKeyFlags;
  425. CopyWepKMaterial(szWepKMat);
  426. }
  427. }
  428. else
  429. {
  430. NcMsgBox(
  431. _Module.GetResourceInstance(),
  432. m_hWnd,
  433. IDS_LANUI_ERROR_CAPTION,
  434. nWarnStringID,
  435. MB_ICONSTOP|MB_OK);
  436. }
  437. if (szWepKMat != NULL)
  438. delete szWepKMat;
  439. bHandled = TRUE;
  440. if (nWarnStringID == 0)
  441. {
  442. return PSNRET_NOERROR;
  443. }
  444. else
  445. {
  446. return PSNRET_INVALID_NOCHANGEPAGE;
  447. }
  448. }
  449. //+---------------------------------------------------------------------------
  450. // Context sensitive help handler
  451. extern const WCHAR c_szNetCfgHelpFile[];
  452. LRESULT
  453. CWZCConfigPage::OnContextMenu(
  454. UINT uMsg,
  455. WPARAM wParam,
  456. LPARAM lParam,
  457. BOOL& fHandled)
  458. {
  459. ::WinHelp(m_hWnd,
  460. c_szNetCfgHelpFile,
  461. HELP_CONTEXTMENU,
  462. (ULONG_PTR)g_aHelpIDs_IDC_WZC_DLG_PROPS);
  463. return 0;
  464. }
  465. LRESULT
  466. CWZCConfigPage::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  467. {
  468. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  469. if (HELPINFO_WINDOW == lphi->iContextType)
  470. {
  471. ::WinHelp(static_cast<HWND>(lphi->hItemHandle),
  472. c_szNetCfgHelpFile,
  473. HELP_WM_HELP,
  474. (ULONG_PTR)g_aHelpIDs_IDC_WZC_DLG_PROPS);
  475. }
  476. return 0;
  477. }
  478. //+---------------------------------------------------------------------------
  479. // Handler for enabling/disabling WEP
  480. LRESULT
  481. CWZCConfigPage::OnUsePW(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  482. {
  483. EnableWepKControls();
  484. SetEapolAllowedState();
  485. return 0;
  486. }
  487. //+---------------------------------------------------------------------------
  488. // Handler for enabling controls if the user wants to specify key material (password) explicitly
  489. LRESULT
  490. CWZCConfigPage::OnUseHWPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  491. {
  492. EnableWepKControls();
  493. SetEapolAllowedState();
  494. return 0;
  495. }
  496. //+---------------------------------------------------------------------------
  497. // Handler for detecting changes in the key material
  498. LRESULT
  499. CWZCConfigPage::OnWepKMatCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  500. {
  501. if (wNotifyCode == EN_SETFOCUS)
  502. {
  503. if (!m_bKMatTouched)
  504. {
  505. ::SetWindowText(m_hwndEdKMat, L"");
  506. ::SetWindowText(m_hwndEdKMat2, L"");
  507. ::EnableWindow(m_hwndLblKMat2, TRUE);
  508. ::EnableWindow(m_hwndEdKMat2, TRUE);
  509. m_bKMatTouched = TRUE;
  510. }
  511. }
  512. return 0;
  513. }
  514. //+---------------------------------------------------------------------------
  515. LRESULT
  516. CWZCConfigPage::OnCheckEapolAllowed(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  517. {
  518. return SetEapolAllowedState();
  519. }