ReactOS 0.4.16-dev-319-g6cf4263
session.c File Reference
#include "urlmon_main.h"
#include "winreg.h"
#include "wine/debug.h"
Include dependency graph for session.c:

Go to the source code of this file.

Classes

struct  name_space
 
struct  mime_filter
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (urlmon)
 
static name_spacefind_name_space (LPCWSTR protocol)
 
static HRESULT get_protocol_cf (LPCWSTR schema, DWORD schema_len, CLSID *pclsid, IClassFactory **ret)
 
HRESULT register_namespace (IClassFactory *cf, REFIID clsid, LPCWSTR protocol, BOOL urlmon_protocol)
 
static HRESULT unregister_namespace (IClassFactory *cf, LPCWSTR protocol)
 
BOOL is_registered_protocol (LPCWSTR url)
 
IInternetProtocolInfoget_protocol_info (LPCWSTR url)
 
HRESULT get_protocol_handler (IUri *uri, CLSID *clsid, IClassFactory **ret)
 
IInternetProtocolget_mime_filter (LPCWSTR mime)
 
static HRESULT WINAPI InternetSession_QueryInterface (IInternetSession *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI InternetSession_AddRef (IInternetSession *iface)
 
static ULONG WINAPI InternetSession_Release (IInternetSession *iface)
 
static HRESULT WINAPI InternetSession_RegisterNameSpace (IInternetSession *iface, IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns, const LPCWSTR *ppwzPatterns, DWORD dwReserved)
 
static HRESULT WINAPI InternetSession_UnregisterNameSpace (IInternetSession *iface, IClassFactory *pCF, LPCWSTR pszProtocol)
 
static HRESULT WINAPI InternetSession_RegisterMimeFilter (IInternetSession *iface, IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzType)
 
static HRESULT WINAPI InternetSession_UnregisterMimeFilter (IInternetSession *iface, IClassFactory *pCF, LPCWSTR pwzType)
 
static HRESULT WINAPI InternetSession_CreateBinding (IInternetSession *iface, LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IInternetProtocol **ppOInetProt, DWORD dwOption)
 
static HRESULT WINAPI InternetSession_SetSessionOption (IInternetSession *iface, DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD dwReserved)
 
HRESULT WINAPI CoInternetGetSession (DWORD dwSessionMode, IInternetSession **ppIInternetSession, DWORD dwReserved)
 
static BOOL get_url_encoding (HKEY root, DWORD *encoding)
 
static void ensure_useragent (void)
 
LPWSTR get_useragent (void)
 
HRESULT WINAPI UrlMkGetSessionOption (DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD *pdwBufferLength, DWORD dwReserved)
 
HRESULT WINAPI UrlMkSetSessionOption (DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD Reserved)
 
HRESULT WINAPI ObtainUserAgentString (DWORD dwOption, LPSTR pcszUAOut, DWORD *cbSize)
 
void free_session (void)
 

Variables

static struct list name_space_list = LIST_INIT(name_space_list)
 
static struct list mime_filter_list = LIST_INIT(mime_filter_list)
 
static CRITICAL_SECTION session_cs = { &session_cs_dbg, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG session_cs_dbg
 
static const WCHAR internet_settings_keyW []
 
static const IInternetSessionVtbl InternetSessionVtbl
 
static IInternetSession InternetSession = { &InternetSessionVtbl }
 
static LPWSTR user_agent
 

Function Documentation

◆ CoInternetGetSession()

HRESULT WINAPI CoInternetGetSession ( DWORD  dwSessionMode,
IInternetSession **  ppIInternetSession,
DWORD  dwReserved 
)

Definition at line 485 of file session.c.

487{
488 TRACE("(%d %p %d)\n", dwSessionMode, ppIInternetSession, dwReserved);
489
490 if(dwSessionMode)
491 ERR("dwSessionMode=%d\n", dwSessionMode);
492 if(dwReserved)
493 ERR("dwReserved=%d\n", dwReserved);
494
495 IInternetSession_AddRef(&InternetSession);
496 *ppIInternetSession = &InternetSession;
497 return S_OK;
498}
#define ERR(fmt,...)
Definition: precomp.h:57
static IInternetSession InternetSession
Definition: session.c:467
#define S_OK
Definition: intsafe.h:52
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by register_protocol(), and register_protocols().

◆ ensure_useragent()

static void ensure_useragent ( void  )
static

Definition at line 522 of file session.c.

523{
524 OSVERSIONINFOW info = {sizeof(info)};
525 const WCHAR *os_type, *is_nt;
526 WCHAR buf[512], *ret, *tmp;
527 DWORD res, idx=0;
528 size_t len, size;
529 BOOL is_wow;
530 HKEY key;
531
532 static const WCHAR formatW[] =
533 {'M','o','z','i','l','l','a','/','4','.','0',
534 ' ','(','c','o','m','p','a','t','i','b','l','e',';',
535 ' ','M','S','I','E',' ','8','.','0',';',
536 ' ','W','i','n','d','o','w','s',' ','%','s','%','d','.','%','d',';',
537 ' ','%','s','T','r','i','d','e','n','t','/','5','.','0',0};
538 static const WCHAR post_platform_keyW[] =
539 {'S','O','F','T','W','A','R','E',
540 '\\','M','i','c','r','o','s','o','f','t',
541 '\\','W','i','n','d','o','w','s',
542 '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
543 '\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',
544 '\\','5','.','0','\\','U','s','e','r',' ','A','g','e','n','t',
545 '\\','P','o','s','t',' ','P','l','a','t','f','o','r','m',0};
546 static const WCHAR ntW[] = {'N','T',' ',0};
547 static const WCHAR win64W[] = {'W','i','n','6','4',';',' ','x','6','4',';',' ',0};
548 static const WCHAR wow64W[] = {'W','O','W','6','4',';',' ',0};
549 static const WCHAR emptyW[] = {0};
550
551 if(user_agent)
552 return;
553
555 is_nt = info.dwPlatformId == VER_PLATFORM_WIN32_NT ? ntW : emptyW;
556
557 if(sizeof(void*) == 8)
558 os_type = win64W;
559 else if(IsWow64Process(GetCurrentProcess(), &is_wow) && is_wow)
560 os_type = wow64W;
561 else
562 os_type = emptyW;
563
564 swprintf(buf, formatW, is_nt, info.dwMajorVersion, info.dwMinorVersion, os_type);
565 len = lstrlenW(buf);
566
567 size = len+40;
568 ret = heap_alloc(size * sizeof(WCHAR));
569 if(!ret)
570 return;
571
572 memcpy(ret, buf, len*sizeof(WCHAR));
573
574 res = RegOpenKeyW(HKEY_LOCAL_MACHINE, post_platform_keyW, &key);
575 if(res == ERROR_SUCCESS) {
576 DWORD value_len;
577
578 while(1) {
579 value_len = ARRAY_SIZE(buf);
580 res = RegEnumValueW(key, idx, buf, &value_len, NULL, NULL, NULL, NULL);
581 if(res != ERROR_SUCCESS)
582 break;
583 idx++;
584
585 if(len + value_len + 2 /* strlen("; ") */ + 1 /* trailing ')' */ >= size) {
586 tmp = heap_realloc(ret, (size*2+value_len)*sizeof(WCHAR));
587 if(!tmp)
588 break;
589 ret = tmp;
590 size = size*2+value_len;
591 }
592
593 ret[len++] = ';';
594 ret[len++] = ' ';
595 memcpy(ret+len, buf, value_len*sizeof(WCHAR));
596 len += value_len;
597 }
598
600 }
601
602 ret[len++] = ')';
603 ret[len++] = 0;
604
605 user_agent = ret;
606 TRACE("Using user agent %s\n", debugstr_w(user_agent));
607}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define ARRAY_SIZE(A)
Definition: main.h:20
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
static LPWSTR user_agent
Definition: session.c:520
#define swprintf
Definition: precomp.h:40
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR emptyW[]
Definition: navigate.c:40
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:238
Definition: copy.c:22
int ret
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by get_useragent(), ObtainUserAgentString(), and UrlMkGetSessionOption().

◆ find_name_space()

static name_space * find_name_space ( LPCWSTR  protocol)
static

Definition at line 62 of file session.c.

63{
64 name_space *iter;
65
67 if(!wcsicmp(iter->protocol, protocol))
68 return iter;
69 }
70
71 return NULL;
72}
#define wcsicmp
Definition: compat.h:15
static struct list name_space_list
Definition: session.c:43
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
LPWSTR protocol
Definition: session.c:27

Referenced by get_protocol_handler(), and get_protocol_info().

◆ free_session()

void free_session ( void  )

Definition at line 755 of file session.c.

756{
757 name_space *ns_iter, *ns_last;
758 mime_filter *mf_iter, *mf_last;
759
761 if(!ns_iter->urlmon)
762 IClassFactory_Release(ns_iter->cf);
763 heap_free(ns_iter->protocol);
764 heap_free(ns_iter);
765 }
766
768 IClassFactory_Release(mf_iter->cf);
769 heap_free(mf_iter->mime);
770 heap_free(mf_iter);
771 }
772
774}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static struct list mime_filter_list
Definition: session.c:44
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
IClassFactory * cf
Definition: session.c:36
LPWSTR mime
Definition: session.c:38
BOOL urlmon
Definition: session.c:30
IClassFactory * cf
Definition: session.c:28

