2005-06-27 11:50:56 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Jacek Caban
|
|
|
|
*
|
|
|
|
* 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
|
2005-06-27 11:50:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2018-05-15 15:26:58 +02:00
|
|
|
typedef struct {
|
2018-05-15 15:27:27 +02:00
|
|
|
IUnknown IUnknown_inner;
|
2018-05-15 15:26:58 +02:00
|
|
|
IInternetProtocol IInternetProtocol_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
BYTE *data;
|
|
|
|
ULONG data_len;
|
|
|
|
ULONG cur;
|
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
IUnknown *outer;
|
2018-05-15 15:26:58 +02:00
|
|
|
} InternetProtocol;
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
/********************************************************************
|
|
|
|
* common ProtocolFactory implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
2011-01-05 00:43:29 +01:00
|
|
|
IInternetProtocolInfo IInternetProtocolInfo_iface;
|
|
|
|
IClassFactory IClassFactory_iface;
|
2005-06-27 11:50:56 +02:00
|
|
|
} ProtocolFactory;
|
|
|
|
|
2011-01-05 00:43:29 +01:00
|
|
|
static inline ProtocolFactory *impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ProtocolFactory, IInternetProtocolInfo_iface);
|
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-05 00:43:29 +01:00
|
|
|
ProtocolFactory *This = impl_from_IInternetProtocolInfo(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2011-01-05 00:43:29 +01:00
|
|
|
*ppv = &This->IInternetProtocolInfo_iface;
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolInfo %p)\n", This, ppv);
|
2011-01-05 00:43:29 +01:00
|
|
|
*ppv = &This->IInternetProtocolInfo_iface;
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IClassFactory, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", This, ppv);
|
2011-01-05 00:43:29 +01:00
|
|
|
*ppv = &This->IClassFactory_iface;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!*ppv) {
|
|
|
|
WARN("unknown interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocolInfo_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
|
|
|
|
{
|
2008-12-05 20:04:03 +01:00
|
|
|
TRACE("(%p)\n", iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
|
|
|
|
{
|
2008-12-05 20:04:03 +01:00
|
|
|
TRACE("(%p)\n", iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-08-12 18:43:16 +02:00
|
|
|
static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
|
|
|
|
LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult,
|
|
|
|
DWORD cchResult, DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%s %s %08x %p %d %p %d)\n", iface, debugstr_w(pwzBaseUrl),
|
2006-08-12 18:43:16 +02:00
|
|
|
debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
|
|
|
|
pcchResult, dwReserved);
|
|
|
|
|
|
|
|
return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
|
|
|
|
}
|
|
|
|
|
2006-12-12 21:52:46 +01:00
|
|
|
static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
|
|
|
|
LPCWSTR pwzUrl2, DWORD dwCompareFlags)
|
|
|
|
{
|
|
|
|
TRACE("%p)->(%s %s %08x)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-01-05 00:43:29 +01:00
|
|
|
static inline ProtocolFactory *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ProtocolFactory, IClassFactory_iface);
|
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-05 00:43:29 +01:00
|
|
|
ProtocolFactory *This = impl_from_IClassFactory(iface);
|
|
|
|
return IInternetProtocolInfo_QueryInterface(&This->IInternetProtocolInfo_iface, riid, ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
|
|
|
{
|
2011-01-05 00:43:29 +01:00
|
|
|
ProtocolFactory *This = impl_from_IClassFactory(iface);
|
|
|
|
return IInternetProtocolInfo_AddRef(&This->IInternetProtocolInfo_iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
|
|
|
|
{
|
2011-01-05 00:43:29 +01:00
|
|
|
ProtocolFactory *This = impl_from_IClassFactory(iface);
|
|
|
|
return IInternetProtocolInfo_Release(&This->IInternetProtocolInfo_iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
|
|
|
|
{
|
2008-12-05 20:04:03 +01:00
|
|
|
TRACE("(%p)->(%x)\n", iface, dolock);
|
2005-06-27 11:50:56 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
static inline InternetProtocol *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, InternetProtocol, IUnknown_inner);
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:26:58 +02:00
|
|
|
static inline InternetProtocol *impl_from_IInternetProtocol(IInternetProtocol *iface)
|
2011-01-06 16:16:55 +01:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
return CONTAINING_RECORD(iface, InternetProtocol, IInternetProtocol_iface);
|
2011-01-06 16:16:55 +01:00
|
|
|
}
|
2005-08-15 12:23:35 +02:00
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
static HRESULT WINAPI Protocol_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:27:27 +02:00
|
|
|
InternetProtocol *This = impl_from_IUnknown(iface);
|
2005-08-11 19:04:45 +02:00
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
2018-05-15 15:27:27 +02:00
|
|
|
*ppv = &This->IUnknown_inner;
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
2011-01-06 16:16:55 +01:00
|
|
|
*ppv = &This->IInternetProtocol_iface;
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
2011-01-06 16:16:55 +01:00
|
|
|
*ppv = &This->IInternetProtocol_iface;
|
2018-05-15 15:27:27 +02:00
|
|
|
}else {
|
|
|
|
if(IsEqualGUID(&IID_IServiceProvider, riid))
|
|
|
|
FIXME("IServiceProvider is not implemented\n");
|
|
|
|
*ppv = NULL;
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
static ULONG WINAPI Protocol_AddRef(IUnknown *iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:27:27 +02:00
|
|
|
InternetProtocol *This = impl_from_IUnknown(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", iface, ref);
|
2018-05-15 15:27:27 +02:00
|
|
|
return ref;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
static ULONG WINAPI Protocol_Release(IUnknown *iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:27:27 +02:00
|
|
|
InternetProtocol *This = impl_from_IUnknown(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%x\n", iface, ref);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-02 11:49:06 +02:00
|
|
|
if(!ref) {
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This->data);
|
|
|
|
heap_free(This);
|
2005-08-02 11:49:06 +02:00
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl ProtocolUnkVtbl = {
|
|
|
|
Protocol_QueryInterface,
|
|
|
|
Protocol_AddRef,
|
|
|
|
Protocol_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
|
|
|
return IUnknown_QueryInterface(This->outer, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocol_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
|
|
|
return IUnknown_AddRef(This->outer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocol_Release(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
|
|
|
return IUnknown_Release(This->outer);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
2005-06-27 11:50:56 +02:00
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
2005-08-03 12:56:26 +02:00
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Suspend(IInternetProtocol *iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Resume(IInternetProtocol *iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
if(!This->data)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
*pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
|
|
|
|
|
|
|
|
if(!*pcbRead)
|
|
|
|
return S_FALSE;
|
|
|
|
|
2008-01-04 01:49:36 +01:00
|
|
|
memcpy(pv, This->data+This->cur, *pcbRead);
|
2005-08-03 12:56:26 +02:00
|
|
|
This->cur += *pcbRead;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
2005-06-27 11:50:56 +02:00
|
|
|
DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
|
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, dwOptions);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
static HRESULT WINAPI InternetProtocol_UnlockRequest(IInternetProtocol *iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
static HRESULT create_protocol_instance(const IInternetProtocolVtbl *protocol_vtbl,
|
|
|
|
IUnknown *outer, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
InternetProtocol *protocol;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(outer && !IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol = heap_alloc_zero(sizeof(InternetProtocol));
|
|
|
|
protocol->IUnknown_inner.lpVtbl = &ProtocolUnkVtbl;
|
|
|
|
protocol->IInternetProtocol_iface.lpVtbl = protocol_vtbl;
|
|
|
|
protocol->outer = outer ? outer : &protocol->IUnknown_inner;
|
|
|
|
protocol->ref = 1;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(&protocol->IUnknown_inner, riid, ppv);
|
|
|
|
IUnknown_Release(&protocol->IUnknown_inner);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2018-05-15 15:27:11 +02:00
|
|
|
/********************************************************************
|
|
|
|
* about protocol implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
|
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
|
|
|
{
|
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
|
|
|
BINDINFO bindinfo;
|
|
|
|
DWORD grfBINDF = 0;
|
|
|
|
LPCWSTR text = NULL;
|
|
|
|
DWORD data_len;
|
|
|
|
BYTE *data;
|
|
|
|
HRESULT hres;
|
|
|
|
static const WCHAR wszAbout[] = {'a','b','o','u','t',':'};
|
|
|
|
|
|
|
|
/* NOTE:
|
|
|
|
* the about protocol seems not to work as I would expect. It creates html document
|
|
|
|
* for a given url, eg. about:some_text -> <HTML>some_text</HTML> except for the case when
|
|
|
|
* some_text = "blank", when document is blank (<HTML></HMTL>). The same happens
|
|
|
|
* when the url does not have "about:" in the beginning.
|
|
|
|
*/
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
|
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(BINDINFO);
|
|
|
|
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
ReleaseBindInfo(&bindinfo);
|
|
|
|
|
|
|
|
TRACE("bindf %x\n", grfBINDF);
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
if(lstrlenW(szUrl) >= ARRAY_SIZE(wszAbout) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
|
2018-08-23 23:31:15 +02:00
|
|
|
text = szUrl + ARRAY_SIZE(wszAbout);
|
2020-11-24 23:29:19 +01:00
|
|
|
if(!wcscmp(L"blank", text))
|
2018-05-15 15:27:11 +02:00
|
|
|
text = NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
data_len = sizeof(L"\xfeff<HTML>")+sizeof(L"</HTML>")-sizeof(WCHAR)
|
2019-06-13 08:34:29 +02:00
|
|
|
+ (text ? lstrlenW(text)*sizeof(WCHAR) : 0);
|
2018-05-15 15:27:11 +02:00
|
|
|
data = heap_alloc(data_len);
|
|
|
|
if(!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
heap_free(This->data);
|
|
|
|
This->data = data;
|
|
|
|
This->data_len = data_len;
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
lstrcpyW((LPWSTR)This->data, L"\xfeff<HTML>");
|
2018-05-15 15:27:11 +02:00
|
|
|
if(text)
|
2019-06-13 08:34:29 +02:00
|
|
|
lstrcatW((LPWSTR)This->data, text);
|
2020-11-24 23:29:19 +01:00
|
|
|
lstrcatW((LPWSTR)This->data, L"</HTML>");
|
2018-05-15 15:27:11 +02:00
|
|
|
|
|
|
|
This->cur = 0;
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, L"text/html");
|
2018-05-15 15:27:11 +02:00
|
|
|
|
|
|
|
IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
|
|
|
|
This->data_len, This->data_len);
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
static const IInternetProtocolVtbl AboutProtocolVtbl = {
|
2018-05-15 15:27:11 +02:00
|
|
|
InternetProtocol_QueryInterface,
|
|
|
|
InternetProtocol_AddRef,
|
|
|
|
InternetProtocol_Release,
|
2005-06-27 11:50:56 +02:00
|
|
|
AboutProtocol_Start,
|
2018-05-15 15:27:11 +02:00
|
|
|
InternetProtocol_Continue,
|
|
|
|
InternetProtocol_Abort,
|
|
|
|
InternetProtocol_Terminate,
|
|
|
|
InternetProtocol_Suspend,
|
|
|
|
InternetProtocol_Resume,
|
|
|
|
InternetProtocol_Read,
|
|
|
|
InternetProtocol_Seek,
|
|
|
|
InternetProtocol_LockRequest,
|
|
|
|
InternetProtocol_UnlockRequest
|
2005-06-27 11:50:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2005-08-11 19:04:45 +02:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
return create_protocol_instance(&AboutProtocolVtbl, pUnkOuter, riid, ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
|
|
|
|
DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2011-02-08 15:09:24 +01:00
|
|
|
TRACE("%p)->(%s %d %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
|
2005-06-27 11:50:56 +02:00
|
|
|
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
|
2005-09-12 12:10:21 +02:00
|
|
|
|
|
|
|
if(ParseAction == PARSE_SECURITY_URL) {
|
2019-06-13 08:34:29 +02:00
|
|
|
unsigned int len = lstrlenW(pwzUrl)+1;
|
2005-09-12 12:10:21 +02:00
|
|
|
|
2011-02-08 15:09:24 +01:00
|
|
|
*pcchResult = len;
|
|
|
|
if(len > cchResult)
|
2005-09-12 12:10:21 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
2011-02-08 15:09:24 +01:00
|
|
|
memcpy(pwzResult, pwzUrl, len*sizeof(WCHAR));
|
2005-09-12 12:10:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ParseAction == PARSE_DOMAIN) {
|
2006-05-12 18:49:27 +02:00
|
|
|
if(!pcchResult)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(pwzUrl)
|
2019-06-13 08:34:29 +02:00
|
|
|
*pcchResult = lstrlenW(pwzUrl)+1;
|
2006-05-12 18:49:27 +02:00
|
|
|
else
|
|
|
|
*pcchResult = 1;
|
|
|
|
return E_FAIL;
|
2005-09-12 12:10:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return INET_E_DEFAULT_ACTION;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2007-12-28 01:58:41 +01:00
|
|
|
TRACE("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
|
|
|
|
cbBuffer, pcbBuf, dwReserved);
|
|
|
|
|
|
|
|
switch(QueryOption) {
|
|
|
|
case QUERY_CAN_NAVIGATE:
|
|
|
|
return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
|
|
|
|
|
|
|
|
case QUERY_USES_NETWORK:
|
|
|
|
if(!pBuffer || cbBuffer < sizeof(DWORD))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
*(DWORD*)pBuffer = 0;
|
|
|
|
if(pcbBuf)
|
|
|
|
*pcbBuf = sizeof(DWORD);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QUERY_IS_CACHED:
|
|
|
|
FIXME("Unsupported option QUERY_IS_CACHED\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
case QUERY_IS_INSTALLEDENTRY:
|
|
|
|
FIXME("Unsupported option QUERY_IS_INSTALLEDENTRY\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
case QUERY_IS_CACHED_OR_MAPPED:
|
|
|
|
FIXME("Unsupported option QUERY_IS_CACHED_OR_MAPPED\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
case QUERY_IS_SECURE:
|
|
|
|
FIXME("Unsupported option QUERY_IS_SECURE\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
case QUERY_IS_SAFE:
|
|
|
|
FIXME("Unsupported option QUERY_IS_SAFE\n");
|
|
|
|
return E_NOTIMPL;
|
2008-06-06 20:09:45 +02:00
|
|
|
case QUERY_USES_HISTORYFOLDER:
|
|
|
|
FIXME("Unsupported option QUERY_USES_HISTORYFOLDER\n");
|
|
|
|
return E_FAIL;
|
2011-10-11 19:14:20 +02:00
|
|
|
case QUERY_IS_CACHED_AND_USABLE_OFFLINE:
|
|
|
|
FIXME("Unsupported option QUERY_IS_CACHED_AND_USABLE_OFFLINE\n");
|
|
|
|
return E_NOTIMPL;
|
2007-12-28 01:58:41 +01:00
|
|
|
default:
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolInfoVtbl AboutProtocolInfoVtbl = {
|
|
|
|
InternetProtocolInfo_QueryInterface,
|
|
|
|
InternetProtocolInfo_AddRef,
|
|
|
|
InternetProtocolInfo_Release,
|
|
|
|
AboutProtocolInfo_ParseUrl,
|
2006-08-12 18:43:16 +02:00
|
|
|
InternetProtocolInfo_CombineUrl,
|
2006-12-12 21:52:46 +01:00
|
|
|
InternetProtocolInfo_CompareUrl,
|
2005-06-27 11:50:56 +02:00
|
|
|
AboutProtocolInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl AboutProtocolFactoryVtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
AboutProtocolFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static ProtocolFactory AboutProtocolFactory = {
|
2011-01-05 00:43:29 +01:00
|
|
|
{ &AboutProtocolInfoVtbl },
|
|
|
|
{ &AboutProtocolFactoryVtbl }
|
2005-06-27 11:50:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/********************************************************************
|
2018-05-15 15:27:11 +02:00
|
|
|
* res protocol implementation
|
2005-06-27 11:50:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
|
2009-04-01 03:42:37 +02:00
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
2005-06-27 11:50:56 +02:00
|
|
|
{
|
2018-05-15 15:26:58 +02:00
|
|
|
InternetProtocol *This = impl_from_IInternetProtocol(iface);
|
2020-04-24 18:37:44 +02:00
|
|
|
WCHAR *url_dll, *url_file, *url, *mime, *res_type, *alt_res_type = NULL, *ptr;
|
2005-09-12 22:12:58 +02:00
|
|
|
DWORD grfBINDF = 0, len;
|
2005-06-30 12:21:58 +02:00
|
|
|
BINDINFO bindinfo;
|
|
|
|
HMODULE hdll;
|
|
|
|
HRSRC src;
|
2005-09-12 22:12:58 +02:00
|
|
|
HRESULT hres;
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
|
|
|
|
|
2009-04-01 03:42:37 +02:00
|
|
|
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
|
2005-06-27 11:50:56 +02:00
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(BINDINFO);
|
2012-11-27 12:16:34 +01:00
|
|
|
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2005-09-08 20:55:18 +02:00
|
|
|
ReleaseBindInfo(&bindinfo);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
len = lstrlenW(szUrl)+16;
|
2007-12-05 21:52:31 +01:00
|
|
|
url = heap_alloc(len*sizeof(WCHAR));
|
2005-09-12 22:12:58 +02:00
|
|
|
hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
|
|
|
|
if(FAILED(hres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("CoInternetParseUrl failed: %08x\n", hres);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(url);
|
2005-09-12 22:12:58 +02:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, hres, 0, NULL);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
if(len < ARRAY_SIZE(wszRes) || memcmp(url, wszRes, sizeof(wszRes))) {
|
2005-09-12 22:12:58 +02:00
|
|
|
WARN("Wrong protocol of url: %s\n", debugstr_w(url));
|
2007-01-22 20:29:53 +01:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, E_INVALIDARG, 0, NULL);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(url);
|
2007-01-22 20:29:53 +01:00
|
|
|
return E_INVALIDARG;
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
url_dll = url + ARRAY_SIZE(wszRes);
|
2019-06-13 08:34:29 +02:00
|
|
|
if(!(res_type = wcschr(url_dll, '/'))) {
|
2005-09-12 22:12:58 +02:00
|
|
|
WARN("wrong url: %s\n", debugstr_w(url));
|
2005-06-30 12:21:58 +02:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(url);
|
2005-06-30 12:21:58 +02:00
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
|
2013-07-19 17:59:30 +02:00
|
|
|
*res_type++ = 0;
|
2019-06-13 08:34:29 +02:00
|
|
|
if ((url_file = wcschr(res_type, '/'))) {
|
2020-04-24 18:37:27 +02:00
|
|
|
DWORD res_type_id;
|
|
|
|
WCHAR *endpoint;
|
2013-07-19 17:59:30 +02:00
|
|
|
*url_file++ = 0;
|
2020-04-24 18:37:27 +02:00
|
|
|
res_type_id = wcstol(res_type, &endpoint, 10);
|
|
|
|
if(!*endpoint)
|
|
|
|
res_type = MAKEINTRESOURCEW(res_type_id);
|
2013-07-19 17:59:30 +02:00
|
|
|
}else {
|
|
|
|
url_file = res_type;
|
2020-04-24 18:37:44 +02:00
|
|
|
res_type = MAKEINTRESOURCEW(RT_HTML);
|
|
|
|
alt_res_type = MAKEINTRESOURCEW(2110 /* RT_FILE */);
|
2013-07-19 17:59:30 +02:00
|
|
|
}
|
|
|
|
|
2014-11-11 11:37:22 +01:00
|
|
|
/* Ignore query and hash parts. */
|
2019-06-13 08:34:29 +02:00
|
|
|
if((ptr = wcschr(url_file, '?')))
|
2014-11-11 11:37:22 +01:00
|
|
|
*ptr = 0;
|
2019-06-13 08:34:29 +02:00
|
|
|
if(*url_file && (ptr = wcschr(url_file+1, '#')))
|
2014-11-11 11:37:22 +01:00
|
|
|
*ptr = 0;
|
|
|
|
|
2005-09-12 22:12:58 +02:00
|
|
|
hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
2005-06-30 12:21:58 +02:00
|
|
|
if(!hdll) {
|
2013-07-19 17:59:30 +02:00
|
|
|
WARN("Could not open dll: %s\n", debugstr_w(url_dll));
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
|
|
|
|
heap_free(url);
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
|
|
|
|
2008-04-10 13:01:48 +02:00
|
|
|
TRACE("trying to find resource type %s, name %s\n", debugstr_w(res_type), debugstr_w(url_file));
|
|
|
|
|
|
|
|
src = FindResourceW(hdll, url_file, res_type);
|
2020-04-24 18:37:44 +02:00
|
|
|
if(!src && alt_res_type)
|
|
|
|
src = FindResourceW(hdll, url_file, alt_res_type);
|
2005-06-30 12:21:58 +02:00
|
|
|
if(!src) {
|
2006-07-26 20:55:35 +02:00
|
|
|
LPWSTR endpoint = NULL;
|
2019-06-13 08:34:29 +02:00
|
|
|
DWORD file_id = wcstol(url_file, &endpoint, 10);
|
2020-04-24 18:37:44 +02:00
|
|
|
if(!*endpoint) {
|
2013-07-19 17:59:30 +02:00
|
|
|
src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), res_type);
|
2020-04-24 18:37:44 +02:00
|
|
|
if(!src && alt_res_type)
|
|
|
|
src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), alt_res_type);
|
|
|
|
}
|
2006-07-26 20:55:35 +02:00
|
|
|
if(!src) {
|
|
|
|
WARN("Could not find resource\n");
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink,
|
|
|
|
HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(url);
|
2006-07-26 20:55:35 +02:00
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(This->data) {
|
|
|
|
WARN("data already loaded\n");
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This->data);
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
This->data_len = SizeofResource(hdll, src);
|
2007-12-05 21:52:31 +01:00
|
|
|
This->data = heap_alloc(This->data_len);
|
2005-06-30 12:21:58 +02:00
|
|
|
memcpy(This->data, LoadResource(hdll, src), This->data_len);
|
|
|
|
This->cur = 0;
|
|
|
|
|
|
|
|
FreeLibrary(hdll);
|
|
|
|
|
2010-07-01 12:17:42 +02:00
|
|
|
hres = FindMimeFromData(NULL, url_file, This->data, This->data_len, NULL, 0, &mime, 0);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(url);
|
2005-09-14 12:06:34 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
}
|
|
|
|
|
2005-06-30 12:21:58 +02:00
|
|
|
IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
|
|
|
|
This->data_len, This->data_len);
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolVtbl ResProtocolVtbl = {
|
2018-05-15 15:27:11 +02:00
|
|
|
InternetProtocol_QueryInterface,
|
|
|
|
InternetProtocol_AddRef,
|
|
|
|
InternetProtocol_Release,
|
2005-06-27 11:50:56 +02:00
|
|
|
ResProtocol_Start,
|
2018-05-15 15:27:11 +02:00
|
|
|
InternetProtocol_Continue,
|
|
|
|
InternetProtocol_Abort,
|
|
|
|
InternetProtocol_Terminate,
|
|
|
|
InternetProtocol_Suspend,
|
|
|
|
InternetProtocol_Resume,
|
|
|
|
InternetProtocol_Read,
|
|
|
|
InternetProtocol_Seek,
|
|
|
|
InternetProtocol_LockRequest,
|
|
|
|
InternetProtocol_UnlockRequest
|
2005-06-27 11:50:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2005-08-11 19:04:45 +02:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2018-05-15 15:27:27 +02:00
|
|
|
return create_protocol_instance(&ResProtocolVtbl, pUnkOuter, riid, ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
|
|
|
|
DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%s %d %x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
|
2005-06-27 11:50:56 +02:00
|
|
|
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
|
2005-09-12 12:10:21 +02:00
|
|
|
|
|
|
|
if(ParseAction == PARSE_SECURITY_URL) {
|
2008-03-14 12:40:46 +01:00
|
|
|
WCHAR file_part[MAX_PATH], full_path[MAX_PATH];
|
2005-09-12 12:10:21 +02:00
|
|
|
WCHAR *ptr;
|
2008-03-14 12:40:46 +01:00
|
|
|
DWORD size, len;
|
2005-09-12 12:10:21 +02:00
|
|
|
|
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
|
|
|
|
static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
if(lstrlenW(pwzUrl) <= ARRAY_SIZE(wszRes) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
|
2007-01-22 20:29:53 +01:00
|
|
|
return E_INVALIDARG;
|
2005-09-12 12:10:21 +02:00
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(pwzUrl + ARRAY_SIZE(wszRes), '/');
|
2005-09-12 12:10:21 +02:00
|
|
|
if(!ptr)
|
2007-01-22 20:29:53 +01:00
|
|
|
return E_INVALIDARG;
|
2005-09-12 12:10:21 +02:00
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
len = ptr - (pwzUrl + ARRAY_SIZE(wszRes));
|
|
|
|
if(len >= ARRAY_SIZE(file_part)) {
|
2008-03-14 12:40:46 +01:00
|
|
|
FIXME("Too long URL\n");
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
2005-09-12 12:10:21 +02:00
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
memcpy(file_part, pwzUrl + ARRAY_SIZE(wszRes), len*sizeof(WCHAR));
|
2008-03-14 12:40:46 +01:00
|
|
|
file_part[len] = 0;
|
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
len = SearchPathW(NULL, file_part, NULL, ARRAY_SIZE(full_path), full_path, NULL);
|
2008-03-14 12:40:46 +01:00
|
|
|
if(!len) {
|
2011-03-29 12:50:52 +02:00
|
|
|
HMODULE module;
|
|
|
|
|
|
|
|
/* SearchPath does not work well with winelib files (like our test executable),
|
|
|
|
* so we also try to load the library here */
|
|
|
|
module = LoadLibraryExW(file_part, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
if(!module) {
|
|
|
|
WARN("Could not find file %s\n", debugstr_w(file_part));
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
len = GetModuleFileNameW(module, full_path, ARRAY_SIZE(full_path));
|
2011-03-29 12:50:52 +02:00
|
|
|
FreeLibrary(module);
|
|
|
|
if(!len)
|
|
|
|
return E_FAIL;
|
2008-03-14 12:40:46 +01:00
|
|
|
}
|
2005-09-12 12:10:21 +02:00
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
size = ARRAY_SIZE(wszFile) + len + 1;
|
2005-09-12 12:10:21 +02:00
|
|
|
if(pcchResult)
|
|
|
|
*pcchResult = size;
|
2011-02-08 15:09:38 +01:00
|
|
|
if(size > cchResult)
|
2008-03-14 12:40:46 +01:00
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
memcpy(pwzResult, wszFile, sizeof(wszFile));
|
2018-08-23 23:31:15 +02:00
|
|
|
memcpy(pwzResult + ARRAY_SIZE(wszFile), full_path, (len+1)*sizeof(WCHAR));
|
2005-09-12 12:10:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ParseAction == PARSE_DOMAIN) {
|
2006-05-12 18:49:27 +02:00
|
|
|
if(!pcchResult)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(pwzUrl)
|
2019-06-13 08:34:29 +02:00
|
|
|
*pcchResult = lstrlenW(pwzUrl)+1;
|
2006-05-12 18:49:27 +02:00
|
|
|
else
|
|
|
|
*pcchResult = 1;
|
|
|
|
return E_FAIL;
|
2005-09-12 12:10:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return INET_E_DEFAULT_ACTION;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2007-12-28 01:58:53 +01:00
|
|
|
TRACE("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
|
|
|
|
cbBuffer, pcbBuf, dwReserved);
|
|
|
|
|
|
|
|
switch(QueryOption) {
|
|
|
|
case QUERY_USES_NETWORK:
|
|
|
|
if(!pBuffer || cbBuffer < sizeof(DWORD))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
*(DWORD*)pBuffer = 0;
|
|
|
|
if(pcbBuf)
|
|
|
|
*pcbBuf = sizeof(DWORD);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QUERY_IS_SECURE:
|
2011-08-02 22:20:32 +02:00
|
|
|
FIXME("QUERY_IS_SECURE not supported\n");
|
2007-12-28 01:58:53 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
case QUERY_IS_SAFE:
|
2011-08-02 22:20:32 +02:00
|
|
|
FIXME("QUERY_IS_SAFE not supported\n");
|
2007-12-28 01:58:53 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
default:
|
|
|
|
return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolInfoVtbl ResProtocolInfoVtbl = {
|
|
|
|
InternetProtocolInfo_QueryInterface,
|
|
|
|
InternetProtocolInfo_AddRef,
|
|
|
|
InternetProtocolInfo_Release,
|
|
|
|
ResProtocolInfo_ParseUrl,
|
2006-08-12 18:43:16 +02:00
|
|
|
InternetProtocolInfo_CombineUrl,
|
2006-12-12 21:52:46 +01:00
|
|
|
InternetProtocolInfo_CompareUrl,
|
2005-06-27 11:50:56 +02:00
|
|
|
ResProtocolInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ResProtocolFactoryVtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
ResProtocolFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static ProtocolFactory ResProtocolFactory = {
|
2011-01-05 00:43:29 +01:00
|
|
|
{ &ResProtocolInfoVtbl },
|
|
|
|
{ &ResProtocolFactoryVtbl }
|
2005-06-27 11:50:56 +02:00
|
|
|
};
|
|
|
|
|
2009-09-08 22:27:31 +02:00
|
|
|
/********************************************************************
|
|
|
|
* JSProtocol implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI JSProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JSProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
|
|
|
|
DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2009-09-08 22:28:00 +02:00
|
|
|
TRACE("%p)->(%s %d %x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
|
2009-09-08 22:27:31 +02:00
|
|
|
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
|
2009-09-08 22:28:00 +02:00
|
|
|
|
|
|
|
switch(ParseAction) {
|
|
|
|
case PARSE_SECURITY_URL:
|
|
|
|
FIXME("PARSE_SECURITY_URL\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
case PARSE_DOMAIN:
|
|
|
|
FIXME("PARSE_DOMAIN\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
default:
|
|
|
|
return INET_E_DEFAULT_ACTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-09-08 22:27:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JSProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2009-09-08 22:28:28 +02:00
|
|
|
TRACE("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
|
2009-09-08 22:27:31 +02:00
|
|
|
cbBuffer, pcbBuf, dwReserved);
|
2009-09-08 22:28:28 +02:00
|
|
|
|
|
|
|
switch(QueryOption) {
|
|
|
|
case QUERY_USES_NETWORK:
|
|
|
|
if(!pBuffer || cbBuffer < sizeof(DWORD))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
*(DWORD*)pBuffer = 0;
|
|
|
|
if(pcbBuf)
|
|
|
|
*pcbBuf = sizeof(DWORD);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QUERY_IS_SECURE:
|
2011-08-02 22:20:32 +02:00
|
|
|
FIXME("QUERY_IS_SECURE not supported\n");
|
2009-09-08 22:28:28 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-09-08 22:27:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolInfoVtbl JSProtocolInfoVtbl = {
|
|
|
|
InternetProtocolInfo_QueryInterface,
|
|
|
|
InternetProtocolInfo_AddRef,
|
|
|
|
InternetProtocolInfo_Release,
|
|
|
|
JSProtocolInfo_ParseUrl,
|
|
|
|
InternetProtocolInfo_CombineUrl,
|
|
|
|
InternetProtocolInfo_CompareUrl,
|
|
|
|
JSProtocolInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl JSProtocolFactoryVtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
JSProtocolFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static ProtocolFactory JSProtocolFactory = {
|
2011-01-05 00:43:29 +01:00
|
|
|
{ &JSProtocolInfoVtbl },
|
|
|
|
{ &JSProtocolFactoryVtbl }
|
2009-09-08 22:27:31 +02:00
|
|
|
};
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ProtocolFactory *cf = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&CLSID_AboutProtocol, rclsid))
|
|
|
|
cf = &AboutProtocolFactory;
|
|
|
|
else if(IsEqualGUID(&CLSID_ResProtocol, rclsid))
|
|
|
|
cf = &ResProtocolFactory;
|
2009-09-08 22:27:31 +02:00
|
|
|
else if(IsEqualGUID(&CLSID_JSProtocol, rclsid))
|
|
|
|
cf = &JSProtocolFactory;
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
if(!cf) {
|
|
|
|
FIXME("not implemented protocol %s\n", debugstr_guid(rclsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
2005-08-02 11:49:06 +02:00
|
|
|
|
2011-01-07 14:22:41 +01:00
|
|
|
return IInternetProtocolInfo_QueryInterface(&cf->IInternetProtocolInfo_iface, riid, ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|