ReactOS 0.4.17-dev-573-g8315b8c
urlmon_main.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "urlmon.h"
#include "wininet.h"
#include "wine/list.h"
Include dependency graph for urlmon_main.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Protocol
 
struct  ProtocolVtbl
 
struct  BindProtocol
 
struct  tls_data_t
 

Macros

#define COBJMACROS
 
#define FLAG_REQUEST_COMPLETE   0x0001
 
#define FLAG_FIRST_CONTINUE_COMPLETE   0x0002
 
#define FLAG_FIRST_DATA_REPORTED   0x0004
 
#define FLAG_ALL_DATA_READ   0x0008
 
#define FLAG_LAST_DATA_REPORTED   0x0010
 
#define FLAG_RESULT_REPORTED   0x0020
 
#define FLAG_ERROR   0x0040
 
#define FLAG_SYNC_READ   0x0080
 

Typedefs

typedef HRESULT(* stop_cache_binding_proc_t) (void *, const WCHAR *, HRESULT, const WCHAR *)
 
typedef struct ProtocolVtbl ProtocolVtbl
 
typedef struct _task_header_t task_header_t
 

Functions

HRESULT SecManagerImpl_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT ZoneMgrImpl_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT StdURLMoniker_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT FileProtocol_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT HttpProtocol_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT HttpSProtocol_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT FtpProtocol_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT GopherProtocol_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT MkProtocol_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT MimeFilter_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT Uri_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
BOOL WINAPI URLMON_DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
HRESULT WINAPI URLMON_DllGetClassObject (REFCLSID rclsid, REFIID iid, LPVOID *ppv)
 
HRESULT WINAPI URLMON_DllRegisterServer (void)
 
HRESULT WINAPI URLMON_DllUnregisterServer (void)
 
static void URLMON_LockModule (void)
 
static void URLMON_UnlockModule (void)
 
IInternetProtocolInfoget_protocol_info (LPCWSTR)
 
HRESULT get_protocol_handler (IUri *, CLSID *, IClassFactory **)
 
IInternetProtocolget_mime_filter (LPCWSTR)
 
BOOL is_registered_protocol (LPCWSTR)
 
HRESULT register_namespace (IClassFactory *, REFIID, LPCWSTR, BOOL)
 
HINTERNET get_internet_session (IInternetBindInfo *)
 
WCHARget_useragent (void)
 
void update_user_agent (WCHAR *)
 
void free_session (void)
 
HRESULT find_mime_from_ext (const WCHAR *, WCHAR **)
 
HRESULT bind_to_storage (IUri *, IBindCtx *, REFIID, void **)
 
HRESULT bind_to_object (IMoniker *, IUri *, IBindCtx *, REFIID, void **ppv)
 
HRESULT create_default_callback (IBindStatusCallback **)
 
HRESULT wrap_callback (IBindStatusCallback *, IBindStatusCallback **)
 
IBindStatusCallbackbsc_from_bctx (IBindCtx *)
 
HRESULT download_to_cache (IUri *, stop_cache_binding_proc_t, void *, IBindStatusCallback *)
 
HRESULT protocol_start (Protocol *, IInternetProtocol *, IUri *, IInternetProtocolSink *, IInternetBindInfo *)
 
HRESULT protocol_continue (Protocol *, PROTOCOLDATA *)
 
HRESULT protocol_read (Protocol *, void *, ULONG, ULONG *)
 
HRESULT protocol_lock_request (Protocol *)
 
HRESULT protocol_unlock_request (Protocol *)
 
HRESULT protocol_abort (Protocol *, HRESULT)
 
HRESULT protocol_syncbinding (Protocol *)
 
void protocol_close_connection (Protocol *)
 
void find_domain_name (const WCHAR *, DWORD, INT *)
 
HRESULT create_binding_protocol (BindProtocol **)
 
void set_binding_sink (BindProtocol *, IInternetProtocolSink *, IInternetBindInfo *)
 
tls_data_tget_tls_data (void)
 
void unregister_notif_wnd_class (void)
 
HWND get_notif_hwnd (void)
 
void release_notif_hwnd (HWND)
 
const chardebugstr_bindstatus (ULONG)
 
static WCHARstrndupW (LPCWSTR str, int len)
 
static WCHARstrdupAtoW (const char *str)
 

Variables

HINSTANCE hProxyDll
 
GUID const CLSID_PSFactoryBuffer
 
GUID const CLSID_CUri
 
LONG URLMON_refCount
 
HINSTANCE urlmon_instance
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file urlmon_main.h.

◆ FLAG_ALL_DATA_READ

#define FLAG_ALL_DATA_READ   0x0008

Definition at line 151 of file urlmon_main.h.

◆ FLAG_ERROR

#define FLAG_ERROR   0x0040

Definition at line 154 of file urlmon_main.h.

◆ FLAG_FIRST_CONTINUE_COMPLETE

#define FLAG_FIRST_CONTINUE_COMPLETE   0x0002

Definition at line 149 of file urlmon_main.h.

◆ FLAG_FIRST_DATA_REPORTED

#define FLAG_FIRST_DATA_REPORTED   0x0004

Definition at line 150 of file urlmon_main.h.

◆ FLAG_LAST_DATA_REPORTED

#define FLAG_LAST_DATA_REPORTED   0x0010

Definition at line 152 of file urlmon_main.h.

◆ FLAG_REQUEST_COMPLETE

#define FLAG_REQUEST_COMPLETE   0x0001

Definition at line 148 of file urlmon_main.h.

◆ FLAG_RESULT_REPORTED

#define FLAG_RESULT_REPORTED   0x0020

Definition at line 153 of file urlmon_main.h.

◆ FLAG_SYNC_READ

#define FLAG_SYNC_READ   0x0080

Definition at line 155 of file urlmon_main.h.

Typedef Documentation

◆ ProtocolVtbl

Definition at line 91 of file urlmon_main.h.

◆ stop_cache_binding_proc_t

typedef HRESULT(* stop_cache_binding_proc_t) (void *, const WCHAR *, HRESULT, const WCHAR *)

Definition at line 88 of file urlmon_main.h.

◆ task_header_t

Definition at line 168 of file urlmon_main.h.

Function Documentation

◆ bind_to_object()

HRESULT bind_to_object ( IMoniker mon,
IUri uri,
IBindCtx pbc,
REFIID  riid,
void **  ppv 
)

Definition at line 1640 of file binding.c.

1641{
1643 HRESULT hres;
1644
1645 *ppv = NULL;
1646
1647 hres = start_binding(mon, NULL, uri, pbc, TRUE, riid, &binding);
1648 if(FAILED(hres))
1649 return hres;
1650
1651 if(binding->hres != S_OK) {
1652 hres = SUCCEEDED(binding->hres) ? S_OK : binding->hres;
1653 }else if(binding->bindf & BINDF_ASYNCHRONOUS) {
1654 hres = MK_S_ASYNCHRONOUS;
1655 }else {
1656 *ppv = binding->obj;
1657 IUnknown_AddRef(binding->obj);
1658 hres = S_OK;
1659 }
1660
1661 IBinding_Release(&binding->IBinding_iface);
1662
1663 return hres;
1664}
static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, IUri *uri, IBindCtx *pbc, BOOL to_obj, REFIID riid, Binding **ret)
Definition: binding.c:1554
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
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
HRESULT hres
Definition: protocol.c:465
static RPC_BINDING_HANDLE binding
Definition: server.c:166
const WCHAR * uri
Definition: sec_mgr.c:1564

