2004-09-28 21:18:52 +02:00
|
|
|
/*
|
2004-11-30 22:14:21 +01:00
|
|
|
* Internet Security and Zone Manager
|
2004-09-28 21:18:52 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Huw D M Davies
|
2004-11-30 22:14:21 +01:00
|
|
|
* Copyright 2004 Jacek Caban
|
2009-07-02 22:04:43 +02:00
|
|
|
* Copyright 2009 Detlef Riekenberg
|
2011-03-14 00:26:45 +01:00
|
|
|
* Copyright 2011 Thomas Mullaly for CodeWeavers
|
2004-09-28 21:18:52 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-09-28 21:18:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2007-12-13 20:26:51 +01:00
|
|
|
#include "urlmon_main.h"
|
2005-09-29 12:30:04 +02:00
|
|
|
#include "winreg.h"
|
2008-03-14 12:40:22 +01:00
|
|
|
#include "wininet.h"
|
2007-12-13 20:26:51 +01:00
|
|
|
|
2011-01-17 05:40:08 +01:00
|
|
|
#define NO_SHLWAPI_REG
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
|
|
|
|
2009-06-22 00:39:11 +02:00
|
|
|
static const WCHAR currentlevelW[] = {'C','u','r','r','e','n','t','L','e','v','e','l',0};
|
|
|
|
static const WCHAR descriptionW[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
|
|
|
|
static const WCHAR displaynameW[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
|
2008-03-14 12:40:22 +01:00
|
|
|
static const WCHAR fileW[] = {'f','i','l','e',0};
|
2009-06-22 00:39:11 +02:00
|
|
|
static const WCHAR flagsW[] = {'F','l','a','g','s',0};
|
|
|
|
static const WCHAR iconW[] = {'I','c','o','n',0};
|
|
|
|
static const WCHAR minlevelW[] = {'M','i','n','L','e','v','e','l',0};
|
|
|
|
static const WCHAR recommendedlevelW[] = {'R','e','c','o','m','m','e','n','d','e','d',
|
|
|
|
'L','e','v','e','l',0};
|
2009-07-02 22:04:43 +02:00
|
|
|
static const WCHAR wszZonesKey[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
|
|
|
|
'Z','o','n','e','s','\\',0};
|
2011-03-14 00:26:45 +01:00
|
|
|
static const WCHAR wszZoneMapDomainsKey[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
|
|
|
|
'Z','o','n','e','M','a','p','\\',
|
|
|
|
'D','o','m','a','i','n','s',0};
|
2009-06-22 00:39:11 +02:00
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
static inline BOOL is_drive_path(const WCHAR *path)
|
|
|
|
{
|
|
|
|
return isalphaW(*path) && *(path+1) == ':';
|
|
|
|
}
|
|
|
|
|
2009-06-22 00:39:11 +02:00
|
|
|
/********************************************************************
|
|
|
|
* get_string_from_reg [internal]
|
|
|
|
*
|
|
|
|
* helper to get a string from the reg.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void get_string_from_reg(HKEY hcu, HKEY hklm, LPCWSTR name, LPWSTR out, DWORD maxlen)
|
|
|
|
{
|
|
|
|
DWORD type = REG_SZ;
|
|
|
|
DWORD len = maxlen * sizeof(WCHAR);
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
res = RegQueryValueExW(hcu, name, NULL, &type, (LPBYTE) out, &len);
|
|
|
|
|
|
|
|
if (res && hklm) {
|
|
|
|
len = maxlen * sizeof(WCHAR);
|
|
|
|
type = REG_SZ;
|
|
|
|
res = RegQueryValueExW(hklm, name, NULL, &type, (LPBYTE) out, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
TRACE("%s failed: %d\n", debugstr_w(name), res);
|
|
|
|
*out = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* get_dword_from_reg [internal]
|
|
|
|
*
|
|
|
|
* helper to get a dword from the reg.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void get_dword_from_reg(HKEY hcu, HKEY hklm, LPCWSTR name, LPDWORD out)
|
|
|
|
{
|
|
|
|
DWORD type = REG_DWORD;
|
|
|
|
DWORD len = sizeof(DWORD);
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
res = RegQueryValueExW(hcu, name, NULL, &type, (LPBYTE) out, &len);
|
|
|
|
|
|
|
|
if (res && hklm) {
|
|
|
|
len = sizeof(DWORD);
|
|
|
|
type = REG_DWORD;
|
|
|
|
res = RegQueryValueExW(hklm, name, NULL, &type, (LPBYTE) out, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
TRACE("%s failed: %d\n", debugstr_w(name), res);
|
|
|
|
*out = 0;
|
|
|
|
}
|
|
|
|
}
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2008-03-14 12:40:22 +01:00
|
|
|
static HRESULT get_zone_from_reg(LPCWSTR schema, DWORD *zone)
|
2005-09-29 12:30:04 +02:00
|
|
|
{
|
2008-03-14 12:40:22 +01:00
|
|
|
DWORD res, size;
|
2005-09-29 12:30:04 +02:00
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
static const WCHAR wszZoneMapProtocolKey[] =
|
|
|
|
{'S','o','f','t','w','a','r','e','\\',
|
2008-03-14 12:40:22 +01:00
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
|
|
|
|
'Z','o','n','e','M','a','p','\\',
|
|
|
|
'P','r','o','t','o','c','o','l','D','e','f','a','u','l','t','s',0};
|
2005-09-29 12:30:04 +02:00
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, wszZoneMapProtocolKey, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
ERR("Could not open key %s\n", debugstr_w(wszZoneMapProtocolKey));
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
res = RegQueryValueExW(hkey, schema, NULL, NULL, (PBYTE)zone, &size);
|
2006-07-17 21:22:27 +02:00
|
|
|
RegCloseKey(hkey);
|
2005-09-29 12:30:04 +02:00
|
|
|
if(res == ERROR_SUCCESS)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_LOCAL_MACHINE, wszZoneMapProtocolKey, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
ERR("Could not open key %s\n", debugstr_w(wszZoneMapProtocolKey));
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
res = RegQueryValueExW(hkey, schema, NULL, NULL, (PBYTE)zone, &size);
|
2006-07-17 21:22:27 +02:00
|
|
|
RegCloseKey(hkey);
|
2005-09-29 12:30:04 +02:00
|
|
|
if(res == ERROR_SUCCESS)
|
2005-12-26 13:27:25 +01:00
|
|
|
return S_OK;
|
2005-09-29 12:30:04 +02:00
|
|
|
|
|
|
|
*zone = 3;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-03-14 00:26:45 +01:00
|
|
|
/********************************************************************
|
|
|
|
* matches_domain_pattern [internal]
|
|
|
|
*
|
|
|
|
* Checks if the given string matches the specified domain pattern.
|
|
|
|
*
|
|
|
|
* This function looks for explicit wildcard domain components iff
|
|
|
|
* they appear at the very beginning of the 'pattern' string
|
|
|
|
*
|
|
|
|
* pattern = "*.google.com"
|
|
|
|
*/
|
|
|
|
static BOOL matches_domain_pattern(LPCWSTR pattern, LPCWSTR str, BOOL implicit_wildcard, LPCWSTR *matched)
|
|
|
|
{
|
|
|
|
BOOL matches = FALSE;
|
|
|
|
DWORD pattern_len = strlenW(pattern);
|
|
|
|
DWORD str_len = strlenW(str);
|
|
|
|
|
|
|
|
TRACE("(%d) Checking if %s matches %s\n", implicit_wildcard, debugstr_w(str), debugstr_w(pattern));
|
|
|
|
|
|
|
|
*matched = NULL;
|
|
|
|
if(str_len >= pattern_len) {
|
|
|
|
/* Check if there's an explicit wildcard in the pattern. */
|
|
|
|
if(pattern[0] == '*' && pattern[1] == '.') {
|
|
|
|
/* Make sure that 'str' matches the wildcard pattern.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* pattern = "*.google.com"
|
|
|
|
*
|
|
|
|
* So in this case 'str' would have to end with ".google.com" in order
|
|
|
|
* to map to this pattern.
|
|
|
|
*/
|
|
|
|
if(str_len >= pattern_len+1 && !strcmpiW(str+(str_len-pattern_len+1), pattern+1)) {
|
|
|
|
/* Check if there's another '.' inside of the "unmatched" portion
|
|
|
|
* of 'str'.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* pattern = "*.google.com"
|
|
|
|
* str = "test.testing.google.com"
|
|
|
|
*
|
|
|
|
* The currently matched portion is ".google.com" in 'str', we need
|
|
|
|
* see if there's a '.' inside of the unmatched portion ("test.testing"), because
|
|
|
|
* if there is and 'implicit_wildcard' isn't set, then this isn't
|
|
|
|
* a match.
|
|
|
|
*/
|
|
|
|
const WCHAR *ptr;
|
|
|
|
if(str_len > pattern_len+1 && (ptr = memrchrW(str, '.', str_len-pattern_len-2))) {
|
|
|
|
if(implicit_wildcard) {
|
|
|
|
matches = TRUE;
|
|
|
|
*matched = ptr+1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
matches = TRUE;
|
|
|
|
*matched = str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(implicit_wildcard && str_len > pattern_len) {
|
|
|
|
/* When the pattern has an implicit wildcard component, it means
|
|
|
|
* that anything goes in 'str' as long as it ends with the pattern
|
|
|
|
* and that the beginning of the match has a '.' before it.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* pattern = "google.com"
|
|
|
|
* str = "www.google.com"
|
|
|
|
*
|
|
|
|
* Implicitly matches the pattern, where as:
|
|
|
|
*
|
|
|
|
* pattern = "google.com"
|
|
|
|
* str = "wwwgoogle.com"
|
|
|
|
*
|
|
|
|
* Doesn't match the pattern.
|
|
|
|
*/
|
|
|
|
if(str_len > pattern_len) {
|
|
|
|
if(str[str_len-pattern_len-1] == '.' && !strcmpiW(str+(str_len-pattern_len), pattern)) {
|
|
|
|
matches = TRUE;
|
|
|
|
*matched = str+(str_len-pattern_len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* The pattern doesn't have an implicit wildcard, or an explicit wildcard,
|
|
|
|
* so 'str' has to be an exact match to the 'pattern'.
|
|
|
|
*/
|
|
|
|
if(!strcmpiW(str, pattern)) {
|
|
|
|
matches = TRUE;
|
|
|
|
*matched = str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(matches)
|
|
|
|
TRACE("Found a match: matched=%s\n", debugstr_w(*matched));
|
|
|
|
else
|
|
|
|
TRACE("No match found\n");
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_zone_for_scheme(HKEY key, LPCWSTR schema, DWORD *zone)
|
|
|
|
{
|
|
|
|
static const WCHAR wildcardW[] = {'*',0};
|
|
|
|
|
|
|
|
DWORD res;
|
|
|
|
DWORD size = sizeof(DWORD);
|
|
|
|
DWORD type;
|
|
|
|
|
|
|
|
/* See if the key contains a value for the scheme first. */
|
|
|
|
res = RegQueryValueExW(key, schema, NULL, &type, (BYTE*)zone, &size);
|
2011-06-03 11:40:33 +02:00
|
|
|
if(res == ERROR_SUCCESS) {
|
|
|
|
if(type == REG_DWORD)
|
|
|
|
return TRUE;
|
2011-03-14 00:26:45 +01:00
|
|
|
WARN("Unexpected value type %d for value %s, expected REG_DWORD\n", type, debugstr_w(schema));
|
2011-06-03 11:40:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to get the zone for the wildcard scheme. */
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
res = RegQueryValueExW(key, wildcardW, NULL, &type, (BYTE*)zone, &size);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
2011-03-14 00:26:45 +01:00
|
|
|
|
2011-06-03 11:40:33 +02:00
|
|
|
if(type != REG_DWORD) {
|
|
|
|
WARN("Unexpected value type %d for value %s, expected REG_DWORD\n", type, debugstr_w(wildcardW));
|
|
|
|
return FALSE;
|
2011-03-14 00:26:45 +01:00
|
|
|
}
|
|
|
|
|
2011-06-03 11:40:33 +02:00
|
|
|
return TRUE;
|
2011-03-14 00:26:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* search_domain_for_zone [internal]
|
|
|
|
*
|
|
|
|
* Searches the specified 'domain' registry key to see if 'host' maps into it, or any
|
|
|
|
* of it's subdomain registry keys.
|
|
|
|
*
|
|
|
|
* Returns S_OK if a match is found, S_FALSE if no matches were found, or an error code.
|
|
|
|
*/
|
|
|
|
static HRESULT search_domain_for_zone(HKEY domains, LPCWSTR domain, DWORD domain_len, LPCWSTR schema,
|
|
|
|
LPCWSTR host, DWORD host_len, DWORD *zone)
|
|
|
|
{
|
|
|
|
BOOL found = FALSE;
|
|
|
|
HKEY domain_key;
|
|
|
|
DWORD res;
|
|
|
|
LPCWSTR matched;
|
|
|
|
|
|
|
|
if(host_len >= domain_len && matches_domain_pattern(domain, host, TRUE, &matched)) {
|
|
|
|
res = RegOpenKeyW(domains, domain, &domain_key);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
ERR("Failed to open domain key %s: %d\n", debugstr_w(domain), res);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(matched == host)
|
|
|
|
found = get_zone_for_scheme(domain_key, schema, zone);
|
|
|
|
else {
|
|
|
|
INT domain_offset;
|
|
|
|
DWORD subdomain_count, subdomain_len;
|
|
|
|
BOOL check_domain = TRUE;
|
|
|
|
|
|
|
|
find_domain_name(domain, domain_len, &domain_offset);
|
|
|
|
|
|
|
|
res = RegQueryInfoKeyW(domain_key, NULL, NULL, NULL, &subdomain_count, &subdomain_len,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
ERR("Unable to query info for key %s: %d\n", debugstr_w(domain), res);
|
|
|
|
RegCloseKey(domain_key);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(subdomain_count) {
|
|
|
|
WCHAR *subdomain;
|
|
|
|
WCHAR *component;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
subdomain = heap_alloc((subdomain_len+1)*sizeof(WCHAR));
|
|
|
|
if(!subdomain) {
|
|
|
|
RegCloseKey(domain_key);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
component = heap_strndupW(host, matched-host-1);
|
|
|
|
if(!component) {
|
|
|
|
heap_free(subdomain);
|
|
|
|
RegCloseKey(domain_key);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < subdomain_count; ++i) {
|
|
|
|
DWORD len = subdomain_len+1;
|
|
|
|
const WCHAR *sub_matched;
|
|
|
|
|
|
|
|
res = RegEnumKeyExW(domain_key, i, subdomain, &len, NULL, NULL, NULL, NULL);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
heap_free(component);
|
|
|
|
heap_free(subdomain);
|
|
|
|
RegCloseKey(domain_key);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(matches_domain_pattern(subdomain, component, FALSE, &sub_matched)) {
|
|
|
|
HKEY subdomain_key;
|
|
|
|
|
|
|
|
res = RegOpenKeyW(domain_key, subdomain, &subdomain_key);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
ERR("Unable to open subdomain key %s of %s: %d\n", debugstr_w(subdomain),
|
|
|
|
debugstr_w(domain), res);
|
|
|
|
heap_free(component);
|
|
|
|
heap_free(subdomain);
|
|
|
|
RegCloseKey(domain_key);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
found = get_zone_for_scheme(subdomain_key, schema, zone);
|
|
|
|
check_domain = FALSE;
|
|
|
|
RegCloseKey(subdomain_key);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
heap_free(subdomain);
|
|
|
|
heap_free(component);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There's a chance that 'host' implicitly mapped into 'domain', in
|
|
|
|
* which case we check to see if 'domain' contains zone information.
|
|
|
|
*
|
|
|
|
* This can only happen if 'domain' is it's own domain name.
|
|
|
|
* Example:
|
|
|
|
* "google.com" (domain name = "google.com")
|
|
|
|
*
|
|
|
|
* So if:
|
|
|
|
* host = "www.google.com"
|
|
|
|
*
|
|
|
|
* Then host would map directly into the "google.com" domain key.
|
|
|
|
*
|
|
|
|
* If 'domain' has more than just it's domain name, or it does not
|
|
|
|
* have a domain name, then we don't perform the check. The reason
|
|
|
|
* for this is that these domains don't allow implicit mappings.
|
|
|
|
* Example:
|
|
|
|
* domain = "org" (has no domain name)
|
|
|
|
* host = "www.org"
|
|
|
|
*
|
|
|
|
* The mapping would only happen if the "org" key had an explicit subkey
|
|
|
|
* called "www".
|
|
|
|
*/
|
|
|
|
if(check_domain && !domain_offset && !strchrW(host, matched-host-1))
|
|
|
|
found = get_zone_for_scheme(domain_key, schema, zone);
|
|
|
|
}
|
|
|
|
RegCloseKey(domain_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
return found ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT search_for_domain_mapping(HKEY domains, LPCWSTR schema, LPCWSTR host, DWORD host_len, DWORD *zone)
|
|
|
|
{
|
|
|
|
WCHAR *domain;
|
|
|
|
DWORD domain_count, domain_len, i;
|
|
|
|
DWORD res;
|
|
|
|
HRESULT hres = S_FALSE;
|
|
|
|
|
|
|
|
res = RegQueryInfoKeyW(domains, NULL, NULL, NULL, &domain_count, &domain_len,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
WARN("Failed to retrieve information about key\n");
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!domain_count)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
domain = heap_alloc((domain_len+1)*sizeof(WCHAR));
|
|
|
|
if(!domain)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
for(i = 0; i < domain_count; ++i) {
|
|
|
|
DWORD len = domain_len+1;
|
|
|
|
|
|
|
|
res = RegEnumKeyExW(domains, i, domain, &len, NULL, NULL, NULL, NULL);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
heap_free(domain);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = search_domain_for_zone(domains, domain, len, schema, host, host_len, zone);
|
|
|
|
if(FAILED(hres) || hres == S_OK)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(domain);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-09-05 02:56:09 +02:00
|
|
|
static HRESULT get_zone_from_domains(IUri *uri, DWORD *zone)
|
2011-03-14 00:26:45 +01:00
|
|
|
{
|
|
|
|
HRESULT hres;
|
2011-09-05 02:56:09 +02:00
|
|
|
BSTR host, scheme;
|
2011-03-14 00:26:45 +01:00
|
|
|
DWORD res;
|
|
|
|
HKEY domains;
|
2011-09-05 02:56:09 +02:00
|
|
|
DWORD scheme_type;
|
2011-03-14 00:26:45 +01:00
|
|
|
|
2011-09-05 02:56:09 +02:00
|
|
|
hres = IUri_GetScheme(uri, &scheme_type);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2011-03-14 00:26:45 +01:00
|
|
|
|
|
|
|
/* Windows doesn't play nice with unknown scheme types when it tries
|
|
|
|
* to check if a host name maps into any domains.
|
|
|
|
*/
|
2011-09-05 02:56:09 +02:00
|
|
|
if(scheme_type == URL_SCHEME_UNKNOWN)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
hres = IUri_GetHost(uri, &host);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IUri_GetSchemeName(uri, &scheme);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SysFreeString(host);
|
2011-03-14 00:26:45 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First try CURRENT_USER. */
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, wszZoneMapDomainsKey, &domains);
|
|
|
|
if(res == ERROR_SUCCESS) {
|
2011-09-05 02:56:09 +02:00
|
|
|
hres = search_for_domain_mapping(domains, scheme, host, SysStringLen(host), zone);
|
2011-03-14 00:26:45 +01:00
|
|
|
RegCloseKey(domains);
|
|
|
|
} else
|
|
|
|
WARN("Failed to open HKCU's %s key\n", debugstr_w(wszZoneMapDomainsKey));
|
|
|
|
|
|
|
|
/* If that doesn't work try LOCAL_MACHINE. */
|
|
|
|
if(hres == S_FALSE) {
|
|
|
|
res = RegOpenKeyW(HKEY_LOCAL_MACHINE, wszZoneMapDomainsKey, &domains);
|
|
|
|
if(res == ERROR_SUCCESS) {
|
2011-09-05 02:56:09 +02:00
|
|
|
hres = search_for_domain_mapping(domains, scheme, host, SysStringLen(host), zone);
|
2011-03-14 00:26:45 +01:00
|
|
|
RegCloseKey(domains);
|
|
|
|
} else
|
|
|
|
WARN("Failed to open HKLM's %s key\n", debugstr_w(wszZoneMapDomainsKey));
|
|
|
|
}
|
|
|
|
|
2011-09-05 02:56:09 +02:00
|
|
|
SysFreeString(host);
|
|
|
|
SysFreeString(scheme);
|
2011-03-14 00:26:45 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
static HRESULT map_security_uri_to_zone(IUri *uri, DWORD *zone)
|
2008-03-14 12:40:22 +01:00
|
|
|
{
|
|
|
|
HRESULT hres;
|
2011-08-23 02:51:59 +02:00
|
|
|
BSTR scheme;
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-02-08 15:09:06 +01:00
|
|
|
*zone = URLZONE_INVALID;
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
hres = IUri_GetSchemeName(uri, &scheme);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
if(!strcmpiW(scheme, fileW)) {
|
|
|
|
BSTR path;
|
|
|
|
WCHAR *ptr, *path_start, root[20];
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
hres = IUri_GetPath(uri, &path);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SysFreeString(scheme);
|
|
|
|
return hres;
|
|
|
|
}
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
if(*path == '/' && is_drive_path(path+1))
|
|
|
|
path_start = path+1;
|
|
|
|
else
|
|
|
|
path_start = path;
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
if(((ptr = strchrW(path_start, '\\')) || (ptr = strchrW(path_start, '/'))) && ptr-path_start < sizeof(root)/sizeof(WCHAR)) {
|
2008-03-14 12:41:27 +01:00
|
|
|
UINT type;
|
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
memcpy(root, path_start, (ptr-path_start)*sizeof(WCHAR));
|
|
|
|
root[ptr-path_start] = 0;
|
2008-03-14 12:41:27 +01:00
|
|
|
|
|
|
|
type = GetDriveTypeW(root);
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case DRIVE_UNKNOWN:
|
|
|
|
case DRIVE_NO_ROOT_DIR:
|
|
|
|
break;
|
|
|
|
case DRIVE_REMOVABLE:
|
|
|
|
case DRIVE_FIXED:
|
|
|
|
case DRIVE_CDROM:
|
|
|
|
case DRIVE_RAMDISK:
|
2011-02-08 15:09:06 +01:00
|
|
|
*zone = URLZONE_LOCAL_MACHINE;
|
2008-03-14 12:41:27 +01:00
|
|
|
hres = S_OK;
|
|
|
|
break;
|
|
|
|
case DRIVE_REMOTE:
|
2011-02-08 15:09:06 +01:00
|
|
|
*zone = URLZONE_INTERNET;
|
2008-03-14 12:41:27 +01:00
|
|
|
hres = S_OK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unsupported drive type %d\n", type);
|
|
|
|
}
|
|
|
|
}
|
2011-08-23 02:51:59 +02:00
|
|
|
SysFreeString(path);
|
2008-03-14 12:40:22 +01:00
|
|
|
}
|
|
|
|
|
2011-02-08 15:09:06 +01:00
|
|
|
if(*zone == URLZONE_INVALID) {
|
2011-09-05 02:56:09 +02:00
|
|
|
hres = get_zone_from_domains(uri, zone);
|
2011-03-14 00:26:45 +01:00
|
|
|
if(hres == S_FALSE)
|
2011-08-23 02:51:59 +02:00
|
|
|
hres = get_zone_from_reg(scheme, zone);
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(scheme);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone, LPWSTR *ret_url)
|
|
|
|
{
|
|
|
|
IUri *secur_uri;
|
|
|
|
LPWSTR secur_url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
*zone = URLZONE_INVALID;
|
|
|
|
|
|
|
|
hres = CoInternetGetSecurityUrl(url, &secur_url, PSU_SECURITY_URL_ONLY, 0);
|
|
|
|
if(hres != S_OK) {
|
|
|
|
DWORD size = strlenW(url)*sizeof(WCHAR);
|
|
|
|
|
|
|
|
secur_url = CoTaskMemAlloc(size);
|
|
|
|
if(!secur_url)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(secur_url, url, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CreateUri(secur_url, 0, 0, &secur_uri);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
CoTaskMemFree(secur_url);
|
|
|
|
return hres;
|
2008-03-14 12:40:22 +01:00
|
|
|
}
|
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
hres = map_security_uri_to_zone(secur_uri, zone);
|
|
|
|
IUri_Release(secur_uri);
|
|
|
|
|
2008-03-14 12:40:22 +01:00
|
|
|
if(FAILED(hres) || !ret_url)
|
2011-09-01 00:44:28 +02:00
|
|
|
CoTaskMemFree(secur_url);
|
2008-03-14 12:40:22 +01:00
|
|
|
else
|
|
|
|
*ret_url = secur_url;
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-08-23 02:51:59 +02:00
|
|
|
static HRESULT map_uri_to_zone(IUri *uri, DWORD *zone)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
IUri *secur_uri;
|
|
|
|
|
|
|
|
hres = CoInternetGetSecurityUrlEx(uri, &secur_uri, PSU_SECURITY_URL_ONLY, 0);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = map_security_uri_to_zone(secur_uri, zone);
|
|
|
|
IUri_Release(secur_uri);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-03-14 12:41:50 +01:00
|
|
|
static HRESULT open_zone_key(HKEY parent_key, DWORD zone, HKEY *hkey)
|
|
|
|
{
|
2011-01-22 01:52:47 +01:00
|
|
|
static const WCHAR wszFormat[] = {'%','s','%','u',0};
|
2008-03-14 12:41:50 +01:00
|
|
|
|
2011-01-22 01:52:47 +01:00
|
|
|
WCHAR key_name[sizeof(wszZonesKey)/sizeof(WCHAR)+12];
|
2008-03-14 12:41:50 +01:00
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
wsprintfW(key_name, wszFormat, wszZonesKey, zone);
|
|
|
|
|
|
|
|
res = RegOpenKeyW(parent_key, key_name, hkey);
|
|
|
|
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
WARN("RegOpenKey failed\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT get_action_policy(DWORD zone, DWORD action, BYTE *policy, DWORD size, URLZONEREG zone_reg)
|
|
|
|
{
|
|
|
|
HKEY parent_key;
|
|
|
|
HKEY hkey;
|
|
|
|
LONG res;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2008-03-14 12:42:42 +01:00
|
|
|
switch(action) {
|
|
|
|
case URLACTION_SCRIPT_OVERRIDE_SAFETY:
|
2009-10-01 00:00:53 +02:00
|
|
|
case URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY:
|
2008-03-14 12:42:42 +01:00
|
|
|
*(DWORD*)policy = URLPOLICY_DISALLOW;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-14 12:41:50 +01:00
|
|
|
switch(zone_reg) {
|
|
|
|
case URLZONEREG_DEFAULT:
|
|
|
|
case URLZONEREG_HKCU:
|
|
|
|
parent_key = HKEY_CURRENT_USER;
|
|
|
|
break;
|
|
|
|
case URLZONEREG_HKLM:
|
|
|
|
parent_key = HKEY_LOCAL_MACHINE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Unknown URLZONEREG: %d\n", zone_reg);
|
|
|
|
return E_FAIL;
|
|
|
|
};
|
|
|
|
|
|
|
|
hres = open_zone_key(parent_key, zone, &hkey);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
WCHAR action_str[16];
|
|
|
|
DWORD len = size;
|
|
|
|
|
|
|
|
static const WCHAR formatW[] = {'%','X',0};
|
|
|
|
|
|
|
|
wsprintfW(action_str, formatW, action);
|
|
|
|
|
|
|
|
res = RegQueryValueExW(hkey, action_str, NULL, NULL, policy, &len);
|
|
|
|
if(res == ERROR_MORE_DATA) {
|
|
|
|
hres = E_INVALIDARG;
|
|
|
|
}else if(res == ERROR_FILE_NOT_FOUND) {
|
|
|
|
hres = E_FAIL;
|
|
|
|
}else if(res != ERROR_SUCCESS) {
|
|
|
|
ERR("RegQueryValue failed: %d\n", res);
|
|
|
|
hres = E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(hres) && zone_reg == URLZONEREG_DEFAULT)
|
|
|
|
return get_action_policy(zone, action, policy, size, URLZONEREG_HKLM);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-09-01 00:31:35 +02:00
|
|
|
static HRESULT get_security_id(LPCWSTR url, BYTE *secid, DWORD *secid_len)
|
|
|
|
{
|
|
|
|
LPWSTR secur_url, ptr, ptr2;
|
|
|
|
DWORD zone, len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e',':'};
|
|
|
|
|
|
|
|
hres = map_url_to_zone(url, &zone, &secur_url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres == 0x80041001 ? E_INVALIDARG : hres;
|
|
|
|
|
|
|
|
/* file protocol is a special case */
|
|
|
|
if(strlenW(secur_url) >= sizeof(wszFile)/sizeof(WCHAR)
|
|
|
|
&& !memcmp(secur_url, wszFile, sizeof(wszFile))) {
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
len = sizeof(path)/sizeof(WCHAR);
|
|
|
|
|
|
|
|
hres = CoInternetParseUrl(secur_url, PARSE_PATH_FROM_URL, 0, path, len, &len, 0);
|
|
|
|
if(hres == S_OK && !PathIsNetworkPathW(path)) {
|
|
|
|
static const BYTE secidFile[] = {'f','i','l','e',':'};
|
|
|
|
|
|
|
|
CoTaskMemFree(secur_url);
|
|
|
|
|
|
|
|
if(*secid_len < sizeof(secidFile)+sizeof(zone))
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
|
|
|
|
memcpy(secid, secidFile, sizeof(secidFile));
|
|
|
|
*(DWORD*)(secid+sizeof(secidFile)) = zone;
|
|
|
|
|
|
|
|
*secid_len = sizeof(secidFile)+sizeof(zone);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = strchrW(secur_url, ':');
|
|
|
|
ptr2 = ++ptr;
|
|
|
|
while(*ptr2 == '/')
|
|
|
|
ptr2++;
|
|
|
|
if(ptr2 != ptr)
|
|
|
|
memmove(ptr, ptr2, (strlenW(ptr2)+1)*sizeof(WCHAR));
|
|
|
|
|
|
|
|
ptr = strchrW(ptr, '/');
|
|
|
|
if(ptr)
|
|
|
|
*ptr = 0;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, secur_url, -1, NULL, 0, NULL, NULL)-1;
|
|
|
|
|
|
|
|
if(len+sizeof(DWORD) > *secid_len) {
|
|
|
|
CoTaskMemFree(secur_url);
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
}
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, secur_url, -1, (LPSTR)secid, len, NULL, NULL);
|
|
|
|
CoTaskMemFree(secur_url);
|
|
|
|
|
|
|
|
*(DWORD*)(secid+len) = zone;
|
|
|
|
|
|
|
|
*secid_len = len+sizeof(DWORD);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-14 12:40:22 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetSecurityManager implementation
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2011-08-21 05:58:44 +02:00
|
|
|
IInternetSecurityManagerEx2 IInternetSecurityManagerEx2_iface;
|
2008-03-14 12:40:22 +01:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IInternetSecurityMgrSite *mgrsite;
|
|
|
|
IInternetSecurityManager *custom_manager;
|
|
|
|
} SecManagerImpl;
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static inline SecManagerImpl *impl_from_IInternetSecurityManagerEx2(IInternetSecurityManagerEx2 *iface)
|
2010-12-06 23:34:25 +01:00
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
return CONTAINING_RECORD(iface, SecManagerImpl, IInternetSecurityManagerEx2_iface);
|
2010-12-06 23:34:25 +01:00
|
|
|
}
|
2008-03-14 12:40:22 +01:00
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManagerEx2* iface,REFIID riid,void** ppvObject)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2004-09-28 21:18:52 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
|
|
|
|
/* Perform a sanity check on the parameters.*/
|
|
|
|
if ( (This==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* Initialize the return parameter */
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
/* Compare the riid with the interface IDs implemented by this object.*/
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) ||
|
2011-08-21 05:58:44 +02:00
|
|
|
IsEqualIID(&IID_IInternetSecurityManager, riid) ||
|
|
|
|
IsEqualIID(&IID_IInternetSecurityManagerEx, riid) ||
|
|
|
|
IsEqualIID(&IID_IInternetSecurityManagerEx2, riid))
|
2004-09-28 21:18:52 +02:00
|
|
|
*ppvObject = iface;
|
|
|
|
|
|
|
|
/* Check that we obtained an interface.*/
|
2005-09-07 11:23:18 +02:00
|
|
|
if (!*ppvObject) {
|
|
|
|
WARN("not supported interface %s\n", debugstr_guid(riid));
|
2004-09-28 21:18:52 +02:00
|
|
|
return E_NOINTERFACE;
|
2005-09-07 11:23:18 +02:00
|
|
|
}
|
2004-09-28 21:18:52 +02:00
|
|
|
|
|
|
|
/* Query Interface always increases the reference count by one when it is successful */
|
2004-11-30 22:14:21 +01:00
|
|
|
IInternetSecurityManager_AddRef(iface);
|
2004-09-28 21:18:52 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManagerEx2* iface)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-01-12 20:52:38 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%u\n", This, refCount);
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2005-01-12 20:52:38 +01:00
|
|
|
return refCount;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManagerEx2* iface)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-01-12 20:52:38 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%u\n", This, refCount);
|
2004-09-28 21:18:52 +02:00
|
|
|
|
|
|
|
/* destroy the object if there's no more reference on it */
|
2005-01-12 20:52:38 +01:00
|
|
|
if (!refCount){
|
2005-09-07 11:23:18 +02:00
|
|
|
if(This->mgrsite)
|
|
|
|
IInternetSecurityMgrSite_Release(This->mgrsite);
|
|
|
|
if(This->custom_manager)
|
|
|
|
IInternetSecurityManager_Release(This->custom_manager);
|
|
|
|
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
2005-07-02 12:49:56 +02:00
|
|
|
URLMON_UnlockModule();
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
2005-02-03 20:38:37 +01:00
|
|
|
|
2005-01-12 20:52:38 +01:00
|
|
|
return refCount;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManagerEx2 *iface,
|
2004-09-28 21:18:52 +02:00
|
|
|
IInternetSecurityMgrSite *pSite)
|
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pSite);
|
|
|
|
|
|
|
|
if(This->mgrsite)
|
|
|
|
IInternetSecurityMgrSite_Release(This->mgrsite);
|
|
|
|
|
|
|
|
if(This->custom_manager) {
|
|
|
|
IInternetSecurityManager_Release(This->custom_manager);
|
|
|
|
This->custom_manager = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->mgrsite = pSite;
|
|
|
|
|
|
|
|
if(pSite) {
|
|
|
|
IServiceProvider *servprov;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
IInternetSecurityMgrSite_AddRef(pSite);
|
|
|
|
|
|
|
|
hres = IInternetSecurityMgrSite_QueryInterface(pSite, &IID_IServiceProvider,
|
|
|
|
(void**)&servprov);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IServiceProvider_QueryService(servprov, &SID_SInternetSecurityManager,
|
|
|
|
&IID_IInternetSecurityManager, (void**)&This->custom_manager);
|
|
|
|
IServiceProvider_Release(servprov);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManagerEx2 *iface,
|
2004-09-28 21:18:52 +02:00
|
|
|
IInternetSecurityMgrSite **ppSite)
|
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppSite);
|
|
|
|
|
|
|
|
if(!ppSite)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(This->mgrsite)
|
|
|
|
IInternetSecurityMgrSite_AddRef(This->mgrsite);
|
|
|
|
|
|
|
|
*ppSite = This->mgrsite;
|
|
|
|
return S_OK;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManagerEx2 *iface,
|
2004-09-28 21:18:52 +02:00
|
|
|
LPCWSTR pwszUrl, DWORD *pdwZone,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-09-07 11:23:18 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%s %p %08x)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(This->custom_manager) {
|
|
|
|
hres = IInternetSecurityManager_MapUrlToZone(This->custom_manager,
|
|
|
|
pwszUrl, pdwZone, dwFlags);
|
|
|
|
if(hres != INET_E_DEFAULT_ACTION)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:50:02 +02:00
|
|
|
if(!pwszUrl) {
|
2011-02-08 15:09:06 +01:00
|
|
|
*pdwZone = URLZONE_INVALID;
|
2005-09-29 12:30:04 +02:00
|
|
|
return E_INVALIDARG;
|
2007-10-07 17:50:02 +02:00
|
|
|
}
|
2005-09-29 12:30:04 +02:00
|
|
|
|
|
|
|
if(dwFlags)
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("not supported flags: %08x\n", dwFlags);
|
2005-09-29 12:30:04 +02:00
|
|
|
|
2008-03-14 12:40:22 +01:00
|
|
|
return map_url_to_zone(pwszUrl, pdwZone, NULL);
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManagerEx2 *iface,
|
2005-12-26 13:27:25 +01:00
|
|
|
LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-12-26 13:27:25 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId,
|
|
|
|
pcbSecurityId, dwReserved);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(This->custom_manager) {
|
2011-09-01 00:31:35 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2005-09-07 11:23:18 +02:00
|
|
|
hres = IInternetSecurityManager_GetSecurityId(This->custom_manager,
|
|
|
|
pwszUrl, pbSecurityId, pcbSecurityId, dwReserved);
|
|
|
|
if(hres != INET_E_DEFAULT_ACTION)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2005-12-26 13:27:25 +01:00
|
|
|
if(!pwszUrl || !pbSecurityId || !pcbSecurityId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(dwReserved)
|
|
|
|
FIXME("dwReserved is not supported\n");
|
|
|
|
|
2011-09-01 00:31:35 +02:00
|
|
|
return get_security_id(pwszUrl, pbSecurityId, pcbSecurityId);
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManagerEx2 *iface,
|
2004-09-28 21:18:52 +02:00
|
|
|
LPCWSTR pwszUrl, DWORD dwAction,
|
|
|
|
BYTE *pPolicy, DWORD cbPolicy,
|
|
|
|
BYTE *pContext, DWORD cbContext,
|
|
|
|
DWORD dwFlags, DWORD dwReserved)
|
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2008-03-14 12:42:07 +01:00
|
|
|
DWORD zone, policy;
|
2005-09-07 11:23:18 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%s %08x %p %08x %p %08x %08x %08x)\n", iface, debugstr_w(pwszUrl), dwAction,
|
2004-09-28 21:18:52 +02:00
|
|
|
pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(This->custom_manager) {
|
|
|
|
hres = IInternetSecurityManager_ProcessUrlAction(This->custom_manager, pwszUrl, dwAction,
|
|
|
|
pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
|
|
|
|
if(hres != INET_E_DEFAULT_ACTION)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2009-09-30 23:59:47 +02:00
|
|
|
if(dwFlags || dwReserved)
|
2008-03-14 12:42:07 +01:00
|
|
|
FIXME("Unsupported arguments\n");
|
|
|
|
|
|
|
|
if(!pwszUrl)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hres = map_url_to_zone(pwszUrl, &zone, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = get_action_policy(zone, dwAction, (BYTE*)&policy, sizeof(policy), URLZONEREG_DEFAULT);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
TRACE("policy %x\n", policy);
|
2009-09-30 23:59:47 +02:00
|
|
|
if(cbPolicy >= sizeof(DWORD))
|
|
|
|
*(DWORD*)pPolicy = policy;
|
2008-03-14 12:42:07 +01:00
|
|
|
|
|
|
|
switch(GetUrlPolicyPermissions(policy)) {
|
|
|
|
case URLPOLICY_ALLOW:
|
|
|
|
case URLPOLICY_CHANNEL_SOFTDIST_PRECACHE:
|
|
|
|
return S_OK;
|
|
|
|
case URLPOLICY_DISALLOW:
|
|
|
|
return S_FALSE;
|
|
|
|
case URLPOLICY_QUERY:
|
|
|
|
FIXME("URLPOLICY_QUERY not implemented\n");
|
|
|
|
return E_FAIL;
|
|
|
|
default:
|
|
|
|
FIXME("Not implemented policy %x\n", policy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManagerEx2 *iface,
|
2004-09-28 21:18:52 +02:00
|
|
|
LPCWSTR pwszUrl, REFGUID guidKey,
|
|
|
|
BYTE **ppPolicy, DWORD *pcbPolicy,
|
|
|
|
BYTE *pContext, DWORD cbContext,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-09-07 11:23:18 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%s %s %p %p %p %08x %08x )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
|
2004-09-28 21:18:52 +02:00
|
|
|
ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(This->custom_manager) {
|
|
|
|
hres = IInternetSecurityManager_QueryCustomPolicy(This->custom_manager, pwszUrl, guidKey,
|
|
|
|
ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
|
|
|
|
if(hres != INET_E_DEFAULT_ACTION)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2009-10-01 00:00:33 +02:00
|
|
|
WARN("Unknown guidKey %s\n", debugstr_guid(guidKey));
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManagerEx2 *iface,
|
2004-09-28 21:18:52 +02:00
|
|
|
DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
|
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-09-07 11:23:18 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%08x %s %08x)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(This->custom_manager) {
|
|
|
|
hres = IInternetSecurityManager_SetZoneMapping(This->custom_manager, dwZone,
|
|
|
|
pwszPattern, dwFlags);
|
|
|
|
if(hres != INET_E_DEFAULT_ACTION)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Default action is not implemented\n");
|
2004-09-28 21:18:52 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManagerEx2 *iface,
|
2005-09-07 11:23:18 +02:00
|
|
|
DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2005-09-07 11:23:18 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%08x %p %08x)\n", iface, dwZone, ppenumString,dwFlags);
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(This->custom_manager) {
|
|
|
|
hres = IInternetSecurityManager_GetZoneMappings(This->custom_manager, dwZone,
|
|
|
|
ppenumString, dwFlags);
|
|
|
|
if(hres != INET_E_DEFAULT_ACTION)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Default action is not implemented\n");
|
2004-09-28 21:18:52 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-08-21 05:58:44 +02:00
|
|
|
static HRESULT WINAPI SecManagerImpl_ProcessUrlActionEx(IInternetSecurityManagerEx2 *iface,
|
|
|
|
LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext,
|
|
|
|
DWORD dwFlags, DWORD dwReserved, DWORD *pdwOutFlags)
|
|
|
|
{
|
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
|
|
|
FIXME("(%p)->(%s %08x %p %d %p %d %08x %08x %p) stub\n", This, debugstr_w(pwszUrl), dwAction, pPolicy, cbPolicy,
|
|
|
|
pContext, cbContext, dwFlags, dwReserved, pdwOutFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecManagerImpl_MapUrlToZoneEx2(IInternetSecurityManagerEx2 *iface,
|
|
|
|
IUri *pUri, DWORD *pdwZone, DWORD dwFlags, LPWSTR *ppwszMappedUrl, DWORD *pdwOutFlags)
|
|
|
|
{
|
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
2011-08-23 02:51:59 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %08x %p %p)\n", This, pUri, pdwZone, dwFlags, ppwszMappedUrl, pdwOutFlags);
|
|
|
|
|
|
|
|
if(!pdwZone)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(!pUri) {
|
|
|
|
*pdwZone = URLZONE_INVALID;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dwFlags)
|
|
|
|
FIXME("Unsupported flags: %08x\n", dwFlags);
|
|
|
|
|
|
|
|
return map_uri_to_zone(pUri, pdwZone);
|
2011-08-21 05:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecManagerImpl_ProcessUrlActionEx2(IInternetSecurityManagerEx2 *iface,
|
|
|
|
IUri *pUri, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext,
|
|
|
|
DWORD dwFlags, DWORD_PTR dwReserved, DWORD *pdwOutFlags)
|
|
|
|
{
|
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
|
|
|
FIXME("(%p)->(%p %08x %p %d %p %d %08x %08x %p) stub\n", This, pUri, dwAction, pPolicy,
|
|
|
|
cbPolicy, pContext, cbContext, dwFlags, (DWORD)dwReserved, pdwOutFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecManagerImpl_GetSecurityIdEx2(IInternetSecurityManagerEx2 *iface,
|
|
|
|
IUri *pUri, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
|
|
|
{
|
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
|
|
|
FIXME("(%p)->(%p %p %p %08x) stub\n", This, pUri, pbSecurityId, pcbSecurityId, (DWORD)dwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecManagerImpl_QueryCustomPolicyEx2(IInternetSecurityManagerEx2 *iface,
|
|
|
|
IUri *pUri, REFGUID guidKey, BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext,
|
|
|
|
DWORD cbContext, DWORD_PTR dwReserved)
|
|
|
|
{
|
|
|
|
SecManagerImpl *This = impl_from_IInternetSecurityManagerEx2(iface);
|
|
|
|
FIXME("(%p)->(%p %s %p %p %p %d %08x) stub\n", This, pUri, debugstr_guid(guidKey), ppPolicy, pcbPolicy,
|
|
|
|
pContext, cbContext, (DWORD)dwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetSecurityManagerEx2Vtbl VT_SecManagerImpl =
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
|
|
|
SecManagerImpl_QueryInterface,
|
|
|
|
SecManagerImpl_AddRef,
|
|
|
|
SecManagerImpl_Release,
|
|
|
|
SecManagerImpl_SetSecuritySite,
|
|
|
|
SecManagerImpl_GetSecuritySite,
|
|
|
|
SecManagerImpl_MapUrlToZone,
|
|
|
|
SecManagerImpl_GetSecurityId,
|
|
|
|
SecManagerImpl_ProcessUrlAction,
|
|
|
|
SecManagerImpl_QueryCustomPolicy,
|
|
|
|
SecManagerImpl_SetZoneMapping,
|
2011-08-21 05:58:44 +02:00
|
|
|
SecManagerImpl_GetZoneMappings,
|
|
|
|
SecManagerImpl_ProcessUrlActionEx,
|
|
|
|
SecManagerImpl_MapUrlToZoneEx2,
|
|
|
|
SecManagerImpl_ProcessUrlActionEx2,
|
|
|
|
SecManagerImpl_GetSecurityIdEx2,
|
|
|
|
SecManagerImpl_QueryCustomPolicyEx2
|
2004-11-30 22:14:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
SecManagerImpl *This;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n",pUnkOuter,ppobj);
|
2007-11-29 22:12:34 +01:00
|
|
|
This = heap_alloc(sizeof(*This));
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
/* Initialize the virtual function table. */
|
2011-08-21 05:58:44 +02:00
|
|
|
This->IInternetSecurityManagerEx2_iface.lpVtbl = &VT_SecManagerImpl;
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
This->ref = 1;
|
|
|
|
This->mgrsite = NULL;
|
|
|
|
This->custom_manager = NULL;
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
*ppobj = This;
|
2005-07-02 12:49:56 +02:00
|
|
|
|
|
|
|
URLMON_LockModule();
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetZoneManager implementation
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2010-12-06 23:34:25 +01:00
|
|
|
IInternetZoneManagerEx2 IInternetZoneManagerEx2_iface;
|
2005-07-03 14:05:03 +02:00
|
|
|
LONG ref;
|
2009-07-02 22:04:43 +02:00
|
|
|
LPDWORD *zonemaps;
|
|
|
|
DWORD zonemap_count;
|
2004-11-30 22:14:21 +01:00
|
|
|
} ZoneMgrImpl;
|
|
|
|
|
2010-12-06 23:34:25 +01:00
|
|
|
static inline ZoneMgrImpl *impl_from_IInternetZoneManagerEx2(IInternetZoneManagerEx2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ZoneMgrImpl, IInternetZoneManagerEx2_iface);
|
|
|
|
}
|
|
|
|
|
2009-07-02 22:04:43 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* build_zonemap_from_reg [internal]
|
|
|
|
*
|
|
|
|
* Enumerate the Zones in the Registry and return the Zones in a DWORD-array
|
|
|
|
* The number of the Zones is returned in data[0]
|
|
|
|
*/
|
|
|
|
static LPDWORD build_zonemap_from_reg(void)
|
|
|
|
{
|
|
|
|
WCHAR name[32];
|
|
|
|
HKEY hkey;
|
|
|
|
LPDWORD data = NULL;
|
2009-08-11 09:03:12 +02:00
|
|
|
DWORD allocated = 6; /* space for the zonecount and Zone "0" up to Zone "4" */
|
2009-07-02 22:04:43 +02:00
|
|
|
DWORD used = 0;
|
|
|
|
DWORD res;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, wszZonesKey, &hkey);
|
|
|
|
if (res)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
data = heap_alloc(allocated * sizeof(DWORD));
|
|
|
|
if (!data)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
while (!res) {
|
|
|
|
name[0] = '\0';
|
|
|
|
len = sizeof(name) / sizeof(name[0]);
|
|
|
|
res = RegEnumKeyExW(hkey, used, name, &len, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (!res) {
|
|
|
|
used++;
|
|
|
|
if (used == allocated) {
|
|
|
|
LPDWORD new_data;
|
|
|
|
|
|
|
|
allocated *= 2;
|
|
|
|
new_data = heap_realloc_zero(data, allocated * sizeof(DWORD));
|
|
|
|
if (!new_data)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
data = new_data;
|
|
|
|
}
|
|
|
|
data[used] = atoiW(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (used) {
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
data[0] = used;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
/* something failed */
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
heap_free(data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_QueryInterface
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManagerEx2* iface, REFIID riid, void** ppvObject)
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
if(!This || !ppvObject)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2009-07-07 23:55:00 +02:00
|
|
|
if(IsEqualIID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppvObject);
|
|
|
|
}else if(IsEqualIID(&IID_IInternetZoneManager, riid)) {
|
|
|
|
TRACE("(%p)->(IID_InternetZoneManager %p)\n", This, ppvObject);
|
|
|
|
}else if(IsEqualIID(&IID_IInternetZoneManagerEx, riid)) {
|
|
|
|
TRACE("(%p)->(IID_InternetZoneManagerEx %p)\n", This, ppvObject);
|
|
|
|
}else if(IsEqualIID(&IID_IInternetZoneManagerEx2, riid)) {
|
|
|
|
TRACE("(%p)->(IID_InternetZoneManagerEx2 %p)\n", This, ppvObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-11-30 22:14:21 +01:00
|
|
|
FIXME("Unknown interface: %s\n", debugstr_guid(riid));
|
|
|
|
*ppvObject = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppvObject = iface;
|
|
|
|
IInternetZoneManager_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_AddRef
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManagerEx2* iface)
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2005-01-12 20:52:38 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2005-01-12 20:52:38 +01:00
|
|
|
return refCount;
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_Release
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManagerEx2* iface)
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2005-01-12 20:52:38 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2005-07-02 12:49:56 +02:00
|
|
|
if(!refCount) {
|
2009-07-02 22:04:43 +02:00
|
|
|
while (This->zonemap_count) heap_free(This->zonemaps[--This->zonemap_count]);
|
|
|
|
heap_free(This->zonemaps);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2005-07-02 12:49:56 +02:00
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
2005-02-03 20:38:37 +01:00
|
|
|
|
2005-01-12 20:52:38 +01:00
|
|
|
return refCount;
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_GetZoneAttributes
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwZone,
|
|
|
|
ZONEATTRIBUTES* pZoneAttributes)
|
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2009-06-22 00:39:11 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HKEY hcu;
|
|
|
|
HKEY hklm = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, dwZone, pZoneAttributes);
|
|
|
|
|
|
|
|
if (!pZoneAttributes)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = open_zone_key(HKEY_CURRENT_USER, dwZone, &hcu);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return S_OK; /* IE6 and older returned E_FAIL here */
|
|
|
|
|
|
|
|
hr = open_zone_key(HKEY_LOCAL_MACHINE, dwZone, &hklm);
|
|
|
|
if (FAILED(hr))
|
|
|
|
TRACE("Zone %d not in HKLM\n", dwZone);
|
|
|
|
|
|
|
|
get_string_from_reg(hcu, hklm, displaynameW, pZoneAttributes->szDisplayName, MAX_ZONE_PATH);
|
|
|
|
get_string_from_reg(hcu, hklm, descriptionW, pZoneAttributes->szDescription, MAX_ZONE_DESCRIPTION);
|
|
|
|
get_string_from_reg(hcu, hklm, iconW, pZoneAttributes->szIconPath, MAX_ZONE_PATH);
|
|
|
|
get_dword_from_reg(hcu, hklm, minlevelW, &pZoneAttributes->dwTemplateMinLevel);
|
|
|
|
get_dword_from_reg(hcu, hklm, currentlevelW, &pZoneAttributes->dwTemplateCurrentLevel);
|
|
|
|
get_dword_from_reg(hcu, hklm, recommendedlevelW, &pZoneAttributes->dwTemplateRecommended);
|
|
|
|
get_dword_from_reg(hcu, hklm, flagsW, &pZoneAttributes->dwFlags);
|
|
|
|
|
|
|
|
RegCloseKey(hklm);
|
|
|
|
RegCloseKey(hcu);
|
|
|
|
return S_OK;
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_SetZoneAttributes
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_SetZoneAttributes(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwZone,
|
|
|
|
ZONEATTRIBUTES* pZoneAttributes)
|
|
|
|
{
|
2011-05-04 19:42:20 +02:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
HKEY hcu;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, dwZone, pZoneAttributes);
|
|
|
|
|
|
|
|
if (!pZoneAttributes)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = open_zone_key(HKEY_CURRENT_USER, dwZone, &hcu);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return S_OK; /* IE6 returned E_FAIL here */
|
|
|
|
|
|
|
|
/* cbSize is ignored */
|
|
|
|
RegSetValueExW(hcu, displaynameW, 0, REG_SZ, (LPBYTE) pZoneAttributes->szDisplayName,
|
|
|
|
(lstrlenW(pZoneAttributes->szDisplayName)+1)* sizeof(WCHAR));
|
|
|
|
|
|
|
|
RegSetValueExW(hcu, descriptionW, 0, REG_SZ, (LPBYTE) pZoneAttributes->szDescription,
|
|
|
|
(lstrlenW(pZoneAttributes->szDescription)+1)* sizeof(WCHAR));
|
|
|
|
|
|
|
|
RegSetValueExW(hcu, iconW, 0, REG_SZ, (LPBYTE) pZoneAttributes->szIconPath,
|
|
|
|
(lstrlenW(pZoneAttributes->szIconPath)+1)* sizeof(WCHAR));
|
|
|
|
|
|
|
|
RegSetValueExW(hcu, minlevelW, 0, REG_DWORD,
|
|
|
|
(const BYTE*) &pZoneAttributes->dwTemplateMinLevel, sizeof(DWORD));
|
|
|
|
|
|
|
|
RegSetValueExW(hcu, currentlevelW, 0, REG_DWORD,
|
|
|
|
(const BYTE*) &pZoneAttributes->dwTemplateCurrentLevel, sizeof(DWORD));
|
|
|
|
|
|
|
|
RegSetValueExW(hcu, recommendedlevelW, 0, REG_DWORD,
|
|
|
|
(const BYTE*) &pZoneAttributes->dwTemplateRecommended, sizeof(DWORD));
|
|
|
|
|
|
|
|
RegSetValueExW(hcu, flagsW, 0, REG_DWORD, (const BYTE*) &pZoneAttributes->dwFlags, sizeof(DWORD));
|
|
|
|
RegCloseKey(hcu);
|
|
|
|
return S_OK;
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_GetZoneCustomPolicy
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneCustomPolicy(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwZone,
|
|
|
|
REFGUID guidKey,
|
|
|
|
BYTE** ppPolicy,
|
|
|
|
DWORD* pcbPolicy,
|
|
|
|
URLZONEREG ulrZoneReg)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%08x %s %p %p %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
|
2004-11-30 22:14:21 +01:00
|
|
|
ppPolicy, pcbPolicy, ulrZoneReg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_SetZoneCustomPolicy
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_SetZoneCustomPolicy(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwZone,
|
|
|
|
REFGUID guidKey,
|
|
|
|
BYTE* ppPolicy,
|
|
|
|
DWORD cbPolicy,
|
|
|
|
URLZONEREG ulrZoneReg)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%08x %s %p %08x %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
|
2004-11-30 22:14:21 +01:00
|
|
|
ppPolicy, cbPolicy, ulrZoneReg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_GetZoneActionPolicy
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneActionPolicy(IInternetZoneManagerEx2* iface,
|
2005-09-30 12:34:10 +02:00
|
|
|
DWORD dwZone, DWORD dwAction, BYTE* pPolicy, DWORD cbPolicy, URLZONEREG urlZoneReg)
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%d %08x %p %d %d)\n", iface, dwZone, dwAction, pPolicy,
|
2005-09-30 12:34:10 +02:00
|
|
|
cbPolicy, urlZoneReg);
|
|
|
|
|
|
|
|
if(!pPolicy)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-14 12:41:50 +01:00
|
|
|
return get_action_policy(dwZone, dwAction, pPolicy, cbPolicy, urlZoneReg);
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_SetZoneActionPolicy
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_SetZoneActionPolicy(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwZone,
|
|
|
|
DWORD dwAction,
|
|
|
|
BYTE* pPolicy,
|
|
|
|
DWORD cbPolicy,
|
|
|
|
URLZONEREG urlZoneReg)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%08x %08x %p %08x %08x) stub\n", iface, dwZone, dwAction, pPolicy,
|
2004-11-30 22:14:21 +01:00
|
|
|
cbPolicy, urlZoneReg);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-05-24 14:30:35 +02:00
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_PromptAction
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_PromptAction(IInternetZoneManagerEx2* iface,
|
2005-05-24 14:30:35 +02:00
|
|
|
DWORD dwAction,
|
|
|
|
HWND hwndParent,
|
|
|
|
LPCWSTR pwszUrl,
|
|
|
|
LPCWSTR pwszText,
|
|
|
|
DWORD dwPromptFlags)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("%p %08x %p %s %s %08x\n", iface, dwAction, hwndParent,
|
2005-05-24 14:30:35 +02:00
|
|
|
debugstr_w(pwszUrl), debugstr_w(pwszText), dwPromptFlags );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_LogAction
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_LogAction(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwAction,
|
|
|
|
LPCWSTR pwszUrl,
|
|
|
|
LPCWSTR pwszText,
|
|
|
|
DWORD dwLogFlags)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%08x %s %s %08x) stub\n", iface, dwAction, debugstr_w(pwszUrl),
|
2004-11-30 22:14:21 +01:00
|
|
|
debugstr_w(pwszText), dwLogFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_CreateZoneEnumerator
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_CreateZoneEnumerator(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD* pdwEnum,
|
|
|
|
DWORD* pdwCount,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2009-07-02 22:04:43 +02:00
|
|
|
LPDWORD * new_maps;
|
|
|
|
LPDWORD data;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p, 0x%08x)\n", This, pdwEnum, pdwCount, dwFlags);
|
|
|
|
if (!pdwEnum || !pdwCount || (dwFlags != 0))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
data = build_zonemap_from_reg();
|
|
|
|
TRACE("found %d zones\n", data ? data[0] : -1);
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
for (i = 0; i < This->zonemap_count; i++) {
|
|
|
|
if (This->zonemaps && !This->zonemaps[i]) {
|
|
|
|
This->zonemaps[i] = data;
|
|
|
|
*pdwEnum = i;
|
|
|
|
*pdwCount = data[0];
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->zonemaps) {
|
|
|
|
/* try to double the nr. of pointers in the array */
|
|
|
|
new_maps = heap_realloc_zero(This->zonemaps, This->zonemap_count * 2 * sizeof(LPDWORD));
|
|
|
|
if (new_maps)
|
|
|
|
This->zonemap_count *= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->zonemap_count = 2;
|
|
|
|
new_maps = heap_alloc_zero(This->zonemap_count * sizeof(LPDWORD));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!new_maps) {
|
|
|
|
heap_free(data);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
This->zonemaps = new_maps;
|
|
|
|
This->zonemaps[i] = data;
|
|
|
|
*pdwEnum = i;
|
|
|
|
*pdwCount = data[0];
|
|
|
|
return S_OK;
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_GetZoneAt
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwEnum,
|
|
|
|
DWORD dwIndex,
|
|
|
|
DWORD* pdwZone)
|
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2009-07-02 22:04:43 +02:00
|
|
|
LPDWORD data;
|
|
|
|
|
|
|
|
TRACE("(%p)->(0x%08x, %d, %p)\n", This, dwEnum, dwIndex, pdwZone);
|
|
|
|
|
|
|
|
/* make sure, that dwEnum and dwIndex are in the valid range */
|
|
|
|
if (dwEnum < This->zonemap_count) {
|
|
|
|
if ((data = This->zonemaps[dwEnum])) {
|
|
|
|
if (dwIndex < data[0]) {
|
|
|
|
*pdwZone = data[dwIndex + 1];
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return E_INVALIDARG;
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_DestroyZoneEnumerator
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_DestroyZoneEnumerator(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwEnum)
|
|
|
|
{
|
2010-12-06 23:34:25 +01:00
|
|
|
ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
|
2009-07-02 22:04:43 +02:00
|
|
|
LPDWORD data;
|
|
|
|
|
|
|
|
TRACE("(%p)->(0x%08x)\n", This, dwEnum);
|
|
|
|
/* make sure, that dwEnum is valid */
|
|
|
|
if (dwEnum < This->zonemap_count) {
|
|
|
|
if ((data = This->zonemaps[dwEnum])) {
|
|
|
|
This->zonemaps[dwEnum] = NULL;
|
|
|
|
heap_free(data);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return E_INVALIDARG;
|
2004-11-30 22:14:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_CopyTemplatePoliciesToZone
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static HRESULT WINAPI ZoneMgrImpl_CopyTemplatePoliciesToZone(IInternetZoneManagerEx2* iface,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD dwTemplate,
|
|
|
|
DWORD dwZone,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%08x %08x %08x) stub\n", iface, dwTemplate, dwZone, dwReserved);
|
2004-11-30 22:14:21 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-07-07 23:55:00 +02:00
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManagerEx_GetZoneActionPolicyEx
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneActionPolicyEx(IInternetZoneManagerEx2* iface,
|
|
|
|
DWORD dwZone,
|
|
|
|
DWORD dwAction,
|
|
|
|
BYTE* pPolicy,
|
|
|
|
DWORD cbPolicy,
|
|
|
|
URLZONEREG urlZoneReg,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%d, 0x%x, %p, %d, %d, 0x%x)\n", iface, dwZone,
|
|
|
|
dwAction, pPolicy, cbPolicy, urlZoneReg, dwFlags);
|
|
|
|
|
|
|
|
if(!pPolicy)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (dwFlags)
|
|
|
|
FIXME("dwFlags 0x%x ignored\n", dwFlags);
|
|
|
|
|
|
|
|
return get_action_policy(dwZone, dwAction, pPolicy, cbPolicy, urlZoneReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManagerEx_SetZoneActionPolicyEx
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ZoneMgrImpl_SetZoneActionPolicyEx(IInternetZoneManagerEx2* iface,
|
|
|
|
DWORD dwZone,
|
|
|
|
DWORD dwAction,
|
|
|
|
BYTE* pPolicy,
|
|
|
|
DWORD cbPolicy,
|
|
|
|
URLZONEREG urlZoneReg,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, 0x%x, %p, %d, %d, 0x%x) stub\n", iface, dwZone, dwAction, pPolicy,
|
|
|
|
cbPolicy, urlZoneReg, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManagerEx2_GetZoneAttributesEx
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributesEx(IInternetZoneManagerEx2* iface,
|
|
|
|
DWORD dwZone,
|
|
|
|
ZONEATTRIBUTES* pZoneAttributes,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%d, %p, 0x%x)\n", iface, dwZone, pZoneAttributes, dwFlags);
|
|
|
|
|
|
|
|
if (dwFlags)
|
|
|
|
FIXME("dwFlags 0x%x ignored\n", dwFlags);
|
|
|
|
|
|
|
|
return IInternetZoneManager_GetZoneAttributes(iface, dwZone, pZoneAttributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManagerEx2_GetZoneSecurityState
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetZoneSecurityState(IInternetZoneManagerEx2* iface,
|
|
|
|
DWORD dwZoneIndex,
|
|
|
|
BOOL fRespectPolicy,
|
|
|
|
LPDWORD pdwState,
|
|
|
|
BOOL *pfPolicyEncountered)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %d, %p, %p) stub\n", iface, dwZoneIndex, fRespectPolicy,
|
|
|
|
pdwState, pfPolicyEncountered);
|
|
|
|
|
|
|
|
*pdwState = SECURITY_IE_STATE_GREEN;
|
|
|
|
|
|
|
|
if (pfPolicyEncountered)
|
|
|
|
*pfPolicyEncountered = FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManagerEx2_GetIESecurityState
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ZoneMgrImpl_GetIESecurityState(IInternetZoneManagerEx2* iface,
|
|
|
|
BOOL fRespectPolicy,
|
|
|
|
LPDWORD pdwState,
|
|
|
|
BOOL *pfPolicyEncountered,
|
|
|
|
BOOL fNoCache)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %p, %p, %d) stub\n", iface, fRespectPolicy, pdwState,
|
|
|
|
pfPolicyEncountered, fNoCache);
|
|
|
|
|
|
|
|
*pdwState = SECURITY_IE_STATE_GREEN;
|
|
|
|
|
|
|
|
if (pfPolicyEncountered)
|
|
|
|
*pfPolicyEncountered = FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManagerEx2_FixInsecureSettings
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ZoneMgrImpl_FixInsecureSettings(IInternetZoneManagerEx2* iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
/********************************************************************
|
|
|
|
* IInternetZoneManager_Construct
|
|
|
|
*/
|
2009-07-07 23:55:00 +02:00
|
|
|
static const IInternetZoneManagerEx2Vtbl ZoneMgrImplVtbl = {
|
2004-11-30 22:14:21 +01:00
|
|
|
ZoneMgrImpl_QueryInterface,
|
|
|
|
ZoneMgrImpl_AddRef,
|
|
|
|
ZoneMgrImpl_Release,
|
2009-07-07 23:55:00 +02:00
|
|
|
/* IInternetZoneManager */
|
2004-11-30 22:14:21 +01:00
|
|
|
ZoneMgrImpl_GetZoneAttributes,
|
|
|
|
ZoneMgrImpl_SetZoneAttributes,
|
|
|
|
ZoneMgrImpl_GetZoneCustomPolicy,
|
|
|
|
ZoneMgrImpl_SetZoneCustomPolicy,
|
|
|
|
ZoneMgrImpl_GetZoneActionPolicy,
|
|
|
|
ZoneMgrImpl_SetZoneActionPolicy,
|
2005-05-24 14:30:35 +02:00
|
|
|
ZoneMgrImpl_PromptAction,
|
2004-11-30 22:14:21 +01:00
|
|
|
ZoneMgrImpl_LogAction,
|
|
|
|
ZoneMgrImpl_CreateZoneEnumerator,
|
|
|
|
ZoneMgrImpl_GetZoneAt,
|
|
|
|
ZoneMgrImpl_DestroyZoneEnumerator,
|
|
|
|
ZoneMgrImpl_CopyTemplatePoliciesToZone,
|
2009-07-07 23:55:00 +02:00
|
|
|
/* IInternetZoneManagerEx */
|
|
|
|
ZoneMgrImpl_GetZoneActionPolicyEx,
|
|
|
|
ZoneMgrImpl_SetZoneActionPolicyEx,
|
|
|
|
/* IInternetZoneManagerEx2 */
|
|
|
|
ZoneMgrImpl_GetZoneAttributesEx,
|
|
|
|
ZoneMgrImpl_GetZoneSecurityState,
|
|
|
|
ZoneMgrImpl_GetIESecurityState,
|
|
|
|
ZoneMgrImpl_FixInsecureSettings,
|
2004-11-30 22:14:21 +01:00
|
|
|
};
|
2005-05-24 14:30:35 +02:00
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
|
|
|
|
{
|
2009-07-02 22:04:43 +02:00
|
|
|
ZoneMgrImpl* ret = heap_alloc_zero(sizeof(ZoneMgrImpl));
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
TRACE("(%p %p)\n", pUnkOuter, ppobj);
|
2010-12-06 23:34:25 +01:00
|
|
|
ret->IInternetZoneManagerEx2_iface.lpVtbl = &ZoneMgrImplVtbl;
|
2004-11-30 22:14:21 +01:00
|
|
|
ret->ref = 1;
|
2009-07-07 23:55:00 +02:00
|
|
|
*ppobj = (IInternetZoneManagerEx*)ret;
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2005-07-02 12:49:56 +02:00
|
|
|
URLMON_LockModule();
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CoInternetCreateSecurityManager (URLMON.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoInternetCreateSecurityManager( IServiceProvider *pSP,
|
|
|
|
IInternetSecurityManager **ppSM, DWORD dwReserved )
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("%p %p %d\n", pSP, ppSM, dwReserved );
|
2005-09-07 11:23:18 +02:00
|
|
|
|
|
|
|
if(pSP)
|
|
|
|
FIXME("pSP not supported\n");
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
return SecManagerImpl_Construct(NULL, (void**) ppSM);
|
|
|
|
}
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* CoInternetCreateZoneManager (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneManager** ppZM, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p %p %x)\n", pSP, ppZM, dwReserved);
|
2004-11-30 22:14:21 +01:00
|
|
|
return ZoneMgrImpl_Construct(NULL, (void**)ppZM);
|
|
|
|
}
|
2009-10-14 18:06:14 +02:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
static HRESULT parse_security_url(const WCHAR *url, PSUACTION action, WCHAR **result) {
|
|
|
|
IInternetProtocolInfo *protocol_info;
|
|
|
|
WCHAR *tmp, *new_url = NULL, *alloc_url = NULL;
|
|
|
|
DWORD size, new_size;
|
|
|
|
HRESULT hres = S_OK, parse_hres;
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
while(1) {
|
|
|
|
TRACE("parsing %s\n", debugstr_w(url));
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
protocol_info = get_protocol_info(url);
|
|
|
|
if(!protocol_info)
|
|
|
|
break;
|
2010-02-09 01:08:16 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
size = strlenW(url)+1;
|
|
|
|
new_url = CoTaskMemAlloc(size*sizeof(WCHAR));
|
|
|
|
if(!new_url) {
|
|
|
|
hres = E_OUTOFMEMORY;
|
2010-02-09 01:08:16 +01:00
|
|
|
break;
|
2011-02-08 15:16:38 +01:00
|
|
|
}
|
2010-02-09 01:08:16 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
new_size = 0;
|
|
|
|
parse_hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_SECURITY_URL, 0, new_url, size, &new_size, 0);
|
|
|
|
if(parse_hres == S_FALSE) {
|
|
|
|
if(!new_size) {
|
|
|
|
hres = E_UNEXPECTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = CoTaskMemRealloc(new_url, new_size*sizeof(WCHAR));
|
|
|
|
if(!tmp) {
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
new_url = tmp;
|
|
|
|
parse_hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_SECURITY_URL, 0, new_url,
|
|
|
|
new_size, &new_size, 0);
|
|
|
|
if(parse_hres == S_FALSE) {
|
|
|
|
hres = E_FAIL;
|
|
|
|
break;
|
|
|
|
}
|
2010-02-09 01:08:16 +01:00
|
|
|
}
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
if(parse_hres != S_OK || !strcmpW(url, new_url))
|
|
|
|
break;
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
CoTaskMemFree(alloc_url);
|
|
|
|
url = alloc_url = new_url;
|
|
|
|
new_url = NULL;
|
2010-02-09 01:08:16 +01:00
|
|
|
}
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
CoTaskMemFree(new_url);
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
if(hres != S_OK) {
|
|
|
|
WARN("failed: %08x\n", hres);
|
|
|
|
CoTaskMemFree(alloc_url);
|
|
|
|
return hres;
|
2009-12-15 23:48:23 +01:00
|
|
|
}
|
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
if(action == PSU_DEFAULT && (protocol_info = get_protocol_info(url))) {
|
|
|
|
size = strlenW(url)+1;
|
|
|
|
new_url = CoTaskMemAlloc(size * sizeof(WCHAR));
|
|
|
|
if(new_url) {
|
|
|
|
new_size = 0;
|
|
|
|
parse_hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_SECURITY_DOMAIN, 0,
|
|
|
|
new_url, size, &new_size, 0);
|
|
|
|
if(parse_hres == S_FALSE) {
|
|
|
|
if(new_size) {
|
|
|
|
tmp = CoTaskMemRealloc(new_url, new_size*sizeof(WCHAR));
|
|
|
|
if(tmp) {
|
|
|
|
new_url = tmp;
|
|
|
|
parse_hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_SECURITY_DOMAIN, 0, new_url,
|
|
|
|
new_size, &new_size, 0);
|
|
|
|
if(parse_hres == S_FALSE)
|
|
|
|
hres = E_FAIL;
|
|
|
|
}else {
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
hres = E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hres == S_OK && parse_hres == S_OK) {
|
|
|
|
CoTaskMemFree(alloc_url);
|
|
|
|
url = alloc_url = new_url;
|
|
|
|
new_url = NULL;
|
2009-12-15 23:48:23 +01:00
|
|
|
}
|
2011-02-08 15:16:38 +01:00
|
|
|
|
|
|
|
CoTaskMemFree(new_url);
|
|
|
|
}else {
|
|
|
|
hres = E_OUTOFMEMORY;
|
2009-12-15 23:48:23 +01:00
|
|
|
}
|
2011-02-08 15:16:38 +01:00
|
|
|
IInternetProtocolInfo_Release(protocol_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("failed %08x\n", hres);
|
|
|
|
CoTaskMemFree(alloc_url);
|
2010-03-13 00:22:43 +01:00
|
|
|
return hres;
|
2011-02-08 15:16:38 +01:00
|
|
|
}
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
if(!alloc_url) {
|
|
|
|
size = strlenW(url)+1;
|
|
|
|
alloc_url = CoTaskMemAlloc(size * sizeof(WCHAR));
|
|
|
|
if(!alloc_url)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
memcpy(alloc_url, url, size * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
*result = alloc_url;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* CoInternetGetSecurityUrl (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR pwzUrl, LPWSTR *ppwzSecUrl, PSUACTION psuAction, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
WCHAR *secure_url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%u,%u)\n", pwzUrl, ppwzSecUrl, psuAction, dwReserved);
|
|
|
|
|
|
|
|
hres = parse_security_url(pwzUrl, psuAction, &secure_url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(psuAction != PSU_SECURITY_URL_ONLY) {
|
|
|
|
PARSEDURLW parsed_url = { sizeof(parsed_url) };
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
/* FIXME: Use helpers from uri.c */
|
|
|
|
if(SUCCEEDED(ParseURLW(secure_url, &parsed_url))) {
|
|
|
|
WCHAR *new_url;
|
|
|
|
|
|
|
|
switch(parsed_url.nScheme) {
|
|
|
|
case URL_SCHEME_FTP:
|
|
|
|
case URL_SCHEME_HTTP:
|
|
|
|
case URL_SCHEME_HTTPS:
|
|
|
|
size = strlenW(secure_url)+1;
|
|
|
|
new_url = CoTaskMemAlloc(size * sizeof(WCHAR));
|
|
|
|
if(new_url)
|
|
|
|
hres = UrlGetPartW(secure_url, new_url, &size, URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME);
|
|
|
|
else
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
CoTaskMemFree(secure_url);
|
|
|
|
if(hres != S_OK) {
|
|
|
|
WARN("UrlGetPart failed: %08x\n", hres);
|
|
|
|
CoTaskMemFree(new_url);
|
|
|
|
return FAILED(hres) ? hres : E_FAIL;
|
|
|
|
}
|
|
|
|
secure_url = new_url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-15 23:48:23 +01:00
|
|
|
|
2011-02-08 15:16:38 +01:00
|
|
|
*ppwzSecUrl = secure_url;
|
2009-12-15 23:48:23 +01:00
|
|
|
return S_OK;
|
2009-10-14 18:06:14 +02:00
|
|
|
}
|
2011-01-15 22:03:03 +01:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* CoInternetGetSecurityUrlEx (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoInternetGetSecurityUrlEx(IUri *pUri, IUri **ppSecUri, PSUACTION psuAction, DWORD_PTR dwReserved)
|
|
|
|
{
|
2011-01-17 05:40:08 +01:00
|
|
|
URL_SCHEME scheme_type;
|
2011-02-08 15:17:15 +01:00
|
|
|
BSTR secure_uri;
|
|
|
|
WCHAR *ret_url;
|
|
|
|
HRESULT hres;
|
2011-01-17 05:40:08 +01:00
|
|
|
|
2011-01-16 20:36:24 +01:00
|
|
|
TRACE("(%p,%p,%u,%u)\n", pUri, ppSecUri, psuAction, (DWORD)dwReserved);
|
|
|
|
|
|
|
|
if(!pUri || !ppSecUri)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2011-02-08 15:17:15 +01:00
|
|
|
hres = IUri_GetDisplayUri(pUri, &secure_uri);
|
|
|
|
if(FAILED(hres))
|
2011-01-19 05:33:56 +01:00
|
|
|
return hres;
|
|
|
|
|
2011-02-08 15:17:15 +01:00
|
|
|
hres = parse_security_url(secure_uri, psuAction, &ret_url);
|
|
|
|
SysFreeString(secure_uri);
|
2011-01-17 05:40:08 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/* File URIs have to hierarchical. */
|
2011-02-08 15:17:15 +01:00
|
|
|
hres = IUri_GetScheme(pUri, (DWORD*)&scheme_type);
|
|
|
|
if(SUCCEEDED(hres) && scheme_type == URL_SCHEME_FILE) {
|
|
|
|
const WCHAR *tmp = ret_url;
|
2011-01-17 05:40:08 +01:00
|
|
|
|
|
|
|
/* Check and see if a "//" is after the scheme name. */
|
|
|
|
tmp += sizeof(fileW)/sizeof(WCHAR);
|
2011-02-08 15:17:15 +01:00
|
|
|
if(*tmp != '/' || *(tmp+1) != '/')
|
|
|
|
hres = E_INVALIDARG;
|
2011-01-17 05:40:08 +01:00
|
|
|
}
|
|
|
|
|
2011-02-08 15:17:15 +01:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = CreateUri(ret_url, Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, 0, ppSecUri);
|
|
|
|
CoTaskMemFree(ret_url);
|
2011-01-17 05:40:08 +01:00
|
|
|
return hres;
|
2011-01-15 22:03:03 +01:00
|
|
|
}
|