2000-04-24 20:03:54 +02:00
|
|
|
/*
|
|
|
|
* UrlMon
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000 Patrik Stridvall
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-04-24 20:03:54 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2007-12-13 20:26:51 +01:00
|
|
|
#include "urlmon_main.h"
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2005-09-12 22:12:40 +02:00
|
|
|
#include "winreg.h"
|
|
|
|
|
2004-05-05 03:32:00 +02:00
|
|
|
#define NO_SHLWAPI_REG
|
|
|
|
#include "shlwapi.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-04-24 20:03:54 +02:00
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
#include "urlmon.h"
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
|
|
|
|
2005-02-03 20:38:37 +01:00
|
|
|
LONG URLMON_refCount = 0;
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
HINSTANCE URLMON_hInstance = 0;
|
2006-08-04 13:55:37 +02:00
|
|
|
static HMODULE hCabinet = NULL;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2006-07-07 20:31:59 +02:00
|
|
|
static void init_session(BOOL);
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
/***********************************************************************
|
2002-11-05 00:53:41 +01:00
|
|
|
* DllMain (URLMON.init)
|
2002-08-13 20:20:24 +02:00
|
|
|
*/
|
2002-11-05 00:53:41 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
switch(fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2003-06-30 22:53:48 +02:00
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
2002-08-13 20:20:24 +02:00
|
|
|
URLMON_hInstance = hinstDLL;
|
2006-07-07 20:31:59 +02:00
|
|
|
init_session(TRUE);
|
2002-08-13 20:20:24 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2006-08-04 13:55:37 +02:00
|
|
|
if (hCabinet)
|
|
|
|
FreeLibrary(hCabinet);
|
|
|
|
hCabinet = NULL;
|
2006-07-07 20:31:59 +02:00
|
|
|
init_session(FALSE);
|
2002-08-13 20:20:24 +02:00
|
|
|
URLMON_hInstance = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-04-24 20:03:54 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* DllInstall (URLMON.@)
|
2000-04-24 20:03:54 +02:00
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
|
2000-04-24 20:03:54 +02:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
|
2000-04-24 20:03:54 +02:00
|
|
|
debugstr_w(cmdline));
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllCanUnloadNow (URLMON.@)
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2005-02-03 20:38:37 +01:00
|
|
|
return URLMON_refCount != 0 ? S_FALSE : S_OK;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Urlmon ClassFactory
|
2002-05-05 21:40:57 +02:00
|
|
|
*/
|
2004-09-28 21:18:52 +02:00
|
|
|
typedef struct {
|
2006-07-07 20:31:25 +02:00
|
|
|
const IClassFactoryVtbl *lpClassFactoryVtbl;
|
2004-09-28 21:18:52 +02:00
|
|
|
|
|
|
|
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
|
2006-07-07 20:31:25 +02:00
|
|
|
} ClassFactory;
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
#define CLASSFACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2006-07-07 20:31:25 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}else if(IsEqualGUID(riid, &IID_IClassFactory)) {
|
|
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
2004-09-28 21:18:52 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
|
2004-09-28 21:18:52 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static ULONG WINAPI CF_AddRef(IClassFactory *iface)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
2006-07-07 20:31:25 +02:00
|
|
|
URLMON_LockModule();
|
|
|
|
return 2;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static ULONG WINAPI CF_Release(IClassFactory *iface)
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2006-07-07 20:31:25 +02:00
|
|
|
URLMON_UnlockModule();
|
|
|
|
return 1;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
|
2004-09-28 21:18:52 +02:00
|
|
|
REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
2006-07-07 20:31:25 +02:00
|
|
|
ClassFactory *This = (ClassFactory*)iface;
|
2004-09-28 21:18:52 +02:00
|
|
|
HRESULT hres;
|
|
|
|
LPUNKNOWN punk;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
if(SUCCEEDED(hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk))) {
|
|
|
|
hres = IUnknown_QueryInterface(punk, riid, ppobj);
|
|
|
|
IUnknown_Release(punk);
|
|
|
|
}
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|
|
|
{
|
2005-02-03 20:38:37 +01:00
|
|
|
TRACE("(%d)\n", dolock);
|
|
|
|
|
|
|
|
if (dolock)
|
|
|
|
URLMON_LockModule();
|
|
|
|
else
|
|
|
|
URLMON_UnlockModule();
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static const IClassFactoryVtbl ClassFactoryVtbl =
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
|
|
|
CF_QueryInterface,
|
|
|
|
CF_AddRef,
|
|
|
|
CF_Release,
|
|
|
|
CF_CreateInstance,
|
|
|
|
CF_LockServer
|
|
|
|
};
|
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static const ClassFactory FileProtocolCF =
|
|
|
|
{ &ClassFactoryVtbl, FileProtocol_Construct};
|
|
|
|
static const ClassFactory FtpProtocolCF =
|
|
|
|
{ &ClassFactoryVtbl, FtpProtocol_Construct};
|
|
|
|
static const ClassFactory HttpProtocolCF =
|
|
|
|
{ &ClassFactoryVtbl, HttpProtocol_Construct};
|
2007-11-04 17:09:20 +01:00
|
|
|
static const ClassFactory HttpSProtocolCF =
|
|
|
|
{ &ClassFactoryVtbl, HttpSProtocol_Construct};
|
2007-01-12 12:31:54 +01:00
|
|
|
static const ClassFactory MkProtocolCF =
|
|
|
|
{ &ClassFactoryVtbl, MkProtocol_Construct};
|
2006-07-07 20:31:25 +02:00
|
|
|
static const ClassFactory SecurityManagerCF =
|
|
|
|
{ &ClassFactoryVtbl, SecManagerImpl_Construct};
|
|
|
|
static const ClassFactory ZoneManagerCF =
|
|
|
|
{ &ClassFactoryVtbl, ZoneMgrImpl_Construct};
|
|
|
|
|
|
|
|
struct object_creation_info
|
|
|
|
{
|
|
|
|
const CLSID *clsid;
|
|
|
|
IClassFactory *cf;
|
2006-07-07 20:31:59 +02:00
|
|
|
LPCWSTR protocol;
|
2006-07-07 20:31:25 +02:00
|
|
|
};
|
|
|
|
|
2006-07-07 20:31:59 +02:00
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e',0};
|
|
|
|
static const WCHAR wszFtp[] = {'f','t','p',0};
|
|
|
|
static const WCHAR wszHttp[] = {'h','t','t','p',0};
|
2007-11-04 17:09:20 +01:00
|
|
|
static const WCHAR wszHttps[] = {'h','t','t','p','s',0};
|
2007-01-12 12:31:54 +01:00
|
|
|
static const WCHAR wszMk[] = {'m','k',0};
|
2006-07-07 20:31:59 +02:00
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
static const struct object_creation_info object_creation[] =
|
|
|
|
{
|
2006-07-07 20:31:59 +02:00
|
|
|
{ &CLSID_FileProtocol, CLASSFACTORY(&FileProtocolCF), wszFile },
|
|
|
|
{ &CLSID_FtpProtocol, CLASSFACTORY(&FtpProtocolCF), wszFtp },
|
|
|
|
{ &CLSID_HttpProtocol, CLASSFACTORY(&HttpProtocolCF), wszHttp },
|
2007-11-04 17:09:20 +01:00
|
|
|
{ &CLSID_HttpSProtocol, CLASSFACTORY(&HttpSProtocolCF), wszHttps },
|
2007-01-12 12:31:54 +01:00
|
|
|
{ &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk },
|
2006-07-07 20:31:59 +02:00
|
|
|
{ &CLSID_InternetSecurityManager, CLASSFACTORY(&SecurityManagerCF), NULL },
|
|
|
|
{ &CLSID_InternetZoneManager, CLASSFACTORY(&ZoneManagerCF), NULL }
|
2006-07-07 20:31:25 +02:00
|
|
|
};
|
|
|
|
|
2006-07-07 20:31:59 +02:00
|
|
|
static void init_session(BOOL init)
|
|
|
|
{
|
|
|
|
IInternetSession *session;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
CoInternetGetSession(0, &session, 0);
|
|
|
|
|
|
|
|
for(i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) {
|
|
|
|
if(object_creation[i].protocol) {
|
|
|
|
if(init)
|
2007-04-01 14:43:39 +02:00
|
|
|
{
|
2006-07-07 20:31:59 +02:00
|
|
|
IInternetSession_RegisterNameSpace(session, object_creation[i].cf,
|
|
|
|
object_creation[i].clsid, object_creation[i].protocol, 0, NULL, 0);
|
2007-04-01 14:43:39 +02:00
|
|
|
/* make sure that the AddRef on the class factory doesn't keep us loaded */
|
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
2006-07-07 20:31:59 +02:00
|
|
|
else
|
2007-04-01 14:43:39 +02:00
|
|
|
{
|
|
|
|
/* make sure that the Release on the class factory doesn't unload us */
|
|
|
|
URLMON_LockModule();
|
2006-07-07 20:31:59 +02:00
|
|
|
IInternetSession_UnregisterNameSpace(session, object_creation[i].cf,
|
|
|
|
object_creation[i].protocol);
|
2007-04-01 14:43:39 +02:00
|
|
|
}
|
2006-07-07 20:31:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetSession_Release(session);
|
|
|
|
}
|
|
|
|
|
2004-09-28 21:18:52 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* DllGetClassObject [URLMON.@]
|
|
|
|
* Retrieves class object from a DLL object
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Docs say returns STDAPI
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* rclsid [I] CLSID for the class object
|
|
|
|
* riid [I] Reference to identifier of interface for class object
|
|
|
|
* ppv [O] Address of variable to receive interface pointer for riid
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
|
|
|
|
* E_UNEXPECTED
|
|
|
|
*/
|
|
|
|
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
2004-09-28 21:18:52 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(object_creation[i].clsid, rclsid))
|
2006-07-07 20:31:25 +02:00
|
|
|
return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv);
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
2006-07-07 20:31:25 +02:00
|
|
|
FIXME("%s: no class found.\n", debugstr_guid(rclsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
2004-09-28 21:18:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-29 16:26:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServerEx (URLMON.@)
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllRegisterServerEx(void)
|
2000-04-29 16:26:13 +02:00
|
|
|
{
|
|
|
|
FIXME("(void): stub\n");
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2000-11-01 02:46:24 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* UrlMkSetSessionOption (URLMON.@)
|
|
|
|
*/
|
2005-06-10 21:29:16 +02:00
|
|
|
HRESULT WINAPI UrlMkSetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength,
|
2004-11-30 22:14:21 +01:00
|
|
|
DWORD Reserved)
|
2000-11-01 02:46:24 +01:00
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%#x, %p, %#x): stub\n", dwOption, pBuffer, dwBufferLength);
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-21 11:44:47 +02:00
|
|
|
static const CHAR Agent[] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
|
|
|
|
|
2002-03-21 02:25:42 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* ObtainUserAgentString (URLMON.@)
|
|
|
|
*/
|
2005-06-10 21:29:16 +02:00
|
|
|
HRESULT WINAPI ObtainUserAgentString(DWORD dwOption, LPSTR pcszUAOut, DWORD *cbSize)
|
2002-03-21 02:25:42 +01:00
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%d, %p, %p): stub\n", dwOption, pcszUAOut, cbSize);
|
2002-03-21 02:25:42 +01:00
|
|
|
|
2007-07-10 04:49:58 +02:00
|
|
|
if (pcszUAOut == NULL || cbSize == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (*cbSize < sizeof(Agent))
|
|
|
|
{
|
|
|
|
*cbSize = sizeof(Agent);
|
|
|
|
return E_OUTOFMEMORY;
|
2002-03-21 02:25:42 +01:00
|
|
|
}
|
|
|
|
|
2005-06-21 11:44:47 +02:00
|
|
|
if (sizeof(Agent) < *cbSize)
|
|
|
|
*cbSize = sizeof(Agent);
|
2007-07-10 04:49:58 +02:00
|
|
|
lstrcpynA(pcszUAOut, Agent, *cbSize);
|
2005-06-21 11:44:47 +02:00
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
return S_OK;
|
2002-04-09 00:45:34 +02:00
|
|
|
}
|
2004-05-05 03:32:00 +02:00
|
|
|
|
2004-09-09 21:17:57 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* IsValidURL (URLMON.@)
|
|
|
|
*
|
|
|
|
* Determines if a specified string is a valid URL.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pBC [I] ignored, must be NULL.
|
|
|
|
* szURL [I] string that represents the URL in question.
|
|
|
|
* dwReserved [I] reserved and must be zero.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: S_FALSE.
|
|
|
|
* returns E_INVALIDARG if one or more of the args is invalid.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* test functionality against windows to see what a valid URL is.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI IsValidURL(LPBC pBC, LPCWSTR szURL, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p, %s, %d): stub\n", pBC, debugstr_w(szURL), dwReserved);
|
2004-09-09 21:17:57 +02:00
|
|
|
|
|
|
|
if (pBC != NULL || dwReserved != 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-04-11 14:58:58 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* FaultInIEFeature (URLMON.@)
|
|
|
|
*
|
|
|
|
* Undocumented. Appears to be used by native shdocvw.dll.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI FaultInIEFeature( HWND hwnd, uCLSSPEC * pClassSpec,
|
|
|
|
QUERYCONTEXT *pQuery, DWORD flags )
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("%p %p %p %08x\n", hwnd, pClassSpec, pQuery, flags);
|
2005-04-11 14:58:58 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2005-05-05 11:50:57 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* CoGetClassObjectFromURL (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoGetClassObjectFromURL( REFCLSID rclsid, LPCWSTR szCodeURL, DWORD dwFileVersionMS,
|
|
|
|
DWORD dwFileVersionLS, LPCWSTR szContentType,
|
|
|
|
LPBINDCTX pBindCtx, DWORD dwClsContext, LPVOID pvReserved,
|
2005-05-06 16:32:48 +02:00
|
|
|
REFIID riid, LPVOID *ppv )
|
2005-05-05 11:50:57 +02:00
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%s %s %d %d %s %p %d %p %s %p) Stub!\n", debugstr_guid(rclsid), debugstr_w(szCodeURL),
|
2005-05-05 11:50:57 +02:00
|
|
|
dwFileVersionMS, dwFileVersionLS, debugstr_w(szContentType), pBindCtx, dwClsContext, pvReserved,
|
|
|
|
debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2005-09-08 13:01:46 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ReleaseBindInfo (URLMON.@)
|
|
|
|
*
|
|
|
|
* Release the resources used by the specified BINDINFO structure.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pbindinfo [I] BINDINFO to release.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
|
|
|
void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
|
|
|
|
{
|
2006-05-25 18:43:34 +02:00
|
|
|
DWORD size;
|
|
|
|
|
2005-09-08 13:01:46 +02:00
|
|
|
TRACE("(%p)\n", pbindinfo);
|
|
|
|
|
2006-05-25 18:43:34 +02:00
|
|
|
if(!pbindinfo || !(size = pbindinfo->cbSize))
|
2005-09-08 13:01:46 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
CoTaskMemFree(pbindinfo->szExtraInfo);
|
2006-05-25 18:43:34 +02:00
|
|
|
ReleaseStgMedium(&pbindinfo->stgmedData);
|
|
|
|
|
|
|
|
if(offsetof(BINDINFO, szExtraInfo) < size)
|
|
|
|
CoTaskMemFree(pbindinfo->szCustomVerb);
|
2005-09-08 13:01:46 +02:00
|
|
|
|
2006-05-25 18:43:34 +02:00
|
|
|
if(pbindinfo->pUnk && offsetof(BINDINFO, pUnk) < size)
|
2005-09-08 13:01:46 +02:00
|
|
|
IUnknown_Release(pbindinfo->pUnk);
|
2006-05-25 18:43:34 +02:00
|
|
|
|
|
|
|
memset(pbindinfo, 0, size);
|
|
|
|
pbindinfo->cbSize = size;
|
2005-09-08 13:01:46 +02:00
|
|
|
}
|
2005-09-12 22:12:40 +02:00
|
|
|
|
2008-01-31 18:09:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CopyStgMedium (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CopyStgMedium(const STGMEDIUM *src, STGMEDIUM *dst)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", src, dst);
|
|
|
|
|
|
|
|
if(!src || !dst)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
memcpy(dst, src, sizeof(STGMEDIUM));
|
|
|
|
|
|
|
|
switch(dst->tymed) {
|
|
|
|
case TYMED_NULL:
|
|
|
|
break;
|
2008-02-18 01:04:10 +01:00
|
|
|
case TYMED_FILE:
|
|
|
|
if(src->u.lpszFileName && !src->pUnkForRelease) {
|
|
|
|
DWORD size = (strlenW(src->u.lpszFileName)+1)*sizeof(WCHAR);
|
|
|
|
dst->u.lpszFileName = CoTaskMemAlloc(size);
|
|
|
|
memcpy(dst->u.lpszFileName, src->u.lpszFileName, size);
|
|
|
|
}
|
|
|
|
break;
|
2008-01-31 18:09:04 +01:00
|
|
|
case TYMED_ISTREAM:
|
|
|
|
if(dst->u.pstm)
|
|
|
|
IStream_AddRef(dst->u.pstm);
|
|
|
|
break;
|
|
|
|
case TYMED_ISTORAGE:
|
|
|
|
if(dst->u.pstg)
|
|
|
|
IStorage_AddRef(dst->u.pstg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unimplemented tymed %d\n", src->tymed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dst->pUnkForRelease)
|
|
|
|
IUnknown_AddRef(dst->pUnkForRelease);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-23 12:53:07 +02:00
|
|
|
static BOOL text_richtext_filter(const BYTE *b, DWORD size)
|
|
|
|
{
|
|
|
|
return size > 5 && !memcmp(b, "{\\rtf", 5);
|
|
|
|
}
|
2007-10-21 16:24:47 +02:00
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL text_html_filter(const BYTE *b, DWORD size)
|
2006-05-30 20:06:02 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(size < 5)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for(i=0; i < size-5; i++) {
|
|
|
|
if(b[i] == '<'
|
|
|
|
&& (b[i+1] == 'h' || b[i+1] == 'H')
|
|
|
|
&& (b[i+2] == 't' || b[i+2] == 'T')
|
|
|
|
&& (b[i+3] == 'm' || b[i+3] == 'M')
|
|
|
|
&& (b[i+4] == 'l' || b[i+4] == 'L'))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-18 01:05:14 +01:00
|
|
|
static BOOL audio_basic_filter(const BYTE *b, DWORD size)
|
|
|
|
{
|
|
|
|
return size > 4
|
|
|
|
&& b[0] == '.' && b[1] == 's' && b[2] == 'n' && b[3] == 'd';
|
|
|
|
}
|
|
|
|
|
2007-10-23 12:53:29 +02:00
|
|
|
static BOOL audio_wav_filter(const BYTE *b, DWORD size)
|
|
|
|
{
|
|
|
|
return size > 12
|
|
|
|
&& b[0] == 'R' && b[1] == 'I' && b[2] == 'F' && b[3] == 'F'
|
|
|
|
&& b[8] == 'W' && b[9] == 'A' && b[10] == 'V' && b[11] == 'E';
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL image_gif_filter(const BYTE *b, DWORD size)
|
2006-07-06 20:04:26 +02:00
|
|
|
{
|
|
|
|
return size >= 6
|
|
|
|
&& (b[0] == 'G' || b[0] == 'g')
|
|
|
|
&& (b[1] == 'I' || b[1] == 'i')
|
|
|
|
&& (b[2] == 'F' || b[2] == 'f')
|
|
|
|
&& b[3] == '8'
|
|
|
|
&& (b[4] == '7' || b[4] == '9')
|
|
|
|
&& (b[5] == 'A' || b[5] == 'a');
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL image_pjpeg_filter(const BYTE *b, DWORD size)
|
2006-07-06 20:02:24 +02:00
|
|
|
{
|
2006-10-23 23:39:42 +02:00
|
|
|
return size > 2 && b[0] == 0xff && b[1] == 0xd8;
|
2006-07-06 20:02:24 +02:00
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL image_tiff_filter(const BYTE *b, DWORD size)
|
2006-10-21 22:56:23 +02:00
|
|
|
{
|
2006-10-23 23:39:42 +02:00
|
|
|
return size > 2 && b[0] == 0x4d && b[1] == 0x4d;
|
2006-10-21 22:56:23 +02:00
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL image_xpng_filter(const BYTE *b, DWORD size)
|
2006-07-06 21:11:04 +02:00
|
|
|
{
|
|
|
|
static const BYTE xpng_header[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a};
|
2006-10-23 23:39:42 +02:00
|
|
|
return size > sizeof(xpng_header) && !memcmp(b, xpng_header, sizeof(xpng_header));
|
2006-07-06 21:11:04 +02:00
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL image_bmp_filter(const BYTE *b, DWORD size)
|
2006-07-06 20:38:27 +02:00
|
|
|
{
|
|
|
|
return size >= 14
|
2006-10-23 23:39:42 +02:00
|
|
|
&& b[0] == 0x42 && b[1] == 0x4d
|
2006-11-16 22:55:05 +01:00
|
|
|
&& *(const DWORD *)(b+6) == 0;
|
2006-07-06 20:38:27 +02:00
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL video_avi_filter(const BYTE *b, DWORD size)
|
2006-10-23 23:38:31 +02:00
|
|
|
{
|
|
|
|
return size > 12
|
|
|
|
&& b[0] == 'R' && b[1] == 'I' && b[2] == 'F' && b[3] == 'F'
|
|
|
|
&& b[8] == 'A' && b[9] == 'V' && b[10] == 'I' && b[11] == 0x20;
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL video_mpeg_filter(const BYTE *b, DWORD size)
|
2006-10-23 23:40:58 +02:00
|
|
|
{
|
|
|
|
return size > 4
|
|
|
|
&& !b[0] && !b[1] && b[2] == 0x01
|
|
|
|
&& (b[3] == 0xb3 || b[3] == 0xba);
|
|
|
|
}
|
|
|
|
|
2007-10-23 12:53:49 +02:00
|
|
|
static BOOL application_postscript_filter(const BYTE *b, DWORD size)
|
|
|
|
{
|
|
|
|
return size > 2 && b[0] == '%' && b[1] == '!';
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL application_pdf_filter(const BYTE *b, DWORD size)
|
2006-12-06 18:20:03 +01:00
|
|
|
{
|
|
|
|
return size > 4 && b[0] == 0x25 && b[1] == 0x50 && b[2] == 0x44 && b[3] == 0x46;
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL application_xzip_filter(const BYTE *b, DWORD size)
|
2006-12-06 18:18:23 +01:00
|
|
|
{
|
|
|
|
return size > 2 && b[0] == 0x50 && b[1] == 0x4b;
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL application_xgzip_filter(const BYTE *b, DWORD size)
|
2006-12-06 18:17:26 +01:00
|
|
|
{
|
|
|
|
return size > 2 && b[0] == 0x1f && b[1] == 0x8b;
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL application_java_filter(const BYTE *b, DWORD size)
|
2006-12-06 18:19:14 +01:00
|
|
|
{
|
|
|
|
return size > 4 && b[0] == 0xca && b[1] == 0xfe && b[2] == 0xba && b[3] == 0xbe;
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL application_xmsdownload(const BYTE *b, DWORD size)
|
2006-12-12 21:53:48 +01:00
|
|
|
{
|
|
|
|
return size > 2 && b[0] == 'M' && b[1] == 'Z';
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL text_plain_filter(const BYTE *b, DWORD size)
|
2006-05-30 20:05:31 +02:00
|
|
|
{
|
2006-10-23 23:39:42 +02:00
|
|
|
const BYTE *ptr;
|
2006-05-30 20:05:31 +02:00
|
|
|
|
2006-10-23 23:39:42 +02:00
|
|
|
for(ptr = b; ptr < b+size-1; ptr++) {
|
2006-05-30 20:05:31 +02:00
|
|
|
if(*ptr < 0x20 && *ptr != '\n' && *ptr != '\r' && *ptr != '\t')
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-02-06 08:42:22 +01:00
|
|
|
static BOOL application_octet_stream_filter(const BYTE *b, DWORD size)
|
2006-05-30 20:05:31 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-10-21 16:24:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FindMimeFromData (URLMON.@)
|
|
|
|
*
|
|
|
|
* Determines the Multipurpose Internet Mail Extensions (MIME) type from the data provided.
|
|
|
|
*/
|
2005-09-12 22:12:40 +02:00
|
|
|
HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
|
|
|
|
DWORD cbSize, LPCWSTR pwzMimeProposed, DWORD dwMimeFlags,
|
|
|
|
LPWSTR* ppwzMimeOut, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p,%s,%p,%d,%s,0x%x,%p,0x%x)\n", pBC, debugstr_w(pwzUrl), pBuffer, cbSize,
|
2005-09-12 22:12:40 +02:00
|
|
|
debugstr_w(pwzMimeProposed), dwMimeFlags, ppwzMimeOut, dwReserved);
|
|
|
|
|
|
|
|
if(dwMimeFlags)
|
2006-10-05 23:49:11 +02:00
|
|
|
WARN("dwMimeFlags=%08x\n", dwMimeFlags);
|
2005-09-12 22:12:40 +02:00
|
|
|
if(dwReserved)
|
2006-10-05 23:49:11 +02:00
|
|
|
WARN("dwReserved=%d\n", dwReserved);
|
2005-09-12 22:12:40 +02:00
|
|
|
|
|
|
|
/* pBC seams to not be used */
|
|
|
|
|
|
|
|
if(!ppwzMimeOut || (!pwzUrl && !pBuffer))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-07-06 20:02:49 +02:00
|
|
|
if(pwzMimeProposed && (!pBuffer || (pBuffer && !cbSize))) {
|
2005-09-12 22:12:40 +02:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if(!pwzMimeProposed)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
len = strlenW(pwzMimeProposed)+1;
|
|
|
|
*ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR));
|
|
|
|
memcpy(*ppwzMimeOut, pwzMimeProposed, len*sizeof(WCHAR));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pBuffer) {
|
2007-02-06 08:42:22 +01:00
|
|
|
const BYTE *buf = pBuffer;
|
2005-09-12 22:12:40 +02:00
|
|
|
DWORD len;
|
2006-05-30 20:05:31 +02:00
|
|
|
LPCWSTR ret = NULL;
|
2006-07-06 20:02:49 +02:00
|
|
|
int i;
|
2005-09-12 22:12:40 +02:00
|
|
|
|
2006-05-30 20:06:02 +02:00
|
|
|
static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
|
2007-10-23 12:53:07 +02:00
|
|
|
static const WCHAR wszTextRichtext[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
|
2008-02-18 01:05:14 +01:00
|
|
|
static const WCHAR wszAudioBasic[] = {'a','u','d','i','o','/','b','a','s','i','c',0};
|
2007-10-23 12:53:29 +02:00
|
|
|
static const WCHAR wszAudioWav[] = {'a','u','d','i','o','/','w','a','v',0};
|
2006-07-06 20:04:26 +02:00
|
|
|
static const WCHAR wszImageGif[] = {'i','m','a','g','e','/','g','i','f',0};
|
2006-07-06 20:02:24 +02:00
|
|
|
static const WCHAR wszImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
|
2006-10-21 22:56:23 +02:00
|
|
|
static const WCHAR wszImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0};
|
2006-07-06 21:11:04 +02:00
|
|
|
static const WCHAR wszImageXPng[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
|
2006-07-06 20:38:27 +02:00
|
|
|
static const WCHAR wszImageBmp[] = {'i','m','a','g','e','/','b','m','p',0};
|
2006-10-23 23:38:31 +02:00
|
|
|
static const WCHAR wszVideoAvi[] = {'v','i','d','e','o','/','a','v','i',0};
|
2006-10-23 23:40:58 +02:00
|
|
|
static const WCHAR wszVideoMpeg[] = {'v','i','d','e','o','/','m','p','e','g',0};
|
2007-10-23 12:53:49 +02:00
|
|
|
static const WCHAR wszAppPostscript[] =
|
|
|
|
{'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0};
|
2006-12-06 18:20:03 +01:00
|
|
|
static const WCHAR wszAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'p','d','f',0};
|
2006-12-06 18:18:23 +01:00
|
|
|
static const WCHAR wszAppXZip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
|
2006-12-06 18:17:26 +01:00
|
|
|
static const WCHAR wszAppXGzip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
|
2006-12-06 18:19:14 +01:00
|
|
|
static const WCHAR wszAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'j','a','v','a',0};
|
2006-12-12 21:53:48 +01:00
|
|
|
static const WCHAR wszAppXMSDownload[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'x','-','m','s','d','o','w','n','l','o','a','d',0};
|
2005-09-12 22:12:40 +02:00
|
|
|
static const WCHAR wszTextPlain[] = {'t','e','x','t','/','p','l','a','i','n','\0'};
|
2006-05-30 20:05:31 +02:00
|
|
|
static const WCHAR wszAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'o','c','t','e','t','-','s','t','r','e','a','m','\0'};
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
LPCWSTR mime;
|
2007-02-06 08:42:22 +01:00
|
|
|
BOOL (*filter)(const BYTE *,DWORD);
|
2006-05-30 20:05:31 +02:00
|
|
|
} mime_filters[] = {
|
2006-05-30 20:06:02 +02:00
|
|
|
{wszTextHtml, text_html_filter},
|
2007-10-23 12:53:07 +02:00
|
|
|
{wszTextRichtext, text_richtext_filter},
|
2008-01-29 00:24:47 +01:00
|
|
|
/* {wszAudioXAiff, audio_xaiff_filter}, */
|
2008-02-18 01:05:14 +01:00
|
|
|
{wszAudioBasic, audio_basic_filter},
|
2007-10-23 12:53:29 +02:00
|
|
|
{wszAudioWav, audio_wav_filter},
|
2006-07-06 20:04:26 +02:00
|
|
|
{wszImageGif, image_gif_filter},
|
2006-07-06 20:02:24 +02:00
|
|
|
{wszImagePjpeg, image_pjpeg_filter},
|
2006-10-21 22:56:23 +02:00
|
|
|
{wszImageTiff, image_tiff_filter},
|
2006-07-06 21:11:04 +02:00
|
|
|
{wszImageXPng, image_xpng_filter},
|
2008-01-29 00:24:47 +01:00
|
|
|
/* {wszImageXBitmap, image_xbitmap_filter}, */
|
2006-07-06 20:38:27 +02:00
|
|
|
{wszImageBmp, image_bmp_filter},
|
2008-01-29 00:24:47 +01:00
|
|
|
/* {wszImageXJg, image_xjg_filter}, */
|
|
|
|
/* {wszImageXEmf, image_xemf_filter}, */
|
|
|
|
/* {wszImageXWmf, image_xwmf_filter}, */
|
2006-10-23 23:38:31 +02:00
|
|
|
{wszVideoAvi, video_avi_filter},
|
2006-10-23 23:40:58 +02:00
|
|
|
{wszVideoMpeg, video_mpeg_filter},
|
2007-10-23 12:53:49 +02:00
|
|
|
{wszAppPostscript, application_postscript_filter},
|
2008-01-29 00:24:47 +01:00
|
|
|
/* {wszAppBase64, application_base64_filter}, */
|
|
|
|
/* {wszAppMacbinhex40, application_macbinhex40_filter}, */
|
2006-12-06 18:20:03 +01:00
|
|
|
{wszAppPdf, application_pdf_filter},
|
2008-01-29 00:24:47 +01:00
|
|
|
/* {wszAppXCompressed, application_xcompressed_filter}, */
|
2006-12-06 18:18:23 +01:00
|
|
|
{wszAppXZip, application_xzip_filter},
|
2006-12-06 18:17:26 +01:00
|
|
|
{wszAppXGzip, application_xgzip_filter},
|
2006-12-06 18:19:14 +01:00
|
|
|
{wszAppJava, application_java_filter},
|
2006-12-12 21:53:48 +01:00
|
|
|
{wszAppXMSDownload, application_xmsdownload},
|
2006-05-30 20:05:31 +02:00
|
|
|
{wszTextPlain, text_plain_filter},
|
|
|
|
{wszAppOctetStream, application_octet_stream_filter}
|
|
|
|
};
|
2005-09-12 22:12:40 +02:00
|
|
|
|
|
|
|
if(!cbSize)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2006-07-06 20:02:49 +02:00
|
|
|
if(pwzMimeProposed && strcmpW(pwzMimeProposed, wszAppOctetStream)) {
|
|
|
|
for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) {
|
|
|
|
if(!strcmpW(pwzMimeProposed, mime_filters[i].mime))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i == sizeof(mime_filters)/sizeof(*mime_filters)
|
2006-10-23 23:39:42 +02:00
|
|
|
|| mime_filters[i].filter(buf, cbSize)) {
|
2006-07-06 20:02:49 +02:00
|
|
|
len = strlenW(pwzMimeProposed)+1;
|
|
|
|
*ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR));
|
|
|
|
memcpy(*ppwzMimeOut, pwzMimeProposed, len*sizeof(WCHAR));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i=0;
|
2006-05-30 20:05:31 +02:00
|
|
|
while(!ret) {
|
2006-10-23 23:39:42 +02:00
|
|
|
if(mime_filters[i].filter(buf, cbSize))
|
2006-05-30 20:05:31 +02:00
|
|
|
ret = mime_filters[i].mime;
|
|
|
|
i++;
|
2005-09-12 22:12:40 +02:00
|
|
|
}
|
|
|
|
|
2006-10-23 23:39:42 +02:00
|
|
|
TRACE("found %s for data\n"
|
|
|
|
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
|
|
debugstr_w(ret), buf[0],buf[1],buf[2],buf[3], buf[4],buf[5],buf[6],buf[7],
|
|
|
|
buf[8],buf[9],buf[10],buf[11], buf[12],buf[13],buf[14],buf[15]);
|
|
|
|
|
2006-07-06 20:02:49 +02:00
|
|
|
if(pwzMimeProposed) {
|
|
|
|
if(i == sizeof(mime_filters)/sizeof(*mime_filters))
|
|
|
|
ret = pwzMimeProposed;
|
|
|
|
|
|
|
|
/* text/html is a special case */
|
2006-10-23 23:38:31 +02:00
|
|
|
if(!strcmpW(pwzMimeProposed, wszTextHtml) && !strcmpW(ret, wszTextPlain))
|
2006-07-06 20:02:49 +02:00
|
|
|
ret = wszTextHtml;
|
|
|
|
}
|
|
|
|
|
2005-09-12 22:12:40 +02:00
|
|
|
len = strlenW(ret)+1;
|
|
|
|
*ppwzMimeOut = CoTaskMemAlloc(len*sizeof(WCHAR));
|
|
|
|
memcpy(*ppwzMimeOut, ret, len*sizeof(WCHAR));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pwzUrl) {
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD res, size;
|
|
|
|
LPCWSTR ptr;
|
|
|
|
WCHAR mime[64];
|
|
|
|
|
|
|
|
static const WCHAR wszContentType[] =
|
|
|
|
{'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
|
|
|
|
|
|
|
|
ptr = strrchrW(pwzUrl, '.');
|
|
|
|
if(!ptr)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CLASSES_ROOT, ptr, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
2007-03-01 20:21:55 +01:00
|
|
|
return HRESULT_FROM_WIN32(res);
|
2005-09-12 22:12:40 +02:00
|
|
|
|
|
|
|
size = sizeof(mime);
|
|
|
|
res = RegQueryValueExW(hkey, wszContentType, NULL, NULL, (LPBYTE)mime, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
2007-03-01 20:21:55 +01:00
|
|
|
return HRESULT_FROM_WIN32(res);
|
2005-09-12 22:12:40 +02:00
|
|
|
|
|
|
|
*ppwzMimeOut = CoTaskMemAlloc(size);
|
|
|
|
memcpy(*ppwzMimeOut, mime, size);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2006-08-04 13:55:37 +02:00
|
|
|
|
2007-10-21 16:24:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetClassFileOrMime (URLMON.@)
|
|
|
|
*
|
|
|
|
* Determines the class ID from the bind context, file name or MIME type.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetClassFileOrMime(LPBC pBC, LPCWSTR pszFilename,
|
|
|
|
LPVOID pBuffer, DWORD cbBuffer, LPCWSTR pszMimeType, DWORD dwReserved,
|
|
|
|
CLSID *pclsid)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s, %p, %d, %p, 0x%08x, %p): stub\n", pBC,
|
|
|
|
debugstr_w(pszFilename), pBuffer, cbBuffer, debugstr_w(pszMimeType),
|
|
|
|
dwReserved, pclsid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2006-08-04 13:55:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Extract (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI Extract(void *dest, LPCSTR szCabName)
|
|
|
|
{
|
|
|
|
HRESULT (WINAPI *pExtract)(void *, LPCSTR);
|
|
|
|
|
|
|
|
if (!hCabinet)
|
|
|
|
hCabinet = LoadLibraryA("cabinet.dll");
|
|
|
|
|
|
|
|
if (!hCabinet) return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
pExtract = (void *)GetProcAddress(hCabinet, "Extract");
|
|
|
|
if (!pExtract) return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
|
|
|
|
return pExtract(dest, szCabName);
|
|
|
|
}
|