Referenced by process_detach().

◆ get_mime_filter()

IInternetProtocol * get_mime_filter ( LPCWSTR  mime)

Definition at line 250 of file session.c.

251{
252 static const WCHAR filtersW[] = {'P','r','o','t','o','c','o','l','s',
253 '\\','F','i','l','t','e','r',0 };
254 static const WCHAR CLSIDW[] = {'C','L','S','I','D',0};
255
258 mime_filter *iter;
259 HKEY hlist, hfilter;
260 WCHAR clsidw[64];
261 CLSID clsid;
262 DWORD res, type, size;
264
266
268 if(!wcscmp(iter->mime, mime)) {
269 cf = iter->cf;
270 break;
271 }
272 }
273
275
276 if(cf) {
277 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&ret);
278 if(FAILED(hres)) {
279 WARN("CreateInstance failed: %08x\n", hres);
280 return NULL;
281 }
282
283 return ret;
284 }
285
286 res = RegOpenKeyW(HKEY_CLASSES_ROOT, filtersW, &hlist);
287 if(res != ERROR_SUCCESS) {
288 TRACE("Could not open MIME filters key\n");
289 return NULL;
290 }
291
292 res = RegOpenKeyW(hlist, mime, &hfilter);
293 CloseHandle(hlist);
294 if(res != ERROR_SUCCESS)
295 return NULL;
296
297 size = sizeof(clsidw);
298 res = RegQueryValueExW(hfilter, CLSIDW, NULL, &type, (LPBYTE)clsidw, &size);
299 CloseHandle(hfilter);
300 if(res!=ERROR_SUCCESS || type!=REG_SZ) {
301 WARN("Could not get filter CLSID for %s\n", debugstr_w(mime));
302 return NULL;
303 }
304
305 hres = CLSIDFromString(clsidw, &clsid);
306 if(FAILED(hres)) {
307 WARN("CLSIDFromString failed for %s (%x)\n", debugstr_w(mime), hres);
308 return NULL;
309 }
310
311 hres = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&ret);
312 if(FAILED(hres)) {
313 WARN("CoCreateInstance failed: %08x\n", hres);
314 return NULL;
315 }
316
317 return ret;
318}
#define WARN(fmt,...)
Definition: precomp.h:61
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define CloseHandle
Definition: compat.h:739
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
static CRITICAL_SECTION session_cs
Definition: session.c:46
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
#define REG_SZ
Definition: layer.c:22
const WCHAR * mime
Definition: mimefilter.c:512
HRESULT hres
Definition: protocol.c:465
REFCLSID clsid
Definition: msctf.c:82
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
unsigned char * LPBYTE
Definition: typedefs.h:53
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by mime_available().

