GetZoneAttributes ignores the names and descriptions in the registry for the first five zones. Do the same in Wine.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=27245
Supersedes https://gitlab.winehq.org/wine/wine/-/merge_requests/7084
-- v2: urlmon: Make security zone names and descriptions translatable.
From: Alex Henrie alexhenrie24@gmail.com
GetZoneAttributes ignores the names and descriptions in the registry for the first five zones. Do the same in Wine.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=27245 --- dlls/urlmon/resource.h | 11 +++++++++++ dlls/urlmon/sec_mgr.c | 18 +++++++++++++++-- dlls/urlmon/tests/sec_mgr.c | 39 ++++++++++++++++++++++++++++++++++--- dlls/urlmon/urlmon.inf | 2 ++ dlls/urlmon/urlmon.rc | 12 ++++++++++++ 5 files changed, 77 insertions(+), 5 deletions(-)
diff --git a/dlls/urlmon/resource.h b/dlls/urlmon/resource.h index 3ff2ac690a5..c42a522e0ea 100644 --- a/dlls/urlmon/resource.h +++ b/dlls/urlmon/resource.h @@ -24,3 +24,14 @@ #define IDS_AXINSTALL_FAILURE 1100 #define IDS_AXINSTALL_INSTALLN 1101 #define IDS_AXINSTALL_INSTALL 1102 + +#define IDS_SEC_ZONE0_NAME 2000 +#define IDS_SEC_ZONE1_NAME 2001 +#define IDS_SEC_ZONE2_NAME 2002 +#define IDS_SEC_ZONE3_NAME 2003 +#define IDS_SEC_ZONE4_NAME 2004 +#define IDS_SEC_ZONE0_DESC 2100 +#define IDS_SEC_ZONE1_DESC 2101 +#define IDS_SEC_ZONE2_DESC 2102 +#define IDS_SEC_ZONE3_DESC 2103 +#define IDS_SEC_ZONE4_DESC 2104 diff --git a/dlls/urlmon/sec_mgr.c b/dlls/urlmon/sec_mgr.c index 82266066e0f..21f1b9e3d66 100644 --- a/dlls/urlmon/sec_mgr.c +++ b/dlls/urlmon/sec_mgr.c @@ -24,6 +24,8 @@ #include <stdio.h>
#include "urlmon_main.h" +#include "resource.h" + #include "winreg.h" #include "wininet.h"
@@ -1390,8 +1392,20 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManagerEx2* ifa if (FAILED(hr)) TRACE("Zone %ld not in HKLM\n", dwZone);
- get_string_from_reg(hcu, hklm, L"DisplayName", pZoneAttributes->szDisplayName, MAX_ZONE_PATH); - get_string_from_reg(hcu, hklm, L"Description", pZoneAttributes->szDescription, MAX_ZONE_DESCRIPTION); + if (dwZone < 5) { + /* For the standard zones (0-4), ignore the name and description in the registry and return + * a name and description in the user's own language. */ + LoadStringW(urlmon_instance, IDS_SEC_ZONE0_NAME + dwZone, + pZoneAttributes->szDisplayName, ARRAY_SIZE(pZoneAttributes->szDisplayName)); + LoadStringW(urlmon_instance, IDS_SEC_ZONE0_DESC + dwZone, + pZoneAttributes->szDescription, ARRAY_SIZE(pZoneAttributes->szDescription)); + } else { + get_string_from_reg(hcu, hklm, L"DisplayName", + pZoneAttributes->szDisplayName, ARRAY_SIZE(pZoneAttributes->szDisplayName)); + get_string_from_reg(hcu, hklm, L"Description", + pZoneAttributes->szDescription, ARRAY_SIZE(pZoneAttributes->szDescription)); + } + get_string_from_reg(hcu, hklm, L"Icon", pZoneAttributes->szIconPath, MAX_ZONE_PATH); get_dword_from_reg(hcu, hklm, L"MinLevel", &pZoneAttributes->dwTemplateMinLevel); get_dword_from_reg(hcu, hklm, L"CurrentLevel", &pZoneAttributes->dwTemplateCurrentLevel); diff --git a/dlls/urlmon/tests/sec_mgr.c b/dlls/urlmon/tests/sec_mgr.c index debd1e9ebc5..c28f0eb6f7c 100644 --- a/dlls/urlmon/tests/sec_mgr.c +++ b/dlls/urlmon/tests/sec_mgr.c @@ -1157,10 +1157,13 @@ cleanup: static void test_GetZoneAttributes(void) { IInternetZoneManager *zonemgr = NULL; - CHAR buffer [sizeof(ZONEATTRIBUTES) + 32]; + char zone_key_name[MAX_PATH], buffer[sizeof(ZONEATTRIBUTES) + 32]; + WCHAR name[MAX_ZONE_PATH], desc[MAX_ZONE_DESCRIPTION]; ZONEATTRIBUTES* pZA = (ZONEATTRIBUTES*) buffer; + HKEY zone_key; + DWORD size, i; + LSTATUS res; HRESULT hr; - DWORD i;
trace("testing GetZoneAttributes...\n");
@@ -1171,9 +1174,39 @@ static void test_GetZoneAttributes(void)
/* native urlmon has Zone "0" up to Zone "4" since IE4 */ for (i = 0; i < 5; i++) { + winetest_push_context("Zone %ld", i); + + sprintf(zone_key_name, "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%ld", i); + res = RegOpenKeyExA(HKEY_CURRENT_USER, zone_key_name, 0, KEY_ALL_ACCESS, &zone_key); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + + size = sizeof(name); + res = RegQueryValueExW(zone_key, L"DisplayName", 0, NULL, (BYTE*)name, &size); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + res = RegSetValueExW(zone_key, L"DisplayName", 0, REG_SZ, (BYTE*)L"Foobar", sizeof(L"Foobar")); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + + size = sizeof(desc); + res = RegQueryValueExW(zone_key, L"Description", 0, NULL, (BYTE*)desc, &size); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + res = RegSetValueExW(zone_key, L"Description", 0, REG_SZ, (BYTE*)L"Foobar", sizeof(L"Foobar")); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + memset(buffer, -1, sizeof(buffer)); hr = IInternetZoneManager_GetZoneAttributes(zonemgr, i, pZA); - ok(hr == S_OK, "#%ld: got 0x%lx (expected S_OK)\n", i, hr); + ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", res); + + ok(wcscmp(pZA->szDisplayName, L"Foobar"), "got "Foobar", expected localized name\n"); + ok(wcscmp(pZA->szDescription, L"Foobar"), "got "Foobar", expected localized description\n"); + + res = RegSetValueExW(zone_key, L"DisplayName", 0, REG_SZ, (BYTE*)name, (wcslen(name) + 1) * sizeof(WCHAR)); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + res = RegSetValueExW(zone_key, L"Description", 0, REG_SZ, (BYTE*)desc, (wcslen(desc) + 1) * sizeof(WCHAR)); + ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res); + + RegCloseKey(zone_key); + + winetest_pop_context(); }
/* IE8 no longer set cbSize */ diff --git a/dlls/urlmon/urlmon.inf b/dlls/urlmon/urlmon.inf index 77bb8f21165..ef0b891b4a7 100644 --- a/dlls/urlmon/urlmon.inf +++ b/dlls/urlmon/urlmon.inf @@ -440,6 +440,8 @@ ZONES_TRUSTED="Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones ZONES_INTERNET="Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" ZONES_UNTRUSTED="Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4"
+;; The English zone names and descriptions should be identical to the ones in urlmon.rc + NAME_LOCAL="My Computer" DESC_LOCAL="Your computer" ZICON_LOCAL="explorer.exe#0100" diff --git a/dlls/urlmon/urlmon.rc b/dlls/urlmon/urlmon.rc index 70d7aadfaa5..e0ed12ceb5c 100644 --- a/dlls/urlmon/urlmon.rc +++ b/dlls/urlmon/urlmon.rc @@ -50,6 +50,18 @@ STRINGTABLE IDS_AXINSTALL_FAILURE "Installation of component failed: %08x" IDS_AXINSTALL_INSTALLN "Install (%d)" IDS_AXINSTALL_INSTALL "Install" + + /* The English zone names and descriptions should be identical to the ones in urlmon.inf */ + IDS_SEC_ZONE0_NAME "My Computer" + IDS_SEC_ZONE0_DESC "Your computer" + IDS_SEC_ZONE1_NAME "Local intranet" + IDS_SEC_ZONE1_DESC "This zone contains all Web sites that are on your organization's intranet." + IDS_SEC_ZONE2_NAME "Trusted sites" + IDS_SEC_ZONE2_DESC "This zone contains Web sites that you trust not to damage your computer or data." + IDS_SEC_ZONE3_NAME "Internet" + IDS_SEC_ZONE3_DESC "This zone contains all Web sites you haven't placed in other zones" + IDS_SEC_ZONE4_NAME "Restricted sites" + IDS_SEC_ZONE4_DESC "This zone contains Web sites that could potentially damage your computer or data." }
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
This merge request was approved by Jacek Caban.