ReactOS 0.4.17-dev-470-gf9e3448
sec_mgr.c
Go to the documentation of this file.
1/*
2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
3 * Copyright 2009-2011 Detlef Riekenberg
4 * Copyright 2011 Thomas Mullaly for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22#define CONST_VTABLE
23
24#include <wine/test.h>
25#include <stdarg.h>
26#include <stddef.h>
27#include <stdio.h>
28
29#include "windef.h"
30#include "winbase.h"
31#include "ole2.h"
32#include "urlmon.h"
33
34#include "initguid.h"
35
36#define URLZONE_CUSTOM URLZONE_USER_MIN+1
37#define URLZONE_CUSTOM2 URLZONE_CUSTOM+1
38
39#define DEFINE_EXPECT(func) \
40 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41
42#define SET_EXPECT(func) \
43 expect_ ## func = TRUE
44
45#define CHECK_EXPECT(func) \
46 do { \
47 ok(expect_ ##func, "unexpected call " #func "\n"); \
48 expect_ ## func = FALSE; \
49 called_ ## func = TRUE; \
50 }while(0)
51
52#define CHECK_EXPECT2(func) \
53 do { \
54 ok(expect_ ##func, "unexpected call " #func "\n"); \
55 called_ ## func = TRUE; \
56 }while(0)
57
58#define CHECK_CALLED(func) \
59 do { \
60 ok(called_ ## func, "expected " #func "\n"); \
61 expect_ ## func = called_ ## func = FALSE; \
62 }while(0)
63
64#define SET_CALLED(func) \
65 do { \
66 expect_ ## func = called_ ## func = FALSE; \
67 }while(0)
68
69DEFINE_EXPECT(ParseUrl_SECURITY_URL_input);
70DEFINE_EXPECT(ParseUrl_SECURITY_URL_input2);
71DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected);
72DEFINE_EXPECT(ParseUrl_SECURITY_URL_http);
73DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected);
74DEFINE_EXPECT(ProcessUrlAction);
75
76static HRESULT (WINAPI *pCoInternetCreateSecurityManager)(IServiceProvider *, IInternetSecurityManager**, DWORD);
77static HRESULT (WINAPI *pCoInternetCreateZoneManager)(IServiceProvider *, IInternetZoneManager**, DWORD);
78static HRESULT (WINAPI *pCoInternetGetSecurityUrl)(LPCWSTR, LPWSTR*, PSUACTION, DWORD);
79static HRESULT (WINAPI *pCoInternetGetSecurityUrlEx)(IUri*, IUri**, PSUACTION, DWORD_PTR);
80static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
81static HRESULT (WINAPI *pCoInternetGetSession)(DWORD, IInternetSession**, DWORD);
82static HRESULT (WINAPI *pCoInternetIsFeatureEnabled)(INTERNETFEATURELIST, DWORD);
83static HRESULT (WINAPI *pCoInternetIsFeatureEnabledForUrl)(INTERNETFEATURELIST, DWORD, LPCWSTR, IInternetSecurityManager*);
84static HRESULT (WINAPI *pCoInternetIsFeatureZoneElevationEnabled)(LPCWSTR, LPCWSTR, IInternetSecurityManager*, DWORD);
85
86static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
87 '/','b','l','a','n','k','.','h','t','m',0};
88static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
89static const WCHAR url3[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
90static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
91 '%','2','e','j','p','g',0};
92static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
93 '.','w','i','n','e','t','e','s','t',0};
94static const WCHAR url6[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
95static const WCHAR url7[] = {'f','t','p',':','/','/','z','o','n','e','3',
96 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
97static const WCHAR url8[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
98static const WCHAR url9[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
99 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
100static const WCHAR url10[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
101 '.','j','p','g',0};
102static const WCHAR url11[] = {'f','i','l','e',':','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
103static const WCHAR url12[] = {'f','i','l','e',':','/','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
104static const WCHAR url13[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m',0};
105static const WCHAR url14[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',0};
106static const WCHAR url15[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','c','o','m','.','u','k',0};
107static const WCHAR url16[] = {'f','i','l','e',':','/','/','/','c',':',0};
108static const WCHAR url17[] = {'f','i','l','e',':','/','/','/','c',':','c','\\',0};
109static const WCHAR url18[] = {'c',':','\\','t','e','s','t','.','h','t','m',0};
110
111static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
112static const WCHAR security_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
113static const WCHAR security_url2W[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g','2',0};
114static const WCHAR security_expectedW[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
115static const WCHAR winetest_to_httpW[] = {'w','i','n','e','t','e','s','t',':','h',0};
116
117static const char *szZoneMapDomainsKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains";
118static const char *szInternetSettingsKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
119
120static const BYTE secid1[] = {'f','i','l','e',':',0,0,0,0};
121static const BYTE secid2[] = {'*',':','i','n','d','e','x','.','h','t','m',3,0,0,0};
122static const BYTE secid5[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
123 '.','w','i','n','e','t','e','s','t',3,0,0,0};
124static const BYTE secid6[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
125static const BYTE secid7[] = {'f','t','p',':','z','o','n','e','3',
126 '.','w','i','n','e','t','e','s','t',3,0,0,0};
127static const BYTE secid10[] =
128 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
129static const BYTE secid14[] =
130 {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',3,0,0,0};
131static const BYTE secid10_2[] =
132 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
133static const BYTE secid13[] = {'h','t','t','p',':','c','o','m','.','u','k',3,0,0,0};
134static const BYTE secid13_2[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m','.','u','k',3,0,0,0};
135
137 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
138
139/* Defined as extern in urlmon.idl, but not exported by uuid.lib */
141 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
142
145
146static struct secmgr_test {
151 const BYTE *secid;
153} secmgr_tests[] = {
154 {url1, 0, S_OK, sizeof(secid1), secid1, S_OK},
155 {url2, 100, 0x80041001, 0, NULL, E_INVALIDARG},
156 {url3, 0, S_OK, sizeof(secid1), secid1, S_OK},
157 {url5, 3, S_OK, sizeof(secid5), secid5, S_OK},
158 {url6, 3, S_OK, sizeof(secid6), secid6, S_OK},
159 {url7, 3, S_OK, sizeof(secid7), secid7, S_OK},
160 {url11,0, S_OK, sizeof(secid1), secid1, S_OK},
161 {url12,0, S_OK, sizeof(secid1), secid1, S_OK},
162 {url16,0, S_OK, sizeof(secid1), secid1, S_OK},
163 {url17,0, S_OK, sizeof(secid1), secid1, S_OK},
164 {url18,0, S_OK, sizeof(secid1), secid1, S_OK}
166
167static int strcmp_w(const WCHAR *str1, const WCHAR *str2)
168{
169 DWORD len1 = lstrlenW(str1);
170 DWORD len2 = lstrlenW(str2);
171
172 if(len1!=len2) return 1;
173 return memcmp(str1, str2, len1*sizeof(WCHAR));
174}
175
176
177/* Based on RegDeleteTreeW from dlls/advapi32/registry.c */
179{
180 LONG ret;
181 DWORD dwMaxSubkeyLen, dwMaxValueLen;
182 DWORD dwMaxLen, dwSize;
183 CHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
184 HKEY hSubKey = hKey;
185
186 if(lpszSubKey)
187 {
188 ret = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
189 if (ret) return ret;
190 }
191
192 /* Get highest length for keys, values */
193 ret = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, NULL,
194 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
195 if (ret) goto cleanup;
196
197 dwMaxSubkeyLen++;
198 dwMaxValueLen++;
199 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
200 if (dwMaxLen > ARRAY_SIZE(szNameBuf))
201 {
202 /* Name too big: alloc a buffer for it */
203 if (!(lpszName = malloc(dwMaxLen)))
204 {
206 goto cleanup;
207 }
208 }
209
210 /* Recursively delete all the subkeys */
211 while (TRUE)
212 {
213 dwSize = dwMaxLen;
214 if (RegEnumKeyExA(hSubKey, 0, lpszName, &dwSize, NULL,
215 NULL, NULL, NULL)) break;
216
217 ret = myRegDeleteTreeA(hSubKey, lpszName);
218 if (ret) goto cleanup;
219 }
220
221 if (lpszSubKey)
222 ret = RegDeleteKeyA(hKey, lpszSubKey);
223 else
224 while (TRUE)
225 {
226 dwSize = dwMaxLen;
227 if (RegEnumValueA(hKey, 0, lpszName, &dwSize,
228 NULL, NULL, NULL, NULL)) break;
229
230 ret = RegDeleteValueA(hKey, lpszName);
231 if (ret) goto cleanup;
232 }
233
234cleanup:
235 /* Free buffer if allocated */
236 if (lpszName != szNameBuf)
237 free(lpszName);
238 if(lpszSubKey)
239 RegCloseKey(hSubKey);
240 return ret;
241}
242
244 REFIID riid, void **ppvObject)
245{
246 ok(0, "unexpected call\n");
247 return E_NOTIMPL;
248}
249
251{
252 return 2;
253}
254
256{
257 return 1;
258}
259
262{
263 ok(0, "unexpected call\n");
264 return E_NOTIMPL;
265}
266
269{
270 ok(0, "unexpected call\n");
271 return E_NOTIMPL;
272}
273
275 LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags)
276{
277 ok(0, "unexpected call\n");
278 return E_NOTIMPL;
279}
280
282 LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
283{
284 ok(0, "unexpected call\n");
285 return E_NOTIMPL;
286}
287
289 LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy,
290 BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved)
291{
292 CHECK_EXPECT(ProcessUrlAction);
293 ok(dwAction == URLACTION_FEATURE_ZONE_ELEVATION, "dwAction = %lx\n", dwAction);
294 ok(cbPolicy == sizeof(DWORD), "cbPolicy = %ld\n", cbPolicy);
295 ok(!pContext, "pContext != NULL\n");
296 ok(dwFlags == PUAF_NOUI, "dwFlags = %lx\n", dwFlags);
297 ok(dwReserved == 0, "dwReserved = %lx\n", dwReserved);
298
299 *pPolicy = ProcessUrlAction_policy;
300 return ProcessUrlAction_policy==URLPOLICY_ALLOW ? S_OK : S_FALSE;
301}
302
304 LPCWSTR pwszUrl, REFGUID guidKey, BYTE **ppPolicy, DWORD *pcbPolicy,
305 BYTE *pContext, DWORD cbContext, DWORD dwReserved)
306{
307 ok(0, "unexpected call\n");
308 return E_NOTIMPL;
309}
310
312 DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags)
313{
314 ok(0, "unexpected call\n");
315 return E_NOTIMPL;
316}
317
319 DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
320{
321 ok(0, "unexpected call\n");
322 return E_NOTIMPL;
323}
324
325static const IInternetSecurityManagerVtbl SecurityManagerVtbl = {
337};
338
340
341static void test_SecurityManager(void)
342{
343 int i;
345 BYTE buf[512];
348
349 if(!pCoInternetCreateSecurityManager) {
350 return;
351 }
352
353 trace("Testing security manager...\n");
354
355 hres = pCoInternetCreateSecurityManager(NULL, &secmgr, 0);
356 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
357 if(FAILED(hres))
358 return;
359
360 for(i = 0; i < ARRAY_SIZE(secmgr_tests); i++) {
361 zone = 100;
362 hres = IInternetSecurityManager_MapUrlToZone(secmgr, secmgr_tests[i].url,
363 &zone, 0);
364 ok(hres == secmgr_tests[i].zone_hres /* IE <=6 */
365 || (FAILED(secmgr_tests[i].zone_hres) && hres == E_INVALIDARG), /* IE7 */
366 "[%d] MapUrlToZone failed: %08lx, expected %08lx\n",
367 i, hres, secmgr_tests[i].zone_hres);
368 if(SUCCEEDED(hres))
369 ok(zone == secmgr_tests[i].zone, "[%d] zone=%ld, expected %ld\n", i, zone,
371 else
372 ok(zone == secmgr_tests[i].zone || zone == -1, "[%d] zone=%ld\n", i, zone);
373
374 size = sizeof(buf);
375 memset(buf, 0xf0, sizeof(buf));
376 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[i].url,
377 buf, &size, 0);
379 "[%d] GetSecurityId failed: %08lx, expected %08lx\n",
381 if(secmgr_tests[i].secid) {
382 ok(size == secmgr_tests[i].secid_size, "[%d] size=%ld, expected %ld\n",
384 ok(!memcmp(buf, secmgr_tests[i].secid, size), "[%d] wrong secid\n", i);
385 }
386 }
387
388 zone = 100;
389 hres = IInternetSecurityManager_MapUrlToZone(secmgr, url10, &zone, 0);
390 ok(hres == S_OK, "MapUrlToZone failed: %08lx, expected S_OK\n", hres);
391 ok(zone == 3, "zone=%ld, expected 3\n", zone);
392
393 /* win2k3 translates %20 into a space */
394 size = sizeof(buf);
395 memset(buf, 0xf0, sizeof(buf));
396 hres = IInternetSecurityManager_GetSecurityId(secmgr, url10, buf, &size, 0);
397 ok(hres == S_OK, "GetSecurityId failed: %08lx, expected S_OK\n", hres);
398 ok(size == sizeof(secid10) ||
399 size == sizeof(secid10_2), /* win2k3 */
400 "size=%ld\n", size);
401 ok(!memcmp(buf, secid10, sizeof(secid10)) ||
402 !memcmp(buf, secid10_2, sizeof(secid10_2)), /* win2k3 */
403 "wrong secid\n");
404
405 zone = 100;
406 hres = IInternetSecurityManager_MapUrlToZone(secmgr, url13, &zone, 0);
407 ok(hres == S_OK, "MapUrlToZone failed: %08lx\n", hres);
408 ok(zone == URLZONE_INVALID || broken(zone == URLZONE_INTERNET), "zone=%ld\n", zone);
409
410 size = sizeof(buf);
411 memset(buf, 0xf0, sizeof(buf));
412 hres = IInternetSecurityManager_GetSecurityId(secmgr, url13, buf, &size, 0);
413 ok(hres == E_INVALIDARG || broken(hres == S_OK), "GetSecurityId failed: %08lx\n", hres);
414
415 zone = 100;
416 hres = IInternetSecurityManager_MapUrlToZone(secmgr, url14, &zone, 0);
417 ok(hres == S_OK, "MapUrlToZone failed: %08lx, expected S_OK\n", hres);
418 ok(zone == URLZONE_INTERNET, "zone=%ld\n", zone);
419
420 size = sizeof(buf);
421 memset(buf, 0xf0, sizeof(buf));
422 hres = IInternetSecurityManager_GetSecurityId(secmgr, url14, buf, &size, 0);
423 ok(hres == S_OK, "GetSecurityId failed: %08lx, expected S_OK\n", hres);
424 ok(size == sizeof(secid14), "size=%ld\n", size);
425 ok(!memcmp(buf, secid14, size), "wrong secid\n");
426
427 zone = 100;
428 hres = IInternetSecurityManager_MapUrlToZone(secmgr, NULL, &zone, 0);
429 ok(hres == E_INVALIDARG, "MapUrlToZone failed: %08lx, expected E_INVALIDARG\n", hres);
430 ok(zone == 100 || zone == -1, "zone=%ld\n", zone);
431
432 size = sizeof(buf);
433 hres = IInternetSecurityManager_GetSecurityId(secmgr, NULL, buf, &size, 0);
435 "GetSecurityId failed: %08lx, expected E_INVALIDARG\n", hres);
436 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[1].url,
437 NULL, &size, 0);
439 "GetSecurityId failed: %08lx, expected E_INVALIDARG\n", hres);
440 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[1].url,
441 buf, NULL, 0);
443 "GetSecurityId failed: %08lx, expected E_INVALIDARG\n", hres);
444
445 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, NULL, URLACTION_SCRIPT_RUN, (BYTE*)&policy,
446 sizeof(WCHAR), NULL, 0, 0, 0);
447 ok(hres == E_INVALIDARG, "ProcessUrlAction failed: %08lx, expected E_INVALIDARG\n", hres);
448
449 IInternetSecurityManager_Release(secmgr);
450}
451
452/* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
453/* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
455{
456 HKEY zone_map;
457 DWORD ie_harden, type, size;
458
459 ie_harden = 0;
460 if(RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
461 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
462 size = sizeof(DWORD);
463 if (RegQueryValueExA(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
464 type != REG_DWORD) {
465 ie_harden = 0;
466 }
467 RegCloseKey(zone_map);
468 }
469
470 return ie_harden != 0;
471}
472
474{
475 DWORD res, size, policy, reg_policy;
476 char buf[10];
477 HKEY hkey;
479
480 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
481 * The test should be changed to cope with that, if need be.
482 */
484 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey);
485 ok(res == ERROR_SUCCESS, "Could not open zone key\n");
486 if(res != ERROR_SUCCESS)
487 return;
488
489 wsprintfA(buf, "%X", action);
490 size = sizeof(DWORD);
491 res = RegQueryValueExA(hkey, buf, NULL, NULL, (BYTE*)&reg_policy, &size);
492 RegCloseKey(hkey);
493
494 /* Try settings from HKEY_LOCAL_MACHINE. */
495 if(res != ERROR_SUCCESS || size != sizeof(DWORD)) {
497 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey);
498 ok(res == ERROR_SUCCESS, "Could not open zone key\n");
499
500 size = sizeof(DWORD);
501 res = RegQueryValueExA(hkey, buf, NULL, NULL, (BYTE*)&reg_policy, &size);
502 RegCloseKey(hkey);
503 }
504
505 if(res != ERROR_SUCCESS || size != sizeof(DWORD)) {
506 policy = 0xdeadbeef;
507 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy,
508 sizeof(WCHAR), NULL, 0, 0, 0);
510 "(0x%lx) got 0x%lx (expected E_FAIL)\n", action, hres);
511 ok(policy == 0xdeadbeef, "(%lx) policy=%lx\n", action, policy);
512
513 policy = 0xdeadbeef;
514 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, (BYTE*)&policy,
515 sizeof(DWORD), URLZONEREG_DEFAULT);
517 "(0x%lx) got 0x%lx (expected E_FAIL)\n", action, hres);
518 ok(policy == 0xdeadbeef, "(%lx) policy=%lx\n", action, policy);
519 return;
520 }
521
522 policy = 0xdeadbeef;
523 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, (BYTE*)&policy,
524 sizeof(DWORD), URLZONEREG_DEFAULT);
525 ok(hres == S_OK, "GetZoneActionPolicy failed: %08lx\n", hres);
526 ok(policy == reg_policy, "(%lx) policy=%lx, expected %lx\n", action, policy, reg_policy);
527
528 if(policy != URLPOLICY_QUERY) {
530 BOOL expect_parse_call = !called_securl_http;
531
532 policy = 0xdeadbeef;
533 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy,
534 sizeof(WCHAR), NULL, 0, 0, 0);
535 if(reg_policy == URLPOLICY_DISALLOW)
536 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
537 else
538 ok(hres == S_OK, "ProcessUrlAction(%lx) failed: %08lx\n", action, hres);
539 ok(policy == 0xdeadbeef, "(%lx) policy=%lx\n", action, policy);
540
541 policy = 0xdeadbeef;
542 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy,
543 2, NULL, 0, 0, 0);
544 if(reg_policy == URLPOLICY_DISALLOW)
545 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
546 else
547 ok(hres == S_OK, "ProcessUrlAction(%lx) failed: %08lx\n", action, hres);
548 ok(policy == 0xdeadbeef, "(%lx) policy=%lx\n", action, policy);
549
550 policy = 0xdeadbeef;
551 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy,
552 sizeof(DWORD), NULL, 0, 0, 0);
553 if(reg_policy == URLPOLICY_DISALLOW)
554 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
555 else
556 ok(hres == S_OK, "ProcessUrlAction(%lx) failed: %08lx\n", action, hres);
557 ok(policy == reg_policy, "(%lx) policy=%lx\n", action, policy);
558
559 policy = 0xdeadbeef;
560 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy,
561 sizeof(WCHAR), (BYTE*)0xdeadbeef, 16, 0, 0);
562 if(reg_policy == URLPOLICY_DISALLOW)
563 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
564 else
565 ok(hres == S_OK, "ProcessUrlAction(%lx) failed: %08lx\n", action, hres);
566 ok(policy == 0xdeadbeef, "(%lx) policy=%lx\n", action, policy);
567
568 policy = 0xdeadbeef;
569 if(expect_parse_call)
570 SET_EXPECT(ParseUrl_SECURITY_URL_http);
571 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, winetest_to_httpW, action, (BYTE*)&policy,
572 sizeof(DWORD), NULL, 0, 0, 0);
573 if(expect_parse_call)
574 CHECK_CALLED(ParseUrl_SECURITY_URL_http);
575 if(reg_policy == URLPOLICY_DISALLOW)
576 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
577 else
578 ok(hres == S_OK, "ProcessUrlAction(%lx) failed: %08lx\n", action, hres);
579 ok(policy == reg_policy, "(%lx) policy=%lx\n", action, policy);
580 }else {
581 skip("IE running in Enhanced Security Configuration\n");
582 }
583 }
584}
585
587{
590
591 policy = 0xdeadbeef;
592 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, (BYTE*)&policy,
593 sizeof(DWORD), URLZONEREG_DEFAULT);
594 ok(hres == S_OK, "GetZoneActionPolicy failed: %08lx\n", hres);
595 ok(policy == URLPOLICY_DISALLOW, "(%lx) policy=%lx, expected URLPOLICY_DISALLOW\n", action, policy);
596
597 policy = 0xdeadbeef;
598 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url1, action, (BYTE*)&policy,
599 sizeof(WCHAR), NULL, 0, 0, 0);
600 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
601
602 policy = 0xdeadbeef;
603 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url1, action, (BYTE*)&policy,
604 sizeof(DWORD), NULL, 0, 0, 0);
605 ok(hres == S_FALSE, "ProcessUrlAction(%lx) failed: %08lx, expected S_FALSE\n", action, hres);
606 ok(policy == URLPOLICY_DISALLOW, "policy = %lx\n", policy);
607}
608
610{
611 DWORD policy, policy_size;
612 struct CONFIRMSAFETY cs;
613 BYTE *ppolicy;
615
616 policy = 0xdeadbeef;
617 hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url1, URLACTION_ACTIVEX_RUN, (BYTE*)&policy,
618 sizeof(DWORD), (BYTE*)&CLSID_TestActiveX, sizeof(CLSID), 0, 0);
619 ok(hres == S_OK, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08lx\n", hres);
620 ok(policy == URLPOLICY_ALLOW || policy == URLPOLICY_DISALLOW, "policy = %lx\n", policy);
621
622 cs.clsid = CLSID_TestActiveX;
623 cs.pUnk = (IUnknown*)0xdeadbeef;
624 cs.dwFlags = 0;
625 hres = IInternetSecurityManager_QueryCustomPolicy(secmgr, url1, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
626 &ppolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
627 ok(hres == HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "QueryCusromPolicy failed: %08lx\n", hres);
628}
629
630static void test_polices(void)
631{
632 IInternetZoneManager *zonemgr = NULL;
635
636 trace("testing polices...\n");
637
638 hres = pCoInternetCreateSecurityManager(NULL, &secmgr, 0);
639 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
640 hres = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
641 ok(hres == S_OK, "CoInternetCreateZoneManager failed: %08lx\n", hres);
642
643 test_url_action(secmgr, zonemgr, URLACTION_SCRIPT_RUN);
644 test_url_action(secmgr, zonemgr, URLACTION_ACTIVEX_RUN);
645 test_url_action(secmgr, zonemgr, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY);
646 test_url_action(secmgr, zonemgr, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS);
647 test_url_action(secmgr, zonemgr, 0xdeadbeef);
648
649 test_special_url_action(secmgr, zonemgr, URLACTION_SCRIPT_OVERRIDE_SAFETY);
650 test_special_url_action(secmgr, zonemgr, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY);
651
652 test_activex(secmgr);
653
654 IInternetSecurityManager_Release(secmgr);
655 IInternetZoneManager_Release(zonemgr);
656}
657
658/* IE (or at least newer versions of it) seem to cache the keys in ZoneMap
659 * when urlmon.dll is loaded and it doesn't seem to update its cache, unless
660 * SetZoneMapping is used.
661 */
662static void test_zone_domain_cache(void)
663{
665 DWORD res, zone;
667 HKEY domains, domain;
668
669 static const WCHAR testing_domain_urlW[] = {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.',
670 'd','o','m','a','i','n','/',0};
671
673 ok(res == ERROR_SUCCESS, "RegOpenKey failed: %ld\n", res);
674 if(res != ERROR_SUCCESS)
675 return;
676
677 res = RegCreateKeyA(domains, "testing.domain", &domain);
678 ok(res == ERROR_SUCCESS, "RegCreateKey failed: %ld\n", res);
679 if(res != ERROR_SUCCESS) {
680 RegCloseKey(domains);
681 return;
682 }
683
685 res = RegSetValueExA(domain, "http", 0, REG_DWORD, (BYTE*)&zone, sizeof(DWORD));
686 ok(res == ERROR_SUCCESS, "RegSetValueEx failed: %ld\n", res);
687
689
690 hres = pCoInternetCreateSecurityManager(NULL, &secmgr, 0);
691 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
692
693 zone = URLZONE_INVALID;
694 hres = IInternetSecurityManager_MapUrlToZone(secmgr, testing_domain_urlW, &zone, 0);
695 ok(hres == S_OK, "MapUrlToZone failed: %08lx\n", hres);
696 todo_wine ok(zone == URLZONE_INTERNET, "Got %ld, expected URLZONE_INTERNET\n", zone);
697
698 /* FIXME: Play nice with ZoneMaps that existed before the test is run. */
699 res = RegDeleteKeyA(domains, "testing.domain");
700 ok(res == ERROR_SUCCESS, "RegDeleteKey failed: %ld\n", res);
701
702 RegCloseKey(domains);
703 IInternetSecurityManager_Release(secmgr);
704}
705
706typedef struct {
707 const char *domain;
708 const char *subdomain;
709 const char *scheme;
712
713/* FIXME: Move these into SetZoneMapping tests when the day comes... */
715 /* Implicitly means "*.yabadaba.do". */
716 {"yabadaba.do",NULL,"http",URLZONE_CUSTOM},
717 /* The '*' doesn't count as a wildcard, since it's not the first component of the subdomain. */
718 {"super.cool","testing.*","ftp",URLZONE_CUSTOM2},
719 /* The '*' counts since it's the first component of the subdomain. */
720 {"super.cool","*.testing","ftp",URLZONE_CUSTOM2},
721 /* All known scheme types apply to wildcard schemes. */
722 {"tests.test",NULL,"*",URLZONE_CUSTOM},
723 /* Due to a defect with how windows checks the mappings, unknown scheme types
724 * never seem to get mapped properly. */
725 {"tests.test",NULL,"zip",URLZONE_CUSTOM},
726 {"www.testing.com",NULL,"http",URLZONE_CUSTOM},
727 {"www.testing.com","testing","http",URLZONE_CUSTOM2},
728 {"org",NULL,"http",URLZONE_CUSTOM},
729 {"org","testing","http",URLZONE_CUSTOM2},
730 {"wine.testing",NULL,"*",URLZONE_CUSTOM2}
731};
732
734{
735 HKEY domains;
736 DWORD res, i;
737
738 /* Some Windows versions don't seem to have a "Domains" key in their HKLM. */
740 ok(res == ERROR_SUCCESS || broken(res == ERROR_FILE_NOT_FOUND), "RegOpenKey failed: %ld\n", res);
741 if(res == ERROR_SUCCESS) {
742 HKEY domain;
744
745 res = RegCreateKeyA(domains, "local.machine", &domain);
747 {
748 skip("need admin rights\n");
749 RegCloseKey(domains);
750 return FALSE;
751 }
752 ok(res == ERROR_SUCCESS, "RegCreateKey failed: %ld\n", res);
753
754 res = RegSetValueExA(domain, "http", 0, REG_DWORD, (BYTE*)&zone, sizeof(DWORD));
755 ok(res == ERROR_SUCCESS, "RegSetValueEx failed: %ld\n", res);
756
758 RegCloseKey(domains);
759 }
760
762 ok(res == ERROR_SUCCESS, "RegOpenKey failed: %ld\n", res);
763
764 for(i = 0; i < ARRAY_SIZE(zone_domain_mappings); ++i) {
766 HKEY domain;
767
768 res = RegCreateKeyA(domains, test->domain, &domain);
769 ok(res == ERROR_SUCCESS, "RegCreateKey failed with %ld on test %ld\n", res, i);
770
771 /* Only set the value if there's no subdomain. */
772 if(!test->subdomain) {
773 res = RegSetValueExA(domain, test->scheme, 0, REG_DWORD, (BYTE*)&test->zone, sizeof(DWORD));
774 ok(res == ERROR_SUCCESS, "RegSetValueEx failed with %ld on test %ld\n", res, i);
775 } else {
776 HKEY subdomain;
777
778 res = RegCreateKeyA(domain, test->subdomain, &subdomain);
779 ok(res == ERROR_SUCCESS, "RegCreateKey failed with %ld on test %ld\n", res, i);
780
781 res = RegSetValueExA(subdomain, test->scheme, 0, REG_DWORD, (BYTE*)&test->zone, sizeof(DWORD));
782 ok(res == ERROR_SUCCESS, "RegSetValueEx failed with %ld on test %ld\n", res, i);
783
784 RegCloseKey(subdomain);
785 }
786
788 }
789
790 RegCloseKey(domains);
791 return TRUE;
792}
793
794static void unregister_zone_domains(void)
795{
796 HKEY domains;
797 DWORD res, i;
798
800 ok(res == ERROR_SUCCESS || broken(res == ERROR_FILE_NOT_FOUND), "RegOpenKey failed: %ld\n", res);
801 if(res == ERROR_SUCCESS) {
802 RegDeleteKeyA(domains, "local.machine");
803 RegCloseKey(domains);
804 }
805
807 ok(res == ERROR_SUCCESS, "RegOpenKey failed: %ld\n", res);
808
809 for(i = 0; i < ARRAY_SIZE(zone_domain_mappings); ++i) {
811
812 /* FIXME: Uses the "cludge" approach to remove the test data from the registry!
813 * Although, if domain names are... unique, this shouldn't cause any harm
814 * to keys (if any) that existed before the tests.
815 */
816 if(test->subdomain) {
817 HKEY domain;
818
819 res = RegOpenKeyA(domains, test->domain, &domain);
820 if(res == ERROR_SUCCESS) {
821 RegDeleteKeyA(domain, test->subdomain);
823 }
824 }
825 RegDeleteKeyA(domains, test->domain);
826 }
827
828 RegCloseKey(domains);
829}
830
831static void run_child_process(void)
832{
833 char cmdline[MAX_PATH];
834 char path[MAX_PATH];
835 char **argv;
837 STARTUPINFOA si = { 0 };
838 BOOL ret;
839
841
842 si.cb = sizeof(si);
844 sprintf(cmdline, "\"%s\" %s domain_tests", argv[0], argv[1]);
846 ok(ret, "Failed to spawn child process: %lu\n", GetLastError());
850}
851
852typedef struct {
853 const WCHAR *url;
858
860 /* Tests for "yabadaba.do" zone mappings. */
861 {L"http://yabadaba.do/", URLZONE_CUSTOM},
862 {L"http://google.yabadaba.do/", URLZONE_CUSTOM},
863 {L"zip://yabadaba.do/", URLZONE_INTERNET},
864 /* Tests for "super.cool" zone mappings. */
865 {L"ftp://testing.google.super.cool/", URLZONE_INTERNET},
866 {L"ftp://testing.*.super.cool/", URLZONE_CUSTOM2},
867 {L"ftp://google.testing.super.cool/", URLZONE_CUSTOM2},
868 /* Tests for "tests.test" zone mappings. */
869 {L"http://tests.test/", URLZONE_CUSTOM},
870 {L"http://www.tests.test/", URLZONE_CUSTOM},
871 {L"ftp://tests.test/", URLZONE_CUSTOM},
872 {L"ftp://www.tests.test/", URLZONE_CUSTOM},
873 {L"test://www.tests.test/", URLZONE_INTERNET},
874 {L"test://tests.test/", URLZONE_INTERNET},
875 {L"zip://www.tests.test/", URLZONE_INTERNET},
876 {L"zip://tests.test/", URLZONE_INTERNET},
877 /* Tests for "www.testing.com" zone mappings. */
878 {L"http://google.www.testing.com/", URLZONE_INTERNET},
879 {L"http://www.testing.com/", URLZONE_CUSTOM, FALSE, URLZONE_INTERNET},
880 {L"http://testing.www.testing.com/", URLZONE_CUSTOM2, FALSE, URLZONE_INTERNET},
881 /* Tests for "org" zone mappings. */
882 {L"http://google.org/", URLZONE_INTERNET, FALSE, URLZONE_CUSTOM},
883 {L"http://org/", URLZONE_CUSTOM},
884 {L"http://testing.org/", URLZONE_CUSTOM2},
885 /* Tests for "wine.testing" mapping */
886 {L"*:wine.testing/test", URLZONE_CUSTOM2},
887 {L"http://wine.testing/testing", URLZONE_CUSTOM2}
888};
889
891{
893 DWORD i, res;
895 HKEY domains;
896 DWORD zone = URLZONE_INVALID;
897
898 trace("testing zone domain mappings...\n");
899
900 hres = pCoInternetCreateSecurityManager(NULL, &secmgr, 0);
901 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
902
904 if(res == ERROR_SUCCESS) {
905 static const WCHAR local_machineW[] = {'h','t','t','p',':','/','/','t','e','s','t','.','l','o','c','a','l',
906 '.','m','a','c','h','i','n','e','/',0};
907
908 hres = IInternetSecurityManager_MapUrlToZone(secmgr, local_machineW, &zone, 0);
909 ok(hres == S_OK, "MapUrlToZone failed: %08lx\n", hres);
910 ok(zone == URLZONE_CUSTOM, "Expected URLZONE_CUSTOM, but got %ld\n", zone);
911
912 RegCloseKey(domains);
913 }
914
915 for(i = 0; i < ARRAY_SIZE(zone_mapping_tests); ++i) {
917 zone = URLZONE_INVALID;
918
919 hres = IInternetSecurityManager_MapUrlToZone(secmgr, test->url, &zone, 0);
920 ok(hres == S_OK, "MapUrlToZone failed: %08lx\n", hres);
921 todo_wine_if (test->todo)
922 ok(zone == test->zone || broken(test->broken_zone == zone),
923 "Expected %ld, but got %ld on test %ld\n", test->zone, zone, i);
924 }
925
926 IInternetSecurityManager_Release(secmgr);
927}
928
929static void test_zone_domains(void)
930{
931 if(is_ie_hardened()) {
932 skip("IE running in Enhanced Security Configuration\n");
933 return;
934 } else if(!pCreateUri) {
935 win_skip("Skipping zone domain tests, IE too old\n");
936 return;
937 }
938
939 trace("testing zone domains...\n");
940
942
943 if (!register_zone_domains()) return;
946}
947
949{
950 IInternetZoneManager *zonemgr = NULL;
951 IUnknown *punk = NULL;
952 HRESULT hr;
953
954 trace("simple zone manager tests...\n");
955
956 hr = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
957 ok(hr == S_OK, "CoInternetCreateZoneManager result: 0x%lx\n", hr);
958 if (FAILED(hr))
959 return;
960
961 hr = IInternetZoneManager_QueryInterface(zonemgr, &IID_IUnknown, (void **) &punk);
962 ok(SUCCEEDED(hr), "got 0x%lx with %p (expected Success)\n", hr, punk);
963 if (punk)
964 IUnknown_Release(punk);
965
966 hr = IInternetZoneManager_QueryInterface(zonemgr, &IID_IInternetZoneManager, (void **) &punk);
967 ok(SUCCEEDED(hr), "got 0x%lx with %p (expected Success)\n", hr, punk);
968 if (punk)
969 IUnknown_Release(punk);
970
971
972 hr = IInternetZoneManager_QueryInterface(zonemgr, &IID_IInternetZoneManagerEx, (void **) &punk);
973 if (SUCCEEDED(hr)) {
974 IUnknown_Release(punk);
975
976 hr = IInternetZoneManager_QueryInterface(zonemgr, &IID_IInternetZoneManagerEx2, (void **) &punk);
977 ok(hr == S_OK || broken(hr == E_NOINTERFACE /* some W2K3 */),
978 "got 0x%lx (expected S_OK)\n", hr);
979 if (punk)
980 IUnknown_Release(punk);
981 else
982 win_skip("InternetZoneManagerEx2 not supported\n");
983
984 }
985 else
986 win_skip("InternetZoneManagerEx not supported\n");
987
988 hr = IInternetZoneManager_Release(zonemgr);
989 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
990
991}
992
994{
995 IInternetZoneManager *zonemgr = NULL;
996 HRESULT hr;
997 DWORD dwEnum;
998 DWORD dwEnum2;
999 DWORD dwCount;
1000 DWORD dwCount2;
1001
1002 trace("testing zone enumerator...\n");
1003
1004 hr = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
1005 ok(hr == S_OK, "CoInternetCreateZoneManager result: 0x%lx\n", hr);
1006 if (FAILED(hr))
1007 return;
1008
1009 dwEnum=0xdeadbeef;
1010 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, &dwEnum, NULL, 0);
1011 ok((hr == E_INVALIDARG) && (dwEnum == 0xdeadbeef),
1012 "got 0x%lx with 0x%lx (expected E_INVALIDARG with 0xdeadbeef)\n", hr, dwEnum);
1013
1014 dwCount=0xdeadbeef;
1015 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, NULL, &dwCount, 0);
1016 ok((hr == E_INVALIDARG) && (dwCount == 0xdeadbeef),
1017 "got 0x%lx and 0x%lx (expected E_INVALIDARG and 0xdeadbeef)\n", hr, dwCount);
1018
1019 dwEnum=0xdeadbeef;
1020 dwCount=0xdeadbeef;
1021 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, &dwEnum, &dwCount, 0xffffffff);
1022 ok((hr == E_INVALIDARG) && (dwEnum == 0xdeadbeef) && (dwCount == 0xdeadbeef),
1023 "got 0x%lx with 0x%lx and 0x%lx (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1024 hr, dwEnum, dwCount);
1025
1026 dwEnum=0xdeadbeef;
1027 dwCount=0xdeadbeef;
1028 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, &dwEnum, &dwCount, 1);
1029 ok((hr == E_INVALIDARG) && (dwEnum == 0xdeadbeef) && (dwCount == 0xdeadbeef),
1030 "got 0x%lx with 0x%lx and 0x%lx (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1031 hr, dwEnum, dwCount);
1032
1033 dwEnum=0xdeadbeef;
1034 dwCount=0xdeadbeef;
1035 /* Normal use */
1036 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, &dwEnum, &dwCount, 0);
1037 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1038
1039 if (SUCCEEDED(hr)) {
1040 dwEnum2=0xdeadbeef;
1041 dwCount2=0xdeadbeef;
1042 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, &dwEnum2, &dwCount2, 0);
1043 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1044 if (SUCCEEDED(hr)) {
1045 /* native urlmon has an incrementing counter for dwEnum */
1046 hr = IInternetZoneManager_DestroyZoneEnumerator(zonemgr, dwEnum2);
1047 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1048 }
1049
1050 hr = IInternetZoneManager_DestroyZoneEnumerator(zonemgr, dwEnum);
1051 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1052
1053 /* Destroy the Enumerator twice is detected and handled in native urlmon */
1054 hr = IInternetZoneManager_DestroyZoneEnumerator(zonemgr, dwEnum);
1055 ok((hr == E_INVALIDARG), "got 0x%lx (expected E_INVALIDARG)\n", hr);
1056 }
1057
1058 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
1059 hr = IInternetZoneManager_Release(zonemgr);
1060 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1061}
1062
1064{
1065 IInternetZoneManager *zonemgr = NULL;
1066 BYTE buf[32];
1067 HRESULT hres;
1068 DWORD action = URLACTION_CREDENTIALS_USE; /* Implemented on all IE versions */
1069
1070 trace("testing GetZoneActionPolixy...\n");
1071
1072 hres = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
1073 ok(hres == S_OK, "CoInternetCreateZoneManager failed: %08lx\n", hres);
1074 if(FAILED(hres))
1075 return;
1076
1077 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, buf,
1078 sizeof(DWORD), URLZONEREG_DEFAULT);
1079 ok(hres == S_OK, "GetZoneActionPolicy failed: %08lx\n", hres);
1080 ok(*(DWORD*)buf == URLPOLICY_CREDENTIALS_SILENT_LOGON_OK ||
1081 *(DWORD*)buf == URLPOLICY_CREDENTIALS_MUST_PROMPT_USER ||
1082 *(DWORD*)buf == URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT ||
1083 *(DWORD*)buf == URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY,
1084 "unexpected policy=%ld\n", *(DWORD*)buf);
1085
1086 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, NULL,
1087 sizeof(DWORD), URLZONEREG_DEFAULT);
1088 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08lx, expected E_INVALIDARG\n", hres);
1089
1090 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, buf,
1091 2, URLZONEREG_DEFAULT);
1092 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08lx, expected E_INVALIDARG\n", hres);
1093
1094 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1fff, buf,
1095 sizeof(DWORD), URLZONEREG_DEFAULT);
1097 "(0x%lx) got 0x%lx (expected E_FAIL)\n", action, hres);
1098
1099 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 13, action, buf,
1100 sizeof(DWORD), URLZONEREG_DEFAULT);
1101 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08lx, expected E_INVALIDARG\n", hres);
1102
1103 IInternetZoneManager_Release(zonemgr);
1104}
1105
1106static void test_GetZoneAt(void)
1107{
1108 IInternetZoneManager *zonemgr = NULL;
1109 HRESULT hr;
1110 DWORD dwEnum;
1111 DWORD dwCount;
1112 DWORD dwZone;
1113 DWORD i;
1114
1115 trace("testing GetZoneAt...\n");
1116
1117 hr = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
1118 ok(hr == S_OK, "CoInternetCreateZoneManager result: 0x%lx\n", hr);
1119 if (FAILED(hr))
1120 return;
1121
1122 hr = IInternetZoneManager_CreateZoneEnumerator(zonemgr, &dwEnum, &dwCount, 0);
1123 if (FAILED(hr))
1124 goto cleanup;
1125
1126 if (0) {
1127 /* this crashes with native urlmon */
1128 IInternetZoneManager_GetZoneAt(zonemgr, dwEnum, 0, NULL);
1129 }
1130
1131 dwZone = 0xdeadbeef;
1132 hr = IInternetZoneManager_GetZoneAt(zonemgr, 0xdeadbeef, 0, &dwZone);
1133 ok(hr == E_INVALIDARG,
1134 "got 0x%lx with 0x%lx (expected E_INVALIDARG)\n", hr, dwZone);
1135
1136 for (i = 0; i < dwCount; i++)
1137 {
1138 dwZone = 0xdeadbeef;
1139 hr = IInternetZoneManager_GetZoneAt(zonemgr, dwEnum, i, &dwZone);
1140 ok(hr == S_OK, "#%ld: got x%lx with %ld (expected S_OK)\n", i, hr, dwZone);
1141 }
1142
1143 dwZone = 0xdeadbeef;
1144 /* MSDN (index .. must be .. less than or equal to) is wrong */
1145 hr = IInternetZoneManager_GetZoneAt(zonemgr, dwEnum, dwCount, &dwZone);
1146 ok(hr == E_INVALIDARG,
1147 "got 0x%lx with 0x%lx (expected E_INVALIDARG)\n", hr, dwZone);
1148
1149 hr = IInternetZoneManager_DestroyZoneEnumerator(zonemgr, dwEnum);
1150 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1151
1152cleanup:
1153 hr = IInternetZoneManager_Release(zonemgr);
1154 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1155}
1156
1157static void test_GetZoneAttributes(void)
1158{
1159 IInternetZoneManager *zonemgr = NULL;
1160 CHAR buffer [sizeof(ZONEATTRIBUTES) + 32];
1161 ZONEATTRIBUTES* pZA = (ZONEATTRIBUTES*) buffer;
1162 HRESULT hr;
1163 DWORD i;
1164
1165 trace("testing GetZoneAttributes...\n");
1166
1167 hr = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
1168 ok(hr == S_OK, "CoInternetCreateZoneManager result: 0x%lx\n", hr);
1169 if (FAILED(hr))
1170 return;
1171
1172 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
1173 for (i = 0; i < 5; i++) {
1174 memset(buffer, -1, sizeof(buffer));
1175 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, i, pZA);
1176 ok(hr == S_OK, "#%ld: got 0x%lx (expected S_OK)\n", i, hr);
1177 }
1178
1179 /* IE8 no longer set cbSize */
1180 memset(buffer, -1, sizeof(buffer));
1181 pZA->cbSize = 0;
1182 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, 0, pZA);
1183 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1184 ok((pZA->cbSize == 0) || (pZA->cbSize == sizeof(ZONEATTRIBUTES)),
1185 "got cbSize = %ld (expected 0)\n", pZA->cbSize);
1186
1187 memset(buffer, -1, sizeof(buffer));
1188 pZA->cbSize = 64;
1189 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, 0, pZA);
1190 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1191 ok((pZA->cbSize == 64) || (pZA->cbSize == sizeof(ZONEATTRIBUTES)),
1192 "got cbSize = %ld (expected 64)\n", pZA->cbSize);
1193
1194 memset(buffer, -1, sizeof(buffer));
1195 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, 0, pZA);
1196 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1197 ok((pZA->cbSize == 0xffffffff) || (pZA->cbSize == sizeof(ZONEATTRIBUTES)),
1198 "got cbSize = 0x%lx (expected 0xffffffff)\n", pZA->cbSize);
1199
1200 /* IE8 up to IE10 don't fail on invalid zones */
1201 memset(buffer, -1, sizeof(buffer));
1202 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, 0xdeadbeef, pZA);
1203 ok(hr == S_OK || hr == E_FAIL || hr == E_POINTER,
1204 "got 0x%lx (expected S_OK or E_FAIL)\n", hr);
1205
1206 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, 0, NULL);
1207 ok(hr == E_INVALIDARG, "got 0x%lx (expected E_INVALIDARG)\n", hr);
1208
1209 hr = IInternetZoneManager_Release(zonemgr);
1210 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1211}
1212
1213static void test_SetZoneAttributes(void)
1214{
1215 IInternetZoneManager *zonemgr = NULL;
1216 CHAR buffer [sizeof(ZONEATTRIBUTES) + 16];
1217 ZONEATTRIBUTES* pZA = (ZONEATTRIBUTES*) buffer;
1218 CHAR regpath[MAX_PATH];
1219 HKEY hkey;
1220 HRESULT hr;
1221 DWORD res;
1222
1223 trace("testing SetZoneAttributes...\n");
1224 hr = pCoInternetCreateZoneManager(NULL, &zonemgr, 0);
1225 ok(hr == S_OK, "CoInternetCreateZoneManager result: 0x%lx\n", hr);
1226 if (FAILED(hr))
1227 return;
1228
1229 memset(buffer, -1, sizeof(buffer));
1230 hr = IInternetZoneManager_GetZoneAttributes(zonemgr, URLZONE_LOCAL_MACHINE, pZA);
1231 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1232
1233 sprintf(regpath, "%s\\Zones\\%d", szInternetSettingsKey, URLZONE_CUSTOM);
1234 res = RegCreateKeyA(HKEY_CURRENT_USER, regpath, &hkey);
1235 RegCloseKey(hkey);
1236
1237 ok(res == ERROR_SUCCESS, "got %ld (expected ERROR_SUCCESS)\n", res);
1238 if (res != ERROR_SUCCESS)
1239 goto cleanup;
1240
1241 pZA->cbSize = sizeof(ZONEATTRIBUTES);
1242 hr = IInternetZoneManager_SetZoneAttributes(zonemgr, URLZONE_CUSTOM, NULL);
1243 ok(hr == E_INVALIDARG, "got 0x%lx (expected E_INVALIDARG)\n", hr);
1244
1245 /* normal use */
1246 hr = IInternetZoneManager_SetZoneAttributes(zonemgr, URLZONE_CUSTOM, pZA);
1247 if (hr == E_FAIL) {
1248 win_skip("SetZoneAttributes not supported: IE too old\n");
1249 goto cleanup;
1250 }
1251 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1252
1253 /* native urlmon ignores cbSize */
1254 pZA->cbSize = sizeof(ZONEATTRIBUTES) + sizeof(DWORD);
1255 hr = IInternetZoneManager_SetZoneAttributes(zonemgr, URLZONE_CUSTOM, pZA);
1256 ok(hr == S_OK, "got 0x%lx for sizeof(ZONEATTRIBUTES) + sizeof(DWORD) (expected S_OK)\n", hr);
1257
1258 pZA->cbSize = sizeof(ZONEATTRIBUTES) - sizeof(DWORD);
1259 hr = IInternetZoneManager_SetZoneAttributes(zonemgr, URLZONE_CUSTOM, pZA);
1260 ok(hr == S_OK, "got 0x%lx for sizeof(ZONEATTRIBUTES) - sizeof(DWORD) (expected S_OK)\n", hr);
1261
1262 pZA->cbSize = 0;
1263 hr = IInternetZoneManager_SetZoneAttributes(zonemgr, URLZONE_CUSTOM, pZA);
1264 ok(hr == S_OK, "got 0x%lx for size 0 (expected S_OK)\n", hr);
1265
1266 /* The key for the zone must be present, when calling SetZoneAttributes */
1268 /* E_FAIL is returned from IE6 here, which is reasonable.
1269 All newer IE return S_OK without saving the zone attributes to the registry.
1270 This is a Windows bug, but we have to accept that as standard */
1271 hr = IInternetZoneManager_SetZoneAttributes(zonemgr, URLZONE_CUSTOM, pZA);
1272 ok((hr == S_OK) || broken(hr == E_FAIL), "got 0x%lx (expected S_OK)\n", hr);
1273
1274 /* SetZoneAttributes did not create the directory */
1275 res = RegOpenKeyA(HKEY_CURRENT_USER, regpath, &hkey);
1276 ok((res == ERROR_FILE_NOT_FOUND) && (hkey == NULL),
1277 "got %lu with %p (expected ERROR_FILE_NOT_FOUND with NULL)\n", res, hkey);
1278
1279 if (hkey) RegCloseKey(hkey);
1280
1281cleanup:
1282 /* delete zone settings in the registry */
1284
1285 hr = IInternetZoneManager_Release(zonemgr);
1286 ok(hr == S_OK, "got 0x%lx (expected S_OK)\n", hr);
1287}
1288
1289
1291{
1293 IUnknown *unk;
1294 IStream *stream;
1295 HRESULT hres;
1296
1297 trace("testing marshalling...\n");
1298
1299 hres = pCoInternetCreateSecurityManager(NULL, &secmgr, 0);
1300 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
1301 if(FAILED(hres))
1302 return;
1303
1304 hres = IInternetSecurityManager_QueryInterface(secmgr, &IID_IUnknown, (void**)&unk);
1305 ok(hres == S_OK, "QueryInterface returned: %08lx\n", hres);
1306
1308 ok(hres == S_OK, "CreateStreamOnHGlobal returned: %08lx\n", hres);
1309
1310 hres = CoMarshalInterface(stream, &IID_IInternetSecurityManager, unk, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1311 /* Not supported in W98 */
1313 "CoMarshalInterface returned: %08lx\n", hres);
1314
1315 IStream_Release(stream);
1316 IUnknown_Release(unk);
1317 IInternetSecurityManager_Release(secmgr);
1318}
1319
1321{
1322 const WCHAR url5_out[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
1323 '.','w','i','n','e','t','e','s','t',0};
1324 const WCHAR url7_out[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
1325
1326 const WCHAR *in[] = {url2, url3, url4, url5, url7, url8, url9, url10};
1327 const WCHAR *out_default[] = {url2, url3, url4, url5_out, url7_out, url8, url5_out, url10};
1328 const WCHAR *out_securl[] = {url2, url3, url4, url5, url7, url8, url9, url10};
1329
1330 WCHAR *sec;
1331 DWORD i;
1332 HRESULT hres;
1333
1334 trace("testing CoInternetGetSecurityUrl...\n");
1335
1336 for(i = 0; i < ARRAY_SIZE(in); i++) {
1337 hres = pCoInternetGetSecurityUrl(in[i], &sec, PSU_DEFAULT, 0);
1338 ok(hres == S_OK, "(%ld) CoInternetGetSecurityUrl returned: %08lx\n", i, hres);
1339 if(hres == S_OK) {
1340 ok(!strcmp_w(sec, out_default[i]), "(%ld) Got %s, expected %s\n",
1341 i, wine_dbgstr_w(sec), wine_dbgstr_w(out_default[i]));
1342 CoTaskMemFree(sec);
1343 }
1344
1345 hres = pCoInternetGetSecurityUrl(in[i], &sec, PSU_SECURITY_URL_ONLY, 0);
1346 ok(hres == S_OK, "(%ld) CoInternetGetSecurityUrl returned: %08lx\n", i, hres);
1347 if(hres == S_OK) {
1348 ok(!strcmp_w(sec, out_securl[i]), "(%ld) Got %s, expected %s\n",
1349 i, wine_dbgstr_w(sec), wine_dbgstr_w(out_securl[i]));
1350 CoTaskMemFree(sec);
1351 }
1352 }
1353
1354 SET_EXPECT(ParseUrl_SECURITY_URL_input2);
1355 SET_EXPECT(ParseUrl_SECURITY_URL_expected);
1356 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected);
1357
1358 hres = pCoInternetGetSecurityUrl(security_url2W, &sec, PSU_DEFAULT, 0);
1359 ok(hres == S_OK, "CoInternetGetSecurityUrl returned 0x%08lx, expected S_OK\n", hres);
1360
1361 CHECK_CALLED(ParseUrl_SECURITY_URL_input2);
1362 CHECK_CALLED(ParseUrl_SECURITY_URL_expected);
1363 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected);
1364
1365 ok(!lstrcmpW(security_expectedW, sec), "Expected %s but got %s\n",
1367 CoTaskMemFree(sec);
1368}
1369
1371 REFIID riid, void **ppv)
1372{
1373 ok(0, "unexpected call\n");
1374 return E_NOINTERFACE;
1375}
1376
1378{
1379 return 2;
1380}
1381
1383{
1384 return 1;
1385}
1386
1388 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
1389 DWORD *pcchResult, DWORD dwReserved)
1390{
1391 const WCHAR *ret = NULL;
1392
1393 ok(pwzResult != NULL, "pwzResult == NULL\n");
1394 ok(pcchResult != NULL, "pcchResult == NULL\n");
1395 ok(!dwParseFlags, "Expected 0, but got 0x%08lx\n", dwParseFlags);
1396
1397 switch(ParseAction) {
1398 case PARSE_SECURITY_URL:
1399 if(!strcmp_w(pwzUrl, security_urlW)) {
1400 CHECK_EXPECT(ParseUrl_SECURITY_URL_input);
1401 ok(cchResult == lstrlenW(pwzUrl)+1, "Got %ld\n", cchResult);
1403 } else if(!strcmp_w(pwzUrl, security_url2W)) {
1404 CHECK_EXPECT(ParseUrl_SECURITY_URL_input2);
1405 ok(cchResult == lstrlenW(pwzUrl)+1, "Got %ld\n", cchResult);
1407 } else if(!strcmp_w(pwzUrl, security_expectedW)) {
1408 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected);
1409 ok(cchResult == lstrlenW(pwzUrl)+1, "Got %ld\n", cchResult);
1411 } else if(!strcmp_w(pwzUrl, winetest_to_httpW)) {
1412 switch(++called_securl_http) {
1413 case 1:
1414 ok(cchResult == lstrlenW(pwzUrl)+1, "Got %ld\n", cchResult);
1415 break;
1416 case 2:
1417 CHECK_EXPECT(ParseUrl_SECURITY_URL_http);
1418 ok(cchResult == lstrlenW(url9)+1, "Got %ld\n", cchResult);
1419 break;
1420 default:
1421 todo_wine CHECK_EXPECT(ParseUrl_SECURITY_URL_http);
1422 }
1423 ret = url9;
1424 } else
1425 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl));
1426
1427 break;
1428 case PARSE_SECURITY_DOMAIN:
1429
1430 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected);
1431
1432 ok(!strcmp_w(pwzUrl, security_expectedW), "Expected %s but got %s\n",
1434 ok(cchResult == lstrlenW(pwzUrl)+1, "Got %ld\n", cchResult);
1436 break;
1437 default:
1438 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction,
1439 wine_dbgstr_w(pwzUrl));
1440 }
1441
1442 if(!ret)
1443 return E_FAIL;
1444
1445 *pcchResult = lstrlenW(ret)+1;
1446 if(*pcchResult > cchResult)
1447 return S_FALSE;
1448 memcpy(pwzResult, ret, (*pcchResult)*sizeof(WCHAR));
1449 return S_OK;
1450}
1451
1453 LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
1454 LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
1455{
1456 ok(0, "unexpected call\n");
1457 return E_NOTIMPL;
1458}
1459
1461 LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
1462{
1463 ok(0, "unexpected call\n");
1464 return E_NOTIMPL;
1465}
1466
1468 LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
1469 DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
1470{
1471 ok(0, "unexpected call\n");
1472 return E_NOTIMPL;
1473}
1474
1475static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
1483};
1484
1486
1488{
1489 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
1490 *ppv = &protocol_info;
1491 return S_OK;
1492 }
1493
1494 ok(0, "unexpected call\n");
1495 return E_NOINTERFACE;
1496}
1497
1499{
1500 return 2;
1501}
1502
1504{
1505 return 1;
1506}
1507
1509 REFIID riid, void **ppv)
1510{
1511 ok(0, "unexpected call\n");
1512 return E_NOTIMPL;
1513}
1514
1516{
1517 ok(0, "unexpected call\n");
1518 return S_OK;
1519}
1520
1521static const IClassFactoryVtbl ClassFactoryVtbl = {
1527};
1528
1530
1531static void register_protocols(void)
1532{
1534 HRESULT hres;
1535
1536 hres = pCoInternetGetSession(0, &session, 0);
1537 ok(hres == S_OK, "CoInternetGetSession failed: %08lx\n", hres);
1538 if(FAILED(hres))
1539 return;
1540
1541 hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
1542 winetestW, 0, NULL, 0);
1543 ok(hres == S_OK, "RegisterNameSpace failed: %08lx\n", hres);
1544
1545 IInternetSession_Release(session);
1546}
1547
1548static void unregister_protocols(void) {
1550 HRESULT hr;
1551
1552 hr = pCoInternetGetSession(0, &session, 0);
1553 ok(hr == S_OK, "CoInternetGetSession failed: 0x%08lx\n", hr);
1554 if(FAILED(hr))
1555 return;
1556
1557 hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
1558 ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08lx\n", hr);
1559
1560 IInternetSession_Release(session);
1561}
1562
1563static const struct {
1564 const WCHAR *uri;
1566 const char *security_uri;
1571} sec_url_ex_tests[] = {
1572 {L"index.htm", Uri_CREATE_ALLOW_RELATIVE, "*:index.html", S_OK, L"*:index.htm", S_OK},
1573 {L"file://c:\\Index.htm", Uri_CREATE_FILE_USE_DOS_PATH, "file:///c:/Index.htm", S_OK, L"file:///c:/Index.htm", S_OK},
1574 {L"file:some%20file%2ejpg", 0, NULL, E_INVALIDARG, NULL, E_INVALIDARG},
1575 {L"file:some file.jpg", 0, NULL, E_INVALIDARG, NULL, E_INVALIDARG},
1576 {L"http://www.zone3.winetest/", 0, "http://www.zone3.winetest/", S_OK, L"http://www.zone3.winetest/", S_OK},
1577 {L"about:blank", 0, "about:blank", S_OK, L"about:blank", S_OK},
1578 {L"ftp://zone3.winetest/file.test", 0, "ftp://zone3.winetest/file.test", S_OK, L"ftp://zone3.winetest/file.test", S_OK},
1579 {L"test:123abc", 0, "test:123abc", S_OK, L"test:123abc", S_OK},
1580 {L"http:google.com/test.file", 0, "http:google.com/test.file", S_OK, L"http:google.com/test.file", S_OK},
1581 {L"ftp://test@ftp.winehq.org/", 0, "ftp://ftp.winehq.org/", S_OK, L"ftp://ftp.winehq.org/", S_OK},
1582 {L"test://google@ftp.winehq.org/", 0, "test://google@ftp.winehq.org/", S_OK, L"test://google@ftp.winehq.org/", S_OK}
1584
1586{
1587 HRESULT hr;
1588 DWORD i;
1589 IUri *uri = NULL, *result = NULL;
1590
1591 trace("testing CoInternetGetSecurityUrlEx...\n");
1592
1593 hr = pCoInternetGetSecurityUrlEx(NULL, NULL, PSU_DEFAULT, 0);
1594 ok(hr == E_INVALIDARG, "CoInternetGetSecurityUrlEx returned 0x%08lx, expected E_INVALIDARG\n", hr);
1595
1596 result = (void*) 0xdeadbeef;
1597 hr = pCoInternetGetSecurityUrlEx(NULL, &result, PSU_DEFAULT, 0);
1598 ok(hr == E_INVALIDARG, "CoInternetGetSecurityUrlEx returned 0x%08lx, expected E_INVALIDARG\n", hr);
1599 ok(result == (void*) 0xdeadbeef, "'result' was %p\n", result);
1600
1601 for(i = 0; i < ARRAY_SIZE(sec_url_ex_tests); ++i) {
1602 uri = NULL;
1603
1604 hr = pCreateUri(sec_url_ex_tests[i].uri, sec_url_ex_tests[i].create_flags, 0, &uri);
1605 ok(hr == S_OK, "CreateUri returned 0x%08lx on test %ld\n", hr, i);
1606 if(hr == S_OK) {
1607 result = NULL;
1608
1609 hr = pCoInternetGetSecurityUrlEx(uri, &result, PSU_DEFAULT, 0);
1612 "CoInternetGetSecurityUrlEx returned 0x%08lx, expected 0x%08lx on test %ld\n",
1614 }
1615 if(SUCCEEDED(hr)) {
1616 BSTR received;
1617
1618 hr = IUri_GetDisplayUri(result, &received);
1619 ok(hr == S_OK, "GetDisplayUri returned 0x%08lx on test %ld\n", hr, i);
1620 if(hr == S_OK) {
1623 "Expected %s but got %s on test %ld\n",
1625 }
1626 }
1628 }
1629 if(result) IUri_Release(result);
1630
1631 result = NULL;
1632 hr = pCoInternetGetSecurityUrlEx(uri, &result, PSU_SECURITY_URL_ONLY, 0);
1635 "CoInternetGetSecurityUrlEx returned 0x%08lx, expected 0x%08lx on test %ld\n",
1637 }
1638 if(SUCCEEDED(hr)) {
1639 BSTR received;
1640
1641 hr = IUri_GetDisplayUri(result, &received);
1642 ok(hr == S_OK, "GetDisplayUri returned 0x%08lx on test %ld\n", hr, i);
1643 if(hr == S_OK) {
1646 "Expected %s but got %s on test %ld\n",
1648 }
1649 }
1651 }
1652 if(result) IUri_Release(result);
1653 }
1654
1655 if(uri) IUri_Release(uri);
1656 }
1657}
1658
1660{
1661 HRESULT hr;
1662 IUri *uri = NULL, *result;
1663
1664 trace("testing CoInternetGetSecurityUrlEx for pluggable protocols...\n");
1665
1666 hr = pCreateUri(security_urlW, 0, 0, &uri);
1667 ok(hr == S_OK, "CreateUri returned 0x%08lx\n", hr);
1668 if(hr == S_OK) {
1669 SET_EXPECT(ParseUrl_SECURITY_URL_input);
1670 SET_EXPECT(ParseUrl_SECURITY_URL_expected);
1671 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected);
1672
1673 hr = pCoInternetGetSecurityUrlEx(uri, &result, PSU_DEFAULT, 0);
1674 ok(hr == S_OK, "CoInternetGetSecurityUrlEx returned 0x%08lx, expected S_OK\n", hr);
1675
1676 CHECK_CALLED(ParseUrl_SECURITY_URL_input);
1677 CHECK_CALLED(ParseUrl_SECURITY_URL_expected);
1678 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected);
1679
1680 if(hr == S_OK) {
1681 BSTR received = NULL;
1682
1683 hr = IUri_GetAbsoluteUri(result, &received);
1684 ok(hr == S_OK, "GetAbsoluteUri returned 0x%08lx\n", hr);
1685 if(hr == S_OK) {
1686 ok(!strcmp_w(security_expectedW, received), "Expected %s but got %s\n",
1688 }
1690 }
1691 if(result) IUri_Release(result);
1692
1693 result = NULL;
1694
1695 SET_EXPECT(ParseUrl_SECURITY_URL_input);
1696 SET_EXPECT(ParseUrl_SECURITY_URL_expected);
1697
1698 hr = pCoInternetGetSecurityUrlEx(uri, &result, PSU_SECURITY_URL_ONLY, 0);
1699 ok(hr == S_OK, "CoInternetGetSecurityUrlEx returned 0x%08lx, expected S_OK\n", hr);
1700
1701 CHECK_CALLED(ParseUrl_SECURITY_URL_input);
1702 CHECK_CALLED(ParseUrl_SECURITY_URL_expected);
1703
1704 if(hr == S_OK) {
1705 BSTR received = NULL;
1706
1707 hr = IUri_GetAbsoluteUri(result, &received);
1708 ok(hr == S_OK, "GetAbsoluteUri returned 0x%08lx\n", hr);
1709 if(hr == S_OK) {
1710 ok(!strcmp_w(security_expectedW, received), "Expected %s but got %s\n",
1712 }
1714 }
1715 if(result) IUri_Release(result);
1716 }
1717 if(uri) IUri_Release(uri);
1718}
1719
1720static const BYTE secidex2_1[] = {'z','i','p',':','/','/','t','e','s','t','i','n','g','.','c','o','m','/',3,0,0,0};
1721static const BYTE secidex2_2[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1722static const BYTE secidex2_3[] = {'*',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1723
1724static const struct {
1725 const WCHAR *uri;
1730 const BYTE *secid;
1734} sec_mgr_ex2_tests[] = {
1735 {L"res://mshtml.dll/blank.htm", 0, S_OK, URLZONE_LOCAL_MACHINE, FALSE, secid1, sizeof(secid1), S_OK},
1736 {L"index.htm", Uri_CREATE_ALLOW_RELATIVE, 0, URLZONE_INTERNET, FALSE, secid2, sizeof(secid2), S_OK},
1737 {L"file://c:\\Index.html", 0, 0, URLZONE_LOCAL_MACHINE, FALSE, secid1, sizeof(secid1), S_OK},
1738 {L"http://www.zone3.winetest/", 0, 0, URLZONE_INTERNET, FALSE, secid5, sizeof(secid5), S_OK},
1739 {L"about:blank", 0, 0, URLZONE_INTERNET, FALSE, secid6, sizeof(secid6), S_OK},
1740 {L"ftp://zone3.winetest/file.test", 0, 0, URLZONE_INTERNET, FALSE, secid7, sizeof(secid7), S_OK},
1741 {L"/file/testing/test.test", Uri_CREATE_ALLOW_RELATIVE, 0, URLZONE_INTERNET, FALSE, NULL, 0, E_INVALIDARG},
1742 {L"zip://testing.com/", 0, 0, URLZONE_INTERNET, FALSE, secidex2_1, sizeof(secidex2_1), S_OK},
1743 {L"zip:testing.com", 0, 0, URLZONE_INTERNET, FALSE, secidex2_2, sizeof(secidex2_2), S_OK},
1744 {L"http:google.com", 0, S_OK, URLZONE_INVALID, FALSE, NULL, 0, E_INVALIDARG},
1745 {L"http:/google.com", 0, S_OK, URLZONE_INVALID, FALSE, NULL, 0, E_INVALIDARG},
1746 {L"*:/testing", 0, S_OK, URLZONE_INTERNET, FALSE, NULL, 0, E_INVALIDARG},
1747 {L"*://testing.com", 0, S_OK, URLZONE_INTERNET, FALSE, secidex2_3, sizeof(secidex2_3), S_OK}
1749
1751{
1752 HRESULT hres;
1753 DWORD i, zone;
1754 BYTE buf[512];
1755 DWORD buf_size = sizeof(buf);
1756 IInternetSecurityManager *sec_mgr;
1758 IUri *uri = NULL;
1759
1760 static const WCHAR domainW[] = {'c','o','m','.','u','k',0};
1761
1762 if(!pCreateUri) {
1763 win_skip("Skipping SecurityManagerEx2, IE is too old\n");
1764 return;
1765 }
1766
1767 trace("Testing SecurityManagerEx2...\n");
1768
1769 hres = pCoInternetCreateSecurityManager(NULL, &sec_mgr, 0);
1770 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
1771
1772 hres = IInternetSecurityManager_QueryInterface(sec_mgr, &IID_IInternetSecurityManagerEx2, (void**)&sec_mgr2);
1773 ok(hres == S_OK, "QueryInterface(IID_IInternetSecurityManagerEx2) failed: %08lx\n", hres);
1774
1775 zone = 0xdeadbeef;
1776
1777 hres = IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2, NULL, &zone, 0, NULL, NULL);
1778 ok(hres == E_INVALIDARG, "MapUrlToZoneEx2 returned %08lx, expected E_INVALIDARG\n", hres);
1779 ok(zone == URLZONE_INVALID, "zone was %ld\n", zone);
1780
1781 hres = IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2, NULL, buf, &buf_size, 0);
1782 ok(hres == E_INVALIDARG, "GetSecurityIdEx2 returned %08lx, expected E_INVALIDARG\n", hres);
1783 ok(buf_size == sizeof(buf), "buf_size was %ld\n", buf_size);
1784
1785 hres = pCreateUri(url5, 0, 0, &uri);
1786 ok(hres == S_OK, "CreateUri failed: %08lx\n", hres);
1787
1788 hres = IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2, uri, NULL, 0, NULL, NULL);
1789 ok(hres == E_INVALIDARG, "MapToUrlZoneEx2 returned %08lx, expected E_INVALIDARG\n", hres);
1790
1791 buf_size = sizeof(buf);
1792 hres = IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2, uri, NULL, &buf_size, 0);
1793 ok(hres == E_INVALIDARG || broken(hres == S_OK), "GetSecurityIdEx2 failed: %08lx\n", hres);
1794 ok(buf_size == sizeof(buf), "bug_size was %ld\n", buf_size);
1795
1796 hres = IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2, uri, buf, NULL, 0);
1797 ok(hres == E_INVALIDARG, "GetSecurityIdEx2 returned %08lx, expected E_INVALIDARG\n", hres);
1798
1799 IUri_Release(uri);
1800
1801 for(i = 0; i < ARRAY_SIZE(sec_mgr_ex2_tests); ++i) {
1802 uri = NULL;
1803 zone = URLZONE_INVALID;
1804
1806 ok(hres == S_OK, "CreateUri returned %08lx for '%s'\n", hres, wine_dbgstr_w(sec_mgr_ex2_tests[i].uri));
1807
1808 hres = IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2, uri, &zone, 0, NULL, NULL);
1810 ok(hres == sec_mgr_ex2_tests[i].map_hres, "MapUrlToZoneEx2 returned %08lx, expected %08lx for '%s'\n",
1812 ok(zone == sec_mgr_ex2_tests[i].zone, "Expected zone %ld, but got %ld for '%s'\n", sec_mgr_ex2_tests[i].zone,
1814 }
1815
1816 buf_size = sizeof(buf);
1817 memset(buf, 0xf0, buf_size);
1818
1819 hres = IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2, uri, buf, &buf_size, 0);
1821 ok(hres == sec_mgr_ex2_tests[i].secid_hres, "GetSecurityIdEx2 returned %08lx, expected %08lx on test '%s'\n",
1824 ok(buf_size == sec_mgr_ex2_tests[i].secid_size, "Got wrong security id size=%ld, expected %ld on test '%s'\n",
1826 ok(!memcmp(buf, sec_mgr_ex2_tests[i].secid, sec_mgr_ex2_tests[i].secid_size), "Got wrong security id on test '%s'\n",
1828 }
1829 }
1830
1831 IUri_Release(uri);
1832 }
1833
1834 hres = pCreateUri(url15, 0, 0, &uri);
1835 ok(hres == S_OK, "CreateUri failed: %08lx\n", hres);
1836
1837 buf_size = sizeof(buf);
1838 memset(buf, 0xf0, buf_size);
1839
1840 hres = IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2, uri, buf, &buf_size, (DWORD_PTR)domainW);
1841 ok(hres == S_OK, "GetSecurityIdEx2 failed: %08lx\n", hres);
1842 todo_wine ok(buf_size == sizeof(secid13), "buf_size was %ld\n", buf_size);
1843 todo_wine ok(!memcmp(buf, secid13, sizeof(secid13)), "Got wrong secid\n");
1844
1845 buf_size = sizeof(buf);
1846 memset(buf, 0xf0, buf_size);
1847
1848 hres = IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2, uri, buf, &buf_size, 0);
1849 ok(hres == S_OK, "GetSecurityIdEx2 failed: %08lx\n", hres);
1850 ok(buf_size == sizeof(secid13_2), "buf_size was %ld\n", buf_size);
1851 ok(!memcmp(buf, secid13_2, sizeof(secid13_2)), "Got wrong secid\n");
1852
1853 IUri_Release(uri);
1854
1855 IInternetSecurityManagerEx2_Release(sec_mgr2);
1856 IInternetSecurityManager_Release(sec_mgr);
1857}
1858
1860{
1861 struct {
1862 const WCHAR *url_from;
1863 const WCHAR *url_to;
1864 DWORD flags;
1865 HRESULT hres;
1866 DWORD policy_flags;
1867 } testcases[] = {
1868 /* 0 */ { L"http://www.winehq.org", L"http://www.winehq.org", 0, S_FALSE, URLPOLICY_ALLOW },
1869 /* 1 */ { L"http://www.winehq.org", L"http://www.winehq.org", 0, S_OK, URLPOLICY_DISALLOW },
1870 /* 2 */ { L"http://www.winehq.org", L"http://www.codeweavers.com", 0, S_FALSE, URLPOLICY_ALLOW },
1871 /* 3 */ { L"http://www.winehq.org", L"http://www.codeweavers.com", 0, S_OK, URLPOLICY_DISALLOW },
1872 /* 4 */ { L"http://www.winehq.org", L"http://www.winehq.org", GET_FEATURE_FROM_PROCESS, S_FALSE, -1 },
1873 /* 5 */ { L"http://www.winehq.org", L"http://www.winehq.org/dir", GET_FEATURE_FROM_PROCESS, S_FALSE, -1 },
1874 /* 6 */ { L"http://www.winehq.org", L"http://www.codeweavers.com", GET_FEATURE_FROM_PROCESS, S_FALSE, -1 },
1875 /* 7 */ { L"http://www.winehq.org", L"ftp://winehq.org", GET_FEATURE_FROM_PROCESS, S_FALSE, -1 },
1876 /* 8 */ { L"http://www.winehq.org", L"ftp://winehq.org", GET_FEATURE_FROM_PROCESS|0x100, S_FALSE, URLPOLICY_ALLOW },
1877 /* 9 */ { L"http://www.winehq.org", L"ftp://winehq.org", GET_FEATURE_FROM_REGISTRY, S_FALSE, URLPOLICY_ALLOW },
1878 };
1879
1880 int i;
1881 HRESULT hres;
1882
1883 if(!pCoInternetIsFeatureZoneElevationEnabled || !pCoInternetIsFeatureEnabled
1884 || !pCoInternetIsFeatureEnabledForUrl) {
1885 win_skip("Skipping CoInternetIsFeatureZoneElevationEnabled tests\n");
1886 return;
1887 }
1888
1889
1890 hres = pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION, GET_FEATURE_FROM_PROCESS);
1891 ok(SUCCEEDED(hres), "CoInternetIsFeatureEnabled returned %lx\n", hres);
1892
1893 trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%lx)\n", hres);
1894
1895 for(i = 0; i < ARRAY_SIZE(testcases); i++) {
1896 if(hres==S_OK && testcases[i].flags == GET_FEATURE_FROM_PROCESS)
1897 testcases[i].policy_flags = URLPOLICY_ALLOW;
1898 }
1899
1900 /* IE10 does not seem to use passed ISecurityManager */
1901 SET_EXPECT(ProcessUrlAction);
1902 pCoInternetIsFeatureZoneElevationEnabled(url1, url1, &security_manager, 0);
1903 i = called_ProcessUrlAction;
1904 SET_CALLED(ProcessUrlAction);
1905 if(!i) {
1906 skip("CoInternetIsFeatureZoneElevationEnabled does not use passed ISecurityManager\n");
1907 return;
1908 }
1909
1910 for(i = 0; i < ARRAY_SIZE(testcases); i++) {
1911 if(testcases[i].policy_flags != -1) {
1912 ProcessUrlAction_policy = testcases[i].policy_flags;
1913 SET_EXPECT(ProcessUrlAction);
1914 }
1915 hres = pCoInternetIsFeatureZoneElevationEnabled(testcases[i].url_from, testcases[i].url_to,
1916 &security_manager, testcases[i].flags);
1917 ok(hres == testcases[i].hres, "%d) CoInternetIsFeatureZoneElevationEnabled returned %lx\n", i, hres);
1918 if(testcases[i].policy_flags != -1)
1919 CHECK_CALLED(ProcessUrlAction);
1920
1921 if(testcases[i].policy_flags != -1)
1922 SET_EXPECT(ProcessUrlAction);
1923 hres = pCoInternetIsFeatureEnabledForUrl(FEATURE_ZONE_ELEVATION,
1924 testcases[i].flags, testcases[i].url_to, &security_manager);
1925 ok(hres == testcases[i].hres, "%d) CoInternetIsFeatureEnabledForUrl returned %lx\n", i, hres);
1926 if(testcases[i].policy_flags != -1)
1927 CHECK_CALLED(ProcessUrlAction);
1928 }
1929}
1930
1932{
1933 HMODULE hurlmon;
1934 int argc;
1935 char **argv;
1936
1937 hurlmon = GetModuleHandleA("urlmon.dll");
1938 pCoInternetCreateSecurityManager = (void*) GetProcAddress(hurlmon, "CoInternetCreateSecurityManager");
1939 pCoInternetCreateZoneManager = (void*) GetProcAddress(hurlmon, "CoInternetCreateZoneManager");
1940 pCoInternetGetSecurityUrl = (void*) GetProcAddress(hurlmon, "CoInternetGetSecurityUrl");
1941 pCoInternetGetSecurityUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetGetSecurityUrlEx");
1942 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
1943 pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
1944 pCoInternetIsFeatureEnabled = (void*) GetProcAddress(hurlmon, "CoInternetIsFeatureEnabled");
1945 pCoInternetIsFeatureEnabledForUrl = (void*) GetProcAddress(hurlmon, "CoInternetIsFeatureEnabledForUrl");
1946 pCoInternetIsFeatureZoneElevationEnabled = (void*) GetProcAddress(hurlmon, "CoInternetIsFeatureZoneElevationEnabled");
1947
1948 if (!pCoInternetCreateSecurityManager || !pCoInternetCreateZoneManager ||
1949 !pCoInternetGetSecurityUrl) {
1950 win_skip("Various CoInternet* functions not present in IE 4.0\n");
1951 return;
1952 }
1953
1955 if(argc > 2 && !strcmp(argv[2], "domain_tests")) {
1957 return;
1958 }
1959
1962
1964
1965 if(!pCoInternetGetSecurityUrlEx || !pCreateUri)
1966 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
1967 else {
1970 }
1971
1974 test_polices();
1984
1987}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:78
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1179
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3583
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2668
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2287
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
LONG WINAPI RegEnumKeyExA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2419
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1224
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
HRESULT WINAPI CoMarshalInterface(IStream *stream, REFIID riid, IUnknown *unk, DWORD dest_context, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:483
#define CloseHandle
Definition: compat.h:739
#define GetProcAddress(x, y)
Definition: compat.h:753
OLECHAR * BSTR
Definition: compat.h:2293
#define MAX_PATH
Definition: compat.h:34
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define lstrlenW
Definition: compat.h:750
static void cleanup(void)
Definition: main.c:1335
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
Definition: process.c:686
MonoAssembly int argc
Definition: metahost.c:107
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:162
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:218
return ret
Definition: mutex.c:146
action
Definition: namespace.c:707
#define L(x)
Definition: resources.c:13
r received
Definition: btrfs.c:3005
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define cs
Definition: i386-dis.c:442
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
#define win_skip
Definition: minitest.h:67
int winetest_interactive
#define todo_wine_if(is_todo)
Definition: minitest.h:81
#define todo_wine
Definition: minitest.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define sprintf
Definition: sprintf.c:45
static const WCHAR url[]
Definition: encode.c:1384
HRESULT hres
Definition: protocol.c:465
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static SYSTEM_INFO si
Definition: virtual.c:39
static IInternetProtocolInfo protocol_info
Definition: misc.c:929
static LPWSTR PSUACTION
Definition: misc.c:69
static PARSEACTION
Definition: misc.c:71
static QUERYOPTION
Definition: misc.c:72
#define SET_EXPECT(func)
Definition: sec_mgr.c:42
static const BYTE secid5[]
Definition: sec_mgr.c:122
static void test_zone_domain_cache(void)
Definition: sec_mgr.c:662
static const GUID CLSID_TestActiveX
Definition: sec_mgr.c:136
static const WCHAR url6[]
Definition: sec_mgr.c:94
HRESULT secid_hres
Definition: sec_mgr.c:1732
static void test_GetZoneAt(void)
Definition: sec_mgr.c:1106
#define URLZONE_CUSTOM
Definition: sec_mgr.c:36
#define URLZONE_CUSTOM2
Definition: sec_mgr.c:37
static void test_GetZoneAttributes(void)
Definition: sec_mgr.c:1157
static const BYTE secid7[]
Definition: sec_mgr.c:125
static HRESULT WINAPI SecurityManager_GetSecurityId(IInternetSecurityManager *This, LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
Definition: sec_mgr.c:281
HRESULT security_hres
Definition: sec_mgr.c:1567
static BOOL register_zone_domains(void)
Definition: sec_mgr.c:733
static const WCHAR url15[]
Definition: sec_mgr.c:106
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: sec_mgr.c:1515
static const WCHAR security_url2W[]
Definition: sec_mgr.c:113
static void test_CoInternetIsFeatureZoneElevationEnabled(void)
Definition: sec_mgr.c:1859
BOOL secid_todo
Definition: sec_mgr.c:1733
const WCHAR * uri
Definition: sec_mgr.c:1564
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
Definition: sec_mgr.c:1508
static const WCHAR winetest_to_httpW[]
Definition: sec_mgr.c:115
static const struct @1883 sec_url_ex_tests[]
static const zone_mapping_test zone_mapping_tests[]
Definition: sec_mgr.c:859
static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
Definition: sec_mgr.c:1467
HRESULT map_hres
Definition: sec_mgr.c:1727
static void test_SecurityManagerEx2(void)
Definition: sec_mgr.c:1750
static const IClassFactoryVtbl ClassFactoryVtbl
Definition: sec_mgr.c:1521
static HRESULT WINAPI SecurityManager_GetSecuritySite(IInternetSecurityManager *This, IInternetSecurityMgrSite **ppSite)
Definition: sec_mgr.c:267
const WCHAR * default_uri
Definition: sec_mgr.c:1568
static DWORD ProcessUrlAction_policy
Definition: sec_mgr.c:144
static const zone_domain_mapping zone_domain_mappings[]
Definition: sec_mgr.c:714
static void unregister_protocols(void)
Definition: sec_mgr.c:1548
static HRESULT WINAPI SecurityManager_SetZoneMapping(IInternetSecurityManager *This, DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags)
Definition: sec_mgr.c:311
static void test_CoInternetCreateZoneManager(void)
Definition: sec_mgr.c:948
static const WCHAR url1[]
Definition: sec_mgr.c:86
static LPCWSTR
Definition: sec_mgr.c:83
static void test_InternetSecurityMarshalling(void)
Definition: sec_mgr.c:1290
static const WCHAR url5[]
Definition: sec_mgr.c:92
BOOL map_todo
Definition: sec_mgr.c:1729
#define CHECK_EXPECT(func)
Definition: sec_mgr.c:45
static int strcmp_w(const WCHAR *str1, const WCHAR *str2)
Definition: sec_mgr.c:167
static ULONG WINAPI SecurityManager_Release(IInternetSecurityManager *This)
Definition: sec_mgr.c:255
static const WCHAR security_expectedW[]
Definition: sec_mgr.c:114
static int called_securl_http
Definition: sec_mgr.c:143
static void test_SecurityManager(void)
Definition: sec_mgr.c:341
static const WCHAR url4[]
Definition: sec_mgr.c:90
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: sec_mgr.c:1503
#define DEFINE_EXPECT(func)
Definition: sec_mgr.c:39
static HRESULT WINAPI SecurityManager_MapUrlToZone(IInternetSecurityManager *This, LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags)
Definition: sec_mgr.c:274
static HRESULT WINAPI SecurityManager_ProcessUrlAction(IInternetSecurityManager *This, LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved)
Definition: sec_mgr.c:288
DWORD zone
Definition: sec_mgr.c:1728
static const BYTE secidex2_1[]
Definition: sec_mgr.c:1720
static IUri DWORD_PTR
Definition: sec_mgr.c:79
static const struct @1884 sec_mgr_ex2_tests[]
static void test_zone_domains(void)
Definition: sec_mgr.c:929
static const BYTE secidex2_2[]
Definition: sec_mgr.c:1721
static void test_SetZoneAttributes(void)
Definition: sec_mgr.c:1213
static const WCHAR url8[]
Definition: sec_mgr.c:97
static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
Definition: sec_mgr.c:1460
static const BYTE secid2[]
Definition: sec_mgr.c:121
static void test_polices(void)
Definition: sec_mgr.c:630
DWORD create_flags
Definition: sec_mgr.c:1565
static const WCHAR url14[]
Definition: sec_mgr.c:105
static void test_GetZoneActionPolicy(void)
Definition: sec_mgr.c:1063
static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: sec_mgr.c:1452
static HRESULT WINAPI SecurityManager_SetSecuritySite(IInternetSecurityManager *This, IInternetSecurityMgrSite *pSite)
Definition: sec_mgr.c:260
static const BYTE secidex2_3[]
Definition: sec_mgr.c:1722
static HRESULT WINAPI SecurityManager_QueryCustomPolicy(IInternetSecurityManager *This, LPCWSTR pwszUrl, REFGUID guidKey, BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwReserved)
Definition: sec_mgr.c:303
static void test_CreateZoneEnumerator(void)
Definition: sec_mgr.c:993
static void register_protocols(void)
Definition: sec_mgr.c:1531
static void run_child_process(void)
Definition: sec_mgr.c:831
const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
Definition: sec_mgr.c:140
static const WCHAR url11[]
Definition: sec_mgr.c:102
static void test_InternetGetSecurityUrlEx_Pluggable(void)
Definition: sec_mgr.c:1659
static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
Definition: sec_mgr.c:1377
static void test_special_url_action(IInternetSecurityManager *secmgr, IInternetZoneManager *zonemgr, DWORD action)
Definition: sec_mgr.c:586
static const BYTE secid13[]
Definition: sec_mgr.c:133
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: sec_mgr.c:1487
static const WCHAR security_urlW[]
Definition: sec_mgr.c:112
static void test_activex(IInternetSecurityManager *secmgr)
Definition: sec_mgr.c:609
static void unregister_zone_domains(void)
Definition: sec_mgr.c:794
static const char * szZoneMapDomainsKey
Definition: sec_mgr.c:117
static LONG myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
Definition: sec_mgr.c:178
static const WCHAR url2[]
Definition: sec_mgr.c:88
static void test_InternetGetSecurityUrlEx(void)
Definition: sec_mgr.c:1585
static const BYTE secid10_2[]
Definition: sec_mgr.c:131
static const WCHAR url16[]
Definition: sec_mgr.c:107
static const WCHAR winetestW[]
Definition: sec_mgr.c:111
BOOL todo
Definition: sec_mgr.c:1570
static HRESULT WINAPI SecurityManager_QueryInterface(IInternetSecurityManager *This, REFIID riid, void **ppvObject)
Definition: sec_mgr.c:243
#define CHECK_CALLED(func)
Definition: sec_mgr.c:58
static struct secmgr_test secmgr_tests[]
const char * security_uri
Definition: sec_mgr.c:1566
static void test_InternetGetSecurityUrl(void)
Definition: sec_mgr.c:1320
static const BYTE secid14[]
Definition: sec_mgr.c:129
static const char * szInternetSettingsKey
Definition: sec_mgr.c:118
static const BYTE secid1[]
Definition: sec_mgr.c:120
static const WCHAR url13[]
Definition: sec_mgr.c:104
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: sec_mgr.c:1498
static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
Definition: sec_mgr.c:1382
static const WCHAR url9[]
Definition: sec_mgr.c:98
const BYTE * secid
Definition: sec_mgr.c:1730
HRESULT default_hres
Definition: sec_mgr.c:1569
static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
Definition: sec_mgr.c:1370
static void test_zone_domain_mappings(void)
Definition: sec_mgr.c:890
static const BYTE secid6[]
Definition: sec_mgr.c:124
static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: sec_mgr.c:1387
static const BYTE secid13_2[]
Definition: sec_mgr.c:134
DWORD secid_size
Definition: sec_mgr.c:1731
static IClassFactory protocol_cf
Definition: sec_mgr.c:1529
static const WCHAR url17[]
Definition: sec_mgr.c:108
static const IInternetSecurityManagerVtbl SecurityManagerVtbl
Definition: sec_mgr.c:325
static HRESULT WINAPI SecurityManager_GetZoneMappings(IInternetSecurityManager *This, DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
Definition: sec_mgr.c:318
static ULONG WINAPI SecurityManager_AddRef(IInternetSecurityManager *This)
Definition: sec_mgr.c:250
#define SET_CALLED(func)
Definition: sec_mgr.c:64
static BOOL is_ie_hardened(void)
Definition: sec_mgr.c:454
static const BYTE secid10[]
Definition: sec_mgr.c:127
static const WCHAR url3[]
Definition: sec_mgr.c:89
static void test_url_action(IInternetSecurityManager *secmgr, IInternetZoneManager *zonemgr, DWORD action)
Definition: sec_mgr.c:473
static IInternetSecurityManager security_manager
Definition: sec_mgr.c:339
static const WCHAR url10[]
Definition: sec_mgr.c:100
static const WCHAR url12[]
Definition: sec_mgr.c:103
static const WCHAR url18[]
Definition: sec_mgr.c:109
static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
Definition: sec_mgr.c:1475
static const WCHAR url7[]
Definition: sec_mgr.c:95
#define argv
Definition: mplay32.c:18
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define DWORD
Definition: nt_native.h:44
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
PVOID pBuffer
#define test
Definition: rosglue.h:37
#define REG_DWORD
Definition: sdbapi.c:615
int winetest_get_mainargs(char ***pargv)
#define wait_child_process
Definition: test.h:159
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
#define memset(x, y, z)
Definition: compat.h:39
TCHAR * cmdline
Definition: stretchblt.cpp:32
Definition: scsiwmi.h:51
Definition: cookie.c:42
const BYTE * secid
Definition: sec_mgr.c:151
HRESULT secid_hres
Definition: sec_mgr.c:152
DWORD secid_size
Definition: sec_mgr.c:150
HRESULT zone_hres
Definition: sec_mgr.c:149
DWORD zone
Definition: sec_mgr.c:148
LPCWSTR url
Definition: sec_mgr.c:147
Definition: parse.h:23
const char * domain
Definition: sec_mgr.c:707
const char * subdomain
Definition: sec_mgr.c:708
const char * scheme
Definition: sec_mgr.c:709
DWORD broken_zone
Definition: sec_mgr.c:856
const WCHAR * url
Definition: sec_mgr.c:853
#define max(a, b)
Definition: svc.c:63
const char * LPCSTR
Definition: typedefs.h:52
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
enum INTERNETFEATURELIST
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOINTERFACE
Definition: winerror.h:3479
#define REGDB_E_IIDNOTREG
Definition: winerror.h:3802
#define E_POINTER
Definition: winerror.h:3480
#define ERROR_NOT_FOUND
Definition: winerror.h:1014
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int WINAPIV wsprintfA(_Out_ LPSTR, _In_ _Printf_format_string_ LPCSTR,...)
unsigned char BYTE
Definition: xxhash.c:193