2 * Copyright 2005 Jacek Caban
3 * Copyright 2011 Thomas Mullaly for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "urlmon_main.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
28 static const WCHAR feature_control_keyW
[] =
29 {'S','o','f','t','w','a','r','e','\\',
30 'M','i','c','r','o','s','o','f','t','\\',
31 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
33 'F','e','a','t','u','r','e','C','o','n','t','r','o','l',0};
35 static const WCHAR feature_object_cachingW
[] =
36 {'F','E','A','T','U','R','E','_','O','B','J','E','C','T','_','C','A','C','H','I','N','G',0};
37 static const WCHAR feature_zone_elevationW
[] =
38 {'F','E','A','T','U','R','E','_','Z','O','N','E','_','E','L','E','V','A','T','I','O','N',0};
39 static const WCHAR feature_mime_handlingW
[] =
40 {'F','E','A','T','U','R','E','_','M','I','M','E','_','H','A','N','D','L','I','N','G',0};
41 static const WCHAR feature_mime_sniffingW
[] =
42 {'F','E','A','T','U','R','E','_','M','I','M','E','_','S','N','I','F','F','I','N','G',0};
43 static const WCHAR feature_window_restrictionsW
[] =
44 {'F','E','A','T','U','R','E','_','W','I','N','D','O','W','_','R','E','S','T','R','I','C','T','I','O','N','S',0};
45 static const WCHAR feature_weboc_popupmanagementW
[] =
46 {'F','E','A','T','U','R','E','_','W','E','B','O','C','_','P','O','P','U','P','M','A','N','A','G','E','M','E','N','T',0};
47 static const WCHAR feature_behaviorsW
[] =
48 {'F','E','A','T','U','R','E','_','B','E','H','A','V','I','O','R','S',0};
49 static const WCHAR feature_disable_mk_protocolW
[] =
50 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','M','K','_','P','R','O','T','O','C','O','L',0};
51 static const WCHAR feature_localmachine_lockdownW
[] =
52 {'F','E','A','T','U','R','E','_','L','O','C','A','L','M','A','C','H','I','N','E','_','L','O','C','K','D','O','W','N',0};
53 static const WCHAR feature_securitybandW
[] =
54 {'F','E','A','T','U','R','E','_','S','E','C','U','R','I','T','Y','B','A','N','D',0};
55 static const WCHAR feature_restrict_activexinstallW
[] =
56 {'F','E','A','T','U','R','E','_','R','E','S','T','R','I','C','T','_','A','C','T','I','V','E','X','I','N','S','T','A','L','L',0};
57 static const WCHAR feature_validate_navigate_urlW
[] =
58 {'F','E','A','T','U','R','E','_','V','A','L','I','D','A','T','E','_','N','A','V','I','G','A','T','E','_','U','R','L',0};
59 static const WCHAR feature_restrict_filedownloadW
[] =
60 {'F','E','A','T','U','R','E','_','R','E','S','T','R','I','C','T','_','F','I','L','E','D','O','W','N','L','O','A','D',0};
61 static const WCHAR feature_addon_managementW
[] =
62 {'F','E','A','T','U','R','E','_','A','D','D','O','N','_','M','A','N','A','G','E','M','E','N','T',0};
63 static const WCHAR feature_protocol_lockdownW
[] =
64 {'F','E','A','T','U','R','E','_','P','R','O','T','O','C','O','L','_','L','O','C','K','D','O','W','N',0};
65 static const WCHAR feature_http_username_password_disableW
[] =
66 {'F','E','A','T','U','R','E','_','H','T','T','P','_','U','S','E','R','N','A','M','E','_',
67 'P','A','S','S','W','O','R','D','_','D','I','S','A','B','L','E',0};
68 static const WCHAR feature_safe_bindtoobjectW
[] =
69 {'F','E','A','T','U','R','E','_','S','A','F','E','_','B','I','N','D','T','O','O','B','J','E','C','T',0};
70 static const WCHAR feature_unc_savedfilecheckW
[] =
71 {'F','E','A','T','U','R','E','_','U','N','C','_','S','A','V','E','D','F','I','L','E','C','H','E','C','K',0};
72 static const WCHAR feature_get_url_dom_filepath_unencodedW
[] =
73 {'F','E','A','T','U','R','E','_','G','E','T','_','U','R','L','_','D','O','M','_',
74 'F','I','L','E','P','A','T','H','_','U','N','E','N','C','O','D','E','D',0};
75 static const WCHAR feature_tabbed_browsingW
[] =
76 {'F','E','A','T','U','R','E','_','T','A','B','B','E','D','_','B','R','O','W','S','I','N','G',0};
77 static const WCHAR feature_ssluxW
[] =
78 {'F','E','A','T','U','R','E','_','S','S','L','U','X',0};
79 static const WCHAR feature_disable_navigation_soundsW
[] =
80 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','N','A','V','I','G','A','T','I','O','N','_',
81 'S','O','U','N','D','S',0};
82 static const WCHAR feature_disable_legacy_compressionW
[] =
83 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','L','E','G','A','C','Y','_',
84 'C','O','M','P','R','E','S','S','I','O','N',0};
85 static const WCHAR feature_force_addr_and_statusW
[] =
86 {'F','E','A','T','U','R','E','_','F','O','R','C','E','_','A','D','D','R','_','A','N','D','_',
87 'S','T','A','T','U','S',0};
88 static const WCHAR feature_xmlhttpW
[] =
89 {'F','E','A','T','U','R','E','_','X','M','L','H','T','T','P',0};
90 static const WCHAR feature_disable_telnet_protocolW
[] =
91 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','T','E','L','N','E','T','_',
92 'P','R','O','T','O','C','O','L',0};
93 static const WCHAR feature_feedsW
[] =
94 {'F','E','A','T','U','R','E','_','F','E','E','D','S',0};
95 static const WCHAR feature_block_input_promptsW
[] =
96 {'F','E','A','T','U','R','E','_','B','L','O','C','K','_','I','N','P','U','T','_','P','R','O','M','P','T','S',0};
98 static CRITICAL_SECTION process_features_cs
;
99 static CRITICAL_SECTION_DEBUG process_features_cs_dbg
=
101 0, 0, &process_features_cs
,
102 { &process_features_cs_dbg
.ProcessLocksList
, &process_features_cs_dbg
.ProcessLocksList
},
103 0, 0, { (DWORD_PTR
)(__FILE__
": process features") }
105 static CRITICAL_SECTION process_features_cs
= { &process_features_cs_dbg
, -1, 0, 0, 0, 0 };
107 typedef struct feature_control
{
108 LPCWSTR feature_name
;
115 * This array is indexed using INTERNETFEATURELIST values, so everything must
116 * appear in the same order as it does in INTERNETFEATURELIST.
118 static feature_control process_feature_controls
[FEATURE_ENTRY_COUNT
] = {
119 {feature_object_cachingW
, TRUE
,TRUE
},
120 {feature_zone_elevationW
, FALSE
,TRUE
},
121 {feature_mime_handlingW
, FALSE
,TRUE
},
122 {feature_mime_sniffingW
, FALSE
,TRUE
},
123 {feature_window_restrictionsW
, FALSE
,TRUE
},
124 {feature_weboc_popupmanagementW
, FALSE
,TRUE
},
125 {feature_behaviorsW
, TRUE
,TRUE
},
126 {feature_disable_mk_protocolW
, TRUE
,TRUE
},
127 {feature_localmachine_lockdownW
, FALSE
,TRUE
},
128 {feature_securitybandW
, FALSE
,TRUE
},
129 {feature_restrict_activexinstallW
, FALSE
,TRUE
},
130 {feature_validate_navigate_urlW
, FALSE
,TRUE
},
131 {feature_restrict_filedownloadW
, FALSE
,TRUE
},
132 {feature_addon_managementW
, FALSE
,TRUE
},
133 {feature_protocol_lockdownW
, FALSE
,TRUE
},
134 {feature_http_username_password_disableW
, FALSE
,TRUE
},
135 {feature_safe_bindtoobjectW
, FALSE
,TRUE
},
136 {feature_unc_savedfilecheckW
, FALSE
,TRUE
},
137 {feature_get_url_dom_filepath_unencodedW
, TRUE
,TRUE
},
138 {feature_tabbed_browsingW
, FALSE
,TRUE
},
139 {feature_ssluxW
, FALSE
,TRUE
},
140 {feature_disable_navigation_soundsW
, FALSE
,TRUE
},
141 {feature_disable_legacy_compressionW
, TRUE
,TRUE
},
142 {feature_force_addr_and_statusW
, FALSE
,TRUE
},
143 {feature_xmlhttpW
, TRUE
,TRUE
},
144 {feature_disable_telnet_protocolW
, FALSE
,TRUE
},
145 {feature_feedsW
, FALSE
,TRUE
},
146 {feature_block_input_promptsW
, FALSE
,TRUE
}
149 static HRESULT
parse_schema(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
154 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
157 ERR("wrong flags\n");
159 ptr
= strchrW(url
, ':');
170 memcpy(result
, url
, len
*sizeof(WCHAR
));
176 static HRESULT
parse_canonicalize_url(LPCWSTR url
, DWORD flags
, LPWSTR result
,
177 DWORD size
, DWORD
*rsize
)
179 IInternetProtocolInfo
*protocol_info
;
183 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
185 protocol_info
= get_protocol_info(url
);
188 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_CANONICALIZE
,
189 flags
, result
, size
, rsize
, 0);
190 IInternetProtocolInfo_Release(protocol_info
);
195 hres
= UrlCanonicalizeW(url
, result
, &prsize
, flags
);
202 static HRESULT
parse_security_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
204 IInternetProtocolInfo
*protocol_info
;
207 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
209 protocol_info
= get_protocol_info(url
);
212 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_URL
,
213 flags
, result
, size
, rsize
, 0);
214 IInternetProtocolInfo_Release(protocol_info
);
221 static HRESULT
parse_encode(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
223 IInternetProtocolInfo
*protocol_info
;
227 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
229 protocol_info
= get_protocol_info(url
);
232 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_ENCODE
,
233 flags
, result
, size
, rsize
, 0);
234 IInternetProtocolInfo_Release(protocol_info
);
240 hres
= UrlUnescapeW((LPWSTR
)url
, result
, &prsize
, flags
);
248 static HRESULT
parse_path_from_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
250 IInternetProtocolInfo
*protocol_info
;
254 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
256 protocol_info
= get_protocol_info(url
);
259 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_PATH_FROM_URL
,
260 flags
, result
, size
, rsize
, 0);
261 IInternetProtocolInfo_Release(protocol_info
);
267 hres
= PathCreateFromUrlW(url
, result
, &prsize
, 0);
274 static HRESULT
parse_security_domain(LPCWSTR url
, DWORD flags
, LPWSTR result
,
275 DWORD size
, DWORD
*rsize
)
277 IInternetProtocolInfo
*protocol_info
;
280 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
282 protocol_info
= get_protocol_info(url
);
285 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_DOMAIN
,
286 flags
, result
, size
, rsize
, 0);
287 IInternetProtocolInfo_Release(protocol_info
);
295 static HRESULT
parse_domain(LPCWSTR url
, DWORD flags
, LPWSTR result
,
296 DWORD size
, DWORD
*rsize
)
298 IInternetProtocolInfo
*protocol_info
;
301 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
303 protocol_info
= get_protocol_info(url
);
306 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_DOMAIN
,
307 flags
, result
, size
, rsize
, 0);
308 IInternetProtocolInfo_Release(protocol_info
);
313 hres
= UrlGetPartW(url
, result
, &size
, URL_PART_HOSTNAME
, flags
);
317 if(hres
== E_POINTER
)
325 static HRESULT
parse_rootdocument(LPCWSTR url
, DWORD flags
, LPWSTR result
,
326 DWORD size
, DWORD
*rsize
)
328 IInternetProtocolInfo
*protocol_info
;
332 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
334 protocol_info
= get_protocol_info(url
);
337 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_ROOTDOCUMENT
,
338 flags
, result
, size
, rsize
, 0);
339 IInternetProtocolInfo_Release(protocol_info
);
344 url_info
.cbSize
= sizeof(url_info
);
345 if(FAILED(ParseURLW(url
, &url_info
)))
348 switch(url_info
.nScheme
) {
350 case URL_SCHEME_HTTP
:
351 case URL_SCHEME_HTTPS
:
352 if(url_info
.cchSuffix
<3 || *(url_info
.pszSuffix
)!='/'
353 || *(url_info
.pszSuffix
+1)!='/')
356 if(size
< url_info
.cchProtocol
+3) {
358 hres
= UrlGetPartW(url
, result
, &size
, URL_PART_HOSTNAME
, flags
);
361 *rsize
= size
+url_info
.cchProtocol
+3;
363 if(hres
== E_POINTER
)
369 size
-= url_info
.cchProtocol
+3;
370 hres
= UrlGetPartW(url
, result
+url_info
.cchProtocol
+3,
371 &size
, URL_PART_HOSTNAME
, flags
);
373 if(hres
== E_POINTER
)
380 *rsize
= size
+url_info
.cchProtocol
+3;
382 memcpy(result
, url
, (url_info
.cchProtocol
+3)*sizeof(WCHAR
));
389 /**************************************************************************
390 * CoInternetParseUrl (URLMON.@)
392 HRESULT WINAPI
CoInternetParseUrl(LPCWSTR pwzUrl
, PARSEACTION ParseAction
, DWORD dwFlags
,
393 LPWSTR pszResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
396 WARN("dwReserved = %d\n", dwReserved
);
398 switch(ParseAction
) {
399 case PARSE_CANONICALIZE
:
400 return parse_canonicalize_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
401 case PARSE_SECURITY_URL
:
402 return parse_security_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
404 return parse_encode(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
405 case PARSE_PATH_FROM_URL
:
406 return parse_path_from_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
408 return parse_schema(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
409 case PARSE_SECURITY_DOMAIN
:
410 return parse_security_domain(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
412 return parse_domain(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
413 case PARSE_ROOTDOCUMENT
:
414 return parse_rootdocument(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
416 FIXME("not supported action %d\n", ParseAction
);
422 /**************************************************************************
423 * CoInternetCombineUrl (URLMON.@)
425 HRESULT WINAPI
CoInternetCombineUrl(LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
,
426 DWORD dwCombineFlags
, LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
,
429 IInternetProtocolInfo
*protocol_info
;
430 DWORD size
= cchResult
;
433 TRACE("(%s,%s,0x%08x,%p,%d,%p,%d)\n", debugstr_w(pwzBaseUrl
),
434 debugstr_w(pwzRelativeUrl
), dwCombineFlags
, pwzResult
, cchResult
, pcchResult
,
437 protocol_info
= get_protocol_info(pwzBaseUrl
);
440 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, pwzBaseUrl
, pwzRelativeUrl
,
441 dwCombineFlags
, pwzResult
, cchResult
, pcchResult
, dwReserved
);
442 IInternetProtocolInfo_Release(protocol_info
);
448 hres
= UrlCombineW(pwzBaseUrl
, pwzRelativeUrl
, pwzResult
, &size
, dwCombineFlags
);
456 /**************************************************************************
457 * CoInternetCompareUrl (URLMON.@)
459 HRESULT WINAPI
CoInternetCompareUrl(LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
461 IInternetProtocolInfo
*protocol_info
;
464 TRACE("(%s,%s,%08x)\n", debugstr_w(pwzUrl1
), debugstr_w(pwzUrl2
), dwCompareFlags
);
466 protocol_info
= get_protocol_info(pwzUrl1
);
469 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, pwzUrl1
, pwzUrl2
, dwCompareFlags
);
470 IInternetProtocolInfo_Release(protocol_info
);
475 return UrlCompareW(pwzUrl1
, pwzUrl2
, dwCompareFlags
) ? S_FALSE
: S_OK
;
478 /***********************************************************************
479 * CoInternetQueryInfo (URLMON.@)
481 * Retrieves information relevant to a specified URL
484 HRESULT WINAPI
CoInternetQueryInfo(LPCWSTR pwzUrl
, QUERYOPTION QueryOption
,
485 DWORD dwQueryFlags
, LPVOID pvBuffer
, DWORD cbBuffer
, DWORD
*pcbBuffer
,
488 IInternetProtocolInfo
*protocol_info
;
491 TRACE("(%s, %x, %x, %p, %x, %p, %x): stub\n", debugstr_w(pwzUrl
),
492 QueryOption
, dwQueryFlags
, pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
494 protocol_info
= get_protocol_info(pwzUrl
);
497 hres
= IInternetProtocolInfo_QueryInfo(protocol_info
, pwzUrl
, QueryOption
, dwQueryFlags
,
498 pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
499 IInternetProtocolInfo_Release(protocol_info
);
501 return SUCCEEDED(hres
) ? hres
: E_FAIL
;
504 switch(QueryOption
) {
505 case QUERY_USES_NETWORK
:
506 if(!pvBuffer
|| cbBuffer
< sizeof(DWORD
))
509 *(DWORD
*)pvBuffer
= 0;
511 *pcbBuffer
= sizeof(DWORD
);
515 FIXME("Not supported option %d\n", QueryOption
);
522 static void set_feature_on_process(INTERNETFEATURELIST feature
, BOOL enable
)
524 EnterCriticalSection(&process_features_cs
);
526 process_feature_controls
[feature
].enabled
= enable
;
527 process_feature_controls
[feature
].check_registry
= FALSE
;
529 LeaveCriticalSection(&process_features_cs
);
532 static HRESULT
set_internet_feature(INTERNETFEATURELIST feature
, DWORD flags
, BOOL enable
)
534 const DWORD supported_flags
= SET_FEATURE_ON_PROCESS
;
536 if(feature
>= FEATURE_ENTRY_COUNT
)
539 if(flags
& ~supported_flags
) {
540 FIXME("Unsupported flags: %08x\n", flags
& ~supported_flags
);
544 if(flags
& SET_FEATURE_ON_PROCESS
)
545 set_feature_on_process(feature
, enable
);
550 static BOOL
get_feature_from_reg(HKEY feature_control
, LPCWSTR feature_name
, LPCWSTR process_name
, BOOL
*enabled
)
552 DWORD type
, value
, size
;
556 static const WCHAR wildcardW
[] = {'*',0};
558 res
= RegOpenKeyW(feature_control
, feature_name
, &feature
);
559 if(res
!= ERROR_SUCCESS
)
562 size
= sizeof(DWORD
);
563 res
= RegQueryValueExW(feature
, process_name
, NULL
, &type
, (BYTE
*)&value
, &size
);
564 if(res
!= ERROR_SUCCESS
|| type
!= REG_DWORD
) {
565 size
= sizeof(DWORD
);
566 res
= RegQueryValueExW(feature
, wildcardW
, NULL
, &type
, (BYTE
*)&value
, &size
);
569 RegCloseKey(feature
);
570 if(res
!= ERROR_SUCCESS
)
573 if(type
!= REG_DWORD
) {
574 WARN("Unexpected registry value type %d (expected REG_DWORD) for %s\n", type
, debugstr_w(wildcardW
));
578 *enabled
= value
== 1;
582 /* Assumes 'process_features_cs' is held. */
583 static HRESULT
load_process_feature(INTERNETFEATURELIST feature
)
586 HKEY feature_control
;
587 WCHAR module_name
[MAX_PATH
];
588 LPCWSTR process_name
, feature_name
;
589 HRESULT hres
= S_FALSE
;
590 BOOL check_hklm
= FALSE
;
593 if (!GetModuleFileNameW(NULL
, module_name
, sizeof(module_name
)/sizeof(WCHAR
))) {
594 ERR("Failed to get module file name: %u\n", GetLastError());
598 process_name
= strrchrW(module_name
, '\\');
600 ERR("Invalid module file name: %s\n", debugstr_w(module_name
));
604 /* Skip past the '\\' in front of the filename. */
607 feature_name
= process_feature_controls
[feature
].feature_name
;
609 res
= RegOpenKeyW(HKEY_CURRENT_USER
, feature_control_keyW
, &feature_control
);
610 if(res
== ERROR_SUCCESS
) {
611 if(get_feature_from_reg(feature_control
, feature_name
, process_name
, &enabled
)) {
612 hres
= enabled
? S_OK
: S_FALSE
;
613 process_feature_controls
[feature
].enabled
= enabled
;
615 /* We didn't find anything in HKCU, so check HKLM. */
618 RegCloseKey(feature_control
);
622 res
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, feature_control_keyW
, &feature_control
);
623 if(res
== ERROR_SUCCESS
) {
624 if(get_feature_from_reg(feature_control
, feature_name
, process_name
, &enabled
)) {
625 hres
= enabled
? S_OK
: S_FALSE
;
626 process_feature_controls
[feature
].enabled
= enabled
;
628 RegCloseKey(feature_control
);
632 /* Don't bother checking the registry again for this feature. */
633 process_feature_controls
[feature
].check_registry
= FALSE
;
638 static HRESULT
get_feature_from_process(INTERNETFEATURELIST feature
)
642 EnterCriticalSection(&process_features_cs
);
644 /* Try loading the feature from the registry, if it hasn't already
647 if(process_feature_controls
[feature
].check_registry
) {
648 hres
= load_process_feature(feature
);
650 LeaveCriticalSection(&process_features_cs
);
655 hres
= process_feature_controls
[feature
].enabled
? S_OK
: S_FALSE
;
657 LeaveCriticalSection(&process_features_cs
);
662 static HRESULT
get_internet_feature(INTERNETFEATURELIST feature
, DWORD flags
)
666 if(feature
>= FEATURE_ENTRY_COUNT
)
669 if(flags
== GET_FEATURE_FROM_PROCESS
)
670 hres
= get_feature_from_process(feature
);
672 FIXME("Unsupported flags: %08x\n", flags
);
679 /***********************************************************************
680 * CoInternetSetFeatureEnabled (URLMON.@)
682 HRESULT WINAPI
CoInternetSetFeatureEnabled(INTERNETFEATURELIST FeatureEntry
, DWORD dwFlags
, BOOL fEnable
)
684 TRACE("(%d, %08x, %x)\n", FeatureEntry
, dwFlags
, fEnable
);
685 return set_internet_feature(FeatureEntry
, dwFlags
, fEnable
);
688 /***********************************************************************
689 * CoInternetIsFeatureEnabled (URLMON.@)
691 HRESULT WINAPI
CoInternetIsFeatureEnabled(INTERNETFEATURELIST FeatureEntry
, DWORD dwFlags
)
693 TRACE("(%d, %08x)\n", FeatureEntry
, dwFlags
);
694 return get_internet_feature(FeatureEntry
, dwFlags
);
697 /***********************************************************************
698 * CoInternetIsFeatureEnabledForUrl (URLMON.@)
700 HRESULT WINAPI
CoInternetIsFeatureEnabledForUrl(INTERNETFEATURELIST FeatureEntry
, DWORD dwFlags
, LPCWSTR szURL
,
701 IInternetSecurityManager
*pSecMgr
)
706 TRACE("(%d %08x %s %p)\n", FeatureEntry
, dwFlags
, debugstr_w(szURL
), pSecMgr
);
708 if(FeatureEntry
== FEATURE_MIME_SNIFFING
)
709 urlaction
= URLACTION_FEATURE_MIME_SNIFFING
;
710 else if(FeatureEntry
== FEATURE_WINDOW_RESTRICTIONS
)
711 urlaction
= URLACTION_FEATURE_WINDOW_RESTRICTIONS
;
712 else if(FeatureEntry
== FEATURE_ZONE_ELEVATION
)
713 urlaction
= URLACTION_FEATURE_ZONE_ELEVATION
;
715 if(!szURL
|| !urlaction
|| !pSecMgr
)
716 return CoInternetIsFeatureEnabled(FeatureEntry
, dwFlags
);
719 case GET_FEATURE_FROM_THREAD
:
720 case GET_FEATURE_FROM_THREAD_LOCALMACHINE
:
721 case GET_FEATURE_FROM_THREAD_INTRANET
:
722 case GET_FEATURE_FROM_THREAD_TRUSTED
:
723 case GET_FEATURE_FROM_THREAD_INTERNET
:
724 case GET_FEATURE_FROM_THREAD_RESTRICTED
:
725 FIXME("unsupported flags %x\n", dwFlags
);
728 case GET_FEATURE_FROM_PROCESS
:
729 hres
= CoInternetIsFeatureEnabled(FeatureEntry
, dwFlags
);
735 DWORD policy
= URLPOLICY_DISALLOW
;
737 hres
= IInternetSecurityManager_ProcessUrlAction(pSecMgr
, szURL
, urlaction
,
738 (BYTE
*)&policy
, sizeof(DWORD
), NULL
, 0, PUAF_NOUI
, 0);
739 if(hres
!=S_OK
|| policy
!=URLPOLICY_ALLOW
)
746 /***********************************************************************
747 * CoInternetIsFeatureZoneElevationEnabled (URLMON.@)
749 HRESULT WINAPI
CoInternetIsFeatureZoneElevationEnabled(LPCWSTR szFromURL
, LPCWSTR szToURL
,
750 IInternetSecurityManager
*pSecMgr
, DWORD dwFlags
)
754 TRACE("(%s %s %p %x)\n", debugstr_w(szFromURL
), debugstr_w(szToURL
), pSecMgr
, dwFlags
);
756 if(!pSecMgr
|| !szToURL
)
757 return CoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, dwFlags
);
760 case GET_FEATURE_FROM_THREAD
:
761 case GET_FEATURE_FROM_THREAD_LOCALMACHINE
:
762 case GET_FEATURE_FROM_THREAD_INTRANET
:
763 case GET_FEATURE_FROM_THREAD_TRUSTED
:
764 case GET_FEATURE_FROM_THREAD_INTERNET
:
765 case GET_FEATURE_FROM_THREAD_RESTRICTED
:
766 FIXME("unsupported flags %x\n", dwFlags
);
769 case GET_FEATURE_FROM_PROCESS
:
770 hres
= CoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, dwFlags
);
776 DWORD policy
= URLPOLICY_DISALLOW
;
778 hres
= IInternetSecurityManager_ProcessUrlAction(pSecMgr
, szToURL
,
779 URLACTION_FEATURE_ZONE_ELEVATION
, (BYTE
*)&policy
, sizeof(DWORD
),
780 NULL
, 0, PUAF_NOUI
, 0);
785 case URLPOLICY_ALLOW
:
787 case URLPOLICY_QUERY
:
788 FIXME("Ask user dialog not implemented\n");