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