Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
fb042eb1
Commit
fb042eb1
authored
Dec 26, 2005
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 26, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urlmon: Added GetSecurityId implementation.
parent
0cceb338
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
18 deletions
+152
-18
sec_mgr.c
dlls/urlmon/sec_mgr.c
+67
-8
misc.c
dlls/urlmon/tests/misc.c
+85
-10
No files found.
dlls/urlmon/sec_mgr.c
View file @
fb042eb1
...
...
@@ -109,7 +109,7 @@ static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone)
size
=
sizeof
(
DWORD
);
res
=
RegQueryValueExW
(
hkey
,
schema
,
NULL
,
NULL
,
(
PBYTE
)
zone
,
&
size
);
if
(
res
==
ERROR_SUCCESS
)
return
S_OK
;
return
S_OK
;
*
zone
=
3
;
return
S_OK
;
...
...
@@ -268,15 +268,17 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
}
static
HRESULT
WINAPI
SecManagerImpl_GetSecurityId
(
IInternetSecurityManager
*
iface
,
LPCWSTR
pwszUrl
,
BYTE
*
pbSecurityId
,
DWORD
*
pcbSecurityId
,
DWORD_PTR
dwReserved
)
LPCWSTR
pwszUrl
,
BYTE
*
pbSecurityId
,
DWORD
*
pcbSecurityId
,
DWORD_PTR
dwReserved
)
{
SecManagerImpl
*
This
=
SECMGR_THIS
(
iface
);
LPWSTR
buf
,
ptr
,
ptr2
;
DWORD
size
,
zone
,
len
;
HRESULT
hres
;
TRACE
(
"(%p)->(%s %p %p %08lx)
\n
"
,
iface
,
debugstr_w
(
pwszUrl
),
pbSecurityId
,
pcbSecurityId
,
dwReserved
);
static
const
WCHAR
wszFile
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
};
TRACE
(
"(%p)->(%s %p %p %08lx)
\n
"
,
iface
,
debugstr_w
(
pwszUrl
),
pbSecurityId
,
pcbSecurityId
,
dwReserved
);
if
(
This
->
custom_manager
)
{
hres
=
IInternetSecurityManager_GetSecurityId
(
This
->
custom_manager
,
...
...
@@ -285,8 +287,65 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa
return
hres
;
}
FIXME
(
"Default action is not implemented
\n
"
);
return
E_NOTIMPL
;
if
(
!
pwszUrl
||
!
pbSecurityId
||
!
pcbSecurityId
)
return
E_INVALIDARG
;
if
(
dwReserved
)
FIXME
(
"dwReserved is not supported
\n
"
);
len
=
strlenW
(
pwszUrl
)
+
1
;
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
16
)
*
sizeof
(
WCHAR
));
hres
=
CoInternetParseUrl
(
pwszUrl
,
PARSE_SECURITY_URL
,
0
,
buf
,
len
,
&
size
,
0
);
if
(
FAILED
(
hres
))
memcpy
(
buf
,
pwszUrl
,
len
*
sizeof
(
WCHAR
));
hres
=
map_url_to_zone
(
buf
,
&
zone
);
if
(
FAILED
(
hres
))
{
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
return
hres
==
0x80041001
?
E_INVALIDARG
:
hres
;
}
/* file protocol is a special case */
if
(
strlenW
(
pwszUrl
)
>=
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
)
&&
!
memcmp
(
buf
,
wszFile
,
sizeof
(
wszFile
)))
{
static
const
BYTE
secidFile
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
};
if
(
*
pcbSecurityId
<
sizeof
(
secidFile
)
+
sizeof
(
zone
))
return
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
);
memcpy
(
pbSecurityId
,
secidFile
,
sizeof
(
secidFile
));
*
(
DWORD
*
)(
pbSecurityId
+
sizeof
(
secidFile
))
=
zone
;
*
pcbSecurityId
=
sizeof
(
secidFile
)
+
sizeof
(
zone
);
return
S_OK
;
}
ptr
=
strchrW
(
buf
,
':'
);
ptr2
=
++
ptr
;
while
(
*
ptr2
==
'/'
)
ptr2
++
;
if
(
ptr2
!=
ptr
)
memmove
(
ptr
,
ptr2
,
(
strlenW
(
ptr2
)
+
1
)
*
sizeof
(
WCHAR
));
ptr
=
strchrW
(
ptr
,
'/'
);
if
(
ptr
)
*
ptr
=
0
;
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
buf
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
-
1
;
if
(
len
+
sizeof
(
DWORD
)
>
*
pcbSecurityId
)
return
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
);
WideCharToMultiByte
(
CP_ACP
,
0
,
buf
,
-
1
,
(
LPSTR
)
pbSecurityId
,
-
1
,
NULL
,
NULL
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
*
(
DWORD
*
)(
pbSecurityId
+
len
)
=
zone
;
*
pcbSecurityId
=
len
+
sizeof
(
DWORD
);
return
S_OK
;
}
...
...
dlls/urlmon/tests/misc.c
View file @
fb042eb1
...
...
@@ -26,6 +26,10 @@
#include "ole2.h"
#include "urlmon.h"
#include "initguid.h"
DEFINE_GUID
(
CLSID_AboutProtocol
,
0x3050F406
,
0x98B5
,
0x11CF
,
0xBB
,
0x82
,
0x00
,
0xAA
,
0x00
,
0xBD
,
0xCE
,
0x0B
);
static
void
test_CreateFormatEnum
(
void
)
{
IEnumFORMATETC
*
fenum
=
NULL
,
*
fenum2
=
NULL
;
...
...
@@ -409,25 +413,37 @@ static void test_FindMimeFromData(void)
ok
(
hres
==
E_INVALIDARG
,
"FindMimeFromData failed: %08lx, expected E_INVALIDARG
\n
"
,
hres
);
}
static
const
BYTE
secid1
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
,
0
,
0
,
0
,
0
};
static
const
BYTE
secid4
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
,
3
,
0
,
0
,
0
};
static
const
BYTE
secid5
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'w'
,
'w'
,
'w'
,
'.'
,
'w'
,
'i'
,
'n'
,
'e'
,
'h'
,
'q'
,
'.'
,
'o'
,
'r'
,
'g'
,
3
,
0
,
0
,
0
};
static
const
BYTE
secid6
[]
=
{
'a'
,
'b'
,
'o'
,
'u'
,
't'
,
':'
,
'b'
,
'l'
,
'a'
,
'n'
,
'k'
,
3
,
0
,
0
,
0
};
static
const
BYTE
secid7
[]
=
{
'f'
,
't'
,
'p'
,
':'
,
'w'
,
'i'
,
'n'
,
'e'
,
'h'
,
'q'
,
'.'
,
'o'
,
'r'
,
'g'
,
3
,
0
,
0
,
0
};
static
struct
secmgr_test
{
LPCWSTR
url
;
DWORD
zone
;
HRESULT
zone_hres
;
DWORD
secid_size
;
const
BYTE
*
secid
;
HRESULT
secid_hres
;
}
secmgr_tests
[]
=
{
{
url1
,
0
,
S_OK
},
{
url2
,
100
,
0x80041001
},
{
url3
,
0
,
S_OK
},
{
url4
,
3
,
S_OK
},
{
url5
,
3
,
S_OK
},
{
url6
,
3
,
S_OK
},
{
url7
,
3
,
S_OK
}
{
url1
,
0
,
S_OK
,
sizeof
(
secid1
),
secid1
,
S_OK
},
{
url2
,
100
,
0x80041001
,
0
,
NULL
,
E_INVALIDARG
},
{
url3
,
0
,
S_OK
,
sizeof
(
secid1
),
secid1
,
S_OK
},
{
url4
,
3
,
S_OK
,
sizeof
(
secid4
),
secid4
,
S_OK
},
{
url5
,
3
,
S_OK
,
sizeof
(
secid5
),
secid5
,
S_OK
},
{
url6
,
3
,
S_OK
,
sizeof
(
secid6
),
secid6
,
S_OK
},
{
url7
,
3
,
S_OK
,
sizeof
(
secid7
),
secid7
,
S_OK
}
};
static
void
test_SecurityManager
(
void
)
{
int
i
;
IInternetSecurityManager
*
secmgr
=
NULL
;
DWORD
zone
;
BYTE
buf
[
512
];
DWORD
zone
,
size
;
HRESULT
hres
;
hres
=
CoInternetCreateSecurityManager
(
NULL
,
&
secmgr
,
0
);
...
...
@@ -437,17 +453,45 @@ static void test_SecurityManager(void)
for
(
i
=
0
;
i
<
sizeof
(
secmgr_tests
)
/
sizeof
(
secmgr_tests
[
0
]);
i
++
)
{
zone
=
100
;
hres
=
IInternetSecurityManager_MapUrlToZone
(
secmgr
,
secmgr_tests
[
i
].
url
,
&
zone
,
0
);
ok
(
hres
==
secmgr_tests
[
i
].
zone_hres
,
"[%d] MapUrlToZone failed: %08lx, expected %08lx
\n
"
,
hres
=
IInternetSecurityManager_MapUrlToZone
(
secmgr
,
secmgr_tests
[
i
].
url
,
&
zone
,
0
);
ok
(
hres
==
secmgr_tests
[
i
].
zone_hres
,
"[%d] MapUrlToZone failed: %08lx, expected %08lx
\n
"
,
i
,
hres
,
secmgr_tests
[
i
].
zone_hres
);
ok
(
zone
==
secmgr_tests
[
i
].
zone
,
"[%d] zone=%ld, expected %ld
\n
"
,
i
,
zone
,
secmgr_tests
[
i
].
zone
);
size
=
sizeof
(
buf
);
memset
(
buf
,
0xf0
,
sizeof
(
buf
));
hres
=
IInternetSecurityManager_GetSecurityId
(
secmgr
,
secmgr_tests
[
i
].
url
,
buf
,
&
size
,
0
);
ok
(
hres
==
secmgr_tests
[
i
].
secid_hres
,
"[%d] GetSecurityId failed: %08lx, expected %08lx
\n
"
,
i
,
hres
,
secmgr_tests
[
i
].
secid_hres
);
if
(
secmgr_tests
[
i
].
secid
)
{
ok
(
size
==
secmgr_tests
[
i
].
secid_size
,
"[%d] size=%ld, expected %ld
\n
"
,
i
,
size
,
secmgr_tests
[
i
].
secid_size
);
ok
(
!
memcmp
(
buf
,
secmgr_tests
[
i
].
secid
,
size
),
"[%d] wrong secid
\n
"
,
i
);
}
}
zone
=
100
;
hres
=
IInternetSecurityManager_MapUrlToZone
(
secmgr
,
NULL
,
&
zone
,
0
);
ok
(
hres
==
E_INVALIDARG
,
"MapUrlToZone failed: %08lx, expected E_INVALIDARG
\n
"
,
hres
);
size
=
sizeof
(
buf
);
hres
=
IInternetSecurityManager_GetSecurityId
(
secmgr
,
NULL
,
buf
,
&
size
,
0
);
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityId failed: %08lx, expected E_INVALIDARG
\n
"
,
hres
);
hres
=
IInternetSecurityManager_GetSecurityId
(
secmgr
,
secmgr_tests
[
1
].
url
,
NULL
,
&
size
,
0
);
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityId failed: %08lx, expected E_INVALIDARG
\n
"
,
hres
);
hres
=
IInternetSecurityManager_GetSecurityId
(
secmgr
,
secmgr_tests
[
1
].
url
,
buf
,
NULL
,
0
);
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityId failed: %08lx, expected E_INVALIDARG
\n
"
,
hres
);
IInternetSecurityManager_Release
(
secmgr
);
}
...
...
@@ -486,12 +530,43 @@ static void test_ZoneManager(void)
IInternetZoneManager_Release
(
zonemgr
);
}
static
void
register_protocols
(
void
)
{
IInternetSession
*
session
;
IClassFactory
*
factory
;
HRESULT
hres
;
static
const
WCHAR
wszAbout
[]
=
{
'a'
,
'b'
,
'o'
,
'u'
,
't'
,
0
};
hres
=
CoInternetGetSession
(
0
,
&
session
,
0
);
ok
(
hres
==
S_OK
,
"CoInternetGetSession failed: %08lx
\n
"
,
hres
);
if
(
FAILED
(
hres
))
return
;
hres
=
CoGetClassObject
(
&
CLSID_AboutProtocol
,
CLSCTX_INPROC_SERVER
,
NULL
,
&
IID_IClassFactory
,
(
void
**
)
&
factory
);
ok
(
hres
==
S_OK
,
"Coud not get AboutProtocol factory: %08lx
\n
"
,
hres
);
if
(
FAILED
(
hres
))
return
;
IInternetSession_RegisterNameSpace
(
session
,
factory
,
&
CLSID_AboutProtocol
,
wszAbout
,
0
,
NULL
,
0
);
IClassFactory_Release
(
factory
);
}
START_TEST
(
misc
)
{
OleInitialize
(
NULL
);
register_protocols
();
test_CreateFormatEnum
();
test_RegisterFormatEnumerator
();
test_CoInternetParseUrl
();
test_FindMimeFromData
();
test_SecurityManager
();
test_ZoneManager
();
OleUninitialize
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment