ntdll: Correct 'b' parameter descriptions for _alldiv and _aulldiv.
[wine] / dlls / mshtml / protocol.c
index 05b4388..f0325bf 100644 (file)
@@ -39,31 +39,30 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
  * common ProtocolFactory implementation
  */
 
-#define PROTOCOLINFO(x) ((IInternetProtocolInfo*) &(x)->lpInternetProtocolInfoVtbl)
-#define CLASSFACTORY(x) ((IClassFactory*)         &(x)->lpClassFactoryVtbl)
-#define PROTOCOL(x)     ((IInternetProtocol*)     &(x)->lpInternetProtocolVtbl)
-
 typedef struct {
-    const IInternetProtocolInfoVtbl *lpInternetProtocolInfoVtbl;
-    const IClassFactoryVtbl         *lpClassFactoryVtbl;
+    IInternetProtocolInfo IInternetProtocolInfo_iface;
+    IClassFactory         IClassFactory_iface;
 } ProtocolFactory;
 
-#define PROTOCOLINFO_THIS(iface) DEFINE_THIS(ProtocolFactory, InternetProtocolInfo, iface)
+static inline ProtocolFactory *impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
+{
+    return CONTAINING_RECORD(iface, ProtocolFactory, IInternetProtocolInfo_iface);
+}
 
 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
 {
-    ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
+    ProtocolFactory *This = impl_from_IInternetProtocolInfo(iface);
 
     *ppv = NULL;
     if(IsEqualGUID(&IID_IUnknown, riid)) {
         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
-        *ppv = PROTOCOLINFO(This);
+        *ppv = &This->IInternetProtocolInfo_iface;
     }else if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
         TRACE("(%p)->(IID_IInternetProtocolInfo %p)\n", This, ppv);
-        *ppv = PROTOCOLINFO(This);
+        *ppv = &This->IInternetProtocolInfo_iface;
     }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
         TRACE("(%p)->(IID_IClassFactory %p)\n", This, ppv);
-        *ppv = CLASSFACTORY(This);
+        *ppv = &This->IClassFactory_iface;
     }
 
     if(!*ppv) {
@@ -77,64 +76,69 @@ static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
 
 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
 {
-    ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
-    TRACE("(%p)\n", This);
-    LOCK_MODULE();
+    TRACE("(%p)\n", iface);
     return 2;
 }
 
 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
 {
-    ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
-    TRACE("(%p)\n", This);
-    UNLOCK_MODULE();
+    TRACE("(%p)\n", iface);
     return 1;
 }
 
-#undef PROTOCOLINFO_THIS
+static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
+        LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult,
+        DWORD cchResult, DWORD* pcchResult, DWORD dwReserved)
+{
+    TRACE("%p)->(%s %s %08x %p %d %p %d)\n", iface, debugstr_w(pwzBaseUrl),
+            debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
+            pcchResult, dwReserved);
+
+    return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
+}
 
-#define CLASSFACTORY_THIS(iface) DEFINE_THIS(ProtocolFactory, ClassFactory, iface)
+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;
+}
+
+static inline ProtocolFactory *impl_from_IClassFactory(IClassFactory *iface)
+{
+    return CONTAINING_RECORD(iface, ProtocolFactory, IClassFactory_iface);
+}
 
 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
 {
-    ProtocolFactory *This = CLASSFACTORY_THIS(iface);
-    return IInternetProtocolInfo_QueryInterface(PROTOCOLINFO(This), riid, ppv);
+    ProtocolFactory *This = impl_from_IClassFactory(iface);
+    return IInternetProtocolInfo_QueryInterface(&This->IInternetProtocolInfo_iface, riid, ppv);
 }
 
 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
 {
-    ProtocolFactory *This = CLASSFACTORY_THIS(iface);
-    return IInternetProtocolInfo_AddRef(PROTOCOLINFO(This));
+    ProtocolFactory *This = impl_from_IClassFactory(iface);
+    return IInternetProtocolInfo_AddRef(&This->IInternetProtocolInfo_iface);
 }
 
 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
 {
-    ProtocolFactory *This = CLASSFACTORY_THIS(iface);
-    return IInternetProtocolInfo_Release(PROTOCOLINFO(This));
+    ProtocolFactory *This = impl_from_IClassFactory(iface);
+    return IInternetProtocolInfo_Release(&This->IInternetProtocolInfo_iface);
 }
 
 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
 {
-    ProtocolFactory *This = CLASSFACTORY_THIS(iface);
-
-    TRACE("(%p)->(%x)\n", This, dolock);
-
-    if(dolock)
-        LOCK_MODULE();
-    else
-        UNLOCK_MODULE();
-
+    TRACE("(%p)->(%x)\n", iface, dolock);
     return S_OK;
 }
 
-#undef CLASSFACTORY_THIS
-
 /********************************************************************
  * AboutProtocol implementation
  */
 
 typedef struct {
-    const IInternetProtocolVtbl *lpInternetProtocolVtbl;
+    IInternetProtocol IInternetProtocol_iface;
 
     LONG ref;
 
@@ -145,11 +149,14 @@ typedef struct {
     IUnknown *pUnkOuter;
 } AboutProtocol;
 
-#define PROTOCOL_THIS(iface) DEFINE_THIS(AboutProtocol, InternetProtocol, iface)
+static inline AboutProtocol *AboutProtocol_from_IInternetProtocol(IInternetProtocol *iface)
+{
+    return CONTAINING_RECORD(iface, AboutProtocol, IInternetProtocol_iface);
+}
 
 static HRESULT WINAPI AboutProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
 
     *ppv = NULL;
 
@@ -157,13 +164,13 @@ static HRESULT WINAPI AboutProtocol_QueryInterface(IInternetProtocol *iface, REF
         TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
         if(This->pUnkOuter)
             return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
-        *ppv = PROTOCOL(This);
+        *ppv = &This->IInternetProtocol_iface;
     }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
         TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
-        *ppv = PROTOCOL(This);
+        *ppv = &This->IInternetProtocol_iface;
     }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
         TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
-        *ppv = PROTOCOL(This);
+        *ppv = &This->IInternetProtocol_iface;
     }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
         FIXME("IServiceProvider is not implemented\n");
         return E_NOINTERFACE;
@@ -180,24 +187,23 @@ static HRESULT WINAPI AboutProtocol_QueryInterface(IInternetProtocol *iface, REF
 
 static ULONG WINAPI AboutProtocol_AddRef(IInternetProtocol *iface)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
-    TRACE("(%p) ref=%ld\n", iface, ref);
+    TRACE("(%p) ref=%d\n", iface, ref);
     return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
 }
 
 static ULONG WINAPI AboutProtocol_Release(IInternetProtocol *iface)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
     IUnknown *pUnkOuter = This->pUnkOuter;
     ULONG ref = InterlockedDecrement(&This->ref);
 
-    TRACE("(%p) ref=%lx\n", iface, ref);
+    TRACE("(%p) ref=%x\n", iface, ref);
 
     if(!ref) {
-        mshtml_free(This->data);
-        mshtml_free(This);
-        UNLOCK_MODULE();
+        heap_free(This->data);
+        heap_free(This);
     }
 
     return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
@@ -205,9 +211,9 @@ static ULONG WINAPI AboutProtocol_Release(IInternetProtocol *iface)
 
 static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
-        DWORD grfPI, DWORD dwReserved)
+        DWORD grfPI, HANDLE_PTR dwReserved)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
     BINDINFO bindinfo;
     DWORD grfBINDF = 0;
     LPCWSTR text = NULL;
@@ -225,7 +231,7 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
      * when the url does not have "about:" in the beginning.
      */
 
-    TRACE("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
+    TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
             pOIBindInfo, grfPI, dwReserved);
 
     memset(&bindinfo, 0, sizeof(bindinfo));
@@ -233,6 +239,8 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
     IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
     ReleaseBindInfo(&bindinfo);
 
+    TRACE("bindf %x\n", grfBINDF);
+
     if(strlenW(szUrl)>=sizeof(wszAbout)/sizeof(WCHAR) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
         text = szUrl + sizeof(wszAbout)/sizeof(WCHAR);
         if(!strcmpW(wszBlank, text))
@@ -241,7 +249,7 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
 
     This->data_len = sizeof(html_begin)+sizeof(html_end)-sizeof(WCHAR) 
         + (text ? strlenW(text)*sizeof(WCHAR) : 0);
-    This->data = mshtml_alloc(This->data_len);
+    This->data = heap_alloc(This->data_len);
 
     memcpy(This->data, html_begin, sizeof(html_begin));
     if(text)
@@ -263,7 +271,7 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
 
 static HRESULT WINAPI AboutProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
     FIXME("(%p)->(%p)\n", This, pProtocolData);
     return E_NOTIMPL;
 }
@@ -271,37 +279,37 @@ static HRESULT WINAPI AboutProtocol_Continue(IInternetProtocol *iface, PROTOCOLD
 static HRESULT WINAPI AboutProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
         DWORD dwOptions)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
-    FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
+    FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI AboutProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
-    TRACE("(%p)->(%08lx)\n", This, dwOptions);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
+    TRACE("(%p)->(%08x)\n", This, dwOptions);
     return S_OK;
 }
 
 static HRESULT WINAPI AboutProtocol_Suspend(IInternetProtocol *iface)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
     FIXME("(%p)\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI AboutProtocol_Resume(IInternetProtocol *iface)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
     FIXME("(%p)\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI AboutProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
 
-    TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
+    TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
 
     if(!This->data)
         return E_FAIL;
@@ -311,7 +319,7 @@ static HRESULT WINAPI AboutProtocol_Read(IInternetProtocol *iface, void* pv, ULO
     if(!*pcbRead)
         return S_FALSE;
 
-    memcpy(pv, This->data, *pcbRead);
+    memcpy(pv, This->data+This->cur, *pcbRead);
     This->cur += *pcbRead;
 
     return S_OK;
@@ -320,31 +328,29 @@ static HRESULT WINAPI AboutProtocol_Read(IInternetProtocol *iface, void* pv, ULO
 static HRESULT WINAPI AboutProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
         DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
-    FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
+    FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI AboutProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
 
-    TRACE("(%p)->(%ld)\n", This, dwOptions);
+    TRACE("(%p)->(%d)\n", This, dwOptions);
 
     return S_OK;
 }
 
 static HRESULT WINAPI AboutProtocol_UnlockRequest(IInternetProtocol *iface)
 {
-    AboutProtocol *This = PROTOCOL_THIS(iface);
+    AboutProtocol *This = AboutProtocol_from_IInternetProtocol(iface);
 
     TRACE("(%p)\n", This);
 
     return S_OK;
 }
 
-#undef PROTOCOL_THIS
-
 static const IInternetProtocolVtbl AboutProtocolVtbl = {
     AboutProtocol_QueryInterface,
     AboutProtocol_AddRef,
@@ -369,8 +375,8 @@ static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface,
 
     TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
 
-    ret = mshtml_alloc(sizeof(AboutProtocol));
-    ret->lpInternetProtocolVtbl = &AboutProtocolVtbl;
+    ret = heap_alloc(sizeof(AboutProtocol));
+    ret->IInternetProtocol_iface.lpVtbl = &AboutProtocolVtbl;
     ret->ref = 0;
 
     ret->data = NULL;
@@ -381,17 +387,15 @@ static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface,
     if(pUnkOuter) {
         ret->ref = 1;
         if(IsEqualGUID(&IID_IUnknown, riid))
-            *ppv = PROTOCOL(ret);
+            *ppv = &ret->IInternetProtocol_iface;
         else
             hres = E_INVALIDARG;
     }else {
-        hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
+        hres = IInternetProtocol_QueryInterface(&ret->IInternetProtocol_iface, riid, ppv);
     }
 
-    if(SUCCEEDED(hres))
-        LOCK_MODULE();
-    else
-        mshtml_free(ret);
+    if(FAILED(hres))
+        heap_free(ret);
 
     return hres;
 }
@@ -400,11 +404,11 @@ static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, L
         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
         DWORD* pcchResult, DWORD dwReserved)
 {
-    TRACE("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
+    TRACE("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
             dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
 
     if(ParseAction == PARSE_SECURITY_URL) {
-        int len = lstrlenW(pwzUrl);
+        unsigned int len = strlenW(pwzUrl);
 
         if(len >= cchResult)
             return S_FALSE;
@@ -427,29 +431,50 @@ static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, L
     return INET_E_DEFAULT_ACTION;
 }
 
-static HRESULT WINAPI AboutProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
-        LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult,
-        DWORD* pcchResult, DWORD dwReserved)
-{
-    FIXME("%p)->(%s %s %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzBaseUrl), debugstr_w(pwzRelativeUrl),
-            dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
-    return E_NOTIMPL;
-}
-
-static HRESULT WINAPI AboutProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
-        LPCWSTR pwzUrl2, DWORD dwCompareFlags)
-{
-    FIXME("%p)->(%s %s %08lx)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
-    return E_NOTIMPL;
-}
-
 static HRESULT WINAPI AboutProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
         QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
         DWORD dwReserved)
 {
-    FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
-            cbBuffer, pcbBuf, dwReserved);
-    return E_NOTIMPL;
+    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;
+    case QUERY_USES_HISTORYFOLDER:
+        FIXME("Unsupported option QUERY_USES_HISTORYFOLDER\n");
+        return E_FAIL;
+    default:
+        return E_FAIL;
+    }
+
+    return S_OK;
 }
 
 static const IInternetProtocolInfoVtbl AboutProtocolInfoVtbl = {
@@ -457,8 +482,8 @@ static const IInternetProtocolInfoVtbl AboutProtocolInfoVtbl = {
     InternetProtocolInfo_AddRef,
     InternetProtocolInfo_Release,
     AboutProtocolInfo_ParseUrl,
-    AboutProtocolInfo_CombineUrl,
-    AboutProtocolInfo_CompareUrl,
+    InternetProtocolInfo_CombineUrl,
+    InternetProtocolInfo_CompareUrl,
     AboutProtocolInfo_QueryInfo
 };
 
@@ -471,8 +496,8 @@ static const IClassFactoryVtbl AboutProtocolFactoryVtbl = {
 };
 
 static ProtocolFactory AboutProtocolFactory = {
-    &AboutProtocolInfoVtbl,
-    &AboutProtocolFactoryVtbl
+    { &AboutProtocolInfoVtbl },
+    { &AboutProtocolFactoryVtbl }
 };
 
 /********************************************************************
@@ -480,7 +505,7 @@ static ProtocolFactory AboutProtocolFactory = {
  */
 
 typedef struct {
-    const IInternetProtocolVtbl *lpInternetProtocolVtbl;
+    IInternetProtocol IInternetProtocol_iface;
     LONG ref;
 
     BYTE *data;
@@ -490,11 +515,14 @@ typedef struct {
     IUnknown *pUnkOuter;
 } ResProtocol;
 
-#define PROTOCOL_THIS(iface) DEFINE_THIS(ResProtocol, InternetProtocol, iface)
+static inline ResProtocol *ResProtocol_from_IInternetProtocol(IInternetProtocol *iface)
+{
+    return CONTAINING_RECORD(iface, ResProtocol, IInternetProtocol_iface);
+}
 
 static HRESULT WINAPI ResProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
 
     *ppv = NULL;
 
@@ -502,13 +530,13 @@ static HRESULT WINAPI ResProtocol_QueryInterface(IInternetProtocol *iface, REFII
         TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
         if(This->pUnkOuter)
             return IUnknown_QueryInterface(This->pUnkOuter, &IID_IUnknown, ppv);
-        *ppv = PROTOCOL(This);
+        *ppv = &This->IInternetProtocol_iface;
     }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
         TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
-        *ppv = PROTOCOL(This);
+        *ppv = &This->IInternetProtocol_iface;
     }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
         TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
-        *ppv = PROTOCOL(This);
+        *ppv = &This->IInternetProtocol_iface;
     }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
         FIXME("IServiceProvider is not implemented\n");
         return E_NOINTERFACE;
@@ -525,9 +553,9 @@ static HRESULT WINAPI ResProtocol_QueryInterface(IInternetProtocol *iface, REFII
 
 static ULONG WINAPI ResProtocol_AddRef(IInternetProtocol *iface)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
-    TRACE("(%p) ref=%ld\n", iface, ref);
+    TRACE("(%p) ref=%d\n", iface, ref);
     return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
 }
 
@@ -537,12 +565,11 @@ static ULONG WINAPI ResProtocol_Release(IInternetProtocol *iface)
     IUnknown *pUnkOuter = This->pUnkOuter;
     ULONG ref = InterlockedDecrement(&This->ref);
 
-    TRACE("(%p) ref=%lx\n", iface, ref);
+    TRACE("(%p) ref=%x\n", iface, ref);
 
     if(!ref) {
-        mshtml_free(This->data);
-        mshtml_free(This);
-        UNLOCK_MODULE();
+        heap_free(This->data);
+        heap_free(This);
     }
 
     return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
@@ -550,19 +577,19 @@ static ULONG WINAPI ResProtocol_Release(IInternetProtocol *iface)
 
 static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
-        DWORD grfPI, DWORD dwReserved)
+        DWORD grfPI, HANDLE_PTR dwReserved)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
     DWORD grfBINDF = 0, len;
     BINDINFO bindinfo;
-    LPWSTR url_dll, url_file, url, mime;
+    LPWSTR url_dll, url_file, url, mime, res_type = (LPWSTR)RT_HTML;
     HMODULE hdll;
     HRSRC src;
     HRESULT hres;
 
     static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
 
-    TRACE("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
+    TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
             pOIBindInfo, grfPI, dwReserved);
 
     memset(&bindinfo, 0, sizeof(bindinfo));
@@ -571,68 +598,82 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
     ReleaseBindInfo(&bindinfo);
 
     len = strlenW(szUrl)+16;
-    url = mshtml_alloc(len*sizeof(WCHAR));
+    url = heap_alloc(len*sizeof(WCHAR));
     hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
     if(FAILED(hres)) {
-        WARN("CoInternetParseUrl failed: %08lx\n", hres);
-        mshtml_free(url);
+        WARN("CoInternetParseUrl failed: %08x\n", hres);
+        heap_free(url);
         IInternetProtocolSink_ReportResult(pOIProtSink, hres, 0, NULL);
         return hres;
     }
 
     if(len < sizeof(wszRes)/sizeof(wszRes[0]) || memcmp(url, wszRes, sizeof(wszRes))) {
         WARN("Wrong protocol of url: %s\n", debugstr_w(url));
-        IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
-        mshtml_free(url);
-        return MK_E_SYNTAX;
+        IInternetProtocolSink_ReportResult(pOIProtSink, E_INVALIDARG, 0, NULL);
+        heap_free(url);
+        return E_INVALIDARG;
     }
 
     url_dll = url + sizeof(wszRes)/sizeof(wszRes[0]);
     if(!(url_file = strrchrW(url_dll, '/'))) {
         WARN("wrong url: %s\n", debugstr_w(url));
         IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
-        mshtml_free(url);
+        heap_free(url);
         return MK_E_SYNTAX;
     }
 
     *url_file++ = 0;
     hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
     if(!hdll) {
-        WARN("Could not open dll: %s\n", debugstr_w(url_dll));
-        IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
-        return HRESULT_FROM_WIN32(GetLastError());
+        if (!(res_type = strrchrW(url_dll, '/'))) {
+            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());
+        }
+        *res_type++ = 0;
+
+        hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
+        if(!hdll) {
+            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());
+        }
     }
 
-    src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML);
+    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);
     if(!src) {
         LPWSTR endpoint = NULL;
         DWORD file_id = strtolW(url_file, &endpoint, 10);
         if(endpoint == url_file+strlenW(url_file))
-            src = FindResourceW(hdll, (LPCWSTR)file_id, (LPCWSTR)RT_HTML);
+            src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), MAKEINTRESOURCEW(RT_HTML));
 
         if(!src) {
             WARN("Could not find resource\n");
             IInternetProtocolSink_ReportResult(pOIProtSink,
                     HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
-            mshtml_free(url);
+            heap_free(url);
             return HRESULT_FROM_WIN32(GetLastError());
         }
     }
 
     if(This->data) {
         WARN("data already loaded\n");
-        mshtml_free(This->data);
+        heap_free(This->data);
     }
 
     This->data_len = SizeofResource(hdll, src);
-    This->data = mshtml_alloc(This->data_len);
+    This->data = heap_alloc(This->data_len);
     memcpy(This->data, LoadResource(hdll, src), This->data_len);
     This->cur = 0;
 
     FreeLibrary(hdll);
 
-    hres = FindMimeFromData(NULL, url_file, NULL, 0, NULL, 0, &mime, 0);
-    mshtml_free(url);
+    hres = FindMimeFromData(NULL, url_file, This->data, This->data_len, NULL, 0, &mime, 0);
+    heap_free(url);
     if(SUCCEEDED(hres)) {
         IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
         CoTaskMemFree(mime);
@@ -649,7 +690,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
 
 static HRESULT WINAPI ResProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
     FIXME("(%p)->(%p)\n", This, pProtocolData);
     return E_NOTIMPL;
 }
