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"
22 static const WCHAR feature_control_keyW
[] =
23 {'S','o','f','t','w','a','r','e','\\',
24 'M','i','c','r','o','s','o','f','t','\\',
25 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
27 'F','e','a','t','u','r','e','C','o','n','t','r','o','l',0};
29 static const WCHAR feature_object_cachingW
[] =
30 {'F','E','A','T','U','R','E','_','O','B','J','E','C','T','_','C','A','C','H','I','N','G',0};
31 static const WCHAR feature_zone_elevationW
[] =
32 {'F','E','A','T','U','R','E','_','Z','O','N','E','_','E','L','E','V','A','T','I','O','N',0};
33 static const WCHAR feature_mime_handlingW
[] =
34 {'F','E','A','T','U','R','E','_','M','I','M','E','_','H','A','N','D','L','I','N','G',0};
35 static const WCHAR feature_mime_sniffingW
[] =
36 {'F','E','A','T','U','R','E','_','M','I','M','E','_','S','N','I','F','F','I','N','G',0};
37 static const WCHAR feature_window_restrictionsW
[] =
38 {'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};
39 static const WCHAR feature_weboc_popupmanagementW
[] =
40 {'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};
41 static const WCHAR feature_behaviorsW
[] =
42 {'F','E','A','T','U','R','E','_','B','E','H','A','V','I','O','R','S',0};
43 static const WCHAR feature_disable_mk_protocolW
[] =
44 {'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};
45 static const WCHAR feature_localmachine_lockdownW
[] =
46 {'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};
47 static const WCHAR feature_securitybandW
[] =
48 {'F','E','A','T','U','R','E','_','S','E','C','U','R','I','T','Y','B','A','N','D',0};
49 static const WCHAR feature_restrict_activexinstallW
[] =
50 {'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};
51 static const WCHAR feature_validate_navigate_urlW
[] =
52 {'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};
53 static const WCHAR feature_restrict_filedownloadW
[] =
54 {'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};
55 static const WCHAR feature_addon_managementW
[] =
56 {'F','E','A','T','U','R','E','_','A','D','D','O','N','_','M','A','N','A','G','E','M','E','N','T',0};
57 static const WCHAR feature_protocol_lockdownW
[] =
58 {'F','E','A','T','U','R','E','_','P','R','O','T','O','C','O','L','_','L','O','C','K','D','O','W','N',0};
59 static const WCHAR feature_http_username_password_disableW
[] =
60 {'F','E','A','T','U','R','E','_','H','T','T','P','_','U','S','E','R','N','A','M','E','_',
61 'P','A','S','S','W','O','R','D','_','D','I','S','A','B','L','E',0};
62 static const WCHAR feature_safe_bindtoobjectW
[] =
63 {'F','E','A','T','U','R','E','_','S','A','F','E','_','B','I','N','D','T','O','O','B','J','E','C','T',0};
64 static const WCHAR feature_unc_savedfilecheckW
[] =
65 {'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};
66 static const WCHAR feature_get_url_dom_filepath_unencodedW
[] =
67 {'F','E','A','T','U','R','E','_','G','E','T','_','U','R','L','_','D','O','M','_',
68 'F','I','L','E','P','A','T','H','_','U','N','E','N','C','O','D','E','D',0};
69 static const WCHAR feature_tabbed_browsingW
[] =
70 {'F','E','A','T','U','R','E','_','T','A','B','B','E','D','_','B','R','O','W','S','I','N','G',0};
71 static const WCHAR feature_ssluxW
[] =
72 {'F','E','A','T','U','R','E','_','S','S','L','U','X',0};
73 static const WCHAR feature_disable_navigation_soundsW
[] =
74 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','N','A','V','I','G','A','T','I','O','N','_',
75 'S','O','U','N','D','S',0};
76 static const WCHAR feature_disable_legacy_compressionW
[] =
77 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','L','E','G','A','C','Y','_',
78 'C','O','M','P','R','E','S','S','I','O','N',0};
79 static const WCHAR feature_force_addr_and_statusW
[] =
80 {'F','E','A','T','U','R','E','_','F','O','R','C','E','_','A','D','D','R','_','A','N','D','_',
81 'S','T','A','T','U','S',0};
82 static const WCHAR feature_xmlhttpW
[] =
83 {'F','E','A','T','U','R','E','_','X','M','L','H','T','T','P',0};
84 static const WCHAR feature_disable_telnet_protocolW
[] =
85 {'F','E','A','T','U','R','E','_','D','I','S','A','B','L','E','_','T','E','L','N','E','T','_',
86 'P','R','O','T','O','C','O','L',0};
87 static const WCHAR feature_feedsW
[] =
88 {'F','E','A','T','U','R','E','_','F','E','E','D','S',0};
89 static const WCHAR feature_block_input_promptsW
[] =
90 {'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};
92 static CRITICAL_SECTION process_features_cs
;
93 static CRITICAL_SECTION_DEBUG process_features_cs_dbg
=
95 0, 0, &process_features_cs
,
96 { &process_features_cs_dbg
.ProcessLocksList
, &process_features_cs_dbg
.ProcessLocksList
},
97 0, 0, { (DWORD_PTR
)(__FILE__
": process features") }
99 static CRITICAL_SECTION process_features_cs
= { &process_features_cs_dbg
, -1, 0, 0, 0, 0 };
101 typedef struct feature_control
{
102 LPCWSTR feature_name
;
109 * This array is indexed using INTERNETFEATURELIST values, so everything must
110 * appear in the same order as it does in INTERNETFEATURELIST.
112 static feature_control process_feature_controls
[FEATURE_ENTRY_COUNT
] = {
113 {feature_object_cachingW
, TRUE
,TRUE
},
114 {feature_zone_elevationW
, FALSE
,TRUE
},
115 {feature_mime_handlingW
, FALSE
,TRUE
},
116 {feature_mime_sniffingW
, FALSE
,TRUE
},
117 {feature_window_restrictionsW
, FALSE
,TRUE
},
118 {feature_weboc_popupmanagementW
, FALSE
,TRUE
},
119 {feature_behaviorsW
, TRUE
,TRUE
},
120 {feature_disable_mk_protocolW
, TRUE
,TRUE
},
121 {feature_localmachine_lockdownW
, FALSE
,TRUE
},
122 {feature_securitybandW
, FALSE
,TRUE
},
123 {feature_restrict_activexinstallW
, FALSE
,TRUE
},
124 {feature_validate_navigate_urlW
, FALSE
,TRUE
},
125 {feature_restrict_filedownloadW
, FALSE
,TRUE
},
126 {feature_addon_managementW
, FALSE
,TRUE
},
127 {feature_protocol_lockdownW
, FALSE
,TRUE
},
128 {feature_http_username_password_disableW
, FALSE
,TRUE
},
129 {feature_safe_bindtoobjectW
, FALSE
,TRUE
},
130 {feature_unc_savedfilecheckW
, FALSE
,TRUE
},
131 {feature_get_url_dom_filepath_unencodedW
, TRUE
,TRUE
},
132 {feature_tabbed_browsingW
, FALSE
,TRUE
},
133 {feature_ssluxW
, FALSE
,TRUE
},
134 {feature_disable_navigation_soundsW
, FALSE
,TRUE
},
135 {feature_disable_legacy_compressionW
, TRUE
,TRUE
},
136 {feature_force_addr_and_statusW
, FALSE
,TRUE
},
137 {feature_xmlhttpW
, TRUE
,TRUE
},
138 {feature_disable_telnet_protocolW
, FALSE
,TRUE
},
139 {feature_feedsW
, FALSE
,TRUE
},
140 {feature_block_input_promptsW
, FALSE
,TRUE
}
143 static HRESULT
parse_schema(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
148 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
151 ERR("wrong flags\n");
153 ptr
= strchrW(url
, ':');
164 memcpy(result
, url
, len
*sizeof(WCHAR
));
170 static HRESULT
parse_canonicalize_url(LPCWSTR url
, DWORD flags
, LPWSTR result
,
171 DWORD size
, DWORD
*rsize
)
173 IInternetProtocolInfo
*protocol_info
;
177 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
179 protocol_info
= get_protocol_info(url
);
182 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_CANONICALIZE
,
183 flags
, result
, size
, rsize
, 0);
184 IInternetProtocolInfo_Release(protocol_info
);
189 hres
= UrlCanonicalizeW(url
, result
, &prsize
, flags
);
196 static HRESULT
parse_security_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
198 IInternetProtocolInfo
*protocol_info
;
201 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
203 protocol_info
= get_protocol_info(url
);
206 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_URL
,
207 flags
, result
, size
, rsize
, 0);
208 IInternetProtocolInfo_Release(protocol_info
);
215 static HRESULT
parse_encode(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
217 IInternetProtocolInfo
*protocol_info
;
221 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
223 protocol_info
= get_protocol_info(url
);
226 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_ENCODE
,
227 flags
, result
, size
, rsize
, 0);
228 IInternetProtocolInfo_Release(protocol_info
);
234 hres
= UrlUnescapeW((LPWSTR
)url
, result
, &prsize
, flags
);
242 static HRESULT
parse_path_from_url(LPCWSTR url
, DWORD flags
, LPWSTR result
, DWORD size
, DWORD
*rsize
)
244 IInternetProtocolInfo
*protocol_info
;
248 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
250 protocol_info
= get_protocol_info(url
);
253 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_PATH_FROM_URL
,
254 flags
, result
, size
, rsize
, 0);
255 IInternetProtocolInfo_Release(protocol_info
);
261 hres
= PathCreateFromUrlW(url
, result
, &prsize
, 0);
268 static HRESULT
parse_security_domain(LPCWSTR url
, DWORD flags
, LPWSTR result
,
269 DWORD size
, DWORD
*rsize
)
271 IInternetProtocolInfo
*protocol_info
;
274 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
276 protocol_info
= get_protocol_info(url
);
279 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_SECURITY_DOMAIN
,
280 flags
, result
, size
, rsize
, 0);
281 IInternetProtocolInfo_Release(protocol_info
);
289 static HRESULT
parse_domain(LPCWSTR url
, DWORD flags
, LPWSTR result
,
290 DWORD size
, DWORD
*rsize
)
292 IInternetProtocolInfo
*protocol_info
;
295 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
297 protocol_info
= get_protocol_info(url
);
300 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_DOMAIN
,
301 flags
, result
, size
, rsize
, 0);
302 IInternetProtocolInfo_Release(protocol_info
);
307 hres
= UrlGetPartW(url
, result
, &size
, URL_PART_HOSTNAME
, flags
);
311 if(hres
== E_POINTER
)
319 static HRESULT
parse_rootdocument(LPCWSTR url
, DWORD flags
, LPWSTR result
,
320 DWORD size
, DWORD
*rsize
)
322 IInternetProtocolInfo
*protocol_info
;
326 TRACE("(%s %08x %p %d %p)\n", debugstr_w(url
), flags
, result
, size
, rsize
);
328 protocol_info
= get_protocol_info(url
);
331 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, url
, PARSE_ROOTDOCUMENT
,
332 flags
, result
, size
, rsize
, 0);
333 IInternetProtocolInfo_Release(protocol_info
);
338 url_info
.cbSize
= sizeof(url_info
);
339 if(FAILED(ParseURLW(url
, &url_info
)))
342 switch(url_info
.nScheme
) {
344 case URL_SCHEME_HTTP
:
345 case URL_SCHEME_HTTPS
:
346 if(url_info
.cchSuffix
<3 || *(url_info
.pszSuffix
)!='/'
347 || *(url_info
.pszSuffix
+1)!='/')
350 if(size
< url_info
.cchProtocol
+3) {
352 hres
= UrlGetPartW(url
, result
, &size
, URL_PART_HOSTNAME
, flags
);
355 *rsize
= size
+url_info
.cchProtocol
+3;
357 if(hres
== E_POINTER
)
363 size
-= url_info
.cchProtocol
+3;
364 hres
= UrlGetPartW(url
, result
+url_info
.cchProtocol
+3,
365 &size
, URL_PART_HOSTNAME
, flags
);
367 if(hres
== E_POINTER
)
374 *rsize
= size
+url_info
.cchProtocol
+3;
376 memcpy(result
, url
, (url_info
.cchProtocol
+3)*sizeof(WCHAR
));
383 /**************************************************************************
384 * CoInternetParseUrl (URLMON.@)
386 HRESULT WINAPI
CoInternetParseUrl(LPCWSTR pwzUrl
, PARSEACTION ParseAction
, DWORD dwFlags
,
387 LPWSTR pszResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
390 WARN("dwReserved = %d\n", dwReserved
);
392 switch(ParseAction
) {
393 case PARSE_CANONICALIZE
:
394 return parse_canonicalize_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
395 case PARSE_SECURITY_URL
:
396 return parse_security_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
398 return parse_encode(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
399 case PARSE_PATH_FROM_URL
:
400 return parse_path_from_url(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
402 return parse_schema(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
403 case PARSE_SECURITY_DOMAIN
:
404 return parse_security_domain(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
406 return parse_domain(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
407 case PARSE_ROOTDOCUMENT
:
408 return parse_rootdocument(pwzUrl
, dwFlags
, pszResult
, cchResult
, pcchResult
);
410 FIXME("not supported action %d\n", ParseAction
);
416 /**************************************************************************
417 * CoInternetCombineUrl (URLMON.@)
419 HRESULT WINAPI
CoInternetCombineUrl(LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
,
420 DWORD dwCombineFlags
, LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
,
423 IInternetProtocolInfo
*protocol_info
;
424 DWORD size
= cchResult
;
427 TRACE("(%s,%s,0x%08x,%p,%d,%p,%d)\n", debugstr_w(pwzBaseUrl
),
428 debugstr_w(pwzRelativeUrl
), dwCombineFlags
, pwzResult
, cchResult
, pcchResult
,
431 protocol_info
= get_protocol_info(pwzBaseUrl
);
434 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, pwzBaseUrl
, pwzRelativeUrl
,
435 dwCombineFlags
, pwzResult
, cchResult
, pcchResult
, dwReserved
);
436 IInternetProtocolInfo_Release(protocol_info
);
442 hres
= UrlCombineW(pwzBaseUrl
, pwzRelativeUrl
, pwzResult
, &size
, dwCombineFlags
);
450 /**************************************************************************
451 * CoInternetCompareUrl (URLMON.@)
453 HRESULT WINAPI
CoInternetCompareUrl(LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
455 IInternetProtocolInfo
*protocol_info
;
458 TRACE("(%s,%s,%08x)\n", debugstr_w(pwzUrl1
), debugstr_w(pwzUrl2
), dwCompareFlags
);
460 protocol_info
= get_protocol_info(pwzUrl1
);
463 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, pwzUrl1
, pwzUrl2
, dwCompareFlags
);
464 IInternetProtocolInfo_Release(protocol_info
);
469 return UrlCompareW(pwzUrl1
, pwzUrl2
, dwCompareFlags
) ? S_FALSE
: S_OK
;
472 /***********************************************************************
473 * CoInternetQueryInfo (URLMON.@)
475 * Retrieves information relevant to a specified URL
478 HRESULT WINAPI
CoInternetQueryInfo(LPCWSTR pwzUrl
, QUERYOPTION QueryOption
,
479 DWORD dwQueryFlags
, LPVOID pvBuffer
, DWORD cbBuffer
, DWORD
*pcbBuffer
,
482 IInternetProtocolInfo
*protocol_info
;
485 TRACE("(%s, %x, %x, %p, %x, %p, %x): stub\n", debugstr_w(pwzUrl
),
486 QueryOption
, dwQueryFlags
, pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
488 protocol_info
= get_protocol_info(pwzUrl
);
491 hres
= IInternetProtocolInfo_QueryInfo(protocol_info
, pwzUrl
, QueryOption
, dwQueryFlags
,
492 pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
493 IInternetProtocolInfo_Release(protocol_info
);
495 return SUCCEEDED(hres
) ? hres
: E_FAIL
;
498 switch(QueryOption
) {
499 case QUERY_USES_NETWORK
:
500 if(!pvBuffer
|| cbBuffer
< sizeof(DWORD
))
503 *(DWORD
*)pvBuffer
= 0;
505 *pcbBuffer
= sizeof(DWORD
);
509 FIXME("Not supported option %d\n", QueryOption
);
516 static void set_feature_on_process(INTERNETFEATURELIST feature
, BOOL enable
)
518 EnterCriticalSection(&process_features_cs
);
520 process_feature_controls
[feature
].enabled
= enable
;
521 process_feature_controls
[feature
].check_registry
= FALSE
;
523 LeaveCriticalSection(&process_features_cs
);
526 static HRESULT
set_internet_feature(INTERNETFEATURELIST feature
, DWORD flags
, BOOL enable
)
528 const DWORD supported_flags
= SET_FEATURE_ON_PROCESS
;
530 if(feature
>= FEATURE_ENTRY_COUNT
)
533 if(flags
& ~supported_flags
) {
534 FIXME("Unsupported flags: %08x\n", flags
& ~supported_flags
);
538 if(flags
& SET_FEATURE_ON_PROCESS
)
539 set_feature_on_process(feature
, enable
);
544 static BOOL
get_feature_from_reg(HKEY feature_control
, LPCWSTR feature_name
, LPCWSTR process_name
, BOOL
*enabled
)
546 DWORD type
, value
, size
;
550 static const WCHAR wildcardW
[] = {'*',0};
552 res
= RegOpenKeyW(feature_control
, feature_name
, &feature
);
553 if(res
!= ERROR_SUCCESS
)
556 size
= sizeof(DWORD
);
557 res
= RegQueryValueExW(feature
, process_name
, NULL
, &type
, (BYTE
*)&value
, &size
);
558 if(res
!= ERROR_SUCCESS
|| type
!= REG_DWORD
) {
559 size
= sizeof(DWORD
);
560 res
= RegQueryValueExW(feature
, wildcardW
, NULL
, &type
, (BYTE
*)&value
, &size
);
563 RegCloseKey(feature
);
564 if(res
!= ERROR_SUCCESS
)
567 if(type
!= REG_DWORD
) {
568 WARN("Unexpected registry value type %d (expected REG_DWORD) for %s\n", type
, debugstr_w(wildcardW
));
572 *enabled
= value
== 1;
576 /* Assumes 'process_features_cs' is held. */
577 static HRESULT
load_process_feature(INTERNETFEATURELIST feature
)
580 HKEY feature_control
;
581 WCHAR module_name
[MAX_PATH
];
582 LPCWSTR process_name
, feature_name
;
583 HRESULT hres
= S_FALSE
;
584 BOOL check_hklm
= FALSE
;
587 if (!GetModuleFileNameW(NULL
, module_name
, sizeof(module_name
)/sizeof(WCHAR
))) {
588 ERR("Failed to get module file name: %u\n", GetLastError());
592 process_name
= strrchrW(module_name
, '\\');
594 ERR("Invalid module file name: %s\n", debugstr_w(module_name
));
598 /* Skip past the '\\' in front of the filename. */
601 feature_name
= process_feature_controls
[feature
].feature_name
;
603 res
= RegOpenKeyW(HKEY_CURRENT_USER
, feature_control_keyW
, &feature_control
);
604 if(res
== ERROR_SUCCESS
) {
605 if(get_feature_from_reg(feature_control
, feature_name
, process_name
, &enabled
)) {
606 hres
= enabled
? S_OK
: S_FALSE
;
607 process_feature_controls
[feature
].enabled
= enabled
;
609 /* We didn't find anything in HKCU, so check HKLM. */
612 RegCloseKey(feature_control
);
616 res
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, feature_control_keyW
, &feature_control
);
617 if(res
== ERROR_SUCCESS
) {
618 if(get_feature_from_reg(feature_control
, feature_name
, process_name
, &enabled
)) {
619 hres
= enabled
? S_OK
: S_FALSE
;
620 process_feature_controls
[feature
].enabled
= enabled
;
622 RegCloseKey(feature_control
);
626 /* Don't bother checking the registry again for this feature. */
627 process_feature_controls
[feature
].check_registry
= FALSE
;
632 static HRESULT
get_feature_from_process(INTERNETFEATURELIST feature
)
636 EnterCriticalSection(&process_features_cs
);
638 /* Try loading the feature from the registry, if it hasn't already
641 if(process_feature_controls
[feature
].check_registry
)
642 hres
= load_process_feature(feature
);
644 hres
= process_feature_controls
[feature
].enabled
? S_OK
: S_FALSE
;
646 LeaveCriticalSection(&process_features_cs
);
651 static HRESULT
get_internet_feature(INTERNETFEATURELIST feature
, DWORD flags
)
655 if(feature
>= FEATURE_ENTRY_COUNT
)
658 if(flags
== GET_FEATURE_FROM_PROCESS
)
659 hres
= get_feature_from_process(feature
);
661 FIXME("Unsupported flags: %08x\n", flags
);
668 /***********************************************************************
669 * CoInternetSetFeatureEnabled (URLMON.@)
671 HRESULT WINAPI
CoInternetSetFeatureEnabled(INTERNETFEATURELIST FeatureEntry
, DWORD dwFlags
, BOOL fEnable
)
673 TRACE("(%d, %08x, %x)\n", FeatureEntry
, dwFlags
, fEnable
);
674 return set_internet_feature(FeatureEntry
, dwFlags
, fEnable
);
677 /***********************************************************************
678 * CoInternetIsFeatureEnabled (URLMON.@)
680 HRESULT WINAPI
CoInternetIsFeatureEnabled(INTERNETFEATURELIST FeatureEntry
, DWORD dwFlags
)
682 TRACE("(%d, %08x)\n", FeatureEntry
, dwFlags
);
683 return get_internet_feature(FeatureEntry
, dwFlags
);
686 /***********************************************************************
687 * CoInternetIsFeatureEnabledForUrl (URLMON.@)
689 HRESULT WINAPI
CoInternetIsFeatureEnabledForUrl(INTERNETFEATURELIST FeatureEntry
, DWORD dwFlags
, LPCWSTR szURL
,
690 IInternetSecurityManager
*pSecMgr
)
695 TRACE("(%d %08x %s %p)\n", FeatureEntry
, dwFlags
, debugstr_w(szURL
), pSecMgr
);
697 if(FeatureEntry
== FEATURE_MIME_SNIFFING
)
698 urlaction
= URLACTION_FEATURE_MIME_SNIFFING
;
699 else if(FeatureEntry
== FEATURE_WINDOW_RESTRICTIONS
)
700 urlaction
= URLACTION_FEATURE_WINDOW_RESTRICTIONS
;
701 else if(FeatureEntry
== FEATURE_ZONE_ELEVATION
)
702 urlaction
= URLACTION_FEATURE_ZONE_ELEVATION
;
704 if(!szURL
|| !urlaction
|| !pSecMgr
)
705 return CoInternetIsFeatureEnabled(FeatureEntry
, dwFlags
);
708 case GET_FEATURE_FROM_THREAD
:
709 case GET_FEATURE_FROM_THREAD_LOCALMACHINE
:
710 case GET_FEATURE_FROM_THREAD_INTRANET
:
711 case GET_FEATURE_FROM_THREAD_TRUSTED
:
712 case GET_FEATURE_FROM_THREAD_INTERNET
:
713 case GET_FEATURE_FROM_THREAD_RESTRICTED
:
714 FIXME("unsupported flags %x\n", dwFlags
);
717 case GET_FEATURE_FROM_PROCESS
:
718 hres
= CoInternetIsFeatureEnabled(FeatureEntry
, dwFlags
);
724 DWORD policy
= URLPOLICY_DISALLOW
;
726 hres
= IInternetSecurityManager_ProcessUrlAction(pSecMgr
, szURL
, urlaction
,
727 (BYTE
*)&policy
, sizeof(DWORD
), NULL
, 0, PUAF_NOUI
, 0);
728 if(hres
!=S_OK
|| policy
!=URLPOLICY_ALLOW
)
735 /***********************************************************************
736 * CoInternetIsFeatureZoneElevationEnabled (URLMON.@)
738 HRESULT WINAPI
CoInternetIsFeatureZoneElevationEnabled(LPCWSTR szFromURL
, LPCWSTR szToURL
,
739 IInternetSecurityManager
*pSecMgr
, DWORD dwFlags
)
743 TRACE("(%s %s %p %x)\n", debugstr_w(szFromURL
), debugstr_w(szToURL
), pSecMgr
, dwFlags
);
745 if(!pSecMgr
|| !szToURL
)
746 return CoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, dwFlags
);
749 case GET_FEATURE_FROM_THREAD
:
750 case GET_FEATURE_FROM_THREAD_LOCALMACHINE
:
751 case GET_FEATURE_FROM_THREAD_INTRANET
:
752 case GET_FEATURE_FROM_THREAD_TRUSTED
:
753 case GET_FEATURE_FROM_THREAD_INTERNET
:
754 case GET_FEATURE_FROM_THREAD_RESTRICTED
:
755 FIXME("unsupported flags %x\n", dwFlags
);
758 case GET_FEATURE_FROM_PROCESS
:
759 hres
= CoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, dwFlags
);
765 DWORD policy
= URLPOLICY_DISALLOW
;
767 hres
= IInternetSecurityManager_ProcessUrlAction(pSecMgr
, szToURL
,
768 URLACTION_FEATURE_ZONE_ELEVATION
, (BYTE
*)&policy
, sizeof(DWORD
),
769 NULL
, 0, PUAF_NOUI
, 0);
774 case URLPOLICY_ALLOW
:
776 case URLPOLICY_QUERY
:
777 FIXME("Ask user dialog not implemented\n");