◆ bind_to_storage()

HRESULT bind_to_storage ( IUri uri,
IBindCtx pbc,
REFIID  riid,
void **  ppv 
)

Definition at line 1611 of file binding.c.

1612{
1613 Binding *binding = NULL, *binding_ctx;
1614 HRESULT hres;
1615
1616 binding_ctx = get_bctx_binding(pbc);
1617
1618 hres = start_binding(NULL, binding_ctx, uri, pbc, FALSE, riid, &binding);
1619 if(binding_ctx)
1620 IBinding_Release(&binding_ctx->IBinding_iface);
1621 if(FAILED(hres))
1622 return hres;
1623
1624 if(binding->hres == S_OK && binding->download_state != BEFORE_DOWNLOAD /* FIXME */) {
1625 if((binding->state & BINDING_STOPPED) && (binding->state & BINDING_LOCKED))
1626 IInternetProtocolEx_UnlockRequest(&binding->protocol->IInternetProtocolEx_iface);
1627
1628 hres = binding->stgmed_obj->vtbl->get_result(binding->stgmed_obj, binding->bindf, ppv);
1629 }else if(binding->bindf & BINDF_ASYNCHRONOUS) {
1630 hres = MK_S_ASYNCHRONOUS;
1631 }else {
1632 hres = FAILED(binding->hres) ? binding->hres : S_OK;
1633 }
1634
1635 IBinding_Release(&binding->IBinding_iface);
1636
1637 return hres;
1638}
#define BINDING_STOPPED
Definition: binding.c:62
@ BEFORE_DOWNLOAD
Definition: binding.c:56
static Binding * get_bctx_binding(IBindCtx *bctx)
Definition: binding.c:961
#define BINDING_LOCKED
Definition: binding.c:61
#define FALSE
Definition: types.h:117

Referenced by URLMoniker_BindToStorage().

◆ bsc_from_bctx()

IBindStatusCallback * bsc_from_bctx ( IBindCtx bctx)

Definition at line 70 of file bindctx.c.

71{
72 BindStatusCallback *holder;
75
76 bsc = bsch_from_bctx(bctx);
77 if(!bsc)
78 return NULL;
79
80 hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder);
81 if(FAILED(hres))
82 return bsc;
83
84 if(holder->callback) {
85 IBindStatusCallback_Release(bsc);
86 bsc = holder->callback;
87 IBindStatusCallback_AddRef(bsc);
88 }
89
90 IBindStatusCallbackEx_Release(&holder->IBindStatusCallbackEx_iface);
91 return bsc;
92}
IBindStatusCallback * callback
Definition: bindctx.c:39
IBindStatusCallbackEx IBindStatusCallbackEx_iface
Definition: bindctx.c:31
Definition: xmldoc.c:231
static IBindStatusCallback * bsch_from_bctx(IBindCtx *bctx)
Definition: bindctx.c:55
IID IID_IBindStatusCallbackHolder

Referenced by AsyncInstallDistributionUnit(), and RevokeBindStatusCallback().

◆ create_binding_protocol()

HRESULT create_binding_protocol ( BindProtocol **  protocol)

Definition at line 1453 of file bindprot.c.

1454{
1455 BindProtocol *ret = calloc(1, sizeof(BindProtocol));
1456
1457 ret->IInternetProtocolEx_iface.lpVtbl = &BindProtocolVtbl;
1458 ret->IInternetBindInfo_iface.lpVtbl = &InternetBindInfoVtbl;
1459 ret->IInternetPriority_iface.lpVtbl = &InternetPriorityVtbl;
1460 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1461 ret->IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkVtbl;
1462
1463 ret->default_protocol_handler.IInternetProtocol_iface.lpVtbl = &InternetProtocolHandlerVtbl;
1464 ret->default_protocol_handler.IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkHandlerVtbl;
1465
1466 ret->ref = 1;
1467 ret->apartment_thread = GetCurrentThreadId();
1468 ret->notif_hwnd = get_notif_hwnd();
1469 ret->protocol_handler = &ret->default_protocol_handler.IInternetProtocol_iface;
1470 ret->protocol_sink_handler = &ret->default_protocol_handler.IInternetProtocolSink_iface;
1472 ret->section.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BindProtocol.section");
1473
1475
1476 *protocol = ret;
1477 return S_OK;
1478}
static const IInternetProtocolVtbl InternetProtocolHandlerVtbl
Definition: bindprot.c:823
static const IInternetBindInfoVtbl InternetBindInfoVtbl
Definition: bindprot.c:1131
static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl
Definition: bindprot.c:1399
static const IInternetProtocolExVtbl BindProtocolVtbl
Definition: bindprot.c:584
HWND get_notif_hwnd(void)
Definition: bindprot.c:107
static const IInternetPriorityVtbl InternetPriorityVtbl
Definition: bindprot.c:1183
static const IServiceProviderVtbl ServiceProviderVtbl
Definition: bindprot.c:1446
static const IInternetProtocolSinkVtbl InternetProtocolSinkHandlerVtbl
Definition: bindprot.c:1058
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
return ret
Definition: mutex.c:146
#define calloc
Definition: rosglue.h:14
#define DWORD_PTR
Definition: treelist.c:76
static void URLMON_LockModule(void)
Definition: urlmon_main.h:64
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1156

Referenced by Binding_Create(), and InternetSession_CreateBinding().

◆ create_default_callback()

HRESULT create_default_callback ( IBindStatusCallback **  ret)

Definition at line 361 of file download.c.

362{
365
367 if(FAILED(hres))
368 return hres;
369
370 hres = wrap_callback(&callback->IBindStatusCallback_iface, ret);
371 IBindStatusCallback_Release(&callback->IBindStatusCallback_iface);
372 return hres;
373}
static IPrintDialogCallback callback
Definition: printdlg.c:326
HRESULT wrap_callback(IBindStatusCallback *bsc, IBindStatusCallback **ret_iface)
Definition: bindctx.c:578
static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_name, DownloadBSC **ret_callback)
Definition: download.c:333

Referenced by get_callback().

◆ debugstr_bindstatus()

const char * debugstr_bindstatus ( ULONG  status)

Definition at line 173 of file urlmon_main.c.

174{
175 switch(status) {
176#define X(x) case x: return #x
177 X(BINDSTATUS_FINDINGRESOURCE);
178 X(BINDSTATUS_CONNECTING);
179 X(BINDSTATUS_REDIRECTING);
180 X(BINDSTATUS_BEGINDOWNLOADDATA);
181 X(BINDSTATUS_DOWNLOADINGDATA);
182 X(BINDSTATUS_ENDDOWNLOADDATA);
183 X(BINDSTATUS_BEGINDOWNLOADCOMPONENTS);
184 X(BINDSTATUS_INSTALLINGCOMPONENTS);
185 X(BINDSTATUS_ENDDOWNLOADCOMPONENTS);
186 X(BINDSTATUS_USINGCACHEDCOPY);
187 X(BINDSTATUS_SENDINGREQUEST);
188 X(BINDSTATUS_CLASSIDAVAILABLE);
189 X(BINDSTATUS_MIMETYPEAVAILABLE);
190 X(BINDSTATUS_CACHEFILENAMEAVAILABLE);
191 X(BINDSTATUS_BEGINSYNCOPERATION);
192 X(BINDSTATUS_ENDSYNCOPERATION);
193 X(BINDSTATUS_BEGINUPLOADDATA);
194 X(BINDSTATUS_UPLOADINGDATA);
195 X(BINDSTATUS_ENDUPLOADINGDATA);
196 X(BINDSTATUS_PROTOCOLCLASSID);
197 X(BINDSTATUS_ENCODING);
198 X(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE);
199 X(BINDSTATUS_CLASSINSTALLLOCATION);
200 X(BINDSTATUS_DECODING);
201 X(BINDSTATUS_LOADINGMIMEHANDLER);
202 X(BINDSTATUS_CONTENTDISPOSITIONATTACH);
203 X(BINDSTATUS_FILTERREPORTMIMETYPE);
204 X(BINDSTATUS_CLSIDCANINSTANTIATE);
205 X(BINDSTATUS_IUNKNOWNAVAILABLE);
206 X(BINDSTATUS_DIRECTBIND);
207 X(BINDSTATUS_RAWMIMETYPE);
208 X(BINDSTATUS_PROXYDETECTING);
209 X(BINDSTATUS_ACCEPTRANGES);
210 X(BINDSTATUS_COOKIE_SENT);
211 X(BINDSTATUS_COMPACT_POLICY_RECEIVED);
212 X(BINDSTATUS_COOKIE_SUPPRESSED);
213 X(BINDSTATUS_COOKIE_STATE_UNKNOWN);
214 X(BINDSTATUS_COOKIE_STATE_ACCEPT);
215 X(BINDSTATUS_COOKIE_STATE_REJECT);
216 X(BINDSTATUS_COOKIE_STATE_PROMPT);
217 X(BINDSTATUS_COOKIE_STATE_LEASH);
218 X(BINDSTATUS_COOKIE_STATE_DOWNGRADE);
219 X(BINDSTATUS_POLICY_HREF);
220 X(BINDSTATUS_P3P_HEADER);
221 X(BINDSTATUS_SESSION_COOKIE_RECEIVED);
222 X(BINDSTATUS_PERSISTENT_COOKIE_RECEIVED);
223 X(BINDSTATUS_SESSION_COOKIES_ALLOWED);
224 X(BINDSTATUS_CACHECONTROL);
225 X(BINDSTATUS_CONTENTDISPOSITIONFILENAME);
226 X(BINDSTATUS_MIMETEXTPLAINMISMATCH);
227 X(BINDSTATUS_PUBLISHERAVAILABLE);
228 X(BINDSTATUS_DISPLAYNAMEAVAILABLE);
229#undef X
230 default:
231 return wine_dbg_sprintf("(invalid status %lu)", status);
232 }
233}
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
Definition: ps.c:97
#define X(x)

Referenced by BindStatusCallback_OnProgress(), InternetProtocolSink_ReportProgress(), and ProtocolSinkHandler_ReportProgress().

◆ download_to_cache()

HRESULT download_to_cache ( IUri uri,
stop_cache_binding_proc_t  proc,
void ctx,
IBindStatusCallback callback 
)

Definition at line 375 of file download.c.

376{
377 DownloadBSC *dwl_bsc;
378 IBindCtx *bindctx;
379 IMoniker *mon;
380 IUnknown *unk;
382
383 hres = DownloadBSC_Create(callback, NULL, &dwl_bsc);
384 if(FAILED(hres))
385 return hres;
386
387 dwl_bsc->onstop_proc = proc;
388 dwl_bsc->ctx = ctx;
389 dwl_bsc->bindf = BINDF_ASYNCHRONOUS;
390
391 hres = CreateAsyncBindCtx(0, &dwl_bsc->IBindStatusCallback_iface, NULL, &bindctx);
392 IBindStatusCallback_Release(&dwl_bsc->IBindStatusCallback_iface);
393 if(FAILED(hres))
394 return hres;
395
396 hres = CreateURLMonikerEx2(NULL, uri, &mon, 0);
397 if(FAILED(hres)) {
398 IBindCtx_Release(bindctx);
399 return hres;
400 }
401
402 hres = IMoniker_BindToStorage(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk);
403 IMoniker_Release(mon);
404 IBindCtx_Release(bindctx);
405 if(SUCCEEDED(hres) && unk)
406 IUnknown_Release(unk);
407 return hres;
408
409}
const GUID IID_IUnknown
static HANDLE proc()
Definition: pdb.c:32
IBindStatusCallback IBindStatusCallback_iface
Definition: download.c:25
stop_cache_binding_proc_t onstop_proc
Definition: download.c:36
DWORD bindf
Definition: download.c:34
void * ctx
Definition: download.c:37
HRESULT WINAPI CreateURLMonikerEx2(IMoniker *pmkContext, IUri *pUri, IMoniker **ppmk, DWORD dwFlags)
Definition: umon.c:683
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx **pbind)
Definition: bindctx.c:899

Referenced by AsyncInstallDistributionUnit().

◆ FileProtocol_Construct()

HRESULT FileProtocol_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

Definition at line 420 of file file.c.

421{
423
424 TRACE("(%p %p)\n", outer, ppobj);
425
427
428 ret = malloc(sizeof(FileProtocol));
429
430 ret->IUnknown_inner.lpVtbl = &FileProtocolUnkVtbl;
431 ret->IInternetProtocolEx_iface.lpVtbl = &FileProtocolExVtbl;
432 ret->IInternetPriority_iface.lpVtbl = &FilePriorityVtbl;
434 ret->priority = 0;
435 ret->ref = 1;
436 ret->outer = outer ? outer : &ret->IUnknown_inner;
437
438 *ppobj = &ret->IUnknown_inner;
439 return S_OK;
440}
#define malloc
Definition: debug_ros.c:4
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static const IUnknownVtbl FileProtocolUnkVtbl
Definition: file.c:113
static const IInternetPriorityVtbl FilePriorityVtbl
Definition: file.c:412
static const IInternetProtocolExVtbl FileProtocolExVtbl
Definition: file.c:356
static IUnknown * outer
Definition: compobj.c:82
#define TRACE(s)
Definition: solgame.cpp:4

◆ find_domain_name()

void find_domain_name ( const WCHAR host,
DWORD  host_len,
INT domain_start 
)

Definition at line 477 of file uri.c.

478 {
479 const WCHAR *last_tld, *sec_last_tld, *end, *p;
480
481 end = host+host_len-1;
482
483 *domain_start = -1;
484
485 /* There has to be at least enough room for a '.' followed by a
486 * 3-character TLD for a domain to even exist in the host name.
487 */
488 if(host_len < 4)
489 return;
490
491 for (last_tld = sec_last_tld = NULL, p = host; p <= end; p++)
492 {
493 if (*p == '.')
494 {
495 sec_last_tld = last_tld;
496 last_tld = p;
497 }
498 }
499 if(!last_tld)
500 /* http://hostname -> has no domain name. */
501 return;
502
503 if(!sec_last_tld) {
504 /* If the '.' is at the beginning of the host there
505 * has to be at least 3 characters in the TLD for it
506 * to be valid.
507 * Ex: .com -> .com as the domain name.
508 * .co -> has no domain name.
509 */
510 if(last_tld-host == 0) {
511 if(end-(last_tld-1) < 3)
512 return;
513 } else if(last_tld-host == 3) {
514 DWORD i;
515
516 /* If there are three characters in front of last_tld and
517 * they are on the list of recognized TLDs, then this
518 * host doesn't have a domain (since the host only contains
519 * a TLD name.
520 * Ex: edu.uk -> has no domain name.
521 * foo.uk -> foo.uk as the domain name.
522 */
523 for(i = 0; i < ARRAY_SIZE(recognized_tlds); ++i) {
525 return;
526 }
527 } else if(last_tld-host < 3)
528 {
529 /* Anything less than 3 ASCII characters is considered part
530 * of the TLD name.
531 * Ex: ak.uk -> Has no domain name.
532 */
533 for(p = host; p < last_tld; p++) {
534 if(!is_ascii(*p))
535 break;
536 }
537
538 if(p == last_tld)
539 return;
540 }
541
542 /* Otherwise the domain name is the whole host name. */
543 *domain_start = 0;
544 } else if(end+1-last_tld > 3) {
545 /* If the last_tld has more than 3 characters, then it's automatically
546 * considered the TLD of the domain name.
547 * Ex: www.winehq.org.uk.test -> uk.test as the domain name.
548 */
549 *domain_start = (sec_last_tld+1)-host;
550 } else if(last_tld - (sec_last_tld+1) < 4) {
551 DWORD i;
552 /* If the sec_last_tld is 3 characters long it HAS to be on the list of
553 * recognized to still be considered part of the TLD name, otherwise
554 * it's considered the domain name.
555 * Ex: www.google.com.uk -> google.com.uk as the domain name.
556 * www.google.foo.uk -> foo.uk as the domain name.
557 */
558 if(last_tld - (sec_last_tld+1) == 3) {
559 for(i = 0; i < ARRAY_SIZE(recognized_tlds); ++i) {
560 if(!StrCmpNIW(sec_last_tld+1, recognized_tlds[i].tld_name, 3)) {
561 for (p = sec_last_tld; p > host; p--) if (p[-1] == '.') break;
562 *domain_start = p - host;
563 TRACE("Found domain name %s\n", debugstr_wn(host+*domain_start,
564 (host+host_len)-(host+*domain_start)));
565 return;
566 }
567 }
568
569 *domain_start = (sec_last_tld+1)-host;
570 } else {
571 /* Since the sec_last_tld is less than 3 characters it's considered
572 * part of the TLD.
573 * Ex: www.google.fo.uk -> google.fo.uk as the domain name.
574 */
575 for (p = sec_last_tld; p > host; p--) if (p[-1] == '.') break;
576 *domain_start = p - host;
577 }
578 } else {
579 /* The second to last TLD has more than 3 characters making it
580 * the domain name.
581 * Ex: www.google.test.us -> test.us as the domain name.
582 */
583 *domain_start = (sec_last_tld+1)-host;
584 }
585
586 TRACE("Found domain name %s\n", debugstr_wn(host+*domain_start,
587 (host+host_len)-(host+*domain_start)));
588}
#define ARRAY_SIZE(A)
Definition: main.h:20
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:307
WCHAR tld_name[4]
Definition: uri.c:225
static const struct @614 recognized_tlds[]
static BOOL is_ascii(WCHAR c)
Definition: uri.c:343
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
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 debugstr_wn
Definition: kernel32.h:33
short WCHAR
Definition: pedump.c:58
Definition: txthost.c:37

Referenced by canonicalize_reg_name(), and search_domain_for_zone().

◆ find_mime_from_ext()

HRESULT find_mime_from_ext ( const WCHAR ext,
WCHAR **  ret 
)

Definition at line 425 of file mimefilter.c.

426{
427 DWORD res, size;
428 WCHAR mime[64];
429 HKEY hkey;
430
432 if(res != ERROR_SUCCESS)
433 return HRESULT_FROM_WIN32(res);
434
435 size = sizeof(mime);
436 res = RegQueryValueExW(hkey, L"Content Type", NULL, NULL, (BYTE*)mime, &size);
437 RegCloseKey(hkey);
438 if(res != ERROR_SUCCESS)
439 return HRESULT_FROM_WIN32(res);
440
441 TRACE("found MIME %s\n", debugstr_w(mime));
442
444 memcpy(*ret, mime, size);
445 return S_OK;
446}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
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
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
static const WCHAR *const ext[]
Definition: module.c:53
#define L(x)
Definition: resources.c:13
GLuint res
Definition: glext.h:9613
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * mime
Definition: mimefilter.c:487
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
unsigned char BYTE
Definition: xxhash.c:193

Referenced by FileProtocol_StartEx(), and find_mime_from_url().

◆ free_session()

void free_session ( void  )

Definition at line 795 of file session.c.

796{
797 name_space *ns_iter, *ns_last;
798 mime_filter *mf_iter, *mf_last;
799
801 if(!ns_iter->urlmon)
802 IClassFactory_Release(ns_iter->cf);
803 free(ns_iter->protocol);
804 free(ns_iter);
805 }
806
808 IClassFactory_Release(mf_iter->cf);
809 free(mf_iter->mime);
810 free(mf_iter);
811 }
812
814}
#define free
Definition: debug_ros.c:5
static struct list name_space_list
Definition: session.c:43
static struct list mime_filter_list
Definition: session.c:44
static LPWSTR user_agent
Definition: session.c:506
uint32_t entry
Definition: isohybrid.c:63
#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
LPWSTR protocol
Definition: session.c:27
IClassFactory * cf
Definition: session.c:28

Referenced by process_detach().

◆ FtpProtocol_Construct()

HRESULT FtpProtocol_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

◆ get_internet_session()

HINTERNET get_internet_session ( IInternetBindInfo bind_info)

Definition at line 290 of file protocol.c.

291{
292 HINTERNET new_session;
293
295 return internet_session;
296
297 if(!bind_info)
298 return NULL;
299
300 new_session = create_internet_session(bind_info);
301 if(new_session && InterlockedCompareExchangePointer((void**)&internet_session, new_session, NULL))
302 InternetCloseHandle(new_session);
303
304 return internet_session;
305}
static HINTERNET create_internet_session(IInternetBindInfo *bind_info)
Definition: protocol.c:264
static HINTERNET internet_session
Definition: protocol.c:288
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
static IInternetBindInfo bind_info
Definition: mimeole.c:1246

Referenced by process_detach(), and protocol_start().

◆ get_mime_filter()

IInternetProtocol * get_mime_filter ( LPCWSTR  mime)

Definition at line 242 of file session.c.

243{
246 mime_filter *iter;
247 HKEY hlist, hfilter;
248 WCHAR clsidw[64];
249 CLSID clsid;
250 DWORD res, type, size;
252
254
256 if(!wcscmp(iter->mime, mime)) {
257 cf = iter->cf;
258 break;
259 }
260 }
261
263
264 if(cf) {
265 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&ret);
266 if(FAILED(hres)) {
267 WARN("CreateInstance failed: %08lx\n", hres);
268 return NULL;
269 }
270
271 return ret;
272 }
273
274 res = RegOpenKeyW(HKEY_CLASSES_ROOT, L"Protocols\\Filter", &hlist);
275 if(res != ERROR_SUCCESS) {
276 TRACE("Could not open MIME filters key\n");
277 return NULL;
278 }
279
280 res = RegOpenKeyW(hlist, mime, &hfilter);
281 CloseHandle(hlist);
282 if(res != ERROR_SUCCESS)
283 return NULL;
284
285 size = sizeof(clsidw);
286 res = RegQueryValueExW(hfilter, L"CLSID", NULL, &type, (BYTE*)clsidw, &size);
287 CloseHandle(hfilter);
288 if(res!=ERROR_SUCCESS || type!=REG_SZ) {
289 WARN("Could not get filter CLSID for %s\n", debugstr_w(mime));
290 return NULL;
291 }
292
293 hres = CLSIDFromString(clsidw, &clsid);
294 if(FAILED(hres)) {
295 WARN("CLSIDFromString failed for %s (%lx)\n", debugstr_w(mime), hres);
296 return NULL;
297 }
298
299 hres = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&ret);
300 if(FAILED(hres)) {
301 WARN("CoCreateInstance failed: %08lx\n", hres);
302 return NULL;
303 }
304
305 return ret;
306}
#define WARN(fmt,...)
Definition: precomp.h:61
HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
Definition: combase.c:1470
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define CloseHandle
Definition: compat.h:739
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
static CRITICAL_SECTION session_cs
Definition: session.c:46
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_SZ
Definition: layer.c:22
const CLSID * clsid
Definition: msctf.cpp:50
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by mime_available().