@@ -657,16 +698,16 @@ static HRESULT WINAPI ResProtocol_Continue(IInternetProtocol *iface, PROTOCOLDAT
 static HRESULT WINAPI ResProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
         DWORD dwOptions)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
-    FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
+    FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI ResProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
 
-    TRACE("(%p)->(%08lx)\n", This, dwOptions);
+    TRACE("(%p)->(%08x)\n", This, dwOptions);
 
     /* test show that we don't have to do anything here */
     return S_OK;
@@ -674,23 +715,23 @@ static HRESULT WINAPI ResProtocol_Terminate(IInternetProtocol *iface, DWORD dwOp
 
 static HRESULT WINAPI ResProtocol_Suspend(IInternetProtocol *iface)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
     FIXME("(%p)\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI ResProtocol_Resume(IInternetProtocol *iface)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
     FIXME("(%p)\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI ResProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
 
-    TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
+    TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
 
     if(!This->data)
         return E_FAIL;
@@ -700,7 +741,7 @@ static HRESULT WINAPI ResProtocol_Read(IInternetProtocol *iface, void* pv, ULONG
     if(!*pcbRead)
         return S_FALSE;
 
-    memcpy(pv, This->data, *pcbRead);
+    memcpy(pv, This->data+This->cur, *pcbRead);
     This->cur += *pcbRead;
 
     return S_OK;
@@ -709,16 +750,16 @@ static HRESULT WINAPI ResProtocol_Read(IInternetProtocol *iface, void* pv, ULONG
 static HRESULT WINAPI ResProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
         DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
-    FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
+    FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI ResProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
 
-    TRACE("(%p)->(%ld)\n", This, dwOptions);
+    TRACE("(%p)->(%d)\n", This, dwOptions);
 
     /* test show that we don't have to do anything here */
     return S_OK;
@@ -726,7 +767,7 @@ static HRESULT WINAPI ResProtocol_LockRequest(IInternetProtocol *iface, DWORD dw
 
 static HRESULT WINAPI ResProtocol_UnlockRequest(IInternetProtocol *iface)
 {
-    ResProtocol *This = PROTOCOL_THIS(iface);
+    ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
 
     TRACE("(%p)\n", This);
 
@@ -734,8 +775,6 @@ static HRESULT WINAPI ResProtocol_UnlockRequest(IInternetProtocol *iface)
     return S_OK;
 }
 
-#undef PROTOCOL_THIS
-
 static const IInternetProtocolVtbl ResProtocolVtbl = {
     ResProtocol_QueryInterface,
     ResProtocol_AddRef,
@@ -760,8 +799,8 @@ static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IU
 
     TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
 
-    ret = mshtml_alloc(sizeof(ResProtocol));
-    ret->lpInternetProtocolVtbl = &ResProtocolVtbl;
+    ret = heap_alloc(sizeof(ResProtocol));
+    ret->IInternetProtocol_iface.lpVtbl = &ResProtocolVtbl;
     ret->ref = 0;
     ret->data = NULL;
     ret->data_len = 0;
@@ -771,17 +810,15 @@ static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IU
     if(pUnkOuter) {
         ret->ref = 1;
         if(IsEqualGUID(&IID_IUnknown, riid))
-            *ppv = PROTOCOL(ret);
+            *ppv = &ret->IInternetProtocol_iface;
         else
             hres = E_FAIL;
     }else {
-        hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
+        hres = IInternetProtocol_QueryInterface(&ret->IInternetProtocol_iface, riid, ppv);
     }
 
-    if(SUCCEEDED(hres))
-        LOCK_MODULE();
-    else
-        mshtml_free(ret);
+    if(FAILED(hres))
+        heap_free(ret);
 
     return hres;
 }
@@ -790,36 +827,47 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
         DWORD* pcchResult, DWORD dwReserved)
 {
-    TRACE("%p)->(%s %d %lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
+    TRACE("%p)->(%s %d %x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
             dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
 
     if(ParseAction == PARSE_SECURITY_URL) {
+        WCHAR file_part[MAX_PATH], full_path[MAX_PATH];
         WCHAR *ptr;
-        DWORD size;
+        DWORD size, len;
 
         static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
         static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
 
         if(strlenW(pwzUrl) <= sizeof(wszRes)/sizeof(WCHAR) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
-            return MK_E_SYNTAX;
+            return E_INVALIDARG;
 
         ptr = strchrW(pwzUrl + sizeof(wszRes)/sizeof(WCHAR), '/');
         if(!ptr)
+            return E_INVALIDARG;
+
+        len = ptr - (pwzUrl + sizeof(wszRes)/sizeof(WCHAR));
+        if(len >= sizeof(file_part)/sizeof(WCHAR)) {
+            FIXME("Too long URL\n");
             return MK_E_SYNTAX;
+        }
 
-        size = ptr-pwzUrl + sizeof(wszFile)/sizeof(WCHAR) - sizeof(wszRes)/sizeof(WCHAR);
-        if(size >= cchResult)
-            return S_FALSE;
+        memcpy(file_part, pwzUrl + sizeof(wszRes)/sizeof(WCHAR), len*sizeof(WCHAR));
+        file_part[len] = 0;
 
-        /* FIXME: return full path */
-        memcpy(pwzResult, wszFile, sizeof(wszFile));
-        memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR),
-                pwzUrl + sizeof(wszRes)/sizeof(WCHAR),
-                size*sizeof(WCHAR) - sizeof(wszFile));
-        pwzResult[size] = 0;
+        len = SearchPathW(NULL, file_part, NULL, sizeof(full_path)/sizeof(WCHAR), full_path, NULL);
+        if(!len) {
+            WARN("Could not find file %s\n", debugstr_w(file_part));
+            return MK_E_SYNTAX;
+        }
 
+        size = sizeof(wszFile)/sizeof(WCHAR) + len + 1;
         if(pcchResult)
             *pcchResult = size;
+        if(size >= cchResult)
+            return S_FALSE;
+
+        memcpy(pwzResult, wszFile, sizeof(wszFile));
+        memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR), full_path, (len+1)*sizeof(WCHAR));
         return S_OK;
     }
 
@@ -837,29 +885,34 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
     return INET_E_DEFAULT_ACTION;
 }
 
-static HRESULT WINAPI ResProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
-        LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult,
-        DWORD* pcchResult, DWORD dwReserved)
-{
-    FIXME("%p)->(%s %s %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzBaseUrl), debugstr_w(pwzRelativeUrl),
-            dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
-    return E_NOTIMPL;
-}
-
-static HRESULT WINAPI ResProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
-        LPCWSTR pwzUrl2, DWORD dwCompareFlags)
-{
-    FIXME("%p)->(%s %s %08lx)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
-    return E_NOTIMPL;
-}
-
 static HRESULT WINAPI ResProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
         QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
         DWORD dwReserved)
 {
-    FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
-            cbBuffer, pcbBuf, dwReserved);
-    return E_NOTIMPL;
+    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:
+        FIXME("not supporte QUERY_IS_SECURE\n");
+        return E_NOTIMPL;
+    case QUERY_IS_SAFE:
+        FIXME("not supporte QUERY_IS_SAFE\n");
+        return E_NOTIMPL;
+    default:
+        return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
+    }
+
+    return S_OK;
 }
 
 static const IInternetProtocolInfoVtbl ResProtocolInfoVtbl = {
@@ -867,8 +920,8 @@ static const IInternetProtocolInfoVtbl ResProtocolInfoVtbl = {
     InternetProtocolInfo_AddRef,
     InternetProtocolInfo_Release,
     ResProtocolInfo_ParseUrl,
-    ResProtocolInfo_CombineUrl,
-    ResProtocolInfo_CompareUrl,
+    InternetProtocolInfo_CombineUrl,
+    InternetProtocolInfo_CompareUrl,
     ResProtocolInfo_QueryInfo
 };
 
@@ -881,8 +934,91 @@ static const IClassFactoryVtbl ResProtocolFactoryVtbl = {
 };
 
 static ProtocolFactory ResProtocolFactory = {
-    &ResProtocolInfoVtbl,
-    &ResProtocolFactoryVtbl
+    { &ResProtocolInfoVtbl },
+    { &ResProtocolFactoryVtbl }
+};
+
+/********************************************************************
+ * 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)
+{
+    TRACE("%p)->(%s %d %x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
+          dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
+
+    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;
+}
+
+static HRESULT WINAPI JSProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
+        QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
+        DWORD dwReserved)
+{
+    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:
+        FIXME("not supporte QUERY_IS_SECURE\n");
+        return E_NOTIMPL;
+
+    default:
+        return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
+    }
+
+    return S_OK;
+}
+
+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 = {
+    { &JSProtocolInfoVtbl },
+    { &JSProtocolFactoryVtbl }
 };
 
 HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
@@ -893,11 +1029,13 @@ HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
         cf = &AboutProtocolFactory;
     else if(IsEqualGUID(&CLSID_ResProtocol, rclsid))
         cf = &ResProtocolFactory;
+    else if(IsEqualGUID(&CLSID_JSProtocol, rclsid))
+        cf = &JSProtocolFactory;
 
     if(!cf) {
         FIXME("not implemented protocol %s\n", debugstr_guid(rclsid));
         return CLASS_E_CLASSNOTAVAILABLE;
     }
  
-    return IUnknown_QueryInterface((IUnknown*)cf, riid, ppv);
+    return IInternetProtocolInfo_QueryInterface(&cf->IInternetProtocolInfo_iface, riid, ppv);
 }