Sync to Wine-0_9_4:
Thomas Weidenmueller <wine-patches@reactsoft.com>
- urlmon: Correctly fix IStream::Read.
  Don't dereference a possible NULL pointer.
- urlmon: Fix call to ReadFile.
  The BytesRead parameter passed to ReadFile may never be NULL.
Jacek Caban <jacek@codeweavers.com>
- urlmon: Added handling of BINDF_FROMURLMON in file protocol.
- urlmon: Added some tests and fixes of file protocol.
- urlmon: Fix BindToStorage test.
Modified: trunk/reactos/lib/urlmon/binding.c
Modified: trunk/reactos/lib/urlmon/file.c
Modified: trunk/reactos/lib/urlmon/umstream.c
Modified: trunk/reactos/w32api/include/urlmon.h

Modified: trunk/reactos/lib/urlmon/binding.c
--- trunk/reactos/lib/urlmon/binding.c	2005-12-26 23:24:41 UTC (rev 20354)
+++ trunk/reactos/lib/urlmon/binding.c	2005-12-26 23:31:24 UTC (rev 20355)
@@ -401,7 +401,7 @@
 
     hres = IBindCtx_GetObjectParam(pbc, wszBSCBHolder, (IUnknown**)callback);
     if(FAILED(hres))
-        return INET_E_DATA_NOT_AVAILABLE;
+        return MK_E_SYNTAX;
 
     return S_OK;
 }

Modified: trunk/reactos/lib/urlmon/file.c
--- trunk/reactos/lib/urlmon/file.c	2005-12-26 23:24:41 UTC (rev 20354)
+++ trunk/reactos/lib/urlmon/file.c	2005-12-26 23:31:24 UTC (rev 20355)
@@ -110,7 +110,9 @@
     LARGE_INTEGER size;
     DWORD len;
     LPWSTR url, mime = NULL;
+    LPCWSTR file_name;
     WCHAR null_char = 0;
+    BOOL first_call = FALSE;
     HRESULT hres;
 
     static const WCHAR wszFile[]  = {'f','i','l','e',':'};
@@ -134,33 +136,42 @@
         return hres;
     }
 
-    hres = FindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
-    if(SUCCEEDED(hres))
-        IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DIRECTBIND, mime);
+    if(!(grfBINDF & BINDF_FROMURLMON))
+        IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DIRECTBIND, NULL);
 
     if(!This->file) {
+        first_call = TRUE;
+
         IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char);
 
-        This->file = CreateFileW(url+sizeof(wszFile)/sizeof(WCHAR), GENERIC_READ, FILE_SHARE_READ,
-                NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+        file_name = url+sizeof(wszFile)/sizeof(WCHAR);
+        if(file_name[0] == '/' && file_name[1] == '/' && file_name[2] == '/')
+            file_name += 3;
 
+        This->file = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
+                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
         if(This->file == INVALID_HANDLE_VALUE) {
             This->file = NULL;
             IInternetProtocolSink_ReportResult(pOIProtSink, INET_E_RESOURCE_NOT_FOUND,
                     GetLastError(), NULL);
             HeapFree(GetProcessHeap(), 0, url);
-            CoTaskMemFree(mime);
             return INET_E_RESOURCE_NOT_FOUND;
         }
 
-        IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_CACHEFILENAMEAVAILABLE,
-                url+sizeof(wszFile)/sizeof(WCHAR));
-        if(mime)
-            IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
-        IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
+        IInternetProtocolSink_ReportProgress(pOIProtSink,
+                BINDSTATUS_CACHEFILENAMEAVAILABLE, file_name);
+
+        hres = FindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
+        if(SUCCEEDED(hres)) {
+            IInternetProtocolSink_ReportProgress(pOIProtSink,
+                    (grfBINDF & BINDF_FROMURLMON) ?
+                    BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE : BINDSTATUS_MIMETYPEAVAILABLE,
+                    mime);
+            CoTaskMemFree(mime);
+        }
     }
 
-    CoTaskMemFree(mime);
     HeapFree(GetProcessHeap(), 0, url);
 
     if(GetFileSizeEx(This->file, &size))
@@ -168,6 +179,9 @@
                 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
                 size.u.LowPart, size.u.LowPart);
 