◆ get_notif_hwnd()

HWND get_notif_hwnd ( void  )

Definition at line 107 of file bindprot.c.

108{
109 tls_data_t *tls_data;
110
111 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
112
113 tls_data = get_tls_data();
114 if(!tls_data)
115 return NULL;
116
117 if(tls_data->notif_hwnd_cnt) {
118 tls_data->notif_hwnd_cnt++;
119 return tls_data->notif_hwnd;
120 }
121
123 if(!notif_wnd_class)
124 return NULL;
125
127 L"URL Moniker Notification Window", 0, 0, 0, 0, 0, HWND_MESSAGE,
129 if(tls_data->notif_hwnd)
130 tls_data->notif_hwnd_cnt++;
131
132 TRACE("hwnd = %p\n", tls_data->notif_hwnd);
133
134 return tls_data->notif_hwnd;
135}
static BOOL WINAPI register_notif_wnd_class(INIT_ONCE *once, void *param, void **context)
Definition: bindprot.c:88
static ATOM notif_wnd_class
Definition: bindprot.c:86
HINSTANCE hProxyDll
Definition: combase.c:40
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
Definition: InitOnce.c:12
HWND notif_hwnd
Definition: urlmon_main.h:222
DWORD notif_hwnd_cnt
Definition: urlmon_main.h:223
tls_data_t * get_tls_data(void)
Definition: urlmon_main.c:60
RTL_RUN_ONCE INIT_ONCE
Definition: winbase.h:3652
#define INIT_ONCE_STATIC_INIT
Definition: winbase.h:591
#define HWND_MESSAGE
Definition: winuser.h:1221
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by Binding_Create(), and create_binding_protocol().

◆ get_protocol_handler()

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

Definition at line 212 of file session.c.

213{
214 name_space *ns;
215 BSTR scheme;
217
218 *ret = NULL;
219
220 /* FIXME: Avoid GetSchemeName call for known schemes */
221 hres = IUri_GetSchemeName(uri, &scheme);
222 if(FAILED(hres))
223 return hres;
224
226
228 if(ns) {
229 *ret = ns->cf;
230 IClassFactory_AddRef(*ret);
231 if(clsid)
232 *clsid = ns->clsid;
233 }
234
236
239 return hres;
240}
OLECHAR * BSTR
Definition: compat.h:2293
static name_space * find_name_space(LPCWSTR protocol)
Definition: session.c:55
static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, IClassFactory **ret)
Definition: session.c:67
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:198
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
DWORD scheme
Definition: mxnamespace.c:38

Referenced by BindProtocol_StartEx().

◆ get_protocol_info()

IInternetProtocolInfo * get_protocol_info ( LPCWSTR  url)

Definition at line 173 of file session.c.

174{
177 name_space *ns;
178 WCHAR schema[64];
179 DWORD schema_len;
181
182 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, ARRAY_SIZE(schema), &schema_len, 0);
183 if(FAILED(hres) || !schema_len)
184 return NULL;
185
187
189 if(ns && !ns->urlmon) {
190 hres = IClassFactory_QueryInterface(ns->cf, &IID_IInternetProtocolInfo, (void**)&ret);
191 if(FAILED(hres))
192 hres = IClassFactory_CreateInstance(ns->cf, NULL, &IID_IInternetProtocolInfo, (void**)&ret);
193 }
194
196
197 if(ns && SUCCEEDED(hres))
198 return ret;
199
200 hres = get_protocol_cf(schema, schema_len, NULL, &cf);
201 if(FAILED(hres))
202 return NULL;
203
204 hres = IClassFactory_QueryInterface(cf, &IID_IInternetProtocolInfo, (void**)&ret);
205 if(FAILED(hres))
206 IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocolInfo, (void**)&ret);
207 IClassFactory_Release(cf);
208
209 return ret;
210}
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags, LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: internet.c:325
const WCHAR * schema
static const WCHAR url[]
Definition: encode.c:1384

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_tls_data()

tls_data_t * get_tls_data ( void  )

Definition at line 60 of file urlmon_main.c.

61{
63
65 DWORD tls = TlsAlloc();
67 return NULL;
68
70 if(tls != urlmon_tls)
71 TlsFree(tls);
72 }
73
75 if(!data) {
76 data = calloc(1, sizeof(tls_data_t));
77 if(!data)
78 return NULL;
79
81 list_add_tail(&tls_list, &data->entry);
83
85 }
86
87 return data;
88}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
DWORD WINAPI DECLSPEC_HOTPATCH TlsAlloc(void)
Definition: thread.c:657
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define InterlockedCompareExchange
Definition: interlocked.h:119
long LONG
Definition: pedump.c:60
static DWORD tls
Definition: sock.c:229
static struct list tls_list
Definition: urlmon_main.c:48
static DWORD urlmon_tls
Definition: urlmon_main.c:44
static CRITICAL_SECTION tls_cs
Definition: urlmon_main.c:50
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:529

Referenced by get_notif_hwnd(), notif_wnd_proc(), and release_notif_hwnd().

◆ get_useragent()

WCHAR * get_useragent ( void  )

Definition at line 618 of file session.c.

619{
620 LPWSTR ret;
621
623
627
628 return ret;
629}
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
static void ensure_user_agent(void)
Definition: session.c:605
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by create_internet_session().

◆ GopherProtocol_Construct()

HRESULT GopherProtocol_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

Definition at line 312 of file gopher.c.

313{
315
316 TRACE("(%p %p)\n", pUnkOuter, ppobj);
317
319
320 ret = calloc(1, sizeof(GopherProtocol));
321
322 ret->base.vtbl = &AsyncProtocolVtbl;
323 ret->IInternetProtocol_iface.lpVtbl = &GopherProtocolVtbl;
324 ret->IInternetPriority_iface.lpVtbl = &GopherPriorityVtbl;
325 ret->ref = 1;
326
327 *ppobj = &ret->IInternetProtocol_iface;
328
329 return S_OK;
330}
static const IInternetProtocolVtbl GopherProtocolVtbl
Definition: gopher.c:245
static const IInternetPriorityVtbl GopherPriorityVtbl
Definition: gopher.c:304
static const ProtocolVtbl AsyncProtocolVtbl
Definition: gopher.c:79

◆ HttpProtocol_Construct()

HRESULT HttpProtocol_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

◆ HttpSProtocol_Construct()

HRESULT HttpSProtocol_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

◆ is_registered_protocol()

BOOL is_registered_protocol ( LPCWSTR  url)

Definition at line 160 of file session.c.

