wined3d: Use a separate STATE_TRANSFORM(WINED3D_TS_VIEW) state handler in the GLSL...
[wine/multimedia.git] / dlls / urlmon / urlmon_main.c
blob1204a6204b95cef6737846249c97d6338d83a55f
1 /*
2 * UrlMon
4 * Copyright (c) 2000 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "urlmon_main.h"
25 #include "winreg.h"
27 #define NO_SHLWAPI_REG
28 #include "shlwapi.h"
29 #include "advpub.h"
30 #include "initguid.h"
32 #include "wine/debug.h"
34 #include "urlmon.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
38 DEFINE_GUID(CLSID_CUri, 0xDF2FCE13, 0x25EC, 0x45BB, 0x9D,0x4C, 0xCE,0xCD,0x47,0xC2,0x43,0x0C);
40 LONG URLMON_refCount = 0;
41 HINSTANCE urlmon_instance;
43 static HMODULE hCabinet = NULL;
44 static DWORD urlmon_tls = TLS_OUT_OF_INDEXES;
46 static void init_session(void);
48 static struct list tls_list = LIST_INIT(tls_list);
50 static CRITICAL_SECTION tls_cs;
51 static CRITICAL_SECTION_DEBUG tls_cs_dbg =
53 0, 0, &tls_cs,
54 { &tls_cs_dbg.ProcessLocksList, &tls_cs_dbg.ProcessLocksList },
55 0, 0, { (DWORD_PTR)(__FILE__ ": tls") }
58 static CRITICAL_SECTION tls_cs = { &tls_cs_dbg, -1, 0, 0, 0, 0 };
60 tls_data_t *get_tls_data(void)
62 tls_data_t *data;
64 if(urlmon_tls == TLS_OUT_OF_INDEXES) {
65 DWORD tls = TlsAlloc();
66 if(tls == TLS_OUT_OF_INDEXES)
67 return NULL;
69 tls = InterlockedCompareExchange((LONG*)&urlmon_tls, tls, TLS_OUT_OF_INDEXES);
70 if(tls != urlmon_tls)
71 TlsFree(tls);
74 data = TlsGetValue(urlmon_tls);
75 if(!data) {
76 data = heap_alloc_zero(sizeof(tls_data_t));
77 if(!data)
78 return NULL;
80 EnterCriticalSection(&tls_cs);
81 list_add_tail(&tls_list, &data->entry);
82 LeaveCriticalSection(&tls_cs);
84 TlsSetValue(urlmon_tls, data);
87 return data;
90 static void free_tls_list(void)
92 tls_data_t *data;
94 if(urlmon_tls == TLS_OUT_OF_INDEXES)
95 return;
97 while(!list_empty(&tls_list)) {
98 data = LIST_ENTRY(list_head(&tls_list), tls_data_t, entry);
99 list_remove(&data->entry);
100 heap_free(data);
103 TlsFree(urlmon_tls);
106 static void detach_thread(void)
108 tls_data_t *data;
110 if(urlmon_tls == TLS_OUT_OF_INDEXES)
111 return;
113 data = TlsGetValue(urlmon_tls);
114 if(!data)
115 return;
117 EnterCriticalSection(&tls_cs);
118 list_remove(&data->entry);
119 LeaveCriticalSection(&tls_cs);
121 if(data->notif_hwnd) {
122 WARN("notif_hwnd not destroyed\n");
123 DestroyWindow(data->notif_hwnd);
126 heap_free(data);
129 static void process_detach(void)
131 HINTERNET internet_session;
133 internet_session = get_internet_session(NULL);
134 if(internet_session)
135 InternetCloseHandle(internet_session);
137 if (hCabinet)
138 FreeLibrary(hCabinet);
140 free_session();
141 free_tls_list();
142 unregister_notif_wnd_class();
145 /***********************************************************************
146 * DllMain (URLMON.init)
148 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
150 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
152 URLMON_DllMain( hinstDLL, fdwReason, fImpLoad );
154 switch(fdwReason) {
155 case DLL_PROCESS_ATTACH:
156 urlmon_instance = hinstDLL;
157 init_session();
158 break;
160 case DLL_PROCESS_DETACH:
161 if (fImpLoad) break;
162 process_detach();
163 DeleteCriticalSection(&tls_cs);
164 break;
166 case DLL_THREAD_DETACH:
167 detach_thread();
168 break;
170 return TRUE;
173 const char *debugstr_bindstatus(ULONG status)
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 %u)", status);
235 /***********************************************************************
236 * DllInstall (URLMON.@)
238 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
240 FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
241 debugstr_w(cmdline));
243 return S_OK;
246 /***********************************************************************
247 * DllCanUnloadNow (URLMON.@)
249 HRESULT WINAPI DllCanUnloadNow(void)
251 return URLMON_refCount != 0 ? S_FALSE : S_OK;
256 /******************************************************************************
257 * Urlmon ClassFactory
259 typedef struct {
260 IClassFactory IClassFactory_iface;
262 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
263 } ClassFactory;
265 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
267 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
270 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv)
272 *ppv = NULL;
274 if(IsEqualGUID(riid, &IID_IUnknown)) {
275 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
276 *ppv = iface;
277 }else if(IsEqualGUID(riid, &IID_IClassFactory)) {
278 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
279 *ppv = iface;
282 if(*ppv) {
283 IUnknown_AddRef((IUnknown*)*ppv);
284 return S_OK;
287 WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
288 return E_NOINTERFACE;
291 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
293 URLMON_LockModule();
294 return 2;
297 static ULONG WINAPI CF_Release(IClassFactory *iface)
299 URLMON_UnlockModule();
300 return 1;
304 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
305 REFIID riid, LPVOID *ppobj)
307 ClassFactory *This = impl_from_IClassFactory(iface);
308 HRESULT hres;
309 LPUNKNOWN punk;
311 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
313 *ppobj = NULL;
314 if(SUCCEEDED(hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk))) {
315 hres = IUnknown_QueryInterface(punk, riid, ppobj);
316 IUnknown_Release(punk);
318 return hres;
321 static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
323 TRACE("(%d)\n", dolock);
325 if (dolock)
326 URLMON_LockModule();
327 else
328 URLMON_UnlockModule();
330 return S_OK;
333 static const IClassFactoryVtbl ClassFactoryVtbl =
335 CF_QueryInterface,
336 CF_AddRef,
337 CF_Release,
338 CF_CreateInstance,
339 CF_LockServer
342 static ClassFactory FileProtocolCF =
343 { { &ClassFactoryVtbl }, FileProtocol_Construct};
344 static ClassFactory FtpProtocolCF =
345 { { &ClassFactoryVtbl }, FtpProtocol_Construct};
346 static ClassFactory GopherProtocolCF =
347 { { &ClassFactoryVtbl }, GopherProtocol_Construct};
348 static ClassFactory HttpProtocolCF =
349 { { &ClassFactoryVtbl }, HttpProtocol_Construct};
350 static ClassFactory HttpSProtocolCF =
351 { { &ClassFactoryVtbl }, HttpSProtocol_Construct};
352 static ClassFactory MkProtocolCF =
353 { { &ClassFactoryVtbl }, MkProtocol_Construct};
354 static ClassFactory SecurityManagerCF =
355 { { &ClassFactoryVtbl }, SecManagerImpl_Construct};
356 static ClassFactory ZoneManagerCF =
357 { { &ClassFactoryVtbl }, ZoneMgrImpl_Construct};
358 static ClassFactory StdURLMonikerCF =
359 { { &ClassFactoryVtbl }, StdURLMoniker_Construct};
360 static ClassFactory MimeFilterCF =
361 { { &ClassFactoryVtbl }, MimeFilter_Construct};
362 static ClassFactory CUriCF =
363 { { &ClassFactoryVtbl }, Uri_Construct};
365 struct object_creation_info
367 const CLSID *clsid;
368 IClassFactory *cf;
369 LPCWSTR protocol;
372 static const WCHAR wszFile[] = {'f','i','l','e',0};
373 static const WCHAR wszFtp[] = {'f','t','p',0};
374 static const WCHAR wszGopher[] = {'g','o','p','h','e','r',0};
375 static const WCHAR wszHttp[] = {'h','t','t','p',0};
376 static const WCHAR wszHttps[] = {'h','t','t','p','s',0};
377 static const WCHAR wszMk[] = {'m','k',0};
379 static const struct object_creation_info object_creation[] =
381 { &CLSID_FileProtocol, &FileProtocolCF.IClassFactory_iface, wszFile },
382 { &CLSID_FtpProtocol, &FtpProtocolCF.IClassFactory_iface, wszFtp },
383 { &CLSID_GopherProtocol, &GopherProtocolCF.IClassFactory_iface, wszGopher },
384 { &CLSID_HttpProtocol, &HttpProtocolCF.IClassFactory_iface, wszHttp },
385 { &CLSID_HttpSProtocol, &HttpSProtocolCF.IClassFactory_iface, wszHttps },
386 { &CLSID_MkProtocol, &MkProtocolCF.IClassFactory_iface, wszMk },
387 { &CLSID_InternetSecurityManager, &SecurityManagerCF.IClassFactory_iface, NULL },
388 { &CLSID_InternetZoneManager, &ZoneManagerCF.IClassFactory_iface, NULL },
389 { &CLSID_StdURLMoniker, &StdURLMonikerCF.IClassFactory_iface, NULL },
390 { &CLSID_DeCompMimeFilter, &MimeFilterCF.IClassFactory_iface, NULL },
391 { &CLSID_CUri, &CUriCF.IClassFactory_iface, NULL }
394 static void init_session(void)
396 unsigned int i;
398 for(i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) {
399 if(object_creation[i].protocol)
400 register_namespace(object_creation[i].cf, object_creation[i].clsid,
401 object_creation[i].protocol, TRUE);
405 /*******************************************************************************
406 * DllGetClassObject [URLMON.@]
407 * Retrieves class object from a DLL object
409 * NOTES
410 * Docs say returns STDAPI
412 * PARAMS
413 * rclsid [I] CLSID for the class object
414 * riid [I] Reference to identifier of interface for class object
415 * ppv [O] Address of variable to receive interface pointer for riid
417 * RETURNS
418 * Success: S_OK
419 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
420 * E_UNEXPECTED
423 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
425 unsigned int i;
426 HRESULT hr;
428 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
430 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
432 if (IsEqualGUID(object_creation[i].clsid, rclsid))
433 return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv);
436 hr = URLMON_DllGetClassObject(rclsid, riid, ppv);
437 if(SUCCEEDED(hr))
438 return hr;
440 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
441 return CLASS_E_CLASSNOTAVAILABLE;
444 static HRESULT register_inf(BOOL doregister)
446 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
447 HMODULE hAdvpack;
449 static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
451 hAdvpack = LoadLibraryW(wszAdvpack);
452 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
454 return pRegInstall(hProxyDll, doregister ? "RegisterDll" : "UnregisterDll", NULL);
457 /***********************************************************************
458 * DllRegisterServer (URLMON.@)
460 HRESULT WINAPI DllRegisterServer(void)
462 HRESULT hr;
464 TRACE("\n");
466 hr = URLMON_DllRegisterServer();
467 return SUCCEEDED(hr) ? register_inf(TRUE) : hr;
470 /***********************************************************************
471 * DllUnregisterServer (URLMON.@)
473 HRESULT WINAPI DllUnregisterServer(void)
475 HRESULT hr;
477 TRACE("\n");
479 hr = URLMON_DllUnregisterServer();
480 return SUCCEEDED(hr) ? register_inf(FALSE) : hr;
483 /***********************************************************************
484 * DllRegisterServerEx (URLMON.@)
486 HRESULT WINAPI DllRegisterServerEx(void)
488 FIXME("(void): stub\n");
490 return E_FAIL;
493 /**************************************************************************
494 * IsValidURL (URLMON.@)
496 * Determines if a specified string is a valid URL.
498 * PARAMS
499 * pBC [I] ignored, should be NULL.
500 * szURL [I] string that represents the URL in question.
501 * dwReserved [I] reserved and must be zero.
503 * RETURNS
504 * Success: S_OK.
505 * Failure: S_FALSE.
506 * returns E_INVALIDARG if one or more of the args is invalid.
508 * TODO:
509 * test functionality against windows to see what a valid URL is.
511 HRESULT WINAPI IsValidURL(LPBC pBC, LPCWSTR szURL, DWORD dwReserved)
513 FIXME("(%p, %s, %d): stub\n", pBC, debugstr_w(szURL), dwReserved);
515 if (dwReserved || !szURL)
516 return E_INVALIDARG;
518 return S_OK;
521 /**************************************************************************
522 * FaultInIEFeature (URLMON.@)
524 * Undocumented. Appears to be used by native shdocvw.dll.
526 HRESULT WINAPI FaultInIEFeature( HWND hwnd, uCLSSPEC * pClassSpec,
527 QUERYCONTEXT *pQuery, DWORD flags )
529 FIXME("%p %p %p %08x\n", hwnd, pClassSpec, pQuery, flags);
530 return E_NOTIMPL;
533 /**************************************************************************
534 * CoGetClassObjectFromURL (URLMON.@)
536 HRESULT WINAPI CoGetClassObjectFromURL( REFCLSID rclsid, LPCWSTR szCodeURL, DWORD dwFileVersionMS,
537 DWORD dwFileVersionLS, LPCWSTR szContentType,
538 LPBINDCTX pBindCtx, DWORD dwClsContext, LPVOID pvReserved,
539 REFIID riid, LPVOID *ppv )
541 FIXME("(%s %s %d %d %s %p %d %p %s %p) Stub!\n", debugstr_guid(rclsid), debugstr_w(szCodeURL),
542 dwFileVersionMS, dwFileVersionLS, debugstr_w(szContentType), pBindCtx, dwClsContext, pvReserved,
543 debugstr_guid(riid), ppv);
544 return E_NOINTERFACE;
547 /***********************************************************************
548 * ReleaseBindInfo (URLMON.@)
550 * Release the resources used by the specified BINDINFO structure.
552 * PARAMS
553 * pbindinfo [I] BINDINFO to release.
555 * RETURNS
556 * Nothing.
558 void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
560 DWORD size;
562 TRACE("(%p)\n", pbindinfo);
564 if(!pbindinfo || !(size = pbindinfo->cbSize))
565 return;
567 CoTaskMemFree(pbindinfo->szExtraInfo);
568 ReleaseStgMedium(&pbindinfo->stgmedData);
570 if(offsetof(BINDINFO, szExtraInfo) < size)
571 CoTaskMemFree(pbindinfo->szCustomVerb);
573 if(pbindinfo->pUnk && offsetof(BINDINFO, pUnk) < size)
574 IUnknown_Release(pbindinfo->pUnk);
576 memset(pbindinfo, 0, size);
577 pbindinfo->cbSize = size;
580 /***********************************************************************
581 * CopyStgMedium (URLMON.@)
583 HRESULT WINAPI CopyStgMedium(const STGMEDIUM *src, STGMEDIUM *dst)
585 TRACE("(%p %p)\n", src, dst);
587 if(!src || !dst)
588 return E_POINTER;
590 *dst = *src;
592 switch(dst->tymed) {
593 case TYMED_NULL:
594 break;
595 case TYMED_FILE:
596 if(src->u.lpszFileName && !src->pUnkForRelease) {
597 DWORD size = (strlenW(src->u.lpszFileName)+1)*sizeof(WCHAR);
598 dst->u.lpszFileName = CoTaskMemAlloc(size);
599 if(!dst->u.lpszFileName)
600 return E_OUTOFMEMORY;
601 memcpy(dst->u.lpszFileName, src->u.lpszFileName, size);
603 break;
604 case TYMED_ISTREAM:
605 if(dst->u.pstm)
606 IStream_AddRef(dst->u.pstm);
607 break;
608 case TYMED_ISTORAGE:
609 if(dst->u.pstg)
610 IStorage_AddRef(dst->u.pstg);
611 break;
612 case TYMED_HGLOBAL:
613 if(dst->u.hGlobal) {
614 SIZE_T size = GlobalSize(src->u.hGlobal);
615 char *src_ptr, *dst_ptr;
617 dst->u.hGlobal = GlobalAlloc(GMEM_FIXED, size);
618 if(!dst->u.hGlobal)
619 return E_OUTOFMEMORY;
620 dst_ptr = GlobalLock(dst->u.hGlobal);
621 src_ptr = GlobalLock(src->u.hGlobal);
622 memcpy(dst_ptr, src_ptr, size);
623 GlobalUnlock(src_ptr);
624 GlobalUnlock(dst_ptr);
626 break;
627 default:
628 FIXME("Unimplemented tymed %d\n", src->tymed);
631 if(dst->pUnkForRelease)
632 IUnknown_AddRef(dst->pUnkForRelease);
634 return S_OK;
637 /***********************************************************************
638 * CopyBindInfo (URLMON.@)
640 HRESULT WINAPI CopyBindInfo(const BINDINFO *pcbiSrc, BINDINFO *pcbiDest)
642 DWORD size;
643 HRESULT hres;
645 TRACE("(%p %p)\n", pcbiSrc, pcbiDest);
647 if(!pcbiSrc || !pcbiDest)
648 return E_POINTER;
649 if(!pcbiSrc->cbSize || !pcbiDest->cbSize)
650 return E_INVALIDARG;
652 size = pcbiDest->cbSize;
653 if(size > pcbiSrc->cbSize) {
654 memcpy(pcbiDest, pcbiSrc, pcbiSrc->cbSize);
655 memset((char*)pcbiDest+pcbiSrc->cbSize, 0, size-pcbiSrc->cbSize);
656 } else {
657 memcpy(pcbiDest, pcbiSrc, size);
659 pcbiDest->cbSize = size;
661 size = FIELD_OFFSET(BINDINFO, szExtraInfo)+sizeof(void*);
662 if(pcbiSrc->cbSize>=size && pcbiDest->cbSize>=size && pcbiSrc->szExtraInfo) {
663 size = (strlenW(pcbiSrc->szExtraInfo)+1)*sizeof(WCHAR);
664 pcbiDest->szExtraInfo = CoTaskMemAlloc(size);
665 if(!pcbiDest->szExtraInfo)
666 return E_OUTOFMEMORY;
667 memcpy(pcbiDest->szExtraInfo, pcbiSrc->szExtraInfo, size);
670 size = FIELD_OFFSET(BINDINFO, stgmedData)+sizeof(STGMEDIUM);
671 if(pcbiSrc->cbSize>=size && pcbiDest->cbSize>=size) {
672 hres = CopyStgMedium(&pcbiSrc->stgmedData, &pcbiDest->stgmedData);
673 if(FAILED(hres)) {
674 CoTaskMemFree(pcbiDest->szExtraInfo);
675 return hres;
679 size = FIELD_OFFSET(BINDINFO, szCustomVerb)+sizeof(void*);
680 if(pcbiSrc->cbSize>=size && pcbiDest->cbSize>=size && pcbiSrc->szCustomVerb) {
681 size = (strlenW(pcbiSrc->szCustomVerb)+1)*sizeof(WCHAR);
682 pcbiDest->szCustomVerb = CoTaskMemAlloc(size);
683 if(!pcbiDest->szCustomVerb) {
684 CoTaskMemFree(pcbiDest->szExtraInfo);
685 ReleaseStgMedium(&pcbiDest->stgmedData);
686 return E_OUTOFMEMORY;
688 memcpy(pcbiDest->szCustomVerb, pcbiSrc->szCustomVerb, size);
691 size = FIELD_OFFSET(BINDINFO, securityAttributes)+sizeof(SECURITY_ATTRIBUTES);
692 if(pcbiDest->cbSize >= size)
693 memset(&pcbiDest->securityAttributes, 0, sizeof(SECURITY_ATTRIBUTES));
695 if(pcbiSrc->pUnk)
696 IUnknown_AddRef(pcbiDest->pUnk);
698 return S_OK;
701 /***********************************************************************
702 * GetClassFileOrMime (URLMON.@)
704 * Determines the class ID from the bind context, file name or MIME type.
706 HRESULT WINAPI GetClassFileOrMime(LPBC pBC, LPCWSTR pszFilename,
707 LPVOID pBuffer, DWORD cbBuffer, LPCWSTR pszMimeType, DWORD dwReserved,
708 CLSID *pclsid)
710 FIXME("(%p, %s, %p, %d, %s, 0x%08x, %p): stub\n", pBC, debugstr_w(pszFilename), pBuffer,
711 cbBuffer, debugstr_w(pszMimeType), dwReserved, pclsid);
712 return E_NOTIMPL;
715 /***********************************************************************
716 * Extract (URLMON.@)
718 HRESULT WINAPI Extract(void *dest, LPCSTR szCabName)
720 HRESULT (WINAPI *pExtract)(void *, LPCSTR);
722 if (!hCabinet)
723 hCabinet = LoadLibraryA("cabinet.dll");
725 if (!hCabinet) return HRESULT_FROM_WIN32(GetLastError());
726 pExtract = (void *)GetProcAddress(hCabinet, "Extract");
727 if (!pExtract) return HRESULT_FROM_WIN32(GetLastError());
729 return pExtract(dest, szCabName);
732 /***********************************************************************
733 * IsLoggingEnabledA (URLMON.@)
735 BOOL WINAPI IsLoggingEnabledA(LPCSTR url)
737 FIXME("(%s)\n", debugstr_a(url));
738 return FALSE;
741 /***********************************************************************
742 * IsLoggingEnabledW (URLMON.@)
744 BOOL WINAPI IsLoggingEnabledW(LPCWSTR url)
746 FIXME("(%s)\n", debugstr_w(url));
747 return FALSE;
750 /***********************************************************************
751 * IsProtectedModeURL (URLMON.111)
752 * Undocumented, added in IE7
754 BOOL WINAPI IsProtectedModeURL(const WCHAR *url)
756 FIXME("stub: %s\n", debugstr_w(url));
757 return TRUE;
760 /***********************************************************************
761 * LogSqmBits (URLMON.410)
762 * Undocumented, added in IE8
764 int WINAPI LogSqmBits(DWORD unk1, DWORD unk2)
766 FIXME("stub: %d %d\n", unk1, unk2);
767 return 0;
770 /***********************************************************************
771 * LogSqmUXCommandOffsetInternal (URLMON.423)
772 * Undocumented, added in IE8
774 void WINAPI LogSqmUXCommandOffsetInternal(DWORD unk1, DWORD unk2, DWORD unk3, DWORD unk4)
776 FIXME("stub: %d %d %d %d\n", unk1, unk2, unk3, unk4);
779 /***********************************************************************
780 * MapUriToBrowserEmulationState (URLMON.444)
781 * Undocumented, added in IE8
783 int WINAPI MapUriToBrowserEmulationState(DWORD unk1, DWORD unk2, DWORD unk3)
785 FIXME("stub: %d %d %d\n", unk1, unk2, unk3);
786 return 0;
789 /***********************************************************************
790 * MapBrowserEmulationModeToUserAgent (URLMON.445)
791 * Undocumented, added in IE8
793 int WINAPI MapBrowserEmulationModeToUserAgent(DWORD unk1, DWORD unk2)
795 FIXME("stub: %d %d\n", unk1, unk2);
796 return 0;
799 /***********************************************************************
800 * FlushUrlmonZonesCache (URLMON.455)
801 * Undocumented, added in IE8
803 void WINAPI FlushUrlmonZonesCache(void)
805 FIXME("stub\n");
808 /***********************************************************************
809 * RegisterMediaTypes
810 * Added in IE3, registers known MIME-type strings.
812 HRESULT WINAPI RegisterMediaTypes(UINT types, LPCSTR *szTypes, CLIPFORMAT *cfTypes)
814 FIXME("stub: %u %p %p\n", types, szTypes, cfTypes);
815 return E_INVALIDARG;