jscript: Removed unused do_*_tag_format arguments.
[wine/multimedia.git] / dlls / urlmon / session.c
blobce6ab4e9d6402aa516be10d0fbcb2d2f5b2fdfd6
1 /*
2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "urlmon_main.h"
20 #include "winreg.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
26 typedef struct {
27 LPWSTR protocol;
28 IClassFactory *cf;
29 CLSID clsid;
30 BOOL urlmon;
32 struct list entry;
33 } name_space;
35 typedef struct {
36 IClassFactory *cf;
37 CLSID clsid;
38 LPWSTR mime;
40 struct list entry;
41 } mime_filter;
43 static struct list name_space_list = LIST_INIT(name_space_list);
44 static struct list mime_filter_list = LIST_INIT(mime_filter_list);
46 static CRITICAL_SECTION session_cs;
47 static CRITICAL_SECTION_DEBUG session_cs_dbg =
49 0, 0, &session_cs,
50 { &session_cs_dbg.ProcessLocksList, &session_cs_dbg.ProcessLocksList },
51 0, 0, { (DWORD_PTR)(__FILE__ ": session") }
53 static CRITICAL_SECTION session_cs = { &session_cs_dbg, -1, 0, 0, 0, 0 };
55 static const WCHAR internet_settings_keyW[] =
56 {'S','O','F','T','W','A','R','E',
57 '\\','M','i','c','r','o','s','o','f','t',
58 '\\','W','i','n','d','o','w','s',
59 '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
60 '\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
62 static name_space *find_name_space(LPCWSTR protocol)
64 name_space *iter;
66 LIST_FOR_EACH_ENTRY(iter, &name_space_list, name_space, entry) {
67 if(!strcmpiW(iter->protocol, protocol))
68 return iter;
71 return NULL;
74 static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, IClassFactory **ret)
76 WCHAR str_clsid[64];
77 HKEY hkey = NULL;
78 DWORD res, type, size;
79 CLSID clsid;
80 LPWSTR wszKey;
81 HRESULT hres;
83 static const WCHAR wszProtocolsKey[] =
84 {'P','R','O','T','O','C','O','L','S','\\','H','a','n','d','l','e','r','\\'};
85 static const WCHAR wszCLSID[] = {'C','L','S','I','D',0};
87 wszKey = heap_alloc(sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR));
88 memcpy(wszKey, wszProtocolsKey, sizeof(wszProtocolsKey));
89 memcpy(wszKey + sizeof(wszProtocolsKey)/sizeof(WCHAR), schema, (schema_len+1)*sizeof(WCHAR));
91 res = RegOpenKeyW(HKEY_CLASSES_ROOT, wszKey, &hkey);
92 heap_free(wszKey);
93 if(res != ERROR_SUCCESS) {
94 TRACE("Could not open protocol handler key\n");
95 return MK_E_SYNTAX;
98 size = sizeof(str_clsid);
99 res = RegQueryValueExW(hkey, wszCLSID, NULL, &type, (LPBYTE)str_clsid, &size);
100 RegCloseKey(hkey);
101 if(res != ERROR_SUCCESS || type != REG_SZ) {
102 WARN("Could not get protocol CLSID res=%d\n", res);
103 return MK_E_SYNTAX;
106 hres = CLSIDFromString(str_clsid, &clsid);
107 if(FAILED(hres)) {
108 WARN("CLSIDFromString failed: %08x\n", hres);
109 return hres;
112 if(pclsid)
113 *pclsid = clsid;
115 if(!ret)
116 return S_OK;
118 hres = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)ret);
119 return SUCCEEDED(hres) ? S_OK : MK_E_SYNTAX;
122 HRESULT register_namespace(IClassFactory *cf, REFIID clsid, LPCWSTR protocol, BOOL urlmon_protocol)
124 name_space *new_name_space;
126 new_name_space = heap_alloc(sizeof(name_space));
128 if(!urlmon_protocol)
129 IClassFactory_AddRef(cf);
130 new_name_space->cf = cf;
131 new_name_space->clsid = *clsid;
132 new_name_space->urlmon = urlmon_protocol;
133 new_name_space->protocol = heap_strdupW(protocol);
135 EnterCriticalSection(&session_cs);
137 list_add_head(&name_space_list, &new_name_space->entry);
139 LeaveCriticalSection(&session_cs);
141 return S_OK;
144 static HRESULT unregister_namespace(IClassFactory *cf, LPCWSTR protocol)
146 name_space *iter;
148 EnterCriticalSection(&session_cs);
150 LIST_FOR_EACH_ENTRY(iter, &name_space_list, name_space, entry) {
151 if(iter->cf == cf && !strcmpiW(iter->protocol, protocol)) {
152 list_remove(&iter->entry);
154 LeaveCriticalSection(&session_cs);
156 if(!iter->urlmon)
157 IClassFactory_Release(iter->cf);
158 heap_free(iter->protocol);
159 heap_free(iter);
160 return S_OK;
164 LeaveCriticalSection(&session_cs);
165 return S_OK;
168 BOOL is_registered_protocol(LPCWSTR url)
170 DWORD schema_len;
171 WCHAR schema[64];
172 HRESULT hres;
174 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
175 &schema_len, 0);
176 if(FAILED(hres))
177 return FALSE;
179 return get_protocol_cf(schema, schema_len, NULL, NULL) == S_OK;
182 IInternetProtocolInfo *get_protocol_info(LPCWSTR url)
184 IInternetProtocolInfo *ret = NULL;
185 IClassFactory *cf;
186 name_space *ns;
187 WCHAR schema[64];
188 DWORD schema_len;
189 HRESULT hres;
191 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
192 &schema_len, 0);
193 if(FAILED(hres) || !schema_len)
194 return NULL;
196 EnterCriticalSection(&session_cs);
198 ns = find_name_space(schema);
199 if(ns && !ns->urlmon) {
200 hres = IClassFactory_QueryInterface(ns->cf, &IID_IInternetProtocolInfo, (void**)&ret);
201 if(FAILED(hres))
202 hres = IClassFactory_CreateInstance(ns->cf, NULL, &IID_IInternetProtocolInfo, (void**)&ret);
205 LeaveCriticalSection(&session_cs);
207 if(ns && SUCCEEDED(hres))
208 return ret;
210 hres = get_protocol_cf(schema, schema_len, NULL, &cf);
211 if(FAILED(hres))
212 return NULL;
214 hres = IClassFactory_QueryInterface(cf, &IID_IInternetProtocolInfo, (void**)&ret);
215 if(FAILED(hres))
216 IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocolInfo, (void**)&ret);
217 IClassFactory_Release(cf);
219 return ret;
222 HRESULT get_protocol_handler(IUri *uri, CLSID *clsid, BOOL *urlmon_protocol, IClassFactory **ret)
224 name_space *ns;
225 BSTR scheme;
226 HRESULT hres;
228 *ret = NULL;
230 /* FIXME: Avoid GetSchemeName call for known schemes */
231 hres = IUri_GetSchemeName(uri, &scheme);
232 if(FAILED(hres))
233 return hres;
235 EnterCriticalSection(&session_cs);
237 ns = find_name_space(scheme);
238 if(ns) {
239 *ret = ns->cf;
240 IClassFactory_AddRef(*ret);
241 if(clsid)
242 *clsid = ns->clsid;
243 if(urlmon_protocol)
244 *urlmon_protocol = ns->urlmon;
247 LeaveCriticalSection(&session_cs);
249 if(*ret) {
250 hres = S_OK;
251 }else {
252 if(urlmon_protocol)
253 *urlmon_protocol = FALSE;
254 hres = get_protocol_cf(scheme, SysStringLen(scheme), clsid, ret);
257 SysFreeString(scheme);
258 return hres;
261 IInternetProtocol *get_mime_filter(LPCWSTR mime)
263 static const WCHAR filtersW[] = {'P','r','o','t','o','c','o','l','s',
264 '\\','F','i','l','t','e','r',0 };
265 static const WCHAR CLSIDW[] = {'C','L','S','I','D',0};
267 IClassFactory *cf = NULL;
268 IInternetProtocol *ret;
269 mime_filter *iter;
270 HKEY hlist, hfilter;
271 WCHAR clsidw[64];
272 CLSID clsid;
273 DWORD res, type, size;
274 HRESULT hres;
276 EnterCriticalSection(&session_cs);
278 LIST_FOR_EACH_ENTRY(iter, &mime_filter_list, mime_filter, entry) {
279 if(!strcmpW(iter->mime, mime)) {
280 cf = iter->cf;
281 break;
285 LeaveCriticalSection(&session_cs);
287 if(cf) {
288 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&ret);
289 if(FAILED(hres)) {
290 WARN("CreateInstance failed: %08x\n", hres);
291 return NULL;
294 return ret;
297 res = RegOpenKeyW(HKEY_CLASSES_ROOT, filtersW, &hlist);
298 if(res != ERROR_SUCCESS) {
299 TRACE("Could not open MIME filters key\n");
300 return NULL;
303 res = RegOpenKeyW(hlist, mime, &hfilter);
304 CloseHandle(hlist);
305 if(res != ERROR_SUCCESS)
306 return NULL;
308 size = sizeof(clsidw);
309 res = RegQueryValueExW(hfilter, CLSIDW, NULL, &type, (LPBYTE)clsidw, &size);
310 CloseHandle(hfilter);
311 if(res!=ERROR_SUCCESS || type!=REG_SZ) {
312 WARN("Could not get filter CLSID for %s\n", debugstr_w(mime));
313 return NULL;
316 hres = CLSIDFromString(clsidw, &clsid);
317 if(FAILED(hres)) {
318 WARN("CLSIDFromString failed for %s (%x)\n", debugstr_w(mime), hres);
319 return NULL;
322 hres = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&ret);
323 if(FAILED(hres)) {
324 WARN("CoCreateInstance failed: %08x\n", hres);
325 return NULL;
328 return ret;
331 static HRESULT WINAPI InternetSession_QueryInterface(IInternetSession *iface,
332 REFIID riid, void **ppv)
334 TRACE("(%s %p)\n", debugstr_guid(riid), ppv);
336 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetSession, riid)) {
337 *ppv = iface;
338 IInternetSession_AddRef(iface);
339 return S_OK;
342 *ppv = NULL;
343 return E_NOINTERFACE;
346 static ULONG WINAPI InternetSession_AddRef(IInternetSession *iface)
348 TRACE("()\n");
349 URLMON_LockModule();
350 return 2;
353 static ULONG WINAPI InternetSession_Release(IInternetSession *iface)
355 TRACE("()\n");
356 URLMON_UnlockModule();
357 return 1;
360 static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface,
361 IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns,
362 const LPCWSTR *ppwzPatterns, DWORD dwReserved)
364 TRACE("(%p %s %s %d %p %d)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol),
365 cPatterns, ppwzPatterns, dwReserved);
367 if(cPatterns || ppwzPatterns)
368 FIXME("patterns not supported\n");
369 if(dwReserved)
370 WARN("dwReserved = %d\n", dwReserved);
372 if(!pCF || !pwzProtocol)
373 return E_INVALIDARG;
375 return register_namespace(pCF, rclsid, pwzProtocol, FALSE);
378 static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface,
379 IClassFactory *pCF, LPCWSTR pszProtocol)
381 TRACE("(%p %s)\n", pCF, debugstr_w(pszProtocol));
383 if(!pCF || !pszProtocol)
384 return E_INVALIDARG;
386 return unregister_namespace(pCF, pszProtocol);
389 static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface,
390 IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzType)
392 mime_filter *filter;
394 TRACE("(%p %s %s)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzType));
396 filter = heap_alloc(sizeof(mime_filter));
398 IClassFactory_AddRef(pCF);
399 filter->cf = pCF;
400 filter->clsid = *rclsid;
401 filter->mime = heap_strdupW(pwzType);
403 EnterCriticalSection(&session_cs);
405 list_add_head(&mime_filter_list, &filter->entry);
407 LeaveCriticalSection(&session_cs);
409 return S_OK;
412 static HRESULT WINAPI InternetSession_UnregisterMimeFilter(IInternetSession *iface,
413 IClassFactory *pCF, LPCWSTR pwzType)
415 mime_filter *iter;
417 TRACE("(%p %s)\n", pCF, debugstr_w(pwzType));
419 EnterCriticalSection(&session_cs);
421 LIST_FOR_EACH_ENTRY(iter, &mime_filter_list, mime_filter, entry) {
422 if(iter->cf == pCF && !strcmpW(iter->mime, pwzType)) {
423 list_remove(&iter->entry);
425 LeaveCriticalSection(&session_cs);
427 IClassFactory_Release(iter->cf);
428 heap_free(iter->mime);
429 heap_free(iter);
430 return S_OK;
434 LeaveCriticalSection(&session_cs);
435 return S_OK;
438 static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,
439 LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk,
440 IInternetProtocol **ppOInetProt, DWORD dwOption)
442 BindProtocol *protocol;
443 HRESULT hres;
445 TRACE("(%p %s %p %p %p %08x)\n", pBC, debugstr_w(szUrl), pUnkOuter, ppUnk,
446 ppOInetProt, dwOption);
448 if(pBC || pUnkOuter || ppUnk || dwOption)
449 FIXME("Unsupported arguments\n");
451 hres = create_binding_protocol(FALSE, &protocol);
452 if(FAILED(hres))
453 return hres;
455 *ppOInetProt = (IInternetProtocol*)&protocol->IInternetProtocolEx_iface;
456 return S_OK;
459 static HRESULT WINAPI InternetSession_SetSessionOption(IInternetSession *iface,
460 DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD dwReserved)
462 FIXME("(%08x %p %d %d)\n", dwOption, pBuffer, dwBufferLength, dwReserved);
463 return E_NOTIMPL;
466 static const IInternetSessionVtbl InternetSessionVtbl = {
467 InternetSession_QueryInterface,
468 InternetSession_AddRef,
469 InternetSession_Release,
470 InternetSession_RegisterNameSpace,
471 InternetSession_UnregisterNameSpace,
472 InternetSession_RegisterMimeFilter,
473 InternetSession_UnregisterMimeFilter,
474 InternetSession_CreateBinding,
475 InternetSession_SetSessionOption
478 static IInternetSession InternetSession = { &InternetSessionVtbl };
480 /***********************************************************************
481 * CoInternetGetSession (URLMON.@)
483 * Create a new internet session and return an IInternetSession interface
484 * representing it.
486 * PARAMS
487 * dwSessionMode [I] Mode for the internet session
488 * ppIInternetSession [O] Destination for creates IInternetSession object
489 * dwReserved [I] Reserved, must be 0.
491 * RETURNS
492 * Success: S_OK. ppIInternetSession contains the IInternetSession interface.
493 * Failure: E_INVALIDARG, if any argument is invalid, or
494 * E_OUTOFMEMORY if memory allocation fails.
496 HRESULT WINAPI CoInternetGetSession(DWORD dwSessionMode, IInternetSession **ppIInternetSession,
497 DWORD dwReserved)
499 TRACE("(%d %p %d)\n", dwSessionMode, ppIInternetSession, dwReserved);
501 if(dwSessionMode)
502 ERR("dwSessionMode=%d\n", dwSessionMode);
503 if(dwReserved)
504 ERR("dwReserved=%d\n", dwReserved);
506 IInternetSession_AddRef(&InternetSession);
507 *ppIInternetSession = &InternetSession;
508 return S_OK;
511 /**************************************************************************
512 * UrlMkGetSessionOption (URLMON.@)
514 static BOOL get_url_encoding(HKEY root, DWORD *encoding)
516 DWORD size = sizeof(DWORD), res, type;
517 HKEY hkey;
519 static const WCHAR wszUrlEncoding[] = {'U','r','l','E','n','c','o','d','i','n','g',0};
521 res = RegOpenKeyW(root, internet_settings_keyW, &hkey);
522 if(res != ERROR_SUCCESS)
523 return FALSE;
525 res = RegQueryValueExW(hkey, wszUrlEncoding, NULL, &type, (LPBYTE)encoding, &size);
526 RegCloseKey(hkey);
528 return res == ERROR_SUCCESS;
531 static LPWSTR user_agent;
533 static void ensure_useragent(void)
535 OSVERSIONINFOW info = {sizeof(info)};
536 const WCHAR *os_type, *is_nt;
537 WCHAR buf[512];
538 BOOL is_wow;
540 static const WCHAR formatW[] =
541 {'M','o','z','i','l','l','a','/','4','.','0',
542 ' ','(','c','o','m','p','a','t','i','b','l','e',';',
543 ' ','M','S','I','E',' ','8','.','0',';',
544 ' ','W','i','n','d','o','w','s',' ','%','s','%','d','.','%','d',';',
545 ' ','%','s',';',' ','T','r','i','d','e','n','t','/','5','.','0',')',0};
546 static const WCHAR ntW[] = {'N','T',' ',0};
547 static const WCHAR win32W[] = {'W','i','n','3','2',0};
548 static const WCHAR win64W[] = {'W','i','n','6','4',0};
549 static const WCHAR wow64W[] = {'W','O','W','6','4',0};
550 static const WCHAR emptyW[] = {0};
552 if(user_agent)
553 return;
555 GetVersionExW(&info);
556 is_nt = info.dwPlatformId == VER_PLATFORM_WIN32_NT ? ntW : emptyW;
558 if(sizeof(void*) == 8)
559 os_type = win64W;
560 else if(IsWow64Process(GetCurrentProcess(), &is_wow) && is_wow)
561 os_type = wow64W;
562 else
563 os_type = win32W;
565 sprintfW(buf, formatW, is_nt, info.dwMajorVersion, info.dwMinorVersion, os_type);
566 user_agent = heap_strdupW(buf);
569 LPWSTR get_useragent(void)
571 LPWSTR ret;
573 ensure_useragent();
575 EnterCriticalSection(&session_cs);
576 ret = heap_strdupW(user_agent);
577 LeaveCriticalSection(&session_cs);
579 return ret;
582 HRESULT WINAPI UrlMkGetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength,
583 DWORD* pdwBufferLength, DWORD dwReserved)
585 TRACE("(%x, %p, %d, %p)\n", dwOption, pBuffer, dwBufferLength, pdwBufferLength);
587 if(dwReserved)
588 WARN("dwReserved = %d\n", dwReserved);
590 switch(dwOption) {
591 case URLMON_OPTION_USERAGENT: {
592 HRESULT hres = E_OUTOFMEMORY;
593 DWORD size;
595 if(!pdwBufferLength)
596 return E_INVALIDARG;
598 EnterCriticalSection(&session_cs);
600 ensure_useragent();
601 if(user_agent) {
602 size = WideCharToMultiByte(CP_ACP, 0, user_agent, -1, NULL, 0, NULL, NULL);
603 *pdwBufferLength = size;
604 if(size <= dwBufferLength) {
605 if(pBuffer)
606 WideCharToMultiByte(CP_ACP, 0, user_agent, -1, pBuffer, size, NULL, NULL);
607 else
608 hres = E_INVALIDARG;
612 LeaveCriticalSection(&session_cs);
614 /* Tests prove that we have to return E_OUTOFMEMORY on success. */
615 return hres;
617 case URLMON_OPTION_URL_ENCODING: {
618 DWORD encoding = 0;
620 if(!pBuffer || dwBufferLength < sizeof(DWORD) || !pdwBufferLength)
621 return E_INVALIDARG;
623 if(!get_url_encoding(HKEY_CURRENT_USER, &encoding))
624 get_url_encoding(HKEY_LOCAL_MACHINE, &encoding);
626 *pdwBufferLength = sizeof(DWORD);
627 *(DWORD*)pBuffer = encoding ? URL_ENCODING_DISABLE_UTF8 : URL_ENCODING_ENABLE_UTF8;
628 return S_OK;
630 default:
631 FIXME("unsupported option %x\n", dwOption);
634 return E_INVALIDARG;
637 /**************************************************************************
638 * UrlMkSetSessionOption (URLMON.@)
640 HRESULT WINAPI UrlMkSetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength,
641 DWORD Reserved)
643 TRACE("(%x %p %x)\n", dwOption, pBuffer, dwBufferLength);
645 switch(dwOption) {
646 case URLMON_OPTION_USERAGENT: {
647 LPWSTR new_user_agent;
648 char *buf = pBuffer;
649 DWORD len, size;
651 if(!pBuffer || !dwBufferLength)
652 return E_INVALIDARG;
654 for(len=0; len<dwBufferLength && buf[len]; len++);
656 TRACE("Setting user agent %s\n", debugstr_an(buf, len));
658 size = MultiByteToWideChar(CP_ACP, 0, buf, len, NULL, 0);
659 new_user_agent = heap_alloc((size+1)*sizeof(WCHAR));
660 if(!new_user_agent)
661 return E_OUTOFMEMORY;
662 MultiByteToWideChar(CP_ACP, 0, buf, len, new_user_agent, size);
663 new_user_agent[size] = 0;
665 EnterCriticalSection(&session_cs);
667 heap_free(user_agent);
668 user_agent = new_user_agent;
670 LeaveCriticalSection(&session_cs);
671 break;
673 default:
674 FIXME("Unknown option %x\n", dwOption);
675 return E_INVALIDARG;
678 return S_OK;
681 /**************************************************************************
682 * ObtainUserAgentString (URLMON.@)
684 HRESULT WINAPI ObtainUserAgentString(DWORD dwOption, LPSTR pcszUAOut, DWORD *cbSize)
686 DWORD size;
687 HRESULT hres = E_FAIL;
689 TRACE("(%d %p %p)\n", dwOption, pcszUAOut, cbSize);
691 if(!pcszUAOut || !cbSize)
692 return E_INVALIDARG;
694 EnterCriticalSection(&session_cs);
696 ensure_useragent();
697 if(user_agent) {
698 size = WideCharToMultiByte(CP_ACP, 0, user_agent, -1, NULL, 0, NULL, NULL);
700 if(size <= *cbSize) {
701 WideCharToMultiByte(CP_ACP, 0, user_agent, -1, pcszUAOut, *cbSize, NULL, NULL);
702 hres = S_OK;
703 }else {
704 hres = E_OUTOFMEMORY;
707 *cbSize = size;
710 LeaveCriticalSection(&session_cs);
711 return hres;
714 void free_session(void)
716 name_space *ns_iter, *ns_last;
717 mime_filter *mf_iter, *mf_last;
719 LIST_FOR_EACH_ENTRY_SAFE(ns_iter, ns_last, &name_space_list, name_space, entry) {
720 if(!ns_iter->urlmon)
721 IClassFactory_Release(ns_iter->cf);
722 heap_free(ns_iter->protocol);
723 heap_free(ns_iter);
726 LIST_FOR_EACH_ENTRY_SAFE(mf_iter, mf_last, &mime_filter_list, mime_filter, entry) {
727 IClassFactory_Release(mf_iter->cf);
728 heap_free(mf_iter->mime);
729 heap_free(mf_iter);
732 heap_free(user_agent);