161{
162 DWORD schema_len;
163 WCHAR schema[64];
165
166 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, ARRAY_SIZE(schema), &schema_len, 0);
167 if(FAILED(hres))
168 return FALSE;
169
170 return get_protocol_cf(schema, schema_len, NULL, NULL) == S_OK;
171}

Referenced by MkParseDisplayNameEx().

◆ MimeFilter_Construct()

HRESULT MimeFilter_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

Definition at line 246 of file mimefilter.c.

247{
249
250 TRACE("(%p %p)\n", pUnkOuter, ppobj);
251
253
254 ret = calloc(1, sizeof(MimeFilter));
255
256 ret->IInternetProtocol_iface.lpVtbl = &MimeFilterProtocolVtbl;
257 ret->IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkVtbl;
258 ret->ref = 1;
259
260 *ppobj = &ret->IInternetProtocol_iface;
261 return S_OK;
262}
static const IInternetProtocolVtbl MimeFilterProtocolVtbl
Definition: mimefilter.c:164
static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl
Definition: mimefilter.c:236

◆ MkProtocol_Construct()

HRESULT MkProtocol_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

◆ protocol_abort()

HRESULT protocol_abort ( Protocol protocol,
HRESULT  reason 
)

Definition at line 518 of file protocol.c.

519{
520 if(!protocol->protocol_sink)
521 return S_OK;
522
523 /* NOTE: IE10 returns S_OK here */
524 if(protocol->flags & FLAG_RESULT_REPORTED)
525 return INET_E_RESULT_DISPATCHED;
526
528 return S_OK;
529}
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1971
static HRESULT report_result(Protocol *protocol, HRESULT hres)
Definition: protocol.c:31
#define FLAG_RESULT_REPORTED
Definition: urlmon_main.h:153

Referenced by FtpProtocol_Abort(), GopherProtocol_Abort(), HttpProtocol_Abort(), and HttpProtocol_on_error().

◆ protocol_close_connection()

void protocol_close_connection ( Protocol protocol)

Definition at line 531 of file protocol.c.

532{
533 protocol->vtbl->close_connection(protocol);
534
535 if(protocol->request)
537
538 if(protocol->connection)
539 InternetCloseHandle(protocol->connection);
540
541 if(protocol->post_stream) {
542 IStream_Release(protocol->post_stream);
543 protocol->post_stream = NULL;
544 }
545
546 protocol->flags = 0;
547}

Referenced by FtpProtocol_Terminate(), FtpProtocolUnk_Release(), GopherProtocol_Terminate(), HttpProtocol_on_error(), HttpProtocol_Terminate(), HttpProtocolUnk_Release(), protocol_start(), and start_downloading().

◆ protocol_continue()

HRESULT protocol_continue ( Protocol protocol,
PROTOCOLDATA *  data 
)

Definition at line 355 of file protocol.c.

356{
357 BOOL is_start;
359
360 is_start = !data || data->pData == UlongToPtr(BINDSTATUS_DOWNLOADINGDATA);
361
362 if(!protocol->request) {
363 WARN("Expected request to be non-NULL\n");
364 return S_OK;
365 }
366
367 if(!protocol->protocol_sink) {
368 WARN("Expected IInternetProtocolSink pointer to be non-NULL\n");
369 return S_OK;
370 }
371
372 if(protocol->flags & FLAG_ERROR) {
373 protocol->flags &= ~FLAG_ERROR;
374 protocol->vtbl->on_error(protocol, PtrToUlong(data->pData));
375 return S_OK;
376 }
377
378 if(protocol->post_stream)
380
381 if(is_start) {
383 if(FAILED(hres))
384 return S_OK;
385 }
386
387 if(!data || data->pData >= UlongToPtr(BINDSTATUS_DOWNLOADINGDATA)) {
388 if(!protocol->available_bytes) {
389 if(protocol->query_available) {
390 protocol->available_bytes = protocol->query_available;
391 }else {
392 BOOL res;
393
394 /* InternetQueryDataAvailable may immediately fork and perform its asynchronous
395 * read, so clear the flag _before_ calling so it does not incorrectly get cleared
396 * after the status callback is called */
397 protocol->flags &= ~FLAG_REQUEST_COMPLETE;
398 res = InternetQueryDataAvailable(protocol->request, &protocol->query_available, 0, 0);
399 if(res) {
400 TRACE("available %lu bytes\n", protocol->query_available);
401 if(!protocol->query_available) {
403 return S_OK;
404 }
405 protocol->available_bytes = protocol->query_available;
406 }else if(GetLastError() != ERROR_IO_PENDING) {
408 WARN("InternetQueryDataAvailable failed: %ld\n", GetLastError());
410 return S_OK;
411 }
412 }
413
415 }
416
418 }
419
420 return S_OK;
421}
#define ERROR_IO_PENDING
Definition: dderror.h:15
static void report_data(Protocol *protocol)
Definition: protocol.c:41
static void all_data_read(Protocol *protocol)
Definition: protocol.c:65
static HRESULT write_post_stream(Protocol *protocol)
Definition: protocol.c:228
static HRESULT start_downloading(Protocol *protocol)
Definition: protocol.c:73
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3960
#define UlongToPtr(u)
Definition: config.h:106
#define PtrToUlong(u)
Definition: config.h:107
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLAG_REQUEST_COMPLETE
Definition: urlmon_main.h:148
#define FLAG_ERROR
Definition: urlmon_main.h:154
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define INET_E_DATA_NOT_AVAILABLE
Definition: winerror.h:4657

Referenced by FtpProtocol_Continue(), GopherProtocol_Continue(), HttpProtocol_Continue(), and request_complete().

◆ protocol_lock_request()

HRESULT protocol_lock_request ( Protocol protocol)

Definition at line 498 of file protocol.c.

499{
500 if (!InternetLockRequestFile(protocol->request, &protocol->lock))
501 WARN("InternetLockRequestFile failed: %ld\n", GetLastError());
502
503 return S_OK;
504}
BOOL WINAPI InternetLockRequestFile(HINTERNET hInternet, HANDLE *lphLockReqHandle)
Definition: internet.c:4033

Referenced by FtpProtocol_LockRequest(), GopherProtocol_LockRequest(), and HttpProtocol_LockRequest().

◆ protocol_read()

HRESULT protocol_read ( Protocol protocol,
void buf,
ULONG  size,
ULONG read_ret 
)

Definition at line 423 of file protocol.c.

424{
425 ULONG read = 0;
426 BOOL res;
428
429 if(protocol->flags & FLAG_ALL_DATA_READ) {
430 *read_ret = 0;
431 return S_FALSE;
432 }
433
434 if(!(protocol->flags & FLAG_SYNC_READ) && (!(protocol->flags & FLAG_REQUEST_COMPLETE) || !protocol->available_bytes)) {
435 *read_ret = 0;
436 return E_PENDING;
437 }
438
439 while(read < size && protocol->available_bytes) {
440 ULONG len;
441
442 res = InternetReadFile(protocol->request, ((BYTE *)buf)+read,
443 protocol->available_bytes > size-read ? size-read : protocol->available_bytes, &len);
444 if(!res) {
445 WARN("InternetReadFile failed: %ld\n", GetLastError());
448 break;
449 }
450
451 if(!len) {
453 break;
454 }
455
456 read += len;
457 protocol->current_position += len;
458 protocol->available_bytes -= len;
459
460 TRACE("current_position %ld, available_bytes %ld\n", protocol->current_position, protocol->available_bytes);
461
462 if(!protocol->available_bytes) {
463 /* InternetQueryDataAvailable may immediately fork and perform its asynchronous
464 * read, so clear the flag _before_ calling so it does not incorrectly get cleared
465 * after the status callback is called */
466 protocol->flags &= ~FLAG_REQUEST_COMPLETE;
467 res = InternetQueryDataAvailable(protocol->request, &protocol->query_available, 0, 0);
468 if(!res) {
470 hres = E_PENDING;
471 }else {
472 WARN("InternetQueryDataAvailable failed: %ld\n", GetLastError());
475 }
476 break;
477 }
478
479 if(!protocol->query_available) {
481 break;
482 }
483
484 protocol->available_bytes = protocol->query_available;
485 }
486 }
487
488 *read_ret = read;
489
490 if (hres != E_PENDING)
492 if(FAILED(hres))
493 return hres;
494
495 return read ? S_OK : S_FALSE;
496}
#define read
Definition: acwin.h:97
#define E_PENDING
Definition: dinput.h:172
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2154
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
uint32_t ULONG
Definition: typedefs.h:59
#define FLAG_SYNC_READ
Definition: urlmon_main.h:155
#define FLAG_ALL_DATA_READ
Definition: urlmon_main.h:151
#define S_FALSE
Definition: winerror.h:3451
#define INET_E_DOWNLOAD_FAILURE
Definition: winerror.h:4658

◆ protocol_start()

HRESULT protocol_start ( Protocol protocol,
IInternetProtocol prot,
IUri uri,
IInternetProtocolSink protocol_sink,
IInternetBindInfo bind_info 
)

Definition at line 313 of file protocol.c.

315{
318
319 protocol->protocol = prot;
320
321 IInternetProtocolSink_AddRef(protocol_sink);
322 protocol->protocol_sink = protocol_sink;
323
324 memset(&protocol->bind_info, 0, sizeof(protocol->bind_info));
325 protocol->bind_info.cbSize = sizeof(BINDINFO);
326 hres = IInternetBindInfo_GetBindInfo(bind_info, &protocol->bindf, &protocol->bind_info);
327 if(hres != S_OK) {
328 WARN("GetBindInfo failed: %08lx\n", hres);
329 return report_result(protocol, hres);
330 }
331
332 if(!(protocol->bindf & BINDF_FROMURLMON))
333 report_progress(protocol, BINDSTATUS_DIRECTBIND, NULL);
334
337
339 if(protocol->bindf & BINDF_NOWRITECACHE)
341 if(protocol->bindf & BINDF_NEEDFILE)
343 if(protocol->bind_info.dwOptions & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)
345
347 if(FAILED(hres)) {
349 return report_result(protocol, hres);
350 }
351
352 return S_OK;
353}
HINTERNET get_internet_session(IInternetBindInfo *bind_info)
Definition: protocol.c:290
void protocol_close_connection(Protocol *protocol)
Definition: protocol.c:531
static HRESULT report_progress(Protocol *protocol, ULONG status_code, LPCWSTR status_text)
Definition: protocol.c:26
static IInternetProtocolSink protocol_sink
Definition: mimeole.c:1384
#define memset(x, y, z)
Definition: compat.h:39
#define INET_E_NO_SESSION
Definition: winerror.h:4653
request_flags
#define INTERNET_FLAG_NO_AUTO_REDIRECT
Definition: wininet.h:73
#define INTERNET_FLAG_KEEP_CONNECTION
Definition: wininet.h:72
#define INTERNET_FLAG_NEED_FILE
Definition: wininet.h:88
#define INTERNET_FLAG_NO_CACHE_WRITE
Definition: wininet.h:66

◆ protocol_syncbinding()

HRESULT protocol_syncbinding ( Protocol protocol)

Definition at line 101 of file protocol.c.

102{
103 BOOL res;
105
106 protocol->flags |= FLAG_SYNC_READ;
107
109 if(FAILED(hres))
110 return hres;
111
112 res = InternetQueryDataAvailable(protocol->request, &protocol->query_available, 0, 0);
113 if(res)
114 protocol->available_bytes = protocol->query_available;
115 else
116 WARN("InternetQueryDataAvailable failed: %lu\n", GetLastError());
117
119 IInternetProtocolSink_ReportData(protocol->protocol_sink, BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE,
120 protocol->available_bytes, protocol->content_length);
121 return S_OK;
122}
#define FLAG_FIRST_DATA_REPORTED
Definition: urlmon_main.h:150
#define FLAG_LAST_DATA_REPORTED
Definition: urlmon_main.h:152

Referenced by HttpProtocol_open_request().

◆ protocol_unlock_request()

HRESULT protocol_unlock_request ( Protocol protocol)

Definition at line 506 of file protocol.c.

507{
508 if(!protocol->lock)
509 return S_OK;
510
512 WARN("InternetUnlockRequestFile failed: %ld\n", GetLastError());
513 protocol->lock = 0;
514
515 return S_OK;
516}
BOOL WINAPI InternetUnlockRequestFile(HANDLE hLockHandle)
Definition: internet.c:4062

Referenced by FtpProtocol_UnlockRequest(), GopherProtocol_UnlockRequest(), and HttpProtocol_UnlockRequest().

◆ register_namespace()

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

Definition at line 114 of file session.c.

115{
116 name_space *new_name_space;
117
118 new_name_space = malloc(sizeof(name_space));
119
120 if(!urlmon_protocol)
121 IClassFactory_AddRef(cf);
122 new_name_space->cf = cf;
123 new_name_space->clsid = *clsid;
124 new_name_space->urlmon = urlmon_protocol;
125 new_name_space->protocol = wcsdup(protocol);
126
128
129 list_add_head(&name_space_list, &new_name_space->entry);
130
132
133 return S_OK;
134}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
CLSID clsid
Definition: session.c:29
struct list entry
Definition: session.c:32

Referenced by init_session(), and InternetSession_RegisterNameSpace().

◆ release_notif_hwnd()

void release_notif_hwnd ( HWND  hwnd)

Definition at line 137 of file bindprot.c.

138{
140
141 if(!data)
142 return;
143
144 if(data->notif_hwnd != hwnd) {
145 PostMessageW(data->notif_hwnd, WM_MK_RELEASE, 0, 0);
146 return;
147 }
148
149 if(!--data->notif_hwnd_cnt) {
150 DestroyWindow(data->notif_hwnd);
151 data->notif_hwnd = NULL;
152 }
153}
#define WM_MK_RELEASE
Definition: bindprot.c:35
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Binding_Release(), and BindProtocol_Release().

◆ SecManagerImpl_Construct()

HRESULT SecManagerImpl_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

Definition at line 1206 of file sec_mgr.c.

1207{
1209
1210 TRACE("(%p,%p)\n",pUnkOuter,ppobj);
1211 This = malloc(sizeof(*This));
1212
1213 /* Initialize the virtual function table. */
1214 This->IInternetSecurityManagerEx2_iface.lpVtbl = &VT_SecManagerImpl;
1215
1216 This->ref = 1;
1217 This->mgrsite = NULL;
1218 This->custom_manager = NULL;
1219
1220 *ppobj = This;
1221
1223
1224 return S_OK;
1225}
static const IInternetSecurityManagerEx2Vtbl VT_SecManagerImpl
Definition: sec_mgr.c:1186

Referenced by CoInternetCreateSecurityManager().

◆ set_binding_sink()

void set_binding_sink ( BindProtocol This,
IInternetProtocolSink sink,
IInternetBindInfo bind_info 
)

Definition at line 560 of file bindprot.c.