◆ get_protocol_cf()

static HRESULT get_protocol_cf ( LPCWSTR  schema,
DWORD  schema_len,
CLSID pclsid,
IClassFactory **  ret 
)
static

Definition at line 74 of file session.c.

75{
76 WCHAR str_clsid[64];
77 HKEY hkey = NULL;
80 LPWSTR wszKey;
82
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};
86
87 wszKey = heap_alloc(sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR));
88 memcpy(wszKey, wszProtocolsKey, sizeof(wszProtocolsKey));
89 memcpy(wszKey + ARRAY_SIZE(wszProtocolsKey), schema, (schema_len+1)*sizeof(WCHAR));
90
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;
96 }
97
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;
104 }
105
106 hres = CLSIDFromString(str_clsid, &clsid);
107 if(FAILED(hres)) {
108 WARN("CLSIDFromString failed: %08x\n", hres);
109 return hres;
110 }
111
112 if(pclsid)
113 *pclsid = clsid;
114
115 if(!ret)
116 return S_OK;
117
118 hres = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)ret);
119 return SUCCEEDED(hres) ? S_OK : MK_E_SYNTAX;
120}
const GUID IID_IClassFactory
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3103
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const WCHAR * schema
#define MK_E_SYNTAX
Definition: winerror.h:2785
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by get_protocol_handler(), get_protocol_info(), and is_registered_protocol().

◆ get_protocol_handler()

HRESULT get_protocol_handler ( IUri uri,
CLSID clsid,
IClassFactory **  ret 
)

Definition at line 220 of file session.c.

221{
222 name_space *ns;
223 BSTR scheme;
225
226 *ret = NULL;
227
228 /* FIXME: Avoid GetSchemeName call for known schemes */
229 hres = IUri_GetSchemeName(uri, &scheme);
230 if(FAILED(hres))
231 return hres;
232
234
236 if(ns) {
237 *ret = ns->cf;
238 IClassFactory_AddRef(*ret);
239 if(clsid)
240 *clsid = ns->clsid;
241 }
242
244
247 return hres;
248}
OLECHAR * BSTR
Definition: compat.h:2293
static name_space * find_name_space(LPCWSTR protocol)
Definition: session.c:62
static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, IClassFactory **ret)
Definition: session.c:74
const char * uri
Definition: sec_mgr.c:1588
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
DWORD scheme
Definition: mxnamespace.c:45

Referenced by BindProtocol_StartEx().

◆ get_protocol_info()

IInternetProtocolInfo * get_protocol_info ( LPCWSTR  url)

Definition at line 181 of file session.c.

182{
185 name_space *ns;
186 WCHAR schema[64];
187 DWORD schema_len;
189
190 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, ARRAY_SIZE(schema), &schema_len, 0);
191 if(FAILED(hres) || !schema_len)
192 return NULL;
193
195
197 if(ns && !ns->urlmon) {
198 hres = IClassFactory_QueryInterface(ns->cf, &IID_IInternetProtocolInfo, (void**)&ret);
199 if(FAILED(hres))
200 hres = IClassFactory_CreateInstance(ns->cf, NULL, &IID_IInternetProtocolInfo, (void**)&ret);
201 }
202
204
205 if(ns && SUCCEEDED(hres))
206 return ret;
207
208 hres = get_protocol_cf(schema, schema_len, NULL, &cf);
209 if(FAILED(hres))
210 return NULL;
211
212 hres = IClassFactory_QueryInterface(cf, &IID_IInternetProtocolInfo, (void**)&ret);
213 if(FAILED(hres))
214 IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocolInfo, (void**)&ret);
215 IClassFactory_Release(cf);
216
217 return ret;
218}
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags, LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: internet.c:392
static const WCHAR url[]
Definition: encode.c:1432

Referenced by CoInternetCombineIUri(), CoInternetCombineUrl(), CoInternetCombineUrlEx(), CoInternetCompareUrl(), CoInternetParseIUri(), CoInternetQueryInfo(), parse_canonicalize_url(), parse_domain(), parse_encode(), parse_path_from_url(), parse_rootdocument(), parse_security_domain(), and parse_security_url().

◆ get_url_encoding()

static BOOL get_url_encoding ( HKEY  root,
DWORD encoding 
)
static

Definition at line 503 of file session.c.

504{
505 DWORD size = sizeof(DWORD), res, type;
506 HKEY hkey;
507
508 static const WCHAR wszUrlEncoding[] = {'U','r','l','E','n','c','o','d','i','n','g',0};
509
511 if(res != ERROR_SUCCESS)
512 return FALSE;
513
514 res = RegQueryValueExW(hkey, wszUrlEncoding, NULL, &type, (LPBYTE)encoding, &size);
515 RegCloseKey(hkey);
516
517 return res == ERROR_SUCCESS;
518}
#define FALSE
Definition: types.h:117
static const WCHAR internet_settings_keyW[]
Definition: session.c:55
#define DWORD
Definition: nt_native.h:44
static char * encoding
Definition: xmllint.c:155

Referenced by UrlMkGetSessionOption().

◆ get_useragent()

LPWSTR get_useragent ( void  )

Definition at line 609 of file session.c.

610{
611 LPWSTR ret;
612
614
618
619 return ret;
620}
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: edit.c:4312
static void ensure_useragent(void)
Definition: session.c:522

Referenced by create_internet_session().

◆ InternetSession_AddRef()

static ULONG WINAPI InternetSession_AddRef ( IInternetSession iface)
static

Definition at line 335 of file session.c.

336{
337 TRACE("()\n");
339 return 2;
340}
static void URLMON_LockModule(void)
Definition: urlmon_main.h:68

◆ InternetSession_CreateBinding()

static HRESULT WINAPI InternetSession_CreateBinding ( IInternetSession iface,
LPBC  pBC,
LPCWSTR  szUrl,
IUnknown pUnkOuter,
IUnknown **  ppUnk,
IInternetProtocol **  ppOInetProt,
DWORD  dwOption 
)
static

Definition at line 427 of file session.c.

430{
433
434 TRACE("(%p %s %p %p %p %08x)\n", pBC, debugstr_w(szUrl), pUnkOuter, ppUnk,
435 ppOInetProt, dwOption);
436
437 if(pBC || pUnkOuter || ppUnk || dwOption)
438 FIXME("Unsupported arguments\n");
439
441 if(FAILED(hres))
442 return hres;
443
444 *ppOInetProt = (IInternetProtocol*)&protocol->IInternetProtocolEx_iface;
445 return S_OK;
446}
#define FIXME(fmt,...)
Definition: precomp.h:53
HRESULT create_binding_protocol(BindProtocol **protocol)
Definition: bindprot.c:1442

◆ InternetSession_QueryInterface()

static HRESULT WINAPI InternetSession_QueryInterface ( IInternetSession iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 320 of file session.c.

322{
323 TRACE("(%s %p)\n", debugstr_guid(riid), ppv);
324
325 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetSession, riid)) {
326 *ppv = iface;
327 IInternetSession_AddRef(iface);
328 return S_OK;
329 }
330
331 *ppv = NULL;
332 return E_NOINTERFACE;
333}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ InternetSession_RegisterMimeFilter()

static HRESULT WINAPI InternetSession_RegisterMimeFilter ( IInternetSession iface,
IClassFactory pCF,
REFCLSID  rclsid,
LPCWSTR  pwzType 
)
static

Definition at line 378 of file session.c.

380{
382
383 TRACE("(%p %s %s)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzType));
384
385 filter = heap_alloc(sizeof(mime_filter));
386
387 IClassFactory_AddRef(pCF);
388 filter->cf = pCF;
389 filter->clsid = *rclsid;
390 filter->mime = heap_strdupW(pwzType);
391
393
395
397
398 return S_OK;
399}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ InternetSession_RegisterNameSpace()

static HRESULT WINAPI InternetSession_RegisterNameSpace ( IInternetSession iface,
IClassFactory pCF,
REFCLSID  rclsid,
LPCWSTR  pwzProtocol,
ULONG  cPatterns,
const LPCWSTR ppwzPatterns,
DWORD  dwReserved 
)
static

Definition at line 349 of file session.c.

352{
353 TRACE("(%p %s %s %d %p %d)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol),
354 cPatterns, ppwzPatterns, dwReserved);
355
356 if(cPatterns || ppwzPatterns)
357 FIXME("patterns not supported\n");
358 if(dwReserved)
359 WARN("dwReserved = %d\n", dwReserved);
360
361 if(!pCF || !pwzProtocol)
362 return E_INVALIDARG;
363
364 return register_namespace(pCF, rclsid, pwzProtocol, FALSE);
365}
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT register_namespace(IClassFactory *cf, REFIID clsid, LPCWSTR protocol, BOOL urlmon_protocol)
Definition: session.c:122

◆ InternetSession_Release()

static ULONG WINAPI InternetSession_Release ( IInternetSession iface)
static

Definition at line 342 of file session.c.

343{
344 TRACE("()\n");
346 return 1;
347}
static void URLMON_UnlockModule(void)
Definition: urlmon_main.h:69

◆ InternetSession_SetSessionOption()

static HRESULT WINAPI InternetSession_SetSessionOption ( IInternetSession iface,
DWORD  dwOption,
LPVOID  pBuffer,
DWORD  dwBufferLength,
DWORD  dwReserved 
)
static

Definition at line 448 of file session.c.

450{
451 FIXME("(%08x %p %d %d)\n", dwOption, pBuffer, dwBufferLength, dwReserved);
452 return E_NOTIMPL;
453}
#define E_NOTIMPL
Definition: ddrawi.h:99
PVOID pBuffer

◆ InternetSession_UnregisterMimeFilter()

static HRESULT WINAPI InternetSession_UnregisterMimeFilter ( IInternetSession iface,
IClassFactory pCF,
LPCWSTR  pwzType 
)
static

Definition at line 401 of file session.c.

403{
404 mime_filter *iter;
405
406 TRACE("(%p %s)\n", pCF, debugstr_w(pwzType));
407
409
411 if(iter->cf == pCF && !wcscmp(iter->mime, pwzType)) {
412 list_remove(&iter->entry);
413
415
416 IClassFactory_Release(iter->cf);
417 heap_free(iter->mime);
418 heap_free(iter);
419 return S_OK;
420 }
421 }
422
424 return S_OK;
425}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
struct list entry
Definition: session.c:40

◆ InternetSession_UnregisterNameSpace()

static HRESULT WINAPI InternetSession_UnregisterNameSpace ( IInternetSession iface,
IClassFactory pCF,
LPCWSTR  pszProtocol 
)
static

Definition at line 367 of file session.c.

369{
370 TRACE("(%p %s)\n", pCF, debugstr_w(pszProtocol));
371
372 if(!pCF || !pszProtocol)
373 return E_INVALIDARG;
374
375 return unregister_namespace(pCF, pszProtocol);
376}
static HRESULT unregister_namespace(IClassFactory *cf, LPCWSTR protocol)
Definition: session.c:144

◆ is_registered_protocol()

BOOL is_registered_protocol ( LPCWSTR  url)

Definition at line 168 of file session.c.

169{
170 DWORD schema_len;
171 WCHAR schema[64];
173
174 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, ARRAY_SIZE(schema), &schema_len, 0);
175 if(FAILED(hres))
176 return FALSE;
177
178 return get_protocol_cf(schema, schema_len, NULL, NULL) == S_OK;
179}

Referenced by MkParseDisplayNameEx().

◆ ObtainUserAgentString()

