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.

2752 lines
99 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1995 **
  4. //*********************************************************************
  5. //
  6. // SECURITY.cpp - "Security" Property Sheet
  7. //
  8. // HISTORY:
  9. //
  10. // 6/22/96 t-gpease moved to this file
  11. // 5/14/97 t-ashlm new dialog
  12. #include "inetcplp.h"
  13. #include "inetcpl.h" // for LSDFLAGS
  14. #include "intshcut.h"
  15. #include "permdlg.h" // java permissions
  16. #include "pdlgguid.h" // guids for Java VM permissions dlg
  17. #include "advpub.h"
  18. #include <cryptui.h>
  19. #include <mluisupp.h>
  20. void LaunchSecurityDialogEx(HWND hDlg, DWORD dwZone, BOOL bForceUI, BOOL bDisableAddSites);
  21. //
  22. // Private Functions and Structures
  23. //
  24. INT_PTR CALLBACK SecurityAddSitesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  25. INT_PTR CALLBACK SecurityCustomSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  26. INT_PTR CALLBACK SecurityAddSitesIntranetDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  27. void SecurityChanged();
  28. TCHAR *MyIntToStr(TCHAR *pBuf, BYTE iVal);
  29. BOOL SecurityDlgInit(HWND hDlg);
  30. #define WIDETEXT(x) L ## x
  31. #define REGSTR_PATH_SO TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\SO")
  32. #define REGSTR_PATH_SOIEAK TEXT("Sofwtare\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\SOIEAK")
  33. ///////////////////////////////////////////////////////////////////////////////////////
  34. //
  35. // Structures
  36. //
  37. ///////////////////////////////////////////////////////////////////////////////////////
  38. typedef struct tagSECURITYZONESETTINGS
  39. {
  40. BOOL dwFlags; // from the ZONEATTRIBUTES struct
  41. DWORD dwZoneIndex; // as defined by ZoneManager
  42. DWORD dwSecLevel; // current level (High, Medium, Low, Custom)
  43. DWORD dwPrevSecLevel;
  44. DWORD dwMinSecLevel; // current min level (High, Medium, Low, Custom)
  45. DWORD dwRecSecLevel; // current recommended level (High, Medium, Low, Custom)
  46. TCHAR szDescription[MAX_ZONE_DESCRIPTION];
  47. TCHAR szDisplayName[MAX_ZONE_PATH];
  48. HICON hicon;
  49. } SECURITYZONESETTINGS, *LPSECURITYZONESETTINGS;
  50. // structure for main security page
  51. typedef struct tagSECURITYPAGE
  52. {
  53. HWND hDlg; // handle to window
  54. LPURLZONEMANAGER pInternetZoneManager; // pointer to InternetZoneManager
  55. IInternetSecurityManager *pInternetSecurityManager; // pointer to InternetSecurityManager
  56. HIMAGELIST himl; // imagelist for Zones combobox
  57. HWND hwndZones; // zones combo box hwnd
  58. LPSECURITYZONESETTINGS pszs; // current settings for displayed zone
  59. INT iZoneSel; // selected zone (as defined by ComboBox)
  60. DWORD dwZoneCount; // number of zones
  61. BOOL fChanged;
  62. BOOL fPendingChange; // to prevent the controls sending multiple sets (for cancel, mostly)
  63. HINSTANCE hinstUrlmon;
  64. BOOL fNoEdit; // hklm lockout of level edit
  65. BOOL fNoAddSites; // hklm lockout of addsites
  66. BOOL fNoZoneMapEdit; // hklm lockout of zone map edits
  67. HFONT hfontBolded; // special bolded font created for the zone title
  68. BOOL fForceUI; // Force every zone to show ui?
  69. BOOL fDisableAddSites; // Automatically diable add sites button?
  70. TCHAR szPageUrl[INTERNET_MAX_URL_LENGTH];
  71. } SECURITYPAGE, *LPSECURITYPAGE;
  72. // structure for Intranet Add Sites
  73. typedef struct tagADDSITESINTRANETINFO {
  74. HWND hDlg; // handle to window
  75. BOOL fUseIntranet; // Use local defined intranet addresses (in reg)
  76. BOOL fUseProxyExclusion; // Use proxy exclusion list
  77. BOOL fUseUNC; // Include UNC in intranet
  78. LPSECURITYPAGE pSec;
  79. } ADDSITESINTRANETINFO, *LPADDSITESINTRANETINFO;
  80. // structure for Add Sites
  81. typedef struct tagADDSITESINFO {
  82. HWND hDlg; // handle to window
  83. BOOL fRequireServerVerification; // Require Server Verification on sites in zone
  84. HWND hwndWebSites; // handle to list
  85. HWND hwndAdd; // handle to edit
  86. TCHAR szWebSite[MAX_ZONE_PATH]; // text in edit control
  87. BOOL fRSVOld;
  88. LPSECURITYPAGE pSec;
  89. } ADDSITESINFO, *LPADDSITESINFO;
  90. // structure for Custom Settings
  91. typedef struct tagCUSTOMSETTINGSINFO {
  92. HWND hDlg; // handle to window
  93. HWND hwndTree;
  94. LPSECURITYPAGE pSec;
  95. HWND hwndCombo;
  96. INT iLevelSel;
  97. IRegTreeOptions *pTO;
  98. BOOL fUseHKLM; // get/set settings from HKLM
  99. DWORD dwJavaPolicy; // Java policy selected
  100. BOOL fChanged;
  101. } CUSTOMSETTINGSINFO, *LPCUSTOMSETTINGSINFO;
  102. BOOL SecurityEnableControls(LPSECURITYPAGE pSec, BOOL fSetFocus);
  103. BOOL SecurityDlgApplyNow(LPSECURITYPAGE pSec, BOOL bPrompt);
  104. void SiteAlreadyInZoneMessage(HWND hwnd, DWORD dwZone);
  105. // global variables
  106. extern DWORD g_dwtlsSecInitFlags;
  107. extern BOOL g_fSecurityChanged; // flag indicating that Active Security has changed.
  108. //////////////////////////////////////////////////////////////////////////////
  109. //
  110. // Main Security Page Helper Functions
  111. //
  112. //////////////////////////////////////////////////////////////////////////////
  113. #define NUM_TEMPLATE_LEVELS 4
  114. TCHAR g_szLevel[3][64];
  115. TCHAR LEVEL_DESCRIPTION0[300];
  116. TCHAR LEVEL_DESCRIPTION1[300];
  117. TCHAR LEVEL_DESCRIPTION2[300];
  118. TCHAR LEVEL_DESCRIPTION3[300];
  119. LPTSTR LEVEL_DESCRIPTION[NUM_TEMPLATE_LEVELS] = {
  120. LEVEL_DESCRIPTION0,
  121. LEVEL_DESCRIPTION1,
  122. LEVEL_DESCRIPTION2,
  123. LEVEL_DESCRIPTION3
  124. };
  125. TCHAR CUSTOM_DESCRIPTION[300];
  126. TCHAR LEVEL_NAME0[30];
  127. TCHAR LEVEL_NAME1[30];
  128. TCHAR LEVEL_NAME2[30];
  129. TCHAR LEVEL_NAME3[30];
  130. LPTSTR LEVEL_NAME[NUM_TEMPLATE_LEVELS] = {
  131. LEVEL_NAME0,
  132. LEVEL_NAME1,
  133. LEVEL_NAME2,
  134. LEVEL_NAME3
  135. };
  136. TCHAR CUSTOM_NAME[30];
  137. // Some accessibility related prototypes.
  138. // Our override of the slider window proc.
  139. LRESULT CALLBACK SliderSubWndProc (HWND hwndSlider, UINT uMsg, WPARAM wParam, LPARAM lParam, WPARAM uID, ULONG_PTR dwRefData );
  140. extern BOOL g_fAttemptedOleAccLoad ;
  141. extern HMODULE g_hOleAcc;
  142. // Can't find value for WM_GETOBJECT in the headers. Need to figure out the right header to include
  143. // here.
  144. #ifndef WM_GETOBJECT
  145. #define WM_GETOBJECT 0x03d
  146. #endif
  147. // Prototype for CreateStdAccessibleProxy.
  148. // A and W versions are available - pClassName can be ANSI or UNICODE
  149. // string. This is a TCHAR-style prototype, but you can do a A or W
  150. // specific one if desired.
  151. typedef HRESULT (WINAPI *PFNCREATESTDACCESSIBLEPROXY) (
  152. HWND hWnd,
  153. LPTSTR pClassName,
  154. LONG idObject,
  155. REFIID riid,
  156. void ** ppvObject
  157. );
  158. /*
  159. * Arguments:
  160. *
  161. * HWND hWnd
  162. * Handle of window to return IAccessible for.
  163. *
  164. * LPTSTR pClassName
  165. * Class name indicating underlying class of the window. For
  166. * example, if "LISTBOX" is used here, the returned object will
  167. * behave appropriately for a listbox, and will expect the given
  168. * hWnd to support listbox messages and styles. This argument
  169. * nearly always reflects the window class from which the control
  170. * is derived.
  171. *
  172. * LONG idObject
  173. * Always OBJID_CLIENT
  174. *
  175. * REFIID riid
  176. * Always IID_IAccessible
  177. *
  178. * void ** ppvObject
  179. * Out pointer used to return an IAccessible to a newly-created
  180. * object which represents the control hWnd as though it were of
  181. * window class pClassName.
  182. *
  183. * If successful,
  184. * returns S_OK, *ppvObject != NULL;
  185. * otherwise returns error HRESULT.
  186. *
  187. *
  188. */
  189. // Same for LresultFromObject...
  190. typedef LRESULT (WINAPI *PFNLRESULTFROMOBJECT)(
  191. REFIID riid,
  192. WPARAM wParam,
  193. LPUNKNOWN punk
  194. );
  195. PRIVATE PFNCREATESTDACCESSIBLEPROXY s_pfnCreateStdAccessibleProxy = NULL;
  196. PRIVATE PFNLRESULTFROMOBJECT s_pfnLresultFromObject = NULL;
  197. // Simple accessibility wrapper class which returns the right string values
  198. class CSecurityAccessibleWrapper: public CAccessibleWrapper
  199. {
  200. // Want to remember the hwnd of the trackbar...
  201. HWND m_hWnd;
  202. public:
  203. CSecurityAccessibleWrapper( HWND hWnd, IAccessible * pAcc );
  204. ~CSecurityAccessibleWrapper();
  205. STDMETHODIMP get_accValue(VARIANT varChild, BSTR* pszValue);
  206. };
  207. // Ctor - pass through the IAccessible we're wrapping to the
  208. // CAccessibleWrapper base class; also remember the trackbar hwnd.
  209. CSecurityAccessibleWrapper::CSecurityAccessibleWrapper( HWND hWnd, IAccessible * pAcc )
  210. : CAccessibleWrapper( pAcc ),
  211. m_hWnd( hWnd )
  212. {
  213. // Do nothing
  214. }
  215. // Nothing to do here - but if we do need to do cleanup, this is the
  216. // place for it.
  217. CSecurityAccessibleWrapper::~CSecurityAccessibleWrapper()
  218. {
  219. // Do nothing
  220. }
  221. // Overridden get_accValue method...
  222. STDMETHODIMP CSecurityAccessibleWrapper::get_accValue(VARIANT varChild, BSTR* pszValue)
  223. {
  224. // varChild.lVal specifies which sub-part of the component
  225. // is being queried.
  226. // CHILDID_SELF (0) specifies the overall component - other
  227. // non-0 values specify a child.
  228. // In a trackbar, CHILDID_SELF refers to the overall trackbar
  229. // (which is what we want), whereas other values refer to the
  230. // sub-components - the actual slider 'thumb', and the 'page
  231. // up/page down' areas to the left/right of it.
  232. if( varChild.vt == VT_I4 && varChild.lVal == CHILDID_SELF )
  233. {
  234. // Get the scrollbar value...
  235. int iPos = (int)SendMessage( m_hWnd, TBM_GETPOS , 0, 0 );
  236. // Check that it's in range...
  237. // (It's possible that we may get this request after the
  238. // trackbar has been created, bu before we've set it to
  239. // a meaningful value.)
  240. if( iPos < 0 || iPos >= NUM_TEMPLATE_LEVELS )
  241. {
  242. TCHAR rgchUndefined[40];
  243. int cch = MLLoadString(IDS_TEMPLATE_NAME_UNDEFINED, rgchUndefined, ARRAYSIZE(rgchUndefined));
  244. if (cch != 0)
  245. {
  246. *pszValue = SysAllocString(rgchUndefined);
  247. }
  248. else
  249. {
  250. // Load String failed, for some reason.
  251. return HRESULT_FROM_WIN32(GetLastError());
  252. }
  253. }
  254. else
  255. {
  256. *pszValue = SysAllocString( LEVEL_NAME[iPos]);
  257. }
  258. // All done!
  259. return S_OK;
  260. }
  261. else
  262. {
  263. // Pass requests about the sub-components to the
  264. // base class (which will forward to the 'original'
  265. // IAccessible for us).
  266. return CAccessibleWrapper::get_accValue(varChild, pszValue);
  267. }
  268. }
  269. // Converting the Security Level DWORD identitifiers to slider levels, and vice versa
  270. int SecLevelToSliderPos(DWORD dwLevel)
  271. {
  272. switch(dwLevel)
  273. {
  274. case URLTEMPLATE_LOW:
  275. return 3;
  276. case URLTEMPLATE_MEDLOW:
  277. return 2;
  278. case URLTEMPLATE_MEDIUM:
  279. return 1;
  280. case URLTEMPLATE_HIGH:
  281. return 0;
  282. case URLTEMPLATE_CUSTOM:
  283. return -1;
  284. default:
  285. return -2;
  286. }
  287. }
  288. DWORD SliderPosToSecLevel(int iPos)
  289. {
  290. switch(iPos)
  291. {
  292. case 3:
  293. return URLTEMPLATE_LOW;
  294. case 2:
  295. return URLTEMPLATE_MEDLOW;
  296. case 1:
  297. return URLTEMPLATE_MEDIUM;
  298. case 0:
  299. return URLTEMPLATE_HIGH;
  300. default:
  301. return URLTEMPLATE_CUSTOM;
  302. }
  303. }
  304. int ZoneIndexToGuiIndex(DWORD dwZoneIndex)
  305. // Product testing asked for the zones in a specific order in the list box;
  306. // This function returns the desired gui position for a given zone
  307. // Unrecognized zones are added to the front
  308. {
  309. int iGuiIndex = -1;
  310. switch(dwZoneIndex)
  311. {
  312. // Intranet: 2nd spot
  313. case 1:
  314. iGuiIndex = 1;
  315. break;
  316. // Internet: 1st spot
  317. case 3:
  318. iGuiIndex = 0;
  319. break;
  320. // Trusted Sites: 3rd Spot
  321. case 2:
  322. iGuiIndex = 2;
  323. break;
  324. // Restricted Sites: 4th Spot
  325. case 4:
  326. iGuiIndex = 3;
  327. break;
  328. // unknown zone
  329. default:
  330. iGuiIndex = -1;
  331. break;
  332. }
  333. return iGuiIndex;
  334. }
  335. // Initialize the global variables (to be destroyed at WM_DESTROY)
  336. // pSec, Urlmon, pSec->pInternetZoneManager, pSec->hIml
  337. // and set up the proper relationships among them
  338. BOOL SecurityInitGlobals(LPSECURITYPAGE * ppSec, HWND hDlg, SECURITYINITFLAGS * psif)
  339. {
  340. DWORD cxIcon;
  341. DWORD cyIcon;
  342. LPSECURITYPAGE pSec = NULL;
  343. *ppSec = (LPSECURITYPAGE)LocalAlloc(LPTR, sizeof(SECURITYPAGE));
  344. pSec = *ppSec;
  345. if (!pSec)
  346. {
  347. return FALSE; // no memory?
  348. }
  349. // make sure Urlmon stays around until we're done with it.
  350. pSec->hinstUrlmon = LoadLibrary(TEXT("URLMON.DLL"));
  351. if(pSec->hinstUrlmon == NULL)
  352. {
  353. return FALSE; // no urlmon?
  354. }
  355. // Get the zone manager
  356. if (FAILED(CoInternetCreateZoneManager(NULL, &(pSec->pInternetZoneManager),0)))
  357. {
  358. return FALSE; // no zone manager?
  359. }
  360. // get our zones hwnd
  361. if (hDlg)
  362. {
  363. pSec->hwndZones = GetDlgItem(hDlg, IDC_LIST_ZONE);
  364. if(! pSec->hwndZones)
  365. {
  366. ASSERT(FALSE);
  367. return FALSE; // no list box?
  368. }
  369. }
  370. // Get the internet secrity manager (for telling if a zone is empty,
  371. // and deciphering the current URL
  372. if(FAILED(CoInternetCreateSecurityManager(NULL, &(pSec->pInternetSecurityManager), 0)))
  373. pSec->pInternetSecurityManager = NULL;
  374. // Store the URL for use by the Add Sites sub-dialog
  375. StrCpyN(pSec->szPageUrl, g_szCurrentURL, ARRAYSIZE(pSec->szPageUrl));
  376. // tell dialog where to get info
  377. if (hDlg)
  378. {
  379. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pSec);
  380. }
  381. // save the handle to the page
  382. pSec->hDlg = hDlg;
  383. pSec->fPendingChange = FALSE;
  384. // set dialog options: force ui and disable add sites
  385. if(psif)
  386. {
  387. pSec->fForceUI = psif->fForceUI;
  388. pSec->fDisableAddSites = psif->fDisableAddSites;
  389. }
  390. // create an imagelist for the ListBox
  391. cxIcon = GetSystemMetrics(SM_CXICON);
  392. cyIcon = GetSystemMetrics(SM_CYICON);
  393. #ifndef UNIX
  394. UINT flags = ILC_COLOR32|ILC_MASK;
  395. if(IS_WINDOW_RTL_MIRRORED(hDlg))
  396. {
  397. flags |= ILC_MIRROR;
  398. }
  399. pSec->himl = ImageList_Create(cxIcon, cyIcon, flags, pSec->dwZoneCount, 0);
  400. #else
  401. pSec->himl = ImageList_Create(cxIcon, cyIcon, ILC_COLOR|ILC_MASK, pSec->dwZoneCount, 0);
  402. #endif
  403. if(! pSec->himl)
  404. {
  405. return FALSE; // Image list not created
  406. }
  407. if (hDlg)
  408. {
  409. SendMessage(pSec->hwndZones, LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)pSec->himl);
  410. }
  411. return TRUE;
  412. }
  413. void FreePszs(SECURITYZONESETTINGS* pszs)
  414. {
  415. if (pszs->hicon)
  416. DestroyIcon(pszs->hicon);
  417. LocalFree((HLOCAL)pszs);
  418. }
  419. void SecurityFreeGlobals(SECURITYPAGE* pSec)
  420. {
  421. if(pSec->hwndZones)
  422. {
  423. for (int iIndex = (int)SendMessage(pSec->hwndZones, LVM_GETITEMCOUNT, 0, 0) - 1;
  424. iIndex >= 0; iIndex--)
  425. {
  426. LV_ITEM lvItem;
  427. // get security zone settings object for this item and release it
  428. lvItem.mask = LVIF_PARAM;
  429. lvItem.iItem = iIndex;
  430. lvItem.iSubItem = 0;
  431. if (SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem) == TRUE)
  432. {
  433. LPSECURITYZONESETTINGS pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  434. if (pszs)
  435. {
  436. FreePszs(pszs);
  437. pszs = NULL;
  438. }
  439. }
  440. }
  441. }
  442. if(pSec->pInternetZoneManager)
  443. pSec->pInternetZoneManager->Release();
  444. if(pSec->pInternetSecurityManager)
  445. pSec->pInternetSecurityManager->Release();
  446. if(pSec->himl)
  447. ImageList_Destroy(pSec->himl);
  448. if(pSec->hfontBolded)
  449. DeleteObject(pSec->hfontBolded);
  450. // ok, we're done with URLMON
  451. if(pSec->hinstUrlmon)
  452. FreeLibrary(pSec->hinstUrlmon);
  453. LocalFree(pSec);
  454. }
  455. // Set up the variables in pSec about whether the zone settings can be editted
  456. void SecuritySetEdit(LPSECURITYPAGE pSec)
  457. {
  458. // if these calls fail then we'll use the default of zero which means no lockout
  459. DWORD cb;
  460. cb = SIZEOF(pSec->fNoEdit);
  461. SHGetValue(HKEY_LOCAL_MACHINE, REGSTR_PATH_SECURITY_LOCKOUT, REGSTR_VAL_OPTIONS_EDIT,
  462. NULL, &(pSec->fNoEdit), &cb);
  463. // also allow g_restrict to restrict changing settings
  464. pSec->fNoEdit += g_restrict.fSecChangeSettings;
  465. SHGetValue(HKEY_LOCAL_MACHINE, REGSTR_PATH_SECURITY_LOCKOUT, REGSTR_VAL_OPTIONS_EDIT,
  466. NULL, &(pSec->fNoAddSites), &cb);
  467. cb = SIZEOF(pSec->fNoZoneMapEdit);
  468. SHGetValue(HKEY_LOCAL_MACHINE, REGSTR_PATH_SECURITY_LOCKOUT, REGSTR_VAL_ZONES_MAP_EDIT,
  469. NULL, &(pSec->fNoZoneMapEdit), &cb);
  470. // also allow the g_restrict to restrict edit
  471. pSec->fNoAddSites += g_restrict.fSecAddSites;
  472. }
  473. // Fill a zone with information from the zone manager and add it to the
  474. // ordered list going to the listbox
  475. // REturn values:
  476. // S_OK indicates success
  477. // S_FALSE indicates a good state, but the zone was not added (example: flag ZAFLAGS_NO_UI)
  478. // E_OUTOFMEMORY
  479. // E_FAIL - other failure
  480. HRESULT SecurityInitZone(DWORD dwIndex, LPSECURITYPAGE pSec, DWORD dwZoneEnumerator,
  481. LV_ITEM * plviZones, BOOL * pfSpotTaken)
  482. {
  483. DWORD dwZone;
  484. ZONEATTRIBUTES za = {0};
  485. HICON hiconSmall = NULL;
  486. HICON hiconLarge = NULL;
  487. LPSECURITYZONESETTINGS pszs;
  488. WORD iIcon=0;
  489. LPWSTR psz;
  490. TCHAR szIconPath[MAX_PATH];
  491. int iSpot;
  492. LV_ITEM * plvItem;
  493. HRESULT hr = 0;
  494. // get the zone attributes for this zone
  495. za.cbSize = sizeof(ZONEATTRIBUTES);
  496. pSec->pInternetZoneManager->GetZoneAt(dwZoneEnumerator, dwIndex, &dwZone);
  497. hr = pSec->pInternetZoneManager->GetZoneAttributes(dwZone, &za);
  498. if(FAILED(hr))
  499. {
  500. return S_FALSE;
  501. }
  502. // if no ui, then ignore
  503. if ((za.dwFlags & ZAFLAGS_NO_UI) && !pSec->fForceUI)
  504. {
  505. return S_FALSE;
  506. }
  507. // create a structure for zone settings
  508. pszs = (LPSECURITYZONESETTINGS)LocalAlloc(LPTR, sizeof(*pszs));
  509. if (!pszs)
  510. {
  511. return E_OUTOFMEMORY;
  512. }
  513. // store settings for later use
  514. pszs->dwFlags = za.dwFlags;
  515. pszs->dwZoneIndex = dwZone;
  516. pszs->dwSecLevel = za.dwTemplateCurrentLevel;
  517. pszs->dwMinSecLevel = za.dwTemplateMinLevel;
  518. pszs->dwRecSecLevel = za.dwTemplateRecommended;
  519. StrCpyN(pszs->szDescription, za.szDescription, ARRAYSIZE(pszs->szDescription));
  520. StrCpyN(pszs->szDisplayName, za.szDisplayName, ARRAYSIZE(pszs->szDisplayName));
  521. // load the icon
  522. psz = za.szIconPath;
  523. if (*psz)
  524. {
  525. // search for the '#'
  526. while ((psz[0] != WIDETEXT('#')) && (psz[0] != WIDETEXT('\0')))
  527. psz++;
  528. // if we found it, then we have the foo.dll#00001200 format
  529. if (psz[0] == WIDETEXT('#'))
  530. {
  531. psz[0] = WIDETEXT('\0');
  532. StrCpyN(szIconPath, za.szIconPath, ARRAYSIZE(szIconPath));
  533. iIcon = (WORD)StrToIntW(psz+1);
  534. CHAR szPath[MAX_PATH];
  535. SHUnicodeToAnsi(szIconPath, szPath, ARRAYSIZE(szPath));
  536. ExtractIconExA(szPath,(UINT)(-1*iIcon), &hiconLarge, &hiconSmall, 1);
  537. }
  538. else
  539. {
  540. hiconLarge = (HICON)ExtractAssociatedIcon(ghInstance, szIconPath, (LPWORD)&iIcon);
  541. }
  542. }
  543. // no icons?! well, just use the generic icon
  544. if (!hiconSmall && !hiconLarge)
  545. {
  546. hiconLarge = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_ZONE));
  547. if(! hiconLarge)
  548. {
  549. LocalFree((HLOCAL)pszs);
  550. return S_FALSE; // no icon found for this zone, not even the generic one
  551. }
  552. }
  553. // we want to save the Large icon if possible for use in the subdialogs
  554. pszs->hicon = hiconLarge ? hiconLarge : hiconSmall;
  555. if (plviZones && pfSpotTaken)
  556. {
  557. // Find the proper index for the zone in the listbox (there is a user-preferred order)
  558. iSpot = ZoneIndexToGuiIndex(dwIndex);
  559. if(iSpot == -1)
  560. {
  561. // if not a recognized zone, add it to the end of the list
  562. iSpot = pSec->dwZoneCount - 1;
  563. }
  564. // Make sure there are no collisisons
  565. while(iSpot >= 0 && pfSpotTaken[iSpot] == TRUE)
  566. {
  567. iSpot--;
  568. }
  569. // Don't go past beginning of array
  570. if(iSpot < 0)
  571. {
  572. // It can be proven that it is impossible to get here, unless there is
  573. // something wrong with the function ZoneIndexToGuiIndex
  574. ASSERT(FALSE);
  575. LocalFree((HLOCAL)pszs);
  576. if(hiconSmall)
  577. DestroyIcon(hiconSmall);
  578. if(hiconLarge)
  579. DestroyIcon(hiconLarge);
  580. return E_FAIL;
  581. }
  582. plvItem = &(plviZones[iSpot]);
  583. pfSpotTaken[iSpot] = TRUE;
  584. // init the List Box item and save it for later addition
  585. plvItem->mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  586. plvItem->iItem = iSpot;
  587. plvItem->iSubItem = 0;
  588. // large icons prefered for the icon view (if switch back to report view, prefer small icons)
  589. plvItem->iImage = ImageList_AddIcon(pSec->himl, hiconLarge ? hiconLarge : hiconSmall);
  590. plvItem->pszText = new TCHAR[MAX_PATH];
  591. if(! plvItem->pszText)
  592. {
  593. LocalFree((HLOCAL)pszs);
  594. if(hiconSmall)
  595. DestroyIcon(hiconSmall);
  596. if(hiconLarge)
  597. DestroyIcon(hiconLarge);
  598. return E_OUTOFMEMORY;
  599. }
  600. MLLoadString( IDS_ZONENAME_LOCAL + dwIndex, plvItem->pszText, MAX_PATH);
  601. plvItem->lParam = (LPARAM)pszs; // save the zone settings here
  602. }
  603. else
  604. {
  605. pSec->pszs = pszs;
  606. }
  607. // if we created a small icon, destroy it, since the system does not save the handle
  608. // when it is added to the imagelist (see ImageList_AddIcon in VC help)
  609. // Keep it around if we had to use it in place of the large icon
  610. if (hiconSmall && hiconLarge)
  611. DestroyIcon(hiconSmall);
  612. return S_OK;
  613. }
  614. // Find the current zone from, in order of preference,
  615. // Current URL
  616. // Parameter passed in through dwZone
  617. // Default of internet
  618. void SecurityFindCurrentZone(LPSECURITYPAGE pSec, SECURITYINITFLAGS * psif)
  619. {
  620. INT_PTR iItem;
  621. DWORD dwZone=0;
  622. HRESULT hr = E_FAIL;
  623. // Check for zone selection in psif
  624. if(psif)
  625. {
  626. dwZone = psif->dwZone;
  627. hr = S_OK;
  628. }
  629. // check for current url, and if found, make it's zone the current (overwriting any request from
  630. // psif)
  631. if (g_szCurrentURL[0] && (pSec->pInternetSecurityManager != NULL))
  632. {
  633. LPWSTR pwsz;
  634. #ifndef UNICODE
  635. WCHAR wszCurrentURL[MAX_URL_STRING];
  636. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, g_szCurrentURL, -1, wszCurrentURL, ARRAYSIZE(wszCurrentURL));
  637. pwsz = wszCurrentURL;
  638. #else
  639. pwsz = g_szCurrentURL;
  640. #endif
  641. hr = pSec->pInternetSecurityManager->MapUrlToZone(pwsz, (LPDWORD)&dwZone, 0);
  642. }
  643. // If there is an active zone, then dwZone now holds the zone's identifier
  644. // if there is no active zone, check to see if there was a zone requested in dwZone
  645. iItem = -1;
  646. if (SUCCEEDED(hr)) // then we have a zone to display
  647. {
  648. ZONEATTRIBUTES za = {0};
  649. LPTSTR pszText;
  650. LV_FINDINFO lvfiName;
  651. za.cbSize = (ULONG) sizeof(ZONEATTRIBUTES);
  652. if(pSec->pInternetZoneManager->GetZoneAttributes(dwZone, &za) != E_FAIL)
  653. {
  654. #ifdef UNICODE
  655. pszText = za.szDisplayName;
  656. #else
  657. CHAR szDisplayName[MAX_ZONE_PATH];
  658. WideCharToMultiByte(CP_ACP, 0, za.szDisplayName, -1, szDisplayName, ARRAYSIZE(szDisplayName), NULL, NULL);
  659. pszText = szDisplayName;
  660. #endif // UNICODE
  661. // Create a find info structure to find the index of the Zone
  662. lvfiName.flags = LVFI_STRING;
  663. lvfiName.psz = pszText;
  664. iItem = SendMessage(pSec->hwndZones, LVM_FINDITEM, (WPARAM)-1, (LPARAM)&lvfiName);
  665. }
  666. }
  667. if (iItem < 0)
  668. {
  669. iItem = 0;
  670. // 0 is the the index (in the listbox) of the "Internet" zone, which we want to come up by default
  671. }
  672. // Sundown: typecast OK since zone values restricted
  673. pSec->iZoneSel = (int) iItem;
  674. }
  675. // To make the slider control accessbile we have to subclass it and over-ride
  676. // the accessiblity object
  677. void SecurityInitSlider(LPSECURITYPAGE pSec)
  678. {
  679. HWND hwndSlider = GetDlgItem(pSec->hDlg, IDC_SLIDER);
  680. ASSERT(hwndSlider != NULL);
  681. // Sub-class the control
  682. BOOL fSucceeded = SetWindowSubclass(hwndSlider, SliderSubWndProc, 0, NULL);
  683. // Shouldn't fail normally. If we fail we will just fall through and use the
  684. // base slider control.
  685. ASSERT(fSucceeded);
  686. // Initialize the slider control (set number of levels, and frequency one tick per level)
  687. SendDlgItemMessage(pSec->hDlg, IDC_SLIDER, TBM_SETRANGE, (WPARAM) (BOOL) FALSE, (LPARAM) MAKELONG(0, NUM_TEMPLATE_LEVELS - 1));
  688. SendDlgItemMessage(pSec->hDlg, IDC_SLIDER, TBM_SETTICFREQ, (WPARAM) 1, (LPARAM) 0);
  689. }
  690. void SecurityInitControls(LPSECURITYPAGE pSec)
  691. {
  692. LV_COLUMN lvCasey;
  693. LV_ITEM lvItem;
  694. // select the item in the listbox
  695. lvItem.mask = LVIF_STATE;
  696. lvItem.stateMask = LVIS_SELECTED;
  697. lvItem.state = LVIS_SELECTED;
  698. SendMessage(pSec->hwndZones, LVM_SETITEMSTATE, (WPARAM)pSec->iZoneSel, (LPARAM)&lvItem);
  699. // get the zone settings for the selected item
  700. lvItem.mask = LVIF_PARAM;
  701. lvItem.iItem = pSec->iZoneSel;
  702. lvItem.iSubItem = 0;
  703. SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem);
  704. pSec->pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  705. // Initialize the local strings to carry the Level Descriptions
  706. MLLoadString(IDS_TEMPLATE_DESC_HI, LEVEL_DESCRIPTION0, ARRAYSIZE(LEVEL_DESCRIPTION0));
  707. MLLoadString(IDS_TEMPLATE_DESC_MED, LEVEL_DESCRIPTION1, ARRAYSIZE(LEVEL_DESCRIPTION1));
  708. MLLoadString(IDS_TEMPLATE_DESC_MEDLOW, LEVEL_DESCRIPTION2, ARRAYSIZE(LEVEL_DESCRIPTION2));
  709. MLLoadString(IDS_TEMPLATE_DESC_LOW, LEVEL_DESCRIPTION3, ARRAYSIZE(LEVEL_DESCRIPTION3));
  710. MLLoadString(IDS_TEMPLATE_DESC_CUSTOM, CUSTOM_DESCRIPTION, ARRAYSIZE(CUSTOM_DESCRIPTION));
  711. MLLoadString(IDS_TEMPLATE_NAME_HI, LEVEL_NAME0, ARRAYSIZE(LEVEL_NAME0));
  712. MLLoadString(IDS_TEMPLATE_NAME_MED, LEVEL_NAME1, ARRAYSIZE(LEVEL_NAME1));
  713. MLLoadString(IDS_TEMPLATE_NAME_MEDLOW, LEVEL_NAME2, ARRAYSIZE(LEVEL_NAME2));
  714. MLLoadString(IDS_TEMPLATE_NAME_LOW, LEVEL_NAME3, ARRAYSIZE(LEVEL_NAME3));
  715. MLLoadString(IDS_TEMPLATE_NAME_CUSTOM, CUSTOM_NAME, ARRAYSIZE(CUSTOM_NAME));
  716. // Initialize text boxes and icons for the current zone
  717. WCHAR wszBuffer[ MAX_PATH*2];
  718. MLLoadString( IDS_ZONEDESC_LOCAL + pSec->pszs->dwZoneIndex, wszBuffer, ARRAYSIZE(wszBuffer));
  719. SetDlgItemText(pSec->hDlg, IDC_ZONE_DESCRIPTION, wszBuffer);
  720. MLLoadString( IDS_ZONENAME_LOCAL + pSec->pszs->dwZoneIndex, wszBuffer, ARRAYSIZE(wszBuffer));
  721. SetDlgItemText(pSec->hDlg, IDC_ZONELABEL, wszBuffer);
  722. SendDlgItemMessage(pSec->hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pSec->pszs->hicon);
  723. // Initialize the slider control
  724. SecurityInitSlider(pSec);
  725. // Initialize the list view (add column 0 for icon and text, and autosize it)
  726. lvCasey.mask = 0;
  727. SendDlgItemMessage(pSec->hDlg, IDC_LIST_ZONE, LVM_INSERTCOLUMN, (WPARAM) 0, (LPARAM) &lvCasey);
  728. SendDlgItemMessage(pSec->hDlg, IDC_LIST_ZONE, LVM_SETCOLUMNWIDTH, (WPARAM) 0, (LPARAM) MAKELPARAM(LVSCW_AUTOSIZE, 0));
  729. // Set the font of the name to the bold font
  730. pSec->hfontBolded = NULL;
  731. HFONT hfontOrig = (HFONT) SendDlgItemMessage(pSec->hDlg, IDC_STATIC_EMPTY, WM_GETFONT, (WPARAM) 0, (LPARAM) 0);
  732. if(hfontOrig == NULL)
  733. hfontOrig = (HFONT) GetStockObject(SYSTEM_FONT);
  734. // set the zone name and level font to bolded
  735. if(hfontOrig)
  736. {
  737. LOGFONT lfData;
  738. if(GetObject(hfontOrig, SIZEOF(lfData), &lfData) != 0)
  739. {
  740. // The distance from 400 (normal) to 700 (bold)
  741. lfData.lfWeight += 300;
  742. if(lfData.lfWeight > 1000)
  743. lfData.lfWeight = 1000;
  744. pSec->hfontBolded = CreateFontIndirect(&lfData);
  745. if(pSec->hfontBolded)
  746. {
  747. // the zone level and zone name text boxes should have the same font, so this is okat
  748. SendDlgItemMessage(pSec->hDlg, IDC_ZONELABEL, WM_SETFONT, (WPARAM) pSec->hfontBolded, (LPARAM) MAKELPARAM(FALSE, 0));
  749. SendDlgItemMessage(pSec->hDlg, IDC_LEVEL_NAME, WM_SETFONT, (WPARAM) pSec->hfontBolded, (LPARAM) MAKELPARAM(FALSE, 0));
  750. }
  751. }
  752. }
  753. /*
  754. {
  755. // calculate the postions of the static text boxes for the "The current level is:" "<bold>(Level)</bold>" message
  756. TCHAR * pszText = NULL;
  757. LONG lLength = 30;
  758. HDC hdc = NULL;
  759. SIZE size;
  760. RECT rect;
  761. LONG lNameLeftPos = 0;
  762. // Get the text from the "The current level is" box.
  763. lLength = SendDlgItemMessage(pSec->hDlg, IDC_SEC_STATIC_CURRENT_LEVEL, WM_GETTEXTLENGTH,
  764. (WPARAM) 0, (LPARAM) 0);
  765. pszText = new TCHAR[lLength + 1];
  766. if(!pszText)
  767. goto Exit; // E_OUTOFMEMORY
  768. SendDlgItemMessage(pSec->hDlg, IDC_SEC_STATIC_CURRENT_LEVEL, WM_GETTEXT, (WPARAM) lLength,
  769. (LPARAM) pszText);
  770. // get the device context
  771. hdc = GetDC(GetDlgItem(pSec->hDlg, IDC_SEC_STATIC_CURRENT_LEVEL));
  772. if(! hdc)
  773. goto Exit;
  774. // get the length of the text from the device context; assumes the proper font is already in
  775. if(GetTextExtentPoint32(hdc, pszText, lLength, &size) == 0)
  776. goto Exit;
  777. // set the width of the "The current level is" box
  778. GetClientRect(GetDlgItem(pSec->hDlg, IDC_SEC_STATIC_CURRENT_LEVEL), &rect);
  779. rect.right = rect.left + size.cx;
  780. lNameLeftPos = rect.right;
  781. if(MoveWindow(GetDlgItem(pSec->hDlg, IDC_SEC_STATIC_CURRENT_LEVEL), rect.left, rect.top,
  782. rect.right - rect.left, rect.top - rect.bottom, FALSE) == 0)
  783. goto Exit;
  784. // set the x position of the level name box
  785. GetClientRect(GetDlgItem(pSec->hDlg, IDC_LEVEL_NAME), &rect);
  786. rect.left = lNameLeftPos;
  787. if(MoveWindow(GetDlgItem(pSec->hDlg, IDC_LEVEL_NAME), rect.left,
  788. rect.top, rect.right - rect.left, rect.top - rect.bottom, FALSE) == 0)
  789. goto Exit;
  790. Exit:
  791. if(hdc)
  792. ReleaseDC(GetDlgItem(pSec->hDlg, IDC_SEC_STATIC_CURRENT_LEVEL), hdc);
  793. if(pszText)
  794. delete pszText;
  795. }
  796. */
  797. }
  798. //
  799. // SecurityDlgInit()
  800. //
  801. // Does initalization for Security Dlg.
  802. //
  803. // History:
  804. //
  805. // 6/17/96 t-gpease remove 'gPrefs', cleaned up code
  806. // 6/20/96 t-gpease UI changes
  807. // 5/14/97 t-ashlm UI changes
  808. //
  809. // 7/02/97 t-mattp UI changes (slider, listbox)
  810. //
  811. // hDlg is the handle to the SecurityDialog window
  812. // psif holds initialization parameters. In the case of our entry point
  813. // from shdocvw (ie, double click browser zone icon, view-internetoptions-security, or right click
  814. // on desktop icon), it can be NULL
  815. BOOL SecurityDlgInit(HWND hDlg, SECURITYINITFLAGS * psif)
  816. {
  817. LPSECURITYPAGE pSec = NULL;
  818. UINT iIndex = 0;
  819. HRESULT hr = 0;
  820. DWORD dwZoneEnumerator;
  821. // Initialize globals variables (to be destroyed at WM_DESTROY)
  822. if(SecurityInitGlobals(&pSec, hDlg, psif) == FALSE)
  823. {
  824. EndDialog(hDlg, 0);
  825. return FALSE; // Initialization failed
  826. }
  827. // Get a (local) enumerator for the zones
  828. if (FAILED(pSec->pInternetZoneManager->
  829. CreateZoneEnumerator(&dwZoneEnumerator, &(pSec->dwZoneCount), 0)))
  830. {
  831. EndDialog(hDlg, 0);
  832. return FALSE; // no zone enumerator?
  833. }
  834. // Set up the variables in pSec about whether the zone settings can be editted
  835. SecuritySetEdit(pSec);
  836. // Add the Listbox items for the zones
  837. // The zones have to be added in a particular order
  838. // Array used to order zones for adding
  839. LV_ITEM * plviZones = new LV_ITEM[pSec->dwZoneCount];
  840. BOOL * pfSpotTaken = new BOOL[pSec->dwZoneCount];
  841. // bail out if there were any allocation failures
  842. if ((plviZones == NULL) || (pfSpotTaken == NULL))
  843. {
  844. if (plviZones)
  845. delete [] plviZones;
  846. if (pfSpotTaken)
  847. delete [] pfSpotTaken;
  848. pSec->pInternetZoneManager->DestroyZoneEnumerator(dwZoneEnumerator);
  849. EndDialog(hDlg, 0);
  850. return FALSE;
  851. }
  852. for(iIndex =0; iIndex < pSec->dwZoneCount; iIndex++)
  853. pfSpotTaken[iIndex] = FALSE;
  854. // propogate zone dropdown
  855. for (DWORD dwIndex=0; dwIndex < pSec->dwZoneCount; dwIndex++)
  856. {
  857. if(FAILED(SecurityInitZone(dwIndex, pSec, dwZoneEnumerator, plviZones, pfSpotTaken)))
  858. {
  859. // Delete all memory allocated for any previous zones (which have not yet been added to
  860. // the listbox)
  861. for(iIndex = 0; iIndex < pSec->dwZoneCount; iIndex++)
  862. {
  863. if(pfSpotTaken[iIndex] && (LPSECURITYZONESETTINGS) (plviZones[iIndex].lParam) != NULL)
  864. {
  865. LocalFree((LPSECURITYZONESETTINGS) (plviZones[iIndex].lParam));
  866. plviZones[iIndex].lParam = NULL;
  867. if(plviZones[iIndex].pszText)
  868. delete [] plviZones[iIndex].pszText;
  869. }
  870. }
  871. delete [] plviZones;
  872. delete [] pfSpotTaken;
  873. pSec->pInternetZoneManager->DestroyZoneEnumerator(dwZoneEnumerator);
  874. EndDialog(hDlg, 0);
  875. return FALSE;
  876. }
  877. }
  878. pSec->pInternetZoneManager->DestroyZoneEnumerator(dwZoneEnumerator);
  879. // Add all of the arrayed listitems to the listbox
  880. for(iIndex = 0; iIndex < pSec->dwZoneCount; iIndex++)
  881. {
  882. if(pfSpotTaken[iIndex])
  883. {
  884. SendMessage(pSec->hwndZones, LVM_INSERTITEM, (WPARAM)0, (LPARAM)&(plviZones[iIndex]));
  885. delete [] plviZones[iIndex].pszText;
  886. }
  887. }
  888. delete [] plviZones;
  889. delete [] pfSpotTaken;
  890. SecurityFindCurrentZone(pSec, psif);
  891. SecurityInitControls(pSec);
  892. SecurityEnableControls(pSec, FALSE);
  893. return TRUE;
  894. }
  895. void SecurityChanged()
  896. {
  897. TCHAR szClassName[32];
  898. HWND hwnd = GetTopWindow(GetDesktopWindow());
  899. //
  900. // FEATURE: These should be gotten from some place that is public
  901. // to both MSHTML and INETCPL.
  902. //
  903. while (hwnd) {
  904. GetClassName(hwnd, szClassName, ARRAYSIZE(szClassName));
  905. // notify all "browser" windows that security has changed
  906. if (!StrCmpI(szClassName, TEXT("ExploreWClass")) ||
  907. !StrCmpI(szClassName, TEXT("IEFrame")) ||
  908. !StrCmpI(szClassName, TEXT("CabinetWClass")))
  909. {
  910. // yes... post it a message..
  911. PostMessage(hwnd, CWM_GLOBALSTATECHANGE, CWMF_SECURITY, 0L );
  912. }
  913. hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
  914. }
  915. }
  916. int SecurityWarning(LPSECURITYPAGE pSec)
  917. {
  918. TCHAR szWarning[64];
  919. TCHAR szBuf[512];
  920. TCHAR szMessage[512];
  921. TCHAR szLevel[64];
  922. // Load "Warning!"
  923. MLLoadShellLangString(IDS_WARNING, szWarning, ARRAYSIZE(szWarning));
  924. // Load "It is not recommended...."
  925. MLLoadShellLangString(IDS_SECURITY_WARNING, szBuf, ARRAYSIZE(szBuf));
  926. // Load level: "High, Medium, Medium Low, Low"
  927. if (pSec->pszs->dwMinSecLevel == URLTEMPLATE_HIGH)
  928. MLLoadShellLangString(IDS_TEMPLATE_NAME_HI, szLevel, ARRAYSIZE(szLevel));
  929. else if (pSec->pszs->dwMinSecLevel == URLTEMPLATE_MEDIUM)
  930. MLLoadShellLangString(IDS_TEMPLATE_NAME_MED, szLevel, ARRAYSIZE(szLevel));
  931. else if (pSec->pszs->dwMinSecLevel == URLTEMPLATE_MEDLOW)
  932. MLLoadShellLangString(IDS_TEMPLATE_NAME_MEDLOW, szLevel, ARRAYSIZE(szLevel));
  933. else
  934. MLLoadShellLangString(IDS_TEMPLATE_NAME_LOW, szLevel, ARRAYSIZE(szLevel));
  935. wnsprintf(szMessage, ARRAYSIZE(szMessage), szBuf, szLevel);
  936. return MessageBox(pSec->hDlg,szMessage,szWarning, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
  937. }
  938. int RegWriteWarning(HWND hParent)
  939. {
  940. TCHAR szWarning[64];
  941. TCHAR szWriteWarning[128];
  942. // load "Warning!"
  943. MLLoadShellLangString(IDS_WARNING, szWarning, ARRAYSIZE(szWarning));
  944. // Load "You are about to write..."
  945. MLLoadShellLangString(IDS_WRITE_WARNING, szWriteWarning, ARRAYSIZE(szWriteWarning));
  946. return MessageBox(hParent,szWriteWarning, szWarning, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
  947. }
  948. BOOL SecurityEnableControls(LPSECURITYPAGE pSec, BOOL fSetFocus)
  949. // Duties:
  950. // Make the controls (slider, en/disabled buttons) match the data for the current zone
  951. // Make the views (Level description text) match the data for the current zone
  952. // Set focus (to slider, if enabled, else custom settings button, if enabled, else
  953. // listbox) if fSetFocus is TRUE
  954. // Note: the zone descriptions are not set here; those are handled by the code responsible
  955. // for changing zones
  956. {
  957. int iLevel = -1;
  958. if (pSec && pSec->pszs)
  959. {
  960. HWND hwndSlider = GetDlgItem(pSec->hDlg, IDC_SLIDER);
  961. iLevel = SecLevelToSliderPos(pSec->pszs->dwSecLevel);
  962. ASSERT(iLevel > -2);
  963. // Set the level of the slider to the setting for the current zone
  964. // Show or hide the slider for preset levels/custom
  965. // Set the level description text
  966. if(iLevel >= 0)
  967. {
  968. SendMessage(hwndSlider, TBM_SETPOS, (WPARAM) (BOOL) TRUE, (LPARAM) (LONG) iLevel);
  969. // Make sure the slider is visible
  970. ShowWindow(hwndSlider, SW_SHOW);
  971. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_SLIDERMOVETEXT), SW_SHOW);
  972. SetDlgItemText(pSec->hDlg, IDC_LEVEL_DESCRIPTION, LEVEL_DESCRIPTION[iLevel]);
  973. SetDlgItemText(pSec->hDlg, IDC_LEVEL_NAME, LEVEL_NAME[iLevel]);
  974. }
  975. else
  976. {
  977. // Hide the slider for custom
  978. ShowWindow(hwndSlider, SW_HIDE);
  979. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_SLIDERMOVETEXT), SW_HIDE);
  980. SetDlgItemText(pSec->hDlg, IDC_LEVEL_DESCRIPTION, CUSTOM_DESCRIPTION);
  981. SetDlgItemText(pSec->hDlg, IDC_LEVEL_NAME, CUSTOM_NAME);
  982. }
  983. // If the zone is empty, show the "zone is empty" string
  984. // Default is to not show the sting (if something goes wrong)
  985. // Empty zone not possible for internet, intranet, or local zones
  986. if((pSec->pszs->dwZoneIndex != URLZONE_INTRANET &&
  987. pSec->pszs->dwZoneIndex != URLZONE_INTERNET) &&
  988. pSec->pszs->dwZoneIndex != URLZONE_LOCAL_MACHINE &&
  989. (pSec->pInternetSecurityManager != NULL))
  990. {
  991. IEnumString * piesZones = NULL;
  992. LPOLESTR ppszDummy[1];
  993. pSec->pInternetSecurityManager->GetZoneMappings(pSec->pszs->dwZoneIndex, &piesZones, 0);
  994. // If enumerator can not get 1 item, zone is empty (not valid for internet and intranet)
  995. if(piesZones && (piesZones->Next(1, ppszDummy, NULL) == S_FALSE))
  996. {
  997. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_EMPTY), SW_SHOW);
  998. }
  999. else
  1000. {
  1001. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_EMPTY), SW_HIDE);
  1002. }
  1003. if(piesZones)
  1004. piesZones->Release();
  1005. }
  1006. else
  1007. {
  1008. ShowWindow(GetDlgItem(pSec->hDlg, IDC_STATIC_EMPTY), SW_HIDE);
  1009. }
  1010. // If we were told to set focus then move focus to the slider.
  1011. if (fSetFocus)
  1012. {
  1013. if(!pSec->fNoEdit)
  1014. {
  1015. if(iLevel >= 0)
  1016. SetFocus(hwndSlider);
  1017. else if(pSec->pszs->dwFlags & ZAFLAGS_CUSTOM_EDIT)
  1018. SetFocus(GetDlgItem(pSec->hDlg, IDC_BUTTON_SETTINGS));
  1019. else
  1020. SetFocus(GetDlgItem(pSec->hDlg, IDC_LIST_ZONE));
  1021. }
  1022. else // No focus is allowed, set focus to the list box
  1023. {
  1024. SetFocus(GetDlgItem(pSec->hDlg, IDC_LIST_ZONE));
  1025. }
  1026. }
  1027. BOOL fEdit = !(pSec->fNoEdit || (IEHardened() && !IsNTAdmin(0, NULL)));
  1028. EnableWindow(hwndSlider, (iLevel >= 0) && fEdit);
  1029. EnableWindow(GetDlgItem(pSec->hDlg, IDC_ZONE_RESET),
  1030. fEdit && (pSec->pszs->dwSecLevel != pSec->pszs->dwRecSecLevel));
  1031. EnableWindow(GetDlgItem(pSec->hDlg, IDC_BUTTON_SETTINGS),
  1032. (pSec->pszs->dwFlags & ZAFLAGS_CUSTOM_EDIT) && fEdit);
  1033. EnableWindow(GetDlgItem(pSec->hDlg, IDC_BUTTON_ADD_SITES),
  1034. (pSec->pszs->dwFlags & ZAFLAGS_ADD_SITES) && !pSec->fDisableAddSites);
  1035. return TRUE;
  1036. }
  1037. return FALSE;
  1038. }
  1039. void SecuritySetLevel(DWORD dwLevel, LPSECURITYPAGE pSec)
  1040. {
  1041. // All calls to this function are requests to change the security
  1042. // level for the current zone
  1043. // dwLevel = requested level template (URLTEMPLATE_???)
  1044. int iPos = SecLevelToSliderPos(dwLevel);
  1045. ASSERT(iPos != -2);
  1046. BOOL bCanceled = FALSE;
  1047. // Do nothing if the requested level is equal to the current level
  1048. if(dwLevel != pSec->pszs->dwSecLevel)
  1049. {
  1050. // Pop up warning box if under recommended min level and lowering security (custom N/A)
  1051. if((pSec->pszs->dwMinSecLevel > dwLevel) && (pSec->pszs->dwSecLevel > dwLevel)
  1052. && (dwLevel != URLTEMPLATE_CUSTOM))
  1053. {
  1054. if(SecurityWarning(pSec) == IDNO)
  1055. {
  1056. bCanceled = TRUE;
  1057. }
  1058. }
  1059. if(! bCanceled)
  1060. {
  1061. // Set the level
  1062. pSec->pszs->dwPrevSecLevel = pSec->pszs->dwSecLevel;
  1063. pSec->pszs->dwSecLevel = dwLevel;
  1064. ENABLEAPPLY(pSec->hDlg);
  1065. //Tell apply and ok that settings have been changed
  1066. pSec->fChanged = TRUE;
  1067. }
  1068. // Sync the controls to the new level (or back to the old if cancelled)
  1069. SecurityEnableControls(pSec, TRUE);
  1070. }
  1071. // Record that the change request has been handled
  1072. pSec->fPendingChange = FALSE;
  1073. }
  1074. //
  1075. // SecurityDlgApplyNow()
  1076. //
  1077. // Retrieves the user's choices in dlg ctls,
  1078. // and saves them through SecurityManager interfaces
  1079. // If bSaveAll is true, the data for all zones is saved,
  1080. // if false, only the current
  1081. // Return value is whether the changes were okayed
  1082. //
  1083. BOOL SecurityDlgApplyNow(LPSECURITYPAGE pSec, BOOL bSaveAll)
  1084. {
  1085. if (pSec->fChanged)
  1086. {
  1087. for (int iIndex = (int)SendMessage(pSec->hwndZones, LVM_GETITEMCOUNT, 0, 0) - 1;
  1088. iIndex >= 0; iIndex--)
  1089. {
  1090. if(!((bSaveAll) || (iIndex == pSec->iZoneSel)))
  1091. continue;
  1092. LV_ITEM lvItem = {0};
  1093. ZONEATTRIBUTES za = {0};
  1094. LPSECURITYZONESETTINGS pszs;
  1095. // get the item settings
  1096. lvItem.mask = LVIF_PARAM;
  1097. lvItem.iItem = iIndex;
  1098. lvItem.iSubItem = 0;
  1099. if(SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem))
  1100. {
  1101. pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  1102. za.cbSize = sizeof(ZONEATTRIBUTES);
  1103. pSec->pInternetZoneManager->GetZoneAttributes(pszs->dwZoneIndex, &za);
  1104. za.dwTemplateCurrentLevel = pszs->dwSecLevel;
  1105. pSec->pInternetZoneManager->SetZoneAttributes(pszs->dwZoneIndex, &za);
  1106. // Custom settings are saved on exit from the Custom Settings window
  1107. }
  1108. }
  1109. UpdateAllWindows();
  1110. SecurityChanged();
  1111. if (bSaveAll)
  1112. {
  1113. // if bSaveAll is false, that means we're saving the info for one zone, but not
  1114. // the others. This happens when you have custom settings for a particular zone
  1115. // However, other zones may have been changed to only one of the standard settings
  1116. // We need to ensure that those settings also get saved when the user clicks OK/Apply.
  1117. pSec->fChanged = FALSE;
  1118. }
  1119. }
  1120. return TRUE;
  1121. }
  1122. //
  1123. // SecurityOnCommand()
  1124. //
  1125. // Handles Security Dialog's window messages
  1126. //
  1127. // History:
  1128. //
  1129. // 6/17/96 t-gpease created
  1130. // 5/14/97 t-ashlm ui changes
  1131. //
  1132. void SecurityOnCommand(LPSECURITYPAGE pSec, UINT id, UINT nCmd)
  1133. {
  1134. switch (id)
  1135. {
  1136. case IDC_BUTTON_ADD_SITES:
  1137. {
  1138. if (pSec->pszs->dwZoneIndex == URLZONE_INTRANET && !IEHardened())
  1139. {
  1140. DialogBoxParam(MLGetHinst(), MAKEINTRESOURCE(IDD_SECURITY_INTRANET), pSec->hDlg,
  1141. SecurityAddSitesIntranetDlgProc, (LPARAM)pSec);
  1142. }
  1143. else
  1144. {
  1145. DialogBoxParam(MLGetHinst(), MAKEINTRESOURCE(IDD_SECURITY_ADD_SITES), pSec->hDlg,
  1146. SecurityAddSitesDlgProc, (LPARAM)pSec);
  1147. }
  1148. // Resynch controls (in case the "zone is empty" message needs to be updated)
  1149. SecurityEnableControls(pSec, FALSE);
  1150. }
  1151. break;
  1152. case IDC_BUTTON_SETTINGS:
  1153. {
  1154. // Note: messages to change the level from preset to custom as a result of this call
  1155. // are sent by the CustomSettings dialog
  1156. DialogBoxParam(MLGetHinst(), MAKEINTRESOURCE(IDD_SECURITY_CUSTOM_SETTINGS), pSec->hDlg,
  1157. SecurityCustomSettingsDlgProc, (LPARAM)pSec);
  1158. break;
  1159. }
  1160. case IDC_ZONE_RESET:
  1161. if(!pSec->fPendingChange && pSec->pszs->dwSecLevel != pSec->pszs->dwRecSecLevel)
  1162. {
  1163. pSec->fPendingChange = TRUE;
  1164. PostMessage(pSec->hDlg, WM_APP, (WPARAM) 0, (LPARAM) pSec->pszs->dwRecSecLevel);
  1165. }
  1166. break;
  1167. case IDOK:
  1168. SecurityDlgApplyNow(pSec, TRUE);
  1169. EndDialog(pSec->hDlg, IDOK);
  1170. break;
  1171. case IDCANCEL:
  1172. EndDialog(pSec->hDlg, IDCANCEL);
  1173. break;
  1174. case IDC_SLIDER:
  1175. {
  1176. // Get the current slider position
  1177. // Sundown: forced typecast to int, slider positions are restricted
  1178. int iPos = (int) SendDlgItemMessage(pSec->hDlg, IDC_SLIDER, TBM_GETPOS, (WPARAM) 0, (LPARAM) 0);
  1179. if(nCmd == TB_THUMBTRACK)
  1180. {
  1181. // on Mouse Move, change the level description only
  1182. SetDlgItemText(pSec->hDlg, IDC_LEVEL_DESCRIPTION, LEVEL_DESCRIPTION[iPos]);
  1183. SetDlgItemText(pSec->hDlg, IDC_LEVEL_NAME, LEVEL_NAME[iPos]);
  1184. }
  1185. else
  1186. {
  1187. // Request that the current zone's security level be set to the corresponding level
  1188. DWORD_PTR dwLevel = SliderPosToSecLevel(iPos);
  1189. if(! pSec->fPendingChange)
  1190. {
  1191. pSec->fPendingChange = TRUE;
  1192. PostMessage(pSec->hDlg, WM_APP, (WPARAM) 0, (LPARAM) dwLevel);
  1193. }
  1194. }
  1195. }
  1196. break;
  1197. case IDC_LIST_ZONE:
  1198. {
  1199. // Sundown: coercion to int-- selection is range-restricted
  1200. int iNewSelection = (int) SendMessage(pSec->hwndZones, LVM_GETNEXTITEM, (WPARAM)-1,
  1201. MAKELPARAM(LVNI_SELECTED, 0));
  1202. if ((iNewSelection != pSec->iZoneSel) && (iNewSelection != -1))
  1203. {
  1204. LV_ITEM lvItem;
  1205. lvItem.iItem = iNewSelection;
  1206. lvItem.iSubItem = 0;
  1207. lvItem.mask = LVIF_PARAM;
  1208. SendMessage(pSec->hwndZones, LVM_GETITEM, (WPARAM)0, (LPARAM)&lvItem);
  1209. pSec->pszs = (LPSECURITYZONESETTINGS)lvItem.lParam;
  1210. pSec->iZoneSel = iNewSelection;
  1211. WCHAR wszBuffer[ MAX_PATH*2];
  1212. MLLoadString( IDS_ZONEDESC_LOCAL + pSec->pszs->dwZoneIndex, wszBuffer, ARRAYSIZE(wszBuffer));
  1213. SetDlgItemText(pSec->hDlg, IDC_ZONE_DESCRIPTION, wszBuffer);
  1214. MLLoadString( IDS_ZONENAME_LOCAL + pSec->pszs->dwZoneIndex, wszBuffer, ARRAYSIZE(wszBuffer));
  1215. SetDlgItemText(pSec->hDlg, IDC_ZONELABEL, wszBuffer);
  1216. SendDlgItemMessage(pSec->hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pSec->pszs->hicon);
  1217. SecurityEnableControls(pSec, FALSE);
  1218. }
  1219. break;
  1220. }
  1221. }
  1222. } // SecurityOnCommand()
  1223. //
  1224. // SecurityDlgProc()
  1225. //
  1226. // Handles Security Dialog's window messages
  1227. //
  1228. // History:
  1229. //
  1230. // 6/17/96 t-gpease created
  1231. // 5/14/97 t-ashlm ui changes
  1232. //
  1233. INT_PTR CALLBACK SecurityDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1234. {
  1235. LPSECURITYPAGE pSec;
  1236. if (uMsg == WM_INITDIALOG)
  1237. {
  1238. // A hack forced by PropertyPage:
  1239. // PropertyPage creates this dialog in mainwnd.cpp when the dialog is entered from
  1240. // the desktop e's properties, the browser's menu view-internetoptions-security, or
  1241. // right clicking on the browser's zone icon.
  1242. // In the property page case, lParam (our only route to get initialization information
  1243. // in) is a pointer to a PROPERTYSHEETHEADER, more or less, and of entirely no use to us.
  1244. // However, when called from our exported function LaunchSecurityDialogEx, using
  1245. // CreateDialogParamWrapW, we want to pass useful information in. The only way to make sure
  1246. // we our dealing with useful information is to make the passed in pointer be to a
  1247. // structure we know and love, and hence could not possibly be pointed to by PropertyPage.
  1248. // We use a ThreadLocalStorage object, as our information reference
  1249. SECURITYINITFLAGS * psif = NULL;
  1250. if(g_dwtlsSecInitFlags != (DWORD) -1)
  1251. psif = (SECURITYINITFLAGS *) TlsGetValue(g_dwtlsSecInitFlags);
  1252. if((SECURITYINITFLAGS *) lParam != psif)
  1253. psif = NULL;
  1254. return SecurityDlgInit(hDlg, psif);
  1255. }
  1256. pSec = (LPSECURITYPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
  1257. if (!pSec)
  1258. return FALSE;
  1259. switch (uMsg)
  1260. {
  1261. case WM_COMMAND:
  1262. SecurityOnCommand(pSec, LOWORD(wParam), HIWORD(wParam));
  1263. return TRUE;
  1264. case WM_NOTIFY:
  1265. {
  1266. NMHDR *lpnm = (NMHDR *) lParam;
  1267. ASSERT(lpnm);
  1268. // List Box Messages
  1269. if(lpnm->idFrom == IDC_LIST_ZONE)
  1270. {
  1271. NM_LISTVIEW * lplvnm = (NM_LISTVIEW *) lParam;
  1272. if(lplvnm->hdr.code == LVN_ITEMCHANGED)
  1273. {
  1274. // If an item's state has changed, and it is now selected
  1275. if(((lplvnm->uChanged & LVIF_STATE) != 0) && ((lplvnm->uNewState & LVIS_SELECTED) != 0))
  1276. {
  1277. SecurityOnCommand(pSec, IDC_LIST_ZONE, LVN_ITEMCHANGED);
  1278. }
  1279. }
  1280. }
  1281. else
  1282. {
  1283. switch (lpnm->code)
  1284. {
  1285. case PSN_QUERYCANCEL:
  1286. case PSN_KILLACTIVE:
  1287. case PSN_RESET:
  1288. SetWindowLongPtr(pSec->hDlg, DWLP_MSGRESULT, FALSE);
  1289. return TRUE;
  1290. case PSN_APPLY:
  1291. // Hitting the apply button runs this code
  1292. SecurityDlgApplyNow(pSec, TRUE);
  1293. break;
  1294. }
  1295. }
  1296. }
  1297. break;
  1298. case WM_HELP: // F1
  1299. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  1300. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1301. break;
  1302. case WM_APP:
  1303. // A message needs to be posted, because the set tools sometimes send two messages
  1304. // hence we need delayed action and a pending change boolean
  1305. // lParam is the level to set for this message
  1306. // wParam is not used
  1307. SecuritySetLevel((DWORD) lParam, pSec);
  1308. break;
  1309. case WM_VSCROLL:
  1310. // Slider Messages
  1311. SecurityOnCommand(pSec, IDC_SLIDER, LOWORD(wParam));
  1312. return TRUE;
  1313. case WM_CONTEXTMENU: // right mouse click
  1314. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  1315. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1316. break;
  1317. case WM_DESTROY:
  1318. if(! pSec)
  1319. break;
  1320. SecurityFreeGlobals(pSec);
  1321. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  1322. break;
  1323. }
  1324. return FALSE;
  1325. }
  1326. // Subclassed window proc for the slider. This is used to take over the
  1327. // accessibility wrapper for the class so we can return the right zone
  1328. // string ( i.e. High, Medium, Low, etc). Just trap WM_GETOBJECT and pass
  1329. // in our override of the accessibility wrapper.
  1330. LRESULT CALLBACK SliderSubWndProc (HWND hwndSlider, UINT uMsg, WPARAM wParam, LPARAM lParam, WPARAM uID, ULONG_PTR dwRefData)
  1331. {
  1332. ASSERT(uID == 0);
  1333. ASSERT(dwRefData == 0);
  1334. switch (uMsg)
  1335. {
  1336. case WM_GETOBJECT:
  1337. if ( lParam == OBJID_CLIENT )
  1338. {
  1339. // At this point we will try to load oleacc and get the functions
  1340. // we need.
  1341. if (!g_fAttemptedOleAccLoad)
  1342. {
  1343. g_fAttemptedOleAccLoad = TRUE;
  1344. ASSERT(s_pfnCreateStdAccessibleProxy == NULL);
  1345. ASSERT(s_pfnLresultFromObject == NULL);
  1346. g_hOleAcc = LoadLibrary(TEXT("OLEACC"));
  1347. if (g_hOleAcc != NULL)
  1348. {
  1349. #ifdef UNICODE
  1350. s_pfnCreateStdAccessibleProxy = (PFNCREATESTDACCESSIBLEPROXY)
  1351. GetProcAddress(g_hOleAcc, "CreateStdAccessibleProxyW");
  1352. #else
  1353. s_pfnCreateStdAccessibleProxy = (PFNCREATESTDACCESSIBLEPROXY)
  1354. GetProcAddress(g_hOleAcc, "CreateStdAccessibleProxyA");
  1355. #endif
  1356. s_pfnLresultFromObject = (PFNLRESULTFROMOBJECT)
  1357. GetProcAddress(g_hOleAcc, "LresultFromObject");
  1358. }
  1359. if (s_pfnLresultFromObject == NULL || s_pfnCreateStdAccessibleProxy == NULL)
  1360. {
  1361. // No point holding on to Oleacc since we can't use it.
  1362. FreeLibrary(g_hOleAcc);
  1363. g_hOleAcc = NULL;
  1364. s_pfnLresultFromObject = NULL;
  1365. s_pfnCreateStdAccessibleProxy = NULL;
  1366. }
  1367. }
  1368. if (g_hOleAcc && s_pfnCreateStdAccessibleProxy && s_pfnLresultFromObject)
  1369. {
  1370. IAccessible *pAcc = NULL;
  1371. HRESULT hr;
  1372. // Create default slider proxy.
  1373. hr = s_pfnCreateStdAccessibleProxy(
  1374. hwndSlider,
  1375. TEXT("msctls_trackbar32"),
  1376. OBJID_CLIENT,
  1377. IID_IAccessible,
  1378. (void **)&pAcc
  1379. );
  1380. if (SUCCEEDED(hr) && pAcc)
  1381. {
  1382. // now wrap it up in our customized wrapper...
  1383. IAccessible * pWrapAcc = new CSecurityAccessibleWrapper( hwndSlider, pAcc );
  1384. // Release our ref to proxy (wrapper has its own addref'd ptr)...
  1385. pAcc->Release();
  1386. if (pWrapAcc != NULL)
  1387. {
  1388. // ...and return the wrapper via LresultFromObject...
  1389. LRESULT lr = s_pfnLresultFromObject( IID_IAccessible, wParam, pWrapAcc );
  1390. // Release our interface pointer - OLEACC has its own addref to the object
  1391. pWrapAcc->Release();
  1392. // Return the lresult, which 'contains' a reference to our wrapper object.
  1393. return lr;
  1394. // All done!
  1395. }
  1396. // If it didn't work, fall through to default behavior instead.
  1397. }
  1398. }
  1399. }
  1400. break;
  1401. case WM_DESTROY:
  1402. RemoveWindowSubclass(hwndSlider, SliderSubWndProc, uID);
  1403. break;
  1404. } /* end switch */
  1405. return DefSubclassProc(hwndSlider, uMsg, wParam, lParam);
  1406. }
  1407. // In Urlmon.dll
  1408. HRESULT __stdcall GetAddSitesFileUrl(LPWSTR /* [in, out] */ pszUrl);
  1409. HRESULT _GetAddSitesDisplayUrl(LPCWSTR pszUrl, LPWSTR pszUrlDisplay, DWORD cchUrlDisplay)
  1410. {
  1411. HRESULT hr;
  1412. LPWSTR pszSecUrl;
  1413. hr = CoInternetGetSecurityUrl(pszUrl, &pszSecUrl, PSU_DEFAULT, 0);
  1414. if (SUCCEEDED(hr))
  1415. {
  1416. LPCWSTR pszColon = StrChr(pszSecUrl, L':');
  1417. //Special case about Urls so we don't munge them.
  1418. if (pszColon && (pszColon - pszSecUrl != 5 || StrCmpNI(pszSecUrl, L"about", 5) != 0))
  1419. {
  1420. DWORD bufferUsed = min(cchUrlDisplay, (DWORD)(pszColon - pszSecUrl) + 2);
  1421. StrCpyN(pszUrlDisplay, pszSecUrl, bufferUsed);
  1422. //Don't add // if the security url already has it
  1423. if (StrCmpNI(pszColon + 1, L"//", 2) != 0)
  1424. {
  1425. StrCatBuff(pszUrlDisplay, L"//", cchUrlDisplay - bufferUsed);
  1426. StrCatBuff(pszUrlDisplay, pszColon + 1, cchUrlDisplay - bufferUsed - 2);
  1427. }
  1428. else
  1429. {
  1430. StrCatBuff(pszUrlDisplay, pszColon + 1, cchUrlDisplay - bufferUsed);
  1431. }
  1432. }
  1433. else
  1434. {
  1435. StrCpyN(pszUrlDisplay, pszSecUrl, cchUrlDisplay);
  1436. }
  1437. CoTaskMemFree(pszSecUrl);
  1438. }
  1439. else
  1440. {
  1441. StrCpyN(pszUrlDisplay, pszUrl, cchUrlDisplay);
  1442. hr = S_OK;
  1443. }
  1444. if (SUCCEEDED (hr))
  1445. // Transform file:// URLs to a file://UNC format if necessary:
  1446. hr = GetAddSitesFileUrl(pszUrlDisplay);
  1447. return hr;
  1448. }
  1449. BOOL __cdecl _FormatMessage(LPCWSTR szTemplate, LPWSTR szBuf, UINT cchBuf, ...)
  1450. {
  1451. BOOL fRet;
  1452. va_list ArgList;
  1453. va_start(ArgList, cchBuf);
  1454. fRet = FormatMessage(FORMAT_MESSAGE_FROM_STRING, szTemplate, 0, 0, szBuf, cchBuf, &ArgList);
  1455. va_end(ArgList);
  1456. return fRet;
  1457. }
  1458. HRESULT _AddSite(LPADDSITESINFO pasi)
  1459. {
  1460. HRESULT hr = S_OK;
  1461. LPWSTR psz;
  1462. SendMessage(pasi->hwndAdd, WM_GETTEXT, MAX_ZONE_PATH, (LPARAM)pasi->szWebSite);
  1463. #ifndef UNICODE
  1464. WCHAR wszMapping[MAX_ZONE_PATH];
  1465. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pasi->szWebSite, sizeof(pasi->szWebSite), wszMapping, ARRAYSIZE(wszMapping));
  1466. psz = wszMapping;
  1467. #else
  1468. psz = pasi->szWebSite;
  1469. #endif
  1470. if (*psz)
  1471. {
  1472. pasi->fRSVOld = pasi->fRequireServerVerification;
  1473. pasi->fRequireServerVerification = IsDlgButtonChecked(pasi->hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION);
  1474. // if the state of RequireServerVer has changed, then do a SetZoneAttr so we'll get the correct error codes
  1475. if (pasi->fRSVOld != pasi->fRequireServerVerification)
  1476. {
  1477. ZONEATTRIBUTES za;
  1478. za.cbSize = sizeof(ZONEATTRIBUTES);
  1479. pasi->pSec->pInternetZoneManager->GetZoneAttributes(pasi->pSec->pszs->dwZoneIndex, &za);
  1480. if (pasi->fRequireServerVerification)
  1481. za.dwFlags |= ZAFLAGS_REQUIRE_VERIFICATION;
  1482. else
  1483. za.dwFlags &= ~ZAFLAGS_REQUIRE_VERIFICATION;
  1484. pasi->pSec->pInternetZoneManager->SetZoneAttributes(pasi->pSec->pszs->dwZoneIndex, &za);
  1485. }
  1486. hr = pasi->pSec->pInternetSecurityManager->SetZoneMapping(pasi->pSec->pszs->dwZoneIndex,
  1487. psz, SZM_CREATE);
  1488. if (FAILED(hr))
  1489. {
  1490. UINT id = IDS_MAPPINGFAIL;
  1491. if (hr == URL_E_INVALID_SYNTAX)
  1492. {
  1493. id = IDS_INVALIDURL;
  1494. }
  1495. else if (hr == E_INVALIDARG)
  1496. {
  1497. id = IDS_INVALIDWILDCARD;
  1498. }
  1499. else if (hr == E_ACCESSDENIED)
  1500. {
  1501. id = IDS_HTTPSREQ;
  1502. }
  1503. else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS))
  1504. {
  1505. id = IDS_SITEEXISTS;
  1506. }
  1507. DWORD dwOldZone;
  1508. if (id == IDS_SITEEXISTS && SUCCEEDED(pasi->pSec->pInternetSecurityManager->MapUrlToZone(psz, &dwOldZone, 0)))
  1509. {
  1510. if (dwOldZone == pasi->pSec->pszs->dwZoneIndex)
  1511. {
  1512. // Nothing to do except inform the user
  1513. SiteAlreadyInZoneMessage(pasi->hDlg, dwOldZone);
  1514. }
  1515. else if (dwOldZone == URLZONE_UNTRUSTED)
  1516. {
  1517. // Do not allow moving a site from the restricted zone to any other zone.
  1518. WCHAR szMessage[200];
  1519. WCHAR szZone[100];
  1520. if (MLLoadString(IDS_CANNOT_MOVE_FROM_RESTRICTED, szMessage, ARRAYSIZE(szMessage)) &&
  1521. MLLoadString(IDS_ZONENAME_LOCAL + URLZONE_UNTRUSTED, szZone, ARRAYSIZE(szZone)))
  1522. {
  1523. MLShellMessageBox(pasi->hDlg, szMessage, szZone, MB_ICONINFORMATION | MB_OK);
  1524. }
  1525. }
  1526. else
  1527. {
  1528. // The site exists in another zone
  1529. WCHAR szNewZone[100];
  1530. MLLoadString(IDS_ZONENAME_LOCAL + pasi->pSec->pszs->dwZoneIndex, szNewZone, ARRAYSIZE(szNewZone));
  1531. WCHAR szOldZone[100];
  1532. MLLoadString(IDS_ZONENAME_LOCAL + dwOldZone, szOldZone, ARRAYSIZE(szOldZone));
  1533. WCHAR szFormat[200];
  1534. MLLoadString(IDS_ADDSITEREPLACE, szFormat, ARRAYSIZE(szFormat));
  1535. WCHAR szText[400];
  1536. _FormatMessage(szFormat, szText, ARRAYSIZE(szText), szOldZone, szNewZone);
  1537. if (IDYES == MLShellMessageBox(pasi->hDlg, szText, NULL, MB_ICONQUESTION | MB_YESNO))
  1538. {
  1539. pasi->pSec->pInternetSecurityManager->SetZoneMapping(dwOldZone, psz, SZM_DELETE);
  1540. hr = _AddSite(pasi);
  1541. }
  1542. }
  1543. }
  1544. else
  1545. {
  1546. MLShellMessageBox(pasi->hDlg, MAKEINTRESOURCEW(id), NULL, MB_ICONSTOP|MB_OK);
  1547. Edit_SetSel(pasi->hwndAdd, 0, -1);
  1548. }
  1549. }
  1550. else
  1551. {
  1552. WCHAR szUrl[MAX_ZONE_PATH];
  1553. _GetAddSitesDisplayUrl(pasi->szWebSite, szUrl, ARRAYSIZE(szUrl));
  1554. SendMessage(pasi->hwndWebSites, LB_ADDSTRING, (WPARAM)0, (LPARAM)szUrl);
  1555. SendMessage(pasi->hwndAdd, WM_SETTEXT, (WPARAM)0, (LPARAM)NULL);
  1556. SetFocus(pasi->hwndAdd);
  1557. }
  1558. }
  1559. return hr;
  1560. }
  1561. INT_PTR CALLBACK SecurityAddSitesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  1562. {
  1563. LPADDSITESINFO pasi;
  1564. if (uMsg == WM_INITDIALOG)
  1565. {
  1566. pasi = (LPADDSITESINFO)LocalAlloc(LPTR, sizeof(*pasi));
  1567. if (!pasi)
  1568. {
  1569. EndDialog(hDlg, IDCANCEL);
  1570. return FALSE;
  1571. }
  1572. // tell dialog where to get info
  1573. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pasi);
  1574. // save the handle to the page
  1575. pasi->hDlg = hDlg;
  1576. pasi->pSec = (LPSECURITYPAGE)lParam;
  1577. pasi->hwndWebSites = GetDlgItem(hDlg, IDC_LIST_WEBSITES);
  1578. pasi->hwndAdd = GetDlgItem(hDlg, IDC_EDIT_ADD_SITE);
  1579. // cross-lang platform support
  1580. SHSetDefaultDialogFont(hDlg, IDC_EDIT_ADD_SITE);
  1581. // limit the text so it will fit
  1582. SendMessage(pasi->hwndAdd, EM_SETLIMITTEXT, (WPARAM)sizeof(pasi->szWebSite), (LPARAM)0);
  1583. pasi->fRequireServerVerification = pasi->pSec->pszs->dwFlags & ZAFLAGS_REQUIRE_VERIFICATION;
  1584. CheckDlgButton(hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION, pasi->fRequireServerVerification);
  1585. // hide the checkbox if it doesn't support server verification
  1586. if (!(pasi->pSec->pszs->dwFlags & ZAFLAGS_SUPPORTS_VERIFICATION))
  1587. ShowWindow(GetDlgItem(hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION), SW_HIDE);
  1588. SendMessage(hDlg, WM_SETTEXT, (WPARAM)0, (LPARAM)pasi->pSec->pszs->szDisplayName);
  1589. SetDlgItemText(hDlg, IDC_ADDSITES_GROUPBOX,(LPTSTR)pasi->pSec->pszs->szDisplayName);
  1590. SendDlgItemMessage(hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pasi->pSec->pszs->hicon);
  1591. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_REMOVE), FALSE);
  1592. if (pasi->pSec->pInternetSecurityManager || SUCCEEDED(CoInternetCreateSecurityManager(NULL, &(pasi->pSec->pInternetSecurityManager), 0)))
  1593. {
  1594. IEnumString *pEnum;
  1595. if (SUCCEEDED(pasi->pSec->pInternetSecurityManager->GetZoneMappings(pasi->pSec->pszs->dwZoneIndex, &pEnum, 0)))
  1596. {
  1597. LPOLESTR pszMapping;
  1598. #ifndef UNICODE
  1599. CHAR szMapping[MAX_URL_STRING];
  1600. #endif
  1601. LPTSTR psz;
  1602. while (pEnum->Next(1, &pszMapping, NULL) == S_OK)
  1603. {
  1604. #ifndef UNICODE
  1605. WideCharToMultiByte(CP_ACP, 0, pszMapping, -1, szMapping, ARRAYSIZE(szMapping), NULL, NULL);
  1606. psz = szMapping;
  1607. #else
  1608. psz = pszMapping;
  1609. #endif // UNICODE
  1610. SendMessage(pasi->hwndWebSites, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)psz);
  1611. CoTaskMemFree(pszMapping);
  1612. }
  1613. pEnum->Release();
  1614. }
  1615. }
  1616. BOOL fUseHKLM = FALSE;
  1617. DWORD cb = SIZEOF(fUseHKLM);
  1618. SHGetValue( HKEY_LOCAL_MACHINE,
  1619. REGSTR_PATH_SECURITY_LOCKOUT,
  1620. REGSTR_VAL_HKLM_ONLY,
  1621. NULL,
  1622. &fUseHKLM,
  1623. &cb);
  1624. if (pasi->pSec->fNoAddSites || pasi->pSec->fNoZoneMapEdit || (fUseHKLM && !IsNTAdmin(0, NULL)))
  1625. {
  1626. EnableDlgItem(hDlg, IDC_EDIT_ADD_SITE, FALSE);
  1627. EnableDlgItem(hDlg, IDC_BUTTON_REMOVE, FALSE);
  1628. }
  1629. else if (pasi->pSec->szPageUrl[0])
  1630. {
  1631. // Security manager should have been created above
  1632. if (pasi->pSec->pInternetSecurityManager)
  1633. {
  1634. DWORD dwZone;
  1635. if (SUCCEEDED(pasi->pSec->pInternetSecurityManager->MapUrlToZone(pasi->pSec->szPageUrl, &dwZone, 0)))
  1636. {
  1637. // If a site is already restricted, we don't want to auto-suggest.
  1638. // If a site is already trusted, we can't add it to either list anyway.
  1639. // So we only need to check for Intranet and Internet.
  1640. if ((dwZone == URLZONE_INTERNET) ||
  1641. (pasi->pSec->pszs->dwZoneIndex == URLZONE_INTRANET && dwZone == URLZONE_TRUSTED) ||
  1642. (pasi->pSec->pszs->dwZoneIndex == URLZONE_TRUSTED && dwZone == URLZONE_INTRANET))
  1643. {
  1644. WCHAR szUrl[MAX_ZONE_PATH];
  1645. if (SUCCEEDED(_GetAddSitesDisplayUrl(pasi->pSec->szPageUrl, szUrl, ARRAYSIZE(szUrl))))
  1646. {
  1647. SetWindowText(pasi->hwndAdd, szUrl);
  1648. SetFocus(GetDlgItem(hDlg, IDC_BUTTON_ADD));
  1649. }
  1650. }
  1651. }
  1652. }
  1653. }
  1654. if (pasi->pSec->fNoZoneMapEdit)
  1655. {
  1656. EnableDlgItem(hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION, FALSE);
  1657. EnableDlgItem(hDlg, IDS_STATIC_ADDSITE, FALSE);
  1658. }
  1659. SHAutoComplete(GetDlgItem(hDlg, IDC_EDIT_ADD_SITE), SHACF_DEFAULT);
  1660. }
  1661. else
  1662. pasi = (LPADDSITESINFO)GetWindowLongPtr(hDlg, DWLP_USER);
  1663. if (!pasi)
  1664. return FALSE;
  1665. switch (uMsg)
  1666. {
  1667. case WM_COMMAND:
  1668. switch (LOWORD(wParam))
  1669. {
  1670. case IDCANCEL: //Close
  1671. {
  1672. ZONEATTRIBUTES za;
  1673. pasi->fRequireServerVerification = IsDlgButtonChecked(hDlg, IDC_CHECK_REQUIRE_SERVER_VERIFICATION);
  1674. if (pasi->fRequireServerVerification)
  1675. pasi->pSec->pszs->dwFlags |= ZAFLAGS_REQUIRE_VERIFICATION;
  1676. else
  1677. pasi->pSec->pszs->dwFlags &= ~ZAFLAGS_REQUIRE_VERIFICATION;
  1678. za.cbSize = sizeof(ZONEATTRIBUTES);
  1679. pasi->pSec->pInternetZoneManager->GetZoneAttributes(pasi->pSec->pszs->dwZoneIndex, &za);
  1680. za.dwFlags = pasi->pSec->pszs->dwFlags;
  1681. pasi->pSec->pInternetZoneManager->SetZoneAttributes(pasi->pSec->pszs->dwZoneIndex, &za);
  1682. SecurityChanged();
  1683. EndDialog(hDlg, IDOK);
  1684. break;
  1685. }
  1686. case IDC_LIST_WEBSITES:
  1687. switch (HIWORD(wParam))
  1688. {
  1689. case LBN_SELCHANGE:
  1690. case LBN_SELCANCEL:
  1691. if (!pasi->pSec->fNoAddSites && !pasi->pSec->fNoZoneMapEdit)
  1692. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_REMOVE), SendDlgItemMessage(hDlg, IDC_LIST_WEBSITES, LB_GETCURSEL, 0, 0) != -1);
  1693. break;
  1694. }
  1695. break;
  1696. case IDC_EDIT_ADD_SITE:
  1697. switch(HIWORD(wParam))
  1698. {
  1699. case EN_CHANGE:
  1700. BOOL fEnable = GetWindowTextLength(GetDlgItem(hDlg, IDC_EDIT_ADD_SITE)) ? TRUE:FALSE;
  1701. EnableWindow(GetDlgItem(hDlg,IDC_BUTTON_ADD), fEnable);
  1702. SendMessage(hDlg, DM_SETDEFID, fEnable ? IDC_BUTTON_ADD : IDOK, 0);
  1703. break;
  1704. }
  1705. break;
  1706. case IDC_BUTTON_ADD:
  1707. _AddSite(pasi);
  1708. break;
  1709. case IDC_BUTTON_REMOVE:
  1710. {
  1711. TCHAR szMapping[MAX_ZONE_PATH];
  1712. LPWSTR psz;
  1713. INT_PTR iSel = SendMessage(pasi->hwndWebSites, LB_GETCURSEL, 0, 0);
  1714. if (iSel != -1)
  1715. {
  1716. SendMessage(pasi->hwndWebSites, LB_GETTEXT, (WPARAM)iSel, (LPARAM)szMapping);
  1717. #ifndef UNICODE
  1718. WCHAR wszMapping[MAX_ZONE_PATH];
  1719. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szMapping, sizeof(szMapping), wszMapping, ARRAYSIZE(wszMapping));
  1720. psz = wszMapping;
  1721. #else
  1722. psz = szMapping;
  1723. #endif
  1724. SendMessage(pasi->hwndWebSites, LB_DELETESTRING, iSel , 0);
  1725. SendMessage(pasi->hwndWebSites, LB_SETCURSEL, iSel-1, 0);
  1726. if (!pasi->pSec->fNoAddSites && !pasi->pSec->fNoZoneMapEdit)
  1727. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_REMOVE), SendDlgItemMessage(hDlg, IDC_LIST_WEBSITES, LB_GETCURSEL, 0, 0) != -1);
  1728. pasi->pSec->pInternetSecurityManager->SetZoneMapping(pasi->pSec->pszs->dwZoneIndex,
  1729. psz, SZM_DELETE);
  1730. }
  1731. break;
  1732. }
  1733. default:
  1734. return FALSE;
  1735. }
  1736. return TRUE;
  1737. break;
  1738. case WM_HELP: // F1
  1739. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  1740. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1741. break;
  1742. case WM_CONTEXTMENU: // right mouse click
  1743. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  1744. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1745. break;
  1746. case WM_DESTROY:
  1747. SHRemoveDefaultDialogFont(hDlg);
  1748. if (pasi)
  1749. {
  1750. LocalFree(pasi);
  1751. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  1752. }
  1753. break;
  1754. }
  1755. return FALSE;
  1756. }
  1757. INT_PTR CALLBACK SecurityAddSitesIntranetDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  1758. {
  1759. LPADDSITESINTRANETINFO pasii;
  1760. if (uMsg == WM_INITDIALOG)
  1761. {
  1762. pasii = (LPADDSITESINTRANETINFO)LocalAlloc(LPTR, sizeof(*pasii));
  1763. if (!pasii)
  1764. {
  1765. EndDialog(hDlg, IDCANCEL);
  1766. return FALSE;
  1767. }
  1768. // tell dialog where to get info
  1769. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pasii);
  1770. // save the handle to the page
  1771. pasii->hDlg = hDlg;
  1772. pasii->pSec = (LPSECURITYPAGE)lParam;
  1773. SendMessage(hDlg, WM_SETTEXT, (WPARAM)0, (LPARAM)pasii->pSec->pszs->szDisplayName);
  1774. CheckDlgButton(hDlg, IDC_CHECK_USEINTRANET, pasii->pSec->pszs->dwFlags & ZAFLAGS_INCLUDE_INTRANET_SITES);
  1775. CheckDlgButton(hDlg, IDC_CHECK_PROXY, pasii->pSec->pszs->dwFlags & ZAFLAGS_INCLUDE_PROXY_OVERRIDE);
  1776. CheckDlgButton(hDlg, IDC_CHECK_UNC, pasii->pSec->pszs->dwFlags & ZAFLAGS_UNC_AS_INTRANET);
  1777. SendDlgItemMessage(hDlg, IDC_ZONE_ICON, STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)pasii->pSec->pszs->hicon);
  1778. BOOL fHarden = IEHardened();
  1779. if (pasii->pSec->fNoAddSites || pasii->pSec->fNoZoneMapEdit || fHarden)
  1780. {
  1781. EnableDlgItem(hDlg, IDC_CHECK_USEINTRANET, FALSE);
  1782. EnableDlgItem(hDlg, IDC_CHECK_PROXY, FALSE);
  1783. }
  1784. if (pasii->pSec->fNoZoneMapEdit || fHarden)
  1785. {
  1786. EnableDlgItem(hDlg, IDC_CHECK_UNC, FALSE);
  1787. }
  1788. return TRUE;
  1789. }
  1790. else
  1791. pasii = (LPADDSITESINTRANETINFO)GetWindowLongPtr(hDlg, DWLP_USER);
  1792. if (!pasii)
  1793. return FALSE;
  1794. switch (uMsg) {
  1795. case WM_COMMAND:
  1796. switch (LOWORD(wParam))
  1797. {
  1798. case IDOK:
  1799. {
  1800. ZONEATTRIBUTES za;
  1801. pasii->fUseIntranet = IsDlgButtonChecked(hDlg, IDC_CHECK_USEINTRANET);
  1802. pasii->fUseProxyExclusion = IsDlgButtonChecked(hDlg, IDC_CHECK_PROXY);
  1803. pasii->fUseUNC = IsDlgButtonChecked(hDlg, IDC_CHECK_UNC);
  1804. if (pasii->fUseIntranet)
  1805. pasii->pSec->pszs->dwFlags |= ZAFLAGS_INCLUDE_INTRANET_SITES;
  1806. else
  1807. pasii->pSec->pszs->dwFlags &= ~ZAFLAGS_INCLUDE_INTRANET_SITES;
  1808. if (pasii->fUseProxyExclusion)
  1809. pasii->pSec->pszs->dwFlags |= ZAFLAGS_INCLUDE_PROXY_OVERRIDE;
  1810. else
  1811. pasii->pSec->pszs->dwFlags &= ~ZAFLAGS_INCLUDE_PROXY_OVERRIDE;
  1812. if (pasii->fUseUNC)
  1813. pasii->pSec->pszs->dwFlags |= ZAFLAGS_UNC_AS_INTRANET;
  1814. else
  1815. pasii->pSec->pszs->dwFlags &= ~ZAFLAGS_UNC_AS_INTRANET;
  1816. za.cbSize = sizeof(ZONEATTRIBUTES);
  1817. pasii->pSec->pInternetZoneManager->GetZoneAttributes(pasii->pSec->pszs->dwZoneIndex, &za);
  1818. za.dwFlags = pasii->pSec->pszs->dwFlags;
  1819. pasii->pSec->pInternetZoneManager->SetZoneAttributes(pasii->pSec->pszs->dwZoneIndex, &za);
  1820. SecurityChanged();
  1821. EndDialog(hDlg, IDOK);
  1822. break;
  1823. }
  1824. case IDCANCEL:
  1825. EndDialog(hDlg, IDCANCEL);
  1826. break;
  1827. case IDC_INTRANET_ADVANCED:
  1828. DialogBoxParam(MLGetHinst(), MAKEINTRESOURCE(IDD_SECURITY_ADD_SITES), hDlg,
  1829. SecurityAddSitesDlgProc, (LPARAM)pasii->pSec);
  1830. break;
  1831. default:
  1832. return FALSE;
  1833. }
  1834. return TRUE;
  1835. break;
  1836. case WM_HELP: // F1
  1837. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  1838. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1839. break;
  1840. case WM_CONTEXTMENU: // right mouse click
  1841. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  1842. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  1843. break;
  1844. case WM_DESTROY:
  1845. if (pasii)
  1846. {
  1847. LocalFree(pasii);
  1848. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  1849. }
  1850. break;
  1851. }
  1852. return FALSE;
  1853. }
  1854. VOID ShowJavaZonePermissionsDialog (HWND hdlg, LPCUSTOMSETTINGSINFO pcsi)
  1855. {
  1856. HRESULT hr;
  1857. IJavaZonePermissionEditor *zoneeditor;
  1858. hr = CoCreateInstance(
  1859. CLSID_JavaRuntimeConfiguration,
  1860. NULL,
  1861. CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER,
  1862. IID_IJavaZonePermissionEditor,
  1863. (PVOID*)&zoneeditor
  1864. );
  1865. if (SUCCEEDED(hr))
  1866. {
  1867. hr = zoneeditor->ShowUI(
  1868. hdlg,
  1869. 0,
  1870. 0,
  1871. pcsi->fUseHKLM ? URLZONEREG_HKLM : URLZONEREG_DEFAULT,
  1872. pcsi->pSec->pszs->dwZoneIndex,
  1873. pcsi->dwJavaPolicy | URLACTION_JAVA_PERMISSIONS,
  1874. pcsi->pSec->pInternetZoneManager
  1875. );
  1876. zoneeditor->Release();
  1877. }
  1878. }
  1879. void ShowCustom(LPCUSTOMSETTINGSINFO pcsi, HTREEITEM hti)
  1880. {
  1881. TV_ITEM tvi;
  1882. tvi.hItem = hti;
  1883. tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
  1884. TreeView_GetItem( pcsi->hwndTree, &tvi );
  1885. // If it's not selected don't bother.
  1886. if (tvi.iImage != IDRADIOON)
  1887. return;
  1888. TCHAR szValName[64];
  1889. DWORD cb = SIZEOF(szValName);
  1890. DWORD dwChecked;
  1891. if (SHRegQueryUSValue((HUSKEY)tvi.lParam,
  1892. TEXT("ValueName"),
  1893. NULL,
  1894. (LPBYTE)szValName,
  1895. &cb,
  1896. pcsi->fUseHKLM,
  1897. NULL,
  1898. 0) == ERROR_SUCCESS)
  1899. {
  1900. if (!(StrCmp(szValName, TEXT("1C00"))))
  1901. {
  1902. cb = SIZEOF(dwChecked);
  1903. if (SHRegQueryUSValue((HUSKEY)tvi.lParam,
  1904. TEXT("CheckedValue"),
  1905. NULL,
  1906. (LPBYTE)&dwChecked,
  1907. &cb,
  1908. pcsi->fUseHKLM,
  1909. NULL,
  1910. 0) == ERROR_SUCCESS)
  1911. {
  1912. #ifndef UNIX
  1913. HWND hCtl = GetDlgItem(pcsi->hDlg, IDC_JAVACUSTOM);
  1914. ShowWindow(hCtl,
  1915. (dwChecked == URLPOLICY_JAVA_CUSTOM) && (tvi.iImage == IDRADIOON) ? SW_SHOWNA : SW_HIDE);
  1916. EnableWindow(hCtl, dwChecked==URLPOLICY_JAVA_CUSTOM ? TRUE : FALSE);
  1917. pcsi->dwJavaPolicy = dwChecked;
  1918. #endif
  1919. }
  1920. }
  1921. }
  1922. }
  1923. void _FindCustomRecursive(
  1924. LPCUSTOMSETTINGSINFO pcsi,
  1925. HTREEITEM htvi
  1926. )
  1927. {
  1928. HTREEITEM hctvi; // child
  1929. // step through the children
  1930. hctvi = TreeView_GetChild( pcsi->hwndTree, htvi );
  1931. while ( hctvi )
  1932. {
  1933. _FindCustomRecursive(pcsi,hctvi);
  1934. hctvi = TreeView_GetNextSibling( pcsi->hwndTree, hctvi );
  1935. }
  1936. ShowCustom(pcsi, htvi);
  1937. }
  1938. void _FindCustom(
  1939. LPCUSTOMSETTINGSINFO pcsi
  1940. )
  1941. {
  1942. HTREEITEM hti = TreeView_GetRoot( pcsi->hwndTree );
  1943. // and walk the list of other roots
  1944. while (hti)
  1945. {
  1946. // recurse through its children
  1947. _FindCustomRecursive(pcsi, hti);
  1948. // get the next root
  1949. hti = TreeView_GetNextSibling(pcsi->hwndTree, hti );
  1950. }
  1951. }
  1952. BOOL SecurityCustomSettingsInitDialog(HWND hDlg, LPARAM lParam)
  1953. {
  1954. LPCUSTOMSETTINGSINFO pcsi = (LPCUSTOMSETTINGSINFO)LocalAlloc(LPTR, sizeof(*pcsi));
  1955. HRESULT hr;
  1956. if (!pcsi)
  1957. {
  1958. EndDialog(hDlg, IDCANCEL);
  1959. return FALSE;
  1960. }
  1961. // tell dialog where to get info
  1962. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pcsi);
  1963. // save the handle to the page
  1964. pcsi->hDlg = hDlg;
  1965. pcsi->pSec = (LPSECURITYPAGE)lParam;
  1966. // save dialog handle
  1967. pcsi->hwndTree = GetDlgItem(pcsi->hDlg, IDC_TREE_SECURITY_SETTINGS);
  1968. CoInitialize(0);
  1969. hr = CoCreateInstance(CLSID_CRegTreeOptions, NULL, CLSCTX_INPROC_SERVER,
  1970. IID_IRegTreeOptions, (LPVOID *)&(pcsi->pTO));
  1971. DWORD cb = SIZEOF(pcsi->fUseHKLM);
  1972. SHGetValue(HKEY_LOCAL_MACHINE,
  1973. REGSTR_PATH_SECURITY_LOCKOUT,
  1974. REGSTR_VAL_HKLM_ONLY,
  1975. NULL,
  1976. &(pcsi->fUseHKLM),
  1977. &cb);
  1978. // if this fails, we'll just use the default of fUseHKLM == 0
  1979. if (SUCCEEDED(hr))
  1980. {
  1981. CHAR szZone[32];
  1982. wnsprintfA(szZone, ARRAYSIZE(szZone), "%ld", pcsi->pSec->pszs->dwZoneIndex);
  1983. // use the SOHKLM tree when fUseHKLM==TRUE for IEAK
  1984. hr = pcsi->pTO->InitTree(pcsi->hwndTree, HKEY_LOCAL_MACHINE,
  1985. pcsi->fUseHKLM ?
  1986. "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\SOIEAK" :
  1987. "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\SO",
  1988. szZone);
  1989. }
  1990. // find the first root and make sure that it is visible
  1991. TreeView_EnsureVisible( pcsi->hwndTree, TreeView_GetRoot( pcsi->hwndTree ) );
  1992. pcsi->hwndCombo = GetDlgItem(hDlg, IDC_COMBO_RESETLEVEL);
  1993. SendMessage(pcsi->hwndCombo, CB_INSERTSTRING, (WPARAM)0, (LPARAM)LEVEL_NAME[3]);
  1994. SendMessage(pcsi->hwndCombo, CB_INSERTSTRING, (WPARAM)0, (LPARAM)LEVEL_NAME[2]);
  1995. SendMessage(pcsi->hwndCombo, CB_INSERTSTRING, (WPARAM)0, (LPARAM)LEVEL_NAME[1]);
  1996. SendMessage(pcsi->hwndCombo, CB_INSERTSTRING, (WPARAM)0, (LPARAM)LEVEL_NAME[0]);
  1997. switch (pcsi->pSec->pszs->dwRecSecLevel)
  1998. {
  1999. case URLTEMPLATE_LOW:
  2000. pcsi->iLevelSel = 3;
  2001. break;
  2002. case URLTEMPLATE_MEDLOW:
  2003. pcsi->iLevelSel = 2;
  2004. break;
  2005. case URLTEMPLATE_MEDIUM:
  2006. pcsi->iLevelSel = 1;
  2007. break;
  2008. case URLTEMPLATE_HIGH:
  2009. pcsi->iLevelSel = 0;
  2010. break;
  2011. default:
  2012. pcsi->iLevelSel = 0;
  2013. break;
  2014. }
  2015. _FindCustom(pcsi);
  2016. SendMessage(pcsi->hwndCombo, CB_SETCURSEL, (WPARAM)pcsi->iLevelSel, (LPARAM)0);
  2017. if (pcsi->pSec->fNoEdit)
  2018. {
  2019. EnableDlgItem(hDlg, IDC_COMBO_RESETLEVEL, FALSE);
  2020. EnableDlgItem(hDlg, IDC_BUTTON_APPLY, FALSE);
  2021. }
  2022. pcsi->fChanged = FALSE;
  2023. return TRUE;
  2024. }
  2025. INT_PTR CALLBACK SecurityCustomSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  2026. {
  2027. LPCUSTOMSETTINGSINFO pcsi;
  2028. if (uMsg == WM_INITDIALOG)
  2029. return SecurityCustomSettingsInitDialog(hDlg, lParam);
  2030. else
  2031. pcsi = (LPCUSTOMSETTINGSINFO)GetWindowLongPtr(hDlg, DWLP_USER);
  2032. if (!pcsi)
  2033. return FALSE;
  2034. switch (uMsg) {
  2035. case WM_NOTIFY:
  2036. {
  2037. LPNMHDR psn = (LPNMHDR)lParam;
  2038. switch( psn->code )
  2039. {
  2040. case TVN_KEYDOWN:
  2041. {
  2042. TV_KEYDOWN *pnm = (TV_KEYDOWN*)psn;
  2043. if (pnm->wVKey == VK_SPACE) {
  2044. if (!pcsi->pSec->fNoEdit)
  2045. {
  2046. HTREEITEM hti = (HTREEITEM)SendMessage(pcsi->hwndTree, TVM_GETNEXTITEM, TVGN_CARET, NULL);
  2047. pcsi->pTO->ToggleItem(hti);
  2048. ShowCustom(pcsi, hti);
  2049. pcsi->fChanged = TRUE;
  2050. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_APPLY),TRUE);
  2051. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); // eat the key
  2052. return TRUE;
  2053. }
  2054. }
  2055. break;
  2056. }
  2057. case NM_CLICK:
  2058. case NM_DBLCLK:
  2059. { // is this click in our tree?
  2060. if ( psn->idFrom == IDC_TREE_SECURITY_SETTINGS )
  2061. { // yes...
  2062. TV_HITTESTINFO ht;
  2063. HTREEITEM hti;
  2064. if (!pcsi->pSec->fNoEdit)
  2065. {
  2066. GetCursorPos( &ht.pt ); // get where we were hit
  2067. ScreenToClient( pcsi->hwndTree, &ht.pt ); // translate it to our window
  2068. // retrieve the item hit
  2069. hti = TreeView_HitTest( pcsi->hwndTree, &ht);
  2070. pcsi->pTO->ToggleItem(hti);
  2071. pcsi->fChanged = TRUE;
  2072. ShowCustom(pcsi, hti);
  2073. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_APPLY),TRUE);
  2074. }
  2075. }
  2076. }
  2077. break;
  2078. }
  2079. }
  2080. break;
  2081. case WM_COMMAND:
  2082. switch (LOWORD(wParam))
  2083. {
  2084. case IDOK:
  2085. if(pcsi->pSec->fPendingChange)
  2086. break;
  2087. if(pcsi->fChanged && RegWriteWarning(pcsi->pSec->hDlg) == IDNO)
  2088. break;
  2089. // we use send message instead of post because there is no chance of this button
  2090. // receiving multiple signals at one click, and we need the change level message to be
  2091. // processed before the apply message below
  2092. pcsi->pSec->fPendingChange = TRUE;
  2093. SendMessage(pcsi->pSec->hDlg, WM_APP, (WPARAM) 0, (LPARAM) URLTEMPLATE_CUSTOM);
  2094. if(pcsi->fChanged)
  2095. {
  2096. pcsi->pTO->WalkTree( WALK_TREE_SAVE );
  2097. }
  2098. // Saves custom to registry and Handles updateallwindows
  2099. // and securitychanged calls
  2100. // APPCOMPAT: Force a call to SetZoneAttributes when anything in custom changes.
  2101. // This forces the security manager to flush any caches it has for that zone.
  2102. pcsi->pSec->fChanged = TRUE;
  2103. SecurityDlgApplyNow(pcsi->pSec, FALSE);
  2104. EndDialog(hDlg, IDOK);
  2105. break;
  2106. case IDCANCEL:
  2107. EndDialog(hDlg, IDCANCEL);
  2108. break;
  2109. case IDC_COMBO_RESETLEVEL:
  2110. switch (HIWORD(wParam))
  2111. {
  2112. case CBN_SELCHANGE:
  2113. {
  2114. // Sundown: coercion to integer since cursor selection is 32b
  2115. int iNewSelection = (int) SendMessage(pcsi->hwndCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
  2116. if (iNewSelection != pcsi->iLevelSel)
  2117. {
  2118. pcsi->iLevelSel = iNewSelection;
  2119. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_APPLY),TRUE);
  2120. }
  2121. break;
  2122. }
  2123. }
  2124. break;
  2125. case IDC_JAVACUSTOM:
  2126. ShowJavaZonePermissionsDialog(hDlg, pcsi);
  2127. break;
  2128. case IDC_BUTTON_APPLY:
  2129. {
  2130. TCHAR szLevel[64];
  2131. ZONEATTRIBUTES za;
  2132. if(pcsi->pSec->fPendingChange == TRUE)
  2133. break;
  2134. if(RegWriteWarning(hDlg) == IDNO)
  2135. {
  2136. break;
  2137. }
  2138. pcsi->pSec->fPendingChange = TRUE;
  2139. SendMessage(pcsi->hwndCombo, WM_GETTEXT, (WPARAM)ARRAYSIZE(szLevel), (LPARAM)szLevel);
  2140. za.cbSize = sizeof(ZONEATTRIBUTES);
  2141. pcsi->pSec->pInternetZoneManager->GetZoneAttributes(pcsi->pSec->pszs->dwZoneIndex, &za);
  2142. if (!StrCmp(szLevel, LEVEL_NAME[3]))
  2143. za.dwTemplateCurrentLevel = URLTEMPLATE_LOW;
  2144. else if (!StrCmp(szLevel, LEVEL_NAME[2]))
  2145. za.dwTemplateCurrentLevel = URLTEMPLATE_MEDLOW;
  2146. else if (!StrCmp(szLevel, LEVEL_NAME[1]))
  2147. za.dwTemplateCurrentLevel = URLTEMPLATE_MEDIUM;
  2148. else if (!StrCmp(szLevel, LEVEL_NAME[0]))
  2149. za.dwTemplateCurrentLevel = URLTEMPLATE_HIGH;
  2150. else
  2151. za.dwTemplateCurrentLevel = URLTEMPLATE_CUSTOM;
  2152. pcsi->pSec->pInternetZoneManager->SetZoneAttributes(pcsi->pSec->pszs->dwZoneIndex, &za);
  2153. pcsi->pTO->WalkTree(WALK_TREE_REFRESH);
  2154. // find the first root and make sure that it is visible
  2155. TreeView_EnsureVisible( pcsi->hwndTree, TreeView_GetRoot( pcsi->hwndTree ) );
  2156. EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_APPLY), FALSE);
  2157. SendMessage(hDlg, DM_SETDEFID, IDOK, 0);
  2158. SetFocus(GetDlgItem(hDlg, IDOK)); // since we grayout the reset button, might have keyboard
  2159. // focus, so we should set focus somewhere else
  2160. _FindCustom(pcsi);
  2161. // BUG #57358. We tell the Zone Manager to change to [High/Med/Low] level because we want
  2162. // the policy values for those, but we don't want it to change the level from
  2163. // custom. So, after it changes the setting from Custom, we change it back.
  2164. // Save the level as custom
  2165. // we use send message instead of post because there is no chance of this button
  2166. // receiving multiple signals at one click, and we need the change level message to be
  2167. // processed before the apply message below
  2168. SendMessage(pcsi->pSec->hDlg, WM_APP, (WPARAM) 0, (LPARAM) URLTEMPLATE_CUSTOM);
  2169. // Saves custom to registry and Handles updateallwindows
  2170. // and securitychanged calls
  2171. // APPCOMPAT: Force a call to SetZoneAttributes when anything in custom changes.
  2172. // This forces the security manager to flush any caches it has for that zone.
  2173. pcsi->pSec->fChanged = TRUE;
  2174. SecurityDlgApplyNow(pcsi->pSec, TRUE);
  2175. pcsi->fChanged = FALSE;
  2176. break;
  2177. }
  2178. default:
  2179. return FALSE;
  2180. }
  2181. return TRUE;
  2182. break;
  2183. case WM_HELP: // F1
  2184. {
  2185. LPHELPINFO lphelpinfo;
  2186. lphelpinfo = (LPHELPINFO)lParam;
  2187. TV_HITTESTINFO ht;
  2188. HTREEITEM hItem;
  2189. // If this help is invoked through the F1 key.
  2190. if (GetAsyncKeyState(VK_F1) < 0)
  2191. {
  2192. // Yes we need to give help for the currently selected item.
  2193. hItem = TreeView_GetSelection(pcsi->hwndTree);
  2194. }
  2195. else
  2196. {
  2197. // Else we need to give help for the item at current cursor position
  2198. ht.pt =((LPHELPINFO)lParam)->MousePos;
  2199. ScreenToClient(pcsi->hwndTree, &ht.pt); // Translate it to our window
  2200. hItem = TreeView_HitTest(pcsi->hwndTree, &ht);
  2201. }
  2202. if (FAILED(pcsi->pTO->ShowHelp(hItem , HELP_WM_HELP)))
  2203. {
  2204. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  2205. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  2206. }
  2207. break;
  2208. }
  2209. case WM_CONTEXTMENU: // right mouse click
  2210. {
  2211. TV_HITTESTINFO ht;
  2212. GetCursorPos( &ht.pt ); // get where we were hit
  2213. ScreenToClient( pcsi->hwndTree, &ht.pt ); // translate it to our window
  2214. // retrieve the item hit
  2215. if (FAILED(pcsi->pTO->ShowHelp(TreeView_HitTest( pcsi->hwndTree, &ht),HELP_CONTEXTMENU)))
  2216. {
  2217. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  2218. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  2219. }
  2220. break;
  2221. }
  2222. case WM_DESTROY:
  2223. if (pcsi)
  2224. {
  2225. if (pcsi->pTO)
  2226. {
  2227. pcsi->pTO->WalkTree( WALK_TREE_DELETE );
  2228. pcsi->pTO->Release();
  2229. pcsi->pTO=NULL;
  2230. }
  2231. LocalFree(pcsi);
  2232. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL);
  2233. CoUninitialize();
  2234. }
  2235. break;
  2236. }
  2237. return FALSE;
  2238. }
  2239. #ifdef UNIX
  2240. extern "C"
  2241. #endif
  2242. BOOL LaunchSecurityDialogEx(HWND hDlg, DWORD dwZone, DWORD dwFlags)
  2243. {
  2244. INITCOMMONCONTROLSEX icex;
  2245. SECURITYINITFLAGS * psif = NULL;
  2246. icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  2247. icex.dwICC = ICC_USEREX_CLASSES|ICC_NATIVEFNTCTL_CLASS;
  2248. InitCommonControlsEx(&icex);
  2249. if(g_dwtlsSecInitFlags != (DWORD) -1)
  2250. psif = (SECURITYINITFLAGS *) TlsGetValue(g_dwtlsSecInitFlags);
  2251. if(psif)
  2252. {
  2253. psif->fForceUI = dwFlags & LSDFLAG_FORCEUI;
  2254. psif->fDisableAddSites = dwFlags & LSDFLAG_NOADDSITES;
  2255. psif->dwZone = dwZone;
  2256. }
  2257. // passing in a NULL psif is okay
  2258. DialogBoxParam(MLGetHinst(), MAKEINTRESOURCE(IDD_SECSTANDALONE), hDlg,
  2259. SecurityDlgProc, (LPARAM) psif);
  2260. return TRUE;
  2261. }
  2262. // backwards compatability
  2263. #ifdef UNIX
  2264. extern "C"
  2265. #endif
  2266. void LaunchSecurityDialog(HWND hDlg, DWORD dwZone)
  2267. {
  2268. LaunchSecurityDialogEx(hDlg, dwZone, LSDFLAG_DEFAULT);
  2269. }
  2270. #ifdef UNIX
  2271. extern "C"
  2272. #endif
  2273. void LaunchSiteCertDialog(HWND hDlg)
  2274. {
  2275. CRYPTUI_CERT_MGR_STRUCT ccm = {0};
  2276. ccm.dwSize = sizeof(ccm);
  2277. ccm.hwndParent = hDlg;
  2278. CryptUIDlgCertMgr(&ccm);
  2279. }
  2280. BOOL SiteAlreadyInZone(LPCWSTR pszUrl, DWORD dwZone, SECURITYPAGE* pSec)
  2281. {
  2282. BOOL fRet = FALSE;
  2283. if (pSec->pInternetSecurityManager || SUCCEEDED(CoInternetCreateSecurityManager(NULL, &(pSec->pInternetSecurityManager), 0)))
  2284. {
  2285. DWORD dwMappedZone;
  2286. if (SUCCEEDED(pSec->pInternetSecurityManager->MapUrlToZone(pszUrl, &dwMappedZone, 0)))
  2287. {
  2288. fRet = (dwZone == dwMappedZone);
  2289. }
  2290. }
  2291. return fRet;
  2292. }
  2293. void SiteAlreadyInZoneMessage(HWND hwnd, DWORD dwZone)
  2294. {
  2295. WCHAR szFormat[200];
  2296. WCHAR szZone[100];
  2297. if (MLLoadString(IDS_SITEALREADYINZONE, szFormat, ARRAYSIZE(szFormat)) &&
  2298. MLLoadString(IDS_ZONENAME_LOCAL + dwZone, szZone, ARRAYSIZE(szZone)))
  2299. {
  2300. WCHAR szText[300];
  2301. wnsprintf(szText, ARRAYSIZE(szText), szFormat, szZone);
  2302. MLShellMessageBox(hwnd, szText, szZone, MB_ICONINFORMATION | MB_OK);
  2303. }
  2304. }
  2305. BOOL ShowAddSitesDialog(HWND hwnd, DWORD dwZone, LPCWSTR pszUrl)
  2306. {
  2307. BOOL fRet = FALSE;
  2308. SECURITYPAGE* pSec = NULL;
  2309. if (SecurityInitGlobals(&pSec, NULL, NULL))
  2310. {
  2311. DWORD dwEnum;
  2312. if (SUCCEEDED(pSec->pInternetZoneManager->CreateZoneEnumerator(&dwEnum, &(pSec->dwZoneCount), 0)))
  2313. {
  2314. if (S_OK == (SecurityInitZone(dwZone, pSec, dwEnum, NULL, NULL)))
  2315. {
  2316. if (!SiteAlreadyInZone(pszUrl, dwZone, pSec))
  2317. {
  2318. StrCpyN(pSec->szPageUrl, pszUrl, ARRAYSIZE(pSec->szPageUrl));
  2319. DialogBoxParam(MLGetHinst(), MAKEINTRESOURCE(IDD_SECURITY_ADD_SITES), hwnd, SecurityAddSitesDlgProc, (LPARAM)pSec);
  2320. fRet = TRUE;
  2321. FreePszs(pSec->pszs);
  2322. }
  2323. else
  2324. {
  2325. SiteAlreadyInZoneMessage(hwnd, dwZone);
  2326. }
  2327. }
  2328. pSec->pInternetZoneManager->DestroyZoneEnumerator(dwEnum);
  2329. }
  2330. SecurityFreeGlobals(pSec);
  2331. }
  2332. return fRet;
  2333. }