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
23 #include "urlmon_main.h"
27 #define NO_SHLWAPI_REG
32 #include "wine/debug.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;
42 static HMODULE hCabinet
= NULL
;
43 static DWORD urlmon_tls
= TLS_OUT_OF_INDEXES
;
45 static void init_session(BOOL
);
47 static struct list tls_list
= LIST_INIT(tls_list
);
49 static CRITICAL_SECTION tls_cs
;
50 static CRITICAL_SECTION_DEBUG tls_cs_dbg
=
53 { &tls_cs_dbg
.ProcessLocksList
, &tls_cs_dbg
.ProcessLocksList
},
54 0, 0, { (DWORD_PTR
)(__FILE__
": tls") }
57 static CRITICAL_SECTION tls_cs
= { &tls_cs_dbg
, -1, 0, 0, 0, 0 };
59 tls_data_t
*get_tls_data(void)
63 if(urlmon_tls
== TLS_OUT_OF_INDEXES
) {
64 DWORD tls
= TlsAlloc();
65 if(tls
== TLS_OUT_OF_INDEXES
)
68 tls
= InterlockedCompareExchange((LONG
*)&urlmon_tls
, tls
, TLS_OUT_OF_INDEXES
);
73 data
= TlsGetValue(urlmon_tls
);
75 data
= heap_alloc_zero(sizeof(tls_data_t
));
79 EnterCriticalSection(&tls_cs
);
80 list_add_tail(&tls_list
, &data
->entry
);
81 LeaveCriticalSection(&tls_cs
);
83 TlsSetValue(urlmon_tls
, data
);
89 static void free_tls_list(void)
93 if(urlmon_tls
== TLS_OUT_OF_INDEXES
)
96 while(!list_empty(&tls_list
)) {
97 data
= LIST_ENTRY(list_head(&tls_list
), tls_data_t
, entry
);
98 list_remove(&data
->entry
);
105 static void detach_thread(void)
109 if(urlmon_tls
== TLS_OUT_OF_INDEXES
)
112 data
= TlsGetValue(urlmon_tls
);
116 EnterCriticalSection(&tls_cs
);
117 list_remove(&data
->entry
);
118 LeaveCriticalSection(&tls_cs
);
120 if(data
->notif_hwnd
) {
121 WARN("notif_hwnd not destroyed\n");
122 DestroyWindow(data
->notif_hwnd
);
128 static void process_detach(void)
130 HINTERNET internet_session
;
132 internet_session
= get_internet_session(NULL
);
134 InternetCloseHandle(internet_session
);
137 FreeLibrary(hCabinet
);
144 /***********************************************************************
145 * DllMain (URLMON.init)
147 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
149 TRACE("%p 0x%x %p\n", hinstDLL
, fdwReason
, fImpLoad
);
151 URLMON_DllMain( hinstDLL
, fdwReason
, fImpLoad
);
154 case DLL_PROCESS_ATTACH
:
158 case DLL_PROCESS_DETACH
:
160 DeleteCriticalSection(&tls_cs
);
163 case DLL_THREAD_DETACH
:
171 /***********************************************************************
172 * DllInstall (URLMON.@)
174 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
176 FIXME("(%s, %s): stub\n", bInstall
?"TRUE":"FALSE",
177 debugstr_w(cmdline
));
182 /***********************************************************************
183 * DllCanUnloadNow (URLMON.@)
185 HRESULT WINAPI
DllCanUnloadNow(void)
187 return URLMON_refCount
!= 0 ? S_FALSE
: S_OK
;
192 /******************************************************************************
193 * Urlmon ClassFactory
196 IClassFactory IClassFactory_iface
;
198 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
201 static inline ClassFactory
*impl_from_IClassFactory(IClassFactory
*iface
)
203 return CONTAINING_RECORD(iface
, ClassFactory
, IClassFactory_iface
);
206 static HRESULT WINAPI
CF_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppv
)
210 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
211 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
213 }else if(IsEqualGUID(riid
, &IID_IClassFactory
)) {
214 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
219 IUnknown_AddRef((IUnknown
*)*ppv
);
223 WARN("(%p)->(%s,%p),not found\n", iface
, debugstr_guid(riid
), ppv
);
224 return E_NOINTERFACE
;
227 static ULONG WINAPI
CF_AddRef(IClassFactory
*iface
)
233 static ULONG WINAPI
CF_Release(IClassFactory
*iface
)
235 URLMON_UnlockModule();
240 static HRESULT WINAPI
CF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
241 REFIID riid
, LPVOID
*ppobj
)
243 ClassFactory
*This
= impl_from_IClassFactory(iface
);
247 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
250 if(SUCCEEDED(hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
))) {
251 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
252 IUnknown_Release(punk
);
257 static HRESULT WINAPI
CF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
259 TRACE("(%d)\n", dolock
);
264 URLMON_UnlockModule();
269 static const IClassFactoryVtbl ClassFactoryVtbl
=
278 static ClassFactory FileProtocolCF
=
279 { { &ClassFactoryVtbl
}, FileProtocol_Construct
};
280 static ClassFactory FtpProtocolCF
=
281 { { &ClassFactoryVtbl
}, FtpProtocol_Construct
};
282 static ClassFactory GopherProtocolCF
=
283 { { &ClassFactoryVtbl
}, GopherProtocol_Construct
};
284 static ClassFactory HttpProtocolCF
=
285 { { &ClassFactoryVtbl
}, HttpProtocol_Construct
};
286 static ClassFactory HttpSProtocolCF
=
287 { { &ClassFactoryVtbl
}, HttpSProtocol_Construct
};
288 static ClassFactory MkProtocolCF
=
289 { { &ClassFactoryVtbl
}, MkProtocol_Construct
};
290 static ClassFactory SecurityManagerCF
=
291 { { &ClassFactoryVtbl
}, SecManagerImpl_Construct
};
292 static ClassFactory ZoneManagerCF
=
293 { { &ClassFactoryVtbl
}, ZoneMgrImpl_Construct
};
294 static ClassFactory StdURLMonikerCF
=
295 { { &ClassFactoryVtbl
}, StdURLMoniker_Construct
};
296 static ClassFactory MimeFilterCF
=
297 { { &ClassFactoryVtbl
}, MimeFilter_Construct
};
298 static ClassFactory CUriCF
=
299 { { &ClassFactoryVtbl
}, Uri_Construct
};
301 struct object_creation_info
308 static const WCHAR wszFile
[] = {'f','i','l','e',0};
309 static const WCHAR wszFtp
[] = {'f','t','p',0};
310 static const WCHAR wszGopher
[] = {'g','o','p','h','e','r',0};
311 static const WCHAR wszHttp
[] = {'h','t','t','p',0};
312 static const WCHAR wszHttps
[] = {'h','t','t','p','s',0};
313 static const WCHAR wszMk
[] = {'m','k',0};
315 static const struct object_creation_info object_creation
[] =
317 { &CLSID_FileProtocol
, &FileProtocolCF
.IClassFactory_iface
, wszFile
},
318 { &CLSID_FtpProtocol
, &FtpProtocolCF
.IClassFactory_iface
, wszFtp
},
319 { &CLSID_GopherProtocol
, &GopherProtocolCF
.IClassFactory_iface
, wszGopher
},
320 { &CLSID_HttpProtocol
, &HttpProtocolCF
.IClassFactory_iface
, wszHttp
},
321 { &CLSID_HttpSProtocol
, &HttpSProtocolCF
.IClassFactory_iface
, wszHttps
},
322 { &CLSID_MkProtocol
, &MkProtocolCF
.IClassFactory_iface
, wszMk
},
323 { &CLSID_InternetSecurityManager
, &SecurityManagerCF
.IClassFactory_iface
, NULL
},
324 { &CLSID_InternetZoneManager
, &ZoneManagerCF
.IClassFactory_iface
, NULL
},
325 { &CLSID_StdURLMoniker
, &StdURLMonikerCF
.IClassFactory_iface
, NULL
},
326 { &CLSID_DeCompMimeFilter
, &MimeFilterCF
.IClassFactory_iface
, NULL
},
327 { &CLSID_CUri
, &CUriCF
.IClassFactory_iface
, NULL
}
330 static void init_session(BOOL init
)
334 for(i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++) {
336 if(object_creation
[i
].protocol
)
337 register_urlmon_namespace(object_creation
[i
].cf
, object_creation
[i
].clsid
,
338 object_creation
[i
].protocol
, init
);
342 /*******************************************************************************
343 * DllGetClassObject [URLMON.@]
344 * Retrieves class object from a DLL object
347 * Docs say returns STDAPI
350 * rclsid [I] CLSID for the class object
351 * riid [I] Reference to identifier of interface for class object
352 * ppv [O] Address of variable to receive interface pointer for riid
356 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
360 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
365 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
367 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
369 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
370 return IClassFactory_QueryInterface(object_creation
[i
].cf
, riid
, ppv
);
373 hr
= URLMON_DllGetClassObject(rclsid
, riid
, ppv
);
377 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
378 return CLASS_E_CLASSNOTAVAILABLE
;
381 static HRESULT
register_inf(BOOL doregister
)
383 HRESULT (WINAPI
*pRegInstall
)(HMODULE hm
, LPCSTR pszSection
, const STRTABLEA
* pstTable
);
386 static const WCHAR wszAdvpack
[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
388 hAdvpack
= LoadLibraryW(wszAdvpack
);
389 pRegInstall
= (void *)GetProcAddress(hAdvpack
, "RegInstall");
391 return pRegInstall(hProxyDll
, doregister
? "RegisterDll" : "UnregisterDll", NULL
);
394 /***********************************************************************
395 * DllRegisterServer (URLMON.@)
397 HRESULT WINAPI
DllRegisterServer(void)
403 hr
= URLMON_DllRegisterServer();
404 return SUCCEEDED(hr
) ? register_inf(TRUE
) : hr
;
407 /***********************************************************************
408 * DllUnregisterServer (URLMON.@)
410 HRESULT WINAPI
DllUnregisterServer(void)
416 hr
= URLMON_DllUnregisterServer();
417 return SUCCEEDED(hr
) ? register_inf(FALSE
) : hr
;
420 /***********************************************************************
421 * DllRegisterServerEx (URLMON.@)
423 HRESULT WINAPI
DllRegisterServerEx(void)
425 FIXME("(void): stub\n");
430 /**************************************************************************
431 * IsValidURL (URLMON.@)
433 * Determines if a specified string is a valid URL.
436 * pBC [I] ignored, should be NULL.
437 * szURL [I] string that represents the URL in question.
438 * dwReserved [I] reserved and must be zero.
443 * returns E_INVALIDARG if one or more of the args is invalid.
446 * test functionality against windows to see what a valid URL is.
448 HRESULT WINAPI
IsValidURL(LPBC pBC
, LPCWSTR szURL
, DWORD dwReserved
)
450 FIXME("(%p, %s, %d): stub\n", pBC
, debugstr_w(szURL
), dwReserved
);
452 if (dwReserved
|| !szURL
)
458 /**************************************************************************
459 * FaultInIEFeature (URLMON.@)
461 * Undocumented. Appears to be used by native shdocvw.dll.
463 HRESULT WINAPI
FaultInIEFeature( HWND hwnd
, uCLSSPEC
* pClassSpec
,
464 QUERYCONTEXT
*pQuery
, DWORD flags
)
466 FIXME("%p %p %p %08x\n", hwnd
, pClassSpec
, pQuery
, flags
);
470 /**************************************************************************
471 * CoGetClassObjectFromURL (URLMON.@)
473 HRESULT WINAPI
CoGetClassObjectFromURL( REFCLSID rclsid
, LPCWSTR szCodeURL
, DWORD dwFileVersionMS
,
474 DWORD dwFileVersionLS
, LPCWSTR szContentType
,
475 LPBINDCTX pBindCtx
, DWORD dwClsContext
, LPVOID pvReserved
,
476 REFIID riid
, LPVOID
*ppv
)
478 FIXME("(%s %s %d %d %s %p %d %p %s %p) Stub!\n", debugstr_guid(rclsid
), debugstr_w(szCodeURL
),
479 dwFileVersionMS
, dwFileVersionLS
, debugstr_w(szContentType
), pBindCtx
, dwClsContext
, pvReserved
,
480 debugstr_guid(riid
), ppv
);
481 return E_NOINTERFACE
;
484 /***********************************************************************
485 * ReleaseBindInfo (URLMON.@)
487 * Release the resources used by the specified BINDINFO structure.
490 * pbindinfo [I] BINDINFO to release.
495 void WINAPI
ReleaseBindInfo(BINDINFO
* pbindinfo
)
499 TRACE("(%p)\n", pbindinfo
);
501 if(!pbindinfo
|| !(size
= pbindinfo
->cbSize
))
504 CoTaskMemFree(pbindinfo
->szExtraInfo
);
505 ReleaseStgMedium(&pbindinfo
->stgmedData
);
507 if(offsetof(BINDINFO
, szExtraInfo
) < size
)
508 CoTaskMemFree(pbindinfo
->szCustomVerb
);
510 if(pbindinfo
->pUnk
&& offsetof(BINDINFO
, pUnk
) < size
)
511 IUnknown_Release(pbindinfo
->pUnk
);
513 memset(pbindinfo
, 0, size
);
514 pbindinfo
->cbSize
= size
;
517 /***********************************************************************
518 * CopyStgMedium (URLMON.@)
520 HRESULT WINAPI
CopyStgMedium(const STGMEDIUM
*src
, STGMEDIUM
*dst
)
522 TRACE("(%p %p)\n", src
, dst
);
533 if(src
->u
.lpszFileName
&& !src
->pUnkForRelease
) {
534 DWORD size
= (strlenW(src
->u
.lpszFileName
)+1)*sizeof(WCHAR
);
535 dst
->u
.lpszFileName
= CoTaskMemAlloc(size
);
536 memcpy(dst
->u
.lpszFileName
, src
->u
.lpszFileName
, size
);
541 IStream_AddRef(dst
->u
.pstm
);
545 IStorage_AddRef(dst
->u
.pstg
);
548 FIXME("Unimplemented tymed %d\n", src
->tymed
);
551 if(dst
->pUnkForRelease
)
552 IUnknown_AddRef(dst
->pUnkForRelease
);
557 static BOOL
text_richtext_filter(const BYTE
*b
, DWORD size
)
559 return size
> 5 && !memcmp(b
, "{\\rtf", 5);
562 static BOOL
text_html_filter(const BYTE
*b
, DWORD size
)
569 for(i
= 0; i
< size
-5; i
++) {
571 && (b
[i
+1] == 'h' || b
[i
+1] == 'H')
572 && (b
[i
+2] == 't' || b
[i
+2] == 'T')
573 && (b
[i
+3] == 'm' || b
[i
+3] == 'M')
574 && (b
[i
+4] == 'l' || b
[i
+4] == 'L')) ||
577 && (b
[i
+1] == 'h' || b
[i
+1] == 'H')
578 && (b
[i
+2] == 'e' || b
[i
+2] == 'E')
579 && (b
[i
+3] == 'a' || b
[i
+3] == 'A')
580 && (b
[i
+4] == 'd' || b
[i
+4] == 'D')
581 && b
[i
+5] == '>')) return TRUE
;
587 static BOOL
audio_basic_filter(const BYTE
*b
, DWORD size
)
590 && b
[0] == '.' && b
[1] == 's' && b
[2] == 'n' && b
[3] == 'd';
593 static BOOL
audio_wav_filter(const BYTE
*b
, DWORD size
)
596 && b
[0] == 'R' && b
[1] == 'I' && b
[2] == 'F' && b
[3] == 'F'
597 && b
[8] == 'W' && b
[9] == 'A' && b
[10] == 'V' && b
[11] == 'E';
600 static BOOL
image_gif_filter(const BYTE
*b
, DWORD size
)
603 && (b
[0] == 'G' || b
[0] == 'g')
604 && (b
[1] == 'I' || b
[1] == 'i')
605 && (b
[2] == 'F' || b
[2] == 'f')
607 && (b
[4] == '7' || b
[4] == '9')
608 && (b
[5] == 'A' || b
[5] == 'a');
611 static BOOL
image_pjpeg_filter(const BYTE
*b
, DWORD size
)
613 return size
> 2 && b
[0] == 0xff && b
[1] == 0xd8;
616 static BOOL
image_tiff_filter(const BYTE
*b
, DWORD size
)
618 static const BYTE magic1
[] = {0x4d,0x4d,0x00,0x2a};
619 static const BYTE magic2
[] = {0x49,0x49,0x2a,0xff};
621 return size
>= 4 && (!memcmp(b
, magic1
, 4) || !memcmp(b
, magic2
, 4));
624 static BOOL
image_xpng_filter(const BYTE
*b
, DWORD size
)
626 static const BYTE xpng_header
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a};
627 return size
> sizeof(xpng_header
) && !memcmp(b
, xpng_header
, sizeof(xpng_header
));
630 static BOOL
image_bmp_filter(const BYTE
*b
, DWORD size
)
633 && b
[0] == 0x42 && b
[1] == 0x4d
634 && *(const DWORD
*)(b
+6) == 0;
637 static BOOL
video_avi_filter(const BYTE
*b
, DWORD size
)
640 && b
[0] == 'R' && b
[1] == 'I' && b
[2] == 'F' && b
[3] == 'F'
641 && b
[8] == 'A' && b
[9] == 'V' && b
[10] == 'I' && b
[11] == 0x20;
644 static BOOL
video_mpeg_filter(const BYTE
*b
, DWORD size
)
647 && !b
[0] && !b
[1] && b
[2] == 0x01
648 && (b
[3] == 0xb3 || b
[3] == 0xba);
651 static BOOL
application_postscript_filter(const BYTE
*b
, DWORD size
)
653 return size
> 2 && b
[0] == '%' && b
[1] == '!';
656 static BOOL
application_pdf_filter(const BYTE
*b
, DWORD size
)
658 return size
> 4 && b
[0] == 0x25 && b
[1] == 0x50 && b
[2] == 0x44 && b
[3] == 0x46;
661 static BOOL
application_xzip_filter(const BYTE
*b
, DWORD size
)
663 return size
> 2 && b
[0] == 0x50 && b
[1] == 0x4b;
666 static BOOL
application_xgzip_filter(const BYTE
*b
, DWORD size
)
668 return size
> 2 && b
[0] == 0x1f && b
[1] == 0x8b;
671 static BOOL
application_java_filter(const BYTE
*b
, DWORD size
)
673 return size
> 4 && b
[0] == 0xca && b
[1] == 0xfe && b
[2] == 0xba && b
[3] == 0xbe;
676 static BOOL
application_xmsdownload(const BYTE
*b
, DWORD size
)
678 return size
> 2 && b
[0] == 'M' && b
[1] == 'Z';
681 static BOOL
text_plain_filter(const BYTE
*b
, DWORD size
)
685 for(ptr
= b
; ptr
< b
+size
-1; ptr
++) {
686 if(*ptr
< 0x20 && *ptr
!= '\n' && *ptr
!= '\r' && *ptr
!= '\t')
693 static BOOL
application_octet_stream_filter(const BYTE
*b
, DWORD size
)
698 static HRESULT
find_mime_from_buffer(const BYTE
*buf
, DWORD size
, const WCHAR
*proposed_mime
, WCHAR
**ret_mime
)
703 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
704 static const WCHAR text_richtextW
[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
705 static const WCHAR audio_basicW
[] = {'a','u','d','i','o','/','b','a','s','i','c',0};
706 static const WCHAR audio_wavW
[] = {'a','u','d','i','o','/','w','a','v',0};
707 static const WCHAR image_gifW
[] = {'i','m','a','g','e','/','g','i','f',0};
708 static const WCHAR image_pjpegW
[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
709 static const WCHAR image_tiffW
[] = {'i','m','a','g','e','/','t','i','f','f',0};
710 static const WCHAR image_xpngW
[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
711 static const WCHAR image_bmpW
[] = {'i','m','a','g','e','/','b','m','p',0};
712 static const WCHAR video_aviW
[] = {'v','i','d','e','o','/','a','v','i',0};
713 static const WCHAR video_mpegW
[] = {'v','i','d','e','o','/','m','p','e','g',0};
714 static const WCHAR app_postscriptW
[] =
715 {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0};
716 static const WCHAR app_pdfW
[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
717 static const WCHAR app_xzipW
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
718 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
719 static const WCHAR app_xgzipW
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
720 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
721 static const WCHAR app_javaW
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
723 static const WCHAR app_xmsdownloadW
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
724 'x','-','m','s','d','o','w','n','l','o','a','d',0};
725 static const WCHAR text_plainW
[] = {'t','e','x','t','/','p','l','a','i','n','\0'};
726 static const WCHAR app_octetstreamW
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
727 'o','c','t','e','t','-','s','t','r','e','a','m','\0'};
729 static const struct {
731 BOOL (*filter
)(const BYTE
*,DWORD
);
733 {text_htmlW
, text_html_filter
},
734 {text_richtextW
, text_richtext_filter
},
735 /* {audio_xaiffW, audio_xaiff_filter}, */
736 {audio_basicW
, audio_basic_filter
},
737 {audio_wavW
, audio_wav_filter
},
738 {image_gifW
, image_gif_filter
},
739 {image_pjpegW
, image_pjpeg_filter
},
740 {image_tiffW
, image_tiff_filter
},
741 {image_xpngW
, image_xpng_filter
},
742 /* {image_xbitmapW, image_xbitmap_filter}, */
743 {image_bmpW
, image_bmp_filter
},
744 /* {image_xjgW, image_xjg_filter}, */
745 /* {image_xemfW, image_xemf_filter}, */
746 /* {image_xwmfW, image_xwmf_filter}, */
747 {video_aviW
, video_avi_filter
},
748 {video_mpegW
, video_mpeg_filter
},
749 {app_postscriptW
, application_postscript_filter
},
750 /* {app_base64W, application_base64_filter}, */
751 /* {app_macbinhex40W, application_macbinhex40_filter}, */
752 {app_pdfW
, application_pdf_filter
},
753 /* {app_zcompressedW, application_xcompressed_filter}, */
754 {app_xzipW
, application_xzip_filter
},
755 {app_xgzipW
, application_xgzip_filter
},
756 {app_javaW
, application_java_filter
},
757 {app_xmsdownloadW
, application_xmsdownload
},
758 {text_plainW
, text_plain_filter
},
759 {app_octetstreamW
, application_octet_stream_filter
}
766 len
= strlenW(proposed_mime
)+1;
767 *ret_mime
= CoTaskMemAlloc(len
*sizeof(WCHAR
));
769 return E_OUTOFMEMORY
;
771 memcpy(*ret_mime
, proposed_mime
, len
*sizeof(WCHAR
));
775 if(proposed_mime
&& strcmpW(proposed_mime
, app_octetstreamW
)) {
776 for(i
=0; i
< sizeof(mime_filters
)/sizeof(*mime_filters
); i
++) {
777 if(!strcmpW(proposed_mime
, mime_filters
[i
].mime
))
781 if(i
== sizeof(mime_filters
)/sizeof(*mime_filters
) || mime_filters
[i
].filter(buf
, size
)) {
782 len
= strlenW(proposed_mime
)+1;
783 *ret_mime
= CoTaskMemAlloc(len
*sizeof(WCHAR
));
785 return E_OUTOFMEMORY
;
787 memcpy(*ret_mime
, proposed_mime
, len
*sizeof(WCHAR
));
794 if(mime_filters
[i
].filter(buf
, size
))
795 ret
= mime_filters
[i
].mime
;
799 TRACE("found %s for %s\n", debugstr_w(ret
), debugstr_an((const char*)buf
, min(32, size
)));
802 if(i
== sizeof(mime_filters
)/sizeof(*mime_filters
))
805 /* text/html is a special case */
806 if(!strcmpW(proposed_mime
, text_htmlW
) && !strcmpW(ret
, text_plainW
))
810 len
= strlenW(ret
)+1;
811 *ret_mime
= CoTaskMemAlloc(len
*sizeof(WCHAR
));
813 return E_OUTOFMEMORY
;
815 memcpy(*ret_mime
, ret
, len
*sizeof(WCHAR
));
819 /***********************************************************************
820 * FindMimeFromData (URLMON.@)
822 * Determines the Multipurpose Internet Mail Extensions (MIME) type from the data provided.
824 HRESULT WINAPI
FindMimeFromData(LPBC pBC
, LPCWSTR pwzUrl
, LPVOID pBuffer
,
825 DWORD cbSize
, LPCWSTR pwzMimeProposed
, DWORD dwMimeFlags
,
826 LPWSTR
* ppwzMimeOut
, DWORD dwReserved
)
828 TRACE("(%p,%s,%p,%d,%s,0x%x,%p,0x%x)\n", pBC
, debugstr_w(pwzUrl
), pBuffer
, cbSize
,
829 debugstr_w(pwzMimeProposed
), dwMimeFlags
, ppwzMimeOut
, dwReserved
);
832 WARN("dwMimeFlags=%08x\n", dwMimeFlags
);
834 WARN("dwReserved=%d\n", dwReserved
);
836 /* pBC seams to not be used */
838 if(!ppwzMimeOut
|| (!pwzUrl
&& !pBuffer
))
841 if(pwzMimeProposed
|| pBuffer
)
842 return find_mime_from_buffer(pBuffer
, cbSize
, pwzMimeProposed
, ppwzMimeOut
);
850 static const WCHAR wszContentType
[] =
851 {'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
853 ptr
= strrchrW(pwzUrl
, '.');
857 res
= RegOpenKeyW(HKEY_CLASSES_ROOT
, ptr
, &hkey
);
858 if(res
!= ERROR_SUCCESS
)
859 return HRESULT_FROM_WIN32(res
);
862 res
= RegQueryValueExW(hkey
, wszContentType
, NULL
, NULL
, (LPBYTE
)mime
, &size
);
864 if(res
!= ERROR_SUCCESS
)
865 return HRESULT_FROM_WIN32(res
);
867 *ppwzMimeOut
= CoTaskMemAlloc(size
);
868 memcpy(*ppwzMimeOut
, mime
, size
);
875 /***********************************************************************
876 * GetClassFileOrMime (URLMON.@)
878 * Determines the class ID from the bind context, file name or MIME type.
880 HRESULT WINAPI
GetClassFileOrMime(LPBC pBC
, LPCWSTR pszFilename
,
881 LPVOID pBuffer
, DWORD cbBuffer
, LPCWSTR pszMimeType
, DWORD dwReserved
,
884 FIXME("(%p, %s, %p, %d, %p, 0x%08x, %p): stub\n", pBC
,
885 debugstr_w(pszFilename
), pBuffer
, cbBuffer
, debugstr_w(pszMimeType
),
890 /***********************************************************************
893 HRESULT WINAPI
Extract(void *dest
, LPCSTR szCabName
)
895 HRESULT (WINAPI
*pExtract
)(void *, LPCSTR
);
898 hCabinet
= LoadLibraryA("cabinet.dll");
900 if (!hCabinet
) return HRESULT_FROM_WIN32(GetLastError());
901 pExtract
= (void *)GetProcAddress(hCabinet
, "Extract");
902 if (!pExtract
) return HRESULT_FROM_WIN32(GetLastError());
904 return pExtract(dest
, szCabName
);
907 /***********************************************************************
908 * IsLoggingEnabledA (URLMON.@)
910 BOOL WINAPI
IsLoggingEnabledA(LPCSTR url
)
912 FIXME("(%s)\n", debugstr_a(url
));
916 /***********************************************************************
917 * IsLoggingEnabledW (URLMON.@)
919 BOOL WINAPI
IsLoggingEnabledW(LPCWSTR url
)
921 FIXME("(%s)\n", debugstr_w(url
));
925 /***********************************************************************
926 * IsProtectedModeURL (URLMON.111)
927 * Undocumented, added in IE7
929 BOOL WINAPI
IsProtectedModeURL(const WCHAR
*url
)
931 FIXME("stub: %s\n", debugstr_w(url
));
935 /***********************************************************************
936 * LogSqmBits (URLMON.410)
937 * Undocumented, added in IE8
939 int WINAPI
LogSqmBits(DWORD unk1
, DWORD unk2
)
941 FIXME("stub: %d %d\n", unk1
, unk2
);
945 /***********************************************************************
946 * LogSqmUXCommandOffsetInternal (URLMON.423)
947 * Undocumented, added in IE8
949 void WINAPI
LogSqmUXCommandOffsetInternal(DWORD unk1
, DWORD unk2
, DWORD unk3
, DWORD unk4
)
951 FIXME("stub: %d %d %d %d\n", unk1
, unk2
, unk3
, unk4
);
954 /***********************************************************************
955 * MapUriToBrowserEmulationState (URLMON.444)
956 * Undocumented, added in IE8
958 int WINAPI
MapUriToBrowserEmulationState(DWORD unk1
, DWORD unk2
, DWORD unk3
)
960 FIXME("stub: %d %d %d\n", unk1
, unk2
, unk3
);
964 /***********************************************************************
965 * MapBrowserEmulationModeToUserAgent (URLMON.445)
966 * Undocumented, added in IE8
968 int WINAPI
MapBrowserEmulationModeToUserAgent(DWORD unk1
, DWORD unk2
)
970 FIXME("stub: %d %d\n", unk1
, unk2
);
974 /***********************************************************************
976 * Added in IE3, registers known MIME-type strings.
978 HRESULT WINAPI
RegisterMediaTypes(UINT types
, LPCSTR
*szTypes
, CLIPFORMAT
*cfTypes
)
980 FIXME("stub: %u %p %p\n", types
, szTypes
, cfTypes
);