HRESULT WINAPI ObtainUserAgentString ( DWORD  dwOption,
LPSTR  pcszUAOut,
DWORD cbSize 
)

Definition at line 725 of file session.c.

726{
727 DWORD size;
729
730 TRACE("(%d %p %p)\n", dwOption, pcszUAOut, cbSize);
731
732 if(!pcszUAOut || !cbSize)
733 return E_INVALIDARG;
734
736
738 if(user_agent) {
740
741 if(size <= *cbSize) {
742 WideCharToMultiByte(CP_ACP, 0, user_agent, -1, pcszUAOut, *cbSize, NULL, NULL);
743 hres = S_OK;
744 }else {
746 }
747
748 *cbSize = size;
749 }
750
752 return hres;
753}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111

Referenced by OmNavigator_get_appVersion(), OmNavigator_get_userAgent(), and test_navigator().

◆ register_namespace()

HRESULT register_namespace ( IClassFactory cf,
REFIID  clsid,
LPCWSTR  protocol,
BOOL  urlmon_protocol 
)

Definition at line 122 of file session.c.

123{
124 name_space *new_name_space;
125
126 new_name_space = heap_alloc(sizeof(name_space));
127
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);
134
136
137 list_add_head(&name_space_list, &new_name_space->entry);
138
140
141 return S_OK;
142}
CLSID clsid
Definition: session.c:29
struct list entry
Definition: session.c:32

Referenced by init_session(), and InternetSession_RegisterNameSpace().

◆ unregister_namespace()

static HRESULT unregister_namespace ( IClassFactory cf,
LPCWSTR  protocol 
)
static

Definition at line 144 of file session.c.

145{
146 name_space *iter;
147
149
151 if(iter->cf == cf && !wcsicmp(iter->protocol, protocol)) {
152 list_remove(&iter->entry);
153
155
156 if(!iter->urlmon)
157 IClassFactory_Release(iter->cf);
158 heap_free(iter->protocol);
159 heap_free(iter);
160 return S_OK;
161 }
162 }
163
165 return S_OK;
166}

Referenced by InternetSession_UnregisterNameSpace().

◆ UrlMkGetSessionOption()

HRESULT WINAPI UrlMkGetSessionOption ( DWORD  dwOption,
LPVOID  pBuffer,
DWORD  dwBufferLength,
DWORD pdwBufferLength,
DWORD  dwReserved 
)

Definition at line 622 of file session.c.

624{
625 TRACE("(%x, %p, %d, %p)\n", dwOption, pBuffer, dwBufferLength, pdwBufferLength);
626
627 if(dwReserved)
628 WARN("dwReserved = %d\n", dwReserved);
629
630 switch(dwOption) {
631 case URLMON_OPTION_USERAGENT: {
633 DWORD size;
634
635 if(!pdwBufferLength)
636 return E_INVALIDARG;
637
639
641 if(user_agent) {
643 *pdwBufferLength = size;
644 if(size <= dwBufferLength) {
645 if(pBuffer)
647 else
649 }
650 }
651
653
654 /* Tests prove that we have to return E_OUTOFMEMORY on success. */
655 return hres;
656 }
657 case URLMON_OPTION_URL_ENCODING: {
658 DWORD encoding = 0;
659
660 if(!pBuffer || dwBufferLength < sizeof(DWORD) || !pdwBufferLength)
661 return E_INVALIDARG;
662
665
666 *pdwBufferLength = sizeof(DWORD);
667 *(DWORD*)pBuffer = encoding ? URL_ENCODING_DISABLE_UTF8 : URL_ENCODING_ENABLE_UTF8;
668 return S_OK;
669 }
670 default:
671 FIXME("unsupported option %x\n", dwOption);
672 }
673
674 return E_INVALIDARG;
675}
static BOOL get_url_encoding(HKEY root, DWORD *encoding)
Definition: session.c:503
#define HKEY_CURRENT_USER
Definition: winreg.h:11

◆ UrlMkSetSessionOption()