+    if(first_call)
+        IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
+
     return S_OK;
 }
 

Modified: trunk/reactos/lib/urlmon/umstream.c
--- trunk/reactos/lib/urlmon/umstream.c	2005-12-26 23:24:41 UTC (rev 20354)
+++ trunk/reactos/lib/urlmon/umstream.c	2005-12-26 23:31:24 UTC (rev 20355)
@@ -225,6 +225,7 @@
                                       ULONG cb,
                                       ULONG* pcbRead)
 {
+    ULONG dwBytesRead;
     IUMCacheStream *This = (IUMCacheStream *)iface;
 
     TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
@@ -232,7 +233,10 @@
     if ( !pv )
        return STG_E_INVALIDPOINTER;
 
-    if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
+    if ( !pcbRead)
+        pcbRead = &dwBytesRead;
+
+    if ( ! ReadFile( This->handle, pv, cb, (LPDWORD)pcbRead, NULL ) )
        return S_FALSE;
 
     if (!*pcbRead)

Modified: trunk/reactos/w32api/include/urlmon.h
--- trunk/reactos/w32api/include/urlmon.h	2005-12-26 23:24:41 UTC (rev 20354)
+++ trunk/reactos/w32api/include/urlmon.h	2005-12-26 23:31:24 UTC (rev 20355)
@@ -1,4 +1,4 @@
-/*** Autogenerated by WIDL 0.9.1 from urlmon.idl - Do not edit ***/
+/*** Autogenerated by WIDL 0.9.4 from urlmon.idl - Do not edit ***/
 #include <rpc.h>
 #include <rpcndr.h>
 
@@ -13,12 +13,12 @@
 #include <msxml.h>
 #ifndef __IInternetProtocolSink_FWD_DEFINED__
 #define __IInternetProtocolSink_FWD_DEFINED__
-typedef struct IInternetProtocolSink IInternetProtocolSink;
+typedef interface IInternetProtocolSink IInternetProtocolSink;
 #endif
 
 #ifndef __IBinding_FWD_DEFINED__
 #define __IBinding_FWD_DEFINED__
-typedef struct IBinding IBinding;
+typedef interface IBinding IBinding;
 #endif
 
 typedef IBinding *LPBINDING;
@@ -30,7 +30,7 @@
 
 DEFINE_GUID(IID_IBinding, 0x79eac9c0, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IBinding : public IUnknown
+interface IBinding : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE Abort(
         ) = 0;
@@ -55,11 +55,7 @@
 
 };
 #else
-typedef struct IBindingVtbl IBindingVtbl;
-struct IBinding {
-    const IBindingVtbl* lpVtbl;
-};
-struct IBindingVtbl {
+typedef struct IBindingVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -100,6 +96,9 @@
         DWORD* pdwReserved);
 
     END_INTERFACE
+} IBindingVtbl;
+interface IBinding {
+    const IBindingVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -121,38 +120,38 @@
 HRESULT CALLBACK IBinding_Abort_Proxy(
     IBinding* This);
 void __RPC_STUB IBinding_Abort_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBinding_Suspend_Proxy(
     IBinding* This);
 void __RPC_STUB IBinding_Suspend_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBinding_Resume_Proxy(
     IBinding* This);
 void __RPC_STUB IBinding_Resume_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBinding_SetPriority_Proxy(
     IBinding* This,
     LONG nPriority);
 void __RPC_STUB IBinding_SetPriority_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBinding_GetPriority_Proxy(
     IBinding* This,
     LONG* pnPriority);
 void __RPC_STUB IBinding_GetPriority_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBinding_RemoteGetBindResult_Proxy(
@@ -162,8 +161,8 @@
     LPOLESTR* pszResult,
     DWORD dwReserved);
 void __RPC_STUB IBinding_RemoteGetBindResult_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBinding_GetBindResult_Proxy(
@@ -183,7 +182,7 @@
 
 #ifndef __IBindStatusCallback_FWD_DEFINED__
 #define __IBindStatusCallback_FWD_DEFINED__
-typedef struct IBindStatusCallback IBindStatusCallback;
+typedef interface IBindStatusCallback IBindStatusCallback;
 #endif
 
 typedef IBindStatusCallback *LPBINDSTATUSCALLBACK;
@@ -291,7 +290,7 @@
     BINDSTATUS_ENDUPLOADINGDATA,
     BINDSTATUS_PROTOCOLCLASSID,
     BINDSTATUS_ENCODING,
-    BINDSTATUS_VERFIEDMIMETYPEAVAILABLE,
+    BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE,
     BINDSTATUS_CLASSINSTALLLOCATION,
     BINDSTATUS_DECODING,
     BINDSTATUS_LOADINGMIMEHANDLER,
@@ -317,7 +316,11 @@
     BINDSTATUS_SESSION_COOKIE_RECEIVED,
     BINDSTATUS_PERSISTENT_COOKIE_RECEIVED,
     BINDSTATUS_SESSION_COOKIES_ALLOWED,
-    BINDSTATUS_CACHECONTROL
+    BINDSTATUS_CACHECONTROL,
+    BINDSTATUS_CONTENTDISPOSITIONFILENAME,
+    BINDSTATUS_MIMETEXTPLAINMISMATCH,
+    BINDSTATUS_PUBLISHERAVAILABLE,
+    BINDSTATUS_DISPLAYNAMEAVAILABLE
 } BINDSTATUS;
 /*****************************************************************************
  * IBindStatusCallback interface
@@ -327,7 +330,7 @@
 
 DEFINE_GUID(IID_IBindStatusCallback, 0x79eac9c1, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IBindStatusCallback : public IUnknown
+interface IBindStatusCallback : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE OnStartBinding(
         DWORD dwReserved,
@@ -365,11 +368,7 @@
 
 };
 #else
-typedef struct IBindStatusCallbackVtbl IBindStatusCallbackVtbl;
-struct IBindStatusCallback {
-    const IBindStatusCallbackVtbl* lpVtbl;
-};
-struct IBindStatusCallbackVtbl {
+typedef struct IBindStatusCallbackVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -428,6 +427,9 @@
         IUnknown* punk);
 
     END_INTERFACE
+} IBindStatusCallbackVtbl;
+interface IBindStatusCallback {
+    const IBindStatusCallbackVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -453,24 +455,24 @@
     DWORD dwReserved,
     IBinding* pib);
 void __RPC_STUB IBindStatusCallback_OnStartBinding_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_GetPriority_Proxy(
     IBindStatusCallback* This,
     LONG* pnPriority);
 void __RPC_STUB IBindStatusCallback_GetPriority_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_OnLowResource_Proxy(
     IBindStatusCallback* This,
     DWORD reserved);
 void __RPC_STUB IBindStatusCallback_OnLowResource_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_OnProgress_Proxy(
@@ -480,8 +482,8 @@
     ULONG ulStatusCode,
     LPCWSTR szStatusText);
 void __RPC_STUB IBindStatusCallback_OnProgress_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_OnStopBinding_Proxy(
@@ -489,8 +491,8 @@
     HRESULT hresult,
     LPCWSTR szError);
 void __RPC_STUB IBindStatusCallback_OnStopBinding_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_RemoteGetBindInfo_Proxy(
@@ -499,8 +501,8 @@
     RemBINDINFO* pbindinfo,
     RemSTGMEDIUM* pstgmed);
 void __RPC_STUB IBindStatusCallback_RemoteGetBindInfo_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_GetBindInfo_Proxy(
@@ -519,8 +521,8 @@
     RemFORMATETC* pformatetc,
     RemSTGMEDIUM* pstgmed);
 void __RPC_STUB IBindStatusCallback_RemoteOnDataAvailable_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindStatusCallback_OnDataAvailable_Proxy(
@@ -540,8 +542,8 @@
     REFIID riid,
     IUnknown* punk);
 void __RPC_STUB IBindStatusCallback_OnObjectAvailable_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -549,7 +551,7 @@
 
 #ifndef __IAuthenticate_FWD_DEFINED__
 #define __IAuthenticate_FWD_DEFINED__
-typedef struct IAuthenticate IAuthenticate;
+typedef interface IAuthenticate IAuthenticate;
 #endif
 
 typedef IAuthenticate *LPAUTHENTICATION;
@@ -561,7 +563,7 @@
 
 DEFINE_GUID(IID_IAuthenticate, 0x79eac9d0, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IAuthenticate : public IUnknown
+interface IAuthenticate : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE Authenticate(
         HWND* phwnd,
@@ -570,11 +572,7 @@
 
 };
 #else
-typedef struct IAuthenticateVtbl IAuthenticateVtbl;
-struct IAuthenticate {
-    const IAuthenticateVtbl* lpVtbl;
-};
-struct IAuthenticateVtbl {
+typedef struct IAuthenticateVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -597,6 +595,9 @@
         LPWSTR* pszPassword);
 
     END_INTERFACE
+} IAuthenticateVtbl;
+interface IAuthenticate {
+    const IAuthenticateVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -616,8 +617,8 @@
     LPWSTR* pszUsername,
     LPWSTR* pszPassword);
 void __RPC_STUB IAuthenticate_Authenticate_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -625,7 +626,7 @@
 
 #ifndef __IHttpNegotiate_FWD_DEFINED__
 #define __IHttpNegotiate_FWD_DEFINED__
-typedef struct IHttpNegotiate IHttpNegotiate;
+typedef interface IHttpNegotiate IHttpNegotiate;
 #endif
 
 typedef IHttpNegotiate *LPHTTPNEGOTIATE;
@@ -637,7 +638,7 @@
 
 DEFINE_GUID(IID_IHttpNegotiate, 0x79eac9d2, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IHttpNegotiate : public IUnknown
+interface IHttpNegotiate : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE BeginningTransaction(
         LPCWSTR szURL,
@@ -653,11 +654,7 @@
 
 };
 #else
-typedef struct IHttpNegotiateVtbl IHttpNegotiateVtbl;
-struct IHttpNegotiate {
-    const IHttpNegotiateVtbl* lpVtbl;
-};
-struct IHttpNegotiateVtbl {
+typedef struct IHttpNegotiateVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -688,6 +685,9 @@
         LPWSTR* pszAdditionalRequestHeaders);
 
     END_INTERFACE
+} IHttpNegotiateVtbl;
+interface IHttpNegotiate {
+    const IHttpNegotiateVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -709,8 +709,8 @@
     DWORD dwReserved,
     LPWSTR* pszAdditionalHeaders);
 void __RPC_STUB IHttpNegotiate_BeginningTransaction_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IHttpNegotiate_OnResponse_Proxy(
@@ -720,8 +720,8 @@
     LPCWSTR szRequestHeaders,
     LPWSTR* pszAdditionalRequestHeaders);
 void __RPC_STUB IHttpNegotiate_OnResponse_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -729,7 +729,7 @@
 
 #ifndef __IHttpNegotiate2_FWD_DEFINED__
 #define __IHttpNegotiate2_FWD_DEFINED__
-typedef struct IHttpNegotiate2 IHttpNegotiate2;
+typedef interface IHttpNegotiate2 IHttpNegotiate2;
 #endif
 
 typedef IHttpNegotiate2 *LPHTTPNEGOTIATE2;
@@ -741,7 +741,7 @@
 
 DEFINE_GUID(IID_IHttpNegotiate2, 0x4f9f9fcb, 0xe0f4, 0x48eb, 0xb7,0xab, 0xfa,0x2e,0xa9,0x36,0x5c,0xb4);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IHttpNegotiate2 : public IHttpNegotiate
+interface IHttpNegotiate2 : public IHttpNegotiate
 {
     virtual HRESULT STDMETHODCALLTYPE GetRootSecurityId(
         BYTE* pbSecurityId,
@@ -750,11 +750,7 @@
 
 };
 #else
-typedef struct IHttpNegotiate2Vtbl IHttpNegotiate2Vtbl;
-struct IHttpNegotiate2 {
-    const IHttpNegotiate2Vtbl* lpVtbl;
-};
-struct IHttpNegotiate2Vtbl {
+typedef struct IHttpNegotiate2Vtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -792,6 +788,9 @@
         DWORD_PTR dwReserved);
 
     END_INTERFACE
+} IHttpNegotiate2Vtbl;
+interface IHttpNegotiate2 {
+    const IHttpNegotiate2Vtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -814,8 +813,8 @@
     DWORD* pcbSecurityId,
     DWORD_PTR dwReserved);
 void __RPC_STUB IHttpNegotiate2_GetRootSecurityId_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -825,7 +824,7 @@
 #define SID_SBindHost IID_IBindHost
 #ifndef __IBindHost_FWD_DEFINED__
 #define __IBindHost_FWD_DEFINED__
-typedef struct IBindHost IBindHost;
+typedef interface IBindHost IBindHost;
 #endif
 
 typedef IBindHost *LPBINDHOST;
@@ -837,7 +836,7 @@
 
 DEFINE_GUID(IID_IBindHost, 0xfc4801a1, 0x2ba9, 0x11cf, 0xa2,0x29, 0x00,0xaa,0x00,0x3d,0x73,0x52);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IBindHost : public IUnknown
+interface IBindHost : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE CreateMoniker(
         LPOLESTR szName,
@@ -861,11 +860,7 @@
 
 };
 #else
-typedef struct IBindHostVtbl IBindHostVtbl;
-struct IBindHost {
-    const IBindHostVtbl* lpVtbl;
-};
-struct IBindHostVtbl {
+typedef struct IBindHostVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -905,6 +900,9 @@
         void** ppvObj);
 
     END_INTERFACE
+} IBindHostVtbl;
+interface IBindHost {
+    const IBindHostVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -927,8 +925,8 @@
     IMoniker** ppmk,
     DWORD dwReserved);
 void __RPC_STUB IBindHost_CreateMoniker_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindHost_RemoteMonikerBindToStorage_Proxy(
@@ -939,8 +937,8 @@
     REFIID riid,
     IUnknown** ppvObj);
 void __RPC_STUB IBindHost_RemoteMonikerBindToStorage_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindHost_MonikerBindToStorage_Proxy(
@@ -965,8 +963,8 @@
     REFIID riid,
     IUnknown** ppvObj);
 void __RPC_STUB IBindHost_RemoteMonikerBindToObject_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IBindHost_MonikerBindToObject_Proxy(
@@ -988,7 +986,7 @@
 
 #ifndef __IWinInetInfo_FWD_DEFINED__
 #define __IWinInetInfo_FWD_DEFINED__
-typedef struct IWinInetInfo IWinInetInfo;
+typedef interface IWinInetInfo IWinInetInfo;
 #endif
 
 typedef IWinInetInfo *LPWININETINFO;
@@ -1000,7 +998,7 @@
 
 DEFINE_GUID(IID_IWinInetInfo, 0x79eac9d6, 0xbafa, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IWinInetInfo : public IUnknown
+interface IWinInetInfo : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE QueryOption(
         DWORD dwOption,
@@ -1009,11 +1007,7 @@
 
 };
 #else
-typedef struct IWinInetInfoVtbl IWinInetInfoVtbl;
-struct IWinInetInfo {
-    const IWinInetInfoVtbl* lpVtbl;
-};
-struct IWinInetInfoVtbl {
+typedef struct IWinInetInfoVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -1036,6 +1030,9 @@
         DWORD* pcbBuf);
 
     END_INTERFACE
+} IWinInetInfoVtbl;
+interface IWinInetInfo {
+    const IWinInetInfoVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -1055,8 +1052,8 @@
     BYTE* pBuffer,
     DWORD* pcbBuf);
 void __RPC_STUB IWinInetInfo_RemoteQueryOption_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IWinInetInfo_QueryOption_Proxy(
@@ -1074,7 +1071,7 @@
 
 #ifndef __IWinInetHttpInfo_FWD_DEFINED__
 #define __IWinInetHttpInfo_FWD_DEFINED__
-typedef struct IWinInetHttpInfo IWinInetHttpInfo;
+typedef interface IWinInetHttpInfo IWinInetHttpInfo;
 #endif
 
 typedef IWinInetHttpInfo *LPWININETHTTPINFO;
@@ -1086,7 +1083,7 @@
 
 DEFINE_GUID(IID_IWinInetHttpInfo, 0x79eac9d8, 0xbafa, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IWinInetHttpInfo : public IWinInetInfo
+interface IWinInetHttpInfo : public IWinInetInfo
 {
     virtual HRESULT STDMETHODCALLTYPE QueryInfo(
         DWORD dwOption,
@@ -1097,11 +1094,7 @@
 
 };
 #else
-typedef struct IWinInetHttpInfoVtbl IWinInetHttpInfoVtbl;
-struct IWinInetHttpInfo {
-    const IWinInetHttpInfoVtbl* lpVtbl;
-};
-struct IWinInetHttpInfoVtbl {
+typedef struct IWinInetHttpInfoVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -1133,6 +1126,9 @@
         DWORD* pdwReserved);
 
     END_INTERFACE
+} IWinInetHttpInfoVtbl;
+interface IWinInetHttpInfo {
+    const IWinInetHttpInfoVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -1156,8 +1152,8 @@
     DWORD* pdwFlags,
     DWORD* pdwReserved);
 void __RPC_STUB IWinInetHttpInfo_RemoteQueryInfo_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IWinInetHttpInfo_QueryInfo_Proxy(
@@ -1179,7 +1175,7 @@
 
 #ifndef __IPersistMoniker_FWD_DEFINED__
 #define __IPersistMoniker_FWD_DEFINED__
-typedef struct IPersistMoniker IPersistMoniker;
+typedef interface IPersistMoniker IPersistMoniker;
 #endif
 
 typedef IPersistMoniker *LPPERSISTMONIKER;
@@ -1191,7 +1187,7 @@
 
 DEFINE_GUID(IID_IPersistMoniker, 0x79eac9c9, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IPersistMoniker : public IUnknown
+interface IPersistMoniker : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE GetClassID(
         CLSID* pClassID) = 0;
@@ -1219,11 +1215,7 @@
 
 };
 #else
-typedef struct IPersistMonikerVtbl IPersistMonikerVtbl;
-struct IPersistMoniker {
-    const IPersistMonikerVtbl* lpVtbl;
-};
-struct IPersistMonikerVtbl {
+typedef struct IPersistMonikerVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -1269,6 +1261,9 @@
         IMoniker** ppimkName);
 
     END_INTERFACE
+} IPersistMonikerVtbl;
+interface IPersistMoniker {
+    const IPersistMonikerVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -1291,15 +1286,15 @@
     IPersistMoniker* This,
     CLSID* pClassID);
 void __RPC_STUB IPersistMoniker_GetClassID_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IPersistMoniker_IsDirty_Proxy(
     IPersistMoniker* This);
 void __RPC_STUB IPersistMoniker_IsDirty_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IPersistMoniker_Load_Proxy(
@@ -1309,8 +1304,8 @@
     LPBC pibc,
     DWORD grfMode);
 void __RPC_STUB IPersistMoniker_Load_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IPersistMoniker_Save_Proxy(
@@ -1319,8 +1314,8 @@
     LPBC pbc,
     BOOL fRemember);
 void __RPC_STUB IPersistMoniker_Save_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IPersistMoniker_SaveCompleted_Proxy(
@@ -1328,16 +1323,16 @@
     IMoniker* pimkName,
     LPBC pibc);
 void __RPC_STUB IPersistMoniker_SaveCompleted_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IPersistMoniker_GetCurMoniker_Proxy(
     IPersistMoniker* This,
     IMoniker** ppimkName);
 void __RPC_STUB IPersistMoniker_GetCurMoniker_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -1345,7 +1340,7 @@
 
 #ifndef __IMonikerProp_FWD_DEFINED__
 #define __IMonikerProp_FWD_DEFINED__
-typedef struct IMonikerProp IMonikerProp;
+typedef interface IMonikerProp IMonikerProp;
 #endif
 
 typedef IMonikerProp *LPMONIKERPROP;
@@ -1361,7 +1356,7 @@
 
 DEFINE_GUID(IID_IMonikerProp, 0xa5ca5f7f, 0x1847, 0x4d87, 0x9c,0x5b, 0x91,0x85,0x09,0xf7,0x51,0x1d);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IMonikerProp : public IUnknown
+interface IMonikerProp : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE PutProperty(
         MONIKERPROPERTY mkp,
@@ -1369,11 +1364,7 @@
 
 };
 #else
-typedef struct IMonikerPropVtbl IMonikerPropVtbl;
-struct IMonikerProp {
-    const IMonikerPropVtbl* lpVtbl;
-};
-struct IMonikerPropVtbl {
+typedef struct IMonikerPropVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -1395,6 +1386,9 @@
         LPCWSTR val);
 
     END_INTERFACE
+} IMonikerPropVtbl;
+interface IMonikerProp {
+    const IMonikerPropVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -1413,8 +1407,8 @@
     MONIKERPROPERTY mkp,
     LPCWSTR val);
 void __RPC_STUB IMonikerProp_PutProperty_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -1422,7 +1416,7 @@
 
 #ifndef __IInternetBindInfo_FWD_DEFINED__
 #define __IInternetBindInfo_FWD_DEFINED__
-typedef struct IInternetBindInfo IInternetBindInfo;
+typedef interface IInternetBindInfo IInternetBindInfo;
 #endif
 
 typedef IInternetBindInfo *LPIINTERNETBINDINFO;
@@ -1453,7 +1447,7 @@
 
 DEFINE_GUID(IID_IInternetBindInfo, 0x79eac9e1, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IInternetBindInfo : public IUnknown
+interface IInternetBindInfo : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE GetBindInfo(
         DWORD* grfBINDF,
@@ -1467,11 +1461,7 @@
 
 };
 #else
-typedef struct IInternetBindInfoVtbl IInternetBindInfoVtbl;
-struct IInternetBindInfo {
-    const IInternetBindInfoVtbl* lpVtbl;
-};
-struct IInternetBindInfoVtbl {
+typedef struct IInternetBindInfoVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -1500,6 +1490,9 @@
         ULONG* pcElFetched);
 
     END_INTERFACE
+} IInternetBindInfoVtbl;
+interface IInternetBindInfo {
+    const IInternetBindInfoVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -1519,8 +1512,8 @@
     DWORD* grfBINDF,
     BINDINFO* pbindinfo);
 void __RPC_STUB IInternetBindInfo_GetBindInfo_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IInternetBindInfo_GetBindString_Proxy(
@@ -1530,8 +1523,8 @@
     ULONG cEl,
     ULONG* pcElFetched);
 void __RPC_STUB IInternetBindInfo_GetBindString_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 
@@ -1539,7 +1532,7 @@
 
 #ifndef __IInternetPriority_FWD_DEFINED__
 #define __IInternetPriority_FWD_DEFINED__
-typedef struct IInternetPriority IInternetPriority;
+typedef interface IInternetPriority IInternetPriority;
 #endif
 
 typedef IInternetPriority *LPIINTERNETPRIORITY;
@@ -1551,7 +1544,7 @@
 
 DEFINE_GUID(IID_IInternetPriority, 0x79eac9eb, 0xbaf9, 0x11ce, 0x8c,0x82, 0x00,0xaa,0x00,0x4b,0xa9,0x0b);
 #if defined(__cplusplus) && !defined(CINTERFACE)
-struct IInternetPriority : public IUnknown
+interface IInternetPriority : public IUnknown
 {
     virtual HRESULT STDMETHODCALLTYPE SetPriority(
         LONG nPriority) = 0;
@@ -1561,11 +1554,7 @@
 
 };
 #else
-typedef struct IInternetPriorityVtbl IInternetPriorityVtbl;
-struct IInternetPriority {
-    const IInternetPriorityVtbl* lpVtbl;
-};
-struct IInternetPriorityVtbl {
+typedef struct IInternetPriorityVtbl {
     BEGIN_INTERFACE
 
     /*** IUnknown methods ***/
@@ -1590,6 +1579,9 @@
         LONG* pnPriority);
 
     END_INTERFACE
+} IInternetPriorityVtbl;
+interface IInternetPriority {
+    const IInternetPriorityVtbl* lpVtbl;
 };
 
 #ifdef COBJMACROS
@@ -1608,16 +1600,16 @@
     IInternetPriority* This,
     LONG nPriority);
 void __RPC_STUB IInternetPriority_SetPriority_Stub(
-    struct IRpcStubBuffer* This,
-    struct IRpcChannelBuffer* pRpcChannelBuffer,
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
 HRESULT CALLBACK IInternetPriority_GetPriority_Proxy(
     IInternetPriority* This,
     LONG* pnPriority);
[truncated at 1000 lines; 906 more skipped]