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.

1665 lines
60 KiB

  1. #include "precomp.h"
  2. #include "rsopsec.h"
  3. static INT_PTR CALLBACK importSecZonesRSoPProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  4. INT_PTR CALLBACK PrivacyDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  5. INT_PTR CALLBACK SecurityCustomSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  6. INT_PTR CALLBACK SecurityAddSitesIntranetDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  7. INT_PTR CALLBACK SecurityAddSitesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  8. INT_PTR CALLBACK PicsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  9. INT_PTR CALLBACK ApprovedSitesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  10. INT_PTR CALLBACK GeneralDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  11. INT_PTR CALLBACK AdvancedDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  12. #define WIDETEXT(x) L ## x
  13. /////////////////////////////////////////////////////////////////////
  14. void InitSecZonesDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  15. {
  16. __try
  17. {
  18. BOOL bImportZones = FALSE;
  19. BOOL bImportRatings = FALSE;
  20. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  21. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  22. if (SUCCEEDED(hr))
  23. {
  24. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  25. long nPSObjects = pDRD->GetPSObjCount();
  26. BOOL bZonesHandled = FALSE;
  27. BOOL bRatingsHandled = FALSE;
  28. for (long nObj = 0; nObj < nPSObjects; nObj++)
  29. {
  30. // importSecurityZoneSettings field
  31. _variant_t vtValue;
  32. if (!bZonesHandled)
  33. {
  34. hr = paPSObj[nObj]->pObj->Get(L"importSecurityZoneSettings", 0, &vtValue, NULL, NULL);
  35. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  36. {
  37. bImportZones = (bool)vtValue ? TRUE : FALSE;
  38. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES,
  39. (bool)vtValue ? IDC_IMPORTZONES : IDC_NOZONES);
  40. bZonesHandled = TRUE;
  41. DWORD dwCurGPOPrec = GetGPOPrecedence(paPSObj[nObj]->pObj);
  42. pDRD->SetImportedSecZonesPrec(dwCurGPOPrec);
  43. // importedZoneCount field
  44. _variant_t vtValue;
  45. hr = paPSObj[nObj]->pObj->Get(L"importedZoneCount", 0, &vtValue, NULL, NULL);
  46. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  47. {
  48. pDRD->SetImportedSecZoneCount((long)vtValue);
  49. }
  50. if(!pDRD->IsPlanningMode() && IsVariantNull(vtValue))
  51. {
  52. bZonesHandled = FALSE;
  53. }
  54. }
  55. }
  56. // importContentRatingsSettings field
  57. vtValue;
  58. if (!bRatingsHandled)
  59. {
  60. hr = paPSObj[nObj]->pObj->Get(L"importContentRatingsSettings", 0, &vtValue, NULL, NULL);
  61. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  62. {
  63. bImportRatings = (bool)vtValue ? TRUE : FALSE;
  64. CheckRadioButton(hDlg, IDC_NORAT, IDC_IMPORTRAT,
  65. (bool)vtValue ? IDC_IMPORTRAT : IDC_NORAT);
  66. DWORD dwCurGPOPrec = GetGPOPrecedence(paPSObj[nObj]->pObj);
  67. pDRD->SetImportedSecRatingsPrec(dwCurGPOPrec);
  68. bRatingsHandled = TRUE;
  69. }
  70. }
  71. // no need to process other GPOs since enabled properties have been found
  72. if (bZonesHandled && bRatingsHandled)
  73. break;
  74. }
  75. }
  76. EnableDlgItem2(hDlg, IDC_NOZONES, FALSE);
  77. EnableDlgItem2(hDlg, IDC_IMPORTZONES, FALSE);
  78. EnableDlgItem2(hDlg, IDC_MODIFYZONES, bImportZones);
  79. EnableDlgItem2(hDlg, IDC_NORAT, FALSE);
  80. EnableDlgItem2(hDlg, IDC_IMPORTRAT, FALSE);
  81. EnableDlgItem2(hDlg, IDC_MODIFYRAT, bImportRatings);
  82. }
  83. __except(TRUE)
  84. {
  85. }
  86. }
  87. /////////////////////////////////////////////////////////////////////
  88. HRESULT InitSecZonesPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  89. {
  90. HRESULT hr = NOERROR;
  91. __try
  92. {
  93. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  94. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  95. if (SUCCEEDED(hr))
  96. {
  97. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  98. long nPSObjects = pDRD->GetPSObjCount();
  99. for (long nObj = 0; nObj < nPSObjects; nObj++)
  100. {
  101. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  102. // importSecurityZoneSettings field
  103. BOOL bImport = FALSE;
  104. _variant_t vtValue;
  105. hr = paPSObj[nObj]->pObj->Get(L"importSecurityZoneSettings", 0, &vtValue, NULL, NULL);
  106. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  107. bImport = (bool)vtValue ? TRUE : FALSE;
  108. _bstr_t bstrSetting;
  109. if (bImport)
  110. {
  111. TCHAR szTemp[MAX_PATH];
  112. LoadString(g_hInstance, IDS_IMPORTZONES_SETTING, szTemp, countof(szTemp));
  113. bstrSetting = szTemp;
  114. }
  115. else
  116. bstrSetting = GetDisabledString();
  117. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  118. }
  119. }
  120. }
  121. __except(TRUE)
  122. {
  123. }
  124. return hr;
  125. }
  126. /////////////////////////////////////////////////////////////////////
  127. HRESULT InitContentRatPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  128. {
  129. HRESULT hr = NOERROR;
  130. __try
  131. {
  132. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  133. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  134. if (SUCCEEDED(hr))
  135. {
  136. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  137. long nPSObjects = pDRD->GetPSObjCount();
  138. for (long nObj = 0; nObj < nPSObjects; nObj++)
  139. {
  140. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  141. // importContentRatingsSettings field
  142. BOOL bImport = FALSE;
  143. _variant_t vtValue;
  144. hr = paPSObj[nObj]->pObj->Get(L"importContentRatingsSettings", 0, &vtValue, NULL, NULL);
  145. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  146. bImport = (bool)vtValue ? TRUE : FALSE;
  147. _bstr_t bstrSetting;
  148. if (bImport)
  149. {
  150. TCHAR szTemp[MAX_PATH];
  151. LoadString(g_hInstance, IDS_IMPORTRATINGS_SETTING, szTemp, countof(szTemp));
  152. bstrSetting = szTemp;
  153. }
  154. else
  155. bstrSetting = GetDisabledString();
  156. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  157. }
  158. }
  159. }
  160. __except(TRUE)
  161. {
  162. }
  163. return hr;
  164. }
  165. /////////////////////////////////////////////////////////////////////
  166. HPROPSHEETPAGE AddContentRatingPropPage(UINT nID, DLGPROC dlgProc, PRSD *pPRSD)
  167. {
  168. HPROPSHEETPAGE hPage = NULL;
  169. __try
  170. {
  171. PROPSHEETPAGE page;
  172. page.dwSize = sizeof(PROPSHEETPAGE);
  173. page.dwFlags = 0;
  174. page.hInstance = g_hInstance;
  175. page.pszTemplate = MAKEINTRESOURCE(nID);
  176. page.pfnDlgProc = dlgProc;
  177. page.pfnCallback = NULL;
  178. page.lParam = (LPARAM)pPRSD;
  179. hPage = CreatePropertySheetPage(&page);
  180. }
  181. __except(TRUE)
  182. {
  183. }
  184. return hPage;
  185. }
  186. /////////////////////////////////////////////////////////////////////
  187. int CreateContentRatingsUI(HWND hDlg, CDlgRSoPData *pDRD)
  188. {
  189. int iRet = 0;
  190. __try
  191. {
  192. PRSD *pPRSD = new PRSD;
  193. if (NULL != pPRSD)
  194. {
  195. pPRSD->hInst = g_hInstance;
  196. pPRSD->pDRD = pDRD;
  197. pPRSD->hwndBitmapCategory = NULL;
  198. pPRSD->hwndBitmapLabel = NULL;
  199. pPRSD->fNewProviders = FALSE;
  200. HPROPSHEETPAGE apsPage[4];
  201. apsPage[0] = AddContentRatingPropPage(IDD_RATINGS, PicsDlgProc, pPRSD);
  202. apsPage[1] = AddContentRatingPropPage(IDD_APPROVEDSITES, ApprovedSitesDlgProc, pPRSD);
  203. apsPage[2] = AddContentRatingPropPage(IDD_GENERAL, GeneralDlgProc, pPRSD);
  204. apsPage[3] = AddContentRatingPropPage(IDD_ADVANCED, AdvancedDlgProc, pPRSD);
  205. PROPSHEETHEADER psHeader;
  206. memset(&psHeader,0,sizeof(psHeader));
  207. psHeader.dwSize = sizeof(psHeader);
  208. psHeader.dwFlags = PSH_PROPTITLE;
  209. psHeader.hwndParent = hDlg;
  210. psHeader.hInstance = g_hInstance;
  211. psHeader.nPages = 4;
  212. psHeader.nStartPage = 0;
  213. psHeader.phpage = apsPage;
  214. psHeader.pszCaption = MAKEINTRESOURCE(IDS_GENERIC);
  215. iRet = (int)PropertySheet(&psHeader);
  216. delete pPRSD;
  217. }
  218. }
  219. __except(TRUE)
  220. {
  221. }
  222. return iRet;
  223. }
  224. /////////////////////////////////////////////////////////////////////
  225. int CreateINetCplSecurityLookALikePages(HWND hwndParent, LPARAM lParam)
  226. {
  227. int iRet = 0;
  228. __try
  229. {
  230. PROPSHEETPAGE pageSec, pagePriv;
  231. // create the security property page
  232. pageSec.dwSize = sizeof(PROPSHEETPAGE);
  233. pageSec.dwFlags = 0;
  234. pageSec.hInstance = g_hInstance;
  235. pageSec.pszTemplate = MAKEINTRESOURCE(IDD_IMPORTEDSECZONES);
  236. pageSec.pfnDlgProc = importSecZonesRSoPProc;
  237. pageSec.pfnCallback = NULL;
  238. pageSec.lParam = lParam;
  239. HPROPSHEETPAGE ahpage[2];
  240. ahpage[0] = CreatePropertySheetPage(&pageSec);
  241. // setup privacy property page
  242. pagePriv.dwSize = sizeof(PROPSHEETPAGE);
  243. pagePriv.dwFlags = 0;
  244. pagePriv.hInstance = g_hInstance;
  245. pagePriv.pszTemplate = MAKEINTRESOURCE(IDD_PRIVACY);
  246. pagePriv.pfnDlgProc = PrivacyDlgProc;
  247. pagePriv.pfnCallback = NULL;
  248. pagePriv.lParam = lParam;
  249. ahpage[1] = CreatePropertySheetPage(&pagePriv);
  250. // add pages to the sheet
  251. PROPSHEETHEADER psHeader;
  252. memset(&psHeader,0,sizeof(psHeader));
  253. psHeader.dwSize = sizeof(psHeader);
  254. psHeader.dwFlags = PSH_PROPTITLE;
  255. psHeader.hwndParent = hwndParent;
  256. psHeader.hInstance = g_hInstance;
  257. psHeader.nPages = 2;
  258. psHeader.nStartPage = 0;
  259. psHeader.phpage = ahpage;
  260. psHeader.pszCaption = MAKEINTRESOURCE(IDS_INTERNET_LOC);
  261. iRet = (int)PropertySheet(&psHeader);
  262. }
  263. __except(TRUE)
  264. {
  265. }
  266. return iRet;
  267. }
  268. INT_PTR CALLBACK EnhancedSecurityWarningDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  269. {
  270. UNREFERENCED_PARAMETER(lParam);
  271. switch (uMsg)
  272. {
  273. case WM_INITDIALOG:
  274. {
  275. TCHAR szBuffer[MAX_PATH * 3];
  276. UINT uID1, uID2, uID3, uID4;
  277. if(IEHardened())
  278. {
  279. uID1 = IDS_IESC_HARDENDESC1;
  280. uID2 = IDS_IESC_HARDENDESC2;
  281. uID3 = IDS_IESC_HARDENDESC3;
  282. uID4 = IDS_IESC_HARDENDESC4;
  283. }
  284. else
  285. {
  286. uID1 = IDS_IESC_SOFTENESC1;
  287. uID2 = IDS_IESC_SOFTENESC2;
  288. uID3 = IDS_IESC_SOFTENESC3;
  289. uID4 = IDS_IESC_SOFTENESC4;
  290. }
  291. LoadString(g_hInstance, uID1, szBuffer, ARRAYSIZE(szBuffer));
  292. SetDlgItemText(hDlg, IDC_STATIC1, szBuffer);
  293. LoadString(g_hInstance, uID2, szBuffer, ARRAYSIZE(szBuffer));
  294. SetDlgItemText(hDlg, IDC_STATIC2, szBuffer);
  295. LoadString(g_hInstance, uID3, szBuffer, ARRAYSIZE(szBuffer));
  296. SetDlgItemText(hDlg, IDC_STATIC3, szBuffer);
  297. LoadString(g_hInstance, uID4, szBuffer, ARRAYSIZE(szBuffer));
  298. SetDlgItemText(hDlg, IDC_STATIC4, szBuffer);
  299. break;
  300. }
  301. case WM_COMMAND:
  302. switch(LOWORD(wParam))
  303. {
  304. case IDCANCEL:
  305. EndDialog(hDlg, IDCANCEL);
  306. break;
  307. case IDOK:
  308. EndDialog(hDlg, IDOK);
  309. break;
  310. }
  311. break;
  312. default:
  313. return FALSE;
  314. }
  315. return TRUE;
  316. }
  317. INT_PTR ShowIEHardenWarning(HWND hParent)
  318. {
  319. return DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_IEESCDLG),
  320. hParent, EnhancedSecurityWarningDlgProc, NULL);
  321. }
  322. /////////////////////////////////////////////////////////////////////
  323. INT_PTR CALLBACK SecurityZonesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  324. {
  325. // Retrieve Property Sheet Page info for each call into dlg proc.
  326. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  327. TCHAR szWorkDir[MAX_PATH],
  328. szInf[MAX_PATH];
  329. BOOL fImport;
  330. switch (uMsg)
  331. {
  332. case WM_SETFONT:
  333. //a change to mmc requires us to do this logic for all our property pages that use common controls
  334. INITCOMMONCONTROLSEX iccx;
  335. iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
  336. iccx.dwICC = ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES |ICC_TREEVIEW_CLASSES;
  337. InitCommonControlsEx(&iccx);
  338. break;
  339. case WM_INITDIALOG:
  340. SetPropSheetCookie(hDlg, lParam);
  341. // find out if this dlg is in RSoP mode
  342. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  343. if (psCookie->pCS->IsRSoP())
  344. {
  345. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES, IDC_NOZONES);
  346. CheckRadioButton(hDlg, IDC_NORAT, IDC_IMPORTRAT, IDC_NORAT);
  347. TCHAR szViewSettings[128];
  348. LoadString(g_hInstance, IDS_VIEW_SETTINGS, szViewSettings, countof(szViewSettings));
  349. SetDlgItemText(hDlg, IDC_MODIFYZONES, szViewSettings);
  350. SetDlgItemText(hDlg, IDC_MODIFYRAT, szViewSettings);
  351. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  352. if (pDRD)
  353. {
  354. pDRD->SetPlanningMode(psCookie->pCS->GetCompData()->IsPlanningMode());
  355. InitSecZonesDlgInRSoPMode(hDlg, pDRD);
  356. }
  357. }
  358. break;
  359. case WM_DESTROY:
  360. if (psCookie->pCS->IsRSoP())
  361. DestroyDlgRSoPData(hDlg);
  362. break;
  363. case WM_TIMER:
  364. {
  365. KillTimer(hDlg, 1);
  366. if(IDCANCEL == ShowIEHardenWarning(hDlg))
  367. {
  368. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES, IDC_NOZONES);
  369. SetFocus(GetDlgItem(hDlg, IDC_NOZONES));
  370. }
  371. break;
  372. }
  373. case WM_NOTIFY:
  374. switch (((LPNMHDR)lParam)->code)
  375. {
  376. case PSN_SETACTIVE:
  377. // don't do any of this stuff in RSoP mode
  378. if (!psCookie->pCS->IsRSoP())
  379. {
  380. // zones
  381. fImport = InsGetBool(SECURITY_IMPORTS, TEXT("ImportSecZones"), FALSE, GetInsFile(hDlg));
  382. if(fImport)
  383. {
  384. SetTimer(hDlg, 1, 300, NULL);
  385. }
  386. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES, fImport ? IDC_IMPORTZONES : IDC_NOZONES);
  387. EnableDlgItem2(hDlg, IDC_MODIFYZONES, fImport);
  388. // ratings
  389. fImport = InsGetBool(SECURITY_IMPORTS, TEXT("ImportRatings"), FALSE, GetInsFile(hDlg));
  390. CheckRadioButton(hDlg, IDC_NORAT, IDC_IMPORTRAT, fImport ? IDC_IMPORTRAT : IDC_NORAT);
  391. EnableDlgItem2(hDlg, IDC_MODIFYRAT, fImport);
  392. }
  393. break;
  394. case PSN_APPLY:
  395. if (psCookie->pCS->IsRSoP())
  396. return FALSE;
  397. else
  398. {
  399. if (!AcquireWriteCriticalSection(hDlg))
  400. {
  401. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  402. break;
  403. }
  404. // process zones
  405. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\ZONES"), szWorkDir);
  406. PathCombine(szInf, szWorkDir, TEXT("seczones.inf"));
  407. ImportZones(GetInsFile(hDlg), NULL, szInf, IsDlgButtonChecked(hDlg, IDC_IMPORTZONES) == BST_CHECKED);
  408. if (PathIsDirectoryEmpty(szWorkDir))
  409. PathRemovePath(szWorkDir);
  410. // process ratings
  411. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\RATINGS"), szWorkDir);
  412. PathCombine(szInf, szWorkDir, TEXT("ratings.inf"));
  413. ImportRatings(GetInsFile(hDlg), NULL, szInf, IsDlgButtonChecked(hDlg, IDC_IMPORTRAT) == BST_CHECKED);
  414. if (PathIsDirectoryEmpty(szWorkDir))
  415. PathRemovePath(szWorkDir);
  416. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  417. }
  418. break;
  419. case PSN_HELP:
  420. ShowHelpTopic(hDlg);
  421. break;
  422. default:
  423. return FALSE;
  424. }
  425. break;
  426. case WM_COMMAND:
  427. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  428. return FALSE;
  429. switch (GET_WM_COMMAND_ID(wParam, lParam))
  430. {
  431. case IDC_NOZONES:
  432. DisableDlgItem(hDlg, IDC_MODIFYZONES);
  433. break;
  434. case IDC_IMPORTZONES:
  435. {
  436. INT_PTR uRet = ShowIEHardenWarning(hDlg);
  437. if(uRet == IDCANCEL)
  438. {
  439. CheckRadioButton(hDlg, IDC_NOZONES, IDC_IMPORTZONES, IDC_NOZONES);
  440. SetFocus(GetDlgItem(hDlg, IDC_NOZONES));
  441. break;
  442. }
  443. EnableDlgItem(hDlg, IDC_MODIFYZONES);
  444. }
  445. break;
  446. case IDC_MODIFYZONES:
  447. if (psCookie->pCS->IsRSoP())
  448. {
  449. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  450. if (NULL != pDRD)
  451. CreateINetCplSecurityLookALikePages(hDlg, (LPARAM)pDRD);
  452. }
  453. else
  454. ModifyZones(hDlg);
  455. break;
  456. case IDC_NORAT:
  457. DisableDlgItem(hDlg, IDC_MODIFYRAT);
  458. break;
  459. case IDC_IMPORTRAT:
  460. EnableDlgItem(hDlg, IDC_MODIFYRAT);
  461. break;
  462. case IDC_MODIFYRAT:
  463. if (psCookie->pCS->IsRSoP())
  464. {
  465. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  466. if (NULL != pDRD)
  467. CreateContentRatingsUI(hDlg, pDRD);
  468. }
  469. else
  470. ModifyRatings(hDlg);
  471. break;
  472. default:
  473. return FALSE;
  474. }
  475. break;
  476. case WM_HELP:
  477. ShowHelpTopic(hDlg);
  478. break;
  479. default:
  480. return FALSE;
  481. }
  482. return TRUE;
  483. }
  484. //*******************************************************************
  485. // CODE FROM INETCPL
  486. //*******************************************************************
  487. TCHAR g_szLevel[3][64];
  488. TCHAR LEVEL_DESCRIPTION0[300];
  489. TCHAR LEVEL_DESCRIPTION1[300];
  490. TCHAR LEVEL_DESCRIPTION2[300];
  491. TCHAR LEVEL_DESCRIPTION3[300];
  492. LPTSTR LEVEL_DESCRIPTION[NUM_TEMPLATE_LEVELS] = {
  493. LEVEL_DESCRIPTION0,
  494. LEVEL_DESCRIPTION1,
  495. LEVEL_DESCRIPTION2,
  496. LEVEL_DESCRIPTION3
  497. };
  498. TCHAR CUSTOM_DESCRIPTION[300];
  499. TCHAR LEVEL_NAME0[30];
  500. TCHAR LEVEL_NAME1[30];
  501. TCHAR LEVEL_NAME2[30];
  502. TCHAR LEVEL_NAME3[30];
  503. LPTSTR LEVEL_NAME[NUM_TEMPLATE_LEVELS] = {
  504. LEVEL_NAME0,
  505. LEVEL_NAME1,
  506. LEVEL_NAME2,
  507. LEVEL_NAME3
  508. };
  509. TCHAR CUSTOM_NAME[30];
  510. /////////////////////////////////////////////////////////////////////
  511. // Initialize the global variables (to be destroyed at WM_DESTROY)
  512. // pSec, Urlmon, pSec->pInternetZoneManager, pSec->hIml
  513. // and set up the proper relationships among them
  514. /////////////////////////////////////////////////////////////////////
  515. BOOL SecurityInitGlobals(LPSECURITYPAGE *ppSec, HWND hDlg, CDlgRSoPData *pDRD,
  516. DWORD dwZoneCount)
  517. {
  518. BOOL bRet = TRUE;
  519. __try
  520. {
  521. DWORD cxIcon;
  522. DWORD cyIcon;
  523. LPSECURITYPAGE pSec = (LPSECURITYPAGE)LocalAlloc(LPTR, sizeof(SECURITYPAGE));
  524. *ppSec = pSec;
  525. if (!pSec)
  526. bRet = FALSE; // no memory?
  527. if (bRet)
  528. {
  529. pSec->dwZoneCount = dwZoneCount;
  530. pSec->pDRD = pDRD; // for rsop functionality
  531. pSec->hinstUrlmon = NULL; // don't need any of its functions
  532. // get our zones hwnd
  533. pSec->hwndZones = GetDlgItem(hDlg, IDC_LIST_ZONE);
  534. if(! pSec->hwndZones)
  535. {
  536. ASSERT(FALSE);
  537. bRet = FALSE; // no list box?
  538. }
  539. }
  540. if (bRet)
  541. {
  542. // tell dialog where to get info
  543. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pSec);
  544. // save the handle to the page
  545. pSec->hDlg = hDlg;
  546. pSec->fPendingChange = FALSE;
  547. // create an imagelist for the ListBox
  548. cxIcon = GetSystemMetrics(SM_CXICON);
  549. cyIcon = GetSystemMetrics(SM_CYICON);
  550. #ifndef UNIX
  551. UINT flags = ILC_COLOR32|ILC_MASK;
  552. // TODO: commented out for RSOP; should it be uncommented?
  553. // if(IS_WINDOW_RTL_MIRRORED(hDlg))
  554. // flags |= ILC_MIRROR;
  555. pSec->himl = ImageList_Create(cxIcon, cyIcon, flags, pSec->dwZoneCount, 0);
  556. #else
  557. pSec->himl = ImageList_Create(cxIcon, cyIcon, ILC_COLOR|ILC_MASK, pSec->dwZoneCount, 0);
  558. #endif
  559. if(! pSec->himl)
  560. bRet = FALSE; // Image list not created
  561. }
  562. if (bRet)
  563. SendMessage(pSec->hwndZones, LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)pSec->himl);
  564. }
  565. __except(TRUE)
  566. {
  567. }
  568. return bRet;
  569. }
  570. /////////////////////////////////////////////////////////////////////
  571. int ZoneIndexToGuiIndex(DWORD dwZoneIndex)
  572. // Product testing asked for the zones in a specific order in the list box;
  573. // This function returns the desired gui position for a given zone
  574. // Unrecognized zones are added to the front
  575. {
  576. int iGuiIndex = -1;
  577. switch(dwZoneIndex)
  578. {
  579. // Intranet: 2nd spot
  580. case 1:
  581. iGuiIndex = 1;
  582. break;
  583. // Internet: 1st spot
  584. case 3:
  585. iGuiIndex = 0;
  586. break;
  587. // Trusted Sites: 3rd Spot
  588. case 2:
  589. iGuiIndex = 2;
  590. break;
  591. // Restricted Sites: 4th Spot
  592. case 4:
  593. iGuiIndex = 3;
  594. break;
  595. // unknown zone
  596. default:
  597. iGuiIndex = -1;
  598. break;
  599. }
  600. return iGuiIndex;
  601. }
  602. /////////////////////////////////////////////////////////////////////
  603. // Fill a zone with information from WMI and add it to the
  604. // ordered list going to the listbox
  605. // Return values:
  606. // S_OK indicates success
  607. // S_FALSE indicates a good state, but the zone was not added (example: flag ZAFLAGS_NO_UI)
  608. // E_OUTOFMEMORY
  609. // E_FAIL - other failure
  610. /////////////////////////////////////////////////////////////////////
  611. HRESULT SecurityInitZone(DWORD dwIndex, DWORD dwZoneCount, BSTR bstrObjPath,
  612. ComPtr<IWbemClassObject> pSZObj, LPSECURITYPAGE pSec,
  613. LV_ITEM *plviZones, BOOL *pfSpotTaken)
  614. {
  615. HRESULT hr = S_OK;
  616. __try
  617. {
  618. // create a structure for zone settings
  619. LPSECURITYZONESETTINGS pszs = (LPSECURITYZONESETTINGS)LocalAlloc(LPTR, sizeof(*pszs));
  620. if (pszs)
  621. {
  622. // store settings for later use
  623. StrCpyW(pszs->wszObjPath, bstrObjPath);
  624. // flags field
  625. _variant_t vtValue;
  626. hr = pSZObj->Get(L"flags", 0, &vtValue, NULL, NULL);
  627. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  628. pszs->dwFlags = (long)vtValue;
  629. // zoneIndex field
  630. hr = pSZObj->Get(L"zoneIndex", 0, &vtValue, NULL, NULL);
  631. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  632. pszs->dwZoneIndex = (long)vtValue;
  633. // currentTemplateLevel field
  634. hr = pSZObj->Get(L"currentTemplateLevel", 0, &vtValue, NULL, NULL);
  635. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  636. pszs->dwSecLevel = (long)vtValue;
  637. // minimumTemplateLevel field
  638. hr = pSZObj->Get(L"minimumTemplateLevel", 0, &vtValue, NULL, NULL);
  639. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  640. pszs->dwMinSecLevel = (long)vtValue;
  641. // recommendedTemplateLevel field
  642. hr = pSZObj->Get(L"recommendedTemplateLevel", 0, &vtValue, NULL, NULL);
  643. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  644. pszs->dwRecSecLevel = (long)vtValue;
  645. // displayName field
  646. _bstr_t bstrValue;
  647. hr = pSZObj->Get(L"displayName", 0, &vtValue, NULL, NULL);
  648. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  649. {
  650. bstrValue = vtValue;
  651. StrCpyN(pszs->szDisplayName, (LPCTSTR)bstrValue, ARRAYSIZE(pszs->szDisplayName));
  652. }
  653. // description field
  654. hr = pSZObj->Get(L"description", 0, &vtValue, NULL, NULL);
  655. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  656. {
  657. bstrValue = vtValue;
  658. StrCpyN(pszs->szDescription, (LPCTSTR)bstrValue, ARRAYSIZE(pszs->szDescription));
  659. }
  660. // iconPath field
  661. HICON hiconSmall = NULL;
  662. HICON hiconLarge = NULL;
  663. hr = pSZObj->Get(L"iconPath", 0, &vtValue, NULL, NULL);
  664. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  665. {
  666. bstrValue = vtValue;
  667. TCHAR szIconPath[MAX_PATH];
  668. // load the icon
  669. LPWSTR psz = (LPWSTR)bstrValue;
  670. if (*psz)
  671. {
  672. // search for the '#'
  673. while ((psz[0] != WIDETEXT('#')) && (psz[0] != WIDETEXT('\0')))
  674. psz++;
  675. // if we found it, then we have the foo.dll#00001200 format
  676. WORD iIcon = 0;
  677. if (psz[0] == WIDETEXT('#'))
  678. {
  679. psz[0] = WIDETEXT('\0');
  680. StrCpyN(szIconPath, (LPCTSTR)bstrValue, ARRAYSIZE(szIconPath));
  681. iIcon = (WORD)StrToIntW(psz+1);
  682. CHAR szPath[MAX_PATH];
  683. SHUnicodeToAnsi(szIconPath, szPath, ARRAYSIZE(szPath));
  684. ExtractIconExA(szPath,(UINT)(-1*iIcon), &hiconLarge, &hiconSmall, 1);
  685. }
  686. else
  687. {
  688. hiconLarge = (HICON)ExtractAssociatedIcon(g_hInstance, szIconPath, (LPWORD)&iIcon);
  689. }
  690. }
  691. // no icons?! well, just use the generic icon
  692. if (!hiconSmall && !hiconLarge)
  693. {
  694. hiconLarge = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ZONE));
  695. if(!hiconLarge)
  696. {
  697. LocalFree((HLOCAL)pszs);
  698. hr = S_FALSE; // no icon found for this zone, not even the generic one
  699. }
  700. }
  701. if (S_OK == hr)
  702. {
  703. // we want to save the Large icon if possible for use in the subdialogs
  704. pszs->hicon = hiconLarge ? hiconLarge : hiconSmall;
  705. }
  706. }
  707. // zoneMappings field
  708. hr = pSZObj->Get(L"zoneMappings", 0, &vtValue, NULL, NULL);
  709. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  710. {
  711. SAFEARRAY *psa = vtValue.parray;
  712. LONG lLBound, lUBound;
  713. hr = SafeArrayGetLBound(psa, 1, &lLBound);
  714. if (SUCCEEDED(hr))
  715. {
  716. hr = SafeArrayGetUBound(psa, 1, &lUBound);
  717. if (SUCCEEDED(hr))
  718. pszs->nMappings = lUBound - lLBound + 1;
  719. }
  720. }
  721. hr = S_OK;
  722. // Find the proper index for the zone in the listbox (there is a user-preferred order)
  723. int iSpot = ZoneIndexToGuiIndex(dwIndex);
  724. if(iSpot == -1)
  725. {
  726. // if not a recognized zone, add it to the end of the list
  727. iSpot = dwZoneCount - 1;
  728. }
  729. // Make sure there are no collisisons
  730. while(iSpot >= 0 && pfSpotTaken[iSpot] == TRUE)
  731. {
  732. iSpot--;
  733. }
  734. // Don't go past beginning of array
  735. if(iSpot < 0)
  736. {
  737. // It can be proven that it is impossible to get here, unless there is
  738. // something wrong with the function ZoneIndexToGuiIndex
  739. ASSERT(FALSE);
  740. LocalFree((HLOCAL)pszs);
  741. if(hiconSmall)
  742. DestroyIcon(hiconSmall);
  743. if(hiconLarge)
  744. DestroyIcon(hiconLarge);
  745. hr = E_FAIL;
  746. }
  747. LV_ITEM *plvItem = NULL;
  748. if (S_OK == hr)
  749. {
  750. plvItem = &(plviZones[iSpot]);
  751. pfSpotTaken[iSpot] = TRUE;
  752. // init the List Box item and save it for later addition
  753. plvItem->mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  754. plvItem->iItem = iSpot;
  755. plvItem->iSubItem = 0;
  756. // large icons prefered for the icon view (if switch back to report view, prefer small icons)
  757. plvItem->iImage = ImageList_AddIcon(pSec->himl, hiconLarge ? hiconLarge : hiconSmall);
  758. plvItem->pszText = new TCHAR[MAX_PATH];
  759. if(!plvItem->pszText)
  760. {
  761. LocalFree((HLOCAL)pszs);
  762. if(hiconSmall)
  763. DestroyIcon(hiconSmall);
  764. if(hiconLarge)
  765. DestroyIcon(hiconLarge);
  766. hr = E_OUTOFMEMORY;
  767. }
  768. }
  769. if (S_OK == hr)
  770. {
  771. StrCpy(plvItem->pszText, pszs->szDisplayName);
  772. plvItem->lParam = (LPARAM)pszs; // save the zone settings here
  773. // if we created a small icon, destroy it, since the system does not save the handle
  774. // when it is added to the imagelist (see ImageList_AddIcon in VC help)
  775. // Keep it around if we had to use it in place of the large icon
  776. if (hiconSmall && hiconLarge)
  777. DestroyIcon(hiconSmall);
  778. }
  779. }
  780. else
  781. hr = E_OUTOFMEMORY;
  782. }
  783. __except(TRUE)
  784. {
  785. }
  786. return hr;
  787. }
  788. /////////////////////////////////////////////////////////////////////
  789. // To make the slider control accessbile we have to subclass it and over-ride
  790. // the accessiblity object
  791. /////////////////////////////////////////////////////////////////////
  792. void SecurityInitSlider(LPSECURITYPAGE pSec)
  793. {
  794. // Initialize the slider control (set number of levels, and frequency one tick per level)
  795. SendDlgItemMessage(pSec->hDlg, IDC_SLIDER, TBM_SETRANGE, (WPARAM) (BOOL) FALSE, (LPARAM) MAKELONG(0, NUM_TEMPLATE_LEVELS - 1));
  796. SendDlgItemMessage(pSec->hDlg, IDC_SLIDER, TBM_SETTICFREQ, (WPARAM) 1, (LPARAM) 0);
  797. }
  798. /////////////////////////////////////////////////////////////////////
  799. void SecurityInitControls(LPSECURITYPAGE pSec)
  800. {
  801. // select the 0 position zone
  802. LV_ITEM lvItem;
  803. lvItem.mask = LVIF_STATE;
  804. lvItem.stateMask = LVIS_SELECTED;
  805. lvItem.state = LVIS_SELECTED;
  806. SendMessage(pSec->hwndZones, LVM_SETITEMSTATE, 0, (LPARAM)&lvItem);
  807. // get the zone settings for the selected item
  808. lvItem.mask = LVIF_PARAM;
  809. lvItem.iItem = pSec->iZoneSel;
  810. lvItem.iSubItem = 0;
  811. SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem);
  812. pSec->pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  813. // Initialize the local strings to carry the Level Descriptions
  814. LoadString(g_hInstance, IDS_TEMPLATE_DESC_HI, LEVEL_DESCRIPTION0, ARRAYSIZE(LEVEL_DESCRIPTION0));
  815. LoadString(g_hInstance, IDS_TEMPLATE_DESC_MED, LEVEL_DESCRIPTION1, ARRAYSIZE(LEVEL_DESCRIPTION1));
  816. LoadString(g_hInstance, IDS_TEMPLATE_DESC_MEDLOW, LEVEL_DESCRIPTION2, ARRAYSIZE(LEVEL_DESCRIPTION2));
  817. LoadString(g_hInstance, IDS_TEMPLATE_DESC_LOW, LEVEL_DESCRIPTION3, ARRAYSIZE(LEVEL_DESCRIPTION3));
  818. LoadString(g_hInstance, IDS_TEMPLATE_DESC_CUSTOM, CUSTOM_DESCRIPTION, ARRAYSIZE(CUSTOM_DESCRIPTION));
  819. LoadString(g_hInstance, IDS_TEMPLATE_NAME_HI, LEVEL_NAME0, ARRAYSIZE(LEVEL_NAME0));
  820. LoadString(g_hInstance, IDS_TEMPLATE_NAME_MED, LEVEL_NAME1, ARRAYSIZE(LEVEL_NAME1));
  821. LoadString(g_hInstance, IDS_TEMPLATE_NAME_MEDLOW, LEVEL_NAME2, ARRAYSIZE(LEVEL_NAME2));
  822. LoadString(g_hInstance, IDS_TEMPLATE_NAME_LOW, LEVEL_NAME3, ARRAYSIZE(LEVEL_NAME3));
  823. LoadString(g_hInstance, IDS_TEMPLATE_NAME_CUSTOM, CUSTOM_NAME, ARRAYSIZE(CUSTOM_NAME));
  824. // Initialize text boxes and icons for the current zone
  825. SetDlgItemText(pSec->hDlg, IDC_ZONE_DESCRIPTION, pSec->pszs->szDescription);
  826. SetDlgItemText(pSec->hDlg, IDC_ZONELABEL, pSec->pszs->szDisplayName);
  827. SendDlgItemMessage(pSec->hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pSec->pszs->hicon);
  828. // Initialize the slider control
  829. SecurityInitSlider(pSec);
  830. // Initialize the list view (add column 0 for icon and text, and autosize it)
  831. LV_COLUMN lvCasey;
  832. lvCasey.mask = 0;
  833. SendDlgItemMessage(pSec->hDlg, IDC_LIST_ZONE, LVM_INSERTCOLUMN, (WPARAM) 0, (LPARAM) &lvCasey);
  834. SendDlgItemMessage(pSec->hDlg, IDC_LIST_ZONE, LVM_SETCOLUMNWIDTH, (WPARAM) 0, (LPARAM) MAKELPARAM(LVSCW_AUTOSIZE, 0));
  835. // Set the font of the name to the bold font
  836. pSec->hfontBolded = NULL;
  837. HFONT hfontOrig = (HFONT) SendDlgItemMessage(pSec->hDlg, IDC_STATIC_EMPTY, WM_GETFONT, (WPARAM) 0, (LPARAM) 0);
  838. if(hfontOrig == NULL)
  839. hfontOrig = (HFONT) GetStockObject(SYSTEM_FONT);
  840. // set the zone name and level font to bolded
  841. if(hfontOrig)
  842. {
  843. LOGFONT lfData;
  844. if(GetObject(hfontOrig, sizeof(lfData), &lfData) != 0)
  845. {
  846. // The distance from 400 (normal) to 700 (bold)
  847. lfData.lfWeight += 300;
  848. if(lfData.lfWeight > 1000)
  849. lfData.lfWeight = 1000;
  850. pSec->hfontBolded = CreateFontIndirect(&lfData);
  851. if(pSec->hfontBolded)
  852. {
  853. // the zone level and zone name text boxes should have the same font, so this is okat
  854. SendDlgItemMessage(pSec->hDlg, IDC_ZONELABEL, WM_SETFONT, (WPARAM) pSec->hfontBolded, (LPARAM) MAKELPARAM(FALSE, 0));
  855. SendDlgItemMessage(pSec->hDlg, IDC_LEVEL_NAME, WM_SETFONT, (WPARAM) pSec->hfontBolded, (LPARAM) MAKELPARAM(FALSE, 0));
  856. }
  857. }
  858. }
  859. }
  860. /////////////////////////////////////////////////////////////////////
  861. // Converting the Security Level DWORD identitifiers to slider levels, and vice versa
  862. /////////////////////////////////////////////////////////////////////
  863. int SecLevelToSliderPos(DWORD dwLevel)
  864. {
  865. switch(dwLevel)
  866. {
  867. case URLTEMPLATE_LOW:
  868. return 3;
  869. case URLTEMPLATE_MEDLOW:
  870. return 2;
  871. case URLTEMPLATE_MEDIUM:
  872. return 1;
  873. case URLTEMPLATE_HIGH:
  874. return 0;
  875. case URLTEMPLATE_CUSTOM:
  876. return -1;
  877. default:
  878. return -2;
  879. }
  880. }
  881. /////////////////////////////////////////////////////////////////////
  882. // Duties:
  883. // Make the controls (slider, en/disabled buttons) match the data for the current zone
  884. // Make the views (Level description text) match the data for the current zone
  885. // Set focus (to slider, if enabled, else custom settings button, if enabled, else
  886. // listbox) if fSetFocus is TRUE
  887. // Note: the zone descriptions are not set here; those are handled by the code responsible
  888. // for changing zones
  889. /////////////////////////////////////////////////////////////////////
  890. BOOL SecurityEnableControls(LPSECURITYPAGE pSec, BOOL fSetFocus)
  891. {
  892. int iLevel = -1;
  893. if (pSec && pSec->pszs)
  894. {
  895. HWND hwndSlider = GetDlgItem(pSec->hDlg, IDC_SLIDER);
  896. iLevel = SecLevelToSliderPos(pSec->pszs->dwSecLevel);
  897. ASSERT(iLevel > -2);
  898. // Set the level of the slider to the setting for the current zone
  899. // Show or hide the slider for preset levels/custom
  900. // Set the level description text
  901. if(iLevel >= 0)
  902. {
  903. SendMessage(hwndSlider, TBM_SETPOS, (WPARAM) (BOOL) TRUE, (LPARAM) (LONG) iLevel);
  904. // Make sure the slider is visible
  905. ShowWindow(hwndSlider, SW_SHOW);
  906. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_SLIDERMOVETEXT), SW_SHOW);
  907. SetDlgItemText(pSec->hDlg, IDC_LEVEL_DESCRIPTION, LEVEL_DESCRIPTION[iLevel]);
  908. SetDlgItemText(pSec->hDlg, IDC_LEVEL_NAME, LEVEL_NAME[iLevel]);
  909. }
  910. else
  911. {
  912. // Hide the slider for custom
  913. ShowWindow(hwndSlider, SW_HIDE);
  914. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_SLIDERMOVETEXT), SW_HIDE);
  915. SetDlgItemText(pSec->hDlg, IDC_LEVEL_DESCRIPTION, CUSTOM_DESCRIPTION);
  916. SetDlgItemText(pSec->hDlg, IDC_LEVEL_NAME, CUSTOM_NAME);
  917. }
  918. // If the zone is empty, show the "zone is empty" string
  919. // Default is to not show the sting (if something goes wrong)
  920. // Empty zone not possible for internet, intranet, or local zones
  921. if((pSec->pszs->dwZoneIndex != URLZONE_INTRANET &&
  922. pSec->pszs->dwZoneIndex != URLZONE_INTERNET) &&
  923. pSec->pszs->dwZoneIndex != URLZONE_LOCAL_MACHINE)
  924. {
  925. // If there aren't any zone mappings, zone is empty (not valid for internet and intranet)
  926. if (pSec->pszs->nMappings > 0)
  927. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_EMPTY), SW_HIDE);
  928. else
  929. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_EMPTY), SW_SHOW);
  930. }
  931. else
  932. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_EMPTY), SW_HIDE);
  933. // If we were told to set focus then move focus to the slider.
  934. if (fSetFocus)
  935. {
  936. if(!pSec->fNoEdit)
  937. {
  938. if(iLevel >= 0)
  939. SetFocus(hwndSlider);
  940. else if(pSec->pszs->dwFlags & ZAFLAGS_CUSTOM_EDIT)
  941. SetFocus(GetDlgItem(pSec->hDlg, IDC_BUTTON_SETTINGS));
  942. else
  943. SetFocus(GetDlgItem(pSec->hDlg, IDC_LIST_ZONE));
  944. }
  945. else // No focus is allowed, set focus to the list box
  946. SetFocus(GetDlgItem(pSec->hDlg, IDC_LIST_ZONE));
  947. }
  948. EnableWindow(GetDlgItem(pSec->hDlg, IDC_BUTTON_SETTINGS),
  949. (pSec->pszs->dwFlags & ZAFLAGS_CUSTOM_EDIT) && !pSec->fNoEdit);
  950. EnableWindow(GetDlgItem(pSec->hDlg, IDC_BUTTON_ADD_SITES),
  951. (pSec->pszs->dwFlags & ZAFLAGS_ADD_SITES) && !pSec->fDisableAddSites);
  952. EnableDlgItem2(pSec->hDlg, IDC_SLIDER, FALSE);
  953. EnableDlgItem2(pSec->hDlg, IDC_ZONE_RESET, FALSE);
  954. return TRUE;
  955. }
  956. return FALSE;
  957. }
  958. BOOL IsESCEnabled(CDlgRSoPData *pDRD, DWORD dwPrecedence)
  959. {
  960. WCHAR wszObjPath[128];
  961. wnsprintf(wszObjPath, countof(wszObjPath),
  962. L"RSOP_IEESC.rsopID=\"IEAK\",rsopPrecedence=%ld", dwPrecedence);
  963. _bstr_t bstrObjPath = wszObjPath;
  964. ComPtr<IWbemServices> pWbemServices = pDRD->GetWbemServices();
  965. ComPtr<IWbemClassObject> pSZObj = NULL;
  966. _variant_t vtValue;
  967. HRESULT hr = pWbemServices->GetObject(bstrObjPath, 0L, NULL, (IWbemClassObject**)&pSZObj, NULL);
  968. if(SUCCEEDED(hr))
  969. {
  970. hr = pSZObj->Get(L"EscEnabled", 0, &vtValue, NULL, NULL);
  971. if (SUCCEEDED(hr) && !IsVariantNull(vtValue) && (bool)vtValue)
  972. {
  973. return TRUE;
  974. }
  975. }
  976. return FALSE;
  977. }
  978. /////////////////////////////////////////////////////////////////////
  979. BOOL InitImportedSecZonesDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  980. {
  981. BOOL bRet = TRUE;
  982. __try
  983. {
  984. // Initialize globals variables (to be destroyed at WM_DESTROY)
  985. LPSECURITYPAGE pSec = NULL;
  986. UINT iIndex = 0;
  987. DWORD dwZoneCount = pDRD->GetImportedSecZoneCount();
  988. if(SecurityInitGlobals(&pSec, hDlg, pDRD, dwZoneCount) == FALSE)
  989. {
  990. EndDialog(hDlg, 0);
  991. bRet = FALSE; // Initialization failed
  992. }
  993. if (bRet)
  994. {
  995. BOOL fUseHKLM = TRUE;
  996. // get the zone settings for this zone
  997. if (NULL != pDRD->ConnectToNamespace())
  998. {
  999. // get our stored precedence value
  1000. DWORD dwCurGPOPrec = pDRD->GetImportedSecZonesPrec();
  1001. if(!pDRD->IsPlanningMode())
  1002. {
  1003. if(IsESCEnabled(pDRD, dwCurGPOPrec))
  1004. {
  1005. TCHAR szBuffer[MAX_PATH * 2], szTitle[MAX_PATH];
  1006. LoadString(g_hInstance, IDS_IESCINFO, szBuffer, ARRAYSIZE(szBuffer));
  1007. LoadString(g_hInstance, IDS_IEESCTITLE, szTitle, ARRAYSIZE(szTitle));
  1008. MessageBox(hDlg, szBuffer, szTitle, MB_OK);
  1009. }
  1010. }
  1011. //
  1012. // Add the Listbox items for the zones
  1013. //
  1014. // The zones have to be added in a particular order
  1015. // Array used to order zones for adding
  1016. LV_ITEM *plviZones = new LV_ITEM[dwZoneCount];
  1017. BOOL *pfSpotTaken = new BOOL[dwZoneCount];
  1018. for(iIndex =0; pfSpotTaken && iIndex < dwZoneCount; iIndex++)
  1019. pfSpotTaken[iIndex] = FALSE;
  1020. // propogate zone dropdown
  1021. WCHAR wszObjPath[128];
  1022. for (DWORD dwIndex=0; dwIndex < dwZoneCount; dwIndex++)
  1023. {
  1024. // create the object path of this security zone for this GPO
  1025. wnsprintf(wszObjPath, countof(wszObjPath),
  1026. L"RSOP_IESecurityZoneSettings.rsopID=\"IEAK\",rsopPrecedence=%ld,useHKLM=%s,zoneIndex=%lu",
  1027. dwCurGPOPrec, fUseHKLM ? TEXT("TRUE") : TEXT("FALSE"), dwIndex);
  1028. _bstr_t bstrObjPath = wszObjPath;
  1029. // get the RSOP_IEProgramSettings object and its properties
  1030. ComPtr<IWbemServices> pWbemServices = pDRD->GetWbemServices();
  1031. ComPtr<IWbemClassObject> pSZObj = NULL;
  1032. HRESULT hr = pWbemServices->GetObject(bstrObjPath, 0L, NULL, (IWbemClassObject**)&pSZObj, NULL);
  1033. if (SUCCEEDED(hr))
  1034. {
  1035. if(FAILED(SecurityInitZone(dwIndex, dwZoneCount, bstrObjPath,
  1036. pSZObj, pSec, plviZones, pfSpotTaken)))
  1037. {
  1038. // Delete all memory allocated for any previous zones (which have not yet been added to
  1039. // the listbox)
  1040. for(iIndex = 0; iIndex < dwZoneCount; iIndex++)
  1041. {
  1042. if(pfSpotTaken && pfSpotTaken[iIndex] && plviZones && (LPSECURITYZONESETTINGS) (plviZones[iIndex].lParam) != NULL)
  1043. {
  1044. LocalFree((LPSECURITYZONESETTINGS) (plviZones[iIndex].lParam));
  1045. plviZones[iIndex].lParam = NULL;
  1046. if(plviZones[iIndex].pszText)
  1047. delete [] plviZones[iIndex].pszText;
  1048. }
  1049. }
  1050. delete [] plviZones;
  1051. delete [] pfSpotTaken;
  1052. EndDialog(hDlg, 0);
  1053. return FALSE;
  1054. }
  1055. }
  1056. else // no more zones read from WMI
  1057. break;
  1058. }
  1059. // Add all of the arrayed list items to the listbox
  1060. for(iIndex = 0; iIndex < dwZoneCount; iIndex++)
  1061. {
  1062. if(pfSpotTaken[iIndex])
  1063. {
  1064. SendMessage(pSec->hwndZones, LVM_INSERTITEM, (WPARAM)0, (LPARAM)&(plviZones[iIndex]));
  1065. delete [] plviZones[iIndex].pszText;
  1066. }
  1067. }
  1068. delete [] plviZones;
  1069. delete [] pfSpotTaken;
  1070. }
  1071. SecurityInitControls(pSec);
  1072. SecurityEnableControls(pSec, FALSE);
  1073. }
  1074. }
  1075. __except(TRUE)
  1076. {
  1077. }
  1078. return bRet;
  1079. }
  1080. /////////////////////////////////////////////////////////////////////
  1081. // SecurityOnCommand()
  1082. //
  1083. // Handles Security Dialog's window messages
  1084. //
  1085. /////////////////////////////////////////////////////////////////////
  1086. void SecurityOnCommand(LPSECURITYPAGE pSec, UINT id, UINT nCmd)
  1087. {
  1088. UNREFERENCED_PARAMETER(nCmd);
  1089. switch (id)
  1090. {
  1091. case IDC_BUTTON_ADD_SITES:
  1092. {
  1093. if (pSec->pszs->dwZoneIndex == URLZONE_INTRANET)
  1094. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SECURITY_INTRANET), pSec->hDlg,
  1095. SecurityAddSitesIntranetDlgProc, (LPARAM)pSec);
  1096. else
  1097. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SECURITY_ADD_SITES), pSec->hDlg,
  1098. SecurityAddSitesDlgProc, (LPARAM)pSec);
  1099. // Resynch controls (in case the "zone is empty" message needs to be updated)
  1100. SecurityEnableControls(pSec, FALSE);
  1101. }
  1102. break;
  1103. case IDC_BUTTON_SETTINGS:
  1104. {
  1105. // Note: messages to change the level from preset to custom as a result of this call
  1106. // are sent by the CustomSettings dialog
  1107. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SECURITY_CUSTOM_SETTINGS), pSec->hDlg,
  1108. SecurityCustomSettingsDlgProc, (LPARAM)pSec);
  1109. break;
  1110. }
  1111. case IDC_ZONE_RESET:
  1112. break;
  1113. case IDOK:
  1114. EndDialog(pSec->hDlg, IDOK);
  1115. break;
  1116. case IDCANCEL:
  1117. EndDialog(pSec->hDlg, IDCANCEL);
  1118. break;
  1119. case IDC_SLIDER:
  1120. break;
  1121. case IDC_LIST_ZONE:
  1122. {
  1123. // Sundown: coercion to int-- selection is range-restricted
  1124. int iNewSelection = (int) SendMessage(pSec->hwndZones, LVM_GETNEXTITEM, (WPARAM)-1,
  1125. MAKELPARAM(LVNI_SELECTED, 0));
  1126. if ((iNewSelection != pSec->iZoneSel) && (iNewSelection != -1))
  1127. {
  1128. LV_ITEM lvItem;
  1129. lvItem.iItem = iNewSelection;
  1130. lvItem.iSubItem = 0;
  1131. lvItem.mask = LVIF_PARAM;
  1132. SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem);
  1133. pSec->pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  1134. pSec->iZoneSel = iNewSelection;
  1135. SetDlgItemText(pSec->hDlg, IDC_ZONE_DESCRIPTION, pSec->pszs->szDescription);
  1136. SetDlgItemText(pSec->hDlg, IDC_ZONELABEL, pSec->pszs->szDisplayName);
  1137. SendDlgItemMessage(pSec->hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pSec->pszs->hicon);
  1138. SecurityEnableControls(pSec, FALSE);
  1139. }
  1140. break;
  1141. }
  1142. }
  1143. } // SecurityOnCommand()
  1144. /////////////////////////////////////////////////////////////////////
  1145. INT_PTR CALLBACK importSecZonesRSoPProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1146. {
  1147. if (uMsg == WM_INITDIALOG)
  1148. {
  1149. CDlgRSoPData *pDRD = (CDlgRSoPData*)((LPPROPSHEETPAGE)lParam)->lParam;
  1150. BOOL fResult = InitImportedSecZonesDlgInRSoPMode(hDlg, pDRD);
  1151. return fResult;
  1152. }
  1153. LPSECURITYPAGE pSec = (LPSECURITYPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
  1154. if (!pSec)
  1155. return FALSE;
  1156. switch (uMsg)
  1157. {
  1158. case WM_COMMAND:
  1159. SecurityOnCommand(pSec, LOWORD(wParam), HIWORD(wParam));
  1160. return TRUE;
  1161. case WM_NOTIFY:
  1162. {
  1163. NMHDR *lpnm = (NMHDR *) lParam;
  1164. ASSERT(lpnm);
  1165. // List Box Messages
  1166. if(lpnm->idFrom == IDC_LIST_ZONE)
  1167. {
  1168. NM_LISTVIEW * lplvnm = (NM_LISTVIEW *) lParam;
  1169. if(lplvnm->hdr.code == LVN_ITEMCHANGED)
  1170. {
  1171. // If an item's state has changed, and it is now selected
  1172. if(((lplvnm->uChanged & LVIF_STATE) != 0) && ((lplvnm->uNewState & LVIS_SELECTED) != 0))
  1173. {
  1174. SecurityOnCommand(pSec, IDC_LIST_ZONE, LVN_ITEMCHANGED);
  1175. }
  1176. }
  1177. }
  1178. else
  1179. {
  1180. switch (lpnm->code)
  1181. {
  1182. case PSN_QUERYCANCEL:
  1183. case PSN_KILLACTIVE:
  1184. case PSN_RESET:
  1185. //TODO: What do we do with this?
  1186. // SetWindowLongPtr(pSec->hDlg, DWLP_MSGRESULT, FALSE);
  1187. return TRUE;
  1188. case PSN_APPLY:
  1189. break;
  1190. }
  1191. }
  1192. }
  1193. break;
  1194. case WM_HELP: // F1
  1195. // ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  1196. // HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1197. break;
  1198. case WM_VSCROLL:
  1199. // Slider Messages
  1200. SecurityOnCommand(pSec, IDC_SLIDER, LOWORD(wParam));
  1201. return TRUE;
  1202. case WM_CONTEXTMENU: // right mouse click
  1203. // ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  1204. // HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1205. break;
  1206. case WM_DESTROY:
  1207. if(! pSec)
  1208. break;
  1209. if(pSec->hwndZones)
  1210. {
  1211. for (int iIndex = (int)SendMessage(pSec->hwndZones, LVM_GETITEMCOUNT, 0, 0) - 1;
  1212. iIndex >= 0; iIndex--)
  1213. {
  1214. LV_ITEM lvItem;
  1215. // get security zone settings object for this item and release it
  1216. lvItem.mask = LVIF_PARAM;
  1217. lvItem.iItem = iIndex;
  1218. lvItem.iSubItem = 0;
  1219. if (SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem) == TRUE)
  1220. {
  1221. LPSECURITYZONESETTINGS pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  1222. if (pszs)
  1223. {
  1224. if (pszs->hicon)
  1225. DestroyIcon(pszs->hicon);
  1226. LocalFree((HLOCAL)pszs);
  1227. pszs = NULL;
  1228. }
  1229. }
  1230. }
  1231. }
  1232. if(pSec->himl)
  1233. ImageList_Destroy(pSec->himl);
  1234. if(pSec->hfontBolded)
  1235. DeleteObject(pSec->hfontBolded);
  1236. LocalFree(pSec);
  1237. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  1238. break;
  1239. }
  1240. return FALSE;
  1241. }
  1242. /////////////////////////////////////////////////////////////////////
  1243. void InitZoneMappingsInUI(HWND hwndList, CDlgRSoPData *pDRD,
  1244. LPSECURITYZONESETTINGS pszs)
  1245. {
  1246. __try
  1247. {
  1248. // get the RSOP_IEProgramSettings object and its properties
  1249. ComPtr<IWbemServices> pWbemServices = pDRD->GetWbemServices();
  1250. _bstr_t bstrObjPath = pszs->wszObjPath;
  1251. ComPtr<IWbemClassObject> pSZObj = NULL;
  1252. HRESULT hr = pWbemServices->GetObject(bstrObjPath, 0L, NULL, (IWbemClassObject**)&pSZObj, NULL);
  1253. if (SUCCEEDED(hr))
  1254. {
  1255. // zoneMappings field
  1256. _variant_t vtValue;
  1257. hr = pSZObj->Get(L"zoneMappings", 0, &vtValue, NULL, NULL);
  1258. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  1259. {
  1260. SAFEARRAY *psa = vtValue.parray;
  1261. BSTR HUGEP *pbstr = NULL;
  1262. hr = SafeArrayAccessData(psa, (void HUGEP**)&pbstr);
  1263. if (SUCCEEDED(hr))
  1264. {
  1265. for (long nMapping = 0; nMapping < pszs->nMappings; nMapping++)
  1266. {
  1267. LPCTSTR szMapping = (LPCTSTR)pbstr[nMapping];
  1268. SendMessage(hwndList, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)szMapping);
  1269. }
  1270. }
  1271. SafeArrayUnaccessData(psa);
  1272. }
  1273. }
  1274. }
  1275. __except(TRUE)
  1276. {
  1277. }
  1278. }
  1279. /////////////////////////////////////////////////////////////////////
  1280. INT_PTR CALLBACK SecurityAddSitesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  1281. {
  1282. LPADDSITESINFO pasi;
  1283. if (uMsg == WM_INITDIALOG)
  1284. {
  1285. pasi = (LPADDSITESINFO)LocalAlloc(LPTR, sizeof(*pasi));
  1286. if (!pasi)
  1287. {
  1288. EndDialog(hDlg, IDCANCEL);
  1289. return FALSE;
  1290. }
  1291. // tell dialog where to get info
  1292. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pasi);
  1293. // save the handle to the page
  1294. pasi->hDlg = hDlg;
  1295. pasi->pSec = (LPSECURITYPAGE)lParam;
  1296. pasi->hwndWebSites = GetDlgItem(hDlg, IDC_LIST_WEBSITES);
  1297. pasi->hwndAdd = GetDlgItem(hDlg, IDC_EDIT_ADD_SITE);
  1298. pasi->fRequireServerVerification = pasi->pSec->pszs->dwFlags & ZAFLAGS_REQUIRE_VERIFICATION;
  1299. CheckDlgButton(hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION, pasi->fRequireServerVerification);
  1300. SendMessage(hDlg, WM_SETTEXT, (WPARAM)0, (LPARAM)pasi->pSec->pszs->szDisplayName);
  1301. SendDlgItemMessage(hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pasi->pSec->pszs->hicon);
  1302. InitZoneMappingsInUI(pasi->hwndWebSites, pasi->pSec->pDRD, pasi->pSec->pszs);
  1303. EnableDlgItem2(hDlg, IDC_EDIT_ADD_SITE, FALSE);
  1304. EnableDlgItem2(hDlg, IDC_BUTTON_ADD, FALSE);
  1305. EnableDlgItem2(hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION, FALSE);
  1306. EnableDlgItem2(hDlg, IDC_BUTTON_REMOVE, FALSE);
  1307. }
  1308. else
  1309. pasi = (LPADDSITESINFO)GetWindowLongPtr(hDlg, DWLP_USER);
  1310. if (!pasi)
  1311. return FALSE;
  1312. switch (uMsg)
  1313. {
  1314. case WM_COMMAND:
  1315. switch (LOWORD(wParam))
  1316. {
  1317. case IDOK:
  1318. EndDialog(hDlg, IDOK);
  1319. break;
  1320. case IDCANCEL:
  1321. EndDialog(hDlg, IDCANCEL);
  1322. break;
  1323. case IDC_LIST_WEBSITES:
  1324. switch (HIWORD(wParam))
  1325. {
  1326. case LBN_SELCHANGE:
  1327. case LBN_SELCANCEL:
  1328. break;
  1329. }
  1330. break;
  1331. case IDC_EDIT_ADD_SITE:
  1332. switch(HIWORD(wParam))
  1333. {
  1334. case EN_CHANGE:
  1335. break;
  1336. }
  1337. break;
  1338. case IDC_BUTTON_ADD:
  1339. break;
  1340. case IDC_BUTTON_REMOVE:
  1341. break;
  1342. default:
  1343. return FALSE;
  1344. }
  1345. return TRUE;
  1346. break;
  1347. case WM_HELP: // F1
  1348. // ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  1349. // HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1350. break;
  1351. case WM_CONTEXTMENU: // right mouse click
  1352. // ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  1353. // HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1354. break;
  1355. case WM_DESTROY:
  1356. if (pasi)
  1357. {
  1358. LocalFree(pasi);
  1359. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  1360. }
  1361. break;
  1362. }
  1363. return FALSE;
  1364. }
  1365. /////////////////////////////////////////////////////////////////////
  1366. INT_PTR CALLBACK SecurityAddSitesIntranetDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  1367. {
  1368. LPADDSITESINTRANETINFO pasii;
  1369. if (uMsg == WM_INITDIALOG)
  1370. {
  1371. pasii = (LPADDSITESINTRANETINFO)LocalAlloc(LPTR, sizeof(*pasii));
  1372. if (!pasii)
  1373. {
  1374. EndDialog(hDlg, IDCANCEL);
  1375. return FALSE;
  1376. }
  1377. // tell dialog where to get info
  1378. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pasii);
  1379. // save the handle to the page
  1380. pasii->hDlg = hDlg;
  1381. pasii->pSec = (LPSECURITYPAGE)lParam;
  1382. SendMessage(hDlg, WM_SETTEXT, (WPARAM)0, (LPARAM)pasii->pSec->pszs->szDisplayName);
  1383. CheckDlgButton(hDlg, IDC_CHECK_USEINTRANET, pasii->pSec->pszs->dwFlags & ZAFLAGS_INCLUDE_INTRANET_SITES);
  1384. CheckDlgButton(hDlg, IDC_CHECK_PROXY, pasii->pSec->pszs->dwFlags & ZAFLAGS_INCLUDE_PROXY_OVERRIDE);
  1385. CheckDlgButton(hDlg, IDC_CHECK_UNC, pasii->pSec->pszs->dwFlags & ZAFLAGS_UNC_AS_INTRANET);
  1386. SendDlgItemMessage(hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pasii->pSec->pszs->hicon);
  1387. EnableDlgItem2(hDlg, IDC_CHECK_USEINTRANET, FALSE);
  1388. EnableDlgItem2(hDlg, IDC_CHECK_PROXY, FALSE);
  1389. EnableDlgItem2(hDlg, IDC_CHECK_UNC, FALSE);
  1390. return TRUE;
  1391. }
  1392. else
  1393. pasii = (LPADDSITESINTRANETINFO)GetWindowLongPtr(hDlg, DWLP_USER);
  1394. if (!pasii)
  1395. return FALSE;
  1396. switch (uMsg) {
  1397. case WM_COMMAND:
  1398. switch (LOWORD(wParam))
  1399. {
  1400. case IDOK:
  1401. EndDialog(hDlg, IDOK);
  1402. break;
  1403. case IDCANCEL:
  1404. EndDialog(hDlg, IDCANCEL);
  1405. break;
  1406. case IDC_INTRANET_ADVANCED:
  1407. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SECURITY_ADD_SITES), hDlg,
  1408. SecurityAddSitesDlgProc, (LPARAM)pasii->pSec);
  1409. break;
  1410. default:
  1411. return FALSE;
  1412. }
  1413. return TRUE;
  1414. case WM_HELP: // F1
  1415. // ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  1416. // HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1417. break;
  1418. case WM_CONTEXTMENU: // right mouse click
  1419. // ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  1420. // HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1421. break;
  1422. case WM_DESTROY:
  1423. if (pasii)
  1424. {
  1425. LocalFree(pasii);
  1426. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  1427. }
  1428. break;
  1429. }
  1430. return FALSE;
  1431. }