kernel32: Use the correct access rights when opening named pipes.
[wine/hacks.git] / dlls / urlmon / urlmon_main.c
blob0f12011d7773a1d1474ea56eb3eba93ac3cc6418
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 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
29 #define NO_SHLWAPI_REG
30 #include "shlwapi.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "winuser.h"
35 #include "urlmon.h"
36 #include "urlmon_main.h"
37 #include "ole2.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
41 LONG URLMON_refCount = 0;
43 HINSTANCE URLMON_hInstance = 0;
44 static HMODULE hCabinet = NULL;
46 static void init_session(BOOL);
48 /***********************************************************************
49 * DllMain (URLMON.init)
51 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
53 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
55 switch(fdwReason) {
56 case DLL_PROCESS_ATTACH:
57 DisableThreadLibraryCalls(hinstDLL);
58 URLMON_hInstance = hinstDLL;
59 init_session(TRUE);
60 break;
62 case DLL_PROCESS_DETACH:
63 if (hCabinet)
64 FreeLibrary(hCabinet);
65 hCabinet = NULL;
66 init_session(FALSE);
67 URLMON_hInstance = 0;
68 break;
70 return TRUE;
74 /***********************************************************************
75 * DllInstall (URLMON.@)
77 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
79 FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
80 debugstr_w(cmdline));
82 return S_OK;
85 /***********************************************************************
86 * DllCanUnloadNow (URLMON.@)
88 HRESULT WINAPI DllCanUnloadNow(void)
90 return URLMON_refCount != 0 ? S_FALSE : S_OK;
95 /******************************************************************************
96 * Urlmon ClassFactory
98 typedef struct {
99 const IClassFactoryVtbl *lpClassFactoryVtbl;
101 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
102 } ClassFactory;
104 #define CLASSFACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
106 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv)
108 *ppv = NULL;
110 if(IsEqualGUID(riid, &IID_IUnknown)) {
111 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
112 *ppv = iface;
113 }else if(IsEqualGUID(riid, &IID_IClassFactory)) {
114 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
115 *ppv = iface;
118 if(*ppv) {
119 IUnknown_AddRef((IUnknown*)*ppv);
120 return S_OK;
123 WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
124 return E_NOINTERFACE;
127 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
129 URLMON_LockModule();
130 return 2;
133 static ULONG WINAPI CF_Release(IClassFactory *iface)
135 URLMON_UnlockModule();
136 return 1;
140 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
141 REFIID riid, LPVOID *ppobj)
143 ClassFactory *This = (ClassFactory*)iface;
144 HRESULT hres;
145 LPUNKNOWN punk;
147 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
149 *ppobj = NULL;
150 if(SUCCEEDED(hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk))) {
151 hres = IUnknown_QueryInterface(punk, riid, ppobj);
152 IUnknown_Release(punk);
154 return hres;
157 static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
159 TRACE("(%d)\n", dolock);
161 if (dolock)
162 URLMON_LockModule();
163 else
164 URLMON_UnlockModule();
166 return S_OK;
169 static const IClassFactoryVtbl ClassFactoryVtbl =
171 CF_QueryInterface,
172 CF_AddRef,
173 CF_Release,
174 CF_CreateInstance,
175 CF_LockServer
178 static const ClassFactory FileProtocolCF =
179 { &ClassFactoryVtbl, FileProtocol_Construct};
180 static const ClassFactory FtpProtocolCF =
181 { &ClassFactoryVtbl, FtpProtocol_Construct};
182 static const ClassFactory HttpProtocolCF =
183 { &ClassFactoryVtbl, HttpProtocol_Construct};
184 static const ClassFactory MkProtocolCF =
185 { &ClassFactoryVtbl, MkProtocol_Construct};
186 static const ClassFactory SecurityManagerCF =
187 { &ClassFactoryVtbl, SecManagerImpl_Construct};
188 static const ClassFactory ZoneManagerCF =
189 { &ClassFactoryVtbl, ZoneMgrImpl_Construct};
191 struct object_creation_info
193 const CLSID *clsid;
194 IClassFactory *cf;
195 LPCWSTR protocol;
198 static const WCHAR wszFile[] = {'f','i','l','e',0};
199 static const WCHAR wszFtp[] = {'f','t','p',0};
200 static const WCHAR wszHttp[] = {'h','t','t','p',0};
201 static const WCHAR wszMk[] = {'m','k',0};
203 static const struct object_creation_info object_creation[] =
205 { &CLSID_FileProtocol, CLASSFACTORY(&FileProtocolCF), wszFile },
206 { &CLSID_FtpProtocol, CLASSFACTORY(&FtpProtocolCF), wszFtp },
207 { &CLSID_HttpProtocol, CLASSFACTORY(&HttpProtocolCF), wszHttp },
208 { &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk },
209 { &CLSID_InternetSecurityManager, CLASSFACTORY(&SecurityManagerCF), NULL },
210 { &CLSID_InternetZoneManager, CLASSFACTORY(&ZoneManagerCF), NULL }
213 static void init_session(BOOL init)
215 IInternetSession *session;
216 int i;
218 CoInternetGetSession(0, &session, 0);
220 for(i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) {
221 if(object_creation[i].protocol) {
222 if(init)
224 IInternetSession_RegisterNameSpace(session, object_creation[i].cf,
225 object_creation[i].clsid, object_creation[i].protocol, 0, NULL, 0);
226 /* make sure that the AddRef on the class factory doesn't keep us loaded */
227 URLMON_UnlockModule();
229 else
231 /* make sure that the Release on the class factory doesn't unload us */
232 URLMON_LockModule();
233 IInternetSession_UnregisterNameSpace(session, object_creation[i].cf,
234 object_creation[i].protocol);
239 IInternetSession_Release(session);
242 /*******************************************************************************
243 * DllGetClassObject [URLMON.@]
244 * Retrieves class object from a DLL object
246 * NOTES
247 * Docs say returns STDAPI
249 * PARAMS
250 * rclsid [I] CLSID for the class object
251 * riid [I] Reference to identifier of interface for class object
252 * ppv [O] Address of variable to receive interface pointer for riid
254 * RETURNS
255 * Success: S_OK
256 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
257 * E_UNEXPECTED
260 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
262 int i;
264 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
266 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
268 if (IsEqualGUID(object_creation[i].clsid, rclsid))
269 return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv);
272 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
273 return CLASS_E_CLASSNOTAVAILABLE;
277 /***********************************************************************
278 * DllRegisterServerEx (URLMON.@)
280 HRESULT WINAPI DllRegisterServerEx(void)
282 FIXME("(void): stub\n");
284 return E_FAIL;
287 /**************************************************************************
288 * UrlMkSetSessionOption (URLMON.@)
290 HRESULT WINAPI UrlMkSetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength,
291 DWORD Reserved)
293 FIXME("(%#x, %p, %#x): stub\n", dwOption, pBuffer, dwBufferLength);
295 return S_OK;
298 static const CHAR Agent[] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
300 /**************************************************************************
301 * ObtainUserAgentString (URLMON.@)
303 HRESULT WINAPI ObtainUserAgentString(DWORD dwOption, LPSTR pcszUAOut, DWORD *cbSize)
305 FIXME("(%d, %p, %p): stub\n", dwOption, pcszUAOut, cbSize);
307 if(dwOption) {
308 ERR("dwOption: %d, must be zero\n", dwOption);
311 if (sizeof(Agent) < *cbSize)
312 *cbSize = sizeof(Agent);
313 lstrcpynA(pcszUAOut, Agent, *cbSize);
315 return S_OK;
318 /**************************************************************************
319 * IsValidURL (URLMON.@)
321 * Determines if a specified string is a valid URL.
323 * PARAMS
324 * pBC [I] ignored, must be NULL.
325 * szURL [I] string that represents the URL in question.
326 * dwReserved [I] reserved and must be zero.
328 * RETURNS
329 * Success: S_OK.
330 * Failure: S_FALSE.
331 * returns E_INVALIDARG if one or more of the args is invalid.
333 * TODO:
334 * test functionality against windows to see what a valid URL is.
336 HRESULT WINAPI IsValidURL(LPBC pBC, LPCWSTR szURL, DWORD dwReserved)
338 FIXME("(%p, %s, %d): stub\n", pBC, debugstr_w(szURL), dwReserved);
340 if (pBC != NULL || dwReserved != 0)
341 return E_INVALIDARG;
343 return S_OK;
346 /**************************************************************************
347 * FaultInIEFeature (URLMON.@)
349 * Undocumented. Appears to be used by native shdocvw.dll.
351 HRESULT WINAPI FaultInIEFeature( HWND hwnd, uCLSSPEC * pClassSpec,
352 QUERYCONTEXT *pQuery, DWORD flags )
354 FIXME("%p %p %p %08x\n", hwnd, pClassSpec, pQuery, flags);
355 return E_NOTIMPL;
358 /**************************************************************************
359 * CoGetClassObjectFromURL (URLMON.@)
361 HRESULT WINAPI CoGetClassObjectFromURL( REFCLSID rclsid, LPCWSTR szCodeURL, DWORD dwFileVersionMS,
362 DWORD dwFileVersionLS, LPCWSTR szContentType,
363 LPBINDCTX pBindCtx, DWORD dwClsContext, LPVOID pvReserved,
364 REFIID riid, LPVOID *ppv )
366 FIXME("(%s %s %d %d %s %p %d %p %s %p) Stub!\n", debugstr_guid(rclsid), debugstr_w(szCodeURL),
367 dwFileVersionMS, dwFileVersionLS, debugstr_w(szContentType), pBindCtx, dwClsContext, pvReserved,
368 debugstr_guid(riid), ppv);
369 return E_NOINTERFACE;
372 /***********************************************************************
373 * ReleaseBindInfo (URLMON.@)
375 * Release the resources used by the specified BINDINFO structure.
377 * PARAMS
378 * pbindinfo [I] BINDINFO to release.
380 * RETURNS
381 * Nothing.
383 void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
385 DWORD size;
387 TRACE("(%p)\n", pbindinfo);
389 if(!pbindinfo || !(size = pbindinfo->cbSize))
390 return;
392 CoTaskMemFree(pbindinfo->szExtraInfo);
393 ReleaseStgMedium(&pbindinfo->stgmedData);
395 if(offsetof(BINDINFO, szExtraInfo) < size)
396 CoTaskMemFree(pbindinfo->szCustomVerb);
399 if(pbindinfo->pUnk && offsetof(BINDINFO, pUnk) < size)
400 IUnknown_Release(pbindinfo->pUnk);
402 memset(pbindinfo, 0, size);
403 pbindinfo->cbSize = size;
406 /***********************************************************************
407 * FindMimeFromData (URLMON.@)
409 * Determines the Multipurpose Internet Mail Extensions (MIME) type from the data provided.
411 static BOOL text_html_filter(const BYTE *b, DWORD size)
413 int i;
415 if(size < 5)
416 return FALSE;
418 for(i=0; i < size-5; i++) {
419 if(b[i] == '<'
420 && (b[i+1] == 'h' || b[i+1] == 'H')
421 && (b[i+2] == 't' || b[i+2] == 'T')
422 && (b[i+3] == 'm' || b[i+3] == 'M')
423 && (b[i+4] == 'l' || b[i+4] == 'L'))
424 return TRUE;
427 return FALSE;
430 static BOOL image_gif_filter(const BYTE *b, DWORD size)
432 return size >= 6
433 && (b[0] == 'G' || b[0] == 'g')
434 && (b[1] == 'I' || b[1] == 'i')
435 && (b[2] == 'F' || b[2] == 'f')
436 && b[3] == '8'
437 && (b[4] == '7' || b[4] == '9')
438 && (b[5] == 'A' || b[5] == 'a');
441 static BOOL image_pjpeg_filter(const BYTE *b, DWORD size)
443 return size > 2 && b[0] == 0xff && b[1] == 0xd8;
446 static BOOL image_tiff_filter(const BYTE *b, DWORD size)
448 return size > 2 && b[0] == 0x4d && b[1] == 0x4d;
451 static BOOL image_xpng_filter(const BYTE *b, DWORD size)
453 static const BYTE xpng_header[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a};
454 return size > sizeof(xpng_header) && !memcmp(b, xpng_header, sizeof(xpng_header));
457 static BOOL image_bmp_filter(const BYTE *b, DWORD size)
459 return size >= 14
460 && b[0] == 0x42 && b[1] == 0x4d
461 && *(const DWORD *)(b+6) == 0;
464 static BOOL video_avi_filter(const BYTE *b, DWORD size)
466 return size > 12
467 && b[0] == 'R' && b[1] == 'I' && b[2] == 'F' && b[3] == 'F'
468 && b[8] == 'A' && b[9] == 'V' && b[10] == 'I' && b[11] == 0x20;
471 static BOOL video_mpeg_filter(const BYTE *b, DWORD size)
473 return size > 4
474 && !b[0] && !b[1] && b[2] == 0x01
475 && (b[3] == 0xb3 || b[3] == 0xba);
478 static BOOL application_pdf_filter(const BYTE *b, DWORD size)
480 return size > 4 && b[0] == 0x25 && b[1] == 0x50 && b[2] == 0x44 && b[3] == 0x46;
483 static BOOL application_xzip_filter(const BYTE *b, DWORD size)
485 return size > 2 && b[0] == 0x50 && b[1] == 0x4b;
488 static BOOL application_xgzip_filter(const BYTE *b, DWORD size)
490 return size > 2 && b[0] == 0x1f && b[1] == 0x8b;
493 static BOOL application_java_filter(const BYTE *b, DWORD size)
495 return size > 4 && b[0] == 0xca && b[1] == 0xfe && b[2] == 0xba && b[3] == 0xbe;
498 static BOOL application_xmsdownload(const BYTE *b, DWORD size)
500 return size > 2 && b[0] == 'M' && b[1] == 'Z';
503 static BOOL text_plain_filter(const BYTE *b, DWORD size)
505 const BYTE *ptr;
507 for(ptr = b; ptr < b+size-1; ptr++) {
508 if(*ptr < 0x20 && *ptr != '\n' && *ptr != '\r' && *ptr != '\t')
509 return FALSE;
512 return TRUE;
515 static BOOL application_octet_stream_filter(const BYTE *b, DWORD size)
517 return TRUE;
520 HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
521 DWORD cbSize, LPCWSTR pwzMimeProposed, DWORD dwMimeFlags,
522 LPWSTR* ppwzMimeOut, DWORD dwReserved)
524 TRACE("(%p,%s,%p,%d,%s,0x%x,%p,0x%x)\n", pBC, debugstr_w(pwzUrl), pBuffer, cbSize,
525 debugstr_w(pwzMimeProposed), dwMimeFlags, ppwzMimeOut, dwReserved);
527 if(dwMimeFlags)
528 WARN("dwMimeFlags=%08x\n", dwMimeFlags);
529 if(dwReserved)
530 WARN("dwReserved=%d\n", dwReserved);
532 /* pBC seams to not be used */
534 if(!ppwzMimeOut || (!pwzUrl && !pBuffer))
535 return E_INVALIDARG;
537 if(pwzMimeProposed && (!pBuffer || (pBuffer && !cbSize))) {
538 DWORD len;
540 if(!pwzMimeProposed)
541 return E_FAIL;
543 len = strlenW(pwzMimeProposed)+1;
544 *ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR));
545 memcpy(*ppwzMimeOut, pwzMimeProposed, len*sizeof(WCHAR));
546 return S_OK;
549 if(pBuffer) {
550 const BYTE *buf = pBuffer;
551 DWORD len;
552 LPCWSTR ret = NULL;
553 int i;
555 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
556 static const WCHAR wszImageGif[] = {'i','m','a','g','e','/','g','i','f',0};
557 static const WCHAR wszImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
558 static const WCHAR wszImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0};
559 static const WCHAR wszImageXPng[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
560 static const WCHAR wszImageBmp[] = {'i','m','a','g','e','/','b','m','p',0};
561 static const WCHAR wszVideoAvi[] = {'v','i','d','e','o','/','a','v','i',0};
562 static const WCHAR wszVideoMpeg[] = {'v','i','d','e','o','/','m','p','e','g',0};
563 static const WCHAR wszAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
564 'p','d','f',0};
565 static const WCHAR wszAppXZip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
566 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
567 static const WCHAR wszAppXGzip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
568 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
569 static const WCHAR wszAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
570 'j','a','v','a',0};
571 static const WCHAR wszAppXMSDownload[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
572 'x','-','m','s','d','o','w','n','l','o','a','d',0};
573 static const WCHAR wszTextPlain[] = {'t','e','x','t','/','p','l','a','i','n','\0'};
574 static const WCHAR wszAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
575 'o','c','t','e','t','-','s','t','r','e','a','m','\0'};
577 static const struct {
578 LPCWSTR mime;
579 BOOL (*filter)(const BYTE *,DWORD);
580 } mime_filters[] = {
581 {wszTextHtml, text_html_filter},
582 {wszImageGif, image_gif_filter},
583 {wszImagePjpeg, image_pjpeg_filter},
584 {wszImageTiff, image_tiff_filter},
585 {wszImageXPng, image_xpng_filter},
586 {wszImageBmp, image_bmp_filter},
587 {wszVideoAvi, video_avi_filter},
588 {wszVideoMpeg, video_mpeg_filter},
589 {wszAppPdf, application_pdf_filter},
590 {wszAppXZip, application_xzip_filter},
591 {wszAppXGzip, application_xgzip_filter},
592 {wszAppJava, application_java_filter},
593 {wszAppXMSDownload, application_xmsdownload},
594 {wszTextPlain, text_plain_filter},
595 {wszAppOctetStream, application_octet_stream_filter}
598 if(!cbSize)
599 return E_FAIL;
601 if(pwzMimeProposed && strcmpW(pwzMimeProposed, wszAppOctetStream)) {
602 for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) {
603 if(!strcmpW(pwzMimeProposed, mime_filters[i].mime))
604 break;
607 if(i == sizeof(mime_filters)/sizeof(*mime_filters)
608 || mime_filters[i].filter(buf, cbSize)) {
609 len = strlenW(pwzMimeProposed)+1;
610 *ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR));
611 memcpy(*ppwzMimeOut, pwzMimeProposed, len*sizeof(WCHAR));
612 return S_OK;
616 i=0;
617 while(!ret) {
618 if(mime_filters[i].filter(buf, cbSize))
619 ret = mime_filters[i].mime;
620 i++;
623 TRACE("found %s for data\n"
624 "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
625 debugstr_w(ret), buf[0],buf[1],buf[2],buf[3], buf[4],buf[5],buf[6],buf[7],
626 buf[8],buf[9],buf[10],buf[11], buf[12],buf[13],buf[14],buf[15]);
628 if(pwzMimeProposed) {
629 if(i == sizeof(mime_filters)/sizeof(*mime_filters))
630 ret = pwzMimeProposed;
632 /* text/html is a special case */
633 if(!strcmpW(pwzMimeProposed, wszTextHtml) && !strcmpW(ret, wszTextPlain))
634 ret = wszTextHtml;
637 len = strlenW(ret)+1;
638 *ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR));
639 memcpy(*ppwzMimeOut, ret, len*sizeof(WCHAR));
640 return S_OK;
643 if(pwzUrl) {
644 HKEY hkey;
645 DWORD res, size;
646 LPCWSTR ptr;
647 WCHAR mime[64];
649 static const WCHAR wszContentType[] =
650 {'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
652 ptr = strrchrW(pwzUrl, '.');
653 if(!ptr)
654 return E_FAIL;
656 res = RegOpenKeyW(HKEY_CLASSES_ROOT, ptr, &hkey);
657 if(res != ERROR_SUCCESS)
658 return HRESULT_FROM_WIN32(res);
660 size = sizeof(mime);
661 res = RegQueryValueExW(hkey, wszContentType, NULL, NULL, (LPBYTE)mime, &size);
662 RegCloseKey(hkey);
663 if(res != ERROR_SUCCESS)
664 return HRESULT_FROM_WIN32(res);
666 *ppwzMimeOut = CoTaskMemAlloc(size);
667 memcpy(*ppwzMimeOut, mime, size);
668 return S_OK;
671 return E_FAIL;
674 /***********************************************************************
675 * Extract (URLMON.@)
677 HRESULT WINAPI Extract(void *dest, LPCSTR szCabName)
679 HRESULT (WINAPI *pExtract)(void *, LPCSTR);
681 if (!hCabinet)
682 hCabinet = LoadLibraryA("cabinet.dll");
684 if (!hCabinet) return HRESULT_FROM_WIN32(GetLastError());
685 pExtract = (void *)GetProcAddress(hCabinet, "Extract");
686 if (!pExtract) return HRESULT_FROM_WIN32(GetLastError());
688 return pExtract(dest, szCabName);