HRESULT WINAPI UrlMkSetSessionOption ( DWORD  dwOption,
LPVOID  pBuffer,
DWORD  dwBufferLength,
DWORD  Reserved 
)

Definition at line 680 of file session.c.

682{
683 TRACE("(%x %p %x)\n", dwOption, pBuffer, dwBufferLength);
684
685 switch(dwOption) {
686 case URLMON_OPTION_USERAGENT: {
687 LPWSTR new_user_agent;
688 char *buf = pBuffer;
689 DWORD len, size;
690
691 if(!pBuffer || !dwBufferLength)
692 return E_INVALIDARG;
693
694 for(len=0; len<dwBufferLength && buf[len]; len++);
695
696 TRACE("Setting user agent %s\n", debugstr_an(buf, len));
697
699 new_user_agent = heap_alloc((size+1)*sizeof(WCHAR));
700 if(!new_user_agent)
701 return E_OUTOFMEMORY;
702 MultiByteToWideChar(CP_ACP, 0, buf, len, new_user_agent, size);
703 new_user_agent[size] = 0;
704
706
708 user_agent = new_user_agent;
710
712 break;
713 }
714 default:
715 FIXME("Unknown option %x\n", dwOption);
716 return E_INVALIDARG;
717 }
718
719 return S_OK;
720}
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define MultiByteToWideChar
Definition: compat.h:110
void update_user_agent(WCHAR *user_agent)
Definition: protocol.c:307

Referenced by test_user_agent().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( urlmon  )

Variable Documentation

◆ internet_settings_keyW

const WCHAR internet_settings_keyW[]
static
Initial value:
=
{'S','O','F','T','W','A','R','E',
'\\','M','i','c','r','o','s','o','f','t',
'\\','W','i','n','d','o','w','s',
'\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
'\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0}

Definition at line 55 of file session.c.

Referenced by get_url_encoding().

◆ InternetSession

IInternetSession InternetSession = { &InternetSessionVtbl }
static

Definition at line 467 of file session.c.

Referenced by CoInternetGetSession().

◆ InternetSessionVtbl

const IInternetSessionVtbl InternetSessionVtbl
static
Initial value:
= {
}
static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface, LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IInternetProtocol **ppOInetProt, DWORD dwOption)
Definition: session.c:427
static HRESULT WINAPI InternetSession_QueryInterface(IInternetSession *iface, REFIID riid, void **ppv)
Definition: session.c:320
static ULONG WINAPI InternetSession_AddRef(IInternetSession *iface)
Definition: session.c:335
static HRESULT WINAPI InternetSession_UnregisterMimeFilter(IInternetSession *iface, IClassFactory *pCF, LPCWSTR pwzType)
Definition: session.c:401
static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface, IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzType)
Definition: session.c:378
static HRESULT WINAPI InternetSession_SetSessionOption(IInternetSession *iface, DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD dwReserved)
Definition: session.c:448
static ULONG WINAPI InternetSession_Release(IInternetSession *iface)
Definition: session.c:342
static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface, IClassFactory *pCF, LPCWSTR pszProtocol)
Definition: session.c:367
static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface, IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns, const LPCWSTR *ppwzPatterns, DWORD dwReserved)
Definition: session.c:349

Definition at line 455 of file session.c.

◆ mime_filter_list

struct list mime_filter_list = LIST_INIT(mime_filter_list)
static

◆ name_space_list

struct list name_space_list = LIST_INIT(name_space_list)
static

Definition at line 43 of file session.c.

Referenced by find_name_space(), free_session(), register_namespace(), and unregister_namespace().

◆ session_cs

◆ session_cs_dbg

CRITICAL_SECTION_DEBUG session_cs_dbg
static
Initial value:
=
{
0, 0, &session_cs,
0, 0, { (DWORD_PTR)(__FILE__ ": session") }
}
static CRITICAL_SECTION_DEBUG session_cs_dbg
Definition: session.c:47
LIST_ENTRY ProcessLocksList
Definition: winbase.h:908
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 47 of file session.c.

◆ user_agent