561{
562 IInternetProtocolSink *prev_sink;
564
565 if(sink)
566 IInternetProtocolSink_AddRef(sink);
567 prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink);
568 if(prev_sink)
569 IInternetProtocolSink_Release(prev_sink);
570
571 if(sink)
572 IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider);
575 IServiceProvider_Release(service_provider);
576
577 if(bind_info)
578 IInternetBindInfo_AddRef(bind_info);
579 bind_info = InterlockedExchangePointer((void**)&This->bind_info, bind_info);
580 if(bind_info)
581 IInternetBindInfo_Release(bind_info);
582}
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
static IServiceProvider service_provider
Definition: mimeole.c:1286

Referenced by BindProtocol_Release(), BindProtocol_StartEx(), ProtocolHandler_Terminate(), and start_binding().

◆ StdURLMoniker_Construct()

HRESULT StdURLMoniker_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

◆ strdupAtoW()

static WCHAR * strdupAtoW ( const char str)
inlinestatic

Definition at line 251 of file urlmon_main.h.

252{
253 LPWSTR ret = NULL;
254
255 if(str) {
257 ret = malloc(len * sizeof(WCHAR));
258 if(ret)
260 }
261
262 return ret;
263}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
const WCHAR * str

◆ strndupW()

static WCHAR * strndupW ( LPCWSTR  str,
int  len 
)
inlinestatic

Definition at line 236 of file urlmon_main.h.

237{
238 LPWSTR ret = NULL;
239
240 if(str) {
241 ret = malloc((len + 1) * sizeof(WCHAR));
242 if(ret) {
243 memcpy(ret, str, len*sizeof(WCHAR));
244 ret[len] = 0;
245 }
246 }
247
248 return ret;
249}

Referenced by search_domain_for_zone().

◆ unregister_notif_wnd_class()

void unregister_notif_wnd_class ( void  )

Definition at line 101 of file bindprot.c.

102{
105}
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)

Referenced by process_detach().

◆ update_user_agent()

void update_user_agent ( WCHAR user_agent)

Definition at line 307 of file protocol.c.

308{
311}
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:2837
#define INTERNET_OPTION_USER_AGENT
Definition: wininet.h:735

Referenced by UrlMkSetSessionOption().

◆ Uri_Construct()

HRESULT Uri_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

Definition at line 5338 of file uri.c.

5339{
5340 Uri *ret = calloc(1, sizeof(Uri));
5341
5342 TRACE("(%p %p)\n", pUnkOuter, ppobj);
5343
5344 *ppobj = ret;
5345 if(!ret)
5346 return E_OUTOFMEMORY;
5347
5348 ret->IUri_iface.lpVtbl = &UriVtbl;
5349 ret->IUriBuilderFactory_iface.lpVtbl = &UriBuilderFactoryVtbl;
5350 ret->IPersistStream_iface.lpVtbl = &PersistStreamVtbl;
5351 ret->IMarshal_iface.lpVtbl = &MarshalVtbl;
5352 ret->ref = 1;
5353
5354 *ppobj = &ret->IUri_iface;
5355 return S_OK;
5356}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IMarshalVtbl MarshalVtbl
Definition: uri.c:5326
static const IUriVtbl UriVtbl
Definition: uri.c:4709
static const IPersistStreamVtbl PersistStreamVtbl
Definition: uri.c:5091
static const IUriBuilderFactoryVtbl UriBuilderFactoryVtbl
Definition: uri.c:4801
Definition: uri.c:54

Referenced by build_uri(), combine_uri(), and CreateUri().

◆ URLMON_DllGetClassObject()

HRESULT WINAPI URLMON_DllGetClassObject ( REFCLSID  rclsid,
REFIID  iid,
LPVOID ppv 
)

Referenced by DllGetClassObject().

◆ URLMON_DllMain()

BOOL WINAPI URLMON_DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Referenced by DllMain().

◆ URLMON_DllRegisterServer()

HRESULT WINAPI URLMON_DllRegisterServer ( void  )

Referenced by DllRegisterServer().

◆ URLMON_DllUnregisterServer()

HRESULT WINAPI URLMON_DllUnregisterServer ( void  )

Referenced by DllUnregisterServer().

◆ URLMON_LockModule()

◆ URLMON_UnlockModule()

◆ wrap_callback()

HRESULT wrap_callback ( IBindStatusCallback bsc,
IBindStatusCallback **  ret_iface 
)

Definition at line 578 of file bindctx.c.

579{
581
582 ret = calloc(1, sizeof(BindStatusCallback));
583 if(!ret)
584 return E_OUTOFMEMORY;
585
586 ret->IBindStatusCallbackEx_iface.lpVtbl = &BindStatusCallbackExVtbl;
587 ret->IInternetBindInfo_iface.lpVtbl = &BSCInternetBindInfoVtbl;
588 ret->IServiceProvider_iface.lpVtbl = &BSCServiceProviderVtbl;
589 ret->IHttpNegotiate2_iface.lpVtbl = &BSCHttpNegotiateVtbl;
590 ret->IAuthenticate_iface.lpVtbl = &BSCAuthenticateVtbl;
591
592 ret->ref = 1;
594
595 *ret_iface = (IBindStatusCallback*)&ret->IBindStatusCallbackEx_iface;
596 return S_OK;
597}
static const IAuthenticateVtbl BSCAuthenticateVtbl
Definition: bindctx.c:497
static const IHttpNegotiate2Vtbl BSCHttpNegotiateVtbl
Definition: bindctx.c:457
static IInternetBindInfoVtbl BSCInternetBindInfoVtbl
Definition: bindctx.c:553
static void set_callback(BindStatusCallback *This, IBindStatusCallback *bsc)
Definition: bindctx.c:561
static const IBindStatusCallbackExVtbl BindStatusCallbackExVtbl
Definition: bindctx.c:283
static const IServiceProviderVtbl BSCServiceProviderVtbl
Definition: bindctx.c:358

Referenced by create_default_callback(), and RegisterBindStatusCallback().

◆ ZoneMgrImpl_Construct()

HRESULT ZoneMgrImpl_Construct ( IUnknown pUnkOuter,
LPVOID ppobj 
)

Definition at line 1781 of file sec_mgr.c.

1782{
1783 ZoneMgrImpl *ret = calloc(1, sizeof(ZoneMgrImpl));
1784
1785 TRACE("(%p %p)\n", pUnkOuter, ppobj);
1786 ret->IInternetZoneManagerEx2_iface.lpVtbl = &ZoneMgrImplVtbl;
1787 ret->ref = 1;
1788 *ppobj = &ret->IInternetZoneManagerEx2_iface;
1789
1791
1792 return S_OK;
1793}
static const IInternetZoneManagerEx2Vtbl ZoneMgrImplVtbl
Definition: sec_mgr.c:1754

Referenced by CoInternetCreateZoneManager().

Variable Documentation

◆ CLSID_CUri

◆ CLSID_PSFactoryBuffer

GUID const CLSID_PSFactoryBuffer
extern

◆ hProxyDll

◆ urlmon_instance

HINSTANCE urlmon_instance
extern

Definition at line 41 of file urlmon_main.c.

Referenced by DllMain(), failure_msgbox(), install_warning(), and update_counter().

◆ URLMON_refCount

LONG URLMON_refCount
extern

Definition at line 40 of file urlmon_main.c.

Referenced by DllCanUnloadNow(), URLMON_LockModule(), and URLMON_UnlockModule().