Index: src/plugin/PluginStdAfx.h
===================================================================
--- a/src/plugin/PluginStdAfx.h
+++ b/src/plugin/PluginStdAfx.h
@@ -34,6 +34,12 @@
#define _WIN32_WINNT 0x0501
#endif
+/*
+ * PassthroughAPP requires at least IE version 7.0
+ * Must be defined before other Windows headers or it gets redefined incorrectly
+ */
+#define _WIN32_IE _WIN32_IE_IE70
+
#define _ATL_APARTMENT_THREADED
//#define _CRT_SECURE_NO_DEPRECATE 1
Index: src/plugin/PluginWbPassThrough.cpp
===================================================================
--- a/src/plugin/PluginWbPassThrough.cpp
+++ b/src/plugin/PluginWbPassThrough.cpp
@@ -218,12 +218,12 @@
//Monitor and/or cancel every request and responde
//WB makes, including images, sounds, scripts, etc
////////////////////////////////////////////////////////////////////////////////////////
-HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
+HRESULT WBPassthruSink::OnStartEx(IUri* pUri, IInternetProtocolSink *pOIProtSink,
IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
IInternetProtocol* pTargetProtocol)
{
m_pTargetProtocol = pTargetProtocol;
- return BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTargetProtocol);
+ return BaseClass::OnStartEx(pUri, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTargetProtocol);
}
HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead)
Index: src/plugin/PluginWbPassThrough.h
===================================================================
--- a/src/plugin/PluginWbPassThrough.h
+++ b/src/plugin/PluginWbPassThrough.h
@@ -65,7 +65,7 @@
/* [in] */ LPCWSTR szRequestHeaders,
/* [out] */ LPWSTR* pszAdditionalRequestHeaders);
- HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink* pOIProtSink,
+ HRESULT OnStartEx(IUri* pUri, IInternetProtocolSink* pOIProtSink,
IInternetBindInfo* pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
IInternetProtocol* pTargetProtocol);
Index: src/plugin/passthroughapp/PassthroughObject.h
===================================================================
--- a/src/plugin/passthroughapp/PassthroughObject.h
+++ b/src/plugin/passthroughapp/PassthroughObject.h
@@ -1,40 +1,23 @@
-/*
- * This file is part of Adblock Plus ,
- * Copyright (C) 2006-2015 Eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see .
- */
-
#ifndef PASSTHROUGHAPP_PASSTHROUGHOBJECT_H
#define PASSTHROUGHAPP_PASSTHROUGHOBJECT_H
// {C38D254C-4C40-4192-A746-AC6FE519831E}
-extern "C" const __declspec(selectany) IID IID_IPassthroughObject =
-{0xc38d254c, 0x4c40, 0x4192,
-{0xa7, 0x46, 0xac, 0x6f, 0xe5, 0x19, 0x83, 0x1e}};
+extern "C" const __declspec(selectany) IID IID_IPassthroughObject =
+ {0xc38d254c, 0x4c40, 0x4192,
+ {0xa7, 0x46, 0xac, 0x6f, 0xe5, 0x19, 0x83, 0x1e}};
struct
- __declspec(uuid("{C38D254C-4C40-4192-A746-AC6FE519831E}"))
- __declspec(novtable)
+__declspec(uuid("{C38D254C-4C40-4192-A746-AC6FE519831E}"))
+__declspec(novtable)
IPassthroughObject : public IUnknown
{
- STDMETHOD(SetTargetUnknown)(IUnknown* punkTarget) = 0;
+ STDMETHOD(SetTargetUnknown)(IUnknown* punkTarget) = 0;
};
#if _ATL_VER < 0x700
-#define InlineIsEqualGUID ::ATL::InlineIsEqualGUID
+ #define InlineIsEqualGUID ::ATL::InlineIsEqualGUID
#else
-#define InlineIsEqualGUID ::InlineIsEqualGUID
+ #define InlineIsEqualGUID ::InlineIsEqualGUID
#endif
#endif // PASSTHROUGHAPP_PASSTHROUGHOBJECT_H
Index: src/plugin/passthroughapp/ProtocolCF.h
===================================================================
--- a/src/plugin/passthroughapp/ProtocolCF.h
+++ b/src/plugin/passthroughapp/ProtocolCF.h
@@ -1,17 +1,3 @@
-// Copyright 2007 Igor Tandetnik
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
#ifndef PASSTHROUGHAPP_PROTOCOLCF_H
#define PASSTHROUGHAPP_PROTOCOLCF_H
@@ -22,70 +8,70 @@
namespace PassthroughAPP
{
- namespace Detail
- {
- // A bit of template metaprogramming allows to avoid requiring
- // the protocol class to either derive from CComCoClass or explicitly
- // specify DECLARE_*AGGREGATABLE macro. If the class does it, the declared
- // behavior is used, otherwise the default behavior is as if
- // DECLARE_AGGREGATABLE is specified
+namespace Detail
+{
+// A bit of template metaprogramming allows to avoid requiring
+// the protocol class to either derive from CComCoClass or explicitly
+// specify DECLARE_*AGGREGATABLE macro. If the class does it, the declared
+// behavior is used, otherwise the default behavior is as if
+// DECLARE_AGGREGATABLE is specified
- // If T has a typedef _CreatorClass, Derived would pick it from its base.
- // If T does not define _CreatorClass, the definition is picked from the next
- // enclosing scope, which is ChooseCreatorClass::_CreatorClass, or Default
- template
- struct ChooseCreatorClass
- {
- typedef Default _CreatorClass;
- struct Derived : private T
- {
- typedef _CreatorClass CreatorClass;
- };
- typedef typename Derived::CreatorClass CreatorClass;
- };
+// If T has a typedef _CreatorClass, Derived would pick it from its base.
+// If T does not define _CreatorClass, the definition is picked from the next
+// enclosing scope, which is ChooseCreatorClass::_CreatorClass, or Default
+template
+struct ChooseCreatorClass
+{
+ typedef Default _CreatorClass;
+ struct Derived : private T
+ {
+ typedef _CreatorClass CreatorClass;
+ };
+ typedef typename Derived::CreatorClass CreatorClass;
+};
- } // end namespace PassthroughAPP::Detail
+} // end namespace PassthroughAPP::Detail
- class ATL_NO_VTABLE CComClassFactoryProtocol :
- public CComClassFactory
- {
- typedef CComClassFactory BaseClass;
- public:
- STDMETHODIMP CreateInstance(IUnknown* punkOuter, REFIID riid,
- void** ppvObj);
+class ATL_NO_VTABLE CComClassFactoryProtocol :
+ public CComClassFactory
+{
+ typedef CComClassFactory BaseClass;
+public:
+ STDMETHODIMP CreateInstance(IUnknown* punkOuter, REFIID riid,
+ void** ppvObj);
- HRESULT CreateInstanceTarget(IUnknown** ppTargetProtocol);
+ HRESULT CreateInstanceTarget(IUnknown** ppTargetProtocol);
- HRESULT GetTargetClassFactory(IClassFactory** ppCF);
- HRESULT SetTargetClassFactory(IClassFactory* pCF);
- HRESULT SetTargetCLSID(REFCLSID clsid, DWORD clsContext = CLSCTX_ALL);
+ HRESULT GetTargetClassFactory(IClassFactory** ppCF);
+ HRESULT SetTargetClassFactory(IClassFactory* pCF);
+ HRESULT SetTargetCLSID(REFCLSID clsid, DWORD clsContext = CLSCTX_ALL);
- void FinalRelease();
- private:
- CComPtr m_spTargetCF;
- };
+ void FinalRelease();
+private:
+ CComPtr m_spTargetCF;
+};
- template >
- struct CMetaFactory
- {
- typedef
- CComCreator2 >,
- CComCreator > >
- DefaultCreatorClass;
+template >
+struct CMetaFactory
+{
+ typedef
+ CComCreator2 >,
+ CComCreator > >
+ DefaultCreatorClass;
- typedef typename
- Detail::ChooseCreatorClass::CreatorClass
- CreatorClass;
+ typedef typename
+ Detail::ChooseCreatorClass::CreatorClass
+ CreatorClass;
- // returns a non-AddRef'ed pointer to FactoryComObject, already initialized
- // with Protocol's creator function, via ppObj [out] parameter
- static HRESULT CreateInstance(Factory** ppObj);
+ // returns a non-AddRef'ed pointer to FactoryComObject, already initialized
+ // with Protocol's creator function, via ppObj [out] parameter
+ static HRESULT CreateInstance(Factory** ppObj);
- static HRESULT CreateInstance(IClassFactory* pTargetCF,
- IClassFactory** ppCF);
- static HRESULT CreateInstance(REFCLSID clsidTarget, IClassFactory** ppCF);
- };
+ static HRESULT CreateInstance(IClassFactory* pTargetCF,
+ IClassFactory** ppCF);
+ static HRESULT CreateInstance(REFCLSID clsidTarget, IClassFactory** ppCF);
+};
} // end namespace PassthroughAPP
Index: src/plugin/passthroughapp/ProtocolCF.inl
===================================================================
--- a/src/plugin/passthroughapp/ProtocolCF.inl
+++ b/src/plugin/passthroughapp/ProtocolCF.inl
@@ -1,31 +1,16 @@
-// Copyright 2007 Igor Tandetnik
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
#ifndef PASSTHROUGHAPP_PROTOCOLCF_INL
#define PASSTHROUGHAPP_PROTOCOLCF_INL
#if _MSC_VER > 1000
- #pragma once
+#pragma once
#endif // _MSC_VER > 1000
#ifndef PASSTHROUGHAPP_PROTOCOLCF_H
- #error ProtocolCF.inl requires ProtocolCF.h to be included first
+ #error ProtocolCF.inl requires ProtocolCF.h to be included first
#endif
#include "PassthroughObject.h"
-
namespace PassthroughAPP
{
@@ -170,15 +155,12 @@
{
p->SetVoid(pv);
p->InternalFinalConstructAddRef();
-#if _ATL_VER >= 0x800
+ // MG: Updated to conform to more recent ATL version.
hr = p->_AtlInitialConstruct();
if (SUCCEEDED(hr))
-#endif
hr = p->FinalConstruct();
-#if _ATL_VER >= 0x800
if (SUCCEEDED(hr))
hr = p->_AtlFinalConstruct();
-#endif
p->InternalFinalConstructRelease();
if (FAILED(hr))
{
@@ -205,7 +187,6 @@
ATLASSERT(SUCCEEDED(hr) && pObj != 0);
if (SUCCEEDED(hr))
{
- pObj->_AtlInitialConstruct();
pObj->AddRef();
hr = pObj->SetTargetClassFactory(pTargetCF);
@@ -238,7 +219,6 @@
ATLASSERT(SUCCEEDED(hr) && pObj != 0);
if (SUCCEEDED(hr))
{
- //pObj->_AtlInitialConstruct();
pObj->AddRef();
hr = pObj->SetTargetCLSID(clsidTarget);
Index: src/plugin/passthroughapp/ProtocolImpl.h
===================================================================
--- a/src/plugin/passthroughapp/ProtocolImpl.h
+++ b/src/plugin/passthroughapp/ProtocolImpl.h
@@ -1,301 +1,353 @@
-// Copyright 2007 Igor Tandetnik
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
#ifndef PASSTHROUGHAPP_PROTOCOLIMPL_H
#define PASSTHROUGHAPP_PROTOCOLIMPL_H
#if _MSC_VER > 1000
-#pragma once
+ #pragma once
#endif // _MSC_VER > 1000
#include
#pragma comment(lib, "urlmon.lib")
+#include "PassthroughObject.h"
+
namespace PassthroughAPP
{
- namespace Detail
- {
- struct PassthroughItfData
- {
- DWORD_PTR offsetItf;
- DWORD_PTR offsetUnk;
- const IID* piidBase;
- };
+namespace Detail
+{
- template
- struct PassthroughItfHelper
- {
- static PassthroughItfData data;
- };
+struct PassthroughItfData
+{
+ DWORD_PTR offsetItf;
+ DWORD_PTR offsetUnk;
+ const IID* piidBase;
+};
- template
- PassthroughItfData
- PassthroughItfHelper::
- data = {offsetofclass(itf, impl), offsetUnk, piidBase};
+template
+struct PassthroughItfHelper
+{
+ static PassthroughItfData data;
+};
+
+template
+PassthroughItfData
+ PassthroughItfHelper::
+ data = {offsetofclass(itf, impl), offsetUnk, piidBase};
#define COM_INTERFACE_ENTRY_PASSTHROUGH(itf, punk)\
- {&_ATL_IIDOF(itf),\
- (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\
- itf, _ComMapClass,\
- (DWORD_PTR)offsetof(_ComMapClass, punk),\
- 0\
- >::data,\
- ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
- QueryInterfacePassthroughT\
- },
+ {&_ATL_IIDOF(itf),\
+ (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\
+ itf, _ComMapClass,\
+ (DWORD_PTR)offsetof(_ComMapClass, punk),\
+ 0\
+ >::data,\
+ ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
+ QueryInterfacePassthroughT\
+ },
#define COM_INTERFACE_ENTRY_PASSTHROUGH2(itf, punk, itfBase)\
- {&_ATL_IIDOF(itf),\
- (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\
- itf, _ComMapClass,\
- (DWORD_PTR)offsetof(_ComMapClass, punk),\
- &_ATL_IIDOF(itfBase)\
- >::data,\
- ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
- QueryInterfacePassthroughT\
- },
+ {&_ATL_IIDOF(itf),\
+ (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\
+ itf, _ComMapClass,\
+ (DWORD_PTR)offsetof(_ComMapClass, punk),\
+ &_ATL_IIDOF(itfBase)\
+ >::data,\
+ ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
+ QueryInterfacePassthroughT\
+ },
#ifdef DEBUG
-#define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()\
- {0, 0,\
- ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
- QueryInterfaceDebugT\
- },
+ #define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()\
+ {0, 0,\
+ ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
+ QueryInterfaceDebugT\
+ },
#else
-#define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
+ #define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
#endif
#define DECLARE_GET_TARGET_UNKNOWN(x) \
- inline IUnknown* GetTargetUnknown() {return x;}
+ inline IUnknown* GetTargetUnknown() {return x;}
- // Workaround for VC6's deficiencies in dealing with function templates.
- // We'd use non-member template functions, but VC6 does not handle those well.
- // Static members of class templates work much better, and we don't need
- // parameter deduction here
- template
- struct QIPassthrough
- {
- static HRESULT WINAPI QueryInterfacePassthroughT(void* pv, REFIID riid,
- LPVOID* ppv, DWORD_PTR dw);
- static HRESULT WINAPI QueryInterfaceDebugT(void* pv, REFIID riid,
- LPVOID* ppv, DWORD_PTR dw);
- };
+// Workaround for VC6's deficiencies in dealing with function templates.
+// We'd use non-member template functions, but VC6 does not handle those well.
+// Static members of class templates work much better, and we don't need
+// parameter deduction here
+template
+struct QIPassthrough
+{
+ static HRESULT WINAPI QueryInterfacePassthroughT(void* pv, REFIID riid,
+ LPVOID* ppv, DWORD_PTR dw);
+ static HRESULT WINAPI QueryInterfaceDebugT(void* pv, REFIID riid,
+ LPVOID* ppv, DWORD_PTR dw);
+};
- HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid,
- LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper);
+HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid,
+ LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper);
- HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid,
- LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget);
+HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid,
+ LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget);
- HRESULT QueryServicePassthrough(REFGUID guidService,
- IUnknown* punkThis, REFIID riid, void** ppv,
- IServiceProvider* pClientProvider);
+HRESULT QueryServicePassthrough(REFGUID guidService,
+ IUnknown* punkThis, REFIID riid, void** ppv,
+ IServiceProvider* pClientProvider);
- } // end namespace PassthroughAPP::Detail
+} // end namespace PassthroughAPP::Detail
- class ATL_NO_VTABLE IInternetProtocolImpl :
- public IPassthroughObject,
- public IInternetProtocol,
- public IInternetProtocolInfo,
- public IInternetPriority,
- public IInternetThreadSwitch,
- public IWinInetHttpInfo
- {
- public:
- void ReleaseAll();
+class ATL_NO_VTABLE IInternetProtocolImpl :
+ public IPassthroughObject,
+ public IInternetProtocolEx,
+ public IInternetProtocolInfo,
+ public IInternetPriority,
+ public IInternetThreadSwitch,
+ public IWinInetHttpInfo,
+ public IWinInetCacheHints2
+{
+public:
+ void ReleaseAll();
- DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolUnk)
- public:
- // IPassthroughObject
- STDMETHODIMP SetTargetUnknown(IUnknown* punkTarget);
+ DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolUnk)
+public:
+ // IPassthroughObject
+ STDMETHODIMP SetTargetUnknown(IUnknown* punkTarget);
- // IInternetProtocolRoot
- STDMETHODIMP Start(
- /* [in] */ LPCWSTR szUrl,
- /* [in] */ IInternetProtocolSink *pOIProtSink,
- /* [in] */ IInternetBindInfo *pOIBindInfo,
- /* [in] */ DWORD grfPI,
- /* [in] */ HANDLE_PTR dwReserved);
+ // IInternetProtocolRoot
+ STDMETHODIMP Start(
+ /* [in] */ LPCWSTR szUrl,
+ /* [in] */ IInternetProtocolSink *pOIProtSink,
+ /* [in] */ IInternetBindInfo *pOIBindInfo,
+ /* [in] */ DWORD grfPI,
+ /* [in] */ HANDLE_PTR dwReserved);
- STDMETHODIMP Continue(
- /* [in] */ PROTOCOLDATA *pProtocolData);
+ STDMETHODIMP Continue(
+ /* [in] */ PROTOCOLDATA *pProtocolData);
- STDMETHODIMP Abort(
- /* [in] */ HRESULT hrReason,
- /* [in] */ DWORD dwOptions);
+ STDMETHODIMP Abort(
+ /* [in] */ HRESULT hrReason,
+ /* [in] */ DWORD dwOptions);
- STDMETHODIMP Terminate(
- /* [in] */ DWORD dwOptions);
+ STDMETHODIMP Terminate(
+ /* [in] */ DWORD dwOptions);
- STDMETHODIMP Suspend();
+ STDMETHODIMP Suspend();
- STDMETHODIMP Resume();
+ STDMETHODIMP Resume();
- // IInternetProtocol
- STDMETHODIMP Read(
- /* [in, out] */ void *pv,
- /* [in] */ ULONG cb,
- /* [out] */ ULONG *pcbRead);
+ // IInternetProtocol
+ STDMETHODIMP Read(
+ /* [in, out] */ void *pv,
+ /* [in] */ ULONG cb,
+ /* [out] */ ULONG *pcbRead);
- STDMETHODIMP Seek(
- /* [in] */ LARGE_INTEGER dlibMove,
- /* [in] */ DWORD dwOrigin,
- /* [out] */ ULARGE_INTEGER *plibNewPosition);
+ STDMETHODIMP Seek(
+ /* [in] */ LARGE_INTEGER dlibMove,
+ /* [in] */ DWORD dwOrigin,
+ /* [out] */ ULARGE_INTEGER *plibNewPosition);
- STDMETHODIMP LockRequest(
- /* [in] */ DWORD dwOptions);
+ STDMETHODIMP LockRequest(
+ /* [in] */ DWORD dwOptions);
- STDMETHODIMP UnlockRequest();
+ STDMETHODIMP UnlockRequest();
- // IInternetProtocolInfo
- STDMETHODIMP ParseUrl(
- /* [in] */ LPCWSTR pwzUrl,
- /* [in] */ PARSEACTION ParseAction,
- /* [in] */ DWORD dwParseFlags,
- /* [out] */ LPWSTR pwzResult,
- /* [in] */ DWORD cchResult,
- /* [out] */ DWORD *pcchResult,
- /* [in] */ DWORD dwReserved);
+ // IInternetProtocolEx
+ STDMETHODIMP StartEx(
+ IUri *pUri,
+ IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI,
+ HANDLE_PTR dwReserved);
- STDMETHODIMP CombineUrl(
- /* [in] */ LPCWSTR pwzBaseUrl,
- /* [in] */ LPCWSTR pwzRelativeUrl,
- /* [in] */ DWORD dwCombineFlags,
- /* [out] */ LPWSTR pwzResult,
- /* [in] */ DWORD cchResult,
- /* [out] */ DWORD *pcchResult,
- /* [in] */ DWORD dwReserved);
+ // IInternetProtocolInfo
+ STDMETHODIMP ParseUrl(
+ /* [in] */ LPCWSTR pwzUrl,
+ /* [in] */ PARSEACTION ParseAction,
+ /* [in] */ DWORD dwParseFlags,
+ /* [out] */ LPWSTR pwzResult,
+ /* [in] */ DWORD cchResult,
+ /* [out] */ DWORD *pcchResult,
+ /* [in] */ DWORD dwReserved);
- STDMETHODIMP CompareUrl(
- /* [in] */ LPCWSTR pwzUrl1,
- /* [in] */ LPCWSTR pwzUrl2,
- /* [in] */ DWORD dwCompareFlags);
+ STDMETHODIMP CombineUrl(
+ /* [in] */ LPCWSTR pwzBaseUrl,
+ /* [in] */ LPCWSTR pwzRelativeUrl,
+ /* [in] */ DWORD dwCombineFlags,
+ /* [out] */ LPWSTR pwzResult,
+ /* [in] */ DWORD cchResult,
+ /* [out] */ DWORD *pcchResult,
+ /* [in] */ DWORD dwReserved);
- STDMETHODIMP QueryInfo(
- /* [in] */ LPCWSTR pwzUrl,
- /* [in] */ QUERYOPTION QueryOption,
- /* [in] */ DWORD dwQueryFlags,
- /* [in, out] */ LPVOID pBuffer,
- /* [in] */ DWORD cbBuffer,
- /* [in, out] */ DWORD *pcbBuf,
- /* [in] */ DWORD dwReserved);
+ STDMETHODIMP CompareUrl(
+ /* [in] */ LPCWSTR pwzUrl1,
+ /* [in] */ LPCWSTR pwzUrl2,
+ /* [in] */ DWORD dwCompareFlags);
- // IInternetPriority
- STDMETHODIMP SetPriority(
- /* [in] */ LONG nPriority);
+ STDMETHODIMP QueryInfo(
+ /* [in] */ LPCWSTR pwzUrl,
+ /* [in] */ QUERYOPTION QueryOption,
+ /* [in] */ DWORD dwQueryFlags,
+ /* [in, out] */ LPVOID pBuffer,
+ /* [in] */ DWORD cbBuffer,
+ /* [in, out] */ DWORD *pcbBuf,
+ /* [in] */ DWORD dwReserved);
- STDMETHODIMP GetPriority(
- /* [out] */ LONG *pnPriority);
+ // IInternetPriority
+ STDMETHODIMP SetPriority(
+ /* [in] */ LONG nPriority);
- // IInternetThreadSwitch
- STDMETHODIMP Prepare();
+ STDMETHODIMP GetPriority(
+ /* [out] */ LONG *pnPriority);
- STDMETHODIMP Continue();
+ // IInternetThreadSwitch
+ STDMETHODIMP Prepare();
- // IWinInetInfo
- STDMETHODIMP QueryOption(
- /* [in] */ DWORD dwOption,
- /* [in, out] */ LPVOID pBuffer,
- /* [in, out] */ DWORD *pcbBuf);
+ STDMETHODIMP Continue();
- // IWinInetHttpInfo
- STDMETHODIMP QueryInfo(
- /* [in] */ DWORD dwOption,
- /* [in, out] */ LPVOID pBuffer,
- /* [in, out] */ DWORD *pcbBuf,
- /* [in, out] */ DWORD *pdwFlags,
- /* [in, out] */ DWORD *pdwReserved);
+ // IWinInetInfo
+ STDMETHODIMP QueryOption(
+ /* [in] */ DWORD dwOption,
+ /* [in, out] */ LPVOID pBuffer,
+ /* [in, out] */ DWORD *pcbBuf);
- public:
- CComPtr m_spInternetProtocolUnk;
- CComPtr m_spInternetProtocol;
- CComPtr m_spInternetProtocolInfo;
- CComPtr m_spInternetPriority;
- CComPtr m_spInternetThreadSwitch;
- CComPtr m_spWinInetInfo;
- CComPtr m_spWinInetHttpInfo;
- };
+ // IWinInetHttpInfo
+ STDMETHODIMP QueryInfo(
+ /* [in] */ DWORD dwOption,
+ /* [in, out] */ LPVOID pBuffer,
+ /* [in, out] */ DWORD *pcbBuf,
+ /* [in, out] */ DWORD *pdwFlags,
+ /* [in, out] */ DWORD *pdwReserved);
- class ATL_NO_VTABLE IInternetProtocolSinkImpl :
- public IInternetProtocolSink,
- public IServiceProvider
- {
- public:
- HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
- IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
- IInternetProtocol* pTargetProtocol);
- void ReleaseAll();
+ // IWinInetCacheHints
+ STDMETHODIMP SetCacheExtension(
+ /* [in] */ LPCWSTR pwzExt,
+ /* [in, out] */ LPVOID pszCacheFile,
+ /* [in, out] */ DWORD *pcbCacheFile,
+ /* [in, out] */ DWORD *pdwWinInetError,
+ /* [in, out] */ DWORD *pdwReserved);
- DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolSink)
+ // IWinInetCacheHints2
+ STDMETHODIMP SetCacheExtension2(
+ /* [in] */ LPCWSTR pwzExt,
+ /* [out] */ WCHAR *pwzCacheFile,
+ /* [in, out] */ DWORD *pcchCacheFile,
+ /* [out] */ DWORD *pdwWinInetError,
+ /* [out] */ DWORD *pdwReserved);
- IServiceProvider* GetClientServiceProvider();
+public:
+ CComPtr m_spInternetProtocolUnk;
+ CComPtr m_spInternetProtocol;
+ CComPtr m_spInternetProtocolEx;
+ CComPtr m_spInternetProtocolInfo;
+ CComPtr m_spInternetPriority;
+ CComPtr m_spInternetThreadSwitch;
+ CComPtr m_spWinInetInfo;
+ CComPtr m_spWinInetHttpInfo;
+ CComPtr m_spWinInetCacheHints;
+ CComPtr m_spWinInetCacheHints2;
+};
- HRESULT QueryServiceFromClient(REFGUID guidService, REFIID riid,
- void** ppvObject);
- template
- HRESULT QueryServiceFromClient(REFGUID guidService, Q** pp)
- {
- return QueryServiceFromClient(guidService, _ATL_IIDOF(Q),
- reinterpret_cast(pp));
- }
- template
- HRESULT QueryServiceFromClient(Q** pp)
- {
- return QueryServiceFromClient(_ATL_IIDOF(Q), _ATL_IIDOF(Q),
- reinterpret_cast(pp));
- }
- public:
- // IInternetProtocolSink
- STDMETHODIMP Switch(
- /* [in] */ PROTOCOLDATA *pProtocolData);
+class ATL_NO_VTABLE IInternetProtocolSinkImpl :
+ public IInternetProtocolSink,
+ public IServiceProvider,
+ public IInternetBindInfoEx,
+ public IUriContainer
+{
+public:
+ HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocol* pTargetProtocol);
+ HRESULT OnStartEx(IUri* pUri, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocol* pTargetProtocol);
+ void ReleaseAll();
- STDMETHODIMP ReportProgress(
- /* [in] */ ULONG ulStatusCode,
- /* [in] */ LPCWSTR szStatusText);
+ DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolSink)
- STDMETHODIMP ReportData(
- /* [in] */ DWORD grfBSCF,
- /* [in] */ ULONG ulProgress,
- /* [in] */ ULONG ulProgressMax);
+ IServiceProvider* GetClientServiceProvider();
- STDMETHODIMP ReportResult(
- /* [in] */ HRESULT hrResult,
- /* [in] */ DWORD dwError,
- /* [in] */ LPCWSTR szResult);
+ HRESULT QueryServiceFromClient(REFGUID guidService, REFIID riid,
+ void** ppvObject);
+ template
+ HRESULT QueryServiceFromClient(REFGUID guidService, Q** pp)
+ {
+ return QueryServiceFromClient(guidService, _ATL_IIDOF(Q),
+ reinterpret_cast(pp));
+ }
+ template
+ HRESULT QueryServiceFromClient(Q** pp)
+ {
+ return QueryServiceFromClient(_ATL_IIDOF(Q), _ATL_IIDOF(Q),
+ reinterpret_cast(pp));
+ }
+public:
+ // IInternetProtocolSink
+ STDMETHODIMP Switch(
+ /* [in] */ PROTOCOLDATA *pProtocolData);
- // IServiceProvider
- STDMETHODIMP QueryService(
- /* [in] */ REFGUID guidService,
- /* [in] */ REFIID riid,
- /* [out] */ void** ppvObject);
+ STDMETHODIMP ReportProgress(
+ /* [in] */ ULONG ulStatusCode,
+ /* [in] */ LPCWSTR szStatusText);
- public:
- CComPtr m_spInternetProtocolSink;
- CComPtr m_spServiceProvider;
- CComPtr m_spTargetProtocol;
- };
+ STDMETHODIMP ReportData(
+ /* [in] */ DWORD grfBSCF,
+ /* [in] */ ULONG ulProgress,
+ /* [in] */ ULONG ulProgressMax);
- template
- class CInternetProtocolSinkTM :
- public CComObjectRootEx,
- public IInternetProtocolSinkImpl
- {
- private:
+ STDMETHODIMP ReportResult(
+ /* [in] */ HRESULT hrResult,
+ /* [in] */ DWORD dwError,
+ /* [in] */ LPCWSTR szResult);
+
+ // IServiceProvider
+ STDMETHODIMP QueryService(
+ /* [in] */ REFGUID guidService,
+ /* [in] */ REFIID riid,
+ /* [out] */ void** ppvObject);
+
+ // IInternetBindInfo
+ STDMETHODIMP GetBindInfo(
+ /* [out] */ DWORD *grfBINDF,
+ /* [in, out] */ BINDINFO *pbindinfo);
+
+ STDMETHODIMP GetBindString(
+ /* [in] */ ULONG ulStringType,
+ /* [in, out] */ LPOLESTR *ppwzStr,
+ /* [in] */ ULONG cEl,
+ /* [in, out] */ ULONG *pcElFetched);
+
+ // IInternetBindInfoEx
+ STDMETHODIMP GetBindInfoEx(
+ DWORD *grfBINDF,
+ BINDINFO *pbindinfo,
+ DWORD *grfBINDF2,
+ DWORD *pdwReserved);
+
+ // IUriContainer
+ STDMETHODIMP GetIUri(
+ /* [out] */ IUri **ppIUri);
+
+protected:
+ HRESULT InitMembers(IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ IInternetProtocol* pTargetProtocol);
+
+public:
+ CComPtr m_spInternetProtocolSink;
+ CComPtr m_spServiceProvider;
+ CComPtr m_spInternetBindInfo;
+ CComPtr m_spInternetBindInfoEx;
+ CComPtr m_spUriContainer;
+
+ CComPtr m_spTargetProtocol;
+};
+
+template
+class CInternetProtocolSinkTM :
+ public CComObjectRootEx,
+ public IInternetProtocolSinkImpl
+{
+private:
static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
{
IInternetProtocolSink* pSink = ((CInternetProtocolSinkTM *) pv)->m_spInternetProtocolSink;
@@ -303,82 +355,97 @@
return pSink ? pSink->QueryInterface(riid, ppv) : E_UNEXPECTED;
}
- public:
- BEGIN_COM_MAP(CInternetProtocolSinkTM)
- COM_INTERFACE_ENTRY(IInternetProtocolSink)
- COM_INTERFACE_ENTRY_PASSTHROUGH(IServiceProvider,
- m_spServiceProvider.p)
- COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID)
- COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
- END_COM_MAP()
+public:
+ BEGIN_COM_MAP(CInternetProtocolSinkTM)
+ COM_INTERFACE_ENTRY(IInternetProtocolSink)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IServiceProvider,
+ m_spServiceProvider.p)
+ COM_INTERFACE_ENTRY(IInternetBindInfo)
+ COM_INTERFACE_ENTRY(IInternetBindInfoEx)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IUriContainer, m_spUriContainer.p)
+ COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID)
+ COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
+ END_COM_MAP()
+};
- };
+typedef CInternetProtocolSinkTM<> CInternetProtocolSink;
- typedef CInternetProtocolSinkTM CInternetProtocolSink;
+template
+class CInternetProtocolSinkWithSP :
+ public CInternetProtocolSinkTM
+{
+ typedef CInternetProtocolSinkTM BaseClass;
+public:
+ HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocol* pTargetProtocol);
+ HRESULT OnStartEx(IUri* pUri, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocol* pTargetProtocol);
- template
- class CInternetProtocolSinkWithSP :
- public CInternetProtocolSinkTM
- {
- typedef CInternetProtocolSinkTM BaseClass;
- public:
- HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
- IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
- IInternetProtocol* pTargetProtocol);
+ STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** ppv);
- STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** ppv);
+ HRESULT _InternalQueryService(REFGUID guidService, REFIID riid,
+ void** ppvObject);
- HRESULT _InternalQueryService(REFGUID guidService, REFIID riid,
- void** ppvObject);
-
- BEGIN_COM_MAP(CInternetProtocolSinkWithSP)
- COM_INTERFACE_ENTRY(IServiceProvider)
- COM_INTERFACE_ENTRY_CHAIN(BaseClass)
- END_COM_MAP()
- };
+ BEGIN_COM_MAP(CInternetProtocolSinkWithSP)
+ COM_INTERFACE_ENTRY(IServiceProvider)
+ COM_INTERFACE_ENTRY_CHAIN(BaseClass)
+ END_COM_MAP()
+};
#define SERVICE_ENTRY_PASSTHROUGH(x) \
- if (InlineIsEqualGUID(guidService, x)) \
- { \
- return ::PassthroughAPP::Detail::QueryServicePassthrough(guidService, \
- GetUnknown(), riid, ppvObject, GetClientServiceProvider()); \
- }
+ if (InlineIsEqualGUID(guidService, x)) \
+ { \
+ return ::PassthroughAPP::Detail::QueryServicePassthrough(guidService, \
+ GetUnknown(), riid, ppvObject, GetClientServiceProvider()); \
+ }
- struct __declspec(uuid("C7A98E66-1010-492c-A1C8-C809E1F75905")) IInternetProtocolEx;
+template
+class ATL_NO_VTABLE CInternetProtocol :
+ public CComObjectRootEx,
+ public IInternetProtocolImpl,
+ public StartPolicy
+{
+private:
+ static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
+ {
+ IInternetProtocol* pProtocol = ((CInternetProtocol *) pv)->m_spInternetProtocol;
+ ATLASSERT(pProtocol != 0);
+ return pProtocol ? pProtocol->QueryInterface(riid, ppv) : E_UNEXPECTED;
+ }
- template
- class ATL_NO_VTABLE CInternetProtocol :
- public CComObjectRootEx,
- public IInternetProtocolImpl,
- public StartPolicy
- {
- private:
- static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
- {
- IInternetProtocol* pProtocol = ((CInternetProtocol *) pv)->m_spInternetProtocol;
- ATLASSERT(pProtocol != 0);
- // TODO: don't need this once we support IInternetProtocolEx
- if (InlineIsEqualGUID(riid, __uuidof(IInternetProtocolEx))) return E_NOINTERFACE;
- return pProtocol ? pProtocol->QueryInterface(riid, ppv) : E_UNEXPECTED;
- }
- public:
- BEGIN_COM_MAP(CInternetProtocol)
- COM_INTERFACE_ENTRY(IPassthroughObject)
- COM_INTERFACE_ENTRY(IInternetProtocolRoot)
- COM_INTERFACE_ENTRY(IInternetProtocol)
- COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetProtocolInfo,
- m_spInternetProtocolInfo.p)
- COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetPriority,
- m_spInternetPriority.p)
- COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetThreadSwitch,
- m_spInternetThreadSwitch.p)
- COM_INTERFACE_ENTRY_PASSTHROUGH(IWinInetInfo, m_spWinInetInfo.p)
- COM_INTERFACE_ENTRY_PASSTHROUGH2(IWinInetHttpInfo,
- m_spWinInetHttpInfo.p, IWinInetInfo)
- COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID)
- COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
- END_COM_MAP()
- };
+public:
+ BEGIN_COM_MAP(CInternetProtocol)
+ COM_INTERFACE_ENTRY(IPassthroughObject)
+ COM_INTERFACE_ENTRY(IInternetProtocolRoot)
+ COM_INTERFACE_ENTRY(IInternetProtocol)
+ COM_INTERFACE_ENTRY(IInternetProtocolEx)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetProtocolInfo,
+ m_spInternetProtocolInfo.p)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetPriority,
+ m_spInternetPriority.p)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetThreadSwitch,
+ m_spInternetThreadSwitch.p)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IWinInetInfo, m_spWinInetInfo.p)
+ COM_INTERFACE_ENTRY_PASSTHROUGH2(IWinInetHttpInfo,
+ m_spWinInetHttpInfo.p, IWinInetInfo)
+ COM_INTERFACE_ENTRY_PASSTHROUGH(IWinInetCacheHints,
+ m_spWinInetCacheHints.p)
+ COM_INTERFACE_ENTRY_PASSTHROUGH2(IWinInetCacheHints2,
+ m_spWinInetCacheHints2.p, IWinInetCacheHints)
+ COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID)
+ COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
+ END_COM_MAP()
+
+ // IInternetProtocolRoot
+ STDMETHODIMP Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved);
+
+ // IInternetProtocolEx
+ STDMETHODIMP StartEx(IUri *pUri, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved);
+};
} // end namespace PassthroughAPP
Index: src/plugin/passthroughapp/ProtocolImpl.inl
===================================================================
--- a/src/plugin/passthroughapp/ProtocolImpl.inl
+++ b/src/plugin/passthroughapp/ProtocolImpl.inl
@@ -1,612 +1,755 @@
-// Copyright 2007 Igor Tandetnik
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
#ifndef PASSTHROUGHAPP_PROTOCOLIMPL_INL
#define PASSTHROUGHAPP_PROTOCOLIMPL_INL
#if _MSC_VER > 1000
-#pragma once
+ #pragma once
#endif // _MSC_VER > 1000
#ifndef PASSTHROUGHAPP_PROTOCOLIMPL_H
-#error ProtocolImpl.inl requires ProtocolImpl.h to be included first
+ #error ProtocolImpl.inl requires ProtocolImpl.h to be included first
#endif
namespace PassthroughAPP
{
- namespace Detail
- {
- template
- inline HRESULT WINAPI QIPassthrough::
- QueryInterfacePassthroughT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
- {
- ATLASSERT(pv != 0);
- T* pT = static_cast(pv);
+namespace Detail
+{
- IUnknown* punkTarget = pT->GetTargetUnknown();
- ATLASSERT(punkTarget != 0);
- if (!punkTarget)
- {
- ATLTRACE(_T("Interface queried before target unknown is set"));
- return E_UNEXPECTED;
- }
+template
+inline HRESULT WINAPI QIPassthrough::
+ QueryInterfacePassthroughT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
+{
+ ATLASSERT(pv != 0);
+ T* pT = static_cast(pv);
- IUnknown* punkWrapper = pT->GetUnknown();
+ IUnknown* punkTarget = pT->GetTargetUnknown();
+ ATLASSERT(punkTarget != 0);
+ if (!punkTarget)
+ {
+ ATLTRACE(_T("Interface queried before target unknown is set"));
+ return E_UNEXPECTED;
+ }
- typename T::ObjectLock lock(pT);
- return QueryInterfacePassthrough(
- pv, riid, ppv, dw, punkTarget, punkWrapper);
- }
+ IUnknown* punkWrapper = pT->GetUnknown();
- template
- inline HRESULT WINAPI QIPassthrough::
- QueryInterfaceDebugT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
- {
- ATLASSERT(pv != 0);
- T* pT = static_cast(pv);
+ typename T::ObjectLock lock(pT);
+ return QueryInterfacePassthrough(
+ pv, riid, ppv, dw, punkTarget, punkWrapper);
+}
- IUnknown* punkTarget = pT->GetTargetUnknown();
- // ATLASSERT(punkTarget != 0);
- if (!punkTarget)
- {
- // ATLTRACE(_T("Interface queried before target unknown is set"));
- return E_UNEXPECTED;
- }
+template
+inline HRESULT WINAPI QIPassthrough::
+ QueryInterfaceDebugT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
+{
+ ATLASSERT(pv != 0);
+ T* pT = static_cast(pv);
- typename T::ObjectLock lock(pT);
+ IUnknown* punkTarget = pT->GetTargetUnknown();
+ ATLASSERT(punkTarget != 0);
+ if (!punkTarget)
+ {
+ ATLTRACE(_T("Interface queried before target unknown is set"));
+ return E_UNEXPECTED;
+ }
- return QueryInterfaceDebug(pv, riid, ppv, dw, punkTarget);
- }
+ typename T::ObjectLock lock(pT);
+ return QueryInterfaceDebug(pv, riid, ppv, dw, punkTarget);
+}
- inline HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid,
- LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper)
- {
- ATLASSERT(pv != 0);
- ATLASSERT(ppv != 0);
- ATLASSERT(dw != 0);
- ATLASSERT(punkTarget != 0);
+inline HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid,
+ LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper)
+{
+ ATLASSERT(pv != 0);
+ ATLASSERT(ppv != 0);
+ ATLASSERT(dw != 0);
+ ATLASSERT(punkTarget != 0);
+ const PassthroughItfData& data =
+ *reinterpret_cast(dw);
- const PassthroughItfData& data =
- *reinterpret_cast(dw);
+ IUnknown** ppUnk = reinterpret_cast(
+ static_cast(pv) + data.offsetUnk);
- IUnknown** ppUnk = reinterpret_cast(
- static_cast(pv) + data.offsetUnk);
+ HRESULT hr = S_OK;
+ if (!*ppUnk)
+ {
+ CComPtr spUnk;
+ hr = punkTarget->QueryInterface(riid,
+ reinterpret_cast(&spUnk));
+ ATLASSERT(FAILED(hr) || spUnk != 0);
+ if (SUCCEEDED(hr))
+ {
+ *ppUnk = spUnk.Detach();
- HRESULT hr = S_OK;
- if (!*ppUnk)
- {
- CComPtr spUnk;
- hr = punkTarget->QueryInterface(riid,
- reinterpret_cast(&spUnk));
- ATLASSERT(FAILED(hr) || spUnk != 0);
- if (SUCCEEDED(hr))
- {
- *ppUnk = spUnk.Detach();
+ // Need to QI for base interface to fill in base target pointer
+ if (data.piidBase)
+ {
+ ATLASSERT(punkWrapper != 0);
+ hr = punkWrapper->QueryInterface(*data.piidBase,
+ reinterpret_cast(&spUnk));
+ // since QI for derived interface succeeded,
+ // QI for base interface must succeed, too
+ ATLASSERT(SUCCEEDED(hr));
+ }
+ }
+ }
+ if (SUCCEEDED(hr))
+ {
+ CComPtr spItf = reinterpret_cast(
+ static_cast(pv) + data.offsetItf);
+ *ppv = spItf.Detach();
+ }
+ else
+ {
+ ATLASSERT(_T("Interface not supported by target unknown"));
+ }
+ return hr;
+}
- // Need to QI for base interface to fill in base target pointer
- if (data.piidBase)
- {
- ATLASSERT(punkWrapper != 0);
- hr = punkWrapper->QueryInterface(*data.piidBase,
- reinterpret_cast(&spUnk));
- // since QI for derived interface succeeded,
- // QI for base interface must succeed, too
- ATLASSERT(SUCCEEDED(hr));
- }
- }
- }
- if (SUCCEEDED(hr))
- {
- CComPtr spItf = reinterpret_cast(
- static_cast(pv) + data.offsetItf);
- *ppv = spItf.Detach();
- }
- else
- {
- ATLASSERT(_T("Interface not supported by target unknown"));
- }
- return hr;
- }
+inline HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid,
+ LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget)
+{
+ ATLASSERT(pv != 0);
+ ATLASSERT(ppv != 0);
+ ATLASSERT(punkTarget != 0);
- inline HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid,
- LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget)
- {
- ATLASSERT(pv != 0);
- ATLASSERT(ppv != 0);
- ATLASSERT(punkTarget != 0);
+ CComPtr spUnk;
+ HRESULT hr = punkTarget->QueryInterface(riid,
+ reinterpret_cast(&spUnk));
+ ATLASSERT(FAILED(hr) || spUnk != 0);
+ if (SUCCEEDED(hr))
+ {
+ ATLTRACE(_T("Unrecognized interface supported by target unknown"));
+ ATLASSERT(false);
+ }
- CComPtr spUnk;
- HRESULT hr = punkTarget->QueryInterface(riid,
- reinterpret_cast(&spUnk));
- ATLASSERT(FAILED(hr) || spUnk != 0);
- if (SUCCEEDED(hr))
- {
- //Added by MH to display interface CLSID in debug
- OLECHAR wszBuff[39];
- int i = StringFromGUID2(riid, wszBuff, 39);
- USES_CONVERSION;
- ATLTRACE(_T("=====>Unrecognized interface supported by target unknown=%s\n"), OLE2T(wszBuff));
- }
+ // We don't support this interface, so return an error.
+ // The operations above are for debugging purposes only,
+ // this function is not supposed to ever return success
+ return E_NOINTERFACE;
+}
- // We don't support this interface, so return an error.
- // The operations above are for debugging purposes only,
- // this function is not supposed to ever return success
- return E_NOINTERFACE;
- }
+inline HRESULT QueryServicePassthrough(REFGUID guidService,
+ IUnknown* punkThis, REFIID riid, void** ppv,
+ IServiceProvider* pClientProvider)
+{
+ ATLASSERT(punkThis != 0);
+ CComPtr spDummy;
+ HRESULT hr = pClientProvider ?
+ pClientProvider->QueryService(guidService, riid,
+ reinterpret_cast(&spDummy)) :
+ E_NOINTERFACE;
+ if (SUCCEEDED(hr))
+ {
+ hr = punkThis->QueryInterface(riid, ppv);
+ }
+ return hr;
+}
- inline HRESULT QueryServicePassthrough(REFGUID guidService,
- IUnknown* punkThis, REFIID riid, void** ppv,
- IServiceProvider* pClientProvider)
- {
- ATLASSERT(punkThis != 0);
- CComPtr spDummy;
- HRESULT hr = pClientProvider ?
- pClientProvider->QueryService(guidService, riid,
- reinterpret_cast(&spDummy)) :
- E_NOINTERFACE;
- if (SUCCEEDED(hr))
- {
- hr = punkThis->QueryInterface(riid, ppv);
- }
- return hr;
- }
+} // end namespace PassthroughAPP::Detail
- } // end namespace PassthroughAPP::Detail
+// ===== IInternetProtocolImpl =====
- // ===== IInternetProtocolImpl =====
+inline STDMETHODIMP IInternetProtocolImpl::SetTargetUnknown(
+ IUnknown* punkTarget)
+{
+ ATLASSERT(punkTarget != 0);
+ if (!punkTarget)
+ {
+ return E_POINTER;
+ }
- inline STDMETHODIMP IInternetProtocolImpl::SetTargetUnknown(
- IUnknown* punkTarget)
- {
- ATLASSERT(punkTarget != 0);
- if (!punkTarget)
- {
- return E_POINTER;
- }
+ // This method should only be called once, and be the only source
+ // of target interface pointers.
+ ATLASSERT(m_spInternetProtocolUnk == 0);
+ ATLASSERT(m_spInternetProtocol == 0);
+ if (m_spInternetProtocolUnk || m_spInternetProtocol)
+ {
+ return E_UNEXPECTED;
+ }
- // This method should only be called once, and be the only source
- // of target interface pointers.
- ATLASSERT(m_spInternetProtocolUnk == 0);
- ATLASSERT(m_spInternetProtocol == 0);
- if (m_spInternetProtocolUnk || m_spInternetProtocol)
- {
- return E_UNEXPECTED;
- }
+ // We expect the target unknown to implement at least IInternetProtocol
+ // Otherwise we reject it
+ HRESULT hr = punkTarget->QueryInterface(&m_spInternetProtocol);
+ ATLASSERT(FAILED(hr) || m_spInternetProtocol != 0);
+ if (FAILED(hr))
+ {
+ return hr;
+ }
- // We expect the target unknown to implement at least IInternetProtocol
- // Otherwise we reject it
- HRESULT hr = punkTarget->QueryInterface(&m_spInternetProtocol);
- ATLASSERT(FAILED(hr) || m_spInternetProtocol != 0);
- if (FAILED(hr))
- {
- return hr;
- }
+ hr = m_spInternetProtocol->QueryInterface(&m_spInternetProtocolEx);
+ ATLASSERT(FAILED(hr) || m_spInternetProtocolEx != 0);
+ if (FAILED(hr))
+ {
+ return hr;
+ }
- ATLASSERT(m_spInternetProtocolInfo == 0);
- ATLASSERT(m_spInternetPriority == 0);
- ATLASSERT(m_spInternetThreadSwitch == 0);
- ATLASSERT(m_spWinInetInfo == 0);
- ATLASSERT(m_spWinInetHttpInfo == 0);
+ ATLASSERT(m_spInternetProtocolInfo == 0);
+ ATLASSERT(m_spInternetPriority == 0);
+ ATLASSERT(m_spInternetThreadSwitch == 0);
+ ATLASSERT(m_spWinInetInfo == 0);
+ ATLASSERT(m_spWinInetHttpInfo == 0);
- m_spInternetProtocolUnk = punkTarget;
- return S_OK;
- }
+ m_spInternetProtocolUnk = punkTarget;
+ return S_OK;
+}
- inline void IInternetProtocolImpl::ReleaseAll()
- {
- m_spInternetProtocolUnk.Release();
- m_spInternetProtocol.Release();
- m_spInternetProtocolInfo.Release();
- m_spInternetPriority.Release();
- m_spInternetThreadSwitch.Release();
- m_spWinInetInfo.Release();
- m_spWinInetHttpInfo.Release();
- }
+inline void IInternetProtocolImpl::ReleaseAll()
+{
+ m_spInternetProtocolUnk.Release();
+ m_spInternetProtocol.Release();
+ m_spInternetProtocolEx.Release();
+ m_spInternetProtocolInfo.Release();
+ m_spInternetPriority.Release();
+ m_spInternetThreadSwitch.Release();
+ m_spWinInetInfo.Release();
+ m_spWinInetHttpInfo.Release();
+ m_spWinInetCacheHints.Release();
+ m_spWinInetCacheHints2.Release();
+}
- // IInternetProtocolRoot
- inline STDMETHODIMP IInternetProtocolImpl::Start(
- /* [in] */ LPCWSTR szUrl,
- /* [in] */ IInternetProtocolSink *pOIProtSink,
- /* [in] */ IInternetBindInfo *pOIBindInfo,
- /* [in] */ DWORD grfPI,
- /* [in] */ HANDLE_PTR dwReserved)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Start(szUrl, pOIProtSink, pOIBindInfo, grfPI,
- dwReserved) :
- E_UNEXPECTED;
- }
+// IInternetProtocolRoot
+inline STDMETHODIMP IInternetProtocolImpl::Start(
+ /* [in] */ LPCWSTR szUrl,
+ /* [in] */ IInternetProtocolSink *pOIProtSink,
+ /* [in] */ IInternetBindInfo *pOIBindInfo,
+ /* [in] */ DWORD grfPI,
+ /* [in] */ HANDLE_PTR dwReserved)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Start(szUrl, pOIProtSink, pOIBindInfo, grfPI,
+ dwReserved) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Continue(
- /* [in] */ PROTOCOLDATA *pProtocolData)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Continue(pProtocolData) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Continue(
+ /* [in] */ PROTOCOLDATA *pProtocolData)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Continue(pProtocolData) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Abort(
- /* [in] */ HRESULT hrReason,
- /* [in] */ DWORD dwOptions)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Abort(hrReason, dwOptions) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Abort(
+ /* [in] */ HRESULT hrReason,
+ /* [in] */ DWORD dwOptions)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Abort(hrReason, dwOptions) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Terminate(
- /* [in] */ DWORD dwOptions)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Terminate(dwOptions) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Terminate(
+ /* [in] */ DWORD dwOptions)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Terminate(dwOptions) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Suspend()
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Suspend() :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Suspend()
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Suspend() :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Resume()
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Resume() :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Resume()
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Resume() :
+ E_UNEXPECTED;
+}
- // IInternetProtocol
- inline STDMETHODIMP IInternetProtocolImpl::Read(
- /* [in, out] */ void *pv,
- /* [in] */ ULONG cb,
- /* [out] */ ULONG *pcbRead)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Read(pv, cb, pcbRead) :
- E_UNEXPECTED;
- }
+// IInternetProtocol
+inline STDMETHODIMP IInternetProtocolImpl::Read(
+ /* [in, out] */ void *pv,
+ /* [in] */ ULONG cb,
+ /* [out] */ ULONG *pcbRead)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Read(pv, cb, pcbRead) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Seek(
- /* [in] */ LARGE_INTEGER dlibMove,
- /* [in] */ DWORD dwOrigin,
- /* [out] */ ULARGE_INTEGER *plibNewPosition)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->Seek(dlibMove, dwOrigin, plibNewPosition) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Seek(
+ /* [in] */ LARGE_INTEGER dlibMove,
+ /* [in] */ DWORD dwOrigin,
+ /* [out] */ ULARGE_INTEGER *plibNewPosition)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->Seek(dlibMove, dwOrigin, plibNewPosition) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::LockRequest(
- /* [in] */ DWORD dwOptions)
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->LockRequest(dwOptions) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::LockRequest(
+ /* [in] */ DWORD dwOptions)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->LockRequest(dwOptions) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::UnlockRequest()
- {
- ATLASSERT(m_spInternetProtocol != 0);
- return m_spInternetProtocol ?
- m_spInternetProtocol->UnlockRequest() :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::UnlockRequest()
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ return m_spInternetProtocol ?
+ m_spInternetProtocol->UnlockRequest() :
+ E_UNEXPECTED;
+}
- // IInternetProtocolInfo
- inline STDMETHODIMP IInternetProtocolImpl::ParseUrl(
- /* [in] */ LPCWSTR pwzUrl,
- /* [in] */ PARSEACTION ParseAction,
- /* [in] */ DWORD dwParseFlags,
- /* [out] */ LPWSTR pwzResult,
- /* [in] */ DWORD cchResult,
- /* [out] */ DWORD *pcchResult,
- /* [in] */ DWORD dwReserved)
- {
- ATLASSERT(m_spInternetProtocolInfo != 0);
- return m_spInternetProtocolInfo ?
- m_spInternetProtocolInfo->ParseUrl(pwzUrl, ParseAction, dwParseFlags,
- pwzResult, cchResult, pcchResult, dwReserved) :
- E_UNEXPECTED;
- }
+// IInternetProtocolEx
- inline STDMETHODIMP IInternetProtocolImpl::CombineUrl(
- /* [in] */ LPCWSTR pwzBaseUrl,
- /* [in] */ LPCWSTR pwzRelativeUrl,
- /* [in] */ DWORD dwCombineFlags,
- /* [out] */ LPWSTR pwzResult,
- /* [in] */ DWORD cchResult,
- /* [out] */ DWORD *pcchResult,
- /* [in] */ DWORD dwReserved)
- {
- ATLASSERT(m_spInternetProtocolInfo != 0);
- return m_spInternetProtocolInfo ?
- m_spInternetProtocolInfo->CombineUrl(pwzBaseUrl, pwzRelativeUrl,
- dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::StartEx(
+ IUri *pUri,
+ IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI,
+ HANDLE_PTR dwReserved)
+{
+ ATLASSERT(m_spInternetProtocolEx != 0);
+ return m_spInternetProtocolEx ?
+ m_spInternetProtocolEx->StartEx(pUri, pOIProtSink, pOIBindInfo, grfPI, dwReserved) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::CompareUrl(
- /* [in] */ LPCWSTR pwzUrl1,
- /* [in] */ LPCWSTR pwzUrl2,
- /* [in] */ DWORD dwCompareFlags)
- {
- ATLASSERT(m_spInternetProtocolInfo != 0);
- return m_spInternetProtocolInfo ?
- m_spInternetProtocolInfo->CompareUrl(pwzUrl1,pwzUrl2, dwCompareFlags) :
- E_UNEXPECTED;
- }
+// IInternetProtocolInfo
+inline STDMETHODIMP IInternetProtocolImpl::ParseUrl(
+ /* [in] */ LPCWSTR pwzUrl,
+ /* [in] */ PARSEACTION ParseAction,
+ /* [in] */ DWORD dwParseFlags,
+ /* [out] */ LPWSTR pwzResult,
+ /* [in] */ DWORD cchResult,
+ /* [out] */ DWORD *pcchResult,
+ /* [in] */ DWORD dwReserved)
+{
+ ATLASSERT(m_spInternetProtocolInfo != 0);
+ return m_spInternetProtocolInfo ?
+ m_spInternetProtocolInfo->ParseUrl(pwzUrl, ParseAction, dwParseFlags,
+ pwzResult, cchResult, pcchResult, dwReserved) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::QueryInfo(
- /* [in] */ LPCWSTR pwzUrl,
- /* [in] */ QUERYOPTION QueryOption,
- /* [in] */ DWORD dwQueryFlags,
- /* [in, out] */ LPVOID pBuffer,
- /* [in] */ DWORD cbBuffer,
- /* [in, out] */ DWORD *pcbBuf,
- /* [in] */ DWORD dwReserved)
- {
- ATLASSERT(m_spInternetProtocolInfo != 0);
- return m_spInternetProtocolInfo ?
- m_spInternetProtocolInfo->QueryInfo(pwzUrl, QueryOption, dwQueryFlags,
- pBuffer, cbBuffer, pcbBuf, dwReserved) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::CombineUrl(
+ /* [in] */ LPCWSTR pwzBaseUrl,
+ /* [in] */ LPCWSTR pwzRelativeUrl,
+ /* [in] */ DWORD dwCombineFlags,
+ /* [out] */ LPWSTR pwzResult,
+ /* [in] */ DWORD cchResult,
+ /* [out] */ DWORD *pcchResult,
+ /* [in] */ DWORD dwReserved)
+{
+ ATLASSERT(m_spInternetProtocolInfo != 0);
+ return m_spInternetProtocolInfo ?
+ m_spInternetProtocolInfo->CombineUrl(pwzBaseUrl, pwzRelativeUrl,
+ dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved) :
+ E_UNEXPECTED;
+}
- // IInternetPriority
- inline STDMETHODIMP IInternetProtocolImpl::SetPriority(
- /* [in] */ LONG nPriority)
- {
- ATLASSERT(m_spInternetPriority != 0);
- return m_spInternetPriority ?
- m_spInternetPriority->SetPriority(nPriority) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::CompareUrl(
+ /* [in] */ LPCWSTR pwzUrl1,
+ /* [in] */ LPCWSTR pwzUrl2,
+ /* [in] */ DWORD dwCompareFlags)
+{
+ ATLASSERT(m_spInternetProtocolInfo != 0);
+ return m_spInternetProtocolInfo ?
+ m_spInternetProtocolInfo->CompareUrl(pwzUrl1,pwzUrl2, dwCompareFlags) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::GetPriority(
- /* [out] */ LONG *pnPriority)
- {
- ATLASSERT(m_spInternetPriority != 0);
- return m_spInternetPriority ?
- m_spInternetPriority->GetPriority(pnPriority) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::QueryInfo(
+ /* [in] */ LPCWSTR pwzUrl,
+ /* [in] */ QUERYOPTION QueryOption,
+ /* [in] */ DWORD dwQueryFlags,
+ /* [in, out] */ LPVOID pBuffer,
+ /* [in] */ DWORD cbBuffer,
+ /* [in, out] */ DWORD *pcbBuf,
+ /* [in] */ DWORD dwReserved)
+{
+ ATLASSERT(m_spInternetProtocolInfo != 0);
+ return m_spInternetProtocolInfo ?
+ m_spInternetProtocolInfo->QueryInfo(pwzUrl, QueryOption, dwQueryFlags,
+ pBuffer, cbBuffer, pcbBuf, dwReserved) :
+ E_UNEXPECTED;
+}
- // IInternetThreadSwitch
- inline STDMETHODIMP IInternetProtocolImpl::Prepare()
- {
- ATLASSERT(m_spInternetThreadSwitch != 0);
- return m_spInternetThreadSwitch ?
- m_spInternetThreadSwitch->Prepare() :
- E_UNEXPECTED;
- }
+// IInternetPriority
+inline STDMETHODIMP IInternetProtocolImpl::SetPriority(
+ /* [in] */ LONG nPriority)
+{
+ ATLASSERT(m_spInternetPriority != 0);
+ return m_spInternetPriority ?
+ m_spInternetPriority->SetPriority(nPriority) :
+ E_UNEXPECTED;
+}
- inline STDMETHODIMP IInternetProtocolImpl::Continue()
- {
- ATLASSERT(m_spInternetThreadSwitch != 0);
- return m_spInternetThreadSwitch ?
- m_spInternetThreadSwitch->Continue() :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::GetPriority(
+ /* [out] */ LONG *pnPriority)
+{
+ ATLASSERT(m_spInternetPriority != 0);
+ return m_spInternetPriority ?
+ m_spInternetPriority->GetPriority(pnPriority) :
+ E_UNEXPECTED;
+}
- // IWinInetInfo
- inline STDMETHODIMP IInternetProtocolImpl::QueryOption(
- /* [in] */ DWORD dwOption,
- /* [in, out] */ LPVOID pBuffer,
- /* [in, out] */ DWORD *pcbBuf)
- {
- ATLASSERT(m_spWinInetInfo != 0);
- return m_spWinInetInfo ?
- m_spWinInetInfo->QueryOption(dwOption, pBuffer, pcbBuf) :
- E_UNEXPECTED;
- }
+// IInternetThreadSwitch
+inline STDMETHODIMP IInternetProtocolImpl::Prepare()
+{
+ ATLASSERT(m_spInternetThreadSwitch != 0);
+ return m_spInternetThreadSwitch ?
+ m_spInternetThreadSwitch->Prepare() :
+ E_UNEXPECTED;
+}
- // IWinInetHttpInfo
- inline STDMETHODIMP IInternetProtocolImpl::QueryInfo(
- /* [in] */ DWORD dwOption,
- /* [in, out] */ LPVOID pBuffer,
- /* [in, out] */ DWORD *pcbBuf,
- /* [in, out] */ DWORD *pdwFlags,
- /* [in, out] */ DWORD *pdwReserved)
- {
- ATLASSERT(m_spWinInetHttpInfo != 0);
- return m_spWinInetHttpInfo ?
- m_spWinInetHttpInfo->QueryInfo(dwOption, pBuffer, pcbBuf, pdwFlags,
- pdwReserved) :
- E_UNEXPECTED;
- }
+inline STDMETHODIMP IInternetProtocolImpl::Continue()
+{
+ ATLASSERT(m_spInternetThreadSwitch != 0);
+ return m_spInternetThreadSwitch ?
+ m_spInternetThreadSwitch->Continue() :
+ E_UNEXPECTED;
+}
- // ===== IInternetProtocolSinkImpl =====
+// IWinInetInfo
+inline STDMETHODIMP IInternetProtocolImpl::QueryOption(
+ /* [in] */ DWORD dwOption,
+ /* [in, out] */ LPVOID pBuffer,
+ /* [in, out] */ DWORD *pcbBuf)
+{
+ ATLASSERT(m_spWinInetInfo != 0);
+ return m_spWinInetInfo ?
+ m_spWinInetInfo->QueryOption(dwOption, pBuffer, pcbBuf) :
+ E_UNEXPECTED;
+}
- inline HRESULT IInternetProtocolSinkImpl::OnStart(LPCWSTR szUrl,
- IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
- DWORD grfPI, HANDLE_PTR dwReserved, IInternetProtocol* pTargetProtocol)
- {
- ATLASSERT(pOIProtSink != 0);
- ATLASSERT(pOIBindInfo != 0);
- ATLASSERT(pTargetProtocol != 0);
- if (!pOIProtSink || !pOIBindInfo || !pTargetProtocol)
- {
- return E_POINTER;
- }
+// IWinInetHttpInfo
+inline STDMETHODIMP IInternetProtocolImpl::QueryInfo(
+ /* [in] */ DWORD dwOption,
+ /* [in, out] */ LPVOID pBuffer,
+ /* [in, out] */ DWORD *pcbBuf,
+ /* [in, out] */ DWORD *pdwFlags,
+ /* [in, out] */ DWORD *pdwReserved)
+{
+ ATLASSERT(m_spWinInetHttpInfo != 0);
+ return m_spWinInetHttpInfo ?
+ m_spWinInetHttpInfo->QueryInfo(dwOption, pBuffer, pcbBuf, pdwFlags,
+ pdwReserved) :
+ E_UNEXPECTED;
+}
- // This method should only be called once, and be the only source
- // of target interface pointers.
- ATLASSERT(m_spInternetProtocolSink == 0);
- ATLASSERT(m_spTargetProtocol == 0);
- if (m_spInternetProtocolSink || m_spTargetProtocol)
- {
- return E_UNEXPECTED;
- }
+// IWinInetCacheHints
- ATLASSERT(m_spServiceProvider == 0);
+inline STDMETHODIMP IInternetProtocolImpl::SetCacheExtension(
+ /* [in] */ LPCWSTR pwzExt,
+ /* [in, out] */ LPVOID pszCacheFile,
+ /* [in, out] */ DWORD *pcbCacheFile,
+ /* [in, out] */ DWORD *pdwWinInetError,
+ /* [in, out] */ DWORD *pdwReserved)
+{
+ ATLASSERT(m_spWinInetCacheHints2 != NULL);
+ return m_spWinInetCacheHints2 ?
+ m_spWinInetCacheHints2->SetCacheExtension(pwzExt, pszCacheFile, pcbCacheFile,
+ pdwWinInetError, pdwReserved) : E_UNEXPECTED;
+}
- m_spInternetProtocolSink = pOIProtSink;
- m_spTargetProtocol = pTargetProtocol;
- return S_OK;
- }
+inline STDMETHODIMP IInternetProtocolImpl::SetCacheExtension2(
+ /* [in] */ LPCWSTR pwzExt,
+ /* [out] */ WCHAR *pwzCacheFile,
+ /* [in, out] */ DWORD *pcchCacheFile,
+ /* [out] */ DWORD *pdwWinInetError,
+ /* [out] */ DWORD *pdwReserved)
+{
+ ATLASSERT(m_spWinInetCacheHints2 != NULL);
+ return m_spWinInetCacheHints2 ?
+ m_spWinInetCacheHints2->SetCacheExtension2(pwzExt, pwzCacheFile, pcchCacheFile,
+ pdwWinInetError, pdwReserved) : E_UNEXPECTED;
+}
- inline void IInternetProtocolSinkImpl::ReleaseAll()
- {
- m_spInternetProtocolSink.Release();
- m_spServiceProvider.Release();
- m_spTargetProtocol.Release();
- }
+// ===== IInternetProtocolSinkImpl =====
- inline IServiceProvider* IInternetProtocolSinkImpl::GetClientServiceProvider()
- {
- return m_spServiceProvider;
- }
+inline HRESULT IInternetProtocolSinkImpl::InitMembers(IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ IInternetProtocol* pTargetProtocol)
+{
+ ATLASSERT(pOIProtSink != 0);
+ ATLASSERT(pOIBindInfo != 0);
+ ATLASSERT(pTargetProtocol != 0);
+ if (!pOIProtSink || !pOIBindInfo || !pTargetProtocol)
+ {
+ return E_POINTER;
+ }
- inline HRESULT IInternetProtocolSinkImpl::QueryServiceFromClient(
- REFGUID guidService, REFIID riid, void** ppvObject)
- {
- HRESULT hr = S_OK;
- CComPtr spClientProvider = m_spServiceProvider;
- if (!spClientProvider)
- {
- hr = m_spInternetProtocolSink->QueryInterface(&spClientProvider);
- ATLASSERT(SUCCEEDED(hr) && spClientProvider != 0);
- }
- if (SUCCEEDED(hr))
- {
- hr = spClientProvider->QueryService(guidService, riid, ppvObject);
- }
- return hr;
- }
+ // This method should only be called once, and be the only source
+ // of target interface pointers.
+ ATLASSERT(m_spInternetProtocolSink == 0);
+ ATLASSERT(m_spInternetBindInfo == 0);
+ ATLASSERT(m_spTargetProtocol == 0);
+ if (m_spInternetProtocolSink || m_spInternetBindInfo || m_spTargetProtocol)
+ {
+ return E_UNEXPECTED;
+ }
- // IInternetProtocolSink
- inline STDMETHODIMP IInternetProtocolSinkImpl::Switch(
- /* [in] */ PROTOCOLDATA *pProtocolData)
- {
- ATLASSERT(m_spInternetProtocolSink != 0);
- return m_spInternetProtocolSink ?
- m_spInternetProtocolSink->Switch(pProtocolData) :
- E_UNEXPECTED;
- }
+ ATLASSERT(m_spServiceProvider == 0);
- inline STDMETHODIMP IInternetProtocolSinkImpl::ReportProgress(
- /* [in] */ ULONG ulStatusCode,
- /* [in] */ LPCWSTR szStatusText)
- {
- ATLASSERT(m_spInternetProtocolSink != 0);
- return m_spInternetProtocolSink ?
- m_spInternetProtocolSink->ReportProgress(ulStatusCode, szStatusText) :
- E_UNEXPECTED;
- }
+ m_spInternetProtocolSink = pOIProtSink;
+ m_spInternetBindInfo = pOIBindInfo;
+ if (FAILED(m_spInternetBindInfo->QueryInterface(&m_spInternetBindInfoEx)))
+ m_spInternetBindInfoEx = NULL;
+ m_spTargetProtocol = pTargetProtocol;
+ return S_OK;
+}
- inline STDMETHODIMP IInternetProtocolSinkImpl::ReportData(
- /* [in] */ DWORD grfBSCF,
- /* [in] */ ULONG ulProgress,
- /* [in] */ ULONG ulProgressMax)
- {
- ATLASSERT(m_spInternetProtocolSink != 0);
- return m_spInternetProtocolSink ?
- m_spInternetProtocolSink->ReportData(grfBSCF, ulProgress,
- ulProgressMax) :
- E_UNEXPECTED;
- }
+inline HRESULT IInternetProtocolSinkImpl::OnStart(LPCWSTR szUrl,
+ IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI, HANDLE_PTR dwReserved, IInternetProtocol* pTargetProtocol)
+{
+ return InitMembers(pOIProtSink, pOIBindInfo, pTargetProtocol);
+}
- inline STDMETHODIMP IInternetProtocolSinkImpl::ReportResult(
- /* [in] */ HRESULT hrResult,
- /* [in] */ DWORD dwError,
- /* [in] */ LPCWSTR szResult)
- {
- ATLASSERT(m_spInternetProtocolSink != 0);
+inline HRESULT IInternetProtocolSinkImpl::OnStartEx(IUri* pUri,
+ IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI, HANDLE_PTR dwReserved, IInternetProtocol* pTargetProtocol)
+{
+ return InitMembers(pOIProtSink, pOIBindInfo, pTargetProtocol);
+}
- // On some websites there are broken requests, that keep on redirecting without a stop.
- // For example: http://telegrafua.com/ has a request to: http://www.ool.ua/webroot/delivery/images/ool-button.gif
- // which causes IE tab to crash in urlmon.dll. That request doesn't ever resolve, since it's constantly responding
- // with HTTP 302.
- // It seems like WinInet (urlmon.dll) doesn't expect anything like that to happen, and relies on APP to make sure it doesn't.
- // So here we detect if there has been too many redirects (ie INET_E_REDIRECT_FAILED) and we just notify WinInet
- // that there has been a generic problem, not redirect specific error.
+inline void IInternetProtocolSinkImpl::ReleaseAll()
+{
+ m_spInternetProtocolSink.Release();
+ m_spServiceProvider.Release();
+ m_spInternetBindInfo.Release();
+ m_spInternetBindInfoEx.Release();
+ m_spUriContainer.Release();
+ m_spTargetProtocol.Release();
+}
- // This seem to only postpone the issue to some different place. Undo for now
-// if (hrResult == INET_E_REDIRECT_FAILED)
-// hrResult = S_FALSE;
+inline IServiceProvider* IInternetProtocolSinkImpl::GetClientServiceProvider()
+{
+ return m_spServiceProvider;
+}
- return m_spInternetProtocolSink ?
- m_spInternetProtocolSink->ReportResult(hrResult, dwError, szResult) :
- E_UNEXPECTED;
- }
+inline HRESULT IInternetProtocolSinkImpl::QueryServiceFromClient(
+ REFGUID guidService, REFIID riid, void** ppvObject)
+{
+ HRESULT hr = S_OK;
+ CComPtr spClientProvider = m_spServiceProvider;
+ if (!spClientProvider)
+ {
+ hr = m_spInternetProtocolSink->QueryInterface(&spClientProvider);
+ ATLASSERT(SUCCEEDED(hr) && spClientProvider != 0);
+ }
+ if (SUCCEEDED(hr))
+ {
+ hr = spClientProvider->QueryService(guidService, riid, ppvObject);
+ }
+ return hr;
+}
- // IServiceProvider
- inline STDMETHODIMP IInternetProtocolSinkImpl::QueryService(
- /* [in] */ REFGUID guidService,
- /* [in] */ REFIID riid,
- /* [out] */ void** ppvObject)
- {
- ATLASSERT(m_spServiceProvider != 0);
- return m_spServiceProvider ?
- m_spServiceProvider->QueryService(guidService, riid, ppvObject) :
- E_UNEXPECTED;
- }
+// IInternetProtocolSink
+inline STDMETHODIMP IInternetProtocolSinkImpl::Switch(
+ /* [in] */ PROTOCOLDATA *pProtocolData)
+{
+ ATLASSERT(m_spInternetProtocolSink != 0);
+ return m_spInternetProtocolSink ?
+ m_spInternetProtocolSink->Switch(pProtocolData) :
+ E_UNEXPECTED;
+}
- // ===== CInternetProtocolSinkWithSP =====
+inline STDMETHODIMP IInternetProtocolSinkImpl::ReportProgress(
+ /* [in] */ ULONG ulStatusCode,
+ /* [in] */ LPCWSTR szStatusText)
+{
+ ATLASSERT(m_spInternetProtocolSink != 0);
+ return m_spInternetProtocolSink ?
+ m_spInternetProtocolSink->ReportProgress(ulStatusCode, szStatusText) :
+ E_UNEXPECTED;
+}
- template
- inline HRESULT CInternetProtocolSinkWithSP::OnStart(
- LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
- IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
- IInternetProtocol* pTargetProtocol)
- {
- ATLASSERT(m_spServiceProvider == 0);
- if (m_spServiceProvider)
- {
- return E_UNEXPECTED;
- }
- HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI,
- dwReserved, pTargetProtocol);
- if (SUCCEEDED(hr))
- {
- pOIProtSink->QueryInterface(&m_spServiceProvider);
- }
- return hr;
- }
+inline STDMETHODIMP IInternetProtocolSinkImpl::ReportData(
+ /* [in] */ DWORD grfBSCF,
+ /* [in] */ ULONG ulProgress,
+ /* [in] */ ULONG ulProgressMax)
+{
+ ATLASSERT(m_spInternetProtocolSink != 0);
+ return m_spInternetProtocolSink ?
+ m_spInternetProtocolSink->ReportData(grfBSCF, ulProgress,
+ ulProgressMax) :
+ E_UNEXPECTED;
+}
- template
- inline HRESULT CInternetProtocolSinkWithSP::
- _InternalQueryService(REFGUID guidService, REFIID riid, void** ppvObject)
- {
- return E_NOINTERFACE;
- }
+inline STDMETHODIMP IInternetProtocolSinkImpl::ReportResult(
+ /* [in] */ HRESULT hrResult,
+ /* [in] */ DWORD dwError,
+ /* [in] */ LPCWSTR szResult)
+{
+ ATLASSERT(m_spInternetProtocolSink != 0);
+ return m_spInternetProtocolSink ?
+ m_spInternetProtocolSink->ReportResult(hrResult, dwError, szResult) :
+ E_UNEXPECTED;
+}
- template
- inline STDMETHODIMP CInternetProtocolSinkWithSP::QueryService(
- REFGUID guidService, REFIID riid, void** ppv)
- {
- T* pT = static_cast(this);
- HRESULT hr = pT->_InternalQueryService(guidService, riid, ppv);
- if (FAILED(hr) && m_spServiceProvider)
- {
- hr = m_spServiceProvider->QueryService(guidService, riid, ppv);
- }
- return hr;
- }
+// IServiceProvider
+inline STDMETHODIMP IInternetProtocolSinkImpl::QueryService(
+ /* [in] */ REFGUID guidService,
+ /* [in] */ REFIID riid,
+ /* [out] */ void** ppvObject)
+{
+ ATLASSERT(m_spServiceProvider != 0);
+ return m_spServiceProvider ?
+ m_spServiceProvider->QueryService(guidService, riid, ppvObject) :
+ E_UNEXPECTED;
+}
+
+// IInternetBindInfo
+inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindInfo(
+ /* [out] */ DWORD *grfBINDF,
+ /* [in, out] */ BINDINFO *pbindinfo)
+{
+ ATLASSERT(m_spInternetBindInfo != 0);
+ return m_spInternetBindInfo ?
+ m_spInternetBindInfo->GetBindInfo(grfBINDF, pbindinfo) :
+ E_UNEXPECTED;
+}
+
+inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindString(
+ /* [in] */ ULONG ulStringType,
+ /* [in, out] */ LPOLESTR *ppwzStr,
+ /* [in] */ ULONG cEl,
+ /* [in, out] */ ULONG *pcElFetched)
+{
+ ATLASSERT(m_spInternetBindInfo != 0);
+ return m_spInternetBindInfo ?
+ m_spInternetBindInfo->GetBindString(ulStringType, ppwzStr, cEl,
+ pcElFetched) :
+ E_UNEXPECTED;
+}
+
+// IInternetBindInfoEx
+inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindInfoEx(
+ DWORD *grfBINDF,
+ BINDINFO *pbindinfo,
+ DWORD *grfBINDF2,
+ DWORD *pdwReserved)
+{
+ ATLASSERT(m_spInternetBindInfoEx != 0);
+ return m_spInternetBindInfoEx ?
+ m_spInternetBindInfoEx->GetBindInfoEx(grfBINDF, pbindinfo,
+ grfBINDF2, pdwReserved) : E_UNEXPECTED;
+}
+
+inline STDMETHODIMP IInternetProtocolSinkImpl::GetIUri(
+ IUri **ppIUri
+)
+{
+ ATLASSERT(m_spUriContainer != 0);
+ return m_spUriContainer ?
+ m_spUriContainer->GetIUri(ppIUri) : E_UNEXPECTED;
+}
+
+// ===== CInternetProtocolSinkWithSP =====
+
+template
+inline HRESULT CInternetProtocolSinkWithSP::OnStart(
+ LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocol* pTargetProtocol)
+{
+ ATLASSERT(m_spServiceProvider == 0);
+ if (m_spServiceProvider)
+ {
+ return E_UNEXPECTED;
+ }
+ HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI,
+ dwReserved, pTargetProtocol);
+ if (SUCCEEDED(hr))
+ {
+ pOIProtSink->QueryInterface(&m_spServiceProvider);
+ }
+ return hr;
+}
+
+template
+inline HRESULT CInternetProtocolSinkWithSP::OnStartEx(
+ IUri* pUri, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocol* pTargetProtocol)
+{
+ ATLASSERT(m_spServiceProvider == 0);
+ if (m_spServiceProvider)
+ {
+ return E_UNEXPECTED;
+ }
+ HRESULT hr = BaseClass::OnStartEx(pUri, pOIProtSink, pOIBindInfo, grfPI,
+ dwReserved, pTargetProtocol);
+ if (SUCCEEDED(hr))
+ {
+ pOIProtSink->QueryInterface(&m_spServiceProvider);
+ }
+ return hr;
+}
+
+template
+inline HRESULT CInternetProtocolSinkWithSP::
+ _InternalQueryService(REFGUID guidService, REFIID riid, void** ppvObject)
+{
+ return E_NOINTERFACE;
+}
+
+template
+inline STDMETHODIMP CInternetProtocolSinkWithSP::QueryService(
+ REFGUID guidService, REFIID riid, void** ppv)
+{
+ T* pT = static_cast(this);
+ HRESULT hr = pT->_InternalQueryService(guidService, riid, ppv);
+ if (FAILED(hr) && m_spServiceProvider)
+ {
+ hr = m_spServiceProvider->QueryService(guidService, riid, ppv);
+ }
+ return hr;
+}
+
+// ===== CInternetProtocol =====
+
+// IInternetProtocolRoot
+template
+inline STDMETHODIMP CInternetProtocol::Start(
+ LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
+{
+ ATLASSERT(m_spInternetProtocol != 0);
+ if (!m_spInternetProtocol)
+ {
+ return E_UNEXPECTED;
+ }
+
+ return StartPolicy::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI,
+ dwReserved, m_spInternetProtocol);
+}
+
+// IInternetProtocolEx
+template
+inline STDMETHODIMP CInternetProtocol::StartEx(
+ IUri* pUri, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
+{
+ ATLASSERT(m_spInternetProtocolEx != 0);
+ if (!m_spInternetProtocolEx)
+ {
+ return E_UNEXPECTED;
+ }
+
+ return StartPolicy::OnStartEx(pUri, pOIProtSink, pOIBindInfo, grfPI,
+ dwReserved, m_spInternetProtocolEx);
+}
+
} // end namespace PassthroughAPP
#endif // PASSTHROUGHAPP_PROTOCOLIMPL_INL
Index: src/plugin/passthroughapp/README.md
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/plugin/passthroughapp/README.md
@@ -0,0 +1,107 @@
+# Passthrough APP (Asynchronous Pluggable Protocol)
+
+## Motivation and History
+
+Internet Explorer takes a complex and challenging [approach to extensibility](http://msdn.microsoft.com/en-us/library/hh772401.aspx) based on [Window's Component Object Model (COM)](https://www.microsoft.com/com/default.mspx). If you are an experienced and skilled C++ developer, you can create add-ons for IE that offer similar functionality to that of equivalents for other popular browsers like Chrome and Firefox.
+
+However, there are striking gaps in the capabilities of the official APIs that make certain types of add-ons impossible. One significant example is the processing of network requests. The web browser control used by IE handles a few events that are triggered before navigating to a page, when navigation completes, when document loading completes, etc. However, these events are only triggered for page and frame loads (not for subordinate requests like images and stylesheets). Their behavior when a page is refreshed is counterintuitive. And they provide little or no features for viewing and modifying web requests and traffic (e.g. adding new headers to a request or redirecting it to a different URL).
+
+Igor Tandetnik's Passthrough APP is an attempt to bridge these gaps in an ingenious way: by replacing IE's implementation of the HTTP and HTTPS protocols with a new one that does nothing more than delegate to the default implementation. In this way, we are able to spy on and influence the interactions that occur. If a request is made for a URL, we can add headers to the request,for example, before passing it on to the built-in protocol handler.
+
+As the Passthrough APP is no longer actively maintained, this Github project is an attempt to provide a canonical location where the source code can be downloaded, bugfixes and improvements can be proposed, issues can be filed, etc. We have updated the "Passthrough APP beta" sources written by Igor Tandetnik to work with the latest versions of Internet Explorer (versions 8 and 9 at the time of this writing).
+
+## User Guide
+
+### Customizing the protocol sink
+
+The Passthrough APP is designed for us in a [Browser Helper Object](http://msdn.microsoft.com/en-us/library/bb250436). If you are using it, you presumably want to customize some of the behavior of the protocol (used to start requests) and/or sink (used to receive notifications about requests).
+
+In the simplest case you can customize the sink so that you can monitor the progress of requests and modify them (e.g. by changing headers). To do so, create a source file to implement your new sink class:
+
+```c++
+class CMyProtocolSink :
+ public PassthroughAPP::CInternetProtocolSinkWithSP,
+ public IHttpNegotiate
+{
+ typedef PassthroughAPP::CInternetProtocolSinkWithSP BaseClass;
+
+public:
+ BEGIN_COM_MAP(CMyProtocolSink)
+ COM_INTERFACE_ENTRY(IHttpNegotiate)
+ COM_INTERFACE_ENTRY_CHAIN(BaseClass)
+ END_COM_MAP()
+
+ BEGIN_SERVICE_MAP(CMyProtocolSink)
+ SERVICE_ENTRY(IID_IHttpNegotiate)
+ END_SERVICE_MAP()
+
+ // IHttpNegotiate
+ STDMETHODIMP BeginningTransaction(
+ /* [in] */ LPCWSTR szURL,
+ /* [in] */ LPCWSTR szHeaders,
+ /* [in] */ DWORD dwReserved,
+ /* [out] */ LPWSTR *pszAdditionalHeaders);
+
+ STDMETHODIMP OnResponse(
+ /* [in] */ DWORD dwResponseCode,
+ /* [in] */ LPCWSTR szResponseHeaders,
+ /* [in] */ LPCWSTR szRequestHeaders,
+ /* [out] */ LPWSTR *pszAdditionalRequestHeaders);
+
+ STDMETHODIMP ReportProgress(
+ /* [in] */ ULONG ulStatusCode,
+ /* [in] */ LPCWSTR szStatusText);
+};
+```
+
+In this case we are implementing a sink that overrides the functionality of the `IHttpNegotiate` interface. You can override any of the interfaces implemented by the Passthrough APP sink class (`IInternetProtocolSinkImpl`) in a similar manner.
+
+### Creating the APP
+
+In addition to a sink, you also need to create a class that implements the APP itself. This class takes a "start policy" class as a template parameter. The Passthrough APP toolkit provides two built-in start policy classes: `NoSinkStartPolicy`, which simply starts the request using the default sink, and `CustomSinkStartPolicy`, which uses your custom sink (see previous section).
+
+The latter is used as follows:
+
+```c++
+class CMyAPP;
+typedef PassthroughAPP::CustomSinkStartPolicy MyStartPolicy;
+
+class CMyAPP :
+ public PassthroughAPP::CInternetProtocol
+{
+};
+```
+
+### Registering the class factory
+
+In order for your Passthrough APP to be used, you need to register the class factory used by Internet Explorer to instantiate handlers for the HTTP and HTTPS protocols. First, define your factory using the templated `CMetaFactory` class included in the toolkit:
+
+```c++
+#include "ProtocolCF.h"
+#include "MyProtocolSink.h"
+
+typedef PassthroughAPP::CMetaFactory MetaFactory;
+```
+
+Add two new members to your BHO's class:
+
+```c++
+CComPtr m_CFHTTP;
+CComPtr m_CFHTTPS;
+```
+
+Then add this code to your BHO's `SetSite` method to register the class factory:
+
+```c++
+CComPtr pInternetSession;
+CoInternetGetSession(0, &pInternetSession, 0);
+
+MetaFactory::CreateInstance(CLSID_HttpProtocol, &m_CFHTTP);
+pInternetSession->RegisterNameSpace(m_CFHTTP, CLSID_NULL, L"http", 0, 0, 0);
+
+MetaFactory::CreateInstance(CLSID_HttpSProtocol, &m_CFHTTPS);
+pInternetSession->RegisterNameSpace(m_CFHTTPS, CLSID_NULL, L"https", 0, 0, 0);
+```
+
+You can unregister the factories using the `UnregisterNameSpace` methods of `IInternetSession` if you no longer want your Passthrough APP to be used.
Index: src/plugin/passthroughapp/SinkPolicy.h
===================================================================
--- a/src/plugin/passthroughapp/SinkPolicy.h
+++ b/src/plugin/passthroughapp/SinkPolicy.h
@@ -1,20 +1,3 @@
-/*
- * This file is part of Adblock Plus ,
- * Copyright (C) 2006-2015 Eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see .
- */
-
#ifndef PASSTHROUGHAPP_SINKPOLICY_H
#define PASSTHROUGHAPP_SINKPOLICY_H
@@ -36,6 +19,9 @@
IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
IInternetProtocol* pTargetProtocol) const;
+ HRESULT OnStartEx(IUri *pUri, IInternetProtocolSink *pOIProtSink,
+ IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocolEx* pTargetProtocol) const;
};
template
@@ -174,6 +160,10 @@
DWORD grfPI, HANDLE_PTR dwReserved,
IInternetProtocol* pTargetProtocol) const;
+ HRESULT OnStartEx(IUri* pUri,
+ IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocolEx* pTargetProtocol) const;
static Sink* GetSink(const Protocol* pProtocol);
Sink* GetSink() const;
@@ -184,4 +174,4 @@
#include "SinkPolicy.inl"
-#endif // PASSTHROUGHAPP_SINKPOLICY_H
\ No newline at end of file
+#endif // PASSTHROUGHAPP_SINKPOLICY_H
Index: src/plugin/passthroughapp/SinkPolicy.inl
===================================================================
--- a/src/plugin/passthroughapp/SinkPolicy.inl
+++ b/src/plugin/passthroughapp/SinkPolicy.inl
@@ -1,20 +1,3 @@
-/*
- * This file is part of Adblock Plus ,
- * Copyright (C) 2006-2015 Eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see .
- */
-
#ifndef PASSTHROUGHAPP_SINKPOLICY_INL
#define PASSTHROUGHAPP_SINKPOLICY_INL
@@ -41,6 +24,15 @@
grfPI, dwReserved);
}
+inline HRESULT NoSinkStartPolicy::OnStartEx(IUri* pUri,
+ IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocolEx* pTargetProtocol) const
+{
+ ATLASSERT(pTargetProtocol != 0);
+ return pTargetProtocol->StartEx(pUri, pOIProtSink, pOIBindInfo,
+ grfPI, dwReserved);
+}
// ===== CComObjectSharedRef =====
@@ -387,21 +379,57 @@
CComPtr spBindInfo;
if (SUCCEEDED(hr))
{
- hr = pSink->QueryInterface(IID_IInternetProtocolSink, reinterpret_cast(&spSink));
+ hr = pSink->QueryInterface(IID_IInternetProtocolSink,
+ reinterpret_cast(&spSink));
ATLASSERT(SUCCEEDED(hr) && spSink != 0);
}
if (SUCCEEDED(hr))
{
- hr = pSink->QueryInterface(IID_IInternetBindInfo, reinterpret_cast(&spBindInfo));
+ hr = pSink->QueryInterface(IID_IInternetBindInfo,
+ reinterpret_cast(&spBindInfo));
ATLASSERT(SUCCEEDED(hr) && spBindInfo != 0);
}
if (SUCCEEDED(hr))
{
- hr = pTargetProtocol->Start(szUrl, spSink, spBindInfo, grfPI, dwReserved);
+ hr = pTargetProtocol->Start(szUrl, spSink, spBindInfo, grfPI,
+ dwReserved);
}
return hr;
}
+template
+inline HRESULT CustomSinkStartPolicy::OnStartEx(IUri* pUri,
+ IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
+ DWORD grfPI, HANDLE_PTR dwReserved,
+ IInternetProtocolEx* pTargetProtocol) const
+{
+ ATLASSERT(pTargetProtocol != 0);
+
+ Sink* pSink = GetSink(static_cast(this));
+ HRESULT hr = pSink->OnStartEx(pUri, pOIProtSink, pOIBindInfo, grfPI,
+ dwReserved, pTargetProtocol);
+
+ CComPtr spSink;
+ CComPtr spBindInfo;
+ if (SUCCEEDED(hr))
+ {
+ hr = pSink->QueryInterface(IID_IInternetProtocolSink,
+ reinterpret_cast(&spSink));
+ ATLASSERT(SUCCEEDED(hr) && spSink != 0);
+ }
+ if (SUCCEEDED(hr))
+ {
+ hr = pSink->QueryInterface(IID_IInternetBindInfo,
+ reinterpret_cast(&spBindInfo));
+ ATLASSERT(SUCCEEDED(hr) && spBindInfo != 0);
+ }
+ if (SUCCEEDED(hr))
+ {
+ hr = pTargetProtocol->StartEx(pUri, spSink, spBindInfo, grfPI,
+ dwReserved);
+ }
+ return hr;
+}
template
inline Sink* CustomSinkStartPolicy::GetSink(
@@ -425,4 +453,4 @@
} // end namespace PassthroughAPP
-#endif // PASSTHROUGHAPP_SINKPOLICY_INL
\ No newline at end of file
+#endif // PASSTHROUGHAPP_SINKPOLICY_INL
Index: src/plugin/passthroughapp/UNLICENSE
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/plugin/passthroughapp/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to