I'm going to try to post this without having to paste in hundreds of lines
of code.
I'm trying to override IInternetSecuri tyManager. I'm taking sort of a
minimalist approach and adding code as I take each step because I'm not 100%
sure about what I'm doing here.
First of all, I've created a WebBrowser class. It is defined as:
public class WebBrowser : AxSHDocVw.AxWeb Browser,
IOleClientSite,
IInternetSecuri tyManager,
IDocHostUIHandl er,
IServiceProvide r
The relevant interface definitions are listed at the bottom of this post.
The interface for IDocHostUIHandl er comes from MsHtmHstInterop .dll.
Now, for every implementation, I'm doing a Debug.WriteLine () with the method
name so I can see what's getting called.
My QueryService implementation is as follows:
public void QueryService(re f Guid guidService, ref Guid riid, out object
ppvObject)
{
Debug.WriteLine ("QueryService" );
Guid guid1 = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b");
if (guidService == guid1 &&
riid == guid1)
{
ppvObject = (object) this;
return;
}
ppvObject = null;
throw new COMException("" , E_NO_INTERFACE) ;
}
QueryService gets called a bunch of times, twice matching the
IInternetSecuri tyManager guid.
The only other two methods called are GetHostInfo and GetOptionKeyPat h. Both
methods do:
throw new COMException("" , S_OK);
None of the methods in the IInternetSecuri tyManager interface implementation
get called.
When I call:
_webBrowser.Nav igate2(ref page, ref ob, ref ob, ref ob, ref ob);
where page is: "about:blan k"
After a number of QueryService calls, the two other calls mentioned, and a
bunch more QueryService calls, the Navigate2 throws a
System.Executio nEngineExceptio n and I'm dead in the water.
Anyone have any ideas? Thanks.
Interface definitions are below:
[ComImport,
Guid("00000118-0000-0000-C000-000000000046"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]
public interface IOleClientSite
{
void SaveObject();
void GetMoniker(uint dwAssign, uint dwWhichMoniker, ref object ppmk);
void GetContainer(re f object ppContainer);
void ShowObject();
void OnShowWindow(bo ol fShow);
void RequestNewObjec tLayout();
}
[ComImport, GuidAttribute(" 79EAC9EE-BAF9-11CE-8C82-00AA004BA90B")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown)]
public interface IInternetSecuri tyManager
{
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int SetSecuritySite ([In] IntPtr pSite);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int GetSecuritySite ([Out] IntPtr pSite);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int MapUrlToZone([In,MarshalAs(Un managedType.LPW Str)] string pwszUrl,
out UInt32 pdwZone, UInt32 dwFlags);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int GetSecurityId([MarshalAs(Unman agedType.LPWStr )] string pwszUrl,
[MarshalAs(Unman agedType.LPArra y)] byte[] pbSecurityId,
ref UInt32 pcbSecurityId, uint dwReserved);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int ProcessUrlActio n([In,MarshalAs(Un managedType.LPW Str)] string
pwszUrl,
UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy,
byte pContext, UInt32 cbContext, UInt32 dwFlags,
UInt32 dwReserved);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int QueryCustomPoli cy([In,MarshalAs(Un managedType.LPW Str)] string
pwszUrl,
ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy,
ref byte pContext, UInt32 cbContext, UInt32 dwReserved);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int SetZoneMapping( UInt32 dwZone,
[In,MarshalAs(Un managedType.LPW Str)] string lpszPattern,
UInt32 dwFlags);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int GetZoneMappings (UInt32 dwZone, out UCOMIEnumString ppenumString,
UInt32 dwFlags);
}
[ComImport, GuidAttribute(" 6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown)]
public interface IServiceProvide r
{
void QueryService(re f Guid guidService, ref Guid riid,
[MarshalAs(Unman agedType.Interf ace)] out object ppvObject);
}
of code.
I'm trying to override IInternetSecuri tyManager. I'm taking sort of a
minimalist approach and adding code as I take each step because I'm not 100%
sure about what I'm doing here.
First of all, I've created a WebBrowser class. It is defined as:
public class WebBrowser : AxSHDocVw.AxWeb Browser,
IOleClientSite,
IInternetSecuri tyManager,
IDocHostUIHandl er,
IServiceProvide r
The relevant interface definitions are listed at the bottom of this post.
The interface for IDocHostUIHandl er comes from MsHtmHstInterop .dll.
Now, for every implementation, I'm doing a Debug.WriteLine () with the method
name so I can see what's getting called.
My QueryService implementation is as follows:
public void QueryService(re f Guid guidService, ref Guid riid, out object
ppvObject)
{
Debug.WriteLine ("QueryService" );
Guid guid1 = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b");
if (guidService == guid1 &&
riid == guid1)
{
ppvObject = (object) this;
return;
}
ppvObject = null;
throw new COMException("" , E_NO_INTERFACE) ;
}
QueryService gets called a bunch of times, twice matching the
IInternetSecuri tyManager guid.
The only other two methods called are GetHostInfo and GetOptionKeyPat h. Both
methods do:
throw new COMException("" , S_OK);
None of the methods in the IInternetSecuri tyManager interface implementation
get called.
When I call:
_webBrowser.Nav igate2(ref page, ref ob, ref ob, ref ob, ref ob);
where page is: "about:blan k"
After a number of QueryService calls, the two other calls mentioned, and a
bunch more QueryService calls, the Navigate2 throws a
System.Executio nEngineExceptio n and I'm dead in the water.
Anyone have any ideas? Thanks.
Interface definitions are below:
[ComImport,
Guid("00000118-0000-0000-C000-000000000046"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]
public interface IOleClientSite
{
void SaveObject();
void GetMoniker(uint dwAssign, uint dwWhichMoniker, ref object ppmk);
void GetContainer(re f object ppContainer);
void ShowObject();
void OnShowWindow(bo ol fShow);
void RequestNewObjec tLayout();
}
[ComImport, GuidAttribute(" 79EAC9EE-BAF9-11CE-8C82-00AA004BA90B")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown)]
public interface IInternetSecuri tyManager
{
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int SetSecuritySite ([In] IntPtr pSite);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int GetSecuritySite ([Out] IntPtr pSite);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int MapUrlToZone([In,MarshalAs(Un managedType.LPW Str)] string pwszUrl,
out UInt32 pdwZone, UInt32 dwFlags);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int GetSecurityId([MarshalAs(Unman agedType.LPWStr )] string pwszUrl,
[MarshalAs(Unman agedType.LPArra y)] byte[] pbSecurityId,
ref UInt32 pcbSecurityId, uint dwReserved);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int ProcessUrlActio n([In,MarshalAs(Un managedType.LPW Str)] string
pwszUrl,
UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy,
byte pContext, UInt32 cbContext, UInt32 dwFlags,
UInt32 dwReserved);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int QueryCustomPoli cy([In,MarshalAs(Un managedType.LPW Str)] string
pwszUrl,
ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy,
ref byte pContext, UInt32 cbContext, UInt32 dwReserved);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int SetZoneMapping( UInt32 dwZone,
[In,MarshalAs(Un managedType.LPW Str)] string lpszPattern,
UInt32 dwFlags);
[return: MarshalAs(Unman agedType.I4)][PreserveSig]
int GetZoneMappings (UInt32 dwZone, out UCOMIEnumString ppenumString,
UInt32 dwFlags);
}
[ComImport, GuidAttribute(" 6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown)]
public interface IServiceProvide r
{
void QueryService(re f Guid guidService, ref Guid riid,
[MarshalAs(Unman agedType.Interf ace)] out object ppvObject);